test(loader): cover LlamaLoader.resourceMatchesFile match + content-mismatch branches#262
Merged
Merged
Conversation
…ches PR #260 added LlamaLoader.resourceMatchesFile (the fast-path reuse predicate for race-safe native-lib extraction) but unit-tested only the absent-resource -> false branch. Add its two core branches: - a present resource vs a byte-identical on-disk copy -> true (the reuse predicate itself), and - a present resource whose on-disk copy diverges (one extra trailing byte) -> false, so a stale/partial file is never mistaken for the shipped library on the reuse fast path. Uses the committed /images/test-image.jpg test-classpath fixture; pure-Java, no model or native library required. LlamaLoaderTest 25/25 green; Spotless clean. The private extractFile/moveIntoPlace atomic-move + reuse flow stays covered end-to-end by NativeLibraryLoadSmokeTest in the CI Java Tests jobs (needs the built native lib). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Qg1mYW7hHjtVvAfMeMEmPq
bernardladenthin
pushed a commit
that referenced
this pull request
Jun 21, 2026
All 18 findings from the 2026-06-20 correctness/safety audit are now merged — Tiers 1-3 in #258, the deferred LlamaLoader extraction race in #260 (regression tests in #261/#262) — but the TODO.md section still read as "(open)" and still listed every finding (including the already-done LlamaLoader item, duplicated as a Tier-3 bullet) as open work. Rewrite the section as a concise RESOLVED record: retitle the header, collapse the long per-finding "Fix:" prose into a compact ID + one-line + PR/commit checklist (the full rationale lives in the merged PRs), drop the duplicate LlamaLoader Tier-3 bullet, and move the one genuinely-open item (optional per-process extraction *directory* isolation) to the end, clearly labelled "Still open". Docs-only; net -41 lines. No code or test changes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Qg1mYW7hHjtVvAfMeMEmPq
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up test coverage for the native-lib extraction race fix (#260). That PR added
LlamaLoader.resourceMatchesFile(...)— the fast-path reuse predicate that lets extraction reuse abyte-identical existing copy instead of replacing a file a peer JVM may already have loaded — but
unit-tested only its absent-resource → false branch. This adds the two core branches:
file is never mistaken for the shipped library on the reuse fast path.
Uses the committed
src/test/resources/images/test-image.jpgclasspath fixture; the tests are pure-Javaand need no model or native library. The
@ClaudeGeneratedclass-purpose annotation is extended to mentionresourceMatchesFile.The private
extractFile/moveIntoPlaceatomic-move + reuse flow stays covered end-to-end byNativeLibraryLoadSmokeTestin the CI Java Tests jobs (which build the real native lib); it is not cleanlyunit-testable here without reflection.
Test plan
mvn test -Dtest=LlamaLoaderTest→ 25/25 green (was 23; +2 new branch tests).mvn spotless:applyno-op after formatting).Notes for reviewer
Test-only, +38/−1 in a single file (
LlamaLoaderTest.java). No public API or behavior change.🤖 Generated with Claude Code
Generated by Claude Code