Skip to content

Commit 8f5bd54

Browse files
wshallwshallwshallwshall
andauthored
docs(worktree): the FENCE UNAVAILABLE list names every unplaceable shape (#1246)
prune-merged.ps1's header said the fence is available given "at least one config root with a session registry, at least one readable record, and NO record that failed to parse". That named one of three unplaceable shapes. READ FROM Get-WorktreeOccupancy IN scripts/coord/occupancy.ps1, not from the comment it replaces. The prior text is the thing under test, so it is not evidence of anything. Line numbers below are that function at 05a37c1. Available is withheld on FIVE conditions, not three: 253-261 $worktrees.Count -eq 0 RepoFound false 277-285 catch around Get-ClaudeConfigRoots / Get-SessionRecords 333-335 $roots.Count -eq 0 336-340 $faults.Count -gt 0 341-343 $records.Count -eq 0 THE SHAPE THAT MATTERS IS NOT THE COUNT, IT IS THE SPLIT. Four of the five mean the fence could not look: nothing was examined, so nothing is cleared. The fifth means it looked and found a session it cannot place. That is the only refusal resting on positive evidence -- a session demonstrably exists, the fence cannot say which tree it is in, and the tree could be the one the run is about to delete. A flat list of five loses that, so the paragraph is now two bullets and not an enumeration. The unplaceable family has three shapes, built at 291-292 (a file that will not parse), 301-305 (parses, carries no cwd) and 327-328 via Get-UnplaceableCwdReason (a cwd that is a checkout of this repo which `git worktree list` no longer carries). The third is the state this script's own incident produces: deregister a worktree out from under its occupant and that session's recorded cwd names a checkout git has stopped listing. The header already tells that incident eleven lines above and did not connect it. TWO THINGS A READER WOULD OTHERWISE RE-DERIVE, both now stated: The ladder tests faults BEFORE the empty-record count, so a registry holding nothing but unreadable files reports the unplaceable record rather than "not one readable record". RepoFound false reaches the Available gate on the SECOND read. RepoFound appears exactly once in this script (line 227, which exits at 230), but the re-check before each removal at 1101 reads $occ2.Available alone, and 1107-1110 prints that Detail and skips. An earlier draft of this paragraph said the condition never surfaces here. It was wrong and is recorded rather than quietly dropped, because the reason it was wrong -- one guarded call site read as the only call site -- is the error a later reader would repeat. NO BEHAVIOUR CHANGE. Comment text only, inside the .DESCRIPTION help block. Measured on the patched file, each zero beside a control that fired: cp1252-unencodable characters 0, against a control where U+2500 fires and U+2014 deliberately does not, since tests/test_cp1252_console_safety.py gates on encodability rather than on ASCII; non-ASCII 0, control ord(U+2014) > 127 true; tabs 0 and trailing-whitespace lines 0, both detectors fired on planted text; .DESCRIPTION block max width 104 with nothing over it, unchanged from before this change, and the added lines top out at 103. The PowerShell parser reports 0 errors over the whole file. The patch applies to origin/main with `git apply --check`, and the same patch is refused against a subject with line 84 mutated, so the clean apply is attributable. Get-Help was ATTEMPTED AND DISCARDED as a check: run against a bare path it returns 0 description characters and the generic "SHORT DESCRIPTION" synopsis for the unpatched file too, so it measured nothing either way. WHAT I DID NOT VARY. scripts/coord/occupancy.ps1 was read at 05a37c1 and is not touched here. Two sibling drifts of the same family are NOT fixed in this commit and are not mine to widen into: docs/WORKTREES.md:225-232 restates the shapes by count and still says "Two shapes qualify", and scripts/coord/presence.ps1:180 prints "Nothing was examined" on an unavailable roster, which is false on the fault path and was already false before this work. prune-merged.ps1:856-857 does not have the second defect: it interpolates $occ.Detail and adds no claim of its own. Co-authored-by: wshallwshall <mefordev@messagefoundry.org>
1 parent 852a3fa commit 8f5bd54

1 file changed

Lines changed: 23 additions & 5 deletions

File tree

scripts/worktree/prune-merged.ps1

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,29 @@
8080
path-based (the Desktop app's own session tooling only lists what it spawned).
8181
8282
FENCE UNAVAILABLE => NOTHING IS PRUNED, LOUDLY (exit 2). "The fence found nobody" and "the fence
83-
could not look" are the same empty answer, so availability is checked explicitly: at least one
84-
config root with a session registry, at least one readable record, and NO record that failed to
85-
parse (an unparseable record's cwd is unknowable, so it cannot be cleared from any candidate -- and
86-
a file caught half-written is precisely what a session that launched a second ago looks like). When
87-
it is unavailable every candidate becomes SKIP and the run exits non-zero rather than silently
83+
could not look" are the same empty answer, so availability is checked explicitly.
84+
Get-WorktreeOccupancy in scripts/coord/occupancy.ps1 withholds it on five conditions of two
85+
DIFFERENT kinds, and a flat list of the five drops the half that matters:
86+
87+
* IT COULD NOT LOOK -- the -Repo hint resolves to no worktree at all, the session registry throws
88+
on read, no config root carries a registry, or not one readable record is in them. Nothing was
89+
examined, so nothing can be cleared. The first of those sets RepoFound false too and this
90+
script refuses on THAT at its first read, but the re-check before each removal reads Available
91+
alone, so it arrives here instead.
92+
* IT LOOKED, AND A SESSION IS SOMEWHERE IT CANNOT NAME -- one or more records it did examine can
93+
be placed in no worktree. Three shapes qualify: a file that will not parse, a record that
94+
parses but carries no cwd, and a record whose cwd is a checkout of THIS repo that `git worktree
95+
list` no longer carries. This is the only refusal resting on POSITIVE evidence. A session
96+
demonstrably exists, the fence cannot say which tree it is in, so it clears NONE of them -- and
97+
the tree it is in could be the one this run is about to delete. A file caught half-written is
98+
precisely what a session that launched a second ago looks like, and the third shape is what the
99+
incident above LEAVES BEHIND: deregister a worktree out from under its occupant and that
100+
session's recorded cwd names a checkout git no longer lists.
101+
102+
The second kind is tested BEFORE the empty-record count, so a registry holding nothing but
103+
unreadable files reports the unplaceable record rather than "not one readable record".
104+
105+
When it is unavailable every candidate becomes SKIP and the run exits non-zero rather than silently
88106
pruning unfenced, and the fence is re-read immediately before each removal so a fence that DIES
89107
mid-run stops the rest. There is deliberately no override flag.
90108

0 commit comments

Comments
 (0)