Skip to content

fix: reserve Treehouse pool copies until explicit task cleanup - #32

Merged
peterOC26 merged 17 commits into
mainfrom
fm/fm-worktree-record-clash-fix-c2
Oct 23, 2026
Merged

peterOC26 merged 17 commits into
mainfrom
fm/fm-worktree-record-clash-fix-c2

Conversation

@peterOC26

@peterOC26 peterOC26 commented Oct 22, 2026 •

Copy link
Copy Markdown
Owner

Intent

Keep each pool copy reserved while a task record names it (worktree record clash fix).

The diagnosis (2026-10-22) found that ordinary ship and scout spawns use interactive treehouse get, whose reservation lasts only as long as its processes, while Firstmate keeps task records until explicit cleanup. An idle or exited task can leave a valid-looking worktree= record after its slot becomes reusable; the next spawn overwrites .fm-slot-owner and publishes the same path under a different task. Today pv-voice-reliability-program-p1 is the stale record and pv-typed-caller-repair-t1 owns slot 9. The report designs the fix: keep each pool copy reserved for as long as a task record names it, plus the safe teardown path for an existing clash.

The report's fix design, in substance: use Treehouse's existing durable lease contract for ordinary Treehouse-backed ships and scouts (no new pool service, no Treehouse change). Before acquisition, under the project lock, inspect retained task records in this home and registered local homes; a referenced pool copy without a verified matching durable lease refuses before get is invoked (a post-get scan is too late because get resets the copy), and "free" is never inferred from done status, an empty endpoint, or clean Git state. Acquire with treehouse get --lease --lease-holder <home/task/acquisition identity> --json, persist the path, lease id and holder, keep isolation and freshness checks, recheck record exclusivity before claiming/publishing, and never overwrite a conflicting claim. Keep the lease through worker exit, finished status and relaunch until explicit teardown; the holder binds home plus task plus acquisition, not spawn_gen; relaunch takes the project lock and validates lease/claim and exclusive record ownership before any endpoint or wiring mutation, refusing a stale record. Release through identity-conditional treehouse return --if-lease-id --if-lease-holder after the normal completion and landed-work gates, validating ownership before any process reaping, hook/branch/scratch edits or return; keep records and lease on unknown failures; a spawn abort keeps a durable recovery record of a newly acquired lease. For existing duplicate records keep the records-only route for a stale record whose slot claim names another task, refuse owner-first cleanup while another record still names the copy and say which stale task to reconcile first, and never touch the successor's copy, processes, claim or lease. Do not weaken the shared-copy teardown refusal or the slot-owner marker protection. The CI Treehouse pin must support the required flags. Prove the behaviour with offline tests using a mock treehouse (never real treehouse status or teardown): reserved slot skipped on spawn, reservation released at cleanup, existing clash resolved by the safe teardown path without touching the successor's copy.

Q1178 C 2026-10-22 ("q1178 C but instead of gpt-6.1-sol xhigh use astra medium"): diagnosis on gpt-6-astra medium, code on gpt-6.1-sol high, Claude Opus checks.

Q1180 A 2026-10-22 ("q1180 A"): firstmate-repo PRs go to the fork peterOC26/firstmate.

What Changed

  • Acquire durable Treehouse leases for ships and scouts, persist acquisition identities and recovery journals, and retain reservations through worker exit and relaunch until explicit cleanup.
  • Check retained records and slot ownership under the project lock before allocation, relaunch, and cleanup; condition returns on lease identity and reconcile stale records without touching a successor’s copy or processes.
  • Pin CI Treehouse to v2.3.0, require lease capabilities and jq, update lifecycle documentation, and add offline regression coverage for reservations, release, recovery, and duplicate-record cleanup.

Risk Assessment

✅ Low: The latest fix round only adds REFUSED diagnostics before existing return 1 exits in fm_treehouse_record_exclusive and fm_treehouse_records_reserved, plus a behavioural test; the control flow is unchanged, and the earlier fixes (shared lease-CLI gate in bootstrap, the state-directory refusal, the never-acquired and orphan-claim recovery steps) check out against the current code.

Testing

Five focused scripts passed after correcting temporary-fixture placement; ten real CLI scenarios passed after correcting one driver assertion. Transcripts demonstrate refusal, reconciliation and preservation behavior. Full live lease mutations and descendant teardown remain unverified under the accepted boundaries; no source changes remain.

  • Live validation: ⚠️ inconclusive - 10 of 14 scenarios driven live against the product
