Skip to content

fix(spawn): allow crewmate and scout launches on projects with no origin remote - #2486

Open
Inthuson wants to merge 6 commits into
kunchenguid:mainfrom
Inthuson:fm/spawn-noremote-g2
Open

Inthuson wants to merge 6 commits into
kunchenguid:mainfrom
Inthuson:fm/spawn-noremote-g2

Conversation

@Inthuson

Copy link
Copy Markdown
Contributor

Intent

Make firstmate able to launch workers (crewmates/scouts) on a project that has no origin remote. Currently freshen_spawn_worktree_base() in bin/fm-spawn.sh unconditionally fetches origin before every non-relaunch, non-secondmate spawn, so a project with no origin remote can never host a crewmate or scout. Required behavior: when the worktree's repository has no origin remote, skip the freshen, print one clear single-line notice to stderr saying the base was not freshened because the project has no origin remote, and let the spawn proceed. When origin exists and the fetch fails, keep refusing exactly as today with the unchanged message - that refusal is the real staleness guard and must not be weakened. Detect the absence of origin positively by checking whether origin appears in the configured remote list, never by inspecting fetch failure output or exit codes and never by treating a failure to read origin's URL as absence (a project can have an origin with only a push address configured) - inferring 'no remote' from a failed operation would turn a network problem into a silent stale-base launch. The no-remote path must not fall into remote set-head origin --auto, default-branch resolution, or the second fetch of refs/heads/... since none of those apply without a remote. Testing requirements: unit-level coverage for three cases (no origin: skips, notices, succeeds; origin present but fetch fails: still refuses, message unchanged; origin present and fetch succeeds: existing behavior byte-for-byte unchanged), added to the existing test file that covers this script (tests/fm-spawn-pool-base-freshen.test.sh). A real end-to-end crewmate spawn into a throwaway git repository with no remote, proving it succeeds and lands in an isolated worktree, was already performed and verified manually against a real Herdr-backed spawn in an isolated lab session (not part of the committed automated test suite). Acceptance criteria: a repository with no origin remote can host a crewmate spawn, proven end to end; a repository with origin whose fetch fails still refuses to launch with the current message; the passing-fetch path is byte-for-byte unchanged; tests cover all three cases; the no-remote notice is a single clear line rather than a silent skip. This is a change to firstmate's own shared tracked material (bin/fm-spawn.sh and its colocated test file). During review, three follow-up decisions were made and are already committed on this branch: (1) the no-remote early return must not skip the pre-existing dirty-pooled-worktree refusal that the origin path gets, so that refusal now applies on both paths while the no-remote path still bypasses only the fetch and reset machinery; (2) the no-remote path has its own accurate refusal wording, separate from the origin path's refresh-specific wording, since nothing is fetched or reset on that path; (3) every message on the no-remote path says the project has no origin remote specifically (not no remote at all), because the detection principle is that these messages must say exactly what the code checks and nothing broader - the code checks specifically for a remote named origin, and a project can have other remotes. No em dashes in any commit, comment, or PR text (standing captain instruction).

What Changed

  • freshen_spawn_worktree_base() in bin/fm-spawn.sh now reads the absence of origin positively off the configured remote list (git remote output, matched exactly against origin), and on that path skips the fetch, remote set-head, default-branch resolution, and reset entirely, printing one stderr line (notice: pooled worktree '...' base was not freshened because the project has no origin remote) before letting the spawn proceed. An origin that is configured but unusable (for example fetch URL unset, push URL only) still falls through to the existing fetch, whose refusal message is unchanged.
  • Factored the pooled-worktree cleanliness check into require_clean_spawn_worktree(), so the dirty-pool refusal now guards both paths instead of only the origin path. Each caller passes its own message tail: the origin path keeps its refreshing its base wording byte for byte, while the no-origin path says the project has no origin remote and refuses to launch a worker on top of uncommitted work, rather than blaming a refresh that never ran.
  • Added four cases to tests/fm-spawn-pool-base-freshen.test.sh (no-origin pool skips, notices exactly once on stderr, and spawns; dirty no-origin pool refuses without discarding work; upstream-only pool skips the freshen, names the missing origin, and fetches nothing; origin with no fetch address still refuses) via a no-origin mode on the shared fixture builder and a spawn_env helper that keeps stdout and stderr separate. The pre-existing dirty-pool test now asserts its full refusal string, and the spawn header plus docs/architecture.md document the no-origin exception.

