Skip to content

Build the trusted append gate's environment without the project - #460

Draft
MaxGhenis wants to merge 4 commits into
mainfrom
fix/gate-no-scripts-imports-main
Draft

MaxGhenis wants to merge 4 commits into
mainfrom
fix/gate-no-scripts-imports-main

Conversation

@MaxGhenis

@MaxGhenis MaxGhenis commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Draft. Companion to #459.

pull_request_target loads .github/workflows/thesis-facts-append.yml from the default branch. So the trusted base gate on every pull request into codex/thesis-ledger-facts runs from main's copy. This PR carries #459's version of that file, byte for byte, as #242 did for --commit.

Change

Main's current copy starts the base gate with the base's scripts/ on PYTHONPATH and as sys.path[0], in an environment where uv installed the project editable, which puts the base checkout's root on sys.path. Most of scripts/ and the root are off the gate surface, so a data proposal can add a scripts/tempfile.py, a scripts/receipt/ package or a root sitecustomize/ package unnamed. From then on that module stands in for one the gate imports, or runs at its startup.

The new copy builds the base gate's environment with uv sync --no-install-project and starts it with uv run --no-sync ... python -I, with no PYTHONPATH. That applies to every start, both --help questions included. #459 has the full account and the end-to-end tests.

The new copy also checks the base out with an empty attribute tree (git -C "$base_gate" --attr-source="$empty_tree" checkout ...), in both pull request jobs. A .gitattributes anywhere in the base, such as a boolean working-tree-encoding that two pull requests passing alone can merge in, can then neither stop that checkout, which would fail the trusted job on every later pull request until an admin stepped in, nor rewrite the gate's scripts or trust anchors. The candidate keeps its attributes. #459 has the step tests.

Landing order

Land this before #459. Until main carries this copy, the trusted job starts every base gate the old way. A base gate from #459 then loads its pins by path, but scripts/tempfile.py, scripts/receipt/ and scripts/sitecustomize/ still reach it, and so does a root sitecustomize/ package where the interpreter has none of its own. The trusted check closes only once this copy is on main.

Either order still runs, because this copy is correct against base gates on both sides of #459:

  • Today's base gate imports its pins by name and finds them only through the root. The job sees the from scripts.receipt_pins import line in the base checkout's copy of the gate and installs the project for that base, as before, still starting it with python -I. Such a base keeps that gate's limits: scripts/ stays off sys.path, but the root is on it, last, so a root receipt_pins.py, a scripts/__init__.py or a scripts/receipt_pins/ package still reaches the old gate, and a root sitecustomize/ package runs wherever the interpreter has no sitecustomize of its own. The workflow's comments say so.
  • A base gate from Start the append gate isolated so no base module can shadow its imports #459 on loads its pins by path. The job gives it the isolated environment.

#459's tests run this file's step scripts against both kinds of base gate, and check that every start runs the base's gate, never the candidate's.

The file also picks up the ledger branch's existing tests/test_production_tsa_pins.py line in the push-path test list. No main run uses that list: the pull_request and push triggers only fire for codex/thesis-ledger-facts.

🤖 Generated with Claude Code

pull_request_target loads this file from the default branch, so the
trusted base gate on every pull request into codex/thesis-ledger-facts
runs from main's copy. That copy starts the base gate with the base's
scripts/ on PYTHONPATH and as sys.path[0]. scripts/ is mostly off the
gate surface, so a data proposal can add a scripts/tempfile.py or a
scripts/receipt/ package unnamed, and from then on it stands in for one
the gate imports.

This is the ledger branch's version of the file from
#459, byte for byte. Every start of the base gate,
both --help questions included, uses python -I and sets no PYTHONPATH.
Today's base gate still starts this way: it finds its pins as
scripts.receipt_pins through the base root that the editable project
install appends to sys.path. #459's own Append gate job ran this pairing
on ubuntu against base ca7c6fc and accepted the proposal. A base gate
from #459 on loads its pins by path. So this copy can land before or
after #459, and neither order leaves a window in which a run breaks.

The file also picks up the ledger branch's existing
tests/test_production_tsa_pins.py line in the push-path test list,
which no main run uses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Carries the thesis-ledger branch's append workflow to main byte for
byte, because pull_request_target reads main's copy. The base gate's
environment no longer installs this project, so the base checkout's
root is off its sys.path, and every start stays `python -I` with no
PYTHONPATH. A base gate that still imports its pins by name gets the
project installed, as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@MaxGhenis MaxGhenis changed the title Start the trusted append gate with python -I Build the trusted append gate's environment without the project Dec 1, 2026
MaxGhenis and others added 2 commits December 1, 2026 13:28
Carries the thesis-ledger branch's comment changes to main byte for byte:
the legacy branch keeps scripts/ off sys.path but puts the root on it,
last, so a module an old gate looks up there still reaches it, and its
deletion condition is now one that can be met.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Carries #459's workflow change into main, byte
for byte, because pull_request_target runs main's copy. Both pull
request jobs check the base commit out with --attr-source set to the
empty tree, so the judge runs from its committed bytes. A .gitattributes
anywhere in the base can no longer stop that checkout partway (a boolean
working-tree-encoding, a required filter whose smudge fails), which
would fail the trusted job on every later pull request, the one that
removes the file included. Nor can it rewrite the gate's scripts or
trust anchors. The candidate keeps its attributes. #459 holds the step
tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@MaxGhenis
MaxGhenis force-pushed the fix/gate-no-scripts-imports-main branch from a4f197b to c8e4c06 Compare December 1, 2026 20:05
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