Scenario Result Live Evidence
Spawn refuses before allocation when finished, aliased, or registered-home records name an unleased copy ✅ pass live Live CLI guards and stale-record cleanup
Spawn explains missing local-home state and ambiguous records before allocation ✅ pass live Live CLI guards and stale-record cleanup
Retry preserves an unresolved acquisition journal and prints never-acquired and orphan-claim recovery steps ✅ pass live Live CLI guards and stale-record cleanup
Forced cleanup of a missing leased copy preserves ownership records and prints recovery steps ✅ pass live Live CLI guards and stale-record cleanup
Owner-first cleanup refuses, then stale-record cleanup preserves the successor’s copy, process, endpoint, claim and lease ✅ pass live Live CLI guards and stale-record cleanup
Forced cleanup cannot bypass an unreadable slot-owner claim ✅ pass live Live CLI guards and stale-record cleanup
Relaunch refuses stale leases, conflicting claims, duplicate ownership and unreadable records before endpoint mutation ✅ pass live Corrected live relaunch checks
Forced cleanup validates the exact lease before killing an endpoint or changing hooks and scratch files ✅ pass live Live cleanup guards and Treehouse CLI capabilities
Records-only cleanup of an unclaimed legacy ship still refuses dirty unlanded work ✅ pass live Live cleanup guards and Treehouse CLI capabilities
Installed Treehouse v2.3.0 advertises JSON leases and both conditional-return guards ✅ pass live Live cleanup guards and Treehouse CLI capabilities
Acquire distinct copies, retain lease identity through exit and relaunch, and release only the matching lease at cleanup ⏸️ untested no The accepted intent requires offline Treehouse proofs. Authorize acquisition and return against a disposable real pool to establish this lifecycle live.
An interrupted real acquisition retains its recovery identity and blocks unsafe retries ⏸️ untested no The offline Treehouse boundary prevents interrupting a real acquisition. Authorize a disposable real pool and controlled acquisition interruption.
An unrecognized acquired copy refuses claim and publication while retaining its recovery journal ⏸️ untested no Producing this result live requires a real acquisition, excluded by the accepted offline boundary. Authorize a disposable real pool configured to reproduce the identity mismatch.
Parent teardown prints manual recovery for a descendant whose leased copy is missing ⏸️ untested no Teardown refuses descendant-home removal targets inside the Firstmate repository. Live verification needs permission for a disposable home outside the worktree; the mocked descendant regression passed…
Evidence: Live CLI guards and stale-record cleanup

Source: Live CLI guards and stale-record cleanup

$ tmux -L fm-lab new-session -d -s checks -n guard -x 120 -y 40 -c ~/.no-mistakes/worktrees/7f0ec18181b6/01M5J1J041ZAMEAPEMVEM4AYB9 bash --noprofile --norc
[exit=0]

