Skip to content

hf: refuse listed names that end in a cache sidecar's suffix - #1048

Merged
juliankang4 merged 1 commit into
midagedev:mainfrom
juliankang4:dgx-spark-q38-fix-hf-verified-marker
Oct 31, 2026
Merged

juliankang4 merged 1 commit into
midagedev:mainfrom
juliankang4:dgx-spark-q38-fix-hf-verified-marker

Conversation

@juliankang4

Copy link
Copy Markdown
Collaborator

허브 파일 목록에 다른 파일의 .part나 .verified 이름이 있으면 그 파일을 덮어쓰던 문제를 막습니다.

Fixes #1038. Fixes #1038

What and why

A destination x.bin keeps its lock, partial download and verified marker at x.bin.lock, x.bin.part and x.bin.verified. The shared destination check refused only the .lock suffix, so a listing that held both x.bin and x.bin.verified (or x.bin.part) let the fetch of x.bin overwrite the other listed file with a digest marker (or a part file that was then renamed away).

lock_file now refuses a listed name that ends in .lock, .part or .verified, in any case, with the error the <suffix> suffix is reserved for cache sidecars. The refusal happens when that file's own fetch starts, so files listed before it are already fetched. Offline discovery (verified_entries) skips such names, so a cache an older build left does not fail the whole repository.

I kept the <file>.verified marker name instead of moving markers to another namespace: existing caches and the tools that write a marker by that name keep working, and no cache needs rehashing.

Release notes: Fixed: A listed Hugging Face file named like another file's .part or .verified sidecar is now refused instead of overwriting that file.

Code shape

  • No second copy. One private sidecar_suffix owns the suffix list; lock_file and verified_entries both call it.
  • Model code holds only architecture facts. No model file changed.
  • Dead code is gone. Nothing left unused.
  • No silent failure. A reserved name is a named InvalidInput error.
  • Comments state what is true now. No dates, issue numbers or how a bug was found.
  • No relaxed gate. No band, tolerance or lint moved.
  • cargo fmt and cargo clippy are clean on what I touched; the lint count did not go up.

Duplication found or removed (path:line), or "none": none.

What I ran

Base be3e6d336, head c591a640a; one file changed, crates/hf/src/fetch.rs. The change is host-side name checking, so no GPU gate is reached. Tests ran on a macOS CPU node.

The new test listed_files_named_like_another_files_part_or_marker_are_refused resolves x.bin together with x.bin.part, x.bin.verified and x.bin.VERIFIED in both orders, expects the reserved-suffix error, and checks that discovery over a cache holding such markers returns only x.bin. fetch_refuses_reserved_sidecar_destinations_before_touching_sidecars (the former .lock test) gains .part and .Verified.

Before the fix (test-only commit on the base):

cargo test -p bloomery-hf --lib -- fetch::tests::listed_files
test fetch::tests::listed_files_named_like_another_files_part_or_marker_are_refused ... FAILED

rc=101

After the fix, on the head:

cargo test -p bloomery-hf --lib -- fetch::tests
test fetch::tests::fetch_refuses_reserved_sidecar_destinations_before_touching_sidecars ... ok
test fetch::tests::listed_files_named_like_another_files_part_or_marker_are_refused ... ok
test fetch::tests::listed_files_named_like_another_files_records_keep_their_bytes ... ok
test result: ok. 56 passed; 0 failed

Whole crate:

cargo test -p bloomery-hf
test result: ok. 163 passed; 0 failed; 2 ignored

AI help

AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.

@github-actions github-actions Bot added the model The CPU engine and model files: crates/model, models, hf, gguf, tokenizer, jinja label Oct 31, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: MUST_FIX: Two removed test cases lack the required dated reason.

Must fix

1. Document why the two acceptance cases were removed

crates/hf/src/fetch.rs:1366 removes x.bin.part.ranges.part and x.bin.verified.part from the acceptance test without a dated reason. Their suffix is now forbidden. The review contract requires a dated reason for removed test cases; the missing comment is a mechanical kind B fix.
Record this changed expectation now so later edits do not restore obsolete acceptance cases. Replace the array line with:

        // PIN(2026-10-31): The two .part-ending cases are now rejected by the reserved-sidecar tests.
        let names = ["x.bin.part.ranges", "x.bin"];

Checked

Duplicates: 2 new definitions and 1 renamed test checked; no duplicate owner. Dryer reported no pairs.
Complexity: crapper flagged verified_entries, 16 → 17; the added suffix condition uses the shared owner. No split needed.
Silent failure: 1 new skip followed through offline discovery to exact lookup; a requested excluded name produces NoFile.
Tests: static mutation checks only. Removing the rejection at L1023 fails the refusal assertions; removing the skip at L916 makes the discovery test fail.
Gates: two acceptance cases removed without a dated reason, covered by item 1. No tolerance or lint changes.
Escape catalog: no patterns matched. This change touches cache loading, outside the inference hot paths.

Notes

Tests were not rerun: their scratch helper writes under the read-only PR tree. The PR reports a FAIL-first run and passing CPU tests. It supplies no GPU gate evidence.

🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)

Comment thread crates/hf/src/fetch.rs
"x.bin.verified.part",
"x.bin",
];
let names = ["x.bin.part.ranges", "x.bin"];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The review contract requires a dated reason for removing the two acceptance cases.

Suggested change
let names = ["x.bin.part.ranges", "x.bin"];
// PIN(2026-10-31): The two .part-ending cases are now rejected by the reserved-sidecar tests.
let names = ["x.bin.part.ranges", "x.bin"];

A listed file named x.bin.verified or x.bin.part was another listed file's
marker or part: fetching x.bin overwrote the first with its digest or took
its bytes as its own, and resolve_exact returned a path that no longer held
its listed file. The destination check that refuses .lock now refuses .part
and .verified as well, in any case, and the cache's offline discovery skips
such names an earlier version left marked instead of failing the repo.

Fixes midagedev#1038
@juliankang4
juliankang4 force-pushed the dgx-spark-q38-fix-hf-verified-marker branch from 2ea88ee to 271c12f Compare October 31, 2026 17:52

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the last review: must-fix 1 is fixed at crates/hf/src/fetch.rs:1366. The dated reason explains why the two acceptance cases were removed.

Verdict: CLEAN: The prior finding is resolved, and the interdiff adds only the requested comment.

Checked

Duplicates: 0 new items in the interdiff. Dryer reported no pairs; the shared suffix owner is unchanged.
Complexity: crapper flagged verified_entries, 16 → 17 across the full PR, from the suffix guard. The interdiff changes no executable code.
Silent failure: 0 new sites; rechecked the discovery skip. An offline request for an excluded name returns Offline wrapping NoFile.
Tests: no assertions changed. Static mutation checks: dropping the rejection at L1023 fails refusal assertions; dropping the suffix skip at L916 fails the discovery assertion. Tests were not rerun for this comment-only edit.
Gates: the required dated PIN is present; no additional gate changes.
Escape catalog: no patterns matched. Mixed-case reserved names fail before sidecar access; empty paths fail cache-path validation.

🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)

@juliankang4

Copy link
Copy Markdown
Collaborator Author

The review is done and the contribution check passed, so I'm merging this.

@juliankang4
juliankang4 merged commit c98a9c7 into midagedev:main Oct 31, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

model The CPU engine and model files: crates/model, models, hf, gguf, tokenizer, jinja

Projects

None yet

Development

Successfully merging this pull request may close these issues.

hf: listed .verified files are overwritten by cache markers

1 participant