Repository navigation
fix(spawn): support launches from remoteless projects - #2154
dchangchang wants to merge 2 commits into
Conversation
fc5f164 made every fresh ship and scout refresh its pooled worktree from origin before launch. Its first action is `git fetch origin`, which a repository with no origin remote can never satisfy, so the guard refused every spawn into a remoteless project rather than only stale ones. The guard's premise is staleness relative to origin, and that premise is vacuous with no origin configured. freshen_spawn_worktree_base now reads the configured remote list first and takes the origin path only when a remote named origin exists. A configured origin that cannot be fetched still refuses exactly as before: the branch is decided from configuration, never from a failed fetch, so a network error and a missing remote cannot collapse into the same case. The remoteless path skips only the origin-dependent steps. It still resolves the default branch, still refuses a worktree with uncommitted work, still resets to that branch's tip, and still verifies the result, so a remoteless launch gets the same clean, current base from the local repository. The skip warns rather than staying silent. The launch is safe, but the stronger remote-freshness guarantee did not apply to it, and a guard that quietly weakens itself is exactly the kind of change that is hard to notice later - one line on stderr per affected spawn keeps that visible without touching the success path. Regression coverage extends tests/fm-spawn-pool-base-freshen.test.sh with a remoteless fixture whose local default branch is advanced past the pool base, covering a ship launch, a scout launch, the disclosure line, and a dirty remoteless pool that must still be refused without discarding work. The unreachable-origin test now also asserts that refusal never reports a missing remote. Each new assertion was proven able to fail by breaking the code on purpose: forcing the origin path unconditionally, removing the warning, inferring the skip from a failed fetch, dropping the clean-worktree check along with the fetch, and returning early without the local reset. Each break reddened the intended assertion and was reverted.
jkartiwa
left a comment
There was a problem hiding this comment.
Independently reached the same diagnosis today and arrived at the same required fix shape before finding this PR, so this is a confirming second pair of eyes rather than a first read.
The self-contradiction is worth stating plainly for anyone triaging priority: firstmate's own project-management skill instructs a remoteless project into existence ("create a local Git repository under its unused projects/<name> path, add the registry entry, and make no GitHub call", and it may not add a remote without the captain's word), and since fc5f164 the spawn path then refuses to launch a worker into exactly that project. One documented path produces what another rejects. Every neighbouring code path already handles the same situation benignly and by name - fm-fleet-sync.sh and fm-ff-lib.sh both emit "skipped: no origin remote", and fm-teardown.sh:27 calls it "the common case where there is no remote at all". This guard was the only one that did not.
Two properties of this implementation are the ones that matter, and both are easy to lose in a shorter diff:
-
The skip is decided from the configured remote list, before any fetch. A missing remote and an unreachable remote must not collapse into one branch, because only the first is safe to skip. Inferring the skip from a failed fetch would silently convert the exact stale-base risk fc5f164 was written to prevent into a no-op, and it would do so precisely when the network is unreliable. Reading
git remoteup front is the correct discriminator, and refusing whengit remoteitself fails is the right call on the residual case. -
The remoteless path keeps the reset, the clean-worktree refusal, and the HEAD verification. This is the part most at risk of being dropped. Because these worktrees are pooled and reused, the hard reset is not merely a freshness step - it is what prevents a previous task's state from leaking into the next one, and the cleanliness check is what stops uncommitted work being discarded. An implementation that returns early on a missing remote would skip all three and trade a launch failure for a silent isolation regression, which is the worse defect of the two. Retargeting the reset at local
refs/heads/<default>keeps the guarantee intact rather than weakening it.
The delegated call to warn on stderr rather than skip silently also looks right: the launch is safe, but a weaker guarantee applied, and a guard that quietly narrows itself is hard to notice later. Keeping that wording distinct from the unreachable-origin refusal, and asserting in a test that the unreachable case never emits it, is a good touch.
Test coverage looks sufficient to me on the axis that matters - both halves of the missing/unreachable distinction, plus the dirty remoteless pool - and proving each new assertion can go red before trusting it is the right standard for a guard whose failure mode is silence.
One observation rather than a change request: the urgency framing here is real but understates the reach slightly. A fleet whose remoteless project happens to be cloned from a local path will not see this bug at all, because the clone manufactures an origin the original never had. That masks the regression for some operators while blocking others entirely, which is worth knowing when judging how widely it has actually bitten.
No changes requested. This is the shape the fix should take.
kunchenguid
left a comment
There was a problem hiding this comment.
Speaking as Kun's firstmate:
VISION verdict: align. Remoteless local projects are already a supported shape; spawn was the one path that still demanded origin.
Class: corrective. Design: detect missing origin from git remote before any fetch; skip only origin-dependent steps; still require a clean worktree; reset to local refs/heads/<default>; warn on stderr. That is reset-to-local-default, not skip-freshen.
Open overlap, so do not merge:
- #2486 still OPEN: skip-freshen. Early return after the clean check, no local reset, notice that the base was not freshened.
- #2693 still OPEN: reset-to-local-default plus a HEAD-symref fallback when neither main nor master exists.
This PR is closer to #2693 than to #2486. Pick one remoteless spawn design; do not land two.
CI was fully green including no-mistakes on 2026-08-11. New first-time-fork pending runs exist on the same SHA; approving those. Not merge-eligible while overlapping PRs stay open. Not a captain-flag.
|
Closed as superseded — this work already landed on main via #2486. — Kun's Firstmate |
Intent
Fix a spawn regression that blocks every crewmate and scout launch into a project with no
originremote. This is urgent: it currently blocks all work on two of the three registered projects, both gated by a hard 2026-08-22 deadline.The defect: commit fc5f164 ("fix(spawn): refresh pooled worktrees from origin before launch") added freshen_spawn_worktree_base() to bin/fm-spawn.sh, called for every spawn that is not a relaunch and not a secondmate, so it covers ship and scout launches on every backend. Its first action is
git -C "$worktree" fetch --quiet origin. A repository with nooriginremote cannot satisfy that, so the spawn dies with "fatal: 'origin' does not appear to be a git repository" followed by "error: could not fetch origin for pooled worktree ''; refusing to launch from a potentially stale base". Reproducible with any remoteless repo: projects/tacos-draft-dashboard and projects/fantasy-football-draft both have zero remotes, while projects/smarttail has one and spawns fine.The requested fix: the guard's premise is staleness relative to
origin, and that premise is vacuous when there is noorigin, so the refresh should be skipped for a remoteless repo. Every existing refusal for a repo that DOES have anoriginit cannot reach must stay intact - that case is genuinely unsafe and is exactly what fc5f164 was written to prevent. The distinction is "no origin is configured" versus "origin is configured and the fetch failed", and only the first is safe to skip. The configured remote must be detected explicitly rather than inferred from the fetch failure, because a network error and a missing remote must not collapse into the same branch. Whether the skip is silent or prints a one-line notice was an explicitly delegated decision, to be made deliberately with the reason stated in the commit message. A pooled worktree of a remoteless repo still needs its base to be a clean, current default branch from the local repository, so the rest of the launch path must still leave it in the intended state and the cleanliness check must not be silently dropped along with the fetch.Decisions made while implementing, which a reviewer reading only the diff would not know:
git remote, matched exactly againstorigin) BEFORE any fetch, so the branch is chosen from configuration and never from a failed fetch. A failure ofgit remoteitself refuses rather than silently taking the remoteless path.remote set-head). It still resolves the default branch through the existing shared default_branch helper, still refuses a worktree with uncommitted work, still resets to the default branch tip, and still verifies the resulting HEAD. Its reset target is the localrefs/heads/<default>instead oforigin/<default>, which is the local-repository equivalent of the same clean, current base - not a weakening of the guard into a no-op.Repo rules that apply: this is firstmate's own shared tracked material, so the firstmate-coding-guidelines skill was loaded and followed - one sentence per line in prose, plain dash rather than the em dash character, shellcheck-clean bin/ scripts, colocated tests under tests/ extending the existing script rather than a new runner, the one-owner rule (the script header owns exact mechanics while docs/architecture.md owns the boundary statement), and never adding an agent name as a commit co-author.
Verification required and performed: a regression test was mandatory, not optional, covering both halves of the distinction - (1) a remoteless repo spawns instead of refusing, and (2) a repo with an
originthat cannot be fetched still refuses with the existing message. tests/fm-spawn-pool-base-freshen.test.sh was extended with a remoteless fixture whose LOCAL default branch is advanced past the pool base, covering a ship launch, a scout launch, the disclosure line, and a dirty remoteless pool that must still be refused without discarding uncommitted work; the pre-existing unreachable-origin test additionally asserts the refusal never reports a missing remote. Each new assertion was proven able to go red by breaking the code on purpose (forcing the origin path unconditionally, removing the warning, inferring the skip from a failed fetch, dropping the clean-worktree check along with the fetch, and returning early without the local reset), and each break was reverted. bin/fm-lint.sh (shellcheck 0.11.0) and bin/fm-doc-audience-check.sh are clean, and the changed-file selection through bin/fm-test-run.sh exited 0.Acceptance criteria: bin/fm-spawn.sh launches a ship or scout task into a remoteless project; every pre-existing refusal for a reachable-origin repo is preserved, including an origin that is configured but unfetchable; regression tests cover both cases and were each proven able to fail; shellcheck is clean on every script touched.
What Changed
originremote, while refreshing from the local default branch and preserving clean-worktree and verification guards.Risk Assessment
✅ Low: The change explicitly distinguishes a missing origin from an unreachable configured origin, preserves the existing refusal and cleanliness checks, and keeps the local default-branch reset and verification on the remoteless path.
Testing
The focused regression test passed, covering remoteless ship/scout launches, local default refresh, warning disclosure, dirty-worktree refusal, and preserved unreachable-origin refusal. No source or test files were changed.
Evidence: Spawn regression evidence
Focused regression transcript shows successful ship/scout launches for remoteless repos, local-default HEAD alignment, dirty-pool preservation, and refusal for unreachable origin.Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
✅ **Test** - passed
✅ No issues found.
FM_TEST_EVIDENCE=1 bash tests/fm-spawn-pool-base-freshen.test.shusing a temporary process-identity fixture✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.