SCENARIO: Spawn refuses before allocation when a finished, aliased, or registered-home record names an unleased copy
$ bash ~/.no-mistakes/worktrees/7f0ec18181b6/01M5J1J041ZAMEAPEMVEM4AYB9/bin/fm-lab-home.sh create ~/.no-mistakes/worktrees/7f0ec18181b6/01M5J1J041ZAMEAPEMVEM4AYB9/.l2plpg9iq/retained-done/home
~/.no-mistakes/worktrees/7f0ec18181b6/01M5J1J041ZAMEAPEMVEM4AYB9/.l2plpg9iq/retained-done/home
[exit=0]
$ bash ~/.no-mistakes/worktrees/7f0ec18181b6/01M5J1J041ZAMEAPEMVEM4AYB9/bin/fm-spawn.sh candidate ~/.no-mistakes/worktrees/7f0ec18181b6/01M5J1J041ZAMEAPEMVEM4AYB9/.l2plpg9iq/retained-done/project --scout --backend tmux --harness codex
fm-gate-refuse: gate agent lifecycle permitted only against lab home ~/.no-mistakes/worktrees/7f0ec18181b6/01M5J1J041ZAMEAPEMVEM4AYB9/.l2plpg9iq/retained-done/home
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
●  WATCHER DOWN - SUPERVISION IS OFF
●  1 task(s) in flight, but no live watcher process holds this home lock (last beat: 0s ago).
●  Trust the emitted supervision protocol for this harness; do not use shell & for watcher repair.
●  This is a supervision warning only; the guarded operation WILL still run.
●  repair missing watcher supervision with a foreground checkpoint: bin/fm-watch-checkpoint.sh --seconds 180.
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
REFUSED: retained task retained (~/.no-mistakes/worktrees/7f0ec18181b6/01M5J1J041ZAMEAPEMVEM4AYB9/.l2plpg9iq/retained-done/home/state/retained.meta) names pool copy ~/.no-mistakes/worktrees/7f0ec18181b6/01M5J1J041ZAMEAPEMVEM4AYB9/.l2plpg9iq/retained-done/pool/1/project without a verified matching durable lease; reconcile its ownership and run guarded cleanup before spawning again. No Treehouse allocation was attempted.
[exit=1]
done: retained record, pool JSON and dirty sentinel unchanged; no allocation journal or candidate record
$ bash ~/.no-mistakes/worktrees/7f0ec18181b6/01M5J1J041ZAMEAPEMVEM4AYB9/bin/fm-lab-home.sh create ~/.no-mistakes/worktrees/7f0ec18181b6/01M5J1J041ZAMEAPEMVEM4AYB9/.l2plpg9iq/retained-alias/home
~/.no-mistakes/worktrees/7f0ec18181b6/01M5J1J041ZAMEAPEMVEM4AYB9/.l2plpg9iq/retained-alias/home
[exit=0]
$ bash ~/.no-mistakes/worktrees/7f0ec18181b6/01M5J1J041ZAMEAPEMVEM4AYB9/bin/fm-spawn.sh candidate ~/.no-mistakes/worktrees/7f0ec18181b6/01M5J1J041ZAMEAPEMVEM4AYB9/.l2plpg9iq/retained-alias/project --scout --backend tmux --harness codex
fm-gate-refuse: gate agent lifecycle permitted only against lab home ~/.no-mistakes/worktrees/7f0ec18181b6/01M5J1J041ZAMEAPEMVEM4AYB9/.l2plpg9iq/retained-alias/home
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
●  WATCHER DOWN - SUPERVISION IS OFF
●  1 task(s) in flight, but no live watcher process holds this home lock (last beat: 0s ago).
●  Trust the emitted supervision protocol for this harness; do not use shell & for watcher repair.
●  This is a supervision warning only; the guarded operation WILL still run.
●  repair missing watcher supervision with a foreground checkpoint: bin/fm-watch-checkpoint.sh --seconds 180.
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
REFUSED: retained task retained (~/.no-mistakes/worktrees/7f0ec18181b6/01M5J1J041ZAMEAPEMVEM4AYB9/.l2plpg9iq/retained-alias/home/state/retained.meta) names pool copy ~/.no-mistakes/worktrees/7f0ec18181b6/01M5J1J041ZAMEAPEMVEM4AYB9/.l2plpg9iq/retained-alias/alias without a verified matching durable lease; reconcile its ownership and run guarded cleanup before spawning again. No Treehouse allocation was attempted.
[exit=1]
alias: retained record, pool JSON and dirty sentinel unchanged; no allocation journal or candidate record
$ bash ~/.no-mistakes/worktrees/7f0ec18181b6/01M5J1J041ZAMEAPEMVEM4AYB9/bin/fm-lab-home.sh create ~/.no-mistakes/worktrees/7f0ec18181b6/01M5J1J041ZAMEAPEMVEM4AYB9/.l2plpg9iq/retained-registered/home
~/.no-mistakes/worktrees/7f0ec18181b6/01M5J1J041ZAMEAPEMVEM4AYB9/.l2plpg9iq/retained-registered/home
[exit=0]
$ bash ~/.no-mistakes/worktrees/7f0ec18181b6/01M5J1J041ZAMEAPEMVEM4AYB9/bin/fm-lab-home.sh create ~/.no-mistakes/worktrees/7f0ec18181b6/01M5J1J041ZAMEAPEMVEM4AYB9/.l2plpg9iq/retained-registered/mate
~/.no-mistakes/worktrees/7f0ec18181b6/01M5J1J041ZAMEAPEMVEM4AYB9/.l2plpg9iq/retained-registered/mate
[exit=0]
$ bash ~/.no-mistakes/worktrees/7f0ec18181b6/01M5J1J041ZAMEAPEMVEM4AYB9/bin/fm-spawn.sh candidate ~/.no-mistakes/worktrees/7f0ec18181b6/01M5J1J041ZAMEAPEMVEM4AYB9/.l2plpg9iq/retained-registered/project --scout --backend tmux --harness codex
fm-gate-refuse: gate agent lifecycle permitted only against lab home ~/.no-mistakes/worktrees/7f0ec18181b6/01M5J1J041ZAMEAPEMVEM4AYB9/.l2plpg9iq/retained-registered/home
REFUSED: retained task retained (~/.no-mistakes/worktrees/7f0ec18181b6/01M5J1J041ZAMEAPEMVEM4AYB9/.l2plpg9iq/retained-registered/mate/state/retained.meta) names pool copy ~/.no-mistakes/worktrees/7f0ec18181b6/01M5J1J041ZAMEAPEMVEM4AYB9/.l2plpg9iq/retained-registered/pool/1/project without a verified matching durable lease; reconcile its ownership and run guarded cleanup before spawning again. No Treehouse allocation was attempted.
[exit=1]
registered: retained record, pool JSON and dirty sentinel unchanged; no allocation journal or candidate record
OBSERVED: scenario assertions satisfied

SCENARIO: Spawn explains missing local-home state and ambiguous records before allocation
$ bash ~/.no-mistakes/worktrees/7f0ec18181b6/01M5J1J041ZAMEAPEMVEM4AYB9/bin/fm-lab-home.sh create ~/.no-mistakes/worktrees/7f0ec18181b6/01M5J1J041ZAMEAPEMVEM4AYB9/.l2plpg9iq/diagnostic-missing-home/home
~/.no-mistakes/worktrees/7f0ec18181b6/01M5J1J041ZAMEAPEMVEM4AYB9/.l2plpg9iq/diagnostic-missing-home/home
[exit=0]
$ bash ~/.no-mistakes/worktrees/7f0ec18181b6/01M5J1J041ZAMEAPEMVEM4AYB9/bin/fm-spawn.sh candidate ~/.no-mistakes/worktrees/7f0ec18181b6/01M5J1J041ZAMEAPEMVEM4AYB9/.l2plpg9iq/diagnostic-missing-home/project --scout --backend tmux --harness codex
fm-gate-refuse: gate agent lifecycle permitted only against lab home ~/.no-mistakes/worktrees/7f0ec18181b6/01M5J1J041ZAMEAPEMVEM4AYB9/.l2plpg9iq/diagnostic-missing-home/home
REFUSED: registered local Firstmate home is unavailable: ~/.no-mistakes/worktrees/7f0ec18181b6/01M5J1J041ZAMEAPEMVEM4AYB9/.l2plpg9iq/diagnostic-missing-home/mate; no Treehouse allocation was attempted
[exit=1]
$ bash ~/.no-mistakes/worktrees/7f0ec18181b6/01M5J1J041ZAMEAPEMVEM4AYB9/bin/fm-lab-home.sh create ~/.no-mistakes/worktrees/7f0ec18181b6/01M5J1J041ZAMEAPEMVEM4AYB9/.l2plpg9iq/diagnostic-missing-state/home
~/.no-mistakes/worktrees/7f0ec18181b6/01M5J1J041ZAMEAPEMVEM4AYB9/.l2plpg9iq/diagnostic-missing-state/home
[exit=0]
$ bash ~/.no-mistakes/worktrees/7f0ec18181b6/01M5J1J041ZAMEAPEMVEM4AYB9/bin/fm-spawn.sh candidate ~/.no-mistakes/worktrees/7f0ec18181b6/01M5J1J041ZAMEAPEMVEM4AYB9/.l2plpg9iq/diagnostic-missing-state/project --scout --backend tmux --harness codex
fm-gate-refuse: gate agent lifecycle permitted only against lab home ~/.no-mistakes/worktrees/7f0ec18181b6/01M5J1J041ZAMEAPEMVEM

