Repository navigation
fix(bin): confirm a ship done's named head on origin when no tracking ref holds it - #20
Merged
Merged
Conversation
…cking ref A pooled worktree shares its clone's .git/config. When that clone's remote.origin.fetch is narrowed to the default branch, pushing a task branch never creates origin/fm/<id>, so the named-head gate read a correctly pushed head as existing only in the worker copy. Workers cleared the refusal with `git config --add remote.origin.fetch ...`, which outlives the task: once the branch is deleted after merge, every later worktree creation fails with `couldn't find remote ref`. The gate now asks the remote. fm_dod_named_head_on_origin makes one bounded `git ls-remote origin` and accepts when a ref is advertised at that commit, or when an advertised tip this copy already holds contains it. It writes no configuration, fetches no objects and creates no ref. A remote that cannot be read keeps the refusal rather than accepting, and local-only keeps its project-heads rule with no remote read. The refusal now names the shared-configuration hazard and the one-off `git fetch origin <branch>:refs/remotes/origin/<branch>` instead of leaving workers to find the refspec edit themselves.
max-metaplanet
added a commit
that referenced
this pull request
Oct 6, 2026
… ref holds it (#20) * fix(bin): confirm a ship done's named head on origin, not a local tracking ref A pooled worktree shares its clone's .git/config. When that clone's remote.origin.fetch is narrowed to the default branch, pushing a task branch never creates origin/fm/<id>, so the named-head gate read a correctly pushed head as existing only in the worker copy. Workers cleared the refusal with `git config --add remote.origin.fetch ...`, which outlives the task: once the branch is deleted after merge, every later worktree creation fails with `couldn't find remote ref`. The gate now asks the remote. fm_dod_named_head_on_origin makes one bounded `git ls-remote origin` and accepts when a ref is advertised at that commit, or when an advertised tip this copy already holds contains it. It writes no configuration, fetches no objects and creates no ref. A remote that cannot be read keeps the refusal rather than accepting, and local-only keeps its project-heads rule with no remote read. The refusal now names the shared-configuration hazard and the one-off `git fetch origin <branch>:refs/remotes/origin/<branch>` instead of leaving workers to find the refspec edit themselves. * no-mistakes(review): Drop origin containment walk and shorten origin read bound * no-mistakes(document): Document FM_DOD_ORIGIN_READ_SECONDS origin-read bound
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
Stop the ship
donenamed-head gate from pushing workers into editing a project clone's shared git configuration.Observed twice in one day on one project: pooled worktrees share the primary clone's
.git/config, and that clone'sremote.origin.fetchis narrowed to the main branch only.The named-head check in
bin/fm-dod-lib.shaccepts a head only when a local remote-tracking ref such asorigin/fm/<id>contains it, so a correctly pushed head reads as "unreachable outside the worker copy".Workers cleared that refusal with
git config --add remote.origin.fetch +refs/heads/fm/<id>:refs/remotes/origin/fm/<id>, which writes into the shared configuration.Once that branch is deleted after merge, every later worktree creation from the clone fails with
couldn't find remote ref refs/heads/fm/<id>, and no new worker can start.Wanted behaviour: the named-head check confirms the head on the remote or forge directly, for example with
git ls-remote originor the forge API thatfm_dod_recorded_pr_on_forgealready partly uses, without needing a local tracking ref.The refusal text tells workers never to change
remote.origin.fetch, and names a one-offgit fetch origin <branch>:refs/remotes/origin/<branch>if they need a ref.A regression test covers the narrowed-refspec case.
What Changed
donenamed-head gate inbin/fm-dod-lib.shno longer needs a local remote-tracking ref. If neither the worker copy nor the project clone has a remote-tracking ref containing the head, the newfm_dod_named_head_on_originmakes one bounded, read-onlygit ls-remote origincall withGIT_TERMINAL_PROMPT=0. It accepts the head only when origin advertises a ref that points exactly at that SHA. If origin can't be read, the gate still refuses.local-onlymode never reads the remote. As a result, a correctly pushed head now passes in a pooled worktree whose shared clone hasremote.origin.fetchnarrowed to the default branch.remote.origin.fetch, and if a local ref is needed, to fetch it once withgit fetch origin <branch>:refs/remotes/origin/<branch>.FM_DOD_ORIGIN_READ_SECONDS(default 5) bounds the origin read; it is documented indocs/configuration.md.tests/fm-dod-lib.test.shadds regression tests for these cases:local-onlymode does not read origin🤖 Generated with Claude Code
Risk Assessment
✅ Low: The change adds a single read-only
git ls-remotewith a 5s bound, used only as a fallback after the local-ref checks fail and never for local-only. Any read failure keeps the refusal. Both round-1 fixes are confirmed in the code: the containment walk is gone and the bound is now 5s. The narrowed-refspec regression test runs the real gate end-to-end and checks that the shared clone's config and refs stay unchanged.Testing
I ran the real
fm-pr-check.shCLI against throwaway git setups: a bare origin, a clone whose fetch refspec only covers main, and a pooled worktree. On the base commit a correctly pushed head was refused as "unreachable outside the worker copy", which reproduces the reported bug; on the change it was accepted and the PR was armed. In every case the shared clone's config and refs stayed byte-identical. After the branch was deleted on origin, a fresh fetch and worktree creation from the clone still worked. An unpushed head, an origin that can't be read and a stalled origin are all still refused, with the new guidance aboutremote.origin.fetchand the one-off fetch. The stalled read gave up in about 5s, inside the snapshot's 10s bound. Local-only mode still passes without contacting the remote. The targeted fm-dod-lib test file passes, and its new narrowed-refspec test fails against the base library. No Herdr lab was needed because the gate never touches panes.Evidence: Narrowed refspec: base refuses the pushed head, change accepts it, clone unchanged, later worktree creation works
Source: Narrowed refspec: base refuses the pushed head, change accepts it, clone unchanged, later worktree creation works
Evidence: Refusal and boundary cases (unpushed, unreadable, stalled ~5s, local-only)
Source: Refusal and boundary cases (unpushed, unreadable, stalled ~5s, local-only)
Evidence: fm-dod-lib targeted test run
Source: fm-dod-lib targeted test run
Evidence: New regression test fails against base library
Source: New regression test fails against base library
not ok - a head pushed to origin was refused because the clone's fetch refspec is narrowedPipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 2 issues found → auto-fixed ✅
bin/fm-dod-lib.sh:112- The newFM_DOD_ORIGIN_READ_SECONDSdefaults to 10s. That equalsFM_SNAPSHOT_CREW_STATE_TIMEOUT(10s), the boundbin/fm-fleet-snapshot.sh:326puts around the wholefm-crew-state.shcall, and the gate makes this call on every heartbeat. Concrete sequence: a ship crew reportsdone: PR <url> checks greenin a clone with a narrowedremote.origin.fetch, and origin is stalled (offline laptop, hung ssh).fm_dod_named_head_on_originthen uses the full 10s. Any prior work in crew-state, such as the boundedfm_dod_recorded_pr_on_forgeread, pushes the total past 10s. The snapshot kills the child and shows the crew asstate unknowninstead of the old quickblocked: named head ... unreachable. Fix: lower the default (for example to 5s, matching crew-state's other forge fallback) so the gate's worst case fits inside its callers' bounds.bin/fm-dod-lib.sh:718- Unrequired component: the fallback containment walk (cat-file over every advertised tip, thenrev-list $sha --not $held). The intent asks the gate to confirm the head on the remote directly. In the reported narrowed-refspec case the worker pushedfm/<id>at HEAD, so the exact-tip match at line 715 is enough. The walk only helps when HEAD sits behind an advertised tip this copy already holds. That extends the old tracking-ref containment rule to remote refs, which the intent does not require. A latent defect also lives inside it.$heldgoes in as command-line arguments, and on a large GitHub repo the advertisedrefs/pull/*/headtips of merged PRs are mostly held locally. That can mean tens of thousands of SHAs, which can exceed ARG_MAX, sorev-listfails and the gate refuses (it fails closed). The smallest honest remedy is to remove the walk and keep only the exact advertised-tip match. If the author wants to keep it, feed the revs throughrev-list --stdininstead of argv.🔧 Fix applied.
✅ Re-checked - no issues remain.
✅ **Test** - passed
✅ No issues found.
bin/fm-pr-check.sh t1 https://github.com/o/r/pull/1, driven live at base e73254a and at eaad160. Setup: a real bare origin, a project clone withremote.origin.fetch=+refs/heads/main:refs/remotes/origin/main, and a pooled worktree on fm/t1 that had been pushed.Same live drive for an unpushed HEAD, an origin URL that can't be read, a stalled ssh origin (GIT_SSH_COMMAND that sleeps 120s) and local-only mode.Before/after hash of the shared clone's .git/config plus all its refs, taken in every case.After acceptance, deleted fm/t1 on origin, then rangit fetchandgit worktree addfrom the clone.bash tests/fm-dod-lib.test.sh(targeted, all passed)Ran the new tests/fm-dod-lib.test.sh against the base e73254a library: the narrowed-refspec test fails there.✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.