Skip to content

SR-4c: pack hash v2 (engine) - #336

Merged
jothimani-rajendran merged 3 commits into
mainfrom
sr-4c-pack-hash-v2
Oct 27, 2026
Merged

jothimani-rajendran merged 3 commits into
mainfrom
sr-4c-pack-hash-v2

Conversation

@jothimani-rajendran

@jothimani-rajendran jothimani-rajendran commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

What

Engine step of pack hash v2 (org-plan plan/pack-hash-v2.md, item SR-4c, decision D19).

  • compute_pack_hash is v2: sha256("chock-pack-hash-v2\n" || per file: u64be(len(name)) name u64be(len(content)) content), files in UTF-8 byte order of the posix path. Specified in the docstring for a JS port.
  • v1 is private (_hash_v1), used only to recognise old hashes; accepted for all of 1.x, removed in 2.0.
  • pack_hash_matches(dir, expected): v2, or v1 only while no file in the pack holds a NUL byte.
  • Routed through it: --verify-sha and selection pins (verified_pack), local selection pins, --trust-local, the install marker's accepted hash, chock.lock verify (pack and compiled-artifacts hashes), provenance carry-over in build_lock, and chock-market.lock (v1 lock accepted while unambiguous).
  • chock.lock lockfile_version is "2"; chock-market.lock is 2. Every writer writes v2.
  • Vectors for the site's JS parity test: tests/fixtures/pack_hash_v2_vectors.json (includes a NUL pair that collides under v1, not v2).

Tests

tests/test_pack_hash_v2.py (vectors, v1 accepted/refused by NUL, every site via a spy, v1 to v2 lock migration keeping source_commit, a market lock with foreign keys refused unread). test_pack_hash_platform.py and test_marketplace.py updated to v2.

Runtime goldens

No vendored runtime or gate/ file changed, so no golden file changes. The repo-root chock.lock is untouched and still verifies under v1 (no NUL bytes); the owner's chock sync rewrites it as v2.

Not in this PR: docs/registry-and-lockfile.md still shows "lockfile_version": "1" (generated docs).

compute_pack_hash frames each file as a u64be-length-prefixed name and
content under a domain prefix, so a NUL byte in a file can no longer make
two packs collide. pack_hash_matches accepts v2, and v1 only while no file
in the pack holds a NUL byte. --verify-sha, selection pins, --trust-local,
the install marker, chock.lock verify and provenance, and chock-market.lock
all compare through it. chock.lock and chock-market.lock are version 2.

Signed-off-by: Jothi Mani Rajendran <250249270+jothimani-rajendran@users.noreply.github.com>
…ent v1 end in 2.0

Signed-off-by: Jothi Mani Rajendran <250249270+jothimani-rajendran@users.noreply.github.com>
The base ruleset requires the head to be up to date before a merge.

Signed-off-by: Jothi Mani Rajendran <250249270+jothimani-rajendran@users.noreply.github.com>
@jothimani-rajendran
jothimani-rajendran merged commit 496cf6b into main Oct 27, 2026
26 checks passed
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.

1 participant