... [8661 bytes truncated] ...

a=~/.no-mistakes/worktrees/7f0ec18181b6/01M5J1J041ZAMEAPEMVEM4AYB9/.l2plpg9iq/missing-copy/home/state/retained.meta
worktree=~/.no-mistakes/worktrees/7f0ec18181b6/01M5J1J041ZAMEAPEMVEM4AYB9/.l2plpg9iq/missing-copy/pool/1/project
Read project=, treehouse_lease_id=, and treehouse_lease_holder= from "$meta"; compare them with the acquisition journal and the pool treehouse-state.json. Do not use treehouse status.
Restore the original copy at "$worktree" from backup, including its Git metadata and unlanded work; do not create an empty replacement or overwrite another task's copy.
Verify that pool state still holds the exact recorded lease ID and holder and that .fm-slot-owner names this task and home. Do not fabricate ownership evidence.
If the original copy or matching ownership cannot be restored, keep the records and lease and obtain operator reconciliation; do not delete the metadata, journal, or claim or return another lease.
After restoring and verifying the original copy, retry guarded teardown:
  FM_HOME=~/.no-mistakes/worktrees/7f0ec18181b6/01M5J1J041ZAMEAPEMVEM4AYB9/.l2plpg9iq/missing-copy/home bash ~/.no-mistakes/worktrees/7f0ec18181b6/01M5J1J041ZAMEAPEMVEM4AYB9/bin/fm-teardown.sh retained
[exit=1]
Missing-copy refusal keeps metadata, acquisition journal and pool state unchanged
OBSERVED: scenario assertions satisfied

SCENARIO: Owner-first cleanup refuses, then stale-record cleanup leaves the successor copy, process, endpoint, claim and lease untouched
$ bash ~/.no-mistakes/worktrees/7f0ec18181b6/01M5J1J041ZAMEAPEMVEM4AYB9/bin/fm-lab-home.sh create ~/.no-mistakes/worktrees/7f0ec18181b6/01M5J1J041ZAMEAPEMVEM4AYB9/.l2plpg9iq/clash/home
~/.no-mistakes/worktrees/7f0ec18181b6/01M5J1J041ZAMEAPEMVEM4AYB9/.l2plpg9iq/clash/home
[exit=0]
$ tmux -L fm-lab new-window -d -t checks: -n fm-successor -c ~/.no-mistakes/worktrees/7f0ec18181b6/01M5J1J041ZAMEAPEMVEM4AYB9/.l2plpg9iq/clash/pool/1/project bash --noprofile --norc
[exit=0]
$ tmux -L fm-lab new-window -d -t checks: -n fm-stale -c ~/.no-mistakes/worktrees/7f0ec18181b6/01M5J1J041ZAMEAPEMVEM4AYB9/.l2plpg9iq/clash/project bash --noprofile --norc
[exit=0]
$ bash ~/.no-mistakes/worktrees/7f0ec18181b6/01M5J1J041ZAMEAPEMVEM4AYB9/bin/fm-teardown.sh successor --force
fm-gate-refuse: gate agent lifecycle permitted only against lab home ~/.no-mistakes/worktrees/7f0ec18181b6/01M5J1J041ZAMEAPEMVEM4AYB9/.l2plpg9iq/clash/home
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
●  WATCHER DOWN - SUPERVISION IS OFF
●  2 task(s) in flight, but no live watcher process holds this home lock (last beat: 1s ago).
●  Trust the emitted supervision protocol for this harness; do not use shell & for watcher repair.
●  This is a supervision warning only; the guarded operation WILL still run.
●  repair missing watcher supervision with a foreground checkpoint: bin/fm-watch-checkpoint.sh --seconds 180.
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
REFUSED: task successor's recorded worktree ~/.no-mistakes/worktrees/7f0ec18181b6/01M5J1J041ZAMEAPEMVEM4AYB9/.l2plpg9iq/clash/pool/1/project is also task stale's recorded worktree.
Returning that pool slot would kill stale's processes and reset its copy, so nothing was changed - not even with --force.
The slot claim names successor; reconcile stale task stale first with guarded teardown, then retry successor.
[exit=1]
$ tmux -L fm-lab has-session -t checks:fm-successor
[exit=0]
Owner-first cleanup refused; successor process and window still alive; successor copy, lease, claim and metadata unchanged
$ bash ~/.no-mistakes/worktrees/7f0ec18181b6/01M5J1J041ZAMEAPEMVEM4AYB9/bin/fm-teardown.sh stale --force
fm-gate-refuse: gate agent lifecycle permitted only against lab home ~/.no-mistakes/worktrees/7f0ec18181b6/01M5J1J041ZAMEAPEMVEM4AYB9/.l2plpg9iq/clash/home
WARNING: watcher still down (same stale episode; last beat: 3s ago, grace 300s) - full banner already printed this episode.
warning: task stale's recorded worktree ~/.no-mistakes/worktrees/7f0ec18181b6/01M5J1J041ZAMEAPEMVEM4AYB9/.l2plpg9iq/clash/pool/1/project was reassigned to task successor (home ~/.no-mistakes/worktrees/7f0ec18181b6/01M5J1J041ZAMEAPEMVEM4AYB9/.l2plpg9iq/clash/home), which claimed that pool slot after this record was written; that slot is no longer stale's, so its processes, copy, and claim are left untouched and only stale's own cleanup runs.
teardown: reaping leaked tasktmp process group for stale: 117588
teardown: force-killing leaked tasktmp process group for stale: 117588
teardown stale complete (window checks:fm-stale; pool slot ~/.no-mistakes/worktrees/7f0ec18181b6/01M5J1J041ZAMEAPEMVEM4AYB9/.l2plpg9iq/clash/pool/1/project left to task successor (home ~/.no-mistakes/worktrees/7f0ec18181b6/01M5J1J041ZAMEAPEMVEM4AYB9/.l2plpg9iq/clash/home), which it was reassigned to)
Backlog: stale just finished (config/backlog-backend selects manual editing). Update ~/.no-mistakes/worktrees/7f0ec18181b6/01M5J1J041ZAMEAPEMVEM4AYB9/.l2plpg9iq/clash/home/data/backlog.md - move stale to Done, keep Done to the 10 most recent, then re-scan Queued and dispatch only work whose blockers are gone and date is due.
[exit=0]
$ tmux -L fm-lab has-session -t checks:fm-successor
[exit=0]
Stale metadata retired; successor process and window still alive; successor copy, lease, claim and metadata unchanged
OBSERVED: scenario assertions satisfied

