Skip to content

fix(bin): name the stale submodule pin behind a pooled slot refusal - #3121

Merged
kunchenguid merged 4 commits into
kunchenguid:mainfrom
mkurt:fm/pool-submodule-drift
Aug 27, 2026
Merged

kunchenguid merged 4 commits into
kunchenguid:mainfrom
mkurt:fm/pool-submodule-drift

Conversation

@mkurt

@mkurt mkurt commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

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 ui pin 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 --porcelain BEFORE the reset, then runs git 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:

  1. Where linked worktrees keep submodule checkouts (per-worktree .git/worktrees//modules/ vs shared .git/modules/), since a shared checkout would mean two slots cannot hold different pins at once and would force stopping scope there.
  2. Whether the cleanliness check belongs before the reset, after it, or both.
  3. The actual behavior when there are real changes inside the submodule.

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_base now 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.
  • Added 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.
  • The pre-reset status call now runs with -c core.quotePath=false so 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.sh at 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 with bin/fm-spawn.sh swapped 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 a git submodule update --checkout remedy 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, leaving M ui; spawn two refuses. At base the operator gets "is not clean; refusing to discard uncommitted work" while their own git status shows 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 .gitmodules ships ignore = all is 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 -> 4ca2884

############################################################
# AFTER THE FIX   (head e7d2849)
# fm-spawn.sh under test: /tmp/no-mistakes-evidence/01M0ZR39QB0TVBZ7XFNZKD01FX/transcript-after-fix/bin/fm-spawn.sh
############################################################

--- pooled slot before any spawn (operator view) ---
$ git -C <pool> status --short          # (empty = clean)
$ git -C <pool> rev-parse --short HEAD  -> 9a886c9
$ git -C <pool>/ui rev-parse --short HEAD -> 0d0dba4
  origin/main has since moved to 7c6a18f, which moves the 'ui' pin to 7279d9a

=== 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=/tmp/fm-spawn-pool-base-freshen.LHid0G/demo/pool
[exit 0]

--- pooled slot AFTER spawn 1 (this is the residue) ---
$ git -C <pool> rev-parse --short HEAD    -> 7c6a18f  (base moved)
$ git -C <pool>/ui rev-parse --short HEAD -> 0d0dba4  (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 0d0dba46ec30ece43c34098ec07adebdf2af3f24, but this base records 7279d9a012945c08ab7bce5a1252357be6862ca1
error: pooled worktree '/tmp/fm-spawn-pool-base-freshen.LHid0G/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    -> 7c6a18f
$ git -C <pool>/ui rev-parse --short HEAD -> 0d0dba4
Evidence: 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]

############################################################
# BEFORE THE FIX  (base b0ca8f5)
# fm-spawn.sh under test: /tmp/no-mistakes-evidence/01M0ZR39QB0TVBZ7XFNZKD01FX/transcript-before-fix/bin/fm-spawn.sh
############################################################

--- pooled slot before any spawn (operator view) ---
$ git -C <pool> status --short          # (empty = clean)
$ git -C <pool> rev-parse --short HEAD  -> 934ecc8
$ git -C <pool>/ui rev-parse --short HEAD -> b1633b9
  origin/main has since moved to df26c27, which moves the 'ui' pin to 4ce5d10

=== 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=/tmp/fm-spawn-pool-base-freshen.uG0i3N/demo/pool
[exit 0]

--- pooled slot AFTER spawn 1 (this is the residue) ---
$ git -C <pool> rev-parse --short HEAD    -> df26c27  (base moved)
$ git -C <pool>/ui rev-parse --short HEAD -> b1633b9  (submodule left behind)
$ git -C <pool> status --short
 M ui

=== SPAWN 2 of 2  (the next task pays for it) ===
error: pooled worktree '/tmp/fm-spawn-pool-base-freshen.uG0i3N/demo/pool' is not clean; refusing to discard uncommitted work while refreshing its base
[exit 1]

--- slot after the refusal (must be untouched) ---
$ git -C <pool> rev-parse --short HEAD    -> df26c27
$ git -C <pool>/ui rev-parse --short HEAD -> b1633b9
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=1

=== 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 ---
warning: /tmp/fm-spawn-pool-base-freshen.TnrH0x/stale-pin/home/data/pool-stale-pin-r7/brief.md records no delivery contract line (scaffolded before ship briefs recorded one); launching on the explicit --mode no-mistakes - confirm its definition of done matches
error: pooled worktree '/tmp/fm-spawn-pool-base-freshen.TnrH0x/stale-pin/pool' is not clean; refusing to discard uncommitted work while refreshing its base
exit=1

=== test_unpushed_submodule_commit_is_still_uncommitted_work (against pre-fix bin/fm-spawn.sh @ b0ca8f5) ===
ok - an unpushed submodule commit keeps the uncommitted-work refusal and survives it
# all fm-spawn-pool-base-freshen tests passed
exit=0

=== test_work_inside_submodule_is_still_uncommitted_work (against pre-fix bin/fm-spawn.sh @ b0ca8f5) ===
ok - work inside a submodule is still refused as uncommitted work, not called stale
# all fm-spawn-pool-base-freshen tests passed
exit=0

=== test_stale_pin_carrying_real_work_is_not_called_stale (against pre-fix bin/fm-spawn.sh @ b0ca8f5) ===
ok - a stale pin carrying real work is refused conservatively, never called stale
# all fm-spawn-pool-base-freshen tests passed
exit=0

=== test_stale_pin_beside_other_dirt_reports_one_verdict (against pre-fix bin/fm-spawn.sh @ b0ca8f5) ===
ok - a stale pin beside other dirt yields the conservative refusal alone, with no stale-pin line
# all fm-spawn-pool-base-freshen tests passed
exit=0
Evidence: 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=1

=== 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 ---
warning: /tmp/fm-spawn-pool-base-freshen.L3FopH/sub-unpushed/home/data/pool-sub-unpushed-r10/brief.md records no delivery contract line (scaffolded before ship briefs recorded one); launching on the explicit --mode no-mistakes - confirm its definition of done matches
error: submodule 'ui' is checked out at a7a728a64b7256c58295d3d026487d6ee3190451, but this base records 0a14f9ad0c665f4bf6f148b5014140d117076f6b
error: pooled worktree '/tmp/fm-spawn-pool-base-freshen.L3FopH/sub-unpushed/pool' has a stale submodule checkout, not uncommitted work; refusing to launch and leaving it untouched
error: clear it with: git -C '/tmp/fm-spawn-pool-base-freshen.L3FopH/sub-unpushed/pool' submodule update --checkout
exit=1
Evidence: 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 spawn

==========================================================
MEASUREMENT 1: where a linked worktree keeps its submodule
               checkout, and whether two pooled slots on
               different pins collide
==========================================================
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

Put the two slots on DIFFERENT pins and read each slot's status:
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 4adeb0b933c7d080ca52f1c0f647eb1783ece04f, but this base records ffb1560c5136c5072c451befb11da8c11e95963b
error: pooled worktree '/tmp/fm-spawn-pool-base-freshen.6LemFO/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 spawn

==========================================================
MEASUREMENT 2: does the cleanliness gate still see real
               work inside a submodule when .gitmodules
               sets submodule.<name>.ignore = all ?
==========================================================
$ git -C <pool> status --porcelain            -> []
$ git -C <pool> status --porcelain --ignore-submodules=none -> [ M ui;]
spawned measure-c3 harness=codex kind=ship mode=no-mistakes yolo=off window=firstmate:fm-measure-c3 worktree=/tmp/fm-spawn-pool-base-freshen.6LemFO/m2/pool
[exit 0]  (0 = spawn ACCEPTED the slot)
pool HEAD: 492a35f -> b20cfec
submodule work still present? lib.txt tail: [tracked edit inside the submodule]  keep-me.txt: [work that must survive]
Evidence: 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 submodule

### BASE b0ca8f5   (fm-spawn.sh = /tmp/no-mistakes-evidence/01M0ZR39QB0TVBZ7XFNZKD01FX/transcript-before-fix/bin/fm-spawn.sh)
  .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 harness=codex kind=ship mode=no-mistakes yolo=off window=firstmate:fm-gm-ignore-d4 worktree=/tmp/fm-spawn-pool-base-freshen.YYMi8K/m3/pool
  [exit 0] -> slot ACCEPTED and handed to a new task, despite real work inside the submodule
  pool HEAD 628212f -> 628212f

### HEAD e7d2849   (fm-spawn.sh = /tmp/no-mistakes-evidence/01M0ZR39QB0TVBZ7XFNZKD01FX/transcript-after-fix/bin/fm-spawn.sh)
  .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 harness=codex kind=ship mode=no-mistakes yolo=off window=firstmate:fm-gm-ignore-d4 worktree=/tmp/fm-spawn-pool-base-freshen.P1FsAU/m3/pool
  [exit 0] -> slot ACCEPTED and handed to a new task, despite real work inside the submodule
  pool HEAD 1db7b1e -> 1db7b1e
Evidence: 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 passed

ok - a stale pooled worktree refreshes to current origin/main before a crew branch is created
ok - a stale pooled worktree resolves and refreshes a non-main default branch
ok - direct-PR ships and scouts both refresh stale pooled worktrees before launch
ok - a dirty pooled worktree is refused without discarding its local work
ok - an unresolved remote default branch refuses the pooled worktree
ok - an unreachable origin refuses a potentially stale pooled worktree
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 passed
- Outcome: ⚠️ 1 warning across 1 run (6m21s)

Neighbouring issues, named but not absorbed

Pre-existing and out of scope. A project that sets submodule.<name>.ignore = all can hide real uncommitted work inside a submodule from this cleanliness gate, letting the slot be refreshed anyway. This is equally true on main today, whose gate is a plain git status --porcelain with 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 reported M <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.

⚠️ **Review** - 1 warning
  • 🚨 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 reads status=$(git -C &#34;$worktree&#34; -c core.quotePath=false status --porcelain) and --ignore-submodules appears nowhere in the repo (grep -rn ignore-submodules --include=*.sh returns nothing). Without it, git status honors submodule.&lt;name&gt;.ignore from .gitmodules/.git/config and diff.ignoreSubmodules. A superproject that ships ignore = all for 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 to git reset --hard on 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 = dirty hides 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 &#34;$worktree/$path&#34; status --porcelain) has the same exposure for a submodule that itself configures nested-submodule ignores. Adding --ignore-submodules=none to 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, but git log --format=%H &#34;$have&#34; --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 --remotes excludes nothing, so this walks and materializes the submodule's entire history on a path that runs before every pooled spawn. Adding --max-count=1 bounds it to the first commit found without changing the verdict.
  • ℹ️ bin/fm-spawn.sh:1830 - Noting the accepted tradeoff, not asking for a change: the reset --hard on 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 via make_submodule_case, which does a single git worktree add ... &#34;$pool&#34; plus one submodule 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 because describe_stale_submodule_pins reads the slot's submodule through git -C &#34;$worktree/$path&#34; (bin/fm-spawn.sh:1781,1783,1785); if slots shared one submodule gitdir, core.worktree would 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/&lt;slot&gt;/modules/&lt;name&gt; with its own core.worktree and its own refs/remotes, and two slots held different submodule HEADs with only the drifted slot reporting M 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 second git worktree add slot 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.
⚠️ **Test** - 1 warning
  • ⚠️ 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 plain git status --porcelain, and a repo-wide grep for ignore-submodules returns nothing). Measured consequence: with submodule.ui.ignore = all shipped 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=none now or correct the claim. Evidence: /tmp/no-mistakes-evidence/01M0ZR39QB0TVBZ7XFNZKD01FX/measure-gitmodules-ignore.txt
  • bash tests/fm-spawn-pool-base-freshen.test.sh at head e7d2849 — all 11 tests pass (6 pre-existing, 5 new)
  • Red-first vs base: each of the 5 new tests run individually against git show b0ca8f5:bin/fm-spawn.sh in a throwaway copy — test_stale_submodule_pin_explains_itself fails as claimed
  • Red-first vs intermediate: test_unpushed_submodule_commit_is_still_uncommitted_work run against git show 3c9f27c:bin/fm-spawn.sh — fails, and the pre-containment code printed git submodule update --checkout at a slot holding an unpushed submodule commit
  • Manual end-user CLI transcript: two consecutive fm-spawn.sh &lt;id&gt; &lt;project&gt; --mode no-mistakes --yolo off runs over a real superproject+submodule fixture whose origin advanced the ui pin, captured under both base and head
  • Manual measurement: git -C &lt;pool&gt;/ui rev-parse --git-dir in 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 with submodule.ui.ignore = all in .gitmodules plus a tracked edit and an untracked file inside the submodule, spawned under both base b0ca8f5 and head e7d2849
  • grep -rn &#39;is not clean; refusing to discard&#39; tests/ bin/ and grep -rln &#39;freshen_spawn_worktree_base|pooled worktree&#39; tests/ to confirm no other test file asserts the changed refusal text
⚠️ **Document** - 1 info
  • ℹ️ bin/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 ✅
  • ⚠️ linter found issues (exit code 1)

🔧 Fix: lint clean at current head, no changes needed
✅ Re-checked - no issues remain.

✅ **Push** - passed

✅ No issues found.

@greptile-apps

greptile-apps Bot commented Aug 26, 2026 •

Copy link
Copy Markdown

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Reviews (3): Last reviewed commit: "no-mistakes(review): bound submodule con..." | Re-trigger Greptile

Comment thread bin/fm-spawn.sh Resolved
Comment thread bin/fm-spawn.sh
@@ -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) || {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate:

Reviewed HEAD ce42feff5bce1eb4938e4688902d44c005a73b7a vs main 9ce69acf95b901cb6dc38dd5fa55f37a8038e16c. Whole thread read (Greptile success). Full diff reviewed: bin/fm-spawn.sh (describe_stale_submodule_pins + freshen clean-check message) and tests/fm-spawn-pool-base-freshen.test.sh. No .github/workflows/*. Not disguised security. mkurt is not blocked.

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):

  • One captain, one interface — aligns. "is not clean" while git status looks clean was an unreadable refusal; naming the submodule and pins is honest.
  • Authority is explicit — aligns. No new capability; no automatic submodule converge; no remedy that could move an unpushed commit.
  • Scripts own the mechanics — aligns. Deterministic porcelain/gitlink/containment checks in freshen_spawn_worktree_base.
  • A restart is a non-event — aligns. No durable-state contract change.
  • Delegation with a spine — aligns. Strengthens a refusal path's legibility without weakening it.
  • The fleet outlives any vendor — aligns. Git submodule mechanics, not harness lock-in.
  • Scope — aligns. Spawn pool freshen diagnostic, not workshop.

First-time fork CI: after that full-diff review I approved workflow runs 32992929299 (CI), 32992929282 and 32991596656 (Require no-mistakes) for this HEAD.

Not merging. Waiting on the author: body has no no-mistakes-pipeline-attestation:v1 matching this HEAD (Require-no-mistakes failed). Re-run git push no-mistakes so the structured stamp lands. Not with the captain.

Merge-eligible: NO.

mkurt added 4 commits August 26, 2026 22:17
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.
@mkurt
mkurt force-pushed the fm/pool-submodule-drift branch from ce42fef to e7d2849 Compare August 26, 2026 19:58
@mkurt mkurt changed the title Explain a pooled slot's stale submodule refusal instead of reporting it as unclean fix(bin): name the stale submodule pin behind a pooled slot refusal Aug 26, 2026
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate:

Recirc after newer-activity vs stamp 2026-08-26T18:22:47Z. VISION.md read in full from current main 22fa6ed90b0585280db8a87501c5d093ee40830a. HEAD e7d2849f3fd3921584ed721ed0d1d047613eb32a. Whole thread read. Full diff re-reviewed: bin/fm-spawn.sh (describe_stale_submodule_pins + freshen message) and tests/fm-spawn-pool-base-freshen.test.sh. No .github/workflows/*. Not disguised security. mkurt is not blocked.

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/160000/containment/--not --remotes path and the five new tests.

VISION (per rule, inspected evidence):

  • One captain, one interface — aligns. "is not clean" while git status looks clean was unreadable; naming the submodule and pins is honest.
  • Authority is explicit — aligns. No new capability; no automatic submodule converge; no remedy that could move an unpushed commit.
  • Scripts own the mechanics — aligns. Deterministic porcelain/gitlink/containment checks in freshen_spawn_worktree_base.
  • A restart is a non-event — aligns.
  • Delegation with a spine — aligns. Strengthens a refusal path's legibility without weakening it.
  • The fleet outlives any vendor — aligns. Git submodule mechanics, not harness lock-in.
  • Scope — aligns. Spawn pool freshen diagnostic.

Attestation: no-mistakes-pipeline-attestation:v1 now matches this HEAD. Latest Require-no-mistakes runs on this SHA succeed (33008327495, 33008060777); earlier synchronize run 33008027850 failed before the body edit.

First-time fork CI: already approved on the prior pass; current-HEAD CI is run 33008027837 (in_progress; serial 1 pass, serial 2–4 pending).

Not merging. MERGEABLE / UNSTABLE: portable serial 2–4 still pending. File overlap with standing spawn-freshen holds #2622/#2693/#2154 (bin/fm-spawn.sh, tests/fm-spawn-pool-base-freshen.test.sh) noted; this PR only changes the refusal message, not freshen policy.

This is waiting on CI, not on the author and not on the captain.

Merge-eligible: NO.

@kunchenguid
kunchenguid merged commit 524994c into kunchenguid:main Aug 27, 2026
15 of 16 checks passed
@kunchenguid

Copy link
Copy Markdown
Owner

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 git status looks clean. Conservative fallbacks keep the original unclean refusal when containment cannot be proven. --max-count=1 bounds the containment probe.

VISION (per rule, inspected evidence):

  • One captain, one interface — aligns. Naming the submodule and pins is an honest refusal. Evidence: bin/fm-spawn.sh describe_stale_submodule_pins + freshen_spawn_worktree_base; tests/fm-spawn-pool-base-freshen.test.sh five new cases.
  • Authority is explicit — aligns. No automatic submodule converge; no remedy that could move an unpushed commit.
  • Scripts own the mechanics — aligns. Deterministic porcelain/gitlink/containment checks.
  • A restart is a non-event — aligns. No durable-state contract change.
  • Delegation with a spine — aligns. Strengthens a refusal path's legibility without weakening it.
  • The fleet outlives any vendor — aligns. Git submodule mechanics, not harness lock-in.
  • Scope — aligns. Spawn pool freshen diagnostic, not workshop.

No .github/workflows/*. Not disguised security. Distinct from the spawn-freshen hold trio #2622/#2693/#2154 (named-base leftover); this is diagnostic-only on the existing clean check.

Gates: attestation e7d2849f3fd3921584ed721ed0d1d047613eb32a matched HEAD; forge CI green after first-time fork approval of runs 33008027837 (CI), 33008327495 and 33008060777 (Require no-mistakes, success after body edit; earlier synchronize 33008027850 had failed before the matching stamp). Merge CLEAN. Squash-merged as 524994c8b483513eababb4e791b8b06b3b4ec974.

mkurt added a commit to mkurt/firstmate that referenced this pull request Aug 27, 2026
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