fix(snapshot): enforce the receipt inventory content_id at verify time - #483
Merged
kstonekuan merged 2 commits intoSep 10, 2026
Merged
Conversation
…cs#473 gate The gate is two refusals. The mismatch branch is held by the pinning test; deleting the missing-or-malformed branch left the whole suite green. Four shapes: absent, empty, non-string, wrong type, each through the API and the CLI exit code.
kstonekuan
approved these changes
Sep 10, 2026
Contributor
There was a problem hiding this comment.
LGTM, merging.
Pushed one commit: the missing-content_id branch had no case, so four shapes through the API and the CLI exit code.
integrity and content_id arrived in the same commit (#401), so no snapshot we wrote carries one without the other. That is what makes it unreadable input rather than damage.
Contributor
Author
|
Thanks @kstonekuan . #472 is next then i will see what i can do on (Egocentric-10K or Egocentric-100K on Hugging Face) |
4 tasks
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.
fix(snapshot): enforce the receipt inventory content_id at verify time
Closes #473.
What changed
verify_dataset_snapshotnow enforces theintegrity.content_idguarantee documented at docs/how-to/export-dataset-snapshot.md:77. After the receipt is parsed and before the per-file loop, the verifier recomputes the inventory hash from the receipt's own table and asset entries (the identical normalization the exporter uses at snapshot.py:194, via the shared_inventory_content_idhelper) and compares it against the stored value.The exit-2 decision
A
content_idthat disagrees with the recomputed inventory means the marker is internally inconsistent, which points at tampering or a truncated write, not at damaged bytes. Damaged bytes are what findings and exit 1 are for; an inconsistent receipt is unreadable input. The gate therefore raises through the sameValueErrorthe unparsable-marker path uses (snapshot.py:862), so the CLI maps it to exit 2 with no new exit code. A DAMAGED finding was considered and rejected: findings are evidence about delivered files, and the failure here is in the receipt itself, which per-file findings cannot express without inventing a new reason code for a non-file.The same handling covers a missing or malformed
content_idon a marker that carries anintegrityblock: one gate, one behavior, one exit code. Pre-#401 markers with nointegritykey keep the existingno-receiptUNVERIFIABLE path untouched.Test shape, and why
content_idcatches: the surviving entries agree with each other, so every per-file check passes; the comparison against the hash of the original set is the only witness.missingpath and passes without the fix; under the mutation run it stayed green while the pinning test went red, proving the two tests pin different behaviors.Related issues, separate PRs
Gates
15 passed in tests/test_snapshot_verify.py (13 existing + pinning test + negative control), 31 passed across the verify and dataset-snapshot suites, ruff check / ruff format / ty clean, zero non-ASCII and zero em dashes in changed files. Mutation run: inventory comparison neutered, pinning test red, negative control green, restored, all green.