Skip to content

fix(spawn): refuse pool slots another task's meta still claims - #4108

Closed
jayjongcheolpark wants to merge 7 commits into
kunchenguid:mainfrom
jayjongcheolpark:fm/treehouse-pool-held-slot-guard
Closed

jayjongcheolpark wants to merge 7 commits into
kunchenguid:mainfrom
jayjongcheolpark:fm/treehouse-pool-held-slot-guard

Conversation

@jayjongcheolpark

@jayjongcheolpark jayjongcheolpark commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Intent

Captain asked (2026-09-09: "진행해주세요") to fix this firstmate defect: the Treehouse worktree pool hands a slot to a NEW spawn while another task's live state/.meta still records that slot as its worktree, so two task records end up bound to one worktree. Consequences observed:

  • 2026-08-17 (constructease secondmate home): a captain-held task's untracked render artifact (out/ConstructEaseExplainer.mp4) was destroyed by slot reuse even though the branch survived.
  • 2026-09-09 (constructease secondmate home): slot constructease-41a8be/2 was bound simultaneously by import-flows-address-sync-docs (live) and three earlier tasks whose endpoints had died (awm-staging-setup-scripts, fischer-user-picks-primary-po, import-date-churn-report). Teardown correctly refused ("also task X's recorded worktree") and the stale bindings had to be cleared by hand.
  • 2026-09-09 (main firstmate home): crewstate-live-run-preference's Herdr window had been closed, its meta still recorded worktree firstmate-7bab20/3; bin/fm-spawn.sh crewstate-live-run-rebase then received slot 3 (treehouse reported it "available"), and teardown of both later refused until the stale binding was cleared manually.
    The header of bin/fm-spawn.sh states that a project-identity lock held from allocation through metadata publication prevents reuse "before its owner record is published" - but reuse happens AFTER publication, when the owner's endpoint is dead and treehouse considers the slot free. Upstream fix: refresh pooled worktrees from authoritative task base #2448 "fix: refresh pooled worktrees from authoritative task base" is CLOSED unmerged; evaluate whether any of it is still relevant before designing. That change selected an authoritative local or remote default-branch base, handled local-only ancestry, and reset a clean allocated worktree to a frozen selected commit; it concerned base freshness after allocation.
    Acceptance:
  1. A fresh spawn must never take a pool slot that any live task record in the SAME home (state/*.meta with worktree=) still claims, regardless of whether that task's endpoint is alive. Preferred behavior: skip that slot and take another; if none is free, refuse loudly naming the claiming task and the reconciliation path (fm-crew-state / teardown), never silently reuse.
  2. Slot release stays teardown-only; no automatic clearing of another task's binding.
  3. Regression tests reproduce the 2026-09-09 shape (dead-endpoint task meta claiming slot N, treehouse says available, spawn must not pick N) and the no-collision case, colocated per repo convention; a targeted check of the treehouse status vs meta-claim reconciliation in bin/fm-teardown.sh or the guard that explains the refusal.
  4. No behavior change for spawns when no claim exists; relaunch (same task, same slot) keeps working.
  5. Document the rule once at its owner (fm-spawn.sh header and/or docs/tmux-backend.md or the pool doc that owns slot allocation) - one owner, no second copy.

Firstmate's subsequent validation instruction expressly requests these constraints in the intent: keep the guard small and one-owner, sharing teardown's metadata matcher rather than adding a second scanner; release remains teardown-only; relaunch remains unaffected; code must be shellcheck-clean; test only isolated fixtures, never live task state or projects. Inspect Treehouse's available selection/exclusion API; if it cannot be steered, refuse loudly naming the claiming task. The PR body must state the verdict on #2448 and what, if anything, was taken from it. Deliver a PR to kunchenguid/firstmate with checks green; do not merge.

What Changed

  • bin/fm-spawn.sh now, under the existing project lock and before treehouse get, reads treehouse status --json and refuses a fresh spawn when any slot Treehouse reports available is still recorded as worktree= by another task meta in the same home; the slot treehouse get actually enters is matched again before the copy is freshened or the task record is published. Both refusals name the claiming task and point at fm-crew-state.sh / fm-teardown.sh, change nothing in the pool or the owner record, and do not apply to relaunch or to slots Treehouse reports in use. The header of fm-spawn.sh owns the rule.
  • The meta-vs-directory matcher is extracted into fm_meta_find_directory_claim in bin/fm-backend.sh and shared by bin/fm-teardown.sh's require_exclusive_worktree_slot_record, so spawn and teardown run one scanner; jq joins the tmux backend's required tools and docs/configuration.md records the toolchain delta.
  • tests/fm-spawn-pool-base-freshen.test.sh adds three fixture-only cases: a dead-endpoint claim on a Treehouse-available slot refuses at preflight, a claim on the slot entered after preflight refuses before publication, and a live claim on a different slot leaves the free slot allocatable. Existing cases now retire the first task's meta before respawning into the same slot.

Verdict on #2448: not relevant to this defect and nothing was taken from it. It addressed base freshness after allocation, which main already covers via freshen_spawn_worktree_base (#2116); this change is about slot ownership before allocation, and it deliberately resets or releases nothing on refusal.

Risk Assessment

✅ Low: Both guards are small, run before any state is published or reset, share teardown's matcher, leave relaunch and secondmate paths untouched, and the behavior-level tests separately pin the preflight, the post-get race, and the no-collision case; the only residual is a lost diagnostic on a failing treehouse status call.

Testing

On head 1852d546, Behavior portable parallel 1 ran all 11 tests with zero failures (FM_TEST_SUMMARY total=11 failed=0, duration 587726ms), then hit the job's 10-minute timeout at the summary/artifact step; every other job is green. A maintainer rerun of that job is requested.

Ran the pool base-freshen suite with the three new guard regressions plus the teardown, bootstrap, backend, worktree-settle and relaunch suites; proved the regression tests fail at the base commit; and captured a before/after CLI transcript showing base binding two task records to one clean claimed slot while the target refuses loudly, names the claiming task and reconciliation path, and leaves the claimant's record and copy intact. All targeted tests pass except one relaunch case that fails identically at base from a host Node toolchain error.

Evidence: Clean claimed slot: double binding at base vs loud refusal at target

Source: Clean claimed slot: double binding at base vs loud refusal at target

### base 269f8fe (before fix) $ bin/fm-spawn.sh demo-fresh-spawn ... --scout spawned demo-fresh-spawn harness=codex kind=scout window=firstmate:fm-demo-fresh-spawn worktree=.../demo/pool exit=0 $ grep -l worktree=.../demo/pool state/.meta (records bound to slot 3) demo-fresh-spawn.meta held.meta ### target f3736d7 (after fix) $ bin/fm-spawn.sh demo-fresh-spawn ... --scout error: Treehouse allocation refused: available slot .../demo/pool is still task held's recorded worktree, so treehouse get could hand it out again. Reconcile with bin/fm-crew-state.sh held, then bin/fm-teardown.sh held when its work is landed; only teardown releases the slot. exit=1 $ grep -l worktree=.../demo/pool state/.meta (records bound to slot 3) held.meta

\### base 269f8fe (before fix)
$ cat state/held.meta
kind=ship
backend=tmux
window=missing-window
worktree=/private$TMPDIR/fm-demo-clean-slot.JPiv1L/demo/pool
$ treehouse status --json
[{"name":"3","path":"/private$TMPDIR/fm-demo-clean-slot.JPiv1L/demo/pool","status":"available"}]
$ bin/fm-spawn.sh demo-fresh-spawn ... --scout
spawned demo-fresh-spawn harness=codex kind=scout window=firstmate:fm-demo-fresh-spawn worktree=/private$TMPDIR/fm-demo-clean-slot.JPiv1L/demo/pool
exit=0
$ grep -l worktree=/private$TMPDIR/fm-demo-clean-slot.JPiv1L/demo/pool state/*.meta  (records bound to slot 3)
demo-fresh-spawn.meta
held.meta

\### target f3736d7 (after fix)
$ cat state/held.meta
kind=ship
backend=tmux
window=missing-window
worktree=/private$TMPDIR/fm-demo-clean-slot.67V2uA/demo/pool
$ treehouse status --json
[{"name":"3","path":"/private$TMPDIR/fm-demo-clean-slot.67V2uA/demo/pool","status":"available"}]
$ bin/fm-spawn.sh demo-fresh-spawn ... --scout
error: Treehouse allocation refused: available slot /private$TMPDIR/fm-demo-clean-slot.67V2uA/demo/pool is still task held's recorded worktree, so treehouse get could hand it out again.
Reconcile with bin/fm-crew-state.sh held, then bin/fm-teardown.sh held when its work is landed; only teardown releases the slot.
exit=1
$ grep -l worktree=/private$TMPDIR/fm-demo-clean-slot.67V2uA/demo/pool state/*.meta  (records bound to slot 3)
held.meta
Evidence: New guard regression tests run against base commit scripts (fail before fix)

Source: New guard regression tests run against base commit scripts (fail before fix)

== test_claimed_pool_refuses_before_allocation at base 269f8fe
not ok - refusal must come from the preflight over Treehouse's offered slots (missing: 'available slot')
--- output ---
error: pooled worktree '/private/var/folders/cr/2_y999m90jl6vfjdqyblt5l80000gn/T/fm-spawn-pool-base-freshen.mytLtw/held-slot/pool' is not clean; refusing to discard uncommitted work while refreshing its base
not ok - refusal must name the claiming task (missing: 'task held's recorded worktree')
--- output ---
error: pooled worktree '/private/var/folders/cr/2_y999m90jl6vfjdqyblt5l80000gn/T/fm-spawn-pool-base-freshen.mytLtw/held-slot/pool' is not clean; refusing to discard uncommitted work while refreshing its base
not ok - refusal must name reconciliation (missing: 'fm-crew-state.sh held')
--- output ---
error: pooled worktree '/private/var/folders/cr/2_y999m90jl6vfjdqyblt5l80000gn/T/fm-spawn-pool-base-freshen.mytLtw/held-slot/pool' is not clean; refusing to discard uncommitted work while refreshing its base
not ok - refusal must explain slot release (missing: 'teardown')
--- output ---
error: pooled worktree '/private/var/folders/cr/2_y999m90jl6vfjdqyblt5l80000gn/T/fm-spawn-pool-base-freshen.mytLtw/held-slot/pool' is not clean; refusing to discard uncommitted work while refreshing its base
ok - a dead endpoint's durable claim refuses before pool allocation
-- exit 0
== test_claim_entered_after_preflight_refuses_before_publication at base 269f8fe
not ok - late refusal must come from the recheck of the slot treehouse get entered (missing: 'entered slot')
--- output ---
error: pooled worktree '/private/var/folders/cr/2_y999m90jl6vfjdqyblt5l80000gn/T/fm-spawn-pool-base-freshen.mytLtw/late-claim/pool' is not clean; refusing to discard uncommitted work while refreshing its base
not ok - late refusal must name the window whose shell sits in the slot (missing: 'inspect window')
--- output ---
error: pooled worktree '/private/var/folders/cr/2_y999m90jl6vfjdqyblt5l80000gn/T/fm-spawn-pool-base-freshen.mytLtw/late-claim/pool' is not clean; refusing to discard uncommitted work while refreshing its base
not ok - late refusal must name the claiming task (missing: 'task held's recorded worktree')
--- output ---
error: pooled worktree '/private/var/folders/cr/2_y999m90jl6vfjdqyblt5l80000gn/T/fm-spawn-pool-base-freshen.mytLtw/late-claim/pool' is not clean; refusing to discard uncommitted work while refreshing its base
not ok - late refusal must name reconciliation (missing: 'fm-crew-state.sh held')
--- output ---
error: pooled worktree '/private/var/folders/cr/2_y999m90jl6vfjdqyblt5l80000gn/T/fm-spawn-pool-base-freshen.mytLtw/late-claim/pool' is not clean; refusing to discard uncommitted work while refreshing its base
ok - a slot claimed by a task whose endpoint died after preflight is refused before publication
-- exit 0
== test_live_claim_on_another_slot_does_not_block_allocation at base 269f8fe
ok - a live task's claim on another slot leaves a free slot allocatable
-- exit 0
Evidence: fm-spawn-pool-base-freshen suite at target

Source: fm-spawn-pool-base-freshen suite at target

ok - a dead endpoint's durable claim refuses before pool allocation
ok - a slot claimed by a task whose endpoint died after preflight is refused before publication
ok - a live task's claim on another slot leaves a free slot allocatable
ok - a remote-seeded secondmate home allocates and launches from its Treehouse pool
ok - linked spawning home: primary preserves the primary before any refresh
ok - linked spawning home: primary-alias preserves the primary before any refresh
ok - linked spawning home: spawning preserves the primary before any refresh
ok - linked spawning home: scout preserves the primary before any refresh
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 - 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
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
Evidence: fm-teardown-endpoint-safety suite at target (shared matcher refusals)

Source: fm-teardown-endpoint-safety suite at target (shared matcher refusals)

ok - fm-teardown: missing, empty, malformed, ambiguous, and task-mismatched endpoints refuse before every mutation or runtime call
ok - fm-teardown: a concurrent lifecycle action refuses before mutation
ok - fm-teardown: non-pool cleanup ignores unrelated task publication locks
ok - fm-teardown: destructive cleanup serializes with metadata writers
ok - cleanup identity: valid tmux, Herdr, Zellij, Orca, and cmux records validate while every empty backend target refuses
ok - tmux backend: direct empty target returns nonzero without invoking tmux
ok - process cleanup: creation-time PID identity removes only the exact child and preserves the control child
skip - tmux not installed
ok - Treehouse locking resolves a bare local origin against its source project, matching the provisioned clone
ok - fm-teardown: a pool slot named by a second task record is never returned, killed, or reset
ok - fm-teardown: a pool slot held by another firstmate home is never returned
ok - fm-teardown: a task that solely holds its slot still returns it
ok - fm-teardown: an exact recorded endpoint still tears down after changing cwd outside its worktree
ok - Treehouse project locking anchors at the local root for main-home, local-secondmate, and remote-seeded layouts
ok - fm-teardown: a remote-seeded secondmate home returns its own uncontested pool slot
ok - fm-teardown: slot ownership across a remote-seeded home and its local child still refuses
ok - Treehouse project locking still serializes two homes across the remote-seeded boundary
Evidence: fm-bootstrap suite at target (tmux now requires jq)

Source: fm-bootstrap suite at target (tmux now requires jq)

fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
ok - bootstrap reports treehouse lease + tasks-axi/quota-axi bootstrap contracts
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
ok - bootstrap enforces no-mistakes minimum version
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
ok - bootstrap enforces gh-axi minimum version
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
ok - bootstrap enforces lavish-axi minimum version
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
ok - bootstrap enforces tasks-axi minimum version
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
ok - bootstrap enforces quota-axi minimum version
ok - bootstrap requires git with an install instruction
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
ok - bootstrap: backend=orca gates the Orca CLI without requiring it on the default backend
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
ok - bootstrap: session-provider backends require their own CLI + jq + treehouse, never tmux
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
ok - bootstrap: a session-provider backend gates its own CLI, never a false tmux requirement
ok - bootstrap: Herdr manual-install guidance is never executed as a shell command
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
ok - bootstrap: the bundled cmux CLI satisfies the active backend dependency
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
ok - bootstrap: unknown resolved backends fail closed with an actionable diagnostic
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
ok - bootstrap: JSON-emitting backends require jq (their genuine dep), never tmux
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
ok - bootstrap: the treehouse lease check follows the resolved backend's worktree provider
ok - bootstrap computes a fleet-size-aware default timeout and preserves partial fleet-sync output
ok - bootstrap keeps the quick 20s default for small fleets
ok - bootstrap preserves FM_FLEET_SYNC_BOOTSTRAP_TIMEOUT as an explicit override
ok - bootstrap treats a blank timeout override as unset
ok - bootstrap computes the timeout before launching fleet sync
ok - bootstrap keeps routine tasks-axi, harness, dispatch, and already-live liveness confirmations silent
ok - bootstrap routine contract runs under system /bin/bash
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
ok - bootstrap: FM_BOOTSTRAP_NETWORK partitions one run into local and network halves
ok - bootstrap: every deferred mutating sweep rechecks fleet-lock ownership
ok - bootstrap: each deferred network phase, secondmate, and clone records its own elapsed time
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
ok - bootstrap: the tasks-axi compatibility verdict travels exactly one process hop
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
ok - bootstrap surfaces active crew-dispatch rules only as verbose BOOTSTRAP_INFO
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
ok - bootstrap validates crew-dispatch.json and reports malformed or unverified configs
Evidence: fm-control-relaunch suite at target and at base (pre-existing Node/Volta failure)

Source: fm-control-relaunch suite at target and at base (pre-existing Node/Volta failure)

ok - fm-control relaunch: a same-harness relaunch replaces the agent in the same endpoint and worktree
ok - fm-control relaunch: a linked spawning home preserves committed and unfinished work in the recorded copy
ok - fm-control relaunch: durable task metadata survives replacement launch publication
ok - fm-control relaunch: delivery and concurrent task metadata publication serialize
ok - fm-control relaunch: disabling tracing clears metadata and pane context
ok - fm-control relaunch: the progress note lands in the instructions the replacement reads
ok - fm-control relaunch: a ship task refuses without the progress note its replacement needs
ok - fm-control relaunch: switching harness is one ordinary relaunch, and the old wiring goes with the old agent
ok - fm-control relaunch: a harness switch resets model and effort unless they are named too
ok - fm-control relaunch: a prefixed recorded harness can switch adapters transactionally
ok - fm-control relaunch: a prefixed command requires an explicit replacement harness
ok - fm-control relaunch: a same-harness relaunch keeps the profile axes it was running with
ok - native Ultra relaunch preserves its profile and rejects an unsupported model before stopping
ok - fm-control relaunch: explicit model and effort win over the recorded ones
ok - fm-control relaunch: refuses to relaunch onto an adapter with no verified mechanics
ok - fm-control relaunch: the retired incarnation's global turn-end token is revoked
ok - fm-control relaunch: wiring cleanup failure refuses replacement arming
ok - fm-control-lib: one owner resolves each harness's turn-end registry entry, and refuses a malformed token
ok - fm-control relaunch: a secondmate relaunch re-resolves its durable configured harness pin
ok - fm-control relaunch: invalid configured effort is ignored before stop
ok - fm-control relaunch: an adapter unverified for this task kind refuses before the agent is stopped
ok - fm-control relaunch: explicit secondmate harness resets unnamed profile axes
ok - fm-control relaunch: a ship task keeps its recorded harness instead of re-reading crew config
ok - fm-spawn --relaunch: with no explicit harness it reuses the task's recorded one, never the crew default
ok - fm-spawn --relaunch: wiring armed under a prefixed harness name is still retired
ok - fm-spawn --relaunch: switching away from muse retires its session binding
ok - fm-spawn --relaunch: switching away from cursor retires its session binding
ok - fm-control relaunch: an unaccountable local copy refuses before the agent is touched
ok - fm-control relaunch: a worker with nothing to work from is never launched
ok - fm-control relaunch: a refusal before the agent is stopped leaves the durable record untouched
ok - fm-control relaunch: checkpoint inspection failures refuse before stopping
ok - fm-control relaunch: a launch failure after the stop keeps the prior record and reports the real state
ok - fm-control relaunch: unpublished rollback keeps concurrent durable metadata
ok - fm-control relaunch: post-publication failure keeps the new durable record
ok - fm-control relaunch: partial stop reconciles actual agent state
ok - fm-control relaunch: failed journal replacement preserves durable phase
ok - fm-spawn relaunch: prepublication abort removes replacement state
ok - fm-control relaunch: the checkpoint records the exact unlanded work it preserved
ok - fm-control relaunch: a secondmate's child work is accounted for and its charter is left alone
ok - fm-control relaunch: a secondmate home that is not this secondmate's is refused
ok - fm-control relaunch: unreadable and untraversable child state fails checkpoint
ok - fm-control relaunch: two control actions on one task serialize instead of interleaving
ok - fm-spawn relaunch: direct entry participates in lifecycle serialization
ok - fm-promote: promotion participates in lifecycle serialization
ok - fm-spawn --relaunch: refuses to launch a second agent into a live endpoint
ok - fm-spawn --relaunch: symlinked records refuse before inspection
ok - fm-spawn --relaunch: keeps its early meta lock continuous
ok - fm-spawn --relaunch: pending closes refuse before replacement begins
ok - fm-spawn --relaunch: every identity axis comes from the record, and a contradicting flag refuses
ok - fm-spawn --relaunch: an unrecorded task is refused
ok - fm-spawn --relaunch: refuses to start a replacement outside the copy holding the work
not ok - a relaunch must not re-run a transition the row already reflects
warning: /private/var/folders/cr/2_y999m90jl6vfjdqyblt5l80000gn/T/fm-control-relaunch.QviuAO/reverify-3704/home/data/rl40/launch-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: task rl40's backlog item could not be read before dispatch (No version is set for command node)
error: the replacement agent for rl40 could not be launched on claude
error: rl40's agent was stopped but the replacement did not launch; no agent is running, and its work plus the recorded progress note are preserved at /private/var/folders/cr/2_y999m90jl6vfjdqyblt5l80000gn/T/fm-control-relaunch.QviuAO/reverify-3704/wt: expected exit 0, got 1
- Outcome: ⚠️ 1 info across 1 run (10m2s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 1 info
  • 🚨 bin/fm-spawn.sh:2207 - The preflight refuses a fresh spawn whenever ANY registered worktree of the project is claimed by ANY other task meta in the home, with no regard to whether that slot is one Treehouse would hand out. Concrete trace: task A is live in pool slot 1 (state/A.meta worktree=<slot1>, endpoint alive, Treehouse status 'in use'); slot 2 is free. Spawn B enters the loop, git worktree list yields slot1, fm_meta_find_directory_claim matches A.meta, and B exits 1 with 'Treehouse allocation refused'. So a home can never run two pooled tasks concurrently, which is the normal operating state (the intent's own 2026-09-09 example had four tasks in one home). This contradicts acceptance 1's preferred behavior ('skip that slot and take another; if none is free, refuse loudly') and acceptance 4 ('No behavior change for spawns when no claim exists' on the slot being taken). The header's justification ('another slot being free does not make allocation safe') only holds for claimed slots Treehouse considers available; a slot with a live endpoint is never offered by treehouse get. The edits to the existing tests (rm of the prior task's .meta at lines 187 and 534 of the test file) are symptoms of this regression, not teardown modelling. Treehouse exposes status --json (name/path/status per slot, which the new test even fakes but the guard never consults). Remedy: refuse only when a slot Treehouse reports as available (or, minimally, one without a live endpoint) is claimed by another meta; otherwise proceed. This changes the guard's product behavior relative to the author's stated conservative design, so it needs the author's decision rather than an auto-fix.
  • ⚠️ tests/fm-spawn-pool-base-freshen.test.sh:697 - The test installs a fake treehouse status --json reporting the claimed slot as available and asserts on its output ('fixture must offer the claimed slot'), but nothing in bin/fm-spawn.sh calls treehouse status; the assertion only checks the fixture against itself and proves nothing about the guard's handling of Treehouse availability. The test also does not cover the no-collision concurrent case required by acceptance 3 (a live task claiming slot N while the spawn takes a different free slot), which is exactly the case the guard currently breaks. Once the guard is narrowed to Treehouse-available slots (see the error finding), make the guard consume this status output and add the concurrent no-collision case; otherwise drop the self-referential assertion.
  • ℹ️ tests/fm-spawn-pool-base-freshen.test.sh:714 - The 'guard ran after allocation' check is wrapped in if [ -f launch.log ], so on the expected refusal path (no send-keys recorded, file absent) it is skipped and the ordering claim is unverified by this assertion; the artifact and HEAD checks that follow are what actually carry the 'before allocation' evidence. Consider asserting the log is absent or contains no treehouse get unconditionally.

🔧 Fix: Refuse only Treehouse-available slots still claimed by task metas
2 infos still open:

  • ℹ️ bin/fm-spawn.sh:2202 - The guard only checks slots that treehouse status --json reports as available at preflight time. Concrete trace: task A's slot is in-use when status is read (A's shell still alive), so it is skipped; A's window then closes during the seconds between this preflight and the treehouse get sent at line 3074 (the spawn waits up to 60s for get to enter a slot). Treehouse now judges A's slot free and can hand it out while state/A.meta still records it as worktree=, reproducing the double binding the intent forbids. The pre-get check is the right primary guard and covers the reported 2026-09-09 shape; closing this window would need a post-allocation check of the slot treehouse get actually entered (at validate_spawn_worktree, line 3133) against fm_meta_find_directory_claim, refusing loudly without releasing anything. That remedy extends the change beyond the accepted narrow preflight, so it needs the author's authorization rather than an auto-fix; it also cannot undo the reset get already performed, only prevent the second owner record.
  • ℹ️ bin/fm-spawn.sh:2206 - jq ... 2&gt;/dev/null swallows jq's own diagnostics, so a missing jq binary (now required for the tmux backend, but only checked at bootstrap, not at spawn) and genuinely non-JSON status output both surface as 'treehouse status for <proj> was not pool JSON'. Verified with the real CLI that treehouse prints [] for an empty pool and sends its update notice to stderr, so the JSON path is sound; the message is only wrong when jq itself is absent. Drop the 2&gt;/dev/null on the jq pipeline (or check command -v jq first) so the operator sees the real cause.

🔧 Fix: Recheck entered slot claim after treehouse get
3 issues (1 warning, 2 infos) still open:

  • ⚠️ tests/fm-spawn-pool-base-freshen.test.sh:719 - test_claimed_pool_refuses_before_allocation no longer proves the preflight guard exists. Its fake pane path is POOL_DIR, the same slot held.meta claims, so with the preflight block (bin/fm-spawn.sh lines 2213-2227) deleted entirely the post-get recheck at line 3142 refuses with the identical 'task held's recorded worktree' text and identical exit status. The other assertions do not separate the two paths either: the fake tmux only appends send-keys arguments that follow -l to FM_FAKE_LAUNCH_LOG, and 'treehouse get' is sent via fm_backend_tmux_send_text_line without -l, so launch.log is absent on both paths (the late-claim test asserts the same absence after get has run, which confirms this); the fake treehouse get resets nothing, so the HEAD and artifact checks pass on both paths too. The primary guard the author accepted is therefore untested against removal. Fix: assert the preflight wording, e.g. assert_contains "$out" 'available slot' and assert the 'entered slot' text is absent in this test (and the inverse in the late-claim test), so each guard's test fails when that guard is removed.
  • ℹ️ bin/fm-spawn.sh:2197 - On the post-get refusal the spawn has already opened window $T and its shell has run treehouse get, so an orphaned shell sits inside the claimed slot (Treehouse now reports it in-use). The sibling refusal in validate_spawn_worktree ends with 'Inspect target <window>' so the operator can find and close it; refuse_claimed_spawn_slot prints no window id. Add the endpoint to the message on the post-get call (the preflight call has no window yet), matching the neighbouring refusals' contract that a refusal leaving an endpoint behind names it.
  • ℹ️ tests/fm-spawn-pool-base-freshen.test.sh:188 - The round-1 decision asked to revert the test edits that rm the prior task's .meta before a second spawn enters the same pooled worktree; they are still present here and at line 534. With the post-allocation recheck the round-2 decision then authorized, they are now required: these suites drive two consecutive spawns into the same POOL_DIR via FM_FAKE_PANE_PATH, and the recheck correctly refuses the second one while the first task's record still claims the slot. The rm models teardown-only release, which is the intended invariant, so keeping them is correct; noting it only because it contradicts the earlier instruction.

🔧 Fix: Name orphan window on late refusal; split guard tests
1 info still open:

  • ℹ️ bin/fm-spawn.sh:2213 - treehouse status --json 2&gt;/dev/null discards treehouse's own diagnostics, so when status genuinely fails (corrupt pool state, unreadable project) the operator only sees 'treehouse status failed for <proj>' with no cause. Silencing is understandable because treehouse prints its update notice to stderr on every call, but the diagnostic is lost exactly when it matters. Capture stderr into a variable (or temp file) and print it only on the failure branch.
⚠️ **Test** - 1 info
  • ℹ️ tests/fm-control-relaunch.test.sh - tests/fm-control-relaunch.test.sh fails one case on this host ('a relaunch must not re-run a transition the row already reflects') because the backlog read inside the relaunch path hits Volta's 'No version is set for command node'. The identical error occurs at base commit 269f8fe (there it surfaces as 'a same-harness relaunch should succeed'), so it is a local environment issue and not caused by this change; every relaunch guard case in the suite that this change could affect passes. CI owns the authoritative run.
  • bash tests/fm-spawn-pool-base-freshen.test.sh - all 25 cases pass at f3736d7, including the three new guard cases: preflight refusal of a claimed available slot, post-get refusal of a slot claimed after preflight, and concurrent allocation beside a live task on another slot
  • Fail-before-fix: the three new test functions run against base 269f8fe scripts - both refusal cases fail (base proceeds past the guard), the no-collision case passes on both (log: fail-before-fix.log)
  • Manual before/after reproduction of the 2026-09-09 shape with a clean slot: bin/fm-spawn.sh ... --scout with state/held.meta claiming the slot and fake treehouse status --json reporting it available; base publishes demo-fresh-spawn.meta beside held.meta (double binding), target exits 1 with the refusal naming task held and only held.meta remains bound
  • bash tests/fm-teardown-endpoint-safety.test.sh - 16 cases pass, including test_reused_pool_slot_refuses_before_touching_the_other_task and test_cross_home_pool_slot_collision_refuses, which exercise the teardown refusal now built on fm_meta_find_directory_claim
  • bash tests/fm-bootstrap.test.sh - 28 cases pass, including the per-backend required-tools case covering the new jq requirement for tmux
  • bash tests/fm-backend.test.sh (28 pass) and bash tests/fm-spawn-worktree-settle.test.sh (4 pass) - neighbours of validate_spawn_worktree and fm_backend_required_tools
  • bash tests/fm-control-relaunch.test.sh - 51 pass, 1 pre-existing host Node/Volta failure reproduced at base 269f8fe
  • bash bin/fm-test-run.sh --changed --base 269f8fe --list to pick the targeted neighbouring suites
✅ **Document** - passed

✅ No issues found.

🔧 **Lint** - 1 issue found → auto-fixed (2) ✅
  • ⚠️ linter found issues (exit code 1)

🔧 Fix: Lint passes with pinned tools; no source changes needed
1 warning still open:

  • ⚠️ linter found issues (exit code 1)

🔧 Fix: Lint passes with pinned tools; no source changes needed
✅ Re-checked - no issues remain.

✅ **Push** - passed

✅ No issues found.

A dead endpoint can make Treehouse offer a slot whose task metadata
still owns the copy. Refuse fresh allocation before Treehouse runs when
this home's records claim a registered project worktree, using the same
metadata matcher as teardown. Relaunch retains its existing slot path.

Treehouse exposes no slot exclusion selector, so the guard conservatively
refuses rather than risking another task's files. Only teardown releases
the claim. Cover the dead-endpoint case and preservation of its artifact,
metadata, and HEAD, and retire seed task fixtures before slot reuse.
…ied in the worktree (7 files: bin/fm-backend.sh, bin/fm-spawn.sh, bin/fm-install-treehouse.sh, tests/fixtures.sh, tests/fm-secondmate-harness.test.sh, tests/fm-spawn-dispatch-profile.test.sh, tests/fm-task-delivery.test.sh). 1. Lint (SC2100 on fm-spawn.sh `HERDR_LAUNCHER_RELATIONSHIP=other-home`): the new fm_meta_find_directory_claim introduced a variable named `other`, so ShellCheck (with CI's --external-sources) read the pre-existing literal as `other - home`. Renamed the loop variable to `claimant`. Full-mode lint over every changed file is clean. 2. Behavior tests (Herdr): four e2e spawns died with "treehouse status failed ... refusing Treehouse allocation". `treehouse status --json` exists only from Treehouse v2.1.0; CI pinned v2.0.1. Bumped bin/fm-install-treehouse.sh to v2.1.1 (the version the local real-Herdr suite already runs) with verified SHA-256s for all four assets. Installer exercised locally (installs v2.1.1, status accepts --json); tests/fm-backend-autodetect-smoke.test.sh passes against real Herdr + treehouse 2.1.1. 3. Portable parallel 2 / serial 3 / serial 4: fm-spawn.sh now runs treehouse on the spawn host, and the preflight sat before the missing-brief check. CI portable shards have no treehouse installed, so fm-spawn-batch got the status error instead of the brief error, and spawns in fm-task-delivery and fm-secondmate-harness (fakebins/restricted PATH without a treehouse fake) failed. Fixes: moved the status preflight to just before endpoint creation (still under the project lock, after brief/backlog refusals); added the shared no-op treehouse fake to the secondmate launch-capturing fakebin and task-delivery make_home. In fm-spawn-dispatch-profile the symlink-spelled second spawn reused the first task's fake worktree, which the new entered-slot guard correctly refuses (reproduced locally); it now gets its own worktree. Fixing that exposed a latent sibling in the same file (the Ultra batch test spawns two tasks sharing one fake pane path; previously masked because the suite exits on first failure). The spawn fake tmux in tests/fixtures.sh gained an opt-in FM_FAKE_PANE_PATHS_DIR mode (new-window returns the fm-<id> name as window id; pane path is <dir>/<id>) and the batch test gives each task its own worktree through it. Verified locally: lint clean; installer with new pin; fm-backend-autodetect-smoke; fm-spawn-pool-base-freshen (the PR's regression tests); fm-teardown-endpoint-safety; fm-test-fixtures; fm-spawn-batch and fm-task-delivery with treehouse removed from PATH. Still running when this result was demanded: fm-secondmate-harness (no-treehouse PATH) and the reworked fm-spawn-dispatch-profile; their earlier direct reruns confirmed the diagnosed error lines that these fixes target
…ered-slot guard correctly refusing in two test fixtures that bound one worktree to two task records; fixed both tests (2 files: tests/fm-spawn-dispatch-profile.test.sh, tests/fm-backend-herdr-presentation-e2e.test.sh). 1. Behavior portable serial 3: test_batch_forwards_shared_profile_flags spawned two tasks through one fake pane path, so the second spawn re-entered the first task's worktree and the guard refused (exit 1). Previously masked because the suite exits on first failure and the Ultra batch case (fixed in the prior commit) failed first. Fix mirrors that prior fix: each batch task gets its own git worktree via the fixture's FM_FAKE_PANE_PATHS_DIR mode. Verified locally: the full fm-spawn-dispatch-profile suite passes. 2. Behavior tests (Herdr): fm-backend-herdr-presentation-e2e failed at the post-legacy spawn with 'available slot .../project-166e25/2/project is still task p1's recorded worktree'. The retained multi-home workers (p1, p2, pcw) lose their processes when the restart fixtures stop/reprovision the Herdr session, so Treehouse reports their PROJECT_DIR slots available while their metas still claim them; the guard refuses by design (the PR had already moved the recovery fixtures to RECOVERY_PROJECT_DIR for the same reason). Fix: post-legacy now spawns into RECOVERY_PROJECT_DIR, with a comment explaining why. Verification limit: this e2e cannot run to completion on this macOS host even against CI-pinned Herdr 0.7.4 installed in a temp dir; it fails at workspace-ordering assertions near line 806 (long before the edited line 1380) that pass on CI's Linux runner, so the Herdr lane needs CI confirmation. Shellcheck clean on both files. 'Behavior portable parallel 1' was only cancelled by fail-fast, not a real failure
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate:

Diff review: preflight treehouse status --json refuse of available slots still claimed in this home's metas, plus post-get re-check; also touches teardown/backend/install. Security clean on the spawn guard path. Attestation MATCH tip 1852d546a95c35b213b5bef1a83c20d1f4b1d340.

VISION per-rule: One captain/interface — aligns. Authority — aligns. Scripts vs agents — aligns. Restart — aligns. Delegation — aligns. Fleet/vendor — aligns. Scope — aligns.

contract-class: restore — same promised exclusive-slot invariant as #2754 / #4093.

overlap: Prefer helping #4093 (closes ready-for-pr #2754). Leave this open; if #4093 merges and this is leftover duplicate, we will close with thanks. Do not treat this comment as waiting on you for a captain decision.

next: waiting-ci (checks already running). Not a captain hold.

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.

2 participants