Repository navigation
fix(bin): let a stale record on a reassigned slot retire records-only - #6213
Merged
kunchenguid merged 2 commits intoSep 30, 2026
Merged
kunchenguid merged 2 commits into
kunchenguid merged 2 commits into
Conversation
When a pool slot's owner claim names another task, the stale record's teardown touches nothing under the slot, so the exclusive-slot record scan no longer refuses it. Full teardowns of a slot this task still claims, or one with no claim, keep the refusal. Fixes kunchenguid#6184
…ed teardown slots
|
Owner
|
Speaking as Kun's firstmate: this is merged. Thank you @karotkriss — really appreciate you taking the time on this. |
TastyTom13
referenced
this pull request
in TastyTom13/firstmate
Sep 30, 2026
- ci: the merged tree has 61 Bearings tests (upstream 60 plus the fork's one). - teardown: a shared-worktree record on a slot claimed by another task retires records-only, matching upstream's reassigned-slot exception (#6213). - contributions: restore the fork's settled field on terminal records, drop the runner entry for the near-deadline test the fork replaced with its retry test, and fix the truncated late-owner test name. Upstream's terminal and failure episode tests now reflect the fork's daily closed recheck and single retry. - watcher: upstream's own-work wait test now follows the fork rule that a declared pause is absorbed on first sight; comments no longer promise a first-sight stale alert. - tests: the context-budget fixture copies the libraries upstream's guard now loads, the free-lane secondmate fixture is a git repo as upstream's trailer hooks require, and the Orca bridge fixture uses Orca's composite worktree id.
This was referenced Oct 1, 2026
Closed
Closed
Closed
Intent
Fixes #6184
When a task's recorded worktree slot has been handed to another task,
bin/fm-teardown.sh <stale-task>correctly chooses a records-only retirement (ALLOC_RECORDS_ONLY=1), but then still runsrequire_exclusive_task_worktree_slot, which refuses because the slot's current owner also names that path.The stale record can then never be retired, with or without
--force, and it blocks teardown of the task that legitimately holds the slot.A records-only retirement touches no worktree, so when the slot's positive owner claim names a different live task the exclusivity check should allow it, while every full teardown that acts on the worktree keeps the check.
What Changed
bin/fm-teardown.sh:require_exclusive_worktree_slot_recordnow checks the slot's owner claim before the cross-home record scan. When the claim names a different task, the check returns early. The teardown is records-only in that case, so a stale record on a reassigned slot can retire even while the claimant's own record names the same path, and it no longer blocks the claimant's teardown. Slots this task still claims, or slots with no claim, still get the full exclusivity scan. The header comments now describe the exception.tests/fm-teardown-endpoint-safety.test.sh: addstest_stale_record_on_claimed_slot_retires_then_claimant_tears_down. It covers a pool slot where both records survive. Tearing down the stale task leaves the slot, its sentinel and the claimant's record untouched. Tearing down the claimant afterwards removes its record and its slot claim, then returns the pool slot.docs/architecture.md: updates the slot-ownership paragraph. A claim naming another task releases nothing, even when that task also has a contradictory record.Fixes #6184
Risk Assessment
✅ Low: The change is a small guard that skips the record-exclusivity scan only when the slot's claim names another task, and that is the same determination that already makes every slot-touching step records-only. Both reads of the claim happen under the held Treehouse project lock, and the new test reproduces the stranding and then the claimant's teardown end to end.
Testing
I ran the real
bin/fm-teardown.shagainst disposable marked lab homes. Each lab had a real treehouse pool slot leased under TREEHOUSE_ROOT, a live worker process in the slot, a claim file written by the product's own lib, and a private tmux server with task windows. On base eb77f02 the stale record could never be retired: teardown refused with and without--force, and it also blocked the teardown of the task that holds the slot. On the target commit the stale record retires records-only and leaves the slot, its worker, its claim and the other task's files untouched. The slot-holding task then tears down normally and treehouse shows the slot available again. The guard cases all still refuse with nothing changed: the slot-holding task tearing down while the stale record exists, no claim, a claim naming the task itself, and an unreadable claim. Without--force, the stale teardown gets past the exclusivity check and stops only at the scout captain-call gate, which this change does not touch. The focused test filetests/fm-teardown-endpoint-safety.test.shpasses, including the new regression test, but that is a fixture test with a stubbed treehouse and is not counted as a live result. All labs and temp copies were removed, and the worktree is clean.Evidence: Base eb77f02 repro: stale record refused with and without --force, and it also blocks the slot-holding task's teardown
Source: Base eb77f02 repro: stale record refused with and without --force, and it also blocks the slot-holding task's teardown
Evidence: Target 65c3e01: stale record retires records-only, then the slot-holding task tears down and the slot returns to the pool
Source: Target 65c3e01: stale record retires records-only, then the slot-holding task tears down and the slot returns to the pool
Evidence: Target guard cases: exclusivity check still refuses for full teardowns (slot-holder first, no claim, own claim, unreadable claim)
Source: Target guard cases: exclusivity check still refuses for full teardowns (slot-holder first, no claim, own claim, unreadable claim)
Evidence: Target: stale teardown without --force gets past the exclusivity check (stops at the unrelated captain-call gate)
Source: Target: stale teardown without --force gets past the exclusivity check (stops at the unrelated captain-call gate)
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
✅ **Test** - passed
✅ No issues found.
Reproduced #6184 on base eb77f02 (git archive eb77f02into a temp dir): ran realbin/fm-teardown.sh stale-task,stale-task --forceandlive-task --forceagainst a marked lab FM_HOME with a real treehouse lease (TREEHOUSE_ROOT=$LAB/pool treehouse get --lease --no-fetch), a real slot claim written byfm_treehouse_slot_owner_claim, and a private-socket tmux server. All three refused.Target 65c3e01: ranbin/fm-teardown.sh stale-task --forcein the same lab (records-only, slot left alone), thenbin/fm-teardown.sh live-task --force(full teardown, slot returned to the pool).Target guard cases: the claimant's full teardown while the stale record remains; both records with no claim; claim naming stale-task itself; unreadable claim; all run with--force.Target:bin/fm-teardown.sh stale-taskwithout --force (with a report written), to confirm the exclusivity check no longer blocks it.bash tests/fm-teardown-endpoint-safety.test.sh(focused suite, including the new test_stale_record_on_claimed_slot_retires_then_claimant_tears_down)✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.