Risk Assessment

✅ Low: The change is confined to one function plus an extracted helper, leaves the origin fetch/reset path and all of its refusal messages byte-for-byte identical, detects missing origin positively so a network failure still refuses, keeps the clean-pool guard on both paths, and is covered by four behavior-level tests; the only findings are informational wording and test-strength nits.

Testing

I ran the script's own focused test file (9 cases, all passing, with the operator-visible notice and refusal lines captured), proved the three new no-origin cases fail against the base commit's fm-spawn.sh while the unusable-origin guard passes on both sides, and then demonstrated the intent end to end: a real fm-spawn.sh crewmate launch into a throwaway no-remote git repo using real treehouse pooling and a real tmux server on an isolated socket succeeded with exactly one stderr notice naming the missing origin remote, and the worker really ran in an isolated pooled worktree distinct from the project checkout. The same lab shows the origin-present path unchanged (no notice, base freshened to the origin tip including a commit pushed after the pool worktree existed) and that an unfetchable origin still launches nothing; note that in the live treehouse path treehouse's own fetch fails before fm-spawn's does, so fm-spawn's own unchanged refusal wording is evidenced at the real-script level in the unit transcript rather than in the live lab. This change is CLI/stderr-only with no rendered UI surface, so terminal transcripts are the reviewer-visible evidence. Adjacent spawn-path tests also pass, and I left the worktree clean with all lab and scratch artifacts removed.

Evidence: End-to-end transcript: real crewmate spawn into a no-origin project, plus the two origin-present contrasts

notice: pooled worktree '/tmp/fm-noremote-lab-e2e/project/.treehouse/project-a2d1ad/1/project' base was not freshened because the project has no origin remote spawned nr-evidence-a1 harness=bash kind=ship mode=local-only yolo=off window=firstmate:fm-nr-evidence-a1 worktree=/tmp/fm-noremote-lab-e2e/project/.treehouse/project-a2d1ad/1/project == spawn exit=0 == -- crewmate landed in an isolated pooled worktree, not the project checkout -- /tmp/fm-noremote-lab-e2e/project 8000a9a [main] /tmp/fm-noremote-lab-e2e/project/.treehouse/project-a2d1ad/1/project 8000a9a (detached HEAD) -- the crewmate process is really running in that worktree -- firstmate:fm-nr-evidence-a1 cwd=/tmp/fm-noremote-lab-e2e/project/.treehouse/project-a2d1ad/1/project running=bash crewmate-worker-alive lines in pane: 1

############################################################
# CASE 1 (the fix): real crewmate spawn into a git project with NO origin remote
############################################################
== project remotes (expect empty) ==
== spawn ==
warning: /tmp/fm-noremote-lab-e2e/home/data/nr-evidence-a1/brief.md records no delivery contract line (scaffolded before ship briefs recorded one); launching on the explicit --mode local-only - confirm its definition of done matches
notice: nr-evidence-a1 ships mode=local-only while the standing posture for project is no-mistakes - less rigor than the captain's standing posture; proceed only on a current explicit captain instruction or an intake judgment you can state
notice: pooled worktree '/tmp/fm-noremote-lab-e2e/project/.treehouse/project-a2d1ad/1/project' base was not freshened because the project has no origin remote
spawned nr-evidence-a1 harness=bash kind=ship mode=local-only yolo=off window=firstmate:fm-nr-evidence-a1 worktree=/tmp/fm-noremote-lab-e2e/project/.treehouse/project-a2d1ad/1/project
== spawn exit=0 ==

