Skip to content

fix(bin): allow pooled spawns without a git origin - #3885

Merged
kunchenguid merged 9 commits into
mainfrom
fm/fm-spawn-originless-freshness-skip-r1
Sep 7, 2026
Merged

kunchenguid merged 9 commits into
mainfrom
fm/fm-spawn-originless-freshness-skip-r1

Conversation

@kunchenguid

Copy link
Copy Markdown
Owner

Intent

Fix fm-spawn.sh refusing crews for local-only projects with no git origin. When no origin is configured there is nothing remote to be stale against, so the freshness gate must skip; an existing-but-unreachable origin must keep refusing.

What Changed

  • Skip remote freshness fetching and resetting for clean pooled worktrees with no configured origin, launching from their current HEAD.
  • Preserve safety refusals for dirty worktrees and configured-but-unusable origins, with regression coverage for origin detection and include configurations.

Risk Assessment

✅ Low: The change is bounded, preserves refusal for usable-but-unreachable origin configurations, and explicitly documents the accepted narrow limitation for variable-less included sections.

Testing

Exercised the real fm-spawn pooled-worktree flow, demonstrating that an originless project launches without fetching while configured, unusable, and unreachable origins refuse; dirty-worktree protections and related refresh behavior also passed. The initial run exceeded its timeout, and the complete rerun succeeded with reviewer-visible CLI evidence captured.

Evidence: End-to-end fm-spawn freshness behavior transcript

Source: End-to-end fm-spawn freshness behavior transcript

