Repository navigation
fix(bin): let teardown retire tasks with an absent or reassigned worktree - #6229
AgardnerAU wants to merge 15 commits into
Conversation
…r task Teardown now finishes a records-only cleanup - endpoint, status, records, checks, backlog - when a ship or scout record names no worktree, when its recorded path provably no longer exists, or when its slot's owner claim names another task even while that task's record also names the slot. No step reads, resets, kills under, or returns that path, and --force is unchanged. Duplicated worktree identities, collisions the claim does not resolve, Orca, and secondmates keep their existing refusals.
…own copy Run the recorded-work landed proof for every ship whose own copy is not inspected - no worktree recorded, no directory at the recorded path, or a slot another task claims - so only --force retires unproven work. Move the landed-proof globals above pr_number_from_branch's comment, and give the test fixtures that record a ship with an absent copy a pushed branch.
[Medium impact] The change affects task retirement in the teardown workflow. The PR should not merge until the records-only proof stops accepting mirror-only work as pushed. Reviews (4) · Last reviewed commit: "Merge branch 'main' of https://github.co..." · Reviewed by Greptile |
…worktree-unreapable # Conflicts: # docs/architecture.md
…worktree-unreapable # Conflicts: # bin/fm-teardown.sh
…deleted A teardown that proves a ship's own copy landed now records landed_proven=1 before deleting the task branch, so a retry whose returned slot another task has claimed accepts that proof instead of refusing on the missing branch. Also give upstream's gone-worktree pipeline-spend test the landed-work proof that records naming no inspectable copy now require.
The retry-after-partial-teardown concern (Greptile 'Retries lose pushed-work proof') was declined in earlier review rounds, so remove the landed_proven writer, its reader, its header text, and its two tests. Keep the merged-PR proof in upstream's gone-worktree pipeline-spend test, which this PR's landed-work gate requires.
|
Merged current main into this branch (head 2a3cd16) and resolved the conflicts in bin/fm-teardown.sh, keeping both upstream's Forgejo and base-branch changes and this PR's absent-worktree handling. Upstream's new gone-worktree pipeline-spend test now records a merged PR, because this PR requires landed-work proof for a copy it cannot inspect. The Greptile finding 'Retries lose pushed-work proof' was considered and declined in earlier review rounds, so there is no code change for it. Up to date with main and ready for CI. |
|
Speaking as Kun's firstmate: thank you @AgardnerAU — and thanks for the main merge today. Records-only teardown once landed work is proved (and a hard refuse when it is not) matches the spine we already promised. VISION (each rule):
Contract-class: restore. Existing default: teardown retires a finished task when its work is landed/pushed, and refuses discard without proof or Where it stands: attestation MATCH |
…n gate fm-project-capacity's teardown fixture records an absent worktree with no branch or PR, so the landed-work gate refuses it. Record a pushed branch, as the other absent-worktree fixtures do.
|
Speaking as Kun's firstmate: thanks @AgardnerAU. Contract-class: I'm revising my earlier read from restore to new-default. That fixture change is what showed me why. On main, a ship whose recorded worktree path is no directory, or whose pool slot another task now claims, tears down without a landed-work proof. Main's own tests specify that: This PR adds a landed-work gate to those paths: teardown refuses unless the branch is pushed, its PR is merged, or its content is already in the default branch, or the caller passes VISION.md: one captain / authority / scripts / restart / spine / vendor / scope all align. It strengthens a refusal path, and Status: waiting-ci. Once this is green on a green main, it goes to Kun to merge or leave instead of auto-merging. It overlaps #5435 ( |
…worktree-unreapable # Conflicts: # bin/fm-backend.sh # bin/fm-teardown.sh
|
Speaking as Kun's firstmate: thanks @AgardnerAU for bringing this up to date with main. I'm sorry it sat this long after the last round. What I checked: head Verdict (unchanged from 10-13): contract-class is new-default. On main, a gone-worktree or reassigned-slot ship tears down without any landed-work proof, and main's own tests specify that. This PR puts a new refusal on that default path. It does follow VISION's "unlanded work is never torn down," but a new refusal on a specified default path is the captain's call. VISION.md: one captain aligns · authority aligns ( Where it stands: waiting on CI. Nothing is needed from you. Once this head is green and mergeable, it goes to the captain for a merge-or-leave decision instead of auto-merging. It still overlaps the open #5435 and #6760 in |
…worktree-unreapable
…worktree-unreapable # Conflicts: # bin/fm-teardown.sh
…fm/fm-teardown-empty-worktree-unreapable # Conflicts: # bin/fm-backend.sh # bin/fm-teardown.sh
| LANDED_REV= | ||
| if [ -n "$branch" ] && git -C "$PROJ" show-ref --verify --quiet "refs/heads/$branch"; then | ||
| LANDED_REV=refs/heads/$branch | ||
| if ! unpushed_raw=$(git -C "$PROJ" log --oneline "$LANDED_REV" --not --remotes -- 2>/dev/null); then |
There was a problem hiding this comment.
Mirror-only work is marked done
When an absent-worktree task's branch exists only on the local no-mistakes mirror, this check treats it as pushed and returns success before checking its PR or content. Teardown can then close the endpoint, remove the task record, and mark unfinished work done without --force.
The existing worktree check deliberately excludes that mirror because it is not a forge. Add the same --exclude='no-mistakes/*' before --remotes here.
| if ! unpushed_raw=$(git -C "$PROJ" log --oneline "$LANDED_REV" --not --remotes -- 2>/dev/null); then | |
| if ! unpushed_raw=$(git -C "$PROJ" log --oneline "$LANDED_REV" --not --exclude='no-mistakes/*' --remotes -- 2>/dev/null); then |
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
|
Speaking as Kun's firstmate: thanks @AgardnerAU for merging main into this tip ( Waiting on you for two gates:
Contract-class stays new-default (gone-worktree / reassigned-slot teardown now gated). Overlaps #5435 / #6760 unchanged; any conflict is ours. Rockets: none. Unlabelled Full suite failure is our label gate. |
Intent
Update the existing pull request #6229 (branch fm/fm-teardown-empty-worktree-unreapable, from the AgardnerAU fork) onto current upstream main and push so CI re-runs. The earlier CI failures came from GitHub moving ubuntu-latest to ubuntu-26.04, fixed on main by upstream PR 7798 (an ubuntu-24.04 pin), and were not caused by this change. That PR lets bin/fm-teardown.sh retire a task whose recorded local copy (worktree) is absent or now belongs to another task, when the task's own work has landed or is pushed; work that cannot be proven landed or pushed still refuses unless --force is given. Keep updating the existing PR; do not replace it. If only the known flaky cases fail on main itself (fm-supervision-host serial 1, fm-watch-wedge-cap serial 4), report that rather than chasing them.
What Changed
bin/fm-teardown.shcan now do a records-only cleanup of a ship or scout task that has no local copy to inspect. This applies when the record names no worktree (noworktree=line, or one empty line), when the recorded path is not a directory, or when the slot now belongs to another task. In each case teardown cleans up only the task's own endpoint, status, records, checks and backlog. It does not touch a slot. Two or moreworktree=lines still refuse.validate_recorded_work_landedgate keeps the landed-work check for these tasks. It proves the work from the record: every commit on the recorded branch in the project repository is on a remote-tracking branch (a fork counts), or the PR is merged and holds that work, or the branch content is already in the default branch. If none of these is true, teardown refuses, shows the evidence, and continues only with--force. To make this possible, the existing landed-work helpers now read from a configurable repository and revision (LANDED_REPO/LANDED_REV) instead of the worktree'sHEAD.fm_backend_validate_task_endpointinbin/fm-backend.shhas a new--allow-unrecorded-worktreeoption, which only teardown uses. Teardown never passes it for secondmates, and the validator refuses it for Orca. All other callers still refuse an unrecorded worktree.docs/architecture.mddescribes the new boundary. The tests cover the new paths and add afm_test_pushed_branch_projectfixture helper.🤖 Generated with Claude Code
Risk Assessment
✅ Low: The change is limited to the teardown gate. The validator opt-in only applies to teardown, and Orca, secondmates and duplicate worktree= lines still refuse. The new landed-work gate fails closed: it checks the project repository, which pool slots share as their git common dir, so the branch refs are visible. The merge from main adds no conflicting changes to the files this branch owns. The one known retry-convergence gap was already declined by the user.
Testing
I ran the real fm-teardown.sh in a disposable, marked lab home. The lab used a real git project with a bare remote and real tmux windows on a private socket. Two records retired cleanly when their branch was pushed: one with an empty worktree= line, and one whose recorded worktree path no longer exists. For each, the record was removed, the window was killed, and the run printed a records-only completion line. A record with no worktree and an unpushed commit refused, listed the commit, and kept the record and the window. With --force, it then retired. A record with two empty worktree= lines still refused as ambiguous. Both targeted teardown test files passed in full. I did not run two scenarios against the live product: the slot claimed by another live task, and the merged-PR or local-only proofs. Only the test suite covers them. I could not run the before-fix reproduction against the base commit because the permission system denied it.
fm-teardown.sh emptywt-> 'teardown emptywt complete (... no worktree recorded, records-only cleanup)', exit 0, record removed, window gonefm-teardown.sh gonewt-> exit 0, record removed, window gonefm-teardown.sh nowt-unpushed-> 'REFUSED: ... cannot be proven landed or pushed' listing 'work for nowt-unpushed', exit 1, record present, window alivefm-teardown.sh nowt-unpushed --force-> exit 0, record removed, window gonefm-teardown.sh dupwt-> 'REFUSED: ... ambiguous worktree identity', exit 1, record present, window aliveEvidence: Live lab transcript: fm-teardown.sh on branch head against absent-worktree records
Source: Live lab transcript: fm-teardown.sh on branch head against absent-worktree records
Evidence: fm-teardown-endpoint-safety test log
Source: fm-teardown-endpoint-safety test log
Evidence: fm-teardown test log
Source: fm-teardown test log
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.
fm-teardown.sh emptywt-> 'teardown emptywt complete (... no worktree recorded, records-only cleanup)', exit 0, record removed, window gonefm-teardown.sh gonewt-> exit 0, record removed, window gonefm-teardown.sh nowt-unpushed-> 'REFUSED: ... cannot be proven landed or pushed' listing 'work for nowt-unpushed', exit 1, record present, window alivefm-teardown.sh nowt-unpushed --force-> exit 0, record removed, window gonefm-teardown.sh dupwt-> 'REFUSED: ... ambiguous worktree identity', exit 1, record present, window aliveLive lab run:bin/fm-lab-home.sh create $LAB, a real git project with a bare origin, a private tmux server (tmux -L fm-lab), real fm-<id> windows, and task records, thenFM_HOME=$LAB bin/fm-teardown.sh <id> [--force]for emptywt, gonewt, nowt-unpushed, nowt-unpushed --force, and dupwt. The lab was torn down with kill-server and rm -rf.bash tests/fm-teardown-endpoint-safety.test.sh(31 ok, 0 not ok). This includes the unrecorded-worktree, gone-worktree, and slot-held-by-another-live-task records-only cases.bash tests/fm-teardown.test.sh(150 ok, 0 not ok). This includes the absent-worktree cases: merged PR, open PR with pushed branch, unpushed branch refused then --force, and local-only work merged to local main.Tried to run the same lab against the base commit 7da4c362 to reproduce the old refusal. The permission system denied that command.✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.