-- project remotes (the project really has no origin) --
(no output above == no remotes at all)
-- crewmate landed in an isolated pooled worktree, not the project checkout --
/tmp/fm-noremote-lab-e2e/project                                      8000a9a [main]
/tmp/fm-noremote-lab-e2e/project/.treehouse/project-a2d1ad/1/project  8000a9a (detached HEAD)
project checkout : /tmp/fm-noremote-lab-e2e/project
crewmate worktree: /tmp/fm-noremote-lab-e2e/project/.treehouse/project-a2d1ad/1/project
-- the crewmate process is really running in that worktree --
   firstmate:zsh  cwd=/local/home/inthuson/.no-mistakes/worktrees/d4c7ad84348d/01M05MDFW0CTN0BG3KBHK37NK5  running=zsh
   firstmate:fm-nr-evidence-a1  cwd=/tmp/fm-noremote-lab-e2e/project/.treehouse/project-a2d1ad/1/project  running=bash
-- what the crewmate pane printed --
   crewmate-worker-alive lines in pane: 1
-- recorded task state --
window=firstmate:fm-nr-evidence-a1
endpoint_task_id=nr-evidence-a1
worktree=/tmp/fm-noremote-lab-e2e/project/.treehouse/project-a2d1ad/1/project
project=/tmp/fm-noremote-lab-e2e/project
harness=bash
kind=ship
mode=local-only
yolo=off
tasktmp=/tmp/fm-nr-evidence-a1
model=default
effort=default
spawn_gen=s1786896602.2775119.4870

############################################################
# CASE 2 (unchanged): origin present and reachable -> still freshens to the origin tip
############################################################
== [good-origin] project remotes ==
origin	file:///tmp/fm-noremote-lab-e2e/origin-good-origin.git (fetch)
origin	file:///tmp/fm-noremote-lab-e2e/origin-good-origin.git (push)
== [good-origin] project HEAD before spawn ==
18bf3af
== [good-origin] spawn ==
warning: /tmp/fm-noremote-lab-e2e/home-good-origin/data/nr-evidence-c3/brief.md records no delivery contract line (scaffolded before ship briefs recorded one); launching on the explicit --mode local-only - confirm its definition of done matches
notice: nr-evidence-c3 ships mode=local-only while the standing posture for project-good-origin is no-mistakes - less rigor than the captain's standing posture; proceed only on a current explicit captain instruction or an intake judgment you can state
spawned nr-evidence-c3 harness=bash kind=ship mode=local-only yolo=off window=firstmate:fm-nr-evidence-c3 worktree=/tmp/fm-noremote-lab-e2e/project-good-origin/.treehouse/project-good-origin-af120d/1/project-good-origin
== [good-origin] spawn exit=0 ==

-- no no-origin notice above; base was freshened to origin's tip --
crewmate worktree HEAD = 515fec95f8bd837925b292ed6d519221ed4e8470
origin/main            = 515fec95f8bd837925b292ed6d519221ed4e8470
commit pushed to origin AFTER the pool worktree existed is present in the crew worktree:
   README.md
   advanced.txt
   treehouse.toml

############################################################
# CASE 3 (unchanged): origin present but unfetchable -> nothing launches
############################################################
== [broken-origin] project remotes ==
origin	file:///tmp/fm-noremote-lab-e2e/origin-does-not-exist.git (fetch)
origin	file:///tmp/fm-noremote-lab-e2e/origin-does-not-exist.git (push)
== [broken-origin] project HEAD before spawn ==
431cab7
== [broken-origin] spawn ==
warning: /tmp/fm-noremote-lab-e2e/home-broken-origin/data/nr-evidence-b2/brief.md records no delivery contract line (scaffolded before ship briefs recorded one); launching on the explicit --mode local-only - confirm its definition of done matches
notice: nr-evidence-b2 ships mode=local-only while the standing posture for project-broken-origin is no-mistakes - less rigor than the captain's standing posture; proceed only on a current explicit captain instruction or an intake judgment you can state
error: treehouse get did not enter a worktree within 60s; inspect window firstmate:fm-nr-evidence-b2
== [broken-origin] spawn exit=1 ==

-- with a live treehouse pool, treehouse's own fetch fails first, so the spawn
-- never reaches fm-spawn's fetch; either way no worker launches on a stale base.
-- fm-spawn's own refusal for that shape is exercised in the unit transcript.
🌳 Setting up worktree...
fetch failed: git fetch origin: fatal: '/tmp/fm-noremote-lab-e2e/origin-does-not
-exist.git' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
(26-08-16 16:10:06) <1> [/tmp/fm-noremote-lab-e2e/project-broken-origin]
dev-dsk-inthuson-1a-a07ae4cd %
Evidence: Fail-before-fix: the three no-origin cases against the base commit's fm-spawn.sh

