Repository navigation
fix(bin): name the stale submodule pin behind a pooled slot refusal - #3121
Conversation
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Reviews (3): Last reviewed commit: "no-mistakes(review): bound submodule con..." | Re-trigger Greptile |
| @@ -1765,12 +1803,17 @@ freshen_spawn_worktree_base() { # <worktree> | |||
| echo "error: '$target' is not a commit for pooled worktree '$worktree'; refusing to launch from a potentially stale base" >&2 | |||
| return 1 | |||
| } | |||
| status=$(git -C "$worktree" status --porcelain) || { | |||
| status=$(git -C "$worktree" -c core.quotePath=false status --porcelain) || { | |||
There was a problem hiding this comment.
Unquoted paths remain line-delimited
For a stale submodule whose path contains a newline, core.quotePath=false emits a pathname that this line-oriented parser cannot preserve as one entry, causing the new diagnosis to fall back to the same unexplained generic refusal. Use a NUL-delimited status format so each valid Git pathname remains intact.
|
Speaking as Kun's firstmate: Reviewed HEAD Class: corrective. The refusal itself is unchanged and still touches nothing; only the message distinguishes a proven-stale submodule gitlink (names path + both pins, no remedy command) from real uncommitted work. Conservative fallbacks keep the original unclean refusal when containment cannot be proven. VISION (per rule, inspected evidence):
First-time fork CI: after that full-diff review I approved workflow runs Not merging. Waiting on the author: body has no Merge-eligible: NO. |
A pool slot whose submodule pin moved is refused with "is not clean; refusing to discard uncommitted work", while the operator's own `git status` in that slot reads clean. The message names no submodule, no pin, and no remedy, so the refusal is unreadable and the slot looks wedged for no reason. That is the failure that jammed three slots in a row when a submodule pin moved. The refusal itself was never the bug and is unchanged: the gate still refuses, and still touches nothing. It now distinguishes the one case it can prove and says what it found - the submodule, the pin the slot has, the pin the base records, and the command that clears it. The diagnosis is deliberately conservative, because ` M <path>` alone cannot tell a stale pin from real work. An entry is reported as stale only when every reported entry is a gitlink whose submodule is internally clean and whose recorded pin actually differs. A submodule holding uncommitted work, untracked files, or an unpushed commit therefore keeps the original uncommitted-work refusal, even when its pin is also stale - the remedy command would be wrong there, and the conservative refusal is the safe answer. Nothing is converged, synced, initialized, or deleted. There is no new failure path: a slot that launched before still launches, a slot that refused before still refuses, and projects that configure a submodule `ignore` are read exactly as before. Paths are read with core.quotePath=false so a non-ASCII submodule is named rather than falling back to the unreadable message. Tests keep the reproductions that prove the message is accurate: the stale-pin diagnosis (which fails against the previous refusal), work inside a submodule still refused as uncommitted work, and a stale pin carrying real work refused conservatively rather than called stale. Each asserts the slot is left untouched.
…ehind The stale-pin diagnosis printed `git submodule update --checkout` as the command that clears the slot. The containment check behind it reads local refs only and never fetches, because this gate has to stay usable offline. A remote-tracking ref that has gone stale - its upstream branch deleted or force-pushed, and never pruned - still reads as containment, so a commit that is really unpushed can look contained and that command would move the submodule off it. Naming the submodule and both pins is the whole point of the diagnosis: it turns "is not clean", on a slot whose own `git status` reads clean, into a statement of which submodule drifted and where it drifted from. The operator can choose the remedy from that, seeing the whole picture. Printing an instruction that rests on a judgement which can be fooled is worse than printing none, so it is dropped. The limitation is now stated where it applies, in the script header and beside the check itself, rather than left for a reader to discover. No fetch is added: the gate stays offline-safe by design. Nothing else changes - the same conditions are refused, the slot is still never touched, and a submodule carrying real work or an unpushed commit still keeps the conservative uncommitted-work refusal.
ce42fef to
e7d2849
Compare
|
Speaking as Kun's firstmate: Recirc after newer-activity vs stamp Class: corrective. The refusal still stands and touches nothing; only the message distinguishes a proven-stale submodule gitlink (names path + both pins, no remedy) from real uncommitted work. Conservative fallbacks keep the original unclean refusal when containment cannot be proven. Inspected the porcelain/ VISION (per rule, inspected evidence):
Attestation: First-time fork CI: already approved on the prior pass; current-HEAD CI is run Not merging. MERGEABLE / UNSTABLE: portable serial 2–4 still pending. File overlap with standing spawn-freshen holds #2622/#2693/#2154 ( This is waiting on CI, not on the author and not on the captain. Merge-eligible: NO. |
|
Speaking as Kun's firstmate: this is merged. Thank you @mkurt — really appreciate you taking the time on this. Class: corrective. The pooled-slot refusal itself is unchanged and still touches nothing; the message now names a proven-stale submodule gitlink (path + both pins, no remedy command) instead of a generic "is not clean" while VISION (per rule, inspected evidence):
No Gates: attestation |
The `Require no-mistakes` gate judged `github.event.pull_request.body` - the body as it stood when the event fired. no-mistakes pushes the head first and writes that head's attestation into the body second, so the `synchronize` payload a push raises can never carry the attestation for the head it reports on. That run is doomed by construction. That alone was survivable while the later `edited` run reported the truth. It stopped being survivable because the two sit in different concurrency groups by design (bd43c73, so a fork approval cannot collapse a pending body check), so neither cancels nor supersedes the other, and the runner is free to start them in any order. On PR kunchenguid#3121 head e7d2849 it started the synchronize job last: the edited jobs succeeded at 02:20:39 and 02:20:42, the synchronize job failed at 02:20:43, and the newest check run for the name is the verdict the PR carries. A compliant PR reported red with no way to clear it but another push. The gate now r
Intent
Fix a bug in firstmate's bin/fm-spawn.sh pool-slot refresh path: when a pooled worktree's base is reset to the new default-branch head, submodules are never synced, so the superproject moves while the submodule stays pinned to the old commit, leaving " M " residue that makes the NEXT spawn refuse the slot as possibly holding unpushed work. Observed in the field on 2026-08-24 when the inscada
uipin moved and three pooled slots jammed in a row; cleared by hand, but it recurs every time the pin moves. The refusal always lands one spawn late: the spawn that creates the residue succeeds and the following task pays for it.Measured root cause: the refresh path checks cleanliness with
git status --porcelainBEFORE the reset, then runsgit reset --hard origin/<default>, and never syncs submodules.The goal is that a pooled slot stays clean after its base is refreshed and its submodule pin matches that base, so the residue never forms - explicitly WITHOUT weakening protection: genuinely unpushed work must still be refused, hard rule 3 (never tear down unlanded work) stays intact, repos with no submodule must behave identically, and real modifications INSIDE a submodule (not merely a pointer difference) must still be refused. That last point had to be measured, not assumed.
Three measurements were required before choosing the fix's shape, with anything unmeasurable written down as "not measured" rather than guessed:
Acceptance required red-first tests: two consecutive spawns across a moving submodule pin failing before the fix, plus tests proving real unpushed work is still refused (including changes inside a submodule), that no-submodule repos are unchanged, and that concurrent pooled slots do not collide - or, if they do collide, saying so and stopping scope there.
Accepted delivered shape: rather than silently resyncing a pin, the slot explains a stale-submodule refusal instead of reporting it as merely unclean, and requires remote containment before calling a submodule pin stale, so no remedy is printed that the containment check cannot stand behind. The cleanliness gate was TIGHTENED, not loosened, using --ignore-submodules=none. Delivered on branch fm/pool-submodule-drift as changes to bin/fm-spawn.sh plus a 302-line colocated test file, 6 tests of which 2 are red-before-the-fix.
This work touches firstmate's shared tracked material, so firstmate-coding-guidelines applies. Commit trailers must not carry Co-Authored-By.
Current delivery state: this is published externally as PR #3121 against kunchenguid/firstmate. Upstream has reviewed it, approved the substance as class corrective and aligned on all seven vision points, and approved the CI workflow runs. They are withholding merge for exactly one reason: the PR body carries no no-mistakes-pipeline-attestation:v1 matching the current head, so the "Require no-mistakes" check fails. The remaining objective is to run the pipeline so the structured attestation lands on the PR body for the CURRENT head and that check turns green. Nothing about the code is in question; the shape is settled, so do not narrow or redesign it.
What Changed
freshen_spawn_worktree_basenow distinguishes a stale submodule checkout from uncommitted work: when a slot's only deviation is a submodule gitlink, the refusal reports it as a stale checkout naming the submodule and both pins instead of the generic "is not clean" message. The refusal itself still stands and the slot is left untouched — nothing is converged, reset, or removed.describe_stale_submodule_pins, which only reaches that diagnosis when every status entry is a clean submodule sitting on a different pin and the checked-out commit is already contained in one of the submodule's remotes (git log ... --not --remotes, capped at one commit). Anything unprovable — an unpushed commit, a submodule with no remote, a git error, or any non-submodule entry — falls through to the conservative uncommitted-work refusal. The diagnosis is buffered and emitted only after every entry qualifies, so it can never contradict the verdict. No remedy command is printed, since the containment probe reads local refs only and never fetches; the header comment documents that trade-off.-c core.quotePath=falseso paths parse reliably, and the colocated test file gains five cases covering: two consecutive spawns across a moved submodule pin (residue produced by a real spawn, not hand-built), an unpushed submodule commit, work inside a submodule, a stale pin carrying real work, and a stale pin beside unrelated dirt.Risk Assessment
✅ Low: The change is a refuse-only diagnostic refinement on a path that already refused: every guard in the new classifier degrades to the pre-existing conservative message, no new write or reset path is introduced, the review-round fix (
--max-count=1) is verdict-preserving, and the only gap is a missing acceptance test for a concurrent-slot property I independently verified holds in git 2.43.Testing
I ran the colocated suite
tests/fm-spawn-pool-base-freshen.test.shat the target commit (all 11 pass) and confirmed no other test file depends on the changed refusal text, then went past pass/fail to demonstrate the intent as an operator sees it. Using throwaway copies of the tree withbin/fm-spawn.shswapped to the base and to the intermediate review commit, I verified both red-first claims: the stale-pin diagnosis test fails at base b0ca8f5, and the unpushed-commit test fails at 3c9f27c, where the pre-containment code printed agit submodule update --checkoutremedy at a slot holding an unpushed submodule commit. I then captured a real before/after CLI transcript of the actual field sequence — spawn one succeeds and strands the submodule, leavingM ui; spawn two refuses. At base the operator gets "is not clean; refusing to discard uncommitted work" while their owngit statusshows only a pointer difference; at head they get the submodule name, both pins, and "has a stale submodule checkout, not uncommitted work", with no remedy printed and HEAD plus the submodule pin unmoved. I also measured the two open questions the intent flagged: linked worktrees keep submodule checkouts per-worktree, and a spawn refused in one pooled slot left a second slot's differing pin untouched, so concurrent slots do not collide. One thing did not check out: the intent says the cleanliness gate was tightened with--ignore-submodules=none, but that flag is nowhere in the code, and a slot whose.gitmodulesshipsignore = allis still accepted with a tracked edit and an untracked file inside the submodule. Base behaves identically, so this is pre-existing rather than a regression from this change, and I left the code alone since the shape is settled — but it contradicts the stated delivered shape and needs the author's call.Evidence: CLI transcript — two consecutive spawns across a moved submodule pin, AFTER the fix (head e7d2849)
=== SPAWN 1 of 2 (fm-spawn.sh ship-ui-copy-seed <project>) === spawned ship-ui-copy-seed harness=codex kind=ship mode=no-mistakes yolo=off window=firstmate:fm-ship-ui-copy-seed worktree=.../demo/pool [exit 0] --- pooled slot AFTER spawn 1 (this is the residue) --- $ git -C <pool> rev-parse --short HEAD -> d9a165e (base moved) $ git -C <pool>/ui rev-parse --short HEAD -> 4ca2884 (submodule left behind) $ git -C <pool> status --short M ui === SPAWN 2 of 2 (the next task pays for it) === error: submodule 'ui' is checked out at 4ca2884b919922bb347389ec64457945c9b713a6, but this base records aef27f14851884b44a3cd2775a9dc8bb3fbdb39f error: pooled worktree '.../demo/pool' has a stale submodule checkout, not uncommitted work; refusing to launch and leaving it untouched [exit 1] --- slot after the refusal (must be untouched) --- $ git -C <pool> rev-parse --short HEAD -> d9a165e $ git -C <pool>/ui rev-parse --short HEAD -> 4ca2884Evidence: CLI transcript — same sequence BEFORE the fix (base b0ca8f5): the misleading verdict
--- pooled slot AFTER spawn 1 (this is the residue) --- $ git -C <pool> status --short M ui === SPAWN 2 of 2 (the next task pays for it) === error: pooled worktree '.../demo/pool' is not clean; refusing to discard uncommitted work while refreshing its base [exit 1]Evidence: Red-first proof #1 — new tests run against the pre-fix bin/fm-spawn.sh (b0ca8f5)
=== test_stale_submodule_pin_explains_itself (against pre-fix bin/fm-spawn.sh @ b0ca8f5) === not ok - refusal did not name the cause as a stale submodule checkout (missing: 'stale submodule checkout') --- output --- error: pooled worktree '.../stale-pin/pool' is not clean; refusing to discard uncommitted work while refreshing its base exit=1Evidence: Red-first proof #2 — containment test against the pre-containment commit (3c9f27c), where a destructive remedy was printed at an unpushed commit
=== test_unpushed_submodule_commit_is_still_uncommitted_work against pre-containment bin/fm-spawn.sh @ 3c9f27c === not ok - an unpushed submodule commit was not refused as uncommitted work (missing: 'refusing to discard uncommitted work') --- output --- error: submodule 'ui' is checked out at a7a728a6..., but this base records 0a14f9ad... error: pooled worktree '.../sub-unpushed/pool' has a stale submodule checkout, not uncommitted work; refusing to launch and leaving it untouched error: clear it with: git -C '.../sub-unpushed/pool' submodule update --checkout exit=1Evidence: Measurements — per-worktree submodule storage and concurrent pooled slots
slot A gitdir for 'ui': <case>/project/.git/worktrees/pool/modules/ui slot B gitdir for 'ui': <case>/project/.git/worktrees/pool2/modules/ui => PER-WORKTREE submodule git dir slot A ui HEAD = ffb1560 slot A status: [] slot B ui HEAD = 4adeb0b slot B status: [ M ui;] Now spawn into slot B while slot A holds the other pin: error: submodule 'ui' is checked out at 4adeb0b9..., but this base records ffb1560c... error: pooled worktree '.../m1/pool2' has a stale submodule checkout, not uncommitted work; refusing to launch and leaving it untouched [exit 1] slot A ui HEAD after slot B's spawn = ffb1560 (was ffb1560) => no collision: slot A's submodule pin untouched by slot B's spawnEvidence: Gap measurement — `.gitmodules` ignore = all defeats the cleanliness gate identically on base and head
### BASE b0ca8f5 .gitmodules ships: submodule.ui.ignore=all real work inside the submodule: tracked edit to ui/lib.txt + untracked ui/keep-me.txt git status --porcelain -> [] git status --porcelain --ignore-submodules=none -> [ M ui;] spawned gm-ignore-d4 ... worktree=.../m3/pool [exit 0] -> slot ACCEPTED and handed to a new task, despite real work inside the submodule ### HEAD e7d2849 .gitmodules ships: submodule.ui.ignore=all git status --porcelain -> [] git status --porcelain --ignore-submodules=none -> [ M ui;] spawned gm-ignore-d4 ... worktree=.../m3/pool [exit 0] -> slot ACCEPTED and handed to a new task, despite real work inside the submoduleEvidence: Targeted suite at head e7d2849
ok - two consecutive spawns across a moved submodule pin end in a refusal naming both pins and no remedy ok - an unpushed submodule commit keeps the uncommitted-work refusal and survives it ok - work inside a submodule is still refused as uncommitted work, not called stale ok - a stale pin carrying real work is refused conservatively, never called stale ok - a stale pin beside other dirt yields the conservative refusal alone, with no stale-pin line # all fm-spawn-pool-base-freshen tests passedNeighbouring issues, named but not absorbed
Pre-existing and out of scope. A project that sets
submodule.<name>.ignore = allcan hide real uncommitted work inside a submodule from this cleanliness gate, letting the slot be refreshed anyway. This is equally true onmaintoday, whose gate is a plaingit status --porcelainwith no--ignore-submodules, so this branch is at parity and does not introduce the exposure. Flagging it here so it can be weighed on its own rather than folded into this change.Measurement on record. Linked worktrees each get their own submodule gitdir at
.git/worktrees/<slot>/modules/<name>rather than sharing.git/modules(measured on git 2.43.0: two slots held different submodule HEADs at once, and only the drifted slot reportedM <submodule>). Concurrent pooled slots therefore cannot collide over a submodule checkout, so the conditional acceptance item covering a shared checkout does not apply and no two-slot regression test was added.Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
bin/fm-spawn.sh:1818- Acceptance criteria state "The cleanliness gate was TIGHTENED, not loosened, using --ignore-submodules=none", but that flag is absent from the branch: the gate readsstatus=$(git -C "$worktree" -c core.quotePath=false status --porcelain)and--ignore-submodulesappears nowhere in the repo (grep -rn ignore-submodules --include=*.shreturns nothing). Without it,git statushonorssubmodule.<name>.ignorefrom.gitmodules/.git/configanddiff.ignoreSubmodules. A superproject that shipsignore = allfor its submodule (a setting a team plausibly adds precisely to silence the ' M <submodule>' residue this bug produces) makes status report clean, so the gate proceeds straight togit reset --hardon line 1830 and launches a task from a slot that holds real uncommitted modifications inside the submodule - directly contradicting the criterion "real modifications INSIDE a submodule (not merely a pointer difference) must still be refused".ignore = dirtyhides the same work-tree modifications while still surfacing the pin difference, which would additionally route a slot carrying real submodule work into the softer "stale submodule checkout" diagnosis. The inner check on line 1781 (git -C "$worktree/$path" status --porcelain) has the same exposure for a submodule that itself configures nested-submodule ignores. Adding--ignore-submodules=noneto both status calls is what the criteria describe; because it changes which slots are refused and which message they get, it is your call rather than mine.bin/fm-spawn.sh:1785- The containment probe only tests emptiness, butgit log --format=%H "$have" --not --remotes --enumerates every non-contained commit into a shell variable. In the two cases that matter most - a submodule with no remote-tracking refs at all, or one whose refs were never fetched ---not --remotesexcludes nothing, so this walks and materializes the submodule's entire history on a path that runs before every pooled spawn. Adding--max-count=1bounds it to the first commit found without changing the verdict.bin/fm-spawn.sh:1830- Noting the accepted tradeoff, not asking for a change: thereset --hardon this line is unchanged and still never syncs submodules, so each time the pin moves the residue re-forms, and the affected slot now refuses every subsequent spawn until an operator repairs it by hand - the pool loses that slot rather than self-healing. The intent authorizes exactly this shape ("rather than silently resyncing a pin, the slot explains a stale-submodule refusal"), and the diagnosis does make the manual repair actionable by naming the submodule and both pins, so no action is required here.🔧 Fix: bound submodule containment probe to first commit
1 warning still open:
tests/fm-spawn-pool-base-freshen.test.sh:463- The acceptance criteria require tests "that concurrent pooled slots do not collide - or, if they do collide, saying so and stopping scope there." Neither exists on the branch: all five new tests (lines 459-463) build exactly one pool worktree viamake_submodule_case, which does a singlegit worktree add ... "$pool"plus onesubmodule update --init, and nothing in bin/fm-spawn.sh or the test file records the measurement either way. This matters specifically for the new code becausedescribe_stale_submodule_pinsreads the slot's submodule throughgit -C "$worktree/$path"(bin/fm-spawn.sh:1781,1783,1785); if slots shared one submodule gitdir,core.worktreewould point at whichever slot initialized last and the diagnosis would report another slot's state - and the field incident this change is for involved three pooled slots at once. I probed the underlying behavior read-only (git 2.43): a linked worktree gets its OWN submodule gitdir at.git/worktrees/<slot>/modules/<name>with its owncore.worktreeand its ownrefs/remotes, and two slots held different submodule HEADs with only the drifted slot reportingM ui. So the property holds and there is no defect here - this is a missing regression test (and missing recorded measurement) for an explicitly required acceptance item, not a broken behavior. Adding a secondgit worktree addslot to a case and asserting each slot's diagnosis names only its own pin would close it; because it is an acceptance-scope decision, it is the author's call.bin/fm-spawn.sh:1818- The intent states the cleanliness gate was tightened "using --ignore-submodules=none", but that flag does not appear anywhere in the delivered code (bin/fm-spawn.sh:1818 runs plaingit status --porcelain, and a repo-wide grep forignore-submodulesreturns nothing). Measured consequence: withsubmodule.ui.ignore = allshipped in .gitmodules, a pooled slot holding a tracked edit to ui/lib.txt plus an untracked ui/keep-me.txt reads clean to the gate, and the spawn ACCEPTS the slot and hands it to a new task — the intent's required constraint that real modifications inside a submodule must still be refused. The base commit b0ca8f5 behaves identically, so this is pre-existing and NOT a regression introduced by this change, and I did not touch the code because the delivery state says the shape is settled. But the delivered code does not match the delivered-shape description in the intent, and the one-flag change that would close it also affects the conservative refusal path, so it is the author's call whether to add--ignore-submodules=nonenow or correct the claim. Evidence: /tmp/no-mistakes-evidence/01M0ZR39QB0TVBZ7XFNZKD01FX/measure-gitmodules-ignore.txtbash tests/fm-spawn-pool-base-freshen.test.shat head e7d2849 — all 11 tests pass (6 pre-existing, 5 new)Red-first vs base: each of the 5 new tests run individually againstgit show b0ca8f5:bin/fm-spawn.shin a throwaway copy —test_stale_submodule_pin_explains_itselffails as claimedRed-first vs intermediate:test_unpushed_submodule_commit_is_still_uncommitted_workrun againstgit show 3c9f27c:bin/fm-spawn.sh— fails, and the pre-containment code printedgit submodule update --checkoutat a slot holding an unpushed submodule commitManual end-user CLI transcript: two consecutivefm-spawn.sh <id> <project> --mode no-mistakes --yolo offruns over a real superproject+submodule fixture whose origin advanced theuipin, captured under both base and headManual measurement:git -C <pool>/ui rev-parse --git-dirin two linked worktrees of the same project (per-worktree vs shared submodule storage)Manual measurement: spawn into pooled slot B while slot A holds a different submodule pin, asserting slot A's pin is unmoved (concurrent-slot collision check)Manual measurement: slot withsubmodule.ui.ignore = allin.gitmodulesplus a tracked edit and an untracked file inside the submodule, spawned under both base b0ca8f5 and head e7d2849grep -rn 'is not clean; refusing to discard' tests/ bin/andgrep -rln 'freshen_spawn_worktree_base|pooled worktree' tests/to confirm no other test file asserts the changed refusal textbin/fm-spawn.sh:1754- describe_stale_submodule_pins compares each pooled slot's own submodule HEAD against that slot's recorded pin, which is only meaningful because linked worktrees keep independent submodule checkouts. I measured this rather than assume it: under git 2.43.0 each linked worktree gets its own .git/worktrees/<name>/modules/<path> (gitdir pointers ../../super/.git/worktrees/wt1/modules/ui and .../wt2/modules/ui), and two worktrees of one superproject held two different pins at the same time, so concurrent pooled slots do not collide. That external constraint is written down nowhere - not in the function comment, not in the script header - and no test in tests/fm-spawn-pool-base-freshen.test.sh exercises two slots at once, so a future git layout change or a shared-checkout configuration would silently make the per-slot comparison wrong with nothing failing. Recording it is an addition rather than a stale-fact fix, and the test is executable work, so both sit outside this documentation phase. Follow-up: add the measured constraint as one clause in that function's existing comment block (code comments own external constraints under the placement policy) and back it with a concurrent-slot regression case.🔧 **Lint** - 1 issue found → auto-fixed ✅
🔧 Fix: lint clean at current head, no changes needed
✅ Re-checked - no issues remain.
✅ **Push** - passed
✅ No issues found.