Repository navigation
prune-merged keeps a tree holding a DEAD or STALE record and reads its -Apply end state fail-closed (BACKLOG #5956) - #3226
wshallwshall wants to merge 8 commits into
Conversation
…ts end state fail-closed Row 5956, reproduced in a fixture repo. With a DEAD or a STALE record in a candidate, run 1 removed the tree. Run 2 then exited 2 with the fence unavailable and every candidate skipped, because the record now named a missing sibling checkout. The control with no such record ran clean. The tree now stays, at the decision pass and at the -Apply re-check. The record is not a veto, it is not deleted, and -Name does not lift the hold. occupancy.ps1 is unchanged, so the fence faults the same shapes as before. The -Apply end state now reads the shared gone rule. Get-EndStatePresence moved to worktree-gates.ps1 so both removals use one copy. Before this, a not-found under an unlistable parent counted as removed, and an unreadable leftover ended the run with exit 1 and no JSON receipt.
… fix Row 5956, the simplify pass. Get-StrandableRecords moves to worktree-gates.ps1 and replaces the same filter inline in hygiene-report.ps1. The -Apply end state drops two derived variables. The tests lose a duplicate process fixture and one repeated run, and share one git shim frame.
…hold Comment-only. Review round one found the rule at (d) and the two lists of what -Name cannot override had gone incomplete with the new hold. BACKLOG #5956 Proposed PR title: prune-merged keeps a tree holding a DEAD or STALE record and reads its -Apply end state fail-closed (BACKLOG #5956) Proposed banner: SHIPPED. Reproduced in a fixture repo: a DEAD or STALE record in a removed sibling made the next run exit 2 with every candidate skipped. prune-merged now keeps such a tree at the decision pass and the -Apply re-check, and its -Apply end state reads the shared gone rule. The fence and occupancy.ps1 are unchanged, and no session record is deleted. Open findings, from review round one, read and not run: 1. An unknown end state leaves the tree's claims unreleased, and the ledger later clears the entry without releasing them. Introduced by this branch. 2. An unknown end state on a tree git still lists reads ORPHANED and prints the move-aside recipe. Introduced by this branch. 3. A failed git worktree list reads as deregistered in the -Apply end state. 4. Exit 0 with a readable leftover, deregistered, is not ledgered. 5. The report-only list can suggest a detached sibling holding such a record. 6. -Apply -Name on a held tree exits 0. 7. The JSON StrandableRecords field omits pid and root, and no test reads it. 8. Exit 0 with an unknown end state is worded as a failed removal. 9. Get-StrandableRecords repeats the occupancy matcher's path test, and the hold rule is stated in both the script header and docs/WORKTREES.md. Module scripts/worktree/remove.ps1: it has no such hold, so it can strand a record. Module scripts/coord/occupancy.ps1: the name prefix in Get-UnplaceableCwdReason also matches a missing path in a sibling clone.
…tree orphaned An unknown end state released no claim, and the ledger then dropped the entry once the tree read as gone, so the claim was stranded. The entry now stays until an -Apply run releases the tree's claims, on a list that was read and a gone reading with -RequireParent. If either fails, or a claim cannot be read or removed, the entry stays and the run exits 1. An unknown end state on a tree git still lists now reads Outcome unknown, exit 1, with no ledger entry and no move-aside recipe. Exit 0 with an unknown end state is no longer worded as a failed removal. BACKLOG #5956 Proposed PR title: prune-merged keeps a tree holding a DEAD or STALE record and reads its -Apply end state fail-closed (BACKLOG #5956) Proposed banner: SHIPPED. Reproduced in a fixture repo: a DEAD or STALE record in a removed sibling made the next run exit 2 with every candidate skipped. prune-merged now keeps such a tree at the decision pass and the -Apply re-check. Its -Apply end state reads the shared gone rule, and a tree it cannot confirm gone keeps its claims until a later -Apply confirms it. occupancy.ps1 is unchanged, and no session record is deleted. Open findings, from review and not reproduced: 1. A failed git worktree list reads as deregistered in the -Apply end state. 2. Exit 0 with a readable, deregistered leftover is not ledgered. 3. The report-only list can suggest a detached sibling holding such a record. 4. -Apply -Name on a held tree exits 0, and the message cannot name the record file. 5. The JSON StrandableRecords field omits pid and root, and no test reads it. 6. Get-StrandableRecords repeats the occupancy matcher's path test, and the hold rule is stated in both the script header and docs/WORKTREES.md. 7. A present but unlistable leftover reports 0 files. 8. The header's count of control-flow statements is stale. 9. Changing the fault rule itself, rather than holding per route, was not taken: it would weaken the fence and needs its own decision. Module scripts/worktree/remove.ps1: it has no such hold, so it can strand a record. Module scripts/coord/occupancy.ps1: the name prefix in Get-UnplaceableCwdReason also matches a missing path in a sibling clone.
…names the claim Review of 3af2dc1 measured the automatic release freeing a live session's claim. The ledger pass now releases nothing. A gone entry that a claim still names, or that an unreadable registry may name, stays in the ledger, and both the dry run and -Apply name the claim key and file. That costs no exit code; main had no such case. An entry no claim names leaves on -Apply, as before. Releasing stays with claim.ps1 -Force. The removal path releases claims exactly as main does. A non-zero git exit on a tree git still lists, whose end state could not be read, exits 3 again, still with no ORPHANED label, recipe or ledger entry. docs/WORKTREES.md and three script comments now describe this behaviour. BACKLOG #5956 Proposed PR title: prune-merged keeps a tree holding a DEAD or STALE record and reads its -Apply end state fail-closed (BACKLOG #5956) Proposed banner: SHIPPED. Reproduced in a fixture repo: a DEAD or STALE record in a removed sibling made the next run exit 2 with every candidate skipped. prune-merged now keeps such a tree at the decision pass and the -Apply re-check. Its -Apply end state reads the shared gone rule, and a tree it cannot confirm gone keeps its claims and its ledger entry. occupancy.ps1 is unchanged, and no session record or ledger-held claim is deleted. Open findings, from review and not reproduced unless marked: 1. A failed git worktree list reads as deregistered in the -Apply end state. 2. Exit 0 with a readable, deregistered leftover is not ledgered. 3. The report-only list can suggest a detached sibling holding such a record. 4. -Apply -Name on a held tree exits 0, and the message cannot name the record file. 5. The JSON StrandableRecords field omits pid and root, and no test reads it. 6. Get-StrandableRecords repeats the occupancy matcher's path test, and the hold rule is stated in both the script header and docs/WORKTREES.md. 7. A present but unlistable leftover reports 0 files. 8. The header's count of control-flow statements is stale. 9. Changing the fault rule itself was not taken: it would weaken the fence. 10. A truncated ledger reads as empty and -Apply deletes it (measured). 11. The "not a git repository" line is suppressed for a deregistered tree whose end state is unknown. 12. A claim file with no worktree holds every gone entry, and the report does not name that file (measured). 13. The ledger pass matches claims more narrowly than claim.ps1 writes them: no mefor.claimsRoot hop, one path spelling, and no -RequireParent read of a shared root. An unmatched claim lets the entry leave, as on main. Module scripts/worktree/remove.ps1: it has no such hold, so it can strand a record. Module scripts/coord/occupancy.ps1: the name prefix in Get-UnplaceableCwdReason also matches a missing path in a sibling clone.
|
QA -- korus roles/BUILDER.md step 11 |
|
Lander: PR 3226, head 2d4ef04, is yours. Batch 634. |
|
Correction to the handover above: PR 3225 (branch b632/wave) also touches docs/WORKTREES.md. merge-tree against current main is clean, but whichever lands second may need that file re-checked. |
|
Lander hold at 2d4ef04.
Holding on:
Then run one review round that review_tag can read. Ordinary findings, queued for filing:
|
|
Manager, batch 634. Hold acknowledged. A Builder is fixing items 1 and 2. The earlier review nonces are on account 3 (config root .claude-account-3), which your review_tag run did not search. |
A non-zero git exit on a tree git still lists, whose end state could not be read, reports exit 3 but records no orphan and prints no recipe. The closing line was keyed on exit 3, so that run was told a directory was broken RIGHT NOW and to follow a recipe it never printed. The line is now keyed on a recorded orphan, this run's or an earlier one's, and the unknown end state gets its own closing line: what the run established, and to re-check. Lander hold item 1 on PR 3226.
… -Force only where claim.ps1 -List would The notice printed one `claim.ps1 -Release <key> -Force` recipe for every held ledger entry and no host, so it told an operator to force-release another PC's claim from here. Each claim now gets its own line naming its host. Another PC's claim gets no -Force recipe: it must be released from that machine. This machine's claim keeps the recipe only where claim.ps1 -List would read its holder as gone (a record this machine may judge whose worktree path is not there); otherwise the line points to claim.ps1 -List. The receipt's claims carry host and releasable. Get-ClaimedWorktreeIndex now hands back each claim's record, so the host is read without a second read of the file. Lander hold item 2 on PR 3226. BACKLOG #5956
… every claim at claim.ps1 -List The previous commit kept a -Force recipe for this machine's claims by copying part of claim.ps1's liveness rule, and that copy could disagree with claim.ps1 -List, misread a failed probe as a path that is there, and put a claim key from a shared registry into a paste-ready command. Whether a claim can be released is claim.ps1's call, so the notice now prints no release command for any claim. Each claim line names the key, the claim file and the host, and says to run claim.ps1 -List. The copied rule and the receipt's `releasable` field are gone. The text and the receipt write the host the same way: '<no host>' for a record with no host field, coord-root.ps1's unreadable marker for a non-string one. The footer no longer says every held entry clears once no claim names its tree. That sentence prints only when a claim names an entry, and an entry held for an unreadable registry gets its own sentence. Lander hold item 2 on PR 3226. BACKLOG #5956
Batch 634, row #5956. Both limbs of the row are closed in
scripts/worktree/prune-merged.ps1. The workbook filed the row under the vault, but the finding is in this engine script.Merge danger
Reversible: yes. A revert of this squash restores the old behaviour. No schema, store or settings change.
Blast radius:
scripts/worktree/prune-merged.ps1,scripts/worktree/worktree-gates.ps1(new sharedGet-StrandableRecordsandGet-EndStatePresence;Get-ClaimedWorktreeIndexnow keeps key and file per holder),scripts/worktree/hygiene-report.ps1,scripts/worktree/finished-worktree-removal.ps1,docs/WORKTREES.md, and the worktree tests.Visible behaviour:
-Applyre-check.-Namedoes not lift the hold, and the record is not deleted. Before this, removing such a tree left an unplaceable record, and every later run in the clone stopped with the fence unavailable (exit 2), until someone deleted the file by hand.-Applyend state is read fail-closed. A leftover it cannot confirm gone is reported as an unknown end state, not counted as removed, and never labelled ORPHANED.-Applyname the claim key and file. Releasing it stays withclaim.ps1. A held entry exits 0, so another PC's claim cannot red every run. The release on a confirmed removal is unchanged frommain.mainthat case crashed whenTest-Paththrew.Evidence
test_a_dead_or_stale_record_holds_its_tree_and_the_next_run_still_works(3 cases),test_a_dead_or_stale_record_arriving_mid_run_holds_the_tree(2),test_an_end_state_it_cannot_confirm_is_not_counted_as_removed(2),test_an_unknown_end_state_keeps_the_claim_and_its_ledger_entry,test_a_gone_entry_stays_in_the_ledger_while_a_claim_may_name_it(this machine, another PC), andtest_an_unknown_end_state_on_a_tree_git_still_lists_is_not_an_orphan.2d4ef04485f: all four mypy legs,ruff check .,ruff format --checkon the test file, and a targeted run of 21 claim and new tests (all passed).test_worktree_finished_claude_removal.py::test_runner_dry_run_lists_from_a_fresh_prune_merged_run_and_removes_nothingandtest_worktree_hygiene_report.py::test_an_unreadable_claim_holds_every_merged_tree_back. The cause was not captured. Both scripts use the changedGet-ClaimedWorktreeIndex, so this may be a real interaction, not load.prune-merged.ps1ran only against fixture repos.Proposed ledger banner
SHIPPED for the row's two limbs, in
prune-merged.ps1. The open findings below go to one R2 row, andscripts/worktree/remove.ps1can still strand a record the same way (finding 12).Open findings, none repaired
Items 1 and 2 could mislead an operator, so please classify them under your merge rule:
claim.ps1 -Release '<key>' -Forceeven for another PC's claim, and does not show the claim's host.run-daily-prune.ps1line 136 and the$EXIT_ORPHANEDcomment still give exit 3's narrow meaning.exitCode3 withcounts.orphaned0 and nothing saying what earned the 3.Get-LiveOrphanscomment still says the-Applypass settles the tree's claims first, which is now false.git worktree listreads as deregistered (pre-existing).-Applythen deletes it (pre-existing reader).scripts/worktree/remove.ps1has no such hold, on-Nameor-Path, so it can still strand a record and take the fence down.scripts/coord/occupancy.ps1: the<primary>-name test also matches a missing path in a sibling clone such as-vault, and no hold in this repo can see that record.