Skip to content

Commit e66b688

Browse files
committed
no-mistakes(document): Document already-returned worktree teardown recovery
1 parent 4c414e5 commit e66b688

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

AGENTS.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,8 @@ bin/fm-teardown.sh <id>
541541
```
542542

543543
The script refuses if the worktree holds uncommitted changes or committed work that has not landed; treat a refusal as a stop-and-investigate, not an obstacle.
544-
Teardown validates that the recorded project and worktree are exact roots with the expected repository registration, quiesces every ordinary task endpoint, and then runs the final non-destructive safety checks before any Treehouse return.
544+
Teardown normally validates that the recorded project and worktree are exact roots with the expected repository registration, quiesces every ordinary task endpoint, and then runs the final non-destructive safety checks before any Treehouse return.
545+
It can also finish bookkeeping for a provably landed worktree whose Treehouse lease was already cleared; `bin/fm-teardown.sh`'s header owns the fail-closed recovery contract.
545546
For a task whose metadata carries `report_required=1`, teardown also publishes the validated completion report before releasing the account lease or removing the worktree.
546547
A safety refusal after quiescence leaves the endpoint stopped while preserving all task state for repair and retry.
547548
`bin/fm-teardown.sh`'s header owns the full landed-work definition (remote-reachable, merged-PR-head containment for the squash-merge-then-delete-branch flow, content already in the default branch, local-only merges) and the `pr=` discovery fallback for merges that skipped `bin/fm-pr-check.sh`.

bin/fm-teardown.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@
2929
# Uncommitted changes are never landed.
3030
# Ordinary teardown first proves that metadata names the exact registered project,
3131
# worktree, and task lease, then quiesces the endpoint before its final safety checks.
32+
# If Treehouse already cleared that exact pool entry's lease, teardown treats the
33+
# worktree as a partial or completed external return only when the state has exactly
34+
# one matching entry, leased=false, no lease holder, and destroying is not true.
35+
# It then re-proves landed work under the checkout lock before completing the return
36+
# or cleaning the returned worktree, branch, and task bookkeeping. A missing
37+
# worktree directory is accepted only through the same cleared-lease proof and a
38+
# recovered task branch whose landed state can still be proved; ambiguous lease
39+
# state, branch lookup failure, and unlanded recovered work all retain task state.
3240
# Each locked Treehouse return repeats repository, lease, and landed-work checks
3341
# immediately before the destructive return command.
3442
# local-only projects additionally accept work merged into the local default

0 commit comments

Comments
 (0)