Repository navigation
adopt-project.py check and execute write a neutral pin's commit: and tree_sha256: exactly as the adoption plan records them and read neither again, so a hand edit that makes the two disagree is plan ok and adoption verified, and the adopted root's own validate-pins.py then exits 1 with neutral-pin-digest-mismatch on its first run #449
Description
Lane: openreposhape-5 (openRepoShape-5)
(lane openRepoShape-5, 2026-10-12T18:54:12Z)
Found by lane 5's review of fix/adopt-pin-writes-pin-file at 7a94b6b (the fix for #273 and #339), its S3. The lane decided to keep the behaviour in that PR and to file it here (its option (c), below), so it exists once that PR lands: on main adopt-project.py writes no pin file at all (#273). Reproduced on that branch's fix-round head 74ce4d9. Not claimed.
What is wrong. Since #273, plan --pin <product>@<40 hex> reads the pin's digest (from --pin-source <clone>, or gh api) and records product, repository, commit, tree_sha256 and digest_source in the plan's pins:. check and execute read no network for a pin, by design: check holds each value to the form plan writes it in (_pin_row_problem: 40 hex, 64 hex, <owner>/<product>, one printable line), and execute renders contracts/<product lowercased>-pin.yaml from those values as they stand. Nothing asks whether the commit and the digest still belong together. The comment plan writes above pins: says "a commit or a digest edited here is one nobody read (#273)", and nothing enforces it. A plan is a file a person or an AI edits between plan and execute, so a typo, a paste from another pin, or a deliberate edit of either value reaches the adopted root, execute says adoption verified, and the first run of the root's own gate fails. That is #273's own symptom, a verified adoption over a red gate, reached by a hand edit.
SHAPE=<checkout of fix/adopt-pin-writes-pin-file> # git-filter-repo on PATH
# Every repository is local; keep the real `gh` out of reach anyway.
STUB=$(mktemp -d); printf '#!/bin/sh\nexit 97\n' > "$STUB/gh"; chmod +x "$STUB/gh"
export PATH="$STUB:$PATH" GH_TOKEN=bogus GH_CONFIG_DIR=$(mktemp -d)
export GIT_AUTHOR_NAME=T [email protected] GIT_COMMITTER_NAME=T [email protected]
D=$(mktemp -d)
# The neutral product's stand-in, at two commits A and B.
git init -q -b main "$D/openGlass" && cd "$D/openGlass" || exit 1
printf '# openGlass\n' > README.md && git add -A && git commit -qm one && A=$(git rev-parse HEAD)
mkdir contracts && printf 'schema_version: 1\n' > contracts/glass.yaml
git add -A && git commit -qm two && B=$(git rev-parse HEAD)
# The repository to adopt.
git init -q -b main "$D/Thing" && cd "$D/Thing" || exit 1
mkdir -p src/app specs/001 && printf 'print(1)\n' > src/app/main.py && printf '# spec\n' > specs/001/spec.md
printf '# Thing\n' > README.md && git add -A && git commit -qm seed
cd "$D" || exit 1
python3 "$SHAPE/adopt-project.py" plan --source "$D/Thing" --project MedxGlass --org testorg \
--elected-by 'T H' --elected-on 2026-09-02 --out plan.yaml \
--pin "openGlass@$A" --pin-source "$D/openGlass" > /dev/null; echo "plan exit $?"
# The hand edit: the plan's commit becomes B, its digest left as A's.
sed -i "s/commit: \"$A\"/commit: \"$B\"/" plan.yaml && grep -c "$B" plan.yaml
python3 "$SHAPE/adopt-project.py" check --plan plan.yaml > check.out; echo "check exit $?"; tail -n 1 check.out
python3 "$SHAPE/adopt-project.py" execute --plan plan.yaml --yes \
--local-remote-dir "$D/remotes" --work-dir "$D/work" > /dev/null; echo "execute exit $?"
git -c protocol.file.allow=always clone -q --recurse-submodules -b adopt/three-repo-shape "$D/Thing" "$D/clone"
cd "$D/clone" || exit 1
grep -E '^(commit| tree_sha256):' contracts/openglass-pin.yaml
SHAPE_PIN_SOURCE_OPENGLASS="$D/openGlass" python3 scripts/validate-pins.py > /dev/null; echo "validate-pins exit $?"Observed on 74ce4d9, Python 3.12.3, git 2.43 (sed -i is GNU's; on macOS write sed -i ''):
| step | result |
|---|---|
plan |
exit 0 |
check after the edit |
exit 0, plan ok |
execute --yes |
exit 0, adoption verified |
the clone's contracts/openglass-pin.yaml |
commit: B, tree_sha256: A's digest |
the clone's validate-pins.py, with SHAPE_PIN_SOURCE_OPENGLASS naming the stand-in |
exit 1, FINDING neutral-pin-digest-mismatch: contracts/openglass-pin.yaml: digests.tree_sha256 <A's digest> recomputed at <B> <B's digest> ($SHAPE_PIN_SOURCE_OPENGLASS) |
Editing tree_sha256: to B's digest and leaving commit: at A gives the same three exits and the same finding the other way round. An upper-cased commit or digest is the same pin and is written lower-cased (fine). A name alone, pins: [openGlass], is already plan-pin-unrecorded, and execute refuses it before any leg exists (#273).
The gate does catch it, so nothing is silent: the root's validate-pins.py reports it on the first make bootstrap, make validate or CI run, and since the fix round check says, after the pins it will write, "each pin as plan read it, not read again here: the root's own validate-pins.py recomputes its digest wherever it can read the product". But by then the leg repositories exist and the split is on a branch of the source, and the remedy is a pin bump in a project that was just adopted. Where the root's validator has no source for the product (no sibling checkout, no SHAPE_PIN_SOURCE_<PRODUCT>, no --pin-source, no gh) it skips the digest and passes.
What it should do. The author decides; the three options lane 5 weighed:
- (a)
executerecomputes each pin's digest just before it creates the leg remotes (_create_leg_remotes), from the recordeddigest_sourceclone when it still exists, elsegh api, and refuses a pin whose digest disagrees before anything exists. Against GitHubexecutealready needs the forge forgh repo create, sogh apiadds no new dependency there; with--local-remote-dirand no clone left it would needgh, whichexecutedoes not need today. - (b)
checkrecomputes when the recordeddigest_sourceclone still exists, finds a mismatch (plan-pin-digest-mismatch, a FINDING, soexecuterefuses it too), and otherwise prints one line saying the digest was not rechecked. No network at all; it catches the edit only where the clone is still on the machine. - (c) Keep the behaviour, as the PR does, and say it in the docs:
checkandexecutetrust the plan's recorded pin, the root's gate is what verifies it, and the plan comment is the instruction not to edit it. The PR body and this issue record that choice.
Whichever is chosen, check and execute must keep answering the same question of the same plan (_entry_findings is the one list both read).
How to test. In tests/test_adopt_pins.py, beside test_a_plan_whose_pin_execute_cannot_write_is_found_and_refused: write a whole pin with a_good_pin(glass), then replace its commit: with the stand-in's second commit (glass[2]), and separately its tree_sha256: with that commit's digest. Under (a), refused_before_any_leg with the new code (it needs git filter-repo's probe stubbed, as there); under (b), findings(plan) names it while the stand-in exists and says "not rechecked" once it is deleted (the module's adopted fixture deletes its copy before check for the same reason). Reverting the fix fails it. Keep the real gh unreachable: the module's stub_gh and the session gh guard already do.
Not in this issue.
- Extra keys in a hand-edited
pins:entry are ignored, as unknown keys are everywhere else in the plan. - The scaffold reads the digest and writes the file in one run, so it has no plan to edit.
tree_sha256:andcommit:in a pin file edited by hand AFTER adoption: that is what the root'svalidate-pins.pyexists to find, and it does.
Related: #273, and the PR that fixes it (fix/adopt-pin-writes-pin-file).
Activity
adopt-project.py: `plan --pin` takes `product@<40 hex>` and `execute`…
brettheap commentedon Oct 14, 2026
CLAIMED — lane openRepoShape-1, session 300f8f46-004a-4e72-8587-4f192be2e108@Eagle, 2026-10-14T22:36:46Z, for #449
Logged in
lanes/log/openRepoShape-1.mdate9c27b56280f70cbcd59d6b8f1081199953a79a3.The three reads (lane-collision-protocol Rule 1):
adopt-project.py: `check` asks no partial clone for a pin's digest, a…
Merge origin/main (2989b4c) into fix/520-adopt-check-branch-names
Merge main 66267f0 (#589, #582, #576 and eleven more) into fix/540-pi…
adopt-project.py: `plan` records `local-clone (<path>)` in the plan a…
Merge origin/main 55faad2 (#591) into fix/540-pin-source-unread, so t…
scaffold-project.py and adopt-project.py: a pin records `digest_sourc…
shape_materialize.py, adopt-project.py and bump-leg.py: a tag a clone…