SCENARIO: Forced cleanup cannot bypass an unreadable slot-owner claim
$ bash ~/.no-mistakes/worktrees/7f0ec18181b6/01M5J1J041ZAMEAPEMVEM4AYB9/bin/fm-lab-home.sh create ~/.no-mistakes/worktrees/7f0ec18181b6/01M5J1J041ZAMEAPEMVEM4AYB9/.l2plpg9iq/unsafe-claim/home
~/.no-mistakes/worktrees/7f0ec18181b6/01M5J1J041ZAMEAPEMVEM4AYB9/.l2plpg9iq/unsafe-claim/home
[exit=0]
$ bash ~/.no-mistakes/worktrees/7f0ec18181b6/01M5J1J041ZAMEAPEMVEM4AYB9/bin/fm-teardown.sh retained --force
fm-gate-refuse: gate agent lifecycle permitted only against lab home ~/.no-mistakes/worktrees/7f0ec18181b6/01M5J1J041ZAMEAPEMVEM4AYB9/.l2plpg9iq/unsafe-claim/home
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
●  WATCHER DOWN - SUPERVISION IS OFF
●  1 task(s) in flight, but no live watcher process holds this home lock (last beat: 1s ago).
●  Trust the emitted supervision protocol for this harness; do not use shell & for watcher repair.
●  This is a supervision warning only; the guarded operation WILL still run.
●  repair missing watcher supervision with a foreground checkpoint: bin/fm-watch-checkpoint.sh --seconds 180.
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
REFUSED: task retained's recorded worktree ~/.no-mistakes/worktrees/7f0ec18181b6/01M5J1J041ZAMEAPEMVEM4AYB9/.l2plpg9iq/unsafe-claim/pool/1/project carries a slot-owner claim that cannot be read, so the slot cannot be proved to still be this task's; nothing was changed - not even with --force.
Inspect and reconcile the absent or unsafe claim file at ~/.no-mistakes/worktrees/7f0ec18181b6/01M5J1J041ZAMEAPEMVEM4AYB9/.l2plpg9iq/unsafe-claim/pool/1/.fm-slot-owner (task= and home= lines), then re-run teardown.
[exit=1]
Force did not override unreadable claim; record, copy and ownership evidence unchanged
OBSERVED: scenario assertions satisfied
$ tmux -L fm-lab kill-server
[exit=0]
CLEANUP: private tmux server stopped; all disposable lab homes and Git copies removed
Evidence: Validation report with results and limitations

Source: Validation report with results and limitations

# Targeted CLI validation

The real Firstmate CLI was exercised against constructed persisted records in marked disposable homes, using real Git and private tmux endpoints without mock executables.
The checks used no live Treehouse pool acquisition, status, or return operation and no credentialed worker launch.

## Live results

