Repository navigation
Conversation
Since the receipt shim refactor (4a23e31, #116), the trust pins live in scripts/receipt_pins.py, but the gate surface still listed only the files that held them before. receipt's append gate calls a proposal gate-changing only when it touches gate_surface, so a resolver-shaped append that also edited the pins, or bumped receipt in pyproject.toml and uv.lock, was judged as plain data: accepted, and never named. Reproduced with the base gate invoked as the trusted CI job invokes it: 3dd95a0's gate accepted the release-20 append plus a receipt_pins.py edit as "+5 appended vs base, release 20", and #299's gate accepted #297's seven rows plus a pins edit as "+7 appended vs base, release 21". The surface now covers: - scripts/**: the judge runs a script there, so scripts/ is sys.path[0], and both pull request jobs also put it on PYTHONPATH. A new module there shadows imports (the standard library's included), and a sitecustomize.py runs at startup. Both were observed. - pyproject.toml and uv.lock, which pick the receipt version the judge runs, and uv.toml, .python-version and .venv/**, which uv also reads from the project it provisions the judge from. Each was observed to change what `uv sync --locked --no-dev --project <dir>` and `uv run` do. The same candidates are now refused as mixed, naming the decider, while both pure appends still pass and a pins-only change is reported as gate-only. The resolver's proposals change only ledger/** and releases/manifests/**, so they stay data proposals. Tests: every decider is refused as mixed beside a witnessed append and named when changed alone; a pure append beside unchanged deciders passes; an audit-hook run shows every file the gate opens or imports from its own checkout is on the surface; and the shim's surface is pinned as a deliberate superset of the originals'. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Arch checks is red for a reason that predates this PR: |
There was a problem hiding this comment.
One gap in the invariant this PR states ("every file in the judging (base) checkout that can decide a verdict is on gate_surface"):
The repo root is on the judge's sys.path, so a root sitecustomize.py runs in the judge. .github/workflows/thesis-facts-append.yml:102 builds the judge's environment with uv sync --locked --no-dev --project "$base_gate", without --no-install-project. pyproject.toml builds with hatchling (packages = ["arch", "db", "micro", "calibration", "packages"]) and has no [tool.uv] package = false, so uv installs the base checkout editable (uv.lock:1643, source = { editable = "." }). Hatchling's editable .pth adds the repository root to sys.path, and site then imports sitecustomize from there at startup. A root sitecustomize.py is on neither gate_surface (scripts/receipt_pins.py:89-111) nor the data surface. Going by this PR's description of how receipt 0.6.2 treats unclassified files (dropped on the data path), a ledger append that also adds one would pass as data and go unnamed. That is the same class as the scripts/receipt_pins.py case this PR fixes.
Reproduced on a scratch project with the same build config, using the job's exact invocation from another cwd: PYTHONPATH=$P/scripts PYTHONNOUSERSITE=1 uv run --locked --no-dev --project $P python $P/scripts/judge.py. The venv gets _editable_impl_<name>.pth pointing at the project root, and a root sitecustomize.py executed during the judge script.
The gate scripts import only the stdlib and receipt, so the simplest fix is --no-install-project on the judge's uv sync/uv run (or [tool.uv] package = false), plus a regression case with a root sitecustomize.py in tests/test_thesis_append_shim_isolation.py. That also takes arch/, db/ and the rest off the judge's import path. Adding root sitecustomize.py to gate_surface is the narrower alternative. Until one of these lands, the new README sentence that the surface "lists every base-checkout file that can decide a verdict" overstates it.
Review drafted with AI assistance and checked against the code at a7c013a.
…fix/gate-surface-trust-pins Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
All of scripts/ on the surface would refuse a catalog-builder change shipped with the ledger/series_catalog.json it generates, as #128 did. The catalog tests require the two to land together, so that shape could not be split. The surface now lists the gate's own scripts and receipt_pins.py, plus the files that set up its interpreter and environment: scripts/sitecustomize.py, scripts/__pycache__/** (Python loads an unchecked-hash .pyc there in place of its source; observed), pyproject.toml, uv.lock, uv.toml, .python-version and .venv/**. A new module under scripts/ that shadows one of the gate's imports is now off the surface. A strict-xfail test records that limit; the fix is for the gate to stop importing from scripts/. Tests: a builder change beside an append stays a data proposal; the decider list gains the unchecked-hash .pyc; fixtures force-add the changed decider so an ignore file cannot drop it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A "dir/**" entry matches only paths below dir, so a symlink committed at .venv or scripts/__pycache__ itself was unclassified and passed beside a ledger append. List each such directory bare as well, with a test that a symlink there is refused as mixed. Add the other files that decide the judge's environment or the anchor bytes it checks out: .python-versions, hatch.toml and hatch_build.py (uv installs this project with hatchling), a root sitecustomize.py (the editable install puts the root on sys.path), and .gitattributes and releases/.gitattributes. Record the limit that remains: a new module on the judge's import path, under scripts/ or at the root, and the project's own build inputs such as README.md. Running the judge isolated and without installing the project closes it. Pin the exact surface and the exact widening over the original gate in the tests, and let the shadowing xfail pass only on an AssertionError. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Git applies scripts/.gitattributes, .github/.gitattributes and .github/workflows/.gitattributes when it checks out the judge. receipt 0.6.2 already refuses filter, ident and working-tree-encoding on every surface path at any depth, and Python reads either line ending, so none of the three can change a verdict today. Listing them keeps that from depending on the receipt version. A structural test now checks that every .gitattributes above a surface entry is on the surface. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Both pull request jobs check the base commit out to run its gate. Git applied the base's .gitattributes to that checkout, at every depth. A boolean working-tree-encoding, or a required filter whose smudge fails, then stops the checkout before it writes a file. The job fails on every later pull request, the one that removes the file included, until an admin steps in. Two pull requests that each pass alone can merge into such a base: one adds the attribute, the other the file it names. An encoding on the gate's scripts or anchors rewrites the bytes the judge runs from or pins; receipt refuses a proposal that adds one, but that is a property of the receipt version. Both jobs now check the base out with --attr-source set to the empty tree, so the judge runs from its committed bytes whatever the base's attributes say. Under the root .gitattributes today (text eol=lf, binary and -text) a Linux checkout writes the committed bytes either way. The trusted job's candidate keeps its attributes: if they stop its checkout, that refuses the candidate. An older git rejects --attr-source as an unknown option instead of ignoring it, as it would attr.tree. The step tests run the workflow's own scripts against a base holding a boolean working-tree-encoding off the surface, and one holding an encoding on the gate's scripts. The pull request that removes either is judged on both paths, and the judge's scripts and anchors match their committed bytes. The control takes the empty tree out of the trusted job's step, and git refuses the checkout, or Python the rewritten gate. Reported by the #308 session's attribute check. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Both pull request jobs check the base commit out to run its gate, and git applied the base's .gitattributes to that checkout at every depth. Some attributes stop the checkout partway, with exit 128: a boolean working-tree-encoding, or a required filter whose smudge fails. The job then fails on every later pull request, the one that removes the file included, until an admin steps in. Two pull requests that each pass alone can merge into such a base: one adds the attribute, the other the file it names. Other attributes rewrite the bytes the judge runs from or pins. An encoding on the gate's scripts stops Python; receipt refuses a proposal that adds one, but that is a property of the receipt version. eol=crlf on the trust anchors, which receipt does not refuse, makes the gate refuse every append. Both jobs now check the base out with --attr-source set to the empty tree, so the judge runs from its committed bytes whatever the base's attributes say. The runner's own git config still applies; GitHub's ubuntu runners set no core.autocrlf or core.attributesFile. Under the root .gitattributes today (text eol=lf, binary and -text) a checkout of this repository writes the same bytes with and without attributes. The trusted job's candidate keeps its attributes: if they stop its checkout, that refuses the candidate. An older git rejects --attr-source as an unknown option instead of ignoring it, as it would attr.tree. The step tests run the workflow's own scripts against three bases: one holding a boolean working-tree-encoding off the surface, one an encoding on the gate's scripts, and one eol=crlf on the anchors. On both paths, the pull request that removes either of the first two is judged, the witnessed append beside the third is accepted, and the judge's scripts and anchors match their committed bytes. The control takes the empty tree out of the trusted job's step: git refuses the checkout, Python the rewritten gate, or the gate the rewritten anchors. The step harness now sets LC_ALL=C, so git's messages are untranslated. The README and the comments say where the attributes still apply: the push path, a local run, and the trusted job until the default branch carries this workflow. Reported by the #308 session's attribute check. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Summary
The append gate's
gate_surfacedid not match the files that decide its verdicts. Since the receipt shim refactor (4a23e31, #116, 2026-07-25), the trust pins have lived inscripts/receipt_pins.py. The surface still listed only the scripts that held the pins before. It also never listedpyproject.tomloruv.lock, which pick the receipt version the judge runs.receipt 0.6.2 treats a proposal as gate-changing only when it touches
gate_surface(append_gate.py:_classify_surfaces,check_surface_separation). It refuses a proposal that mixes data and gate changes, and drops unclassified changes on the data path. So an append that also edited the pins passed as plain data, and the gate never named the change. The independent review of #299 found this by reading the code; this PR reproduces it by running the gate.Invariant (trust boundary). Every file in the judging (base) checkout that decides the gate's verdict is on
gate_surface. That covers:.gitattributesgit applies to those files when it checks out the judge.The exceptions are the open limits recorded below.
Reproduction (before the fix)
These runs used the base gate exactly as the "Trusted base append gate" job runs it:
PYTHONPATH=$J/scripts PYTHONNOUSERSITE=1 uv run --locked --no-dev --project $J python $J/scripts/check_thesis_facts_append.py --root <clone> --commit <c> --base-ref <b>, from another cwd.receipt_pins.pyedit, vs d77afe2OK: 221 rows, immutable prefix 128, +5 appended vs base, release 20OK: 228 rows, immutable prefix 128, +7 appended vs base, release 21OK ... +7 appended vs base, release 21The mixed proposal and the pure one got the same verdict line. With this PR's surface, both mixed candidates are refused:
mixed data/gate proposal is forbidden: ... GATE_SURFACE changes=['scripts/receipt_pins.py']. Both pure appends still pass, and a pins-only edit is reported asgate-only proposal; ... GATE_SURFACE changes=['scripts/receipt_pins.py'].The surface
scripts/check_thesis_facts_append.py,verify_release_chain.py,canonical_json.py,cut_release_manifest.py,.github/workflows/thesis-facts-append.yml,releases/anchors/**scripts/receipt_pins.pyscripts/sitecustomize.pyscripts/onPYTHONPATH; a newsitecustomize.pythere ran at interpreter startup (observed)sitecustomize.py(root).pthputs the root onsys.path, wheresitelooks forsitecustomizescripts/__pycache__,scripts/__pycache__/**.pycwas loaded in place of its source (observed: printedforgedwhile the source saidhonest)pyproject.toml,uv.lockuv.toml,.python-version,.python-versionsuv sync --locked --no-dev --project <dir>failed on a projectuv.tomlwithrequired-version = "==0.0.1", a.python-versionof 3.12 switcheduv runto 3.12.14, and a lone.python-versionsof 3.12 switched uv 0.11.7's interpreter choice from 3.15 to 3.12 (all observed).venv,.venv/**site-packages/*.pthsurviveduv sync --lockedand ran onuv run(observed, same machine; on CI the committed venv's interpreter path would also have to exist)hatch.toml,hatch_build.pyhatch.tomlover[tool.hatch]and runs a configured build hook.gitattributes,releases/.gitattributeseolchange rewrites the anchor bytes the pins check, and every later proposal is refused, including the one that reverts itscripts/.gitattributes,.github/.gitattributes,.github/workflows/.gitattributesreleases/anchorsdir/**entryBare directory entries. receipt matches
dir/**only for paths belowdir. So a symlink committed at.venvorscripts/__pycache__itself was unclassified, and it passed beside a ledger append. Eachdir/**entry is now also listed bare, and a test commits such a symlink.Why not all of
scripts/. An earlier revision listedscripts/**. That would refuse a catalog-builder change shipped together with theledger/series_catalog.jsonit generates, which is the shape of #128. The required checktest_build_series_catalog.py::test_committed_catalog_is_current_and_validassertsbsc.render(catalog) == committed_text, so that shape cannot be split. The gate never imports the builder, so editing it cannot change a verdict.Nested attribute files. receipt 0.6.2 refuses
filter,identandworking-tree-encodingon every surface path, and it reads.gitattributesat every depth. So a data PR whosescripts/.gitattributessets*.py working-tree-encoding=UTF-16LEwas refused (transforming attribute working-tree-encoding applies to protected path scripts/canonical_json.py), and so wereident,filter, a case variant and the.github/files (all observed with the e0f6734 judge). Without that refusal the encoding would matter: a judge checked out under it cannot run its scripts, and in a test repositoryworking-tree-encoding=UTF-7rewroteprint(3 + 2)asprint(3 2)(git 2.55.0).textandeolpass, and a judge with CRLF scripts gave byte-identical output over 9 cases. The three files are on the surface, and a test checks that every.gitattributesabove a surface entry is on it.Open limits. These are about how the workflow runs the judge, so this list cannot close them:
scripts/issys.path[0]and is onPYTHONPATH. Observed: ascripts/tempfile.pyreplaced the standard-library module. Ascripts/receipt/orscripts/receipt_pins/package would also count.sitecustomize/package.README.md. The editable build reads it..gitattributesin any directory can abort the judge's whole checkout, for example with a booleanworking-tree-encodingon a file that exists (observed in a test repository: git exits 128 and writes no files). The trusted job checks out the candidate the same way, so I expect such a PR to fail its own check; it would take a stale merge of two passing PRs or a direct push (inferred, not run). Checking the judge out with an empty attribute tree (git -c attr.tree=<empty tree>) prevents it (observed).A strict-xfail test records the shadowing cases. The fix is to run the judge isolated (
python -I) and without installing this project (uv sync --no-install-project,uv run --no-sync). That is a workflow change, in #459 (gate-only, stacked on this PR); the checkout abort has been reported for it too.Effects on other PRs
This PR itself is judged by the current base gate, which does not yet see
receipt_pins.py. It passes as data (+0 appended) without naming the change. The new surface applies to PRs whose base includes this merge.Resolver proposals stay pure data. ThesisInstitute/thesis
scripts/resolve_pending.pycommits only:ledger/official_observations.jsonl,ledger/series_catalog.jsonandledger/series_uuid_registry.jsonl;releases/manifests/<release>.*files;tests/fixtures/series_catalog/, which are on neither surface.Series catalog: canonical registry for the thesis fact ledger #128's and Fold seven entity-drift lineages into their economy/aggregate siblings #344's shapes are now refused as mixed, and each splits.
eol=lflines to.gitattributesfor its new ledger files. Those lines can land first, as a gate-only PR.pyproject.tomlanduv.lockwith the builder and the catalog. The dependency change can land first, as a gate-only PR.In both cases the builder and the catalog then land as data. Dependency and attribute changes decide what the judge runs and reads, so these refusals are intended.
Open PRs. None open against this base mixes data with a surface file. I checked every open PR's file list, again against the c29e1de surface: Start the append gate isolated so no base module can shadow its imports #459 is gate-only, and Reclaim a handed-over key on a curated row uuid instead of reviving it #365 touches neither surface.
releases/README.mdsays a data PR "cannot change the verifier, cutter, canonicalizer, append workflow, or anchors". That held for the verifier code, but not for the pins or the receipt version, from Repin integrity shims: vidimus==0.1.2 → receipt==0.2.0 (upstream rename) #116 until this PR. The file is immutable after genesis, so the accurate statement goes in the rootREADME.md.Unchanged. Branch protection still requires only status checks, so a gate-only PR still needs no review. This PR adds the refusal and the naming, not a review requirement.
Tests
tests/test_thesis_append_shim_isolation.pyis in the CI "Ledger observation invariants" list and in Arch checks.It covers 17 deciders:
scripts/receipt_pins.py;pyproject.toml,uv.lock,uv.toml,.python-versionand.python-versions;hatch.tomlandhatch_build.py;scripts/sitecustomize.pyand a rootsitecustomize.py;scripts/__pycache__/receipt_pins.cpython-314.pyc;.venv.pth;.gitattributes,releases/.gitattributes,scripts/.gitattributes,.github/.gitattributesand.github/workflows/.gitattributes.The cases:
.venvorscripts/__pycache__, beside an append, is refused as mixed.scripts/build_series_catalog.pychange beside an append stays a data proposal.PYTHONPATHanduv sync --projectspellings;dir/**entry also listed bare;.gitattributesabove a surface entry on the surface;raises=AssertionError) asserts that five shadowing modules are on the surface. It fails loudly once that becomes true.tests/test_receipt_shim_transparency.pypins the exact widening over the original gate's surface, using an AST read of the hash-authenticated fixture. No differential case touches a decider, so byte-identity is unaffected.Verification
At a7c013a (the
scripts/**surface), run locally on 2026-09-29:174 passed, 5 xfailed;verify_release_chain.py --full: OK.At 8438230, CI (pull-request runs):
190 passed, 7 xfailed;284 passed;240 passed, 1 skipped, 5 xfailed;The push-triggered Arch checks run failed at "Identity anchor move continues the base pin". It compared against this branch's September tip, which predates the anchor fixture; the pull-request run compares against the base and passed.
At e0f6734:
ruff checkandruff format --check(repo-pinned 0.14.10) are clean. CI passes on both the push and pull-request runs:204 passed, 10 xfailed;284 passed;240 passed, 1 skipped, 5 xfailed;OK: 351 rows, immutable prefix 128, +0 appended vs base, release 34.This push also cleared the push-run anchor check.
At c29e1de (the nested
.gitattributesentries):ruff checkandruff format --checkare clean, and the two changed test files pass locally (94 passed, 5 xfailed). CI is running. A separate run of the fullpytest tests, the classification replays (including Series catalog: canonical registry for the thesis fact ledger #128, Fold seven entity-drift lineages into their economy/aggregate siblings #344 and ascripts/.gitattributescase) and the mutation check is queued.Independent review: queued, read-only. Its report will be linked here.
🤖 Generated with Claude Code