# evidence begin: linked-home spawn, returned=primary
$ bin/fm-spawn.sh pool-linked-primary-r12 /private/var/folders/0k/bf8mwt2n5qddzk24r20gfk0c0000gn/T/fm-spawn-pool-base-freshen.N9HKZ5/linked-primary/secondmate --scout
error: treehouse get did not enter an isolated worktree within 60s (last seen '/private/var/folders/0k/bf8mwt2n5qddzk24r20gfk0c0000gn/T/fm-spawn-pool-base-freshen.N9HKZ5/linked-primary/project': it is the repository's primary checkout (its git dir is the spawning project's common git dir); spawning project '/private/var/folders/0k/bf8mwt2n5qddzk24r20gfk0c0000gn/T/fm-spawn-pool-base-freshen.N9HKZ5/linked-primary/secondmate'); inspect window firstmate:fm-pool-linked-primary-r12
exit=1
primary HEAD before=a2aa6b550247ea06c1b2b1b995d4998fce30cf6d after=a2aa6b550247ea06c1b2b1b995d4998fce30cf6d
primary reflog before:
a2aa6b5 HEAD@{0}: commit (initial): initial
primary reflog after:
a2aa6b5 HEAD@{0}: commit (initial): initial
FETCH_HEAD absent
task metadata absent
# evidence end
ok - linked spawning home: primary preserves the primary before any refresh
# evidence begin: linked-home spawn, returned=primary-alias
$ bin/fm-spawn.sh pool-linked-primary-alias-r12 /private/var/folders/0k/bf8mwt2n5qddzk24r20gfk0c0000gn/T/fm-spawn-pool-base-freshen.N9HKZ5/linked-primary-alias/secondmate --scout
error: treehouse get did not enter an isolated worktree within 60s (last seen '/private/var/folders/0k/bf8mwt2n5qddzk24r20gfk0c0000gn/T/fm-spawn-pool-base-freshen.N9HKZ5/linked-primary-alias/primary-alias': it is the repository's primary checkout (its git dir is the spawning project's common git dir); spawning project '/private/var/folders/0k/bf8mwt2n5qddzk24r20gfk0c0000gn/T/fm-spawn-pool-base-freshen.N9HKZ5/linked-primary-alias/secondmate'); inspect window firstmate:fm-pool-linked-primary-alias-r12
exit=1
primary HEAD before=15a8f6536d0a1ba184e4147a2b8f723997da8893 after=15a8f6536d0a1ba184e4147a2b8f723997da8893
primary reflog before:
15a8f65 HEAD@{0}: commit (initial): initial
primary reflog after:
15a8f65 HEAD@{0}: commit (initial): initial
FETCH_HEAD absent
task metadata absent
# evidence end
ok - linked spawning home: primary-alias preserves the primary before any refresh
# evidence begin: linked-home spawn, returned=spawning
$ bin/fm-spawn.sh pool-linked-spawning-r12 /private/var/folders/0k/bf8mwt2n5qddzk24r20gfk0c0000gn/T/fm-spawn-pool-base-freshen.N9HKZ5/linked-spawning/secondmate --scout
error: treehouse get did not enter an isolated worktree within 60s (last seen '/private/var/folders/0k/bf8mwt2n5qddzk24r20gfk0c0000gn/T/fm-spawn-pool-base-freshen.N9HKZ5/linked-spawning/secondmate': it is the spawning project itself; spawning project '/private/var/folders/0k/bf8mwt2n5qddzk24r20gfk0c0000gn/T/fm-spawn-pool-base-freshen.N9HKZ5/linked-spawning/secondmate'); inspect window firstmate:fm-pool-linked-spawning-r12
exit=1
primary HEAD before=f319757d26e2bd26ba3c3d0c07bee3320278c893 after=f319757d26e2bd26ba3c3d0c07bee3320278c893
primary reflog before:
f319757 HEAD@{0}: commit (initial): initial
primary reflog after:
f319757 HEAD@{0}: commit (initial): initial
FETCH_HEAD absent
task metadata absent
# evidence end
ok - linked spawning home: spawning preserves the primary before any refresh
# evidence begin: linked-home spawn, returned=scout
$ bin/fm-spawn.sh pool-linked-scout-r12 /private/var/folders/0k/bf8mwt2n5qddzk24r20gfk0c0000gn/T/fm-spawn-pool-base-freshen.N9HKZ5/linked-scout/secondmate --scout
spawned pool-linked-scout-r12 harness=codex kind=scout window=firstmate:fm-pool-linked-scout-r12 worktree=/private/var/folders/0k/bf8mwt2n5qddzk24r20gfk0c0000gn/T/fm-spawn-pool-base-freshen.N9HKZ5/linked-scout/pool
exit=0
primary HEAD before=e898b15dd0e116c4234944992eb6240a7f444b3d after=e898b15dd0e116c4234944992eb6240a7f444b3d
primary reflog before:
e898b15 HEAD@{0}: commit (initial): initial
primary reflog after:
e898b15 HEAD@{0}: commit (initial): initial
FETCH_HEAD absent
saved task metadata:
window=firstmate:fm-pool-linked-scout-r12
endpoint_task_id=pool-linked-scout-r12
worktree=/private/var/folders/0k/bf8mwt2n5qddzk24r20gfk0c0000gn/T/fm-spawn-pool-base-freshen.N9HKZ5/linked-scout/pool
project=/private/var/folders/0k/bf8mwt2n5qddzk24r20gfk0c0000gn/T/fm-spawn-pool-base-freshen.N9HKZ5/linked-scout/secondmate
harness=codex
kind=scout
tasktmp=/tmp/fm-pool-linked-scout-r12
model=default
effort=default
spawn_gen=s1788743200.82823.28847
worker HEAD=d27b884338472f052e9edebe69a90bacd784a0d9 origin/main=d27b884338472f052e9edebe69a90bacd784a0d9
# evidence end
ok - linked spawning home: scout preserves the primary before any refresh
# observed spawn: spawned pool-current-base-r1 harness=codex kind=ship mode=no-mistakes yolo=off window=firstmate:fm-pool-current-base-r1 worktree=/private/var/folders/0k/bf8mwt2n5qddzk24r20gfk0c0000gn/T/fm-spawn-pool-base-freshen.N9HKZ5/current-base/pool
# observed base: HEAD=355166d99a0e370ee629d8a4dd8af7b5f0e39d95 origin/main=355166d99a0e370ee629d8a4dd8af7b5f0e39d95 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=/private/var/folders/0k/bf8mwt2n5qddzk24r20gfk0c0000gn/T/fm-spawn-pool-base-freshen.N9HKZ5/direct-pr/pool
# observed scout spawn: spawned pool-scout-r3 harness=codex kind=scout window=firstmate:fm-pool-scout-r3 worktree=/private/var/folders/0k/bf8mwt2n5qddzk24r20gfk0c0000gn/T/fm-spawn-pool-base-freshen.N9HKZ5/scout/pool
ok - direct-PR ships and scouts both refresh stale pooled worktrees before launch
# observed dirty refusal: error: pooled worktree '/private/var/folders/0k/bf8mwt2n5qddzk24r20gfk0c0000gn/T/fm-spawn-pool-base-freshen.N9HKZ5/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 '/private/var/folders/0k/bf8mwt2n5qddzk24r20gfk0c0000gn/T/fm-spawn-pool-base-freshen.N9HKZ5/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 '/private/var/folders/0k/bf8mwt2n5qddzk24r20gfk0c0000gn/T/fm-spawn-pool-base-freshen.N9HKZ5/unreachable-origin/pool'; refusing to launch from a potentially stale base
ok - an unreachable origin refuses a potentially stale pooled worktree
# observed origin-less launch: spawned pool-originless-r6 harness=codex kind=ship mode=no-mistakes yolo=off window=firstmate:fm-pool-originless-r6 worktree=/private/var/folders/0k/bf8mwt2n5qddzk24r20gfk0c0000gn/T/fm-spawn-pool-base-freshen.N9HKZ5/originless/pool
ok - an origin-less pooled worktree launches as-is, skipping the freshness gate
ok - a dirty origin-less pooled worktree is refused without discarding its local work
ok - an origin configuration without a URL refuses the pooled worktree
ok - an empty origin configuration section refuses the pooled worktree
ok - an empty-only included origin section documents the accepted detection boundary
ok - an inactive conditional origin include leaves the pooled worktree origin-less
# observed stale-pin refusal: error: submodule 'ui' is checked out at 1a7e6834d665028e81429f8e158ec61ab10de8d2, but this base records f529e45c47790aff1364d8e5dc777640cc2b9e7d
ok - an origin-less pool with a stale submodule pin refuses while 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

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

