Skip to content

test(loader): cover LlamaLoader.resourceMatchesFile match + content-mismatch branches#262

Merged
bernardladenthin merged 1 commit into
mainfrom
claude/eloquent-bell-hgy21r
Jun 21, 2026
Merged

test(loader): cover LlamaLoader.resourceMatchesFile match + content-mismatch branches#262
bernardladenthin merged 1 commit into
mainfrom
claude/eloquent-bell-hgy21r

Conversation

@bernardladenthin

Copy link
Copy Markdown
Owner

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 a
byte-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:

  • a present classpath 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 src/test/resources/images/test-image.jpg classpath fixture; the tests are pure-Java
and need no model or native library. The @ClaudeGenerated class-purpose annotation is extended to mention
resourceMatchesFile.

The private extractFile / moveIntoPlace atomic-move + reuse flow stays covered end-to-end by
NativeLibraryLoadSmokeTest in the CI Java Tests jobs (which build the real native lib); it is not cleanly
unit-testable here without reflection.

Test plan

  • mvn test -Dtest=LlamaLoaderTest25/25 green (was 23; +2 new branch tests).
  • Spotless clean (mvn spotless:apply no-op after formatting).
  • Test-only change — no production code touched; not in PIT scope, so the mutation gate is unaffected.

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

…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 bernardladenthin merged commit 922d82c into main Jun 21, 2026
9 of 12 checks passed
@bernardladenthin bernardladenthin deleted the claude/eloquent-bell-hgy21r branch June 21, 2026 17:19
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants