Skip to content

Static check for in-place edits of hash-pinned bytes (flags #6318's 42 stale pins; no κ) - #6319

Open
apoursh wants to merge 1 commit into
CrocSwap:mainfrom
apoursh:tools/check-pinned-edits
Open

apoursh wants to merge 1 commit into
CrocSwap:mainfrom
apoursh:tools/check-pinned-edits

Conversation

@apoursh

@apoursh apoursh commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds scripts/check_pinned_edits.py, a standard-library static check for one class of PR intake failure: a branch rewrites bytes that other files pin by SHA-256. Existing guards (verify_selected_result.py, check_selected_ci_inputs.py) cover the selected record and its replay inputs. Neither covers the many research packages whose SOURCES.json, receipts or READMEs pin a file.

For each file the branch modifies or deletes, the script hashes the merge-base bytes and runs one git grep -F over the merge-base tree for the full digests. It then classifies each pinning file at the head:

  • stale: the old digest is still present, so that check fails or describes bytes that no longer exist
  • repinned: the pinner was rewritten, so byte checks pass, but frozen evidence may have changed
  • pinner_removed: the pinner was deleted

Exit 1 only for a stale pin on a file under research/ or upstream/, the paths CONTRIBUTING/AGENTS declare frozen. Living records (selected record, task catalogue, docs, shared scripts) are routinely updated while older packages keep their digest as context, so their stale pins are advisory unless --strict. A short pointer is added to docs/research/pr-intake.md.

Evidence (macOS, Python 3.14.8, main 2485805a6)

Diff Result Exit
#6318 at c3fdf0b8 4 modified files, 42 stale pins on frozen files across 26 pinners, incl. certificates/selected-result.json source_certificate_sha256, certificates/frontier6030-source.json, pr6030-audit/{INPUTS,SOURCE-REUSE}.json 1
main~30..main 44 modified files, 0 stale frozen pins; 1 frozen README edited with its manifest → REPINNED; 1,281 advisory living-record pins 0
#6314, #6316, #6317 (additive packages) 0 modified files 0
this branch 1 modified doc, no pins 0

Independently of this script, main's verify_selected_result.check() against the #6318 tree fails with Selected package inventory or bytes changed, and passes on main. About 10 s on the full checkout.

tests/test_check_pinned_edits.py (6 tests, temporary git repos) covers: an unpinned edit, an in-place edit with three stale pinners, repinned/removed pinners, deletion beside a binary file, a living-record update (advisory vs --strict), and merge-base use after main moves. Passes under python3 -B and python3 -O -B.

Scope and limits

Static byte check of a single diff. It executes no contribution code and is not a replay, review or mathematical check. Only full lowercase 64-hex SHA-256 digests in text files are found. Abbreviated digests, other hashes and pins over decompressed or canonical payloads are missed, so an empty report does not prove frozen evidence is unchanged. The frozen-path rule is a prefix heuristic taken from repository policy. Not wired into CI; a maintainer could add it to the plan job if wanted.

Open next questions

Related: review of #6318 posted there. Predecessor guards: scripts/check_selected_ci_inputs.py (Sagar Thakrar), scripts/check_research_commit.py (ywz65).

Prepared with substantial AI assistance (Claude Code, Anthropic). Apache-2.0.

🤖 Generated with Claude Code

scripts/check_pinned_edits.py hashes the merge-base bytes of every file a
branch modifies or deletes, finds every text file that pins that SHA-256,
and classifies each pin at the head as stale, repinned or pinner_removed.
Stale pins on frozen research/ and upstream/ files fail; living records
are advisory unless --strict.

On PR CrocSwap#6318 it reports 42 stale pins on four frozen files, including
certificates/selected-result.json's source_certificate_sha256. On the
last 30 main commits it reports none on frozen files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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