=== PRE-FIX test_no_origin_remote_skips_freshen_and_succeeds === not ok - spawn should succeed on a pooled worktree with no origin remote: expected exit 0, got 1 === PRE-FIX test_no_origin_dirty_pool_refuses_without_discarding_work === not ok - the no-origin dirty refusal should be exactly one complete line naming the missing origin remote, found 0 === PRE-FIX test_non_origin_remote_only_skips_freshen_and_names_origin === not ok - spawn should succeed on a pool whose only remote is not origin: expected exit 0, got 1 === PRE-FIX test_configured_but_unusable_origin_still_refuses === ok - an origin configured without a fetch address still refuses instead of skipping the freshen

# Fail-before-fix check: the four new cases run against bin/fm-spawn.sh as of the base
# commit ef35d79 (scratch copy of bin/ tests/ with the pre-change script), each case in isolation.
# Expectation: the three no-origin cases fail before the fix; the unchanged-origin
# guard case passes both before and after, which is what makes it a regression guard.

=== PRE-FIX test_no_origin_remote_skips_freshen_and_succeeds ===
not ok - spawn should succeed on a pooled worktree with no origin remote: expected exit 0, got 1
=== PRE-FIX test_no_origin_dirty_pool_refuses_without_discarding_work ===
not ok - the no-origin dirty refusal should be exactly one complete line naming the missing origin remote, found 0
=== PRE-FIX test_non_origin_remote_only_skips_freshen_and_names_origin ===
not ok - spawn should succeed on a pool whose only remote is not origin: expected exit 0, got 1
=== PRE-FIX test_configured_but_unusable_origin_still_refuses ===
ok - an origin configured without a fetch address still refuses instead of skipping the freshen
Evidence: Post-fix focused unit run with the observed spawn messages

# observed no-origin notice: notice: pooled worktree '.../no-origin/pool' base was not freshened because the project has no origin remote # observed no-origin dirty refusal: error: pooled worktree '.../no-origin-dirty/pool' is not clean; the project has no origin remote, so refusing to launch a worker on top of uncommitted work; preserved=keep this local work # observed upstream-only notice: notice: pooled worktree '.../upstream-only/pool' base was not freshened because the project has no origin remote # observed unusable-origin refusal: error: could not fetch origin for pooled worktree '.../unusable-origin/pool'; refusing to launch from a potentially stale base # all fm-spawn-pool-base-freshen tests passed

# Post-fix: focused unit run of the script's own test file (real fm-spawn.sh, real git repos, fake terminal)
# command: FM_TEST_EVIDENCE=1 bin/fm-test-run.sh tests/fm-spawn-pool-base-freshen.test.sh