🔧 **Review** - 2 issues found → auto-fixed (7) ✅
  • 🚨 bin/fm-spawn.sh:2379 - The early return bypasses the existing cleanliness check. With no origin and an untracked or modified file in the pooled worktree, spawning now succeeds and hands unrelated/uncommitted work to the new crew. Preserve the clean-worktree refusal before returning from the originless path.
  • 🚨 bin/fm-spawn.sh:2375 - The criterion requires that “an existing-but-unreachable origin must keep refusing,” but this hunk treats every remote get-url origin failure as absence. A configured remote.origin with fetch configuration but no usable URL is an existing, unreachable origin; get-url fails and spawn incorrectly succeeds. Distinguish exact remote absence from an unusable configured remote and retain the fetch refusal for the latter.

🔧 Fix: Preserve pool safety for absent and unusable origins
1 error still open:

  • 🚨 bin/fm-spawn.sh:2387 - This still contradicts the required distinction that only complete origin absence may skip. For a clean repository whose config contains an empty [remote "origin"] section, git config --get-regexp '^remote\.origin\.' finds no variables and returns nonzero, so this branch launches instead of treating the existing unusable origin as a refusal. The added test does not cover this shape because it adds remote.origin.fetch. Detect the section itself, including an empty section, before skipping.

🔧 Fix: Refuse empty origin configurations during pooled spawn
1 error still open:

  • 🚨 bin/fm-spawn.sh:2381 - The required “existing-but-unreachable origin must keep refusing” behavior remains bypassable. If the repository config includes another config file containing an empty [remote "origin"] section, git config --get-regexp finds no origin keys and this loop scans only config and config.worktree, not the included file. The helper therefore reports no origin and spawn succeeds. Extend section detection across the effective include chain and cover this concrete included-empty-section case.