- PASS: Spawn refuses before allocation when a finished, aliased, or registered-home record names an unleased copy ([transcript](live-cli-transcript.log)).
- PASS: Spawn explains missing local-home state and ambiguous records before allocation ([transcript](live-cli-transcript.log)).
- PASS: Retry with an unresolved acquisition journal refuses and prints never-acquired and orphan-claim recovery ([transcript](live-cli-transcript.log)).
- PASS: Forced cleanup of a missing leased copy preserves ownership records and prints exact recovery steps ([transcript](live-cli-transcript.log)).
- PASS: Owner-first cleanup refuses, then stale-record cleanup leaves the successor copy, process, endpoint, claim and lease untouched ([transcript](live-cli-transcript.log)).
- PASS: Forced cleanup cannot bypass an unreadable slot-owner claim ([transcript](live-cli-transcript.log)).
- PASS: Forced cleanup validates the exact lease before killing an endpoint or changing hooks and scratch files ([transcript](live-relaunch-transcript.log)).
- PASS: Records-only cleanup of an unclaimed legacy ship still refuses dirty unlanded work ([transcript](live-relaunch-transcript.log)).
- PASS: The installed Treehouse version supports JSON leases and identity-conditional return ([transcript](live-relaunch-transcript.log)).
- PASS: Relaunch refuses stale leases, claims, duplicate ownership and unreadable local-home records before endpoint mutation ([transcript](live-relaunch-rerun-transcript.log)).

The stale-record cleanup proof kept a real process running inside the successor copy and verified that its endpoint, dirty sentinel, metadata, claim and serialized pool lease remained unchanged.
The relaunch checks compared pane PID, window identity, current working directory, metadata, claim and pool state before and after refusal.

## Focused offline checks

Five selected scripts completed successfully: slot ownership, worktree settling, pooled-copy freshness, endpoint safety, and bootstrap.
The first baseline used TMPDIR inside the source worktree; two suites stopped at existing safety guards that forbid removing secondmate or worktree fixtures inside the Firstmate repository.
Rerunning only those two suites with the default temporary directory passed.
The initial live relaunch driver expected a different duplicate-record message; the product correctly refused, and the corrected assertion passed on rerun.

Logs: [baseline](targeted-tests.log), [slot ownership rerun](slot-ownership-rerun.log), [endpoint safety rerun](endpoint-safety-rerun.log).

## Live limits

- Full acquire / exit / relaunch / conditional return remains untested live under the accepted offline Treehouse boundary; mocked executable regressions passed.
- Real interrupted and unrecognized-copy acquisitions remain untested live under the same boundary; recovery-journal and publication guards passed with mocked Treehouse.
- Live descendant-home teardown needs a disposable home outside this worktree because the product refuses removal targets inside the Firstmate source repository; the workspace boundary does not permit creating that live home here. The direct missing-copy recovery path passed live, and both direct and descendant paths passed the mocked regression.

All private tmux servers and disposable lab homes were removed. No source or test files were changed.
- Outcome: ⚠️ 1 warning across 1 run (9m48s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

🔧 **Review** - 4 issues found → auto-fixed (2) ✅
  • ⚠️ bin/fm-spawn.sh:5033 - If treehouse get --lease --json fails, every later spawn for that project is refused, and the printed recovery steps have no path for the most likely outcome. How it happens: Treehouse v2.3.0 fetches origin before it acquires a copy (its own get --help says so). An offline host or a remote outage therefore makes get exit non-zero after the journal's identity was written (fm-spawn.sh:5032), leaving allocation.json empty. spawn_abort_cleanup keeps the journal. From then on, fm_treehouse_records_reserved refuses every spawn for that project with "unresolved Treehouse acquisition journal" (fm-wake-lib.sh:1874-1876), and a retry of the same task id is refused at fm-spawn.sh:3586-3590. The recovery steps (fm-spawn.sh:1486-1491) only describe recovering a lease that exists in pool state. When no pool entry carries the recorded holder (the normal result of a fetch failure), no step lets the operator retire the journal, so they have to improvise an rm -rf of it. At base, a failed get just failed that one spawn. The fix needs a policy decision: what evidence proves the acquisition never happened (for example, no treehouse-state.json entry carries the recorded holder) and so allows the journal to be removed. That is a new evidence rule for retiring a journal, so the remedy needs authorization.
  • ⚠️ bin/fm-spawn.sh:5052 - A slot claim left behind by the old code makes the new spawn take a durable lease and then strand it, with no documented way out. The base code knowingly left claims behind: an abort after the project lock was released "leaves the claim for the next spawn's atomic replacement" (removed base comment in spawn_abort_cleanup), so after an upgrade some free pool slots still carry a .fm-slot-owner naming a task that no record describes. Preflight passes, because no record names that copy. get --lease can then hand out such a slot. The spawn finds a non-absent claim and refuses (fm-spawn.sh:5050-5053; the same check again at :5125-5129) while keeping both the durable lease and the journal. That copy stays out of the pool, retries of the same task id are blocked, and the recovery text says "Stop if another task owns the claim or lease" (fm-spawn.sh:1487). The text never says how to confirm a claim is orphaned or how to clear it, so each leftover claim costs one slot and one task id until someone improvises a manual cleanup. The intent forbids overwriting a conflicting claim, so the refusal itself is correct. A remedy needs authorization: a documented rule for treating a claim as orphaned (no local record anywhere names that task and home) and returning this acquisition's own lease.
  • ⚠️ bin/fm-wake-lib.sh:1697 - Spawn and teardown now require the full Treehouse lease CLI (get --lease --lease-holder --json plus return --if-lease-id --if-lease-holder, checked by fm_treehouse_lease_cli and enforced at fm-spawn.sh:3817 and fm-teardown.sh require_owned_worktree_slot_record). The bootstrap check that tells the operator to upgrade still looks only for --lease (bin/fm-bootstrap.sh:906-908, used at :1472-1475). An install of Treehouse 2.0.1 (the previous CI pin, which already supported --lease for home seeding) passes bootstrap with no MISSING line. Every ship and scout dispatch then fails at spawn, and teardown of a leased task refuses. Fix: have treehouse_supports_lease check the same flag set as fm_treehouse_lease_cli (or call it), so bootstrap reports MISSING: treehouse before anything is dispatched.
  • ℹ️ bin/fm-wake-lib.sh:1816 - fm_treehouse_records_reserved and fm_treehouse_record_exclusive (fm-wake-lib.sh:1895) return 1 without printing anything when a local state dir is missing or unreadable. That dir can be the root home's or a registered secondmate home's state/. The fresh spawn (fm-spawn.sh:3592) and the relaunch (fm-spawn.sh:3584) then exit 1 with no explanation. The sibling capacity scan (fm-project-capacity-lib.sh:190-193) treats a missing state dir as empty and names an unreadable one. Fix: print a REFUSED line naming the directory before returning, matching the other refusals in these functions.

🔧 Fix applied.
3 issues (1 warning, 2 infos) still open:

  • ⚠️ bin/fm-wake-lib.sh:1697 - Spawn and teardown now require the full Treehouse lease CLI (get --lease --lease-holder --json plus return --if-lease-id --if-lease-holder, checked by fm_treehouse_lease_cli and enforced at fm-spawn.sh:3817 and fm-teardown.sh require_owned_worktree_slot_record). The bootstrap check that tells the operator to upgrade still looks only for --lease (bin/fm-bootstrap.sh:906-908, used at :1472-1475). An install of Treehouse 2.0.1 (the previous CI pin, which already supported --lease for home seeding) passes bootstrap with no MISSING line. Every ship and scout dispatch then fails at spawn, and teardown of a leased task refuses. Fix: have treehouse_supports_lease check the same flag set as fm_treehouse_lease_cli (or call it), so bootstrap reports MISSING: treehouse before anything is dispatched.
  • ℹ️ bin/fm-wake-lib.sh:1816 - fm_treehouse_records_reserved and fm_treehouse_record_exclusive (fm-wake-lib.sh:1895) return 1 without printing anything when a local state dir is missing or unreadable. That dir can be the root home's or a registered secondmate home's state/. The fresh spawn (fm-spawn.sh:3592) and the relaunch (fm-spawn.sh:3584) then exit 1 with no explanation. The sibling capacity scan (fm-project-capacity-lib.sh:190-193) treats a missing state dir as empty and names an unreadable one. Fix: print a REFUSED line naming the directory before returning, matching the other refusals in these functions.
  • ℹ️ bin/fm-wake-lib.sh:1897 - The round-1 fix for silent-refusal-missing-state-dir added a REFUSED line only for a missing or unreadable state directory. It missed sibling silent return 1 exits in the same function, fm_treehouse_record_exclusive: the local-home registry walk failing at fm-wake-lib.sh:1897 (fm_local_firstmate_state_dirs &#34;$state&#34; || return 1), an ambiguous record at :1905 (fm_treehouse_record_paths_safe &#34;$meta&#34; || return 1), and the slot path failing to resolve at :1896. Its relaunch caller (fm-spawn.sh:3588, || exit 1) runs no other scan, so these refusals print nothing. Example: a registered secondmate home that was deleted but is still listed in data/secondmates.md sets FM_LOCAL_FIRSTMATE_ERROR="registered local Firstmate home is unavailable". Every Treehouse relaunch in the root home then exits 1 with no explanation. The sibling fm_treehouse_records_reserved (:1811-1813, :1822-1825) already prints REFUSED lines for the same two conditions, and so does teardown's collect_local_firstmate_states (fm-teardown.sh:2445-2447). Fix: print REFUSED: $FM_LOCAL_FIRSTMATE_ERROR and the 'unreadable or ambiguous task record $meta' line in fm_treehouse_record_exclusive, matching fm_treehouse_records_reserved. The post-get callers (fm-spawn.sh:5052, :5129) benefit from the same change.

🔧 Fix applied.
✅ Re-checked - no issues remain.

⚠️ **Test** - 1 warning
  • ⚠️ live validation verdict: inconclusive (10 of 14 scenarios were driven live against the product); untested: Acquire distinct copies, retain lease identity through exit and relaunch, and release only the matching lease at cleanup, An interrupted real acquisition retains its recovery identity and blocks unsafe retries, An unrecognized acquired copy refuses claim and publication while retaining its recovery journal, Parent teardown prints manual recovery for a descendant whose leased copy is missing
  • Live validation: ⚠️ inconclusive - 10 of 14 scenarios driven live against the product
Scenario Result Live Evidence
Spawn refuses before allocation when finished, aliased, or registered-home records name an unleased copy ✅ pass live Live CLI guards and stale-record cleanup
Spawn explains missing local-home state and ambiguous records before allocation ✅ pass live Live CLI guards and stale-record cleanup
Retry preserves an unresolved acquisition journal and prints never-acquired and orphan-claim recovery steps ✅ pass live Live CLI guards and stale-record cleanup
Forced cleanup of a missing leased copy preserves ownership records and prints recovery steps ✅ pass live Live CLI guards and stale-record cleanup
Owner-first cleanup refuses, then stale-record cleanup preserves the successor’s copy, process, endpoint, claim and lease ✅ pass live Live CLI guards and stale-record cleanup
Forced cleanup cannot bypass an unreadable slot-owner claim ✅ pass live Live CLI guards and stale-record cleanup
Relaunch refuses stale leases, conflicting claims, duplicate ownership and unreadable records before endpoint mutation ✅ pass live Corrected live relaunch checks
Forced cleanup validates the exact lease before killing an endpoint or changing hooks and scratch files ✅ pass live Live cleanup guards and Treehouse CLI capabilities
Records-only cleanup of an unclaimed legacy ship still refuses dirty unlanded work ✅ pass live Live cleanup guards and Treehouse CLI capabilities
Installed Treehouse v2.3.0 advertises JSON leases and both conditional-return guards ✅ pass live Live cleanup guards and Treehouse CLI capabilities
Acquire distinct copies, retain lease identity through exit and relaunch, and release only the matching lease at cleanup ⏸️ untested no The accepted intent requires offline Treehouse proofs. Authorize acquisition and return against a disposable real pool to establish this lifecycle live.
An interrupted real acquisition retains its recovery identity and blocks unsafe retries ⏸️ untested no The offline Treehouse boundary prevents interrupting a real acquisition. Authorize a disposable real pool and controlled acquisition interruption.
An unrecognized acquired copy refuses claim and publication while retaining its recovery journal ⏸️ untested no Producing this result live requires a real acquisition, excluded by the accepted offline boundary. Authorize a disposable real pool configured to reproduce the identity mismatch.
Parent teardown prints manual recovery for a descendant whose leased copy is missing ⏸️ untested no Teardown refuses descendant-home removal targets inside the Firstmate repository. Live verification needs permission for a disposable home outside the worktree; the mocked descendant regression passed…
  • TMPDIR="$PWD/.test-validation-tmp" FM_TEST_MOCK_LIFECYCLE_ONLY=1 bash bin/fm-test-run.sh --jobs 1 tests/fm-spawn-slot-ownership.test.sh tests/fm-spawn-worktree-settle.test.sh tests/fm-spawn-pool-base-freshen.test.sh tests/fm-teardown-endpoint-safety.test.sh tests/fm-bootstrap.test.sh
  • env -u TMPDIR FM_TEST_MOCK_LIFECYCLE_ONLY=1 bash bin/fm-test-run.sh --jobs 1 tests/fm-spawn-slot-ownership.test.sh
  • env -u TMPDIR FM_TEST_MOCK_LIFECYCLE_ONLY=1 bash bin/fm-test-run.sh --jobs 1 tests/fm-teardown-endpoint-safety.test.sh
  • python3 ~/.no-mistakes/evidence/01M5J1J041ZAMEAPEMVEM4AYB9/live-cli-checks.py
  • python3 ~/.no-mistakes/evidence/01M5J1J041ZAMEAPEMVEM4AYB9/live-relaunch-checks.py
  • python3 ~/.no-mistakes/evidence/01M5J1J041ZAMEAPEMVEM4AYB9/live-relaunch-rerun.py
  • treehouse --version, treehouse get --help, and treehouse return --help
  • Removed disposable homes, stopped private tmux servers, removed test temporary directories, and verified a clean working tree.
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

peterOC26 and others added 15 commits October 22, 2026 11:33
A record from before durable leases may relaunch into its own claimed,
unleased copy; fresh-spawn preflight already keeps that copy out of
allocation. A cleanup re-run after an earlier run returned the copy and
then failed retires records only instead of refusing forever.
…es for durable leases, distinct copies, and ownership claims. Targeted regressions and fast lint pass. Live Herdr verification remains blocked by its reference-session prerequisite; the full secondmate safety suite hit temporary-disk limits
…rktree-record-clash-fix-c2

# Conflicts:
#	tests/fm-backend-herdr-presentation-e2e.test.sh
Brings the branch to the validated pipeline tree: Herdr and child-cleanup
fixture repairs, missing-copy and unrecognized-slot recovery handling,
empty record fields treated as absent, and refreshed lease documentation.
Durable leases now keep a copy reserved while its record exists, and a
Treehouse return terminates processes in the copy. The orphan fixture
returned its copy mid-suite, killing the restored husk shell the reclaim
under test must find. Retire only the acquisition journal, keep the
record for the reclaim, and clear stale slot claims when the suite
returns copies whose records are already torn down.
@peterOC26 peterOC26 changed the title fix: reserve task pool copies until explicit cleanup fix: reserve Treehouse pool copies until explicit task cleanup Oct 22, 2026
peterOC26 added 2 commits October 22, 2026 18:17
…Check diagnostics, and moved Herdr pane closure before process reaping and pool return. Targeted regressions and lint pass. Full cleanup verification remains limited by missing lsof
… remote worker tree before deleting fixtures. Added a regression that failed before the fix and now passes. The full public-followup suite passes with an isolated TMPDIR; lint and diff checks pass
@peterOC26
peterOC26 merged commit 3fa9940 into main Oct 23, 2026
18 of 19 checks passed
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