FM_TEST_BEGIN 2026-08-16T16:12:13Z tests/fm-spawn-pool-base-freshen.test.sh family=unclassified expected_gate_skip=none
# observed spawn: spawned pool-current-base-r1 harness=codex kind=ship mode=no-mistakes yolo=off window=firstmate:fm-pool-current-base-r1 worktree=/tmp/fm-spawn-pool-base-freshen.lfKguF/current-base/pool
# observed base: HEAD=c3f684a50d173e9ab1eda3b289d7dff9b857810a origin/main=c3f684a50d173e9ab1eda3b289d7dff9b857810a advanced-main=must survive a newly spawned branch
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
# observed direct-pr spawn: spawned pool-direct-pr-r3 harness=codex kind=ship mode=direct-PR yolo=off window=firstmate:fm-pool-direct-pr-r3 worktree=/tmp/fm-spawn-pool-base-freshen.lfKguF/direct-pr/pool
# observed scout spawn: spawned pool-scout-r3 harness=codex kind=scout window=firstmate:fm-pool-scout-r3 worktree=/tmp/fm-spawn-pool-base-freshen.lfKguF/scout/pool
ok - direct-PR ships and scouts both refresh stale pooled worktrees before launch
# observed dirty refusal: error: pooled worktree '/tmp/fm-spawn-pool-base-freshen.lfKguF/dirty-refusal/pool' is not clean; refusing to discard uncommitted work while refreshing its base; preserved=keep this local work
ok - a dirty pooled worktree is refused without discarding its local work
# observed unresolved-default refusal: error: could not resolve origin's current default branch for pooled worktree '/tmp/fm-spawn-pool-base-freshen.lfKguF/unresolved-default/pool'; refusing to launch from a potentially stale base
ok - an unresolved remote default branch refuses the pooled worktree
# observed unreachable-origin refusal: error: could not fetch origin for pooled worktree '/tmp/fm-spawn-pool-base-freshen.lfKguF/unreachable-origin/pool'; refusing to launch from a potentially stale base
ok - an unreachable origin refuses a potentially stale pooled worktree
# observed no-origin spawn: spawned pool-no-origin-r6 harness=codex kind=ship mode=no-mistakes yolo=off window=firstmate:fm-pool-no-origin-r6 worktree=/tmp/fm-spawn-pool-base-freshen.lfKguF/no-origin/pool
# observed no-origin notice: notice: pooled worktree '/tmp/fm-spawn-pool-base-freshen.lfKguF/no-origin/pool' base was not freshened because the project has no origin remote
ok - a pooled worktree with no origin remote skips the freshen and still spawns
# observed no-origin dirty refusal: error: pooled worktree '/tmp/fm-spawn-pool-base-freshen.lfKguF/no-origin-dirty/pool' is not clean; the project has no origin remote, so refusing to launch a worker on top of uncommitted work; preserved=keep this local work
ok - a dirty pooled worktree with no origin remote is refused without discarding its local work
# observed upstream-only notice: notice: pooled worktree '/tmp/fm-spawn-pool-base-freshen.lfKguF/upstream-only/pool' base was not freshened because the project has no origin remote
# observed upstream-only remotes: upstream 
ok - a pool whose only remote is not origin skips the freshen and names the missing origin remote
# observed unusable-origin refusal: error: could not fetch origin for pooled worktree '/tmp/fm-spawn-pool-base-freshen.lfKguF/unusable-origin/pool'; refusing to launch from a potentially stale base
ok - an origin configured without a fetch address still refuses instead of skipping the freshen
# all fm-spawn-pool-base-freshen tests passed
FM_TEST_END 2026-08-16T16:12:32Z tests/fm-spawn-pool-base-freshen.test.sh exit=0 duration_ms=19289 gate_skip=false
FM_TEST_SUMMARY total=1 failed=0 skipped_gate=0 duration_ms=19343
FM_TEST_SUMMARY_FAMILY family=unclassified count=1 duration_ms=19289 failed=0
FM_TEST_SLOWEST rank=1 script=tests/fm-spawn-pool-base-freshen.test.sh duration_ms=19289

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 3 infos
  • ℹ️ bin/fm-spawn.sh:146 - The header comment still describes the no-origin refusal as wording "that names the missing remote", the exact imprecision this branch went back and corrected everywhere else: eba912c changed all three runtime messages from "has no remote" to "has no origin remote", and 676fc33 changed docs/architecture.md from "there is nothing to freshen against" to "there is no origin to freshen against". docs/architecture.md:162 designates this header as the owner of the exact refusal mechanics, so the one surface that owns the mechanics is now the only one describing them more broadly than the code checks (the code checks for a remote named origin specifically, and the upstream-only test at tests/fm-spawn-pool-base-freshen.test.sh:302 exists precisely because other remotes can be present). Suggested fix: "names the missing origin remote".
  • ℹ️ tests/fm-spawn-pool-base-freshen.test.sh:320 - The assertion "spawn fetched a non-origin remote while skipping the freshen" cannot fail for the reason it states. The upstream remote added at line 307 points at file://$CASE_DIR/upstream-never-fetched.git, a path that is never created, so refs/remotes/upstream stays empty whether or not a fetch was attempted. Today the case is still not vacuous overall (a failed fetch would break the expect_code 0 above it), but if a future change ever fetched non-origin remotes tolerantly, this test would pass while claiming to prove nothing was fetched. Pointing upstream at a real bare clone carrying a commit (the fixture already knows how to make one in origin mode) gives the assertion teeth without changing anything else in the case.
  • ℹ️ bin/fm-spawn.sh:1763 - Recording the accepted tradeoff, not requesting a change: on the no-origin path the worker starts from whatever commit the pooled worktree already holds, which for a treehouse pool can be behind the project's local trunk (the stale-pool premise this test file opens with). Aligning to the local default branch tip is exactly what the intent forbids on this path ("must not fall into ... default-branch resolution"), and the required single-line notice is the disclosure, so the behavior as written is the authorized one. No action needed; noted only so the operator-visible consequence of the notice is on the record.