🔧 Fix: Detect empty origin sections across config includes
1 error still open:

  • 🚨 bin/fm-spawn.sh:2395 - The required “existing-but-unreachable origin must keep refusing” invariant still fails for Git's supported glob includes. With .git/config containing path = config.d/*.conf and a matched file containing only [remote "origin"], the resolved-variable check finds no key, while this walker tests the literal wildcard path with -f and skips it. Spawn then treats the repository as originless and succeeds. Make raw include traversal honor Git include-path expansion semantics rather than treating each path as a literal filename.

🔧 Fix: Honor globbed includes when detecting origin configuration
1 error still open:

  • 🚨 bin/fm-spawn.sh:2403 - The intent requires that “when no origin is configured ... the freshness gate must skip,” but this hunk collects every includeIf.*.path from raw config without evaluating its condition. An origin-less worktree with an inactive conditional include whose target contains an empty [remote "origin"] section is therefore treated as having an origin and refuses on fetch. Replace the hand-walk with detection limited to Git's effective config chain; this pipeline-authored machinery should not be further shape-patched without user approval.

🔧 Fix: Document conservative conditional include handling
1 error still open:

  • 🚨 bin/fm-spawn.sh:2403 - The added compgen path contradicts “When no origin is configured ... the freshness gate must skip.” Git treats include.path as a literal pathname; it does not expand file globs. With include.path=config.d/*.conf and a matching file containing an empty origin section, Git does not read that file, but this helper expands it, reports an origin, and causes fetch to refuse an actually originless project. This pipeline-added matching path exceeds the intent; remove the shell-glob expansion and the regression test that asserts its incorrect refusal.

🔧 Fix: Use Git-resolved config files for origin detection
1 error still open:

  • 🚨 bin/fm-spawn.sh:2383 - This contradicts the requirement that an existing-but-unreachable origin must refuse. git config --list --show-origin emits variables, not every file read, so an active included file containing only [remote "origin"] emits no row and is never scanned. The helper returns origin-absent and spawn succeeds. The test masks this case by adding an unrelated fm-test.marker variable. Because this detector is pipeline-authored machinery from prior fix rounds, ask the user to authorize replacing it with a mechanism that actually discovers zero-variable included files rather than adding another shape patch.

🔧 Fix: Document included empty-origin detection boundary
✅ Re-checked - no issues remain.

✅ **Test** - passed

✅ No issues found.

  • Inspected the target diff for bin/fm-spawn.sh and tests/fm-spawn-pool-base-freshen.test.sh.
  • FM_TEST_EVIDENCE=1 bash tests/fm-spawn-pool-base-freshen.test.sh (initial 180-second run timed out after substantial progress).
  • FM_TEST_EVIDENCE=1 bash tests/fm-spawn-pool-base-freshen.test.sh (rerun with sufficient timeout completed successfully).
  • Verified the worktree remained clean with git status --short.
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

@greptile-apps

greptile-apps Bot commented Sep 7, 2026

Copy link
Copy Markdown

Confidence Score: 5/5

The PR appears safe to merge, with no actionable defects beyond the explicitly accepted and tested variable-less included-section limitation.

The changed flow checks cleanliness before origin detection, skips fetch and reset only when no origin configuration can be detected, and retains refusal behavior for dirty worktrees and detectable unusable or unreachable origins.

Reviews (1): Last reviewed commit: "no-mistakes(document): Document originle..." | Re-trigger Greptile

@kunchenguid
kunchenguid merged commit 1533f47 into main Sep 7, 2026
15 checks passed
@kunchenguid
kunchenguid deleted the fm/fm-spawn-originless-freshness-skip-r1 branch September 7, 2026 01:46