Repository navigation
fix: retire a leased task record when its copy and lease are both gone - #67
Merged
Merged
Conversation
Direct and descendant teardown kept a leased record and printed manual recovery steps whenever the copy directory was missing. When readable pool state shows no entry naming that path and none carrying the lease id, teardown now retires the record, drops only this task's own slot claim, and leaves the pool untouched. Any weaker proof still keeps the record and prints the recovery steps.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
Teardown: rule for retiring a leased task record whose copy directory is gone
Resolution recorded by fm-captain-hold.
Decision digest: 5bdc02baef9afb174011b9518ace85ceccc9553f92fc3327f30be8528c439697
Resolution mode: released
Captain decision:
Captain 2026-11-15 (Jobs page note 1794703235-3uxISq): "The 11 firstmate fixes - do all of these". Start now instead of the staggered dates; Grok builds, DeepSeek checks, firstmate repo reviews one at a time (fleet 133), captain merges each.
Follow-up from fm-worktree-record-clash-fix-c2 review r3 (leased-copy-missing-strands-record): that PR only prints manual recovery steps; deciding what evidence may retire such a record automatically (e.g. no pool entry names the path and none carries the lease_id) extends the ownership contract and needs its own decision.
"The 11 firstmate fixes - do all of these" (2026-11-15)
What Changed
bin/fm-teardown.sh) now retires the task record without touching the pool, but only if the copy is provably absent and the readabletreehouse-state.jsonhas no entry naming that path and no entry carrying the recorded lease id. It also removes this task's own.fm-slot-ownerclaim if one is still there, and the completion message says the pool was left untouched. If that proof is missing, for example because pool state is missing, unreadable, a symlink, or malformed, or a matching entry exists, teardown still refuses, keeps the lease and records, and prints the manual recovery steps.bin/fm-treehouse-slot-lib.sh(fm_treehouse_lexical_absolute,fm_treehouse_anchor_path,fm_treehouse_copy_provably_absent,fm_treehouse_missing_copy_lease_unheld) build the proof without running any Treehouse command.bin/fm-wake-lib.shrecords the retirement rule in the ownership contract and lets the slot-claim helpers read and remove a claim next to a copy that no longer exists (missingmode,fm_treehouse_missing_copy_release_own_claim). It never removes another task's claim.docs/configuration.mdnow describes the automatic retirement and keeps the manual recovery steps as the fallback.tests/fm-spawn-slot-ownership.test.shadds a test where the copy is deleted and its pool entry dropped, and teardown then retires the record.🤖 Generated with Claude Code
Risk Assessment
✅ Low: The change adds the captain-authorized rule for automatically retiring a leased task record whose copy is gone. It is conservative: retirement requires provable absence of the copy and pool state that is a real, readable, well-formed file with no entry naming the path or carrying the lease id. It never runs Treehouse, never touches another task's claim, and refuses with recovery steps in every other case. Direct and descendant teardown are both covered by behavioral tests.
Testing
I ran the targeted slot-ownership suite, which passed. It drives the real fm-teardown.sh against throwaway pools, with a fake Treehouse and fake tmux, through the direct, descendant, slot-removed and other-task-claim retire cases and the path-still-listed, lease-moved, symlinked-pool and malformed-pool refuse cases. Then I ran two live end-to-end checks in throwaway /tmp homes. The real fm-spawn.sh took a lease from the real Treehouse, I deleted the copy, and the real fm-teardown.sh ran. The tmux window and agent launch were stubbed with the repo's test fixtures, so no real agent started. With no pool entry naming the path or the lease, teardown printed the new warning and completion message, exited 0, and removed the task records and its own slot claim. The pool state stayed byte-identical and the moved-aside copy was untouched. With the real Treehouse still holding the lease, teardown refused with the manual recovery steps, exited 1, and kept the record, the acquisition journal, the slot claim and the pool state. The first live attempt failed during my setup, because the throwaway origin had no default branch set. I fixed that and re-ran both checks. All temp dirs were removed, and the worktree is clean.
bash tests/fm-spawn-slot-ownership.test.sh: 'ok - a missing leased copy retires only when no pool entry names its path or carries its lease' and 'ok - missing leased copies retain records and print…Evidence: Live teardown: copy gone, pool names neither path nor lease → record retired, pool untouched
Source: Live teardown: copy gone, pool names neither path nor lease → record retired, pool untouched
Evidence: Live teardown: copy gone, real Treehouse still holds the lease → refused, records and lease kept
Source: Live teardown: copy gone, real Treehouse still holds the lease → refused, records and lease kept
Evidence: Targeted slot-ownership suite transcript
Source: Targeted slot-ownership suite transcript
Evidence: Retire transcript excerpt
Pipeline
Updates from git push no-mistakes
✅ **Intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
bin/fm-teardown.sh:3058- The missing-copy retirement branch inside require_owned_worktree_slot_record deletes this task's own.fm-slot-ownerclaim (fm_treehouse_missing_copy_release_own_claim) during what is otherwise a validation pass. Teardown can still abort after that and keep the records. Direct path: require_owned_task_worktree_slot at fm-teardown.sh:4100 runs before validate_pr_poll_cleanup and the later endpoint/backlog steps. Descendant path: the preflight scan at fm-teardown.sh:3716 runs before the remaining descendants are validated. A re-run still converges: the claim is now absent, release_own_claim treats that as nothing to remove, and the pool proof still holds, so the record retires. If the pool later lists the path again, the re-run refuses safely. So the only effect is that the claim is removed before the records it belongs to. Optional tidy-up: record that a claim release is pending and do it after the records are removed. No change is required.✅ **Test** - passed
✅ No issues found.
bash tests/fm-spawn-slot-ownership.test.sh: 'ok - a missing leased copy retires only when no pool entry names its path or carries its lease' and 'ok - missing leased copies retain records and print…bash tests/fm-spawn-slot-ownership.test.sh(the newtest_missing_leased_copy_retires_when_pool_names_neither_path_nor_leaseplus the existing missing-copy, recovery and ownership cases; all ok, rc=0)Live, pool entry dropped: realbin/fm-spawn.sh live1 <proj> --scoutleased a copy through the realtreehouse get --lease; then I moved the copy aside, removed its entry from the pool's treehouse-state.json, and ran the realbin/fm-teardown.sh live1 --forceLive, pool still holds the lease: same setup, but the real Treehouse pool entry still named the path and lease beforebin/fm-teardown.sh live1 --force✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.