✅ **Test** - passed

✅ No issues found.

  • FM_TEST_EVIDENCE=1 bin/fm-test-run.sh tests/fm-spawn-pool-base-freshen.test.sh (all 9 cases pass, including the 4 new ones; captured operator-visible notice and refusal lines)
  • Fail-before-fix check: scratch copy of bin/+tests/ with git show ef35d79:bin/fm-spawn.sh, each new case run in isolation - test_no_origin_remote_skips_freshen_and_succeeds, test_no_origin_dirty_pool_refuses_without_discarding_work, test_non_origin_remote_only_skips_freshen_and_names_origin all fail pre-fix; test_configured_but_unusable_origin_still_refuses passes pre- and post-fix
  • Manual end-to-end lab (real git + real treehouse pool + real tmux -L fmnoremotelab + sandboxed FM_HOME/state/config, worker = bash -lc &#34;echo crewmate-worker-alive; sleep 900&#34;): bin/fm-spawn.sh nr-evidence-a1 &lt;no-remote-project&gt; --mode local-only --yolo off --backend tmux --harness &#39;...&#39; -> exit 0, one no-origin notice, worker running in the pooled worktree
  • Isolation proof for the no-remote spawn: git -C &lt;project&gt; remote -v (empty), git -C &lt;project&gt; worktree list, tmux list-windows -a -F &#39;...pane_current_path...&#39;, tmux capture-pane -p -t firstmate:fm-nr-evidence-a1, and the recorded state/nr-evidence-a1.meta
  • Same lab with a reachable origin (nr-evidence-c3): no notice emitted, crew worktree HEAD == origin/main, and the commit pushed to origin after the pool worktree existed is present in the crew worktree
  • Same lab with an unfetchable origin (nr-evidence-b2): spawn refuses and no worker launches (treehouse's own git fetch origin fails before fm-spawn's fetch is reached)
  • bin/fm-test-run.sh tests/fm-spawn-batch.test.sh tests/fm-spawn-dispatch-profile.test.sh tests/fm-spawn-worktree-settle.test.sh tests/fm-trace-context-spawn.test.sh tests/fm-control-relaunch.test.sh (5/5 pass) - adjacent fresh-spawn paths whose sandbox projects have no origin and therefore now take the new branch
  • git status --porcelain after cleanup (clean; lab, scratch copy, and per-task /tmp/fm-* dirs removed, isolated tmux server killed)
⚠️ **Document** - 1 info
  • ℹ️ docs/architecture.md:161 - Judgment call, no doc added: the manual end-to-end herdr crewmate spawn into a no-remote repo stays PR/task evidence rather than becoming a docs/verification record. The guard is git-based, not a harness-emitted signal, so firstmate-coding-guidelines' harness-dependent live-evidence rule does not apply, and the placement policy forbids creating a new documentation surface merely to close a perceived gap. The durable facts already live in their owners: the boundary and its one exception in docs/architecture.md, the exact refusal mechanics in bin/fm-spawn.sh's header, and the portable regression coverage in tests/fm-spawn-pool-base-freshen.test.sh.
⚠️ **Lint** - 1 warning
  • ⚠️ linter found issues (exit code 127)
✅ **Push** - passed

✅ No issues found.

freshen_spawn_worktree_base() unconditionally fetched origin before every
non-relaunch, non-secondmate spawn, so a purely local project with no
origin remote could never host a crewmate or scout. Detect the absence of
an origin remote positively (git remote get-url origin), skip the freshen
with a clear notice, and let the spawn proceed. An origin that exists but
fails to fetch still refuses exactly as before.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant