Skip to content

status reads a record leg that names no parked_commit: — and one the record gives no role — the way resume will refuse them, instead of offering resume <Name> for the first and saying nothing about the second - #21

Merged
brettheap merged 5 commits into
mainfrom
fix/record-no-commit-and-empty-role
Sep 12, 2026

Conversation

@brettheap

@brettheap brettheap commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

The follow-ups to notes 7 and 8 of the independent review of #20 (2026-09-11), recorded there as out of scope and taken on the reviewer's notes alone — nobody has ruled on either. Both are the record layer reading a record THE WAY resume.sh WILL JUDGE IT, for two more holes a hand-edited or badly merged record can have.

Note 7: a leg whose record carries pushed: true and NO parked_commit: fell out of the layer in both directions — check_parked_leg's [ -n "$commit" ] || return 0 sat after the no-worktree arm, so with no worktree here the line was "… — resume Atlas brings it back", and with a worktree here there was no line at all, exit 0 — while the extension's resume.sh refuses that record at RR1 (an absent parked commit never equals origin's tip): run against it, "Error: 001-a-thing (repo leg) has moved since it was parked; that feature was NOT recreated", exit 2. The layer did not merely stay quiet about a record resume refuses, it NAMED AN EXIT THAT CANNOT WORK. The state is now read as its own, before the arm that names resume: with no worktree here the line says the record names no parked commit, that resume refuses the leg as having moved on, and the exit — park it again from the workstation that has that feature, because a REFUSED park carries the hole forward (emit_recorded_feature + workspace_write_manifest dropping the empty key) and only a park that parks it THROUGH records a commit; with a worktree here the line says what cannot be compared (moved-on, behind and diverged cannot be told apart with nothing to compare against; the first tip arm, cat-file -e, would otherwise print "its parked commit is not here" with a blank sha) and names no refusal, since RR4 leaves a worktree already at its computed path alone with a warning. A stale registration still has its prune named first. Absent and bare parked_commit: are one state, as in both readers. The pushed: arms keep their order and words (RR6 comes first in resume too).

Note 8: a leg whose - role: value is EMPTY drew nothing at all — record_rows's [ -n "$role" ] did two jobs, "a leg is open" and "the leg has a role", and the second dropped the row — while the extension's loader creates that leg and collect_legs (*) return 1) refuses the WHOLE feature for it, every other leg with it, in words about the project's shape: "Error: 001-a-thing was parked from a single project and this checkout is single; that feature was NOT recreated", "REFUSED: 001-a-thing — shape mismatch", exit 2 — a sentence that contradicts itself and points nowhere near the record's fault. $open now carries "a leg is open", the row goes out with an empty role field (six fields unchanged), and check_parked_leg answers it BEFORE leg_repo_for_role is asked — whose last test for an empty role is [ -d "$root/" ], always true — with a finding on the root's row that names the refusal of the whole feature and the exit: park that feature again from the workstation that has it, which writes the roles this checkout's own shape has (a refused park writes the leg back as - role: ""). A leg with NO - role: LINE at all still emits nothing — neither reader has a leg there — and the test that holds it says what the two readers do NOT agree about: the FEATURE such a record leaves with no legs, which collect_legs's closing count refuses while this layer is still silent, recorded for later as a per-feature reading this layer does not do yet.

status --help, AGENTS.md rule 4 and the README carry both exceptions in their own words — the first is refused at RR1 and the second for the whole feature, so "which resume refuses the same way" would have been untrue; hygiene caps AGENTS.md 150→153, README 246→249 in dated entries. Five regression tests beside note (d)'s and the widened help test, all six failing against the head each bites. The independent review of this branch: 204 comparisons of a40cbb7's status against it (17 record-layer scenarios × six spellings of pushed: × plain and --fetch) byte-identical; every pushed: × commit × worktree combination checked against resume.sh's order; verdict merge after fixes — two disproved sentences and two nits, all taken in the third commit. And from Copilot's review of this PR: role: was read with trim_unquote alone, so - role: # note was # note here and roleless to the loader — record_scalar now cuts a # comment before it unquotes, for every value record_rows reads (id:, root:, the project keys, branch:, role:, parked_commit:, wip_depth:, pushed:), because the loader's parity is per line; one test with both roleless spellings and a commented parked commit, biting against the previous head. Recorded for later, not taken here: role: nope still draws "the record names a leg this root does not mount here" with no exit while resume refuses the whole feature the same way; a feature left with no legs at all is silent; if origin has lost the branch resume refuses at RR2 before RR1, which this layer cannot tell; worktree_on_branch finds a worktree on the branch anywhere while RR4 matches only the computed path.

🤖 Generated with Claude Code

brettheap and others added 3 commits September 11, 2026 22:15
…ich `resume` refuses as moved-on — instead of offering `resume <Name>` for it or, with a worktree here, saying nothing at all

The follow-up to note 7 of the independent review of #20 (2026-09-11), recorded there as out of scope and taken on the reviewer's note alone — nobody has ruled on it: a leg whose record carries `pushed: true` and NO `parked_commit:` fell out of the record layer in both directions. `check_parked_leg`'s `[ -n "$commit" ] || return 0` sat AFTER the no-worktree arm, so with no worktree here the line was "no worktree on that branch here; parked 2026-09-10T20:00:00Z on Falcon — `resume Atlas` brings it back", and with a worktree here there was no line at all, exit 0 — while the extension's `resume.sh` refuses that record: RR6 passes on `pushed: true`, RR4 finds no worktree to call already-done, RR3 nothing in the way, RR2 the branch on origin, and RR1 (`[ "$remote_tip" != "$parked_commit" ]`) refuses it, because an absent parked commit never equals a tip. Run against such a record on 2026-09-11 the extension answered "Error: 001-a-thing (repo leg) has moved since it was parked; that feature was NOT recreated. / parked commit     (parked 2026-09-10T20:00:00Z on Falcon) / current tip    050d1ee9cd784e57c80817d7fb7068d696750249   (origin/001-a-thing)", exit 2. That fails the house rule harder than silence does — the layer did not merely stay quiet about a record `resume` refuses, it NAMED AN EXIT THAT CANNOT WORK — and the other half is the silence itself: the `return 0` skipped the three tip arms, which are the only thing this layer says about a worktree that is here. The state is now read as its own, before the arm that names `resume`: with no worktree here the line says the record names no parked commit, that `resume` matches origin's tip against it before it recreates anything and refuses the leg as having moved on, and the exit — park it again from the workstation that has that feature, which writes the record afresh, because `emit_recorded_feature` carries a REFUSED feature's entry forward untouched and `workspace_write_manifest` drops the empty key again, so only a park that parks it THROUGH records a commit; with a worktree here the line says what cannot be compared — moved-on, behind and diverged cannot be told apart with nothing to compare against, and the empty string is not a commit: the first of those arms, `cat-file -e "$commit^{commit}"`, fails on it, and what would print is "its parked commit  is not here — the record says it was pushed, so this repository has never fetched it", a blank sha and a reason invented for a commit the record never named (the independent review of this branch, 2026-09-11, proved it by removing the arm) — and names no refusal, since `resume.sh`'s RR4 calls a leg whose worktree is already at the path it computes recreated and only warns, "the parked WIP was NOT un-committed". A stale registration still has its prune named first, as the `--no-push` and unreadable-`pushed:` arms do. Absent and bare `parked_commit:` are ONE state here, unlike `pushed:`, and need no field of their own: `workspace_load_project` leaves `MANIFEST_LEG_COMMIT` at the empty string either way and `trim_unquote` does the same, so both readers make one state of them. The `pushed:` arms keep their order and their words — they are RR6, which `resume` reaches first, and their one line already names the same re-park — so a `--no-push` or unreadable leg with no commit and no worktree is unchanged, and with a worktree here the missing commit is a second finding after the first, in `resume`'s own order. `status --help`, AGENTS.md rule 4 and the README gain the exception in their own words, not the `pushed:` clause's: this one is refused at RR1, not RR6, so "which `resume` refuses the same way" would be a claim about the extension that is not true; hygiene caps AGENTS.md 150→152, README 246→248, in dated entries naming the rule. Two regression tests beside the note-8 ones they belong with, both failing against a40cbb7 (there: the `resume Atlas` line, and exit 0 with nothing said), and the widened help test with them. The review guard, well-formed records only: 34 comparisons of a40cbb7's `status` against this one — 17 record-layer scenarios × `pushed: true`/`false`, commit and role present — byte-identical in exit code, stdout and stderr.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
…s the WHOLE feature for, in words about the project's shape — instead of dropping the leg and saying nothing

The follow-up to note 8 of the independent review of #20 (2026-09-11), recorded there as out of scope and taken on the reviewer's note alone — nobody has ruled on it: a leg whose `- role:` value is EMPTY drew nothing at all from `status` — no finding, exit 0, with no worktree here, with one in sync, and under `--fetch` — while the extension creates that leg and refuses the feature for it. `record_rows`'s `[ -n "$role" ]` was doing two jobs at both emit sites, "a leg is open" and "the leg has a role", and the second dropped the row; `workspace_load_project` does no such thing — its indent-10 arm takes the `- ` item, keys on `role` and assigns whatever the scalar is, empty or not — so `resume.sh`'s `collect_legs`, which maps `spec`, `code` and `repo` onto this checkout and has `*) return 1` for everything else, refuses the WHOLE FEATURE: run against such a record on 2026-09-11 the extension answered "Error: 001-a-thing was parked from a single project and this checkout is single; that feature was NOT recreated", exit 2, and the same answer with a good `repo` leg sitting beside the roleless one — every other leg of that feature goes with it. The words are about the SHAPE, which is not what is wrong, so a person who reads them has a sentence that contradicts itself and no way to the record's actual fault; that is the line `status` now prints in advance. `$open` does the "a leg is open" job now — set at the `- role:` line, cleared where the leg ends — so the role's value means only what it says, the row goes out with an empty role field, and the row's six fields are unchanged, an empty field between two 0x1F separators shifting nothing. `check_parked_leg` answers it BEFORE `leg_repo_for_role` is asked, because that function's last test for an empty role is `[ -d "$root/" ]`, always true, and it would hand back the root and read the leg as if the record had named `repo`; and it is not the "the record names a leg this root does not mount here" arm, whose words are true of `role: nope` and misleading where the record names no role at all — the fix is not to mount anything and the refusal is of the whole feature, so the finding is the root's, names the refusal, and names the exit: park it again from the workstation that has that feature, because `emit_recorded_feature` carries a REFUSED feature's legs forward and `role` is the ONE leg key `workspace_write_manifest` keeps when its value is empty (`if value == "" and out_key != "role": continue`), so a refused park writes the leg back as `- role: ""`, which both readers unquote to the empty string again. A leg with NO `- role:` LINE AT ALL is left as it was, deliberately: the loader's `[ "$key" = "role" ] || continue` starts no leg for it and nothing opens one here, so neither reader has a LEG to read, and a test holds that half. What the two readers do NOT agree about is the FEATURE such a record leaves with no legs at all, which `collect_legs` refuses and this layer still says nothing about — the note at the end of this message. `status --help`, AGENTS.md rule 4 and the README carry the exception in their own words — `resume` refuses the whole feature for this one, not the leg — with hygiene caps AGENTS.md 152→153 and README 248→249 in dated entries. Two regression tests beside the ones for note 7 and note (d), both failing against a40cbb7 (there: exit 0 and no line; and the roleless leg missing from a three-leg feature's findings). The review guard, well-formed records only: 34 comparisons of a40cbb7's `status` against this one — 17 record-layer scenarios × `pushed: true`/`false`, commit and role present — byte-identical in exit code, stdout and stderr. Recorded for later, not taken here: a feature whose record leaves it with NO LEGS AT ALL — an empty `legs:`, or leg items with no `- role:` line — is refused by the same `collect_legs` (its closing `[ "${#LEG_ROLES[@]}" -gt 0 ]`) and is still silent here; that is a per-FEATURE reading this layer does not do yet, and it is nobody's note.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
…he roleless-line test says what the two readers do and do not agree about, and the no-role finding stops sending the person to a workstation it cannot vouch for

The independent REPORT-ONLY review of this branch (2026-09-11): 204 comparisons of a40cbb7's `status` against this one — 17 record-layer scenarios × six spellings of `pushed:` × plain and `--fetch` — byte-identical, all five new tests failing against a40cbb7, every combination of `pushed:` state × commit × worktree checked against `resume.sh`'s order; verdict merge after fixes, the fixes being two sentences the review disproved by running the code. First: the worktree-present arm's comment said comparing against an empty commit "would fail `merge-base --is-ancestor` its way into 'diverged'" — it would not get there; the FIRST tip arm, `cat-file -e "$commit^{commit}"`, fails on the empty string, and what would print is "its parked commit  is not here — the record says it was pushed…", a blank sha and a reason invented for a commit the record never named (the review proved it by removing the guard). The comment, the test docstring and the commit message now say that. Second: the roleless-LINE half of the empty-role test claimed "silence about it is the two readers agreeing"; they agree there is no LEG, and do not agree about the FEATURE, which that record leaves with no legs at all and `collect_legs`'s closing `[ "${#LEG_ROLES[@]}" -gt 0 ]` refuses ("REFUSED: 001-a-thing — shape mismatch", exit 2) while this layer says nothing — the per-feature reading the message already records as not done; the test comment and the message say both halves. The nits taken with them: the no-role finding sent the person to `parked_on` unconditionally, though with `pushed: true` the commit is on origin and the feature may be anywhere, so it now names "the workstation that has it" and says what the record says about where; and the RR6 sentence in the no-commit comment is scoped to the no-worktree path, where it is true — with a worktree here the `pushed:` states fall through and the missing commit is a second finding.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Copilot AI lite review requested due to automatic review settings September 11, 2026 23:10

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @brettheap, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 2 days and 18 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@sourcery-ai

sourcery-ai Bot commented Sep 11, 2026

Copy link
Copy Markdown

Reviewer's Guide

Updates the status record layer to mirror resume's handling of legs with no parked commit or no role: it now emits actionable refusal findings, preserves parsing and precedence behavior, and documents and regression-tests both cases across normal and fetched status output.

Sequence diagram for status mirroring resume refusal decisions

sequenceDiagram
    participant User
    participant Status
    participant Record
    participant Resume

    User->>Status: status
    Status->>Record: read leg
    alt no parked_commit
        Status-->>User: report moved-on refusal
        User->>Resume: resume feature
        Resume-->>User: refuse at RR1
    else no role
        Status-->>User: report whole-feature shape refusal
        User->>Resume: resume feature
        Resume-->>User: refuse whole feature
    else valid leg
        Status-->>User: continue normal leg findings
    end
Loading

Flow diagram for status handling of malformed record legs

flowchart TD
    A[status reads record leg] --> B{parked_commit present?}
    B -->|No| C[Report resume refusal: moved-on]
    C --> D[Re-park from workstation with feature]
    B -->|Yes| E{role present?}
    E -->|No| F[Report whole-feature shape refusal]
    F --> D
    E -->|Yes| G[Continue normal worktree and commit checks]
Loading

File-Level Changes

Change Details Files
Make status report record states that resume refuses instead of suggesting an unusable resume path or remaining silent.
  • Detect legs with an absent or empty parked commit before worktree comparison; explain that resume will reject them and recommend re-parking.
  • Preserve stale worktree-registration precedence and avoid naming resume for records lacking a comparable commit.
  • Add regression coverage for no parked commit with and without a worktree, including --fetch behavior and stale registrations.
status
tests/test_status_command.py
Make roleless record legs visible as whole-feature shape failures while preserving surrounding leg parsing.
  • Track whether a leg is open independently of whether its role is nonempty.
  • Report an empty role on the feature/root row before role-to-repository mapping, with resume's whole-feature refusal and re-park guidance.
  • Verify empty-role rows do not suppress adjacent legs and distinguish an empty role line from an absent role line.
status
tests/test_status_command.py
Align user-facing documentation and help text with the new status findings and resume refusal semantics.
  • Document no parked commit and no role as separate exceptions with their respective resume behavior.
  • Update README and AGENTS.md guidance and adjust hygiene limits and dated explanatory tests.
  • Extend status help assertions to cover both exceptions and their finding-list entries.
AGENTS.md
README.md
tests/test_repo_hygiene.py
tests/test_status_command.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

…eg with no role name the pull request that carries them, this repository's #21, beside the review notes they answer

Co-Authored-By: Claude Fable 5.1 <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

YAML-empty roles with inline comments are still misclassified by status.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Aligns status diagnostics with resume for parked records missing commits or roles.

Changes:

  • Reports missing parked commits and empty roles.
  • Adds regression tests.
  • Updates help text and documentation.
File summaries
File Description
tests/test_status_command.py Adds regression coverage.
tests/test_repo_hygiene.py Updates documentation line-count caps.
status Implements parsing and diagnostics.
README.md Documents recovery behavior.
AGENTS.md Updates operational guidance.
Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread status Resolved
… loader reads it — a `#` comment stripped first — so `- role: # note` is a leg with no role here as it is to `resume`, and not a role this root does not mount

Copilot's review of #21 (2026-09-11): `role:` was read with `trim_unquote` alone, so a YAML-empty role written as `- role: # note` or `- role: "" # note` was not empty here — it was `# note` — while `workspace_load_project` takes `#` and everything after it off EVERY line before it splits key from value, and so treats that leg as roleless and refuses the whole feature; here the leg went on to `leg_repo_for_role` and drew "the record names a leg this root does not mount here", the mounting arm's true words about a record `resume` refuses for a different reason entirely. #19 had closed this gap for `pushed:` alone, the one value the layer then judged; `role:` and `parked_commit:` are judged now too, and a `parked_commit: <sha> # note` read whole would have failed `cat-file -e` its way into "not here" for a commit that is here. So one helper, `record_scalar`, cuts a `#` comment and then unquotes, and every value `record_rows` reads goes through it — `id:`, `root:`, the project keys, `branch:`, `role:`, `parked_commit:`, `wip_depth:`, `pushed:` — because the parity is per LINE, as the loader's is: this layer reads the record the way `resume.sh` will judge it, not the way YAML would. One test with the three shapes Copilot named plus the commented parked commit, biting against 83a0f15 (there: "does not mount here" for both roleless spellings, and the commented sha read as no commit at all).

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Copilot AI review requested due to automatic review settings September 11, 2026 23:35
@sonarqubecloud

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

A moderate issue remains where sibling legs may still suggest unusable resume advice for a roleless feature.

Review details

Suppressed comments (1)

status:2125

  • This finding is emitted per leg, but read_record still invokes check_parked_leg for every sibling. Thus a feature with one roleless leg also prints the normal resume <Name> brings it back advice for another leg, even though this message says resume refuses the whole feature; the combined report recommends a command that cannot recreate it. Track the roleless state at feature scope and suppress/qualify sibling resume advice, or otherwise make the whole-feature refusal unambiguous.
        finding "parked feature $branch: a leg of it in the record has no role; \`resume\` maps each leg's role onto this checkout and refuses the WHOLE feature — the other legs with it — where one does not map, reporting it as a shape mismatch, so nothing here brings it back — park that feature again from the workstation that has it ($where), which writes the roles this checkout's own shape has"
  • Files reviewed: 5/5 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@brettheap

Copy link
Copy Markdown
Contributor Author

On Copilot's second-round note at status:2125 (a feature with one roleless leg still prints, for a sibling leg with no worktree here, "resume Atlas brings it back", while the roleless line says resume refuses the whole feature): taken, and it is wider than the roleless leg — collect_legs refuses the whole feature for a role this checkout's shape does not have (role: nope) and for a feature with no legs at all, and every sibling's no-worktree line would contradict those too. The exit is a FEATURE-scope reading in read_record (which features resume refuses as a whole, before any leg's arm names resume), which is what the follow-up already in progress for the role: nope and no-legs cases builds; it lands stacked on this PR as the next one, with the sibling suppression and tests for all three states, rather than as a per-leg patch here that the next PR would rewrite. Until then every sibling line this PR prints is what a40cbb7 printed for it; nothing here got worse.

@brettheap
brettheap merged commit 4ca4690 into main Sep 12, 2026
7 checks passed
@brettheap
brettheap deleted the fix/record-no-commit-and-empty-role branch September 12, 2026 17:48
brettheap added a commit that referenced this pull request Sep 12, 2026
…l judge it — per feature, before any leg — so a feature `resume` refuses whole never has a leg line offering `resume <Name>`, a feature with no legs or an unmountable role is a finding, and the absent-`pushed:` line names the refusal rather than one loader's reading

Four follow-ups to reviewer's notes, taken on the notes alone — nobody has ruled on them — and all of one kind: the record layer reading a feature THE WAY `resume.sh`'s `collect_legs` WILL JUDGE IT, which is per FEATURE, before any leg of it is read.

1. The absent-`pushed:` clause said "`resume` reads a missing one as not pushed and refuses it" — main's loader's mechanism, which workBenches #60 (merged 2026-09-12) changed: the loader now reads a missing key as nothing and `resume` refuses it for that. Both loaders refuse at RR6 and both leave the same re-park, so the clause names the refusal and the exit and not the reading one loader makes to reach it; the three comments that described the old mechanism say which loader does what and that the outcome is the same. Words only.
2. `role: nope` drew "the record names a leg this root does not mount here" — true, and it named no exit and did not say that `collect_legs` (`spec`/`code` only in a three-leg checkout, `repo` only in single, `*) return 1`) refuses the WHOLE feature for it in the shape words ("was parked from a single project and this checkout is single", "REFUSED: … — shape mismatch", exit 2 — verified against both versions of the extension). The finding now says so and names both exits. The arm is SPLIT on what proves the refusal: `collect_legs` maps roles by NAME onto the paths `load_repo_shape` computed and never reads the directory, so a leg this root mounts that is not a checkout (an unfetched submodule) keeps its old sentence byte for byte; only a role `leg_repo_for_role` cannot answer at all is the whole-feature refusal.
3. A feature the record lists no leg for — an empty `legs:`, `legs: []`, or leg items with no `- role:` line — was counted and then silent, while `collect_legs`'s closing `[ "${#LEG_ROLES[@]}" -gt 0 ]` refuses it whole. `read_record` gains a first pass over the rows that counts each feature's legs, keyed per `branch` ROW (the loader makes a feature of every `- branch:` line), and the finding lands in the record's own order; the unrecorded-worktree sweep still knows that branch as recorded.
4. From Copilot's review of #21: a feature with one roleless leg still printed "`resume <Name>` brings it back" for a sibling leg with no worktree here, a command that cannot recreate it. The same first pass now makes the whole-feature verdict — a leg with no role, or a role `leg_repo_for_role` cannot answer — before any leg's arm runs, and hands it to `check_parked_leg`; for such a feature the two arms that named `resume` say instead that `resume` refuses the whole feature and why, with a stale registration's prune still first, while a sibling's other readings (dirty, moved on, missing commit) are unchanged. An empty verdict leaves every arm byte-identical.

`status --help`, AGENTS.md rule 4 and the README widen one clause each for 2 and 3 (they already said "the whole feature", which 4 makes the per-leg lines stop contradicting); hygiene caps AGENTS.md 153→155, README 249→251 in dated entries. Fourteen new or changed tests, each failing against #21's head (04dc60e), and the independent review of this branch ran its own guard against that head: 317 comparisons over 37 record-layer scenarios × nine spellings of `pushed:`, the 182 that these commits do not address all byte-identical, the 108 that differ all the intended ones. That review's findings are taken in a fifth commit: the second pass's per-feature verdict lookup is guarded for a record whose `root:` key sits between a feature's `- branch:` and its legs (a leg row with no branch row — subscript -1 was an error on bash 3.2 and the last feature's verdict on bash 5); `leg_repo_for_role` answers a declared `spec`/`code` leg with no `path:` at the role's own name, as `_shape_record_leg` defaults it, so an unfetched submodule in a genuinely three-leg root keeps the short "does not mount here" line rather than a shape refusal `resume` would not make; and the `load_repo_shape` rule is stated exactly — `kind: project-manifest`, `schema: project-repo-schema`, and both a `spec` and a `code` leg declared, path optional. Suite: 306 passed with it, and its guard against the four commits' tip, 317 comparisons, byte-identical outside the two states it changes. And from Copilot's review of this PR, a sixth commit: `leg_repo_for_role` read `project.yaml`'s `role:` and `path:` without cutting a `#` comment, which `load_repo_shape` cuts from every line, so `- role: spec # the spec leg` declared without a `path:` was misread as a role this root cannot mount; and a `- branch:` with no value was dropped from the record layer with its legs while the loader makes a feature of it and `resume` refuses it (at RR2 with the name blank, or as a shape mismatch with no legs) — it is now one finding on the root's row carrying RR2's two exits. Two tests, both failing against the previous head; suite 308. And from Copilot's SECOND round on this PR, a seventh commit, both suppressed findings taken and both real: `record_rows` decided whether a row went out AT the line it read it from, so every row above the key that SELECTS the block was thrown away for a block that did match — and a `root=` selector (every family member, and a record found under the folder name) is answered at the `root:` key, which a hand-edit or a bad merge can leave below `features:`. With it at the foot of the block that is every row, and the layer said "no block for this root" about a record it had just matched; with it inside the feature it was Copilot's own case, a blank `- branch:` row suppressed while the leg row under it went out, reaching `read_record` with `seen_branches == 0` and drawing "`resume Atlas` brings it back" for a feature `resume` refuses at RR2 under a blank name. The rows are HELD now and flushed in the record's own order the moment the block is known to match — `record_rows` lifted out of both `status` files and run against a two-block family record for six selectors gives byte-identical output, so nothing a record `park` wrote reads differently. And `leg_repo_for_role` read a full-line `#` comment at COLUMN 0 as the indent-zero key that closes a leg, dropping the `path:` under it: `load_repo_shape` cuts `#` off every line and skips what is left when it is empty, so a `- role: code` whose `path: spec` sits under such a comment loads as `CODE_LEG=<root>/spec` there (run against `git-common.sh` 2026-09-12) where this reader answered `<root>/code` and called it a leg this root does not mount — the same cut #20 gave `record_rows` for the same line. Three tests, all failing against the previous head, and the leg-row guard that branch added is now the belt to a brace no record can undo, its test rewritten to the corrected reading. An eighth commit, from Copilot's third round: a `path:` whose own value carries a `#` comment is read where the loader reads it — that cut landed with the sixth commit, but no test held the `path:` arm down, only its `role:` siblings — so `path: spec # note` on a `code` leg is now proved read at `spec/`, the checkout the manifest names, not at the role's default (biting against 4825d61, the head before the cut). Suite: 312 passed. Recorded for later, not taken: a role this root DOES mount that `collect_legs` refuses anyway — `assembly`, `repo` in a root `load_repo_shape` calls three-leg (one project checked out at two shapes, the commonest mismatch there is), `spec` in a root whose `project.yaml` declares no `code` leg, or any word that matches a directory under the root — needs a reading of this root's shape against the record's, which the next branch builds; and two record entries with one branch name draw one name two verdicts, faithfully (`resume` answers both), with nothing yet saying they are two entries.

Stacked on #21 until it landed as 4ca4690; brought onto `main` by merging it in (the branch is a superset of the squash), the merge proved byte-identical to a rebase onto `main`.

PR #22

Co-Authored-By: Claude Fable 5.1 <[email protected]>
brettheap added a commit that referenced this pull request Sep 13, 2026
…y commit is compared — a branch origin has lost is RR2's refusal of the WHOLE feature, and a role this checkout's shape has no place for is `collect_legs`'s — reading this checkout's shape as `load_repo_shape` reads it, with one parser of `project.yaml`

Seven commits, the follow-ups the independent reviews of #21 and #22 recorded as out of scope and nobody has ruled on, each a reading of the record THE WAY `resume.sh` WILL JUDGE IT, verified against the extension's own scripts on scratch estates (bare remotes in a temp dir, a fake `$HOME`).

A branch origin has lost. `resume.sh`'s RR2 fetches `+refs/heads/<branch>:refs/remotes/origin/<branch>` quietly in the leg's repository and refuses on the empty string — "Error: 001-a-thing is no longer on origin in the repo leg; that feature was NOT recreated … If the feature landed, delete its entry … If it was deleted by mistake, push it again from the workstation that parked it", `REFUSED — gone from origin`, exit 2 — BEFORE RR1 compares any commit, and takes the whole feature with it. `check_parked_leg` never read `origin/<branch>` for a leg, so both lines that name `resume <Name>` offered it whatever origin had. The reading is the local layer's own `has_ref` and is AS OF THE LAST FETCH like every other answer here: without a fetch this run the line keeps the exit that works and names the other reading beside it ("… unless origin has lost that branch: … — `status --fetch` settles which"), because a branch pushed elsewhere since this clone last fetched looks exactly the same and RR2's own fetch then finds it; after a fetch that WORKED in that repository there is nothing left to settle and the line is RR2's refusal with RR2's two exits and no `resume` at all — delete the `- branch:` block where the feature landed, or push the branch again from the workstation that parked it. It sits in `resume.sh`'s order, RR6 → RR4 → RR3 → RR2 → RR1: after the `pushed:` arms, only where there is no worktree here, never for a feature `collect_legs` refuses whole, and before the absent-parked-commit arm, so a record naming no commit whose branch is gone is refused for the branch under `--fetch` and keeps its line without one. Five tests failing against main; three existing tests took the clause.

This checkout's shape. `collect_legs` maps `spec` and `code` only onto a three-leg checkout, `repo` only onto a single one, and every other word — `assembly` included, a role the three-leg SHAPE has and `resume` maps in no shape — onto neither; and `load_repo_shape` calls a checkout three-leg on FOUR declarations, `kind: project-manifest`, `schema: project-repo-schema`, and a `spec` LEG and a `code` LEG in `legs:` (the leg, not its `path:`, since `_shape_record_leg` stores `${path:-spec}`). The layer already refused a role this root had no REPOSITORY for; the same refusal reached with a repository in hand — `assembly` anywhere, `spec` in a root that declares no `code` leg, `repo` in a real three-leg root, one project checked out at two shapes — drew nothing. `read_root_shape` now makes exactly the loader's test (a differential harness of fifteen manifests against the real `load_repo_shape`, no disagreement, the same under bash 3.2) and the finding names the ROLE, this checkout's shape AND WHY in the loader's terms, the refusal, and the exits, holding the record's own `shape:` against it without judging it — `resume`'s own sentence, "parked from a single project and this checkout is single", contradicts itself. The verdict is the feature's, asked in `read_record`'s first pass as a third question, and the leg ENDS at that line where there is no worktree here. Five tests failing against main, a `seed_three_leg_root` fixture, three existing tests carry the new lines; `status --help`, AGENTS.md rule 4 and the README widen "does not mount" to "has no place for", caps 159→162 and 255→256 in dated entries.

The fix round of this branch's independent review (2026-09-12; verdict merge after fixes, one blocker, two should-fix, four nits, every one taken). The blocker: RR2's whole-feature line was PRINTED and not MADE — a sibling leg in another repository still said "`resume Trio` brings it back" two lines under it. The lost branch is now the fourth question `read_record`'s first pass asks, kept in an array of its own because `collect_legs` runs to the end before any RR does; the culprit leg still speaks in RR2's words, every sibling carries the verdict with RR2's two exits (never the re-park the other whole-feature refusals name, because the feature may have LANDED), and it is a verdict only under a fetch that worked there. S1: the caveat no longer offers `status --fetch` to a run whose fetch in that repository just failed — `fetch_tried_at` tells that run from one made without the flag. S2: ONE parser of `project.yaml` — `read_root_shape` records each leg's role and `path:` as it walks the loader's way, and `leg_repo_for_role` reads those back instead of its own column-keyed scan, so a `legs:` list indented four spaces (which the loader reads without blinking) is no longer reported as a role this root does not mount with the whole feature refused for it, a refusal `resume` does not make; verified by sourcing `git-common.sh`. Three tests failing against the previous head; the help test took the widened clause; no cap moves. The two earlier commit messages were rewritten in the same round (unpushed history, trees unchanged): they named the pre-rebase base and carried its numbers. Guard, the review's own harness adapted: 54 record-layer scenarios × nine spellings of `pushed:`, 486 comparisons, main against itself identical in all 486; main against this head 334 identical, and the 152 that differ are the three readings and nothing else (fifteen scenarios in all nine spellings, seventeen in the one spelling that reaches the branch-gone reading); the previous head against this one 457 identical, the 29 that differ being the fix round exactly. Suite: 325 passed at that commit.

Copilot's first round on this branch (2026-09-12), three suppressed moderate comments, every one verified empirically before anything was changed. A declared `path: "."` on a `spec` or a `code` leg IS THE ROOT at the other end: `_shape_record_leg` keeps any non-empty path, so `load_repo_shape` builds `CODE_LEG=<root>/.` for `"."`, `.`, `'.'` and `. # a note` alike (an EMPTY `path:` is the only spelling that falls to the role's own name) and `collect_legs` hands that straight to `LEG_REPOS` — a scratch estate with that manifest RESUMED out of the root, "code  worktrees/001-a-thing/.  <sha>  clean", exit 0, while `status` said "the record names a leg this root does not mount here", a whole-feature refusal `resume` does not make. `leg_repo_for_role` takes the declared path whatever it says now and answers `.` as `$root`, the spelling the run's fetch store is keyed by; a differential harness of its own holds it against the real `load_repo_shape` over twelve manifests, 24 comparisons, nine differing at the previous head and none now. The record's PROJECT ROW is built where the block ENDS, not at `features:`: `workspace_load_project` takes `shape:`, `parked_at:`, `parked_on:`, `parked_by_lane:` and `active_feature:` by INDENT in any order — run on a record carrying all five BELOW its feature list it returned every one of them, while this layer read them as absent and said "parked ? on ?" twice, dropped the clause that holds the record's `shape:` against this checkout, and told a person the record does not say where a record that says Falcon was parked. And a role of NEITHER shape is offered NO checkout at all: the re-park remediation is not impossible — that "shape" is the workstation's, and `park.sh`'s `build_legs` writes only `spec`+`code` or `repo` — but the tail promised a checkout of the OTHER shape to a role `resume` refuses in BOTH, `assembly` and `docs` each answering "shape mismatch", exit 2, in a real three-leg root as in a single one, which contradicts what AGENTS.md rule 4, `status --help` and the README already say ("a role of NEITHER shape is a record no checkout resumes"). `role_shape_exits` words the split once and the mount arm takes it too. Three tests failing against the previous head, two existing pins re-cut; no document line moves, so no cap moves. Guard: the same harness with TEN new scenarios, 50 × nine spellings of `pushed:`, 450 comparisons — the previous head against itself identical in all 450, against this one 306 identical, and the 144 that differ are 72 for the exit, 45 for the `.`-declared leg (the same manifest with a NAMED path byte-identical, which is the control) and 27 for the project keys. Suite: 328 passed.

Copilot's SECOND round on this branch (2026-09-12), one suppressed comment, verified against the previous head before anything moved: `fetch_tried_at` answered the PRESENCE of the pre-pass's entry, and `fetch_remote` stores an entry for two returns it makes WITHOUT running a fetch — a repository git cannot read, and one with no `origin` remote — so the record layer's caveat said "the fetch this run made there failed" two lines under a row that had just said "no remote named origin, so nothing could be fetched". Real in three states under `--fetch`, all run against e18ec53: a root with its `origin` removed, a `spec` leg with its `origin` removed in the three-leg fixture, and a leg whose gitdir was deleted. `fetch_remote` now sets one word per repository — `ok`, `failed`, `no-remote`, `unreadable` — the pre-pass stores it as `FETCH_STATE_AT`, and `fetch_state_at` replaces `fetch_tried_at` (its one caller), so the caveat states what actually happened: a fetch that failed keeps its sentence byte for byte, no remote says there was none to ask, an unreadable repository says no fetch was made there, and a run that never fetched there keeps `status --fetch`. One test failing against the previous head in all three states, each pinned beside the row it must not contradict; no document line moves, so no cap moves. Guard: 56 scenarios × nine spellings, 504 comparisons, the previous head against itself identical in all 504 and against this one 501 identical — the three that differ are the `pushed: true` spelling of those three states, the only spelling that reaches the clause, with a fetch that REALLY failed byte-identical as the control. Suite: 329 passed.

Copilot's THIRD round on this branch (2026-09-12), one critical, two suppressed comments and a test nit, every one verified before anything moved. THE CRITICAL: the gone-from-origin verdict was promoted to the whole feature without regard for an EARLIER leg's refusal, so a record whose first leg was parked `--no-push` (RR6) or names no `parked_commit:` (RR1), with a later leg whose branch origin has lost, gave every sibling RR2's verdict — and RR2's EXITS with it, the first of which is to DELETE the record's `- branch:` block, which is the wrong thing to do about a feature refused because a leg was never pushed. `resume.sh` walks the legs in the RECORD's order and breaks at the first refusal, so the verdict is the first REFUSING leg's: four runs against the extension on 2026-09-13, on a scratch three-leg estate with two legs in two repositories, pinned it — the `--no-push` leg first answered "REFUSED: 001-a-thing — parked with --no-push", the leg with no parked commit first "— divergence", the gone leg first "— gone from origin", and the `--no-push` leg WITH ITS WORKTREE STANDING at the parked commit still "— parked with --no-push", because RR6 is before RR4 and carries no worktree condition, the same estate with that leg's `pushed: true` answering "— gone from origin" as the control. One pair of arrays holds the first refusal and its kind now, its arms RR6, RR2, RR1 in `resume.sh`'s own order; the culprit leg keeps its own line, every sibling carries the verdict, and the exits travel with the KIND — RR2's own two for `gone`, the re-park for `pushed` and `moved`, because only a park that parks the feature through writes the record afresh. SUPPRESSED, TAKEN: under `--fetch`, a mapped leg path `project.yaml` names and `.gitmodules` does not read as `none` and drew "`status --fetch` settles which" at a person who had just run the flag; of the comment's two exits the SECOND is taken — the flag's scope is not widened, because `--fetch` is bounded to the root and the legs the estate declares — and the state is `unlisted`, which says what this run did. SUPPRESSED, DISPROVED: "`load_repo_shape` also accepts an indentless sequence here (`legs:` followed by `- role:` at column 0)" — it does not. It tests `[ "$indent" -eq 0 ]` ABOVE its `- ` case, so a column-0 item closes the legs list there exactly as it does here; ten manifests with the indentation as the variable, the real `load_repo_shape` sourced from `git-common.sh` beside this file's own `read_root_shape` on 2026-09-13, no disagreement — every column-0 spelling `single` at both ends (`SHAPE_SPEC_PATH=`, `SHAPE_CODE_PATH=`) and every indented one `three-leg` at both with the same paths. NIT, TAKEN: the `path: .` loop carries `path: '.'` now; it does not bite, because `trim_unquote` has taken single quotes off since it was written, which is what a coverage nit is. And the independent verification's nit N-b: the shape line's disagreement clause moves AFTER the exit, whose `*)` arm opens "nor does any other checkout, of either shape" and had nothing left to deny with the disagreement spliced in front of it. Three tests failing against the previous head, plus a fourth block that fails on its own — there the `spec` leg drew RR2's verdict and RR2's exits for a feature refused because the `code` leg was never pushed — and five existing byte-for-byte pins took the clause order. Guard: b8321d0's own test file against this commit's `status`, 142 status tests, 134 passed, 3 skipped, and the 5 that fail are exactly the shape-line pins; every other record-layer test of that file, the gone-branch verdict reaching the legs beside it included, is unchanged. Suite: 332 passed.

Copilot's FOURTH round on this branch (2026-09-13), no new inline comments and three suppressed, which are one finding said in three places: that the wording promises `--fetch` settles a missing `origin/<branch>` while the implementation leaves four states unsettled. ONE OF THE THREE IS TAKEN. `status --help` said "under `--fetch`, which is the only way that is settled, a missing `origin/<branch>` here is origin's answer" — and the gone-from-origin verdict is made inside `if fetched_ok_at "$repo"` and nowhere else, so a fetch that FAILED there (the review's S1), a repository with no `origin` remote or one git cannot read (round 2), and a path this run's fetch never listed (round 3) are every one of them a run made WITH the flag that settles nothing, each drawing the `resume` line and a caveat instead of the refusal. The clause names the FETCH rather than the flag now — "after a fetch that WORKED in that repository, which is the only way it is settled" — and its tail, "and without one it is named beside the `resume` that still brings back a branch this clone has merely not fetched", covers those four exactly as it already covered a run made without the flag; five lines of help before, five after. THE OTHER TWO ARE NOT TAKEN, and the difference is not convenience: AGENTS.md rule 4's "only `status --fetch` settles that" and the README's "which only `--fetch` settles" are claims of EXCLUSIVITY — that nothing else settles it — which is true of all four of those states and of every run made without one, and is the guidance a person or an agent needs; the help's clause was the one that made the consequence FOLLOW from the flag, which is why it is the one that moved, and rewriting two true sentences would spend AGENTS.md and README lines against caps that exist to stop exactly that. One existing test took the line — the help's byte-for-byte pin, with a dated docstring entry quoting the round and saying why the other two stay — and it fails against dc93459; no test is added, because the line was already pinned. Suite: 332 passed. No document line moves, so no cap moves.

Recorded for later, not taken: `worktree_on_branch` finds a worktree on the branch anywhere in the leg's repository while `resume.sh`'s `leg_registered_at` matches the PATH it computes, so RR1, RR3, RR4's second arm and RR5 are readings this layer does not yet make for a leg with no worktree at that path — the stacked branch `fix/record-worktree-path-parity` is where they are built; and the `--no-push`, unreadable- and absent-`pushed:` legs are RR6 refusals of the whole feature at the other end and are still read per leg here (pre-existing; no line of them claims the whole feature, so none contradicts one).

PR #23

Co-Authored-By: Claude Fable 5.1 <[email protected]>
brettheap added a commit that referenced this pull request Sep 13, 2026
…h) (A11 Addendum 4 ruling 1)

The contract contradicted itself and the tooling had picked a side. Clause (h)'s
table gives every read in it *"64 usage"*; adoption act 0 wrote `session-lane`
with a usage `2` (`3719d97:lanes/lanes-edit.sh:3763`), SPEC rev 5 §13 item 4 and
rev 6 §11 recorded the landed code, and this file matched act 0.

Ruling 1, ratified verbatim *"a11 addendum 4 yes"*: *"`session-lane`'s usage code
is **64** like every other read in clause (h); adoption act 0 item (4), which
says 2, is the line corrected."* The text side moves in `#21` round 5.

**It matters because `2` here already means something else.** A `lanes-edit.sh`
that has never heard of `session-lane` exits 2 from the `*)` arm — and that is
what EVERY workstation answers until adoption act 3's install reaches it. Both
of this read's callers fail CLOSED on anything but 0 or 8 (`lane-start:1124-1131`
and the `/restart` skill's step 2(b)), so what they CAN do with a non-answer is
report which kind it was: *"install the helper"* or *"fix your call"*. One number
carrying both leaves the caller guessing between those two sentences, which is
the whole of what a fail-closed read has left to say.

`session-lane` also gains the argument-count guard its five siblings have —
`[ "$#" -le 1 ]`, also 64 — because a second argument was silently ignored.

**Tests** — four. The no-argument case moves from 2 to 64 in both places it is
asserted, still naming what it takes; a second argument is 64 and says it takes
one; and — the point of the change — an unknown subcommand still exits **2** and
says *"unknown subcommand"* in its own words, so the two codes are told apart by
a test rather than by a comment. `docs/README-lanes.md`'s row for the read now
carries all four codes.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
brettheap added a commit that referenced this pull request Sep 14, 2026
…ead `- role:` the record gives NO ROLE was named with a pair of empty backticks — and `- role: # note` is that line to both readers, which is this layer's own reading from #21 arriving in the arms this branch added

COPILOT'S SECOND ROUND ON THIS PR (2026-09-14T04:15:43Z, one suppressed
comment on `status`, no inline threads, no new comments), verbatim:

  "When an unread `- role:` has an empty value (for example `- role: # note`
  under a closed `legs:` list), `feature_drop_role` is empty and this renders
  `the record lists its `` leg`. That makes the new recovery diagnostic
  unclear for a roleless record; use an explicit label such as "a leg with no
  role" (and cover this malformed spelling in the regression tests)."

IT IS RIGHT, AND THE SPELLING IS ONE THIS LAYER ALREADY KNOWS. `record_scalar`
takes a `#` comment off every value because `workspace_load_project` takes it
off every LINE before it splits key from value, so `- role: # note` is a leg
with no role to BOTH readers — the reading Copilot's round on #21 put above
`record_scalar` itself, four functions above the arms this branch added. The
bare `- role:` is the same line by the same rule. Neither had ever reached
these arms before this branch wrote them, and the line they drew named the leg
with nothing at all between two backticks: a name where the reader is looking
for one, on a line whose whole worth is sending a hand to a line.

RUN AGAINST THE INSTALLED EXTENSION, 2026-09-14, on every shape the arms can
be reached in:

  the roleless line beside a leg the loader DOES read   -> 1 feature, 1 leg,
                                                          `MANIFEST_LEG_ROLE`
                                                          `[repo]`
  the roleless line as the feature's only leg           -> 1 feature, 0 legs
  the same under a `- branch:` with no value either     -> 1 feature named
                                                          nothing, 0 legs

In every one of them `MANIFEST_LEG_ROLE` has no entry for that line:
`collect_legs` never walks it, no RR is ever asked of it, and it is unread for
exactly the reason the finding gives. What was wrong was only the noun.

`record_unread_leg` IS THAT NOUN, worded once beside `record_unread_why` and
`record_unread_exits` and for the same reason: the role in backticks where the
record gives one, "leg with no role" where it does not. The three sentences
that name a dropped leg read it — the feature that keeps a leg `resume` reads
("the record lists a leg with no role for it where `resume` reads no leg"),
the feature that keeps none ("the record lists its leg with no role where
`resume` reads no leg"), and the feature whose `- branch:` has no value either
("the leg with no role listed under it sits where `resume` reads no leg") —
and for every record that names its roles the printed bytes are what they
were, because the helper prints "`repo` leg" exactly as the interpolation
did.

RECORDED AND NOT TAKEN, and it is the EXITS' reading rather than this line's.
With the key put back, a leg with no role is one `collect_legs` READS, and a
role it cannot map is a refusal of the WHOLE feature — so the first exit does
not, for this one record shape, end in a feature that comes back. This layer
already says that: `check_parked_leg`'s roleless arm prints "a leg of it in
the record has no role; `resume` maps each leg's role onto this checkout and
refuses the WHOLE feature" with the re-park as its only exit, on the run after
the key moves, which is where it is true. Bolting it onto this sentence would
say it twice and say it early, about a state the record is not in yet. It is
named here so the next reading starts from it.

TWO TESTS, BOTH BITING. Against 8a77d39's `status` in a scratch tree with this
commit's `tests/` (2026-09-14): `2 failed, 196 passed` —
`test_an_unread_leg_with_no_role_is_named_by_the_role_it_has_not_got`, which
holds both spellings against both arms that name a dropped leg on a feature
the record names, and
`test_a_blank_branch_over_an_unread_leg_with_no_role_says_both_and_neither`,
which holds the third. Each asserts `"``" not in result.stdout` beside the
sentence it pins, because the empty pair is the defect and the wording is the
fix. The loader's answer for every record they build is in the docstrings.

THE SUITE: 488 at 8a77d39, 490 here (`python3 -m pytest tests -q`, in a real
checkout with the submodule at the pinned commit). THE CAPS DO NOT MOVE:
AGENTS.md 224, README.md 383 — this commit touches no document, because the
noun is a finding's and the documents name no leg.

INVARIANTS: the shared estate resolver byte-identical across `park`, `resume`
and `status`; `expand_home` byte-identical across `status` and `resume`;
`gh api` only in `gh_api_line`; no bash-4-only grammar; `bash -n status`
clean; shellcheck 0.9.0's finding profile identical to 8a77d39's; and no
`"${arr[@]}"` expansion is added — `record_unread_leg` takes one positional
and prints.

Base: 8a77d39.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
brettheap added a commit that referenced this pull request Sep 14, 2026
…ill make, and a `- branch:` or a `- role:` the record's KEY ORDER leaves under a shut list is a finding naming the list that shut it and the two exits in the order that does not lose the work, instead of a `resume <Name>` that brings none of it back

`workspace_load_project` — the loader `resume` and `park` both read a record
through — reads a block by INDENT and SHUTS a list at the first key shallower
than its items. `in_features=false` is the first line of its indent-4 arm,
before the `case` that sets it true again for `features:` alone; `in_legs=false`
is the first line of its indent-8 arm; its `- branch:` arm sits behind
`[ "$in_features" = true ] || continue` and its `- role:` arm behind
`[ "$in_legs" = true ] || continue`. So a project-level key a bad merge left
between two features, or between a feature and its `legs:`, does not reorder
the record — it ENDS the list, and everything under it is lines `resume` makes
no feature and no leg out of.

`status` had no such state: it matched the indent of a line and nothing above
it. So it counted features `resume` never makes and legs it never collects,
and offered `resume <Name>` for both — work `status` claims and `resume` will
not bring back, in the direction that matters most, because a person reading
it believes the feature is safe.

## The twelve records, the loader's answer, and what `main` says

Run against the INSTALLED extension on this rebase, 2026-09-14 —
`git-common.sh` and `workspace-common.sh` sourced in place, twelve hand-built
records, the `MANIFEST_*` arrays printed — with the answers the runs of
2026-09-12 and 2026-09-13 recorded. `main` and this branch are read by lifting
`record_rows` out of each `status` and running it over the same twelve.

| record | the loader | `main` | this branch |
|---|---|---|---|
| (d) the ordinary record `park` writes, two features | 2 features, 2 legs | 2, 2 ✅ | 2, 2 ✅ |
| (a) a project key BETWEEN two features | 1 feature, 1 leg | 2, 2 ❌ | 1, 1 ✅ |
| (b) a project key between a `- branch:` and its `legs:` | 1 feature, 0 legs | 1, 1 ❌ | 1, 0 ✅ |
| (c1) a `- branch:` above every `features:` key | 0 features, 0 legs | 1, 1 ❌ | 0, 0 ✅ |
| (c2) …and with no `features:` key at all | 0 features, 0 legs | 1, 1 ❌ | 0, 0 ✅ |
| (e) a feature-level key between `legs:` and its items | 1 feature, 0 legs | 1, 1 ❌ | 1, 0 ✅ |
| (f) a feature-level key BETWEEN two legs | 1 feature, 1 leg | 1, 2 ❌ | 1, 1 ✅ |
| (g) a project key between two legs | 1 feature, 1 leg | 1, 2 ❌ | 1, 1 ✅ |
| (h) a SECOND `features:` key after a project key (the list REOPENS) | 2 features, 2 legs | 2, 2 ✅ | 2, 2 ✅ |
| (i) a `- branch:` below a project key, no legs | 1 feature, 1 leg | 2, 1 ❌ | 1, 1 ✅ |
| (j) a BLANK `- branch:`, a project key above its `legs:` | 1 feature named nothing, 0 legs | 1, 1 ❌ | 1, 0 ✅ |
| (k) a second `features:` key BELOW an unread `- branch:` | 1 feature, 2 legs, both filed under the feature ABOVE it (`MANIFEST_LEG_FEATURE` is `0 0`) | 2, 2, the second leg under the phantom ❌ | 1, 2, both under the feature above ✅ |

`main` agrees on (d) and (h) and on nothing else — the same answer e18ec53
gave, and for a reason worth one line: **`record_rows` is byte-identical
between e18ec53 and 7efc850**. #23's rounds 3–5 and #27's whole computed-path
reading are in `read_record` and below it; neither touched the row reader.

**And what that costs the person reading it** (run against 7efc850's own
`status`, on the estates this suite builds, 2026-09-14):

* (a) — `2 feature(s)` and `resume Atlas` offered twice, once for a feature `resume` never selects.
* (b), (e) — `(repo leg): no worktree on that branch here … `resume Atlas` brings it back` for a leg `collect_legs` never collects, which is a feature `resume` refuses WHOLE.
* (c) — `1 feature(s)` and that same offer; and with no `features:` key at all the note line is `parked record: 1 feature(s), parked ? on ?`, the project row suppressed and the date and the workstation with it.
* (f), (g) — in the three-leg fixture, the phantom leg's own line: ``resume Trio` brings it back, unless origin has lost that branch … taking the WHOLE feature with it ("001-a-thing is no longer on origin in the code leg")` — a whole-feature refusal over a leg `resume` never reads, and `resume Trio` twice.
* (i) — a second feature, and `the record lists no leg for it`, which is `collect_legs`'s refusal of a feature it REACHES.
* (j) — RR2's refusal, `is no longer on origin`, of a feature `collect_legs` throws out before RR2 is reached.

## What changed

`record_rows` carries the loader's two flags, set where the loader sets them:
every line at indent 0, 2 or 4 shuts the feature list and `features:` alone
reopens it; every line at indent 6 or 8 shuts the leg list and `legs:` reopens
it inside an open feature list; nothing at indent 10 or 12 moves either, and a
full-line comment is no line to either reader.

* A `- branch:` under a shut list gets a **`nofeature`** row instead of a `branch` row, and does NOT become `$branch` — `$branch` is this reader's `feature_index`, the last feature the loader MADE, which is record (k).
* A `- role:` under a shut leg list gets a **`noleg`** row carrying the branch, the role and WHICH LIST WAS SHUT — because that is the line a person has to go and find.
* `read_record` counts the unread legs onto the feature in its first pass and prints, in the second, one finding per unread `- branch:` and one per feature whose legs went unread: the whole-feature refusal where the feature keeps no leg, the one-leg line where it keeps some, and the two defects in ONE line where the branch has no name (rather than the "lists no leg" a record that lists one should not be told).
* The why and the exits are worded once, in `record_unread_why` and `record_unread_exits`. The why names ONE arm, never both. The exits are **the record's key ORDER first** — the one hand-edit these rules ask for — and **the re-park second, and only from the workstation that has the feature**: `workspace_write_manifest` rewrites the project's whole block and `emit_recorded_feature` carries forward only what `MANIFEST_FEATURE_BRANCHES` holds, so a park run anywhere else writes the block back without these lines at all. The lines are one park from gone.
* The project row's gate takes an `$unread` half beside `$has_features`, so a block whose `- branch:` sits above every `features:` key still gets the row its finding needs the date and the workstation out of. Every record `park` writes is byte for byte the rows it always was.

**It composes with #27's verdict walk by being invisible to it.** The walk's
questions — `collect_legs`'s three, then RR6, RR4/RR3, RR2, RR1 in
`resume.sh`'s own order, each gated on "no earlier leg refused" — are asked in
the `leg)` arm of the first pass and nowhere else, and a line under a shut list
emits no `leg` row. That is the loader again: it puts no such line in
`MANIFEST_LEG_ROLE`, so `collect_legs` never walks it and no RR is ever asked
of it. A `nofeature` row appends no feature entry either, so every array the
walk reads back is still indexed by the features the loader MAKES.

## The differential guard, rebuilt `7efc850` → `9b06ecb`

Twin estates out of this suite's own fixture builders in a temp dir; the temp
root and every hex sha normalised; exit code, stdout and stderr diffed. Eleven
record shapes × seven phases — five spellings of `pushed:` (`true`, `false`,
the key absent, the key with no value, a word that is neither) with no worktree
here, one with a worktree on the branch, one with the branch dropped from
origin under `--fetch`. **77 comparisons.**

`main`'s `status` run AGAIN after this branch's run is byte-identical in all
77 — the harness reads nothing but the change, and neither run moved the
estate. Against this branch: **14 identical, 63 differing**, and the split is
exactly the loader's.

| shape | pushed:true | pushed:false | pushed absent | pushed empty | pushed word | worktree | gone (`--fetch`) |
|---|---|---|---|---|---|---|---|
| (a) | DIFF | DIFF | DIFF | DIFF | DIFF | DIFF | DIFF |
| (b) | DIFF | DIFF | DIFF | DIFF | DIFF | DIFF | DIFF |
| (c1) | DIFF | DIFF | DIFF | DIFF | DIFF | DIFF | DIFF |
| (c2) | DIFF | DIFF | DIFF | DIFF | DIFF | DIFF | DIFF |
| **(d)** | **SAME** | **SAME** | **SAME** | **SAME** | **SAME** | **SAME** | **SAME** |
| (e) | DIFF | DIFF | DIFF | DIFF | DIFF | DIFF | DIFF |
| (f) | DIFF | DIFF | DIFF | DIFF | DIFF | DIFF | DIFF |
| (g) | DIFF | DIFF | DIFF | DIFF | DIFF | DIFF | DIFF |
| **(h)** | **SAME** | **SAME** | **SAME** | **SAME** | **SAME** | **SAME** | **SAME** |
| (i) | DIFF | DIFF | DIFF | DIFF | DIFF | DIFF | DIFF |
| (j) | DIFF | DIFF | DIFF | DIFF | DIFF | DIFF | DIFF |

Every difference is an arm above: (a), (c) and (i) the feature count and the
branch's own finding (the indent-4 arm); (b) and (e) the whole-feature refusal
that replaces a leg read against disk (the project-indent and the
feature-indent arm); (f) and (g) the phantom leg's line becoming the finding
about the leg that will not come back, while the leg that does keeps its
`resume`; (c2) also the note line, which is the project row's new `$unread`
half; (j) the one line that now says both defects. Two differences are not a
finding's wording and are named for that reason: **(c) in the worktree phase
also gains `worktree on 001-a-thing (root): not in the parked record — never
parked`**, because a branch the loader makes no feature of is in no recorded
set and `park`, reading the record through that same loader, would park it as
new — and the footer's finding COUNT moves with it. The `--fetch` phase adds
no reading of its own: the role is read before any RR.

## Bite, suite, caps, invariants

**Eight tests bite.** This branch's `tests/` against `main`'s `status` in a
scratch tree, 2026-09-14: `8 failed, 6 passed` —
`test_a_project_key_between_two_features_leaves_the_second_unread`,
`test_a_branch_above_every_features_key_is_a_feature_resume_never_makes`,
`test_a_feature_level_key_between_legs_and_its_items_leaves_no_leg`,
`test_a_key_between_two_legs_costs_that_leg_and_not_the_feature`,
`test_a_second_features_key_reopens_the_list_and_its_legs_keep_the_feature`
(the five new ones),
`test_a_root_key_between_a_branch_and_its_legs_still_reads_that_feature` and
`test_a_blank_branch_above_the_root_key_is_still_the_feature_resume_refuses`
(the two that took the split), and
`test_the_help_carries_the_no_push_exception_its_findings_do`.

**The suite: 480 passed at 7efc850, 485 here** (`python3 -m pytest tests -q`,
both in a real checkout with the submodule at the pinned commit).

**The caps are the measured counts, not either side's number.** `main` reached
AGENTS.md 214 / README.md 377 while this branch waited; the ten and six lines
it wrote on 162 and 256 land in the same rule 4 sentence and the same
exception, over none of the lines the entries above them bought. Measured
after the rebase: **AGENTS.md 224, README.md 383**, each with its own dated
entry in `tests/test_repo_hygiene.py` beside `main`'s, which all stay.
(Those were the counts AT THE REBASE. `main` has since moved to `63a74af`
and the checked-in caps are now **224 / 409** — see *The merge of `main` at
`63a74af`* below.)

**Invariants**: the shared estate resolver byte-identical across `park`,
`resume` and `status`; `expand_home` byte-identical across `status` and
`resume`; `gh api` only in `gh_api_line`; no bash-4-only grammar; `bash -n
status` clean; shellcheck 0.9.0's finding profile identical to `main`'s; and
this commit adds no `"${arr[@]}"` expansion at all (its one array read is
`${#feature_legs[@]}`, the count `main`'s own `leg)` arm already uses).

## The rebase

`e18ec53` → `7efc850`, still ONE commit. The conflicts were the three texts
this reading shares with #23 and #27, and the two caps: the `--help` exception
paragraph, where `main`'s "after a fetch that WORKED in that repository"
replaces "under `--fetch`" and the key-order clause follows it; `read_record`'s
locals and its first pass, where the `noleg` arm and its three arrays join
#27's `feature_rr`/`feature_add` walk rather than the `feature_gone` it
replaced; and the two cap entries. AGENTS.md and the README merged clean.
Everything above was re-measured on the rebase.

Recorded and NOT taken, as before: `workspace_load_project` takes a list item
by stripping `- ` and TRIMMING AGAIN, so `-   branch:` and `-   role:` are a
feature and a leg to it while this reader's patterns match neither. Re-run
2026-09-14: `main` and this branch answer IDENTICALLY on both. It is neither
this branch's regression nor its to fix; it wants an item parser this layer
has never had.

## Copilot's three rounds, `8a77d39`, `2bedf9b` and `55bb7a1`

Round 1 on `9b06ecb` (three inline threads, six suppressed), round 2 on
`8a77d39` (one suppressed) and round 3 on `2bedf9b` (one inline) are **six
findings, all six real and all six taken**; the loader run that decided each is
in [this
comment](#33 (comment)).

* **The noun, six places.** "at the next **key** at feature indent" — in
  `status --help`, AGENTS.md rule 4, the README, both cap docstrings and the
  help string the suite pins byte-for-byte. `grep -rn "next at "` over the
  tree now returns nothing.
* **A reopened list is a clean slate for `$dropped`.** The legs of a list
  reopened below an unread `- branch:` are collected onto the feature ABOVE
  it, so a `- role:` left under a shut leg list there is that feature's
  defect — and, left set, `$dropped` suppressed its row entirely: the leg went
  out in SILENCE, and where the feature above kept no read leg the report said
  "the record lists no leg for it" about a record that lists one.
* **A list that was never OPENED has no key that shut it.** `record_unread_why`
  takes two arms more, `nolist` and `nolegs`, which name the key that opens
  each list and say it is missing above that line, rather than sending a hand
  to a closing key the record has not got.
* **And the third state may not swallow the second** — not Copilot's finding
  but the hole taking the one above opened. The loader makes a feature at
  indent 6 only where the item's key is `branch`, so any other line there
  leaves the feature above it current, and THAT feature has its `legs:` key.
  `nolegs` is the `- branch:` line's alone.
* **No unread-leg line promises back a feature this run already refuses.** The
  legs it DOES read can carry a whole-feature verdict of their own; the
  verdict is read back in the order the `leg)` arm reads it, and where there
  is one the sentence says so and stops.
* **A leg the record gives no role is named by the role it has not got.**
  `- role: # note` is that line to both readers — `record_scalar`'s reading
  from #21 — and the finding about it had been naming the leg with a pair of
  empty backticks. Recorded and not taken: with the key put back such a leg is
  one `collect_legs` READS, which `check_parked_leg`'s roleless arm already
  answers on the run after the key moves.

* **A blank `- branch:` that keeps a leg still names the one it drops.** The
  combined line was reached only where the feature keeps NO leg; where it keeps
  one the run fell through to "a `- branch:` in the record has no value" and
  stopped — and since the blank name suppresses every per-leg line and the
  `noleg` arm only counts, the dropped line was said NOWHERE. The new arm is
  the third of four and keeps RR2's refusal, because a feature that keeps a leg
  `collect_legs` collects is not refused as a shape mismatch; the exits stay the
  blank name's, since no re-ordering settles a feature named nothing.

**Bite**: 5 tests fail against `9b06ecb`, 2 more against `8a77d39`, 1 more
against `2bedf9b`. **Suite**: 485 → 488 → 490 → **491**. **Caps unmoved by those four commits**: AGENTS.md 224, README.md 383 (the later merge of `main` raises them to 224 / 409 — see below). **Row
differential `9b06ecb` → `8a77d39` over 21 records**: the feature and leg
counts identical in all 21 — every difference is which line a finding names,
one line that was never printed, and one name that was printed empty. The
estate-level guard above is `7efc850` → `9b06ecb` and is not rebuilt for these
rounds, for that reason. Invariants unchanged at each step, shellcheck profile
included.

## The merge of `main` at `63a74af`

`main` moved to `63a74af` (#26, Amendment 11's lane tooling) while this branch
waited on review, so the branch merges it — **a merge commit, `e2952d9`, not a
rebase**, because three Copilot rounds are recorded against `8a77d39`,
`2bedf9b` and `55bb7a1`, and a rebase would rewrite all three and leave the
review pointing at commits that no longer exist.

#26 touches neither `status` nor `tests/test_status_command.py`, so the overlap
is three files. `AGENTS.md` and `README.md` merged CLEAN and both readings
stand in their places: the merged `AGENTS.md` differs from this branch's by
exactly `main`'s one line (the `--install` count, nine → eleven), and the
merged `README.md` differs from `main`'s by exactly this branch's six.

**The one conflict was the two README cap entries, and both sides were right** —
each appended a dated entry after `270 AND 363 MEET AT 377` and each rewrote the
same `assert`. Both entries are kept, and a third, `383 AND 403 MEET AT 409`,
records the arithmetic. Nothing is dropped.

**The caps are the measured counts of the MERGED files:**

| file | this branch | `main` | **merged, checked in** |
|---|---|---|---|
| `AGENTS.md` | 224 | 214 | **224** |
| `README.md` | 383 | 403 | **409** |

`README.md` is 377 + 6 (this branch) + 26 (`main`), the line sets disjoint, and
neither side's number would have done: 409 fails `<= 383` **and** `<= 403`.
`AGENTS.md` does not move because #26 changed a *word* of it and not a line —
and its 224 is still the number measured after the merge rather than the one the
branch was carrying.

**Suite on the merged tree**: `python3 -m pytest tests -q` → **549 passed**,
rc=0 (the 491 measured here at `55bb7a1`, plus the 58 arriving with #26). Among
those 58, `ALL_BASH` now holds every shipped file to A9 Addendum 4's rule
against a `case` opened inside a `$( )`; it meets this branch's 379 added lines
of `status` for the first time here, and they carry none.

Lane: openrepotools-3 (openRepoTools-3)

PR #33

Co-Authored-By: Claude Fable 5.1 <[email protected]>
brettheap added a commit that referenced this pull request Oct 7, 2026
…ck every removal, switch --yes back on (#174)

* Add lane-worktrees: the sweep that retires a lane's abandoned worktrees

A swap that does not finish gracefully leaves its writers' trees where
they stood, and nothing removed them: a person archived, verified and
removed them by hand. `lane-worktrees sweep <lane>` makes that one act,
dry run by default, under one rule: nothing is deleted that is not
first on origin or in a bundle under the sweeps directory, and a live
writer's tree is never touched.

Which trees are the lane's is #97's inventory and the disk, never the
derived index (Amendment 14(b)); a tree the inventory does not name is
FOREIGN and is left unless --include-foreign and a --word, and one
another lane's inventory names is never taken. Who may act is #97's
reconciliation, read before any write including the fetch: a lane bound
elsewhere, held by another live session, managed-owned or unreadable is
refused (exit 2); a lane this session holds acts only on the writer
count the coordinator states with --live.

"Merged" is the register's LANDED line for the branch's PR or gh's
MERGED for it, never ancestry alone. Unpublished commits are pushed
under the branch's own name, never its upstream's (a branch made from
origin/main tracks main), or to rescue/<lane>/<slice>-<UTC> where
origin diverged; dirty work becomes a WIP commit built through a copy
of the index, so a refused push leaves the tree exactly as it was.
Removal re-proves the head and the content at the moment it happens.

Also --branches, --include-scratch, --include-caches,
--include-sandboxes, --links, alternates and local-remote detection
(LOAD-BEARING clones are never removed), sweep --expire with 90-day
retention that never expires an archive whose rescue left origin, and
the porcelain contract lane-end's gate (#163) reads: 0 nothing to
retire, 3 something to retire, 2 refused.

Part of #162.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Test the sweep against every row of #162's disposition table

tests/test_lane_worktrees.py builds a lane's estate under tmp_path: a
bare origin reached through a url.insteadOf for a GitHub-shaped URL, the
lane's checkout and both worktree roots, and fakes for lanes-edit.sh,
gh and tmux. One lane holds a tree in every state, and the dry run is
held to the table row for row and to a whole-estate snapshot that does
not move. The same lane under --yes is held to every act: pushes,
rescue branches seen on origin, the WIP commit's subject and parent,
the bundles, the ignored-file archive without bytecode, a manifest
that verifies, and one register line per tree.

Also: a refused push leaves the dirty tree byte for byte; a live writer
(a process's cwd, a tmux pane) is never touched; this session's --yes
needs its writer count; bound elsewhere, held elsewhere and unreadable
are refused with 2 and change nothing; merged by register and by gh
against a branch on main by ancestry alone; no gh, nothing merged;
--include-foreign takes a word and never another lane's tree;
--branches; scratch, caches and sandboxes; --links; a LOAD-BEARING
clone; --expire at 89/90/120 days; the porcelain exit codes; and two
cases on the REAL lanes-edit.sh, for the inventory, the register line
and a lane bound on another host.

Part of #162.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Place lane-worktrees as the seventeenth installed file

`openRepoTools --install` places `lane-worktrees` at the end of
INSTALLABLES, so every index a test takes still names the file it did.
The file count moves 16 -> 17 and the artifact count 30 -> 31 wherever
they are stated, with the count history extended rather than restated;
the receipt sentence now says 31 artifacts, 29 rows. --help names the
new command.

The hygiene suite compiles `lane-worktrees` beside `lanes-index`: the
two shipped commands that are Python and have no .py suffix for the
glob to find.

Part of #162.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Document the sweep in the lanes manual

"Retiring a lane's worktrees": the rule, which trees are the lane's and
who may act, the disposition table as implemented in the order it is
decided, the other rows (--branches, scratch, caches, sandboxes, links,
bundles), the sweeps directory and its manifest, the one register line
per tree, retention and sweep.conf, the porcelain exit contract for
lane-end's gate, and the two protocol lines the act assumes, proposed
for the amendment that ratifies it.

Part of #162.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Walk the estate for --links with scandir

`os.walk` lstat()s every entry, and the estate on Eagle is tens of
thousands of directories: a read-only `--links` dry run took 245 s.
A scandir walk reads each entry's kind from the directory read itself,
so only a symlink or a `.git` file costs a call of its own. Measured
on the same estate: 16.7 s, with the same 403 broken links found (99
of them worktree gitdir pointers).

Part of #162.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Keep a test run's bytecode, cache and temp out of the worktree

A suite run left tests/__pycache__, .pytest_cache and, when killed, its
sandboxes in whichever worktree ran it; the estate cleanup found those
were 968 of 1,000 removals (#162, causes 3 and 4). tests/run.sh now
sends bytecode to ${XDG_CACHE_HOME:-~/.cache}/openRepoTools/pycache,
turns pytest's cache off, and roots --basetemp and TMPDIR under one run
root in ${XDG_STATE_HOME:-~/.local/state}/openRepoTools/tmp/<UTC>-<pid>/
that an EXIT trap removes however the run ends.

The suite now runs in the background and is waited for: bash runs a trap
only once its foreground child returns, so a TERM used to wait out the
whole suite. The INT and TERM handlers stop the suite, then exit, so the
EXIT trap removes the run root and, on the mkdir path, the lock. The
lock is computed before TMPDIR moves, so it stays the workstation's.
The repository venv is used when it has pytest, first on PATH so the
command line still reads `python3 -m pytest`.

tests/test_run_wrapper.py proves it against a stub suite: the
relocation, the run root gone after a pass, a failure, a TERM and an
INT, under flock and under the mkdir lock, and the venv.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Name the repository's virtual environment on --install

One virtual environment per repository, outside the estate, is the
convention the sweep's --include-caches row assumes (#162, cause 3): a
venv/ inside a worktree is a leftover to remove. --install now names
this repository's, ${XDG_CACHE_HOME:-~/.cache}/openRepoTools/venvs/
openRepoTools, and says whether it is there; when it is not, it prints
the two commands that make it. It never makes one: that needs pip and
the network, and an install from a checkout needs neither.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Seed the workspace .gitignore with bytecode and cache rules

Cause 19 of the cleanup analysis: a handoff's attachments were committed
with a whole virtualenv's __pycache__ inside them, and brett-wip carries
703 bytecode paths in its history. `wip init` now adds __pycache__/,
*.pyc, *.pyo, .pytest_cache/, .mypy_cache/, .ruff_cache/, node_modules/,
.venv/ and venv/ to the seeded .gitignore, in wip_substitute - the one
function both step-7 paths go through - so the bytes a seed writes and
the bytes a re-run compares are the same. A line the template already
carries is not repeated, so a template that adopts them upstream seeds
them once.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Refuse a workspace commit whose pathspec carries bytecode

The .gitignore lines keep a new workspace clean; an older one without
them still stages whatever a pathspec names. commit_push now asks git
what its pathspec would stage (git add --dry-run, which honours
.gitignore exactly as the real add does) and refuses, exit 2, nothing
staged, when any path has a __pycache__, cache, node_modules, venv or
site-packages component or is *.py[co] - and offers the .gitignore
lines that workspace lacks, with the one command that adds them.

Attachments are committed by hand, so the same question is a
subcommand: `lanes-edit.sh pathspec-check <path>...` answers 0 clean,
2 with the offending paths on stdout and the offer on stderr, 64 usage.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Run the estate report once a day from lane-start

The report is the net under every actor that never runs lane-end, and
it only works if it is read every day. lane-start now runs
`lane-worktrees sweep --all --dry-run --report` once per UTC day per
workstation, after the row is written and before the launch: the first
start of the day takes report-<YYYYMMDD>.stamp under the state
directory with an atomic `set -C` create, removes older stamps, and
starts the report detached, stdin, stdout and stderr closed, writing
reports/<UTC>.md. Every step either works or is skipped in silence, so
the report never delays a start and never fails one. --dry-run starts
none; LANE_WORKTREES_REPORT=off is the switch, and the suite sets it.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Report the estate's leftovers with sweep --all --dry-run --report

Workspace creation outpaces closeout, and nothing counted it. The
report reads every lane's #97 inventory and snapshot (beside each
checkout's parent, where #97 keeps them), the workspace register and
the disk - never the derived index - and lists, as one markdown
document: FOREIGN clones with size, last commit and Lane: owner;
orphaned trees of ENDED lanes; unmerged branches with a missing,
diverged or unpushed upstream; root-main divergence, with Amendment
4's remedy where only handoff/register paths moved; rescue branches
and dirty inventory trees awaiting disposition past aging_days; caches
and sandboxes by size; ignored directories over ignored_report_mb;
evidence-shaped paths; archives past retention (--expire's own table,
now shared as expiry_rows); the workspace's .gitignore and bytecode
history; and `status --all`'s findings, reported as what they are and
never counted as dirt. The head table carries the rescue-branch count
and the sweeps directory's size.

It changes nothing: no fetch, no index refresh, no expiry. --post
writes it to a file or comments it on owner/repo#n through gh.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Document the estate report and prevention at creation

The lanes manual gains the report (its sections, --post, the daily run
from lane-start and its switch) and what keeps leftovers from arriving:
the run.sh relocation, one venv per repository outside the estate, one
evidence root per repository under the state directory, and the
workspace's bytecode rules with lanes-edit.sh's refusal and
pathspec-check.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Take Copilot round 1's defects in the sweep

Every one of these let a destructive act rest on a read that was stale,
failed, or answered a different question:

- Merged now needs the PR's base to be the default branch (origin's HEAD,
  else main/master): a merge into a release branch is not a landing. An
  OPEN PR protects its branch before any older merged PR on that branch
  counts, unless the register LANDED that very PR.
- A failed `rev-list` distance is a read error, never "0 ahead", for a
  tree and for --branches' upstream state alike.
- A clone whose git directory linked worktrees share is kept. Removing it
  would take their repository with it.
- A tree that another lane's inventory also names is kept. An inventory
  record that cannot be read refuses the sweep (exit 2) instead of being
  skipped. The lane name goes through `canon-lane` before any path is
  derived from it, and an unreadable alias table refuses.
- Liveness is asked again before the rescue and again just before
  removal, afresh (processes, tmux, the recording session). A scan that
  cannot be made leaves the tree. Scratch is removed only if no writer
  arrived and nothing outside its caches changed while the tar ran. A
  cache is rechecked against its owning tree.
- Caches never come from a FOREIGN tree, a live one, or one whose
  liveness is unknown.
- Branches are deleted at the SHA that was judged: `update-ref -d <old>`
  locally, a --force-with-lease push for the remote. Each failure is
  counted, and the register claims "+ remote" only for a remote delete
  that happened.
- --branches fetches the lane's own checkout too, and a failed fetch
  deletes nothing.
- A stale registration is removed by `git worktree remove <path>` alone,
  never by a repository-wide prune.
- An ignored-file listing that failed stops the act. It is never read as
  "nothing ignored".
- Each invocation gets its own archive directory, created exclusively.
- An origin-less worktree under --bundle --yes is bundled and removed,
  as its dry run says, instead of being read as a failed fetch.
- --expire requires the rescued SHA itself on origin and an archive that
  is whole: a MANIFEST.sha256 listing every file at its digest, and a
  rescues.tsv whose rows parse.

Ten new or extended cases. Each one fails against the previous head and
passes here.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Document round 1's rules in the lanes manual

The manual now states what changed: the canonical lane name, refusal on
an unreadable record, contested trees, the single-registration prune,
the linked-worktree clone guard, merged-into-default with open PRs first,
SHA-fenced branch deletes, liveness asked again before removal, scratch
and cache rechecks, the exclusive archive directory, and expiry of whole
archives only.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Say what expiry_rows keeps now that #168 checks whole archives

The merge from #168 brought in archive_ledger and the exact-SHA check.
The report's archive section reads them through expiry_rows, so its
docstring now says it keeps archives that are not whole and those whose
rescue branch moved.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Stop the suite's whole process group when a run ends

Copilot on #169: a TERM to the pytest pid alone leaves whatever it is
waiting on (a shell suite, a git, a fixture's sleep) running, while the
EXIT trap deletes its temp root and releases the mkdir lock around it.
The suite now starts in a process group of its own, with `set -m` on for
that one line only. The INT/TERM handlers and the EXIT trap TERM the
whole group, reap the leader, wait up to ten seconds for running members
and then KILL the group. Running members are counted from `ps`, never
`kill -0`, because an orphan's zombie answers `kill -0` until whoever
adopted it reaps it.

The kill cases now give the stub suite a child of its own and require
it to be gone. Against the previous run.sh that case fails with "the
suite's own child outlived its wrapper".

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Offer and seed site-packages/ with the other bytecode rules

Copilot on #169: the refusal classifies any path under a site-packages
directory, since that is a virtual environment under any name, but
neither the offered lines nor the seeded ones covered it. Following the
offer therefore left the refusal standing. `site-packages/` now joins
BYTECODE_IGNORES and WIP_HYGIENE_LINES. The shell case adds a venv
named env-x: it is refused, `site-packages/` is among the lines offered,
and it is still refused until that line is added.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Report duplicate clones with no named checkout, over one estate

Copilot on #169, two report defects:

- Two clones of one origin, neither named for the repository, were both
  treated as canonical, so the duplicate finding vanished. The checkout
  is now chosen deterministically (the one named for the repository,
  else the shallowest), and every other clone is reported, with a note
  when the choice was ambiguous.
- `status --all` was pointed at the estate only when --estate was given.
  It now always gets the root the report resolved, and lane-start passes
  its own $PROJECTS_ROOT to the daily run.

The report's hygiene check wants site-packages/ too. Each new assertion
fails against the previous head.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Take Copilot round 2's defects in the sweep

Seven of round 2's eight. Each one let an act proceed on an unknown:

- Another lane's inventory record or directory that cannot be read, or
  that names no path, now refuses the sweep. Who else claims a tree is
  read before the fetch, so the refusal writes nothing.
- A submodule's ignored files (an .env) keep the tree. The tree's
  ignored archive covers the superproject only.
- Ignored files are printed before the archive and listed again at
  removal. A change, an addition or a failed listing leaves the tree.
- A prune candidate whose directory reappeared is left for the next
  sweep to classify.
- A pytest sandbox's .lock is read again at the act, and a live pid
  leaves it.
- `tracked()` returns None when a repository's index cannot be read,
  and such a cache is left.
- A manifest entry whose file is gone makes the archive not whole.

The eighth, unreadable /proc entries of same-account processes, is a
design trade and is filed in #170. On Eagle, 9 such processes exist at
any time (6 `timeout`, 3 `ssh-agent`), so reading them as "unknown"
would keep every tree on every sweep.

Four new or extended cases. Each fails against ae17742 and passes here.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Refuse bytecode that is already staged, not only what add would stage

Copilot round 2 on #169: `git add --dry-run` says nothing about a path
the index already holds at those bytes, yet the path-limited commit
still takes it. bytecode_in_pathspec now also reads `git diff --cached
--name-only --diff-filter=d` for the same pathspec. A staged deletion of
bytecode is a cleanup and is let through. The shell case force-stages a
.pyc after the ignore lines are in place: pathspec-check and the commit
path both refuse it, and nothing is committed.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Quote the venv paths in the command --install prints

Copilot round 2 on #169: the command is meant to be pasted into a
shell, and $XDG_CACHE_HOME is the person's to choose, spaces included.
Both paths are now `printf %q`-quoted. The new case installs with a
cache directory containing a space, and shlex reads each path back as
one word.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Report what the report could not read

Copilot round 2 on #169: an unreadable lane snapshot or inventory
record became an empty one, so a lane or tree dropped out of every
section and the report could look clean. Reads now go through _ls and
_record. A failure other than "not there", a tree record naming no
path, or an inventory tree whose git status fails is a row in a new
section, "Records the report could not read". The unused _sidecar
reader is gone.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Keep AGENTS.md and README.md within their line caps

test_repo_hygiene caps AGENTS.md at 316 lines and README.md at 486, and
both files were exactly at their caps on main. The run.sh paragraph had
taken AGENTS.md to 330 and the venv sentence README.md to 491. The full
text already lives in docs/README-lanes.md, so AGENTS.md now says the
same thing in the three lines the old sentence took, and README.md says
it on the line it extends. No cap is raised.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Assert the flock file only where there is flock

Copilot on #169: macOS has no flock, so the wrapper takes the mkdir lock
and never creates openrepotools-pytest.lock. The relocation case checked
for that file unconditionally and would have failed the macOS job, which
is the landing gate. Where there is no flock, the case now checks
instead that the mkdir lock was released.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Switch --yes off until #170; keep the gate and exit contract honest

The adversarial review of 3c0b188, reproduced with its probes against
the suite's own Estate fixture:

1. --yes and --expire --yes are refused, exit 2, changing nothing,
   unless LANE_WORKTREES_ENABLE_YES=1 is set. #170 lists data-loss paths
   that are still open. The suite's Estate sets the variable; a real
   estate should not until #170 lands. The dry run, --porcelain and
   --report are untouched.
2. B1: a tree that #97's inventory does not name is still the lane's if
   it stands under .lane-worktrees/<lane>/, or if it sits in
   <checkout>/.claude/worktrees on a branch whose own commits carry this
   lane's Lane: trailer. Another lane's claim still wins. Such trees keep
   the quiet-hours liveness rule. A lane whose state is NONE but which
   has trees of its own is refused, exit 2. On Eagle, `sweep
   openRepoTools-3 --dry-run --porcelain` gave exit 0, `summary 0 15 0
   15`. It now gives exit 2, `summary 9 13 4 4`: 9 trees are the lane's,
   and the snapshot is NONE.
3. B2: subprocess output and git metadata files are decoded with
   surrogateescape, and stdout and stderr write with it too, so a
   Latin-1 worktree name is reported rather than raising. An unreadable
   pytest-of-$USER is a kept sandbox row. A catch-all keeps errors that
   no read caught inside the contract: exit 2 on a dry run, and under
   --yes DISPOSITION.md is written first and the exit is 1.
4. B3: every porcelain field escapes backslash, TAB, newline and CR.
   Worktree registrations are read with `git worktree list -z` where git
   has it, so a newline in a path no longer becomes a phantom
   registration.

Five new cases (switch off, ownership plus NONE, escaping, non-UTF-8
path, unreadable sandbox root), each failing against 3c0b188. Two cases
were moved off the lane root to keep testing FOREIGN trees. 40 cases.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Document the --yes switch, lane-root ownership and porcelain escaping

The manual now leads the sweep section with the --yes switch and #170.
It also says which unrecorded trees are a lane's and that a NONE snapshot
with trees is refused. The exit contract now covers the escaped fields
and the catch-all.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Run the suite in the foreground when stdin is a terminal

Adversarial review B7: `set -m` puts the suite in a background process
group with the terminal as its stdin. Anything that reads the terminal
(--pdb, breakpoint(), input()) is then stopped by SIGTTIN, and the
wrapper waits on it for ever while holding the workstation flock. With
a terminal on stdin the suite now runs in the foreground, in the
terminal's own process group, and a Ctrl-C reaches all of it from the
terminal. Without a terminal the process-group stop is unchanged.

The new case runs the wrapper on a pseudo-terminal whose stub suite
prints a prompt and reads a line. It passes here. Against the previous
run.sh it hangs and fails, with the transcript showing the prompt and
the typed line that was never read.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Never adopt a standalone clone under the lane's root

5f4bd84 made every unrecorded tree under .lane-worktrees/<lane>/ the
lane's. That included standalone clones, which #162's first protocol
line and the manual keep FOREIGN ("a lane creates worktrees, never
clones"). Copilot flagged it on 296e2f0. Clones are now excluded from
both adoption paths. The ownership case adds a clone under the lane
root and requires it to stay foreign and not retire-counted. On Eagle
none of the lane's seven root trees is a clone, so the dry run is
unchanged there.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Fetch the register directly under --yes and refuse when it fails

#170 A1. lanes-edit.sh's log_sync answers 0 on every way it can fail to
fetch, and an inherited LANES_NO_FETCH=1 skips the fetch outright. A lane
rebound on another host after this workstation's last register fetch
therefore read as bound here, and --yes removed its trees (Amendment
18(b): from outside the binding a lane is UNKNOWN, never dead).

Under --yes the sweep now fetches the workspace repository's
origin/<branch> itself, with an explicit refspec, before anything else.
A fetch that fails refuses the run, exit 2, with nothing changed. Every
later helper call reads the ref that fetch left, so an inherited
LANES_NO_FETCH no longer decides. The dry run is unchanged.

The test estate now carries a workspace repository (the fetch's target,
and #170 G6's register) and records its inventory under an earlier
session, as a swept lane's trees are. The new case rebinds the lane on
another host after the last fetch, then runs --yes with origin
unreachable and with LANES_NO_FETCH inherited: both refuse and the tree
stays.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Pin the sweep's fetch refspec so --prune cannot delete local branches

#170 item 6 (Copilot round 3 on #168). With a mirror-style
remote.origin.fetch such as +refs/heads/*:refs/heads/*, the preflight
`git fetch --prune origin` deleted every local branch origin lacks,
before anything was classified or rescued.

The fetch now names its refspec and refmap, as `status --fetch` does:
+refs/heads/*:refs/remotes/origin/*, with --refmap set to the same, so
the configured refspec maps nothing. fetch.pruneTags and the remote's
pruneTags are forced off, so a local tag is never pruned with it.

The case configures the mirror refspec with nothing checked out that
origin has (git refuses to fetch into a checked-out branch, which hides
the prune) and a local-only branch and tag. Both survive --yes.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Refuse when a lane root or a registration list cannot be read

#170 G1 and G5 (Copilot after the cap). Discovery read a lane worktree
root that could not be listed as an absent root, and a failed
`git worktree list` as a repository with no worktrees. With an empty
inventory either one let the dry run exit 0 and clear #163's gate over
trees nobody could see.

Only a root that does not exist is skipped now; any other listing
failure refuses, exit 2. worktree_registrations returns None when both
listings fail. Discovery refuses on it. The prune's after-check, a
branch delete and --branches stop that act. The report records the
checkout as unreadable.

Two cases: a mode-000 lane root with an empty inventory, and a git shim
that fails `worktree list`. Both now exit 2.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Walk every estate directory for dependents; a partial scan deletes nothing

#170 A11. The estate walk entered a repository only through worktree
containers, so it never saw a plain directory inside a repository (it
found none of xFactory/xFactories/* on Eagle). A clone there that
borrowed a lane clone's objects was unseen, and the clone was deleted
from under it. An empty estate root read no dependents at all, and an
unreadable directory read as one with nothing in it.

walk_estate visits every directory but caches, tool environments and
site-packages. It never follows a symlink or enters a .git, and it
collects .lane-state directories for #170 G6. Whatever it, or the
alternates and config reads, could not read makes the dependents scan
partial. A partial scan, a missing estate root, or a tree outside the
estate root keeps a clone and a scratch directory. Both are removed by
deleting a directory, and a dependent nobody saw would lose its objects.
Worktrees are untouched by this: their objects live in the checkout's
repository, which a worktree removal leaves.

Two cases: a --shared dependent under host/vendor/ makes the clone
load-bearing, and a mode-000 directory in the estate keeps it.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Read every other lane's control root before granting a tree

#170 G6 (Copilot after the cap). Other lanes' claims were read only
under this lane's control-root parent and the LANES_LANE_STATE_ROOT
override. A lane in a nested estate keeps its .lane-state beside its own
recorded dir, so its claim was missed, the tree was not contested, and
--yes could take it.

The parents read now also include $PROJECTS_ROOT/.lane-state, every
.lane-state the estate walk found, and the parent of every lane's
recorded dir. The recorded dirs come from one `git grep` over the
register's lane logs on origin/<branch>, parsed as lanes-edit.sh's
payload_subfield parses them. A register that cannot be read refuses:
whose claims were missed would be unknown. Lane names compare without
case, as Amendment 15 has them.

The case puts another lane's claim on one of this lane's trees under
<estate>/group/.lane-state, and under a directory outside the estate
that only the register names. Both keep the tree.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Keep trees whose hidden edits, nested clones, tags or submodule refs would go

Four ways tree_guards let a removal take work no rescue carried:

- #170 A2: a file flagged skip-worktree or assume-unchanged reads clean
  in `git status`, and `git add -A` skips it, so its edit was in no
  rescue. hidden_edits hashes every flagged file present in the tree
  against its index blob, and a difference keeps the tree. A flagged
  file that is absent (a sparse checkout's) is no edit.
- #170 A3: the nested-repository walk passed over venvs and node_modules
  before it looked for a .git, so `pip install -e git+...`'s clone in
  <venv>/src/<pkg> was deleted with the tree. nested_repos skips only
  bytecode caches, and a directory it cannot read keeps the tree.
- #170 item 4: a clone's publication check read branches and the
  stash, not tags. unpublished_ref checks every branch, every tag
  (peeled to its commit) and HEAD against refs/remotes/origin in one
  rev-list. A tag that names no commit cannot be checked, and keeps it.
- #170 item 5: only a submodule's HEAD was checked. A worktree's
  submodules keep their repositories under .git/worktrees/<id>/modules/,
  so their branches, tags and stash went with the tree. Each initialized
  submodule now gets the same check against every remote of it, plus
  its stash. A `git submodule status` that fails keeps the tree; it used
  to skip the submodule checks.

Cases: both flags, a sparse checkout's absent file (still removed), a
clone in .venv/src, a clone's annotated tag on a commit no branch has,
and a submodule's unpublished branch and stash.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Judge an ignored entry by its own name, not an ancestor's

#170 A6. ignored_paths dropped an ignored file when any ancestor was
named like a cache or build output. With --directory an ignored cache or
build directory is listed as itself, so a path beneath a directory named
`build` is an ignored file in a tracked directory. docker/build/prod.env
was deleted unarchived while top.env beside it was archived.

Only the entry's own basename is compared with CACHE_NAMES, VENV_NAMES
and BUILD_NAMES now. An ignored /build/ directory is still build output
and is not archived.

The case puts prod.env in the tracked docker/build/ beside an ignored
/build/ and checks the archive holds prod.env and top.env and nothing
of build/.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Leave other people's open branches alone: rescue, and keep the remote

Two ways --yes acted on a branch someone else's pull request owns:

- #170 A7: push+remove pushed the lane's unreviewed commit onto a
  teammate's OPEN PR branch, because the decision ignored the merge
  state. Where an open PR names the branch, where origin's tip carries
  another lane's Lane: trailer, or where whether a PR names it could not
  be read (gh unavailable), the commits now go to
  rescue/<lane>/<slice>-<UTC> and origin's branch is left as it is.
- #170 A8: a register LANDED line beat gh's live OPEN for the same
  number, so a LANDED #21 typed for #20 deleted the remote branch of the
  still-open #21 and closed it. The tree and its local branch still go
  (the work is on origin), but the remote branch is never deleted while
  gh answers OPEN for it. The same holds under --branches.

Cases: the open PR, another lane's trailer and LANES_NO_GITHUB each send
the commit to a rescue branch with origin's branch unmoved, and a wrong
LANDED number leaves the open PR's branch on origin.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Rescue before a prune, bundle what only a reflog names, self-check each removal

Four #170 items that share one mechanism: before a removal the sweep now
asks git which commits it would take and where each one is kept.

- The loss plan. A worktree's removal takes its git directory: its HEAD
  and that HEAD's reflog, plus the branch and its reflog where the
  branch is deleted after it. A pruned registration takes the same,
  read from its git directory. A clone takes every ref but its
  remote-tracking ones, and every reflog. One rev-list says which of
  those commits no origin ref, surviving branch, tag or stash, push
  seen on origin this run, or bundle head of this run reaches.
- A4: `prune` dropped the only pointer to a detached commit. A
  registration whose git directory names such a commit is now
  rescue+prune: a rescue branch pushed where there is an origin, a
  bundle, then that one registration removed.
- A5: commits only a reflog names (an amend, a reset, checking out away
  from a detached commit) were lost on removal and on delete_local_branch.
  They go to a bundle of their own through temporary
  refs/lane-worktrees/* refs, which are deleted once it is verified.
- Item 8: a bundle that is the only copy of what it holds (bundle+remove
  with no origin, the reflog bundle, the untracked bundle below) gets a
  rescues.tsv row (origin `-`, branch `bundle:<file>`). `--expire` reads
  it as "no other copy" and never expires that archive.
- A9: the WIP rescue pushed every untracked, un-ignored file, a service
  account key included. The pushed WIP commit now carries the tracked
  changes only. A second commit holding the untracked files goes to the
  bundle alone, as the ledger's only copy. --push-untracked pushes them
  as before.

THE SELF-CHECK. Right before each removal (and each prune) the same
question is asked once more. If anything the removal would take is
neither on origin nor in a verified bundle, the removal is refused,
DISPOSITION.md says so, nothing after it is acted on, and the exit is 2.
LANE_WORKTREES_SEAM_NO_LOSS_BUNDLE=1 is the suite's seam: it skips the
reflog bundle so the case can prove the self-check stops the loss.

Cases: a pruned detached commit (rescued, bundled), a reflog-only
commit (bundled, ledger row), the self-check with the seam (exit 2,
both trees left, the refusal in DISPOSITION.md), untracked files with
and without a tracked change (never on origin, in the bundle,
temporary refs gone), --push-untracked, and an origin-less
bundle+remove archive surviving `--expire --yes` at retention 0.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Run the push hooks where git-lfs is configured

#170 A10. `git push --no-verify` skips git-lfs's pre-push hook, which is
what uploads LFS objects. A rescued branch therefore reached origin as
pointers only, and the tree, the one copy of the objects, was then
removed.

Where the repository has any filter.lfs.* setting (the global one
included) the push now runs its hooks. A hook that refuses fails the
push and leaves the tree. Without git-lfs, --no-verify stays, so an
unrelated pre-push hook cannot hold a rescue up.

The case installs a pre-push hook that records itself. It runs with
filter.lfs configured and does not run without it.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Keep scratch that holds a tree or a repository

#170 item 7 (Copilot round 3 on #168). A scratch directory was archived
and removed whenever it had no .git of its own, so a worktree or clone
nested beneath it went with the rmtree. A FOREIGN or live tree was not
protected either, and nor was an unpushed commit.

A scratch directory is now kept while any tree of the table lies under
it, or any .git does at any depth (bytecode caches aside). A directory
under it that cannot be read keeps it too. The tree table retires its
own children first, and the scratch goes on a later sweep. The check is
made again at the act and again after the tar.

The case nests a clone with an unpushed commit two levels down in a
scratch directory. --include-scratch --yes keeps the scratch and the
commit.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Check --live paths, want the writer count for own trees, stop on NOT WRITTEN

Three gaps in how --yes takes the coordinator's word and the register's:

- #170 B4: a misspelt --live path was accepted in silence, so the
  writer it was meant to protect was not protected. Each --live path
  must now name a tree of the table (it, or a path inside it), and
  `--live none` stands alone. Anything else is usage, exit 64, decided
  before any repository is fetched.
- #170 B5: a tree this session recorded skips the transcript check,
  because the transcript is this one. --live was demanded only when the
  holder read as this session, so with the holder read as none, --yes
  removed trees this session's own writers could be in. Any inventory
  record whose writer is the caller now demands the count too.
- #170 B6: removals went on after a NOTED line failed. The first line
  the register refuses now stops the sweep. Every later tree and item
  is left as the table found it, with the reason, and the exit stays 1.

Cases: a typo'd --live path and `--live none <path>` exit 64 and touch
nothing; a tree recorded by this session refuses without --live and
goes with --live none; with the register refusing, the first tree goes,
the second stays, and exactly one line was attempted.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Count --branches by origin's own ref, never by upstream or an open PR alone

Two ways `--branches --dry-run --porcelain` gave #163's gate the wrong
answer (Copilot after the cap on #168):

- G2: every OPEN PR's branch was left out of the retire count, even a
  lane-owned one holding commits origin lacks, so the gate read 0. The
  delete protection stays. Such a branch is now counted unless
  refs/remotes/origin/<branch> holds its tip, and a read that failed
  counts it too.
- G7: a lane-owned branch was judged by its configured upstream alone.
  A branch made with `checkout -b X origin/main` tracks main, so once
  pushed under its own name it still read "ahead" and the gate read 3.
  Publication is now checked in origin's ref for the branch's own name
  first, and a branch origin holds that way is not listed. Unknown
  states are still counted.

Cases: an unpushed lane branch named by an open PR makes the dry run
exit 3 and survives --yes; a branch made from origin/main and pushed
as itself makes it exit 0.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Remove a tmp.* only on proof, and read hidden processes as unknown

#170 items 1 and 2 (Copilot on #168), with the coordinator's defaults,
which the PR body states for Brett Heap to overrule:

1. --include-sandboxes removed any account-owned tmp.* over an hour old
   with nobody in it, with no proof a suite made it, so a person's
   `mktemp -d` checkout or saved scratch could go. A tmp.* is now
   removed only with a suite's mark whose pid is gone (pytest's .lock,
   tests/run.sh's new .openrepotools-run marker, or run.sh's run-root
   layout of basetemp/ beside tmp/), or when nothing in it has been
   written for aging_days (14). Age is the newest mtime anywhere inside,
   not the top directory's. Any other tmp.* is a `list` row, kept. A
   marker's pid is read again at the act. tests/run.sh writes its pid
   into each run root it makes.
2. The /proc scan read a same-account process whose entries cannot be
   read (not dumpable) as absent, so its tree could be removed under
   it. Such a process is now in ProcScan.unknown and placed by what can
   be read: absolute paths in its command line, and its parent's
   working directory. A tree, scratch directory, cache owner or sandbox
   it is placed in is of unknown liveness and is kept, at the read and
   again at the act. One placed nowhere (ssh-agent re-parented to init:
   three on Eagle today) holds no tree, so a sweep is not frozen for
   ever. One whose status cannot be read at all could be anywhere. A
   process of another account is never a writer here. The human table
   names every unreadable pid in a note. Uid is read from
   /proc/<pid>/status, because a non-dumpable process's /proc entry is
   owned by root.

Cases: four tmp.* directories (unmarked and two hours old: listed and
kept; twenty days old, pytest-marked and run-root-shaped: removed), and
a non-dumpable child standing in a tree, which is kept. The existing
sandbox and report cases now age every file, not only the directory,
and the killed sandbox carries pytest's mark.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Document what #170's fixes change in the sweep

The manual's sweep section and --help now say:

- under --yes the register is fetched first, and a failed fetch refuses;
- each repository's fetch pins its refspec;
- other lanes' claims are read wherever #97 keeps them;
- an unreadable lane root, registration list or register refuses;
- --live must name a tree, and a tree this session recorded wants the
  count;
- the new keep rows (hidden edits, nested clones anywhere, clone tags,
  submodule branches, tags and stash, a partial dependents scan) and
  the rescue+prune row;
- untracked files go to the bundle only, unless --push-untracked;
- rescue rather than push onto another's branch, and no remote delete
  while gh answers OPEN;
- the loss plan, the reflog bundle and the self-check, and the stop on
  NOT WRITTEN;
- the LFS hooks, ignored files judged by their own name, scratch kept
  while trees lie under it;
- tmp.* removed only on proof, the bundle: rows that --expire never
  expires, and the exit contract's new 2 and 64.

The --yes switch and its paragraph go in the next commit, with the
switch itself.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Hold the existing cases to the register fetch, the untracked bundle and B5

Three of #170's fixes change what older cases see. A proof run of the
sweep module on CI (the workstation's pytest lock never came free)
failed these seven at the previous head:

- The table case asserted that the WIP rescue pushed the untracked
  new.txt. It now asserts new.txt is not on origin, and that the
  ledger's bundle: row for the dirty tree holds it (A9).
- The four refusal cases and the unreadable-claim case snapshot the
  estate around a refused --yes. --yes now fetches the register first
  (A1), which writes FETCH_HEAD in the workspace repository and nothing
  else, so the workspace is left out of those snapshots.
- The unreadable-record case wrote its record as this session's
  writer. B5 then refused first, with its own reason, so the record is
  written by the earlier session the fixture uses everywhere else.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Walk the whole estate only where a removal deletes a directory

Measured on Eagle, the whole-estate walk A11 asked for is 683,360
directories: 541,236 of them in xFactory alone, mostly spec trees. It
took 25 s warm and 397 s cold, where the gate's dry run took 15 s at
45fa45d. #163's gate would pay that at every lane-end, for nothing a
worktree's removal can break: a worktree's objects are its checkout's,
and the removal leaves them.

The whole walk now runs only where a removal deletes a directory: a
clone the table could take, or --include-scratch. Otherwise the
estate's shape walk is enough, as before. Other lanes' claims (G6)
follow #97's own rungs for every lane: the override, the parent of
every lane's recorded dir in the register, and $PROJECTS_ROOT. Each is
read beside this lane's own root and beside every checkout the shape
walk finds. So they no longer depend on the whole walk. A lane cannot
claim a tree without a register row.

The G6 case's nested checkout is now a repository, as a lane's is.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Refuse an inventory row that carries no id

#170 G9 (Copilot after the cap, on 87da332). lane_facts skipped a
`lane-trees` row whose id was empty. A tree such a row names outside the
scanned roots was then never discovered, and the dry run could exit 0
and clear #163's gate.

A nonempty row with no id is now an unreadable record. Discovery
refuses it, exit 2, as it refuses one of an unknown schema.

The case gives the inventory one id-less row naming a tree outside both
roots: exit 2, where 45fa45d exits 0.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Fail closed when the bytecode check cannot read the pathspec

#170 G13 (Copilot after the cap, on 45fa45d). bytecode_in_pathspec threw
both git reads' stderr away, and its awk exits 0 on no input. A read
that failed therefore printed nothing: a malformed magic pathspec, or an
index git cannot read, makes both `add --dry-run` and
`diff --cached` exit 128. `pathspec-check` then reported the pathspec
clean, and the commit path let it through.

Each git status is kept now, and the function answers 3 when a read
failed. `add --dry-run`'s exit 1 is not a failure: it means a named
path is ignored, which the add would not stage. `pathspec-check`
refuses with exit 2. The commit path refuses with exit 2 before it
stages anything.

The shell suite's #162 block gains four assertions: `pathspec-check
':(bogus)x'` exits 2 and says the read failed, and a commit of that
pathspec exits 2 and commits nothing. At 45fa45d the first exits 0 and
the commit fails later, at the add, with exit 6.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Document G9's id-less row and G13's failed read

The manual's inventory paragraph now names a row with no id among the
unreadable records that refuse a sweep. The pathspec-check usage line,
and the comment above the subcommand, now say exit 2 also covers a read
git could not make.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Read a .git file that is no pointer as no repository, not as unreadable

The read-only dry run over this lane's estate on Eagle kept every
--include-scratch directory as "the dependents scan was partial". The
cause was two empty .git files that uv keeps in its caches to stop git
looking upward. git_common_dir answers '' for those as it does for an
unreadable .git, and dependents_map counted both as unread.

A .git file that can be read and is no gitdir pointer is now skipped
as no repository. Only one that cannot be read leaves the scan partial.

The case puts uv's marker in the estate. A clone taken on a word is
still removed: the scan is whole.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Switch --yes back on: remove LANE_WORKTREES_ENABLE_YES

5f4bd84 switched --yes and --expire --yes off until #170's data-loss
paths were closed. Every item #170 lists for --yes now has a case that
fails against 45fa45d and passes here: items 1, 2 and 4-8, A1-A11,
B4-B6, G1, G2, G5-G7, G9 and G13. Before every removal the sweep also
asserts, of git itself, that each commit the removal would take is on
origin, in a ref that stays, or in a bundle this run verified. If not,
it refuses with exit 2 and a DISPOSITION.md line.

The switch, its refusal, the --help paragraph and the manual's
blockquote are gone. The suite's estates no longer set the variable.
The switched-off case is replaced by one that runs --yes and
--expire --yes with no variable in the environment.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Refuse a clone's removal when a reflog directory under it cannot be listed

#174 Copilot round 1 (lane-worktrees `_loss_plan`): the loss plan of a
clone collected its reflogs with `os.walk`, which passes over a directory
it cannot list in silence. A commit only `logs/refs/heads/<b>` named was
then in no plan: no bundle took it, the self-check asked the same blind
question, and the clone was deleted with it.

`reflog_files` walks `<gitdir>/logs` with an error handler: a `logs`
directory that is not there is an empty answer, anything else it cannot
list makes the loss plan unknown, and the clone is left in place.

The case seals a clone's `logs/refs/heads` (mode 000) with an experiment
only that branch reflog names, and wants the clone and the commit kept.

Lane: openRepoTools-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Keep a tree whose submodule names an unpublished commit only in its reflog

#174 Copilot round 1 (lane-worktrees `tree_guards`): a submodule's
experiment, made detached and checked out away from, is in no branch, tag
or stash of the submodule - only its reflog names it. Every submodule guard
passed, and the tree's removal took the submodule's repository, which lives
under the tree's own git directory, with the experiment in it.

The submodule's reflogs are read now (`unpublished_reflog`, through
`reflog_files`, so a directory it cannot list is unknown too): any commit
they name that no remote of the submodule holds keeps the tree, and says so.

Lane: openRepoTools-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Archive every ignored entry selected, whatever its ancestors are named

#174 Copilot round 1 (lane-worktrees `_tar`): #170 A6 selects an ignored
entry by its own name, so `docker/node_modules/prod.env` - an ignored file
in a tracked directory - is selected for the archive. The archive's member
filter then dropped any path with a cache- or venv-named part anywhere in
it, `top.env` beside it kept the archive non-empty, it verified, and the
tree was removed without prod.env.

The filter now judges only the parts of a member's path BENEATH the entry
it was added for, and always carries the entry itself; and the archive is
read back for every entry selected, so one missing leaves the tree.

Lane: openRepoTools-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Never remove a cache directory that holds a repository

#174 Copilot round 1 (lane-worktrees `_caches`): a tree kept because a
clone is nested in its venv (`pip install -e git+...` clones into
`<venv>/src/<pkg>`, #170 A3) still gave up its caches, and `.venv` is one.
`--include-caches --yes` removed it, and the clone and its unpushed fix
with it.

A cache candidate that is a repository, holds one anywhere inside, or
holds a directory that cannot be read is now a `keep` row when the table is
built, and asked again right before the removal. The venv case of A3 runs
`--include-caches --yes` too and wants the clone's commit kept.

Lane: openRepoTools-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* List an unmarked tmp.* that holds a repository, whatever its age

#174 (found auditing that a check guards every removal): `--include-
sandboxes` removed an unmarked `tmp.*` untouched for `aging_days` on age
alone - the second half of #170 item 1's default - so a person's `mktemp -d`
checkout with an unpushed commit in it went. No suite's mark says such a
directory's repositories are fixtures, so one that holds a repository, or
a directory that cannot be read, is listed and never removed; the check is
asked again right before the removal. A marked one is still the suite's,
and its repositories are its fixtures.

Lane: openRepoTools-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Bundle a branch's reflog-only commits and self-check before --branches deletes it

#174 Copilot round 1 (lane-worktrees `_act_item`): the loss plan, the
bundle and the self-check guarded a tree's branch delete only. With
`--branches --yes` a merged branch no worktree holds was deleted with
`update-ref -d`, which takes its reflog too - the last pointer to an
experiment committed on it and reset away from.

A branch item now asks what the delete would take (its tip and every
commit its reflog names, against origin, the other branches, tags, the
stash, this run's pushes and bundles), bundles what nothing keeps, with a
`bundle:` ledger row, and asks once more right before the delete. A refusal
there stops the sweep, exit 2, and DISPOSITION.md says so, as it does for a
tree; a refused item is no longer counted in the register's "swept branches"
line. The bundle helpers take a repository and a name instead of a tree.

Lane: openRepoTools-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Hold back untracked files by the act's own snapshots, and keep untracked git-lfs content

Two #174 Copilot round 1 findings in the WIP rescue (lane-worktrees
`_wip_rescue`), both about what goes to a bundle only (#170 A9).

Whether untracked files were held back was read from the table's status,
taken minutes earlier. A tree with only a tracked change when it was read,
and an untracked key file by the time of the rescue, had its full
snapshot - key included - pushed to origin. The pushed snapshot is now
always the tracked-only one (unless `--push-untracked`), and what the full
snapshot holds beyond it is what goes to the bundle alone.

An untracked file git-lfs filters is snapshotted as a POINTER: its bytes
go to the local LFS store, which no bundle carries and the removal may
take, so the bundle that was its only copy held no payload. Where git-lfs
is configured, such a tree is now `keep` - in the table, and again at the
act before anything is pushed (a `_Keep` found at the act leaves the tree
as the table would have).

The cases make the file arrive between the table and the act with a `git`
that writes it on the hidden-edit guard's second call.

Lane: openRepoTools-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Read a clone's annotated tag through its peeled commit, and bundle the tag object only origin lacks

#174 Copilot round 1 (lane-worktrees `lost_tips`, `_loss_plan`): a
clone's loss plan read every ref's raw `%(objectname)`, so an annotated
tag arrived as its tag object. `lost_tips` reported any object that was no
commit as lost whatever kept it - so the tag was bundled, then the
self-check reported it lost again, refused the removal and halted the
sweep, for every clone with an annotated tag.

A tag object is now kept where a SHA in the keep list names it - a
verified bundle's head, or origin's own copy of that very tag object,
read with `ls-remote --tags` (none when origin cannot be asked, so the tag
is bundled) - and its history is its peeled commit's, asked like any other
commit. A SHA in the keep list counts through the commit it peels to.

Lane: openRepoTools-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Document what #174's first Copilot round changes in the sweep

The manual's table and the command's own help now say that a submodule's
reflog-only commit keeps its tree, that untracked git-lfs content keeps
its tree and untracked files are read from the act's own snapshots, that
a clone's reflog directory that cannot be listed keeps the clone and its
annotated tags are bundled where origin lacks that very tag object, that
the ignored archive carries every entry selected whatever its ancestors
are named, that a `--branches` delete has its own loss plan, bundle and
self-check, and that neither a cache nor an unmarked `tmp.*` sandbox that
holds a repository is ever removed.

Lane: openRepoTools-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Keep a tree whose git directory keeps a submodule repository with work no remote of it holds, a deinitialized one's included

#174 Copilot round 2 (lane-worktrees `tree_guards`): the submodule
guards read only what `git submodule status` lists as checked out. A
DEINITIALIZED submodule shows `-`, its working tree is gone, and its
repository - branches, a stash, reflog entries - stays under
`<gitdir>/modules/<name>`, which the tree's removal takes. A branch no
remote held went with the tree.

Every repository kept under the tree's git directory's `modules/`
(nested ones included) is now read: a branch, tag or HEAD no remote of it
holds, a stash (read as its ref, since `git stash list` wants a working
tree) or a reflog entry no remote holds keeps the tree, and so does a
`modules/` directory that cannot be read.

Lane: openRepoTools-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Keep a tree whose submodule has a skip-worktree or assume-unchanged edit that git status hides

#174 Copilot round 2 (lane-worktrees `tree_guards`): #170 A2's
hidden-edit guard read the superproject only. A file flagged
skip-worktree or assume-unchanged in a submodule and edited there reads
as clean in that submodule exactly as in the superproject, no rescue
carries it, and it went with the tree. The same `hidden_edits` read now
runs in every checked-out submodule, and flags that cannot be read keep
the tree too.

Lane: openRepoTools-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Pass over nothing but .git when proving a removal takes no nested repository

#174 Copilot round 2 (lane-worktrees `nested_repos`): the walk skipped
directories named `__pycache__`, `.pytest_cache`, `.mypy_cache` and
`.ruff_cache`. It is the proof that a removal takes no repository, so a
checkout under a directory with one of those names was missed: a scratch
holding one was archived without it (the archive leaves caches out) and
removed. NESTED_SKIP is gone and every directory but `.git` is entered.

Lane: openRepoTools-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Read another lane's claims in every .lane-state the whole-estate walk finds

#174 Copilot round 2 (lane-worktrees `Sweep.gather`): where the whole
estate is walked - a clone the table could take, or `--include-scratch` -
`walk_estate` finds every `.lane-state`, one in a plain directory inside
a repository included (`host/vendor/.lane-state`), but the sweep threw
that list away and read claims only beside the shape walk's checkouts and
the register's recorded directories. With no log naming that place, a
clone another lane claimed from there was removed. The walk's control
roots are now read for claims as well, before liveness and the table.

Lane: openRepoTools-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Never push a lane's commits onto a branch gh still answers OPEN, whatever a LANDED line says

#174 Copilot round 2 (lane-worktrees `MergeEvidence.judge`, `_decide`):
a register LANDED line naming a pull request gh still answered OPEN, with
the local tip ahead of the PR's head, made the verdict "moved". That
verdict dropped gh's OPEN answer, so #170 A7's rule never fired and
push+remove put the lane's unreviewed commits onto the open pull
request's branch. The moved and merged-elsewhere verdicts now carry gh's
OPEN numbers, and a branch gh answers OPEN goes to a rescue branch, with
origin's branch left as it is.

Lane: openRepoTools-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Never prune a gone worktree's registration whose git directory keeps a submodule repository with work

#174 Copilot round 2 (lane-worktrees `_decide`, `_act_prune`): a
registration whose directory is gone still keeps its submodules'
repositories under `<admin>/modules/`, and the prune - which read only
the superproject's HEAD and reflog - removed them, a branch no remote held
with them. The same submodule-repository read as the tree guard now keeps
such a registration (`keep`), and is asked again right before the prune.

Lane: openRepoTools-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Keep a clone with a local git-lfs store when its commits would go to a bundle only

#174 Copilot round 2 (lane-worktrees `_act_tree`): a clean clone with a
commit only its reflog named had that commit bundled and was removed with
`.git/lfs/objects`. A bundle carries LFS pointers, never their bytes, and
no push uploaded them, so the bytes behind those pointers were lost. A
CLONE whose local LFS store holds anything (or cannot be read) is now kept
wherever a bundle would be the only copy of a commit - the `bundle+remove`
disposition and the reflog-only commits of step 2b alike.

Lane: openRepoTools-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Count a suite's .lock or run.sh marker as provenance only when it names a pid

#174 Copilot round 2 (lane-worktrees `sandbox_provenance`): an EMPTY or
malformed `.lock` (or `.openrepotools-run`) counted as a suite's mark,
so a person's two-hour-old `tmp.*` with a checkout in it was removed -
past coordinator default 1's 14-day rule and the repository guard both. A
mark now proves a suite made the directory only when it names a pid; the
run-root layout proof (`basetemp/` beside `tmp/`) is unchanged.

Lane: openRepoTools-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Document what #174's second Copilot round changes in the sweep

The manual's table and the command's own help now say that every
submodule repository a tree's or a gone registration's git directory keeps
- a deinitialized one's included - keeps it where it holds work no remote
of it holds, that a submodule's hidden edits keep the tree, that a
repository under a cache-named directory is still found, that the
whole-estate walk's `.lane-state` finds are read for claims, that gh's
OPEN wins over a LANDED line, that a clone's local git-lfs store keeps it
where a bundle would be a commit's only copy, and that a suite's mark must
name a pid.

Lane: openRepoTools-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Read a submodule repository kept under a git directory as that git directory alone, so a gone worktree's is read rather than refused

A submodule repository under `<gitdir>/modules/` names its working tree in
`core.worktree`. Where that directory is gone - every registration whose
worktree directory went, and a submodule removed after its deinit - every
git command run in the repository dies on "cannot chdir", so the guards
of this round's first and sixth commits read every such repository as
unreadable: a gone worktree with any submodule was kept for that reason
alone, never read. The proof run on the round's head showed it (the
prune's reason said the branches "could not be read" where the test
expected the unpublished branch named).

The submodule-repository reads now run each git command there with the
repository's own `objects/` as its working tree (`GIT_WORK_TREE`, through
`git_env(path)`); they are reads that need none - refs, reflogs,
rev-list, cat-file - and a branch no remote holds is named again.

Lane: openRepoTools-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Keep a tree or registration whose submodule repository has an annotated tag object no remote of it holds

#174 Copilot round 2 (lane-worktrees `module_repos_why`, submodule
guards): `unpublished_ref` asks whether an annotated tag's COMMIT is
published, never its tag object, so a submodule's local annotated tag on
a published commit passed every guard, and its message, which nothing
else held, went with the tree. A clone's own tags have been bundled since
round 1, but a submodule's are in no loss plan.

At the act, before anything is rescued, every submodule repository the
tree's (or a gone registration's) git directory keeps is asked: each
annotated tag object must be answered by some remote of it in
`ls-remote --tags` as that very object, else the tree is kept, and so it
is where no remote could be asked. It asks remotes, so the dry run, which
asks none, still reads `remove`.

Lane: openRepoTools-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Read the gone worktree's kept submodule repository in its regression the way the sweep reads it

The proof run on the round's head passed every assertion of
`test_a_gone_worktrees_kept_submodule_repository_is_never_pruned` about
the sweep - the registration kept, the reason naming the unpublished
branch - and then failed its own last c…
brettheap added a commit that referenced this pull request Oct 7, 2026
…s honesty, portability and test items (#170, part 2) (#179)

* Add lane-worktrees: the sweep that retires a lane's abandoned worktrees

A swap that does not finish gracefully leaves its writers' trees where
they stood, and nothing removed them: a person archived, verified and
removed them by hand. `lane-worktrees sweep <lane>` makes that one act,
dry run by default, under one rule: nothing is deleted that is not
first on origin or in a bundle under the sweeps directory, and a live
writer's tree is never touched.

Which trees are the lane's is #97's inventory and the disk, never the
derived index (Amendment 14(b)); a tree the inventory does not name is
FOREIGN and is left unless --include-foreign and a --word, and one
another lane's inventory names is never taken. Who may act is #97's
reconciliation, read before any write including the fetch: a lane bound
elsewhere, held by another live session, managed-owned or unreadable is
refused (exit 2); a lane this session holds acts only on the writer
count the coordinator states with --live.

"Merged" is the register's LANDED line for the branch's PR or gh's
MERGED for it, never ancestry alone. Unpublished commits are pushed
under the branch's own name, never its upstream's (a branch made from
origin/main tracks main), or to rescue/<lane>/<slice>-<UTC> where
origin diverged; dirty work becomes a WIP commit built through a copy
of the index, so a refused push leaves the tree exactly as it was.
Removal re-proves the head and the content at the moment it happens.

Also --branches, --include-scratch, --include-caches,
--include-sandboxes, --links, alternates and local-remote detection
(LOAD-BEARING clones are never removed), sweep --expire with 90-day
retention that never expires an archive whose rescue left origin, and
the porcelain contract lane-end's gate (#163) reads: 0 nothing to
retire, 3 something to retire, 2 refused.

Part of #162.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Test the sweep against every row of #162's disposition table

tests/test_lane_worktrees.py builds a lane's estate under tmp_path: a
bare origin reached through a url.insteadOf for a GitHub-shaped URL, the
lane's checkout and both worktree roots, and fakes for lanes-edit.sh,
gh and tmux. One lane holds a tree in every state, and the dry run is
held to the table row for row and to a whole-estate snapshot that does
not move. The same lane under --yes is held to every act: pushes,
rescue branches seen on origin, the WIP commit's subject and parent,
the bundles, the ignored-file archive without bytecode, a manifest
that verifies, and one register line per tree.

Also: a refused push leaves the dirty tree byte for byte; a live writer
(a process's cwd, a tmux pane) is never touched; this session's --yes
needs its writer count; bound elsewhere, held elsewhere and unreadable
are refused with 2 and change nothing; merged by register and by gh
against a branch on main by ancestry alone; no gh, nothing merged;
--include-foreign takes a word and never another lane's tree;
--branches; scratch, caches and sandboxes; --links; a LOAD-BEARING
clone; --expire at 89/90/120 days; the porcelain exit codes; and two
cases on the REAL lanes-edit.sh, for the inventory, the register line
and a lane bound on another host.

Part of #162.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Place lane-worktrees as the seventeenth installed file

`openRepoTools --install` places `lane-worktrees` at the end of
INSTALLABLES, so every index a test takes still names the file it did.
The file count moves 16 -> 17 and the artifact count 30 -> 31 wherever
they are stated, with the count history extended rather than restated;
the receipt sentence now says 31 artifacts, 29 rows. --help names the
new command.

The hygiene suite compiles `lane-worktrees` beside `lanes-index`: the
two shipped commands that are Python and have no .py suffix for the
glob to find.

Part of #162.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Document the sweep in the lanes manual

"Retiring a lane's worktrees": the rule, which trees are the lane's and
who may act, the disposition table as implemented in the order it is
decided, the other rows (--branches, scratch, caches, sandboxes, links,
bundles), the sweeps directory and its manifest, the one register line
per tree, retention and sweep.conf, the porcelain exit contract for
lane-end's gate, and the two protocol lines the act assumes, proposed
for the amendment that ratifies it.

Part of #162.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Walk the estate for --links with scandir

`os.walk` lstat()s every entry, and the estate on Eagle is tens of
thousands of directories: a read-only `--links` dry run took 245 s.
A scandir walk reads each entry's kind from the directory read itself,
so only a symlink or a `.git` file costs a call of its own. Measured
on the same estate: 16.7 s, with the same 403 broken links found (99
of them worktree gitdir pointers).

Part of #162.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Keep a test run's bytecode, cache and temp out of the worktree

A suite run left tests/__pycache__, .pytest_cache and, when killed, its
sandboxes in whichever worktree ran it; the estate cleanup found those
were 968 of 1,000 removals (#162, causes 3 and 4). tests/run.sh now
sends bytecode to ${XDG_CACHE_HOME:-~/.cache}/openRepoTools/pycache,
turns pytest's cache off, and roots --basetemp and TMPDIR under one run
root in ${XDG_STATE_HOME:-~/.local/state}/openRepoTools/tmp/<UTC>-<pid>/
that an EXIT trap removes however the run ends.

The suite now runs in the background and is waited for: bash runs a trap
only once its foreground child returns, so a TERM used to wait out the
whole suite. The INT and TERM handlers stop the suite, then exit, so the
EXIT trap removes the run root and, on the mkdir path, the lock. The
lock is computed before TMPDIR moves, so it stays the workstation's.
The repository venv is used when it has pytest, first on PATH so the
command line still reads `python3 -m pytest`.

tests/test_run_wrapper.py proves it against a stub suite: the
relocation, the run root gone after a pass, a failure, a TERM and an
INT, under flock and under the mkdir lock, and the venv.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Name the repository's virtual environment on --install

One virtual environment per repository, outside the estate, is the
convention the sweep's --include-caches row assumes (#162, cause 3): a
venv/ inside a worktree is a leftover to remove. --install now names
this repository's, ${XDG_CACHE_HOME:-~/.cache}/openRepoTools/venvs/
openRepoTools, and says whether it is there; when it is not, it prints
the two commands that make it. It never makes one: that needs pip and
the network, and an install from a checkout needs neither.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Seed the workspace .gitignore with bytecode and cache rules

Cause 19 of the cleanup analysis: a handoff's attachments were committed
with a whole virtualenv's __pycache__ inside them, and brett-wip carries
703 bytecode paths in its history. `wip init` now adds __pycache__/,
*.pyc, *.pyo, .pytest_cache/, .mypy_cache/, .ruff_cache/, node_modules/,
.venv/ and venv/ to the seeded .gitignore, in wip_substitute - the one
function both step-7 paths go through - so the bytes a seed writes and
the bytes a re-run compares are the same. A line the template already
carries is not repeated, so a template that adopts them upstream seeds
them once.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Refuse a workspace commit whose pathspec carries bytecode

The .gitignore lines keep a new workspace clean; an older one without
them still stages whatever a pathspec names. commit_push now asks git
what its pathspec would stage (git add --dry-run, which honours
.gitignore exactly as the real add does) and refuses, exit 2, nothing
staged, when any path has a __pycache__, cache, node_modules, venv or
site-packages component or is *.py[co] - and offers the .gitignore
lines that workspace lacks, with the one command that adds them.

Attachments are committed by hand, so the same question is a
subcommand: `lanes-edit.sh pathspec-check <path>...` answers 0 clean,
2 with the offending paths on stdout and the offer on stderr, 64 usage.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Run the estate report once a day from lane-start

The report is the net under every actor that never runs lane-end, and
it only works if it is read every day. lane-start now runs
`lane-worktrees sweep --all --dry-run --report` once per UTC day per
workstation, after the row is written and before the launch: the first
start of the day takes report-<YYYYMMDD>.stamp under the state
directory with an atomic `set -C` create, removes older stamps, and
starts the report detached, stdin, stdout and stderr closed, writing
reports/<UTC>.md. Every step either works or is skipped in silence, so
the report never delays a start and never fails one. --dry-run starts
none; LANE_WORKTREES_REPORT=off is the switch, and the suite sets it.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Report the estate's leftovers with sweep --all --dry-run --report

Workspace creation outpaces closeout, and nothing counted it. The
report reads every lane's #97 inventory and snapshot (beside each
checkout's parent, where #97 keeps them), the workspace register and
the disk - never the derived index - and lists, as one markdown
document: FOREIGN clones with size, last commit and Lane: owner;
orphaned trees of ENDED lanes; unmerged branches with a missing,
diverged or unpushed upstream; root-main divergence, with Amendment
4's remedy where only handoff/register paths moved; rescue branches
and dirty inventory trees awaiting disposition past aging_days; caches
and sandboxes by size; ignored directories over ignored_report_mb;
evidence-shaped paths; archives past retention (--expire's own table,
now shared as expiry_rows); the workspace's .gitignore and bytecode
history; and `status --all`'s findings, reported as what they are and
never counted as dirt. The head table carries the rescue-branch count
and the sweeps directory's size.

It changes nothing: no fetch, no index refresh, no expiry. --post
writes it to a file or comments it on owner/repo#n through gh.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Document the estate report and prevention at creation

The lanes manual gains the report (its sections, --post, the daily run
from lane-start and its switch) and what keeps leftovers from arriving:
the run.sh relocation, one venv per repository outside the estate, one
evidence root per repository under the state directory, and the
workspace's bytecode rules with lanes-edit.sh's refusal and
pathspec-check.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Take Copilot round 1's defects in the sweep

Every one of these let a destructive act rest on a read that was stale,
failed, or answered a different question:

- Merged now needs the PR's base to be the default branch (origin's HEAD,
  else main/master): a merge into a release branch is not a landing. An
  OPEN PR protects its branch before any older merged PR on that branch
  counts, unless the register LANDED that very PR.
- A failed `rev-list` distance is a read error, never "0 ahead", for a
  tree and for --branches' upstream state alike.
- A clone whose git directory linked worktrees share is kept. Removing it
  would take their repository with it.
- A tree that another lane's inventory also names is kept. An inventory
  record that cannot be read refuses the sweep (exit 2) instead of being
  skipped. The lane name goes through `canon-lane` before any path is
  derived from it, and an unreadable alias table refuses.
- Liveness is asked again before the rescue and again just before
  removal, afresh (processes, tmux, the recording session). A scan that
  cannot be made leaves the tree. Scratch is removed only if no writer
  arrived and nothing outside its caches changed while the tar ran. A
  cache is rechecked against its owning tree.
- Caches never come from a FOREIGN tree, a live one, or one whose
  liveness is unknown.
- Branches are deleted at the SHA that was judged: `update-ref -d <old>`
  locally, a --force-with-lease push for the remote. Each failure is
  counted, and the register claims "+ remote" only for a remote delete
  that happened.
- --branches fetches the lane's own checkout too, and a failed fetch
  deletes nothing.
- A stale registration is removed by `git worktree remove <path>` alone,
  never by a repository-wide prune.
- An ignored-file listing that failed stops the act. It is never read as
  "nothing ignored".
- Each invocation gets its own archive directory, created exclusively.
- An origin-less worktree under --bundle --yes is bundled and removed,
  as its dry run says, instead of being read as a failed fetch.
- --expire requires the rescued SHA itself on origin and an archive that
  is whole: a MANIFEST.sha256 listing every file at its digest, and a
  rescues.tsv whose rows parse.

Ten new or extended cases. Each one fails against the previous head and
passes here.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Document round 1's rules in the lanes manual

The manual now states what changed: the canonical lane name, refusal on
an unreadable record, contested trees, the single-registration prune,
the linked-worktree clone guard, merged-into-default with open PRs first,
SHA-fenced branch deletes, liveness asked again before removal, scratch
and cache rechecks, the exclusive archive directory, and expiry of whole
archives only.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Say what expiry_rows keeps now that #168 checks whole archives

The merge from #168 brought in archive_ledger and the exact-SHA check.
The report's archive section reads them through expiry_rows, so its
docstring now says it keeps archives that are not whole and those whose
rescue branch moved.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Stop the suite's whole process group when a run ends

Copilot on #169: a TERM to the pytest pid alone leaves whatever it is
waiting on (a shell suite, a git, a fixture's sleep) running, while the
EXIT trap deletes its temp root and releases the mkdir lock around it.
The suite now starts in a process group of its own, with `set -m` on for
that one line only. The INT/TERM handlers and the EXIT trap TERM the
whole group, reap the leader, wait up to ten seconds for running members
and then KILL the group. Running members are counted from `ps`, never
`kill -0`, because an orphan's zombie answers `kill -0` until whoever
adopted it reaps it.

The kill cases now give the stub suite a child of its own and require
it to be gone. Against the previous run.sh that case fails with "the
suite's own child outlived its wrapper".

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Offer and seed site-packages/ with the other bytecode rules

Copilot on #169: the refusal classifies any path under a site-packages
directory, since that is a virtual environment under any name, but
neither the offered lines nor the seeded ones covered it. Following the
offer therefore left the refusal standing. `site-packages/` now joins
BYTECODE_IGNORES and WIP_HYGIENE_LINES. The shell case adds a venv
named env-x: it is refused, `site-packages/` is among the lines offered,
and it is still refused until that line is added.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Report duplicate clones with no named checkout, over one estate

Copilot on #169, two report defects:

- Two clones of one origin, neither named for the repository, were both
  treated as canonical, so the duplicate finding vanished. The checkout
  is now chosen deterministically (the one named for the repository,
  else the shallowest), and every other clone is reported, with a note
  when the choice was ambiguous.
- `status --all` was pointed at the estate only when --estate was given.
  It now always gets the root the report resolved, and lane-start passes
  its own $PROJECTS_ROOT to the daily run.

The report's hygiene check wants site-packages/ too. Each new assertion
fails against the previous head.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Take Copilot round 2's defects in the sweep

Seven of round 2's eight. Each one let an act proceed on an unknown:

- Another lane's inventory record or directory that cannot be read, or
  that names no path, now refuses the sweep. Who else claims a tree is
  read before the fetch, so the refusal writes nothing.
- A submodule's ignored files (an .env) keep the tree. The tree's
  ignored archive covers the superproject only.
- Ignored files are printed before the archive and listed again at
  removal. A change, an addition or a failed listing leaves the tree.
- A prune candidate whose directory reappeared is left for the next
  sweep to classify.
- A pytest sandbox's .lock is read again at the act, and a live pid
  leaves it.
- `tracked()` returns None when a repository's index cannot be read,
  and such a cache is left.
- A manifest entry whose file is gone makes the archive not whole.

The eighth, unreadable /proc entries of same-account processes, is a
design trade and is filed in #170. On Eagle, 9 such processes exist at
any time (6 `timeout`, 3 `ssh-agent`), so reading them as "unknown"
would keep every tree on every sweep.

Four new or extended cases. Each fails against ae17742 and passes here.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Refuse bytecode that is already staged, not only what add would stage

Copilot round 2 on #169: `git add --dry-run` says nothing about a path
the index already holds at those bytes, yet the path-limited commit
still takes it. bytecode_in_pathspec now also reads `git diff --cached
--name-only --diff-filter=d` for the same pathspec. A staged deletion of
bytecode is a cleanup and is let through. The shell case force-stages a
.pyc after the ignore lines are in place: pathspec-check and the commit
path both refuse it, and nothing is committed.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Quote the venv paths in the command --install prints

Copilot round 2 on #169: the command is meant to be pasted into a
shell, and $XDG_CACHE_HOME is the person's to choose, spaces included.
Both paths are now `printf %q`-quoted. The new case installs with a
cache directory containing a space, and shlex reads each path back as
one word.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Report what the report could not read

Copilot round 2 on #169: an unreadable lane snapshot or inventory
record became an empty one, so a lane or tree dropped out of every
section and the report could look clean. Reads now go through _ls and
_record. A failure other than "not there", a tree record naming no
path, or an inventory tree whose git status fails is a row in a new
section, "Records the report could not read". The unused _sidecar
reader is gone.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Keep AGENTS.md and README.md within their line caps

test_repo_hygiene caps AGENTS.md at 316 lines and README.md at 486, and
both files were exactly at their caps on main. The run.sh paragraph had
taken AGENTS.md to 330 and the venv sentence README.md to 491. The full
text already lives in docs/README-lanes.md, so AGENTS.md now says the
same thing in the three lines the old sentence took, and README.md says
it on the line it extends. No cap is raised.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Assert the flock file only where there is flock

Copilot on #169: macOS has no flock, so the wrapper takes the mkdir lock
and never creates openrepotools-pytest.lock. The relocation case checked
for that file unconditionally and would have failed the macOS job, which
is the landing gate. Where there is no flock, the case now checks
instead that the mkdir lock was released.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Switch --yes off until #170; keep the gate and exit contract honest

The adversarial review of 3c0b188, reproduced with its probes against
the suite's own Estate fixture:

1. --yes and --expire --yes are refused, exit 2, changing nothing,
   unless LANE_WORKTREES_ENABLE_YES=1 is set. #170 lists data-loss paths
   that are still open. The suite's Estate sets the variable; a real
   estate should not until #170 lands. The dry run, --porcelain and
   --report are untouched.
2. B1: a tree that #97's inventory does not name is still the lane's if
   it stands under .lane-worktrees/<lane>/, or if it sits in
   <checkout>/.claude/worktrees on a branch whose own commits carry this
   lane's Lane: trailer. Another lane's claim still wins. Such trees keep
   the quiet-hours liveness rule. A lane whose state is NONE but which
   has trees of its own is refused, exit 2. On Eagle, `sweep
   openRepoTools-3 --dry-run --porcelain` gave exit 0, `summary 0 15 0
   15`. It now gives exit 2, `summary 9 13 4 4`: 9 trees are the lane's,
   and the snapshot is NONE.
3. B2: subprocess output and git metadata files are decoded with
   surrogateescape, and stdout and stderr write with it too, so a
   Latin-1 worktree name is reported rather than raising. An unreadable
   pytest-of-$USER is a kept sandbox row. A catch-all keeps errors that
   no read caught inside the contract: exit 2 on a dry run, and under
   --yes DISPOSITION.md is written first and the exit is 1.
4. B3: every porcelain field escapes backslash, TAB, newline and CR.
   Worktree registrations are read with `git worktree list -z` where git
   has it, so a newline in a path no longer becomes a phantom
   registration.

Five new cases (switch off, ownership plus NONE, escaping, non-UTF-8
path, unreadable sandbox root), each failing against 3c0b188. Two cases
were moved off the lane root to keep testing FOREIGN trees. 40 cases.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Document the --yes switch, lane-root ownership and porcelain escaping

The manual now leads the sweep section with the --yes switch and #170.
It also says which unrecorded trees are a lane's and that a NONE snapshot
with trees is refused. The exit contract now covers the escaped fields
and the catch-all.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Run the suite in the foreground when stdin is a terminal

Adversarial review B7: `set -m` puts the suite in a background process
group with the terminal as its stdin. Anything that reads the terminal
(--pdb, breakpoint(), input()) is then stopped by SIGTTIN, and the
wrapper waits on it for ever while holding the workstation flock. With
a terminal on stdin the suite now runs in the foreground, in the
terminal's own process group, and a Ctrl-C reaches all of it from the
terminal. Without a terminal the process-group stop is unchanged.

The new case runs the wrapper on a pseudo-terminal whose stub suite
prints a prompt and reads a line. It passes here. Against the previous
run.sh it hangs and fails, with the transcript showing the prompt and
the typed line that was never read.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Never adopt a standalone clone under the lane's root

5f4bd84 made every unrecorded tree under .lane-worktrees/<lane>/ the
lane's. That included standalone clones, which #162's first protocol
line and the manual keep FOREIGN ("a lane creates worktrees, never
clones"). Copilot flagged it on 296e2f0. Clones are now excluded from
both adoption paths. The ownership case adds a clone under the lane
root and requires it to stay foreign and not retire-counted. On Eagle
none of the lane's seven root trees is a clone, so the dry run is
unchanged there.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Fetch the register directly under --yes and refuse when it fails

#170 A1. lanes-edit.sh's log_sync answers 0 on every way it can fail to
fetch, and an inherited LANES_NO_FETCH=1 skips the fetch outright. A lane
rebound on another host after this workstation's last register fetch
therefore read as bound here, and --yes removed its trees (Amendment
18(b): from outside the binding a lane is UNKNOWN, never dead).

Under --yes the sweep now fetches the workspace repository's
origin/<branch> itself, with an explicit refspec, before anything else.
A fetch that fails refuses the run, exit 2, with nothing changed. Every
later helper call reads the ref that fetch left, so an inherited
LANES_NO_FETCH no longer decides. The dry run is unchanged.

The test estate now carries a workspace repository (the fetch's target,
and #170 G6's register) and records its inventory under an earlier
session, as a swept lane's trees are. The new case rebinds the lane on
another host after the last fetch, then runs --yes with origin
unreachable and with LANES_NO_FETCH inherited: both refuse and the tree
stays.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Pin the sweep's fetch refspec so --prune cannot delete local branches

#170 item 6 (Copilot round 3 on #168). With a mirror-style
remote.origin.fetch such as +refs/heads/*:refs/heads/*, the preflight
`git fetch --prune origin` deleted every local branch origin lacks,
before anything was classified or rescued.

The fetch now names its refspec and refmap, as `status --fetch` does:
+refs/heads/*:refs/remotes/origin/*, with --refmap set to the same, so
the configured refspec maps nothing. fetch.pruneTags and the remote's
pruneTags are forced off, so a local tag is never pruned with it.

The case configures the mirror refspec with nothing checked out that
origin has (git refuses to fetch into a checked-out branch, which hides
the prune) and a local-only branch and tag. Both survive --yes.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Refuse when a lane root or a registration list cannot be read

#170 G1 and G5 (Copilot after the cap). Discovery read a lane worktree
root that could not be listed as an absent root, and a failed
`git worktree list` as a repository with no worktrees. With an empty
inventory either one let the dry run exit 0 and clear #163's gate over
trees nobody could see.

Only a root that does not exist is skipped now; any other listing
failure refuses, exit 2. worktree_registrations returns None when both
listings fail. Discovery refuses on it. The prune's after-check, a
branch delete and --branches stop that act. The report records the
checkout as unreadable.

Two cases: a mode-000 lane root with an empty inventory, and a git shim
that fails `worktree list`. Both now exit 2.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Walk every estate directory for dependents; a partial scan deletes nothing

#170 A11. The estate walk entered a repository only through worktree
containers, so it never saw a plain directory inside a repository (it
found none of xFactory/xFactories/* on Eagle). A clone there that
borrowed a lane clone's objects was unseen, and the clone was deleted
from under it. An empty estate root read no dependents at all, and an
unreadable directory read as one with nothing in it.

walk_estate visits every directory but caches, tool environments and
site-packages. It never follows a symlink or enters a .git, and it
collects .lane-state directories for #170 G6. Whatever it, or the
alternates and config reads, could not read makes the dependents scan
partial. A partial scan, a missing estate root, or a tree outside the
estate root keeps a clone and a scratch directory. Both are removed by
deleting a directory, and a dependent nobody saw would lose its objects.
Worktrees are untouched by this: their objects live in the checkout's
repository, which a worktree removal leaves.

Two cases: a --shared dependent under host/vendor/ makes the clone
load-bearing, and a mode-000 directory in the estate keeps it.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Read every other lane's control root before granting a tree

#170 G6 (Copilot after the cap). Other lanes' claims were read only
under this lane's control-root parent and the LANES_LANE_STATE_ROOT
override. A lane in a nested estate keeps its .lane-state beside its own
recorded dir, so its claim was missed, the tree was not contested, and
--yes could take it.

The parents read now also include $PROJECTS_ROOT/.lane-state, every
.lane-state the estate walk found, and the parent of every lane's
recorded dir. The recorded dirs come from one `git grep` over the
register's lane logs on origin/<branch>, parsed as lanes-edit.sh's
payload_subfield parses them. A register that cannot be read refuses:
whose claims were missed would be unknown. Lane names compare without
case, as Amendment 15 has them.

The case puts another lane's claim on one of this lane's trees under
<estate>/group/.lane-state, and under a directory outside the estate
that only the register names. Both keep the tree.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Keep trees whose hidden edits, nested clones, tags or submodule refs would go

Four ways tree_guards let a removal take work no rescue carried:

- #170 A2: a file flagged skip-worktree or assume-unchanged reads clean
  in `git status`, and `git add -A` skips it, so its edit was in no
  rescue. hidden_edits hashes every flagged file present in the tree
  against its index blob, and a difference keeps the tree. A flagged
  file that is absent (a sparse checkout's) is no edit.
- #170 A3: the nested-repository walk passed over venvs and node_modules
  before it looked for a .git, so `pip install -e git+...`'s clone in
  <venv>/src/<pkg> was deleted with the tree. nested_repos skips only
  bytecode caches, and a directory it cannot read keeps the tree.
- #170 item 4: a clone's publication check read branches and the
  stash, not tags. unpublished_ref checks every branch, every tag
  (peeled to its commit) and HEAD against refs/remotes/origin in one
  rev-list. A tag that names no commit cannot be checked, and keeps it.
- #170 item 5: only a submodule's HEAD was checked. A worktree's
  submodules keep their repositories under .git/worktrees/<id>/modules/,
  so their branches, tags and stash went with the tree. Each initialized
  submodule now gets the same check against every remote of it, plus
  its stash. A `git submodule status` that fails keeps the tree; it used
  to skip the submodule checks.

Cases: both flags, a sparse checkout's absent file (still removed), a
clone in .venv/src, a clone's annotated tag on a commit no branch has,
and a submodule's unpublished branch and stash.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Judge an ignored entry by its own name, not an ancestor's

#170 A6. ignored_paths dropped an ignored file when any ancestor was
named like a cache or build output. With --directory an ignored cache or
build directory is listed as itself, so a path beneath a directory named
`build` is an ignored file in a tracked directory. docker/build/prod.env
was deleted unarchived while top.env beside it was archived.

Only the entry's own basename is compared with CACHE_NAMES, VENV_NAMES
and BUILD_NAMES now. An ignored /build/ directory is still build output
and is not archived.

The case puts prod.env in the tracked docker/build/ beside an ignored
/build/ and checks the archive holds prod.env and top.env and nothing
of build/.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Leave other people's open branches alone: rescue, and keep the remote

Two ways --yes acted on a branch someone else's pull request owns:

- #170 A7: push+remove pushed the lane's unreviewed commit onto a
  teammate's OPEN PR branch, because the decision ignored the merge
  state. Where an open PR names the branch, where origin's tip carries
  another lane's Lane: trailer, or where whether a PR names it could not
  be read (gh unavailable), the commits now go to
  rescue/<lane>/<slice>-<UTC> and origin's branch is left as it is.
- #170 A8: a register LANDED line beat gh's live OPEN for the same
  number, so a LANDED #21 typed for #20 deleted the remote branch of the
  still-open #21 and closed it. The tree and its local branch still go
  (the work is on origin), but the remote branch is never deleted while
  gh answers OPEN for it. The same holds under --branches.

Cases: the open PR, another lane's trailer and LANES_NO_GITHUB each send
the commit to a rescue branch with origin's branch unmoved, and a wrong
LANDED number leaves the open PR's branch on origin.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Rescue before a prune, bundle what only a reflog names, self-check each removal

Four #170 items that share one mechanism: before a removal the sweep now
asks git which commits it would take and where each one is kept.

- The loss plan. A worktree's removal takes its git directory: its HEAD
  and that HEAD's reflog, plus the branch and its reflog where the
  branch is deleted after it. A pruned registration takes the same,
  read from its git directory. A clone takes every ref but its
  remote-tracking ones, and every reflog. One rev-list says which of
  those commits no origin ref, surviving branch, tag or stash, push
  seen on origin this run, or bundle head of this run reaches.
- A4: `prune` dropped the only pointer to a detached commit. A
  registration whose git directory names such a commit is now
  rescue+prune: a rescue branch pushed where there is an origin, a
  bundle, then that one registration removed.
- A5: commits only a reflog names (an amend, a reset, checking out away
  from a detached commit) were lost on removal and on delete_local_branch.
  They go to a bundle of their own through temporary
  refs/lane-worktrees/* refs, which are deleted once it is verified.
- Item 8: a bundle that is the only copy of what it holds (bundle+remove
  with no origin, the reflog bundle, the untracked bundle below) gets a
  rescues.tsv row (origin `-`, branch `bundle:<file>`). `--expire` reads
  it as "no other copy" and never expires that archive.
- A9: the WIP rescue pushed every untracked, un-ignored file, a service
  account key included. The pushed WIP commit now carries the tracked
  changes only. A second commit holding the untracked files goes to the
  bundle alone, as the ledger's only copy. --push-untracked pushes them
  as before.

THE SELF-CHECK. Right before each removal (and each prune) the same
question is asked once more. If anything the removal would take is
neither on origin nor in a verified bundle, the removal is refused,
DISPOSITION.md says so, nothing after it is acted on, and the exit is 2.
LANE_WORKTREES_SEAM_NO_LOSS_BUNDLE=1 is the suite's seam: it skips the
reflog bundle so the case can prove the self-check stops the loss.

Cases: a pruned detached commit (rescued, bundled), a reflog-only
commit (bundled, ledger row), the self-check with the seam (exit 2,
both trees left, the refusal in DISPOSITION.md), untracked files with
and without a tracked change (never on origin, in the bundle,
temporary refs gone), --push-untracked, and an origin-less
bundle+remove archive surviving `--expire --yes` at retention 0.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Run the push hooks where git-lfs is configured

#170 A10. `git push --no-verify` skips git-lfs's pre-push hook, which is
what uploads LFS objects. A rescued branch therefore reached origin as
pointers only, and the tree, the one copy of the objects, was then
removed.

Where the repository has any filter.lfs.* setting (the global one
included) the push now runs its hooks. A hook that refuses fails the
push and leaves the tree. Without git-lfs, --no-verify stays, so an
unrelated pre-push hook cannot hold a rescue up.

The case installs a pre-push hook that records itself. It runs with
filter.lfs configured and does not run without it.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Keep scratch that holds a tree or a repository

#170 item 7 (Copilot round 3 on #168). A scratch directory was archived
and removed whenever it had no .git of its own, so a worktree or clone
nested beneath it went with the rmtree. A FOREIGN or live tree was not
protected either, and nor was an unpushed commit.

A scratch directory is now kept while any tree of the table lies under
it, or any .git does at any depth (bytecode caches aside). A directory
under it that cannot be read keeps it too. The tree table retires its
own children first, and the scratch goes on a later sweep. The check is
made again at the act and again after the tar.

The case nests a clone with an unpushed commit two levels down in a
scratch directory. --include-scratch --yes keeps the scratch and the
commit.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Check --live paths, want the writer count for own trees, stop on NOT WRITTEN

Three gaps in how --yes takes the coordinator's word and the register's:

- #170 B4: a misspelt --live path was accepted in silence, so the
  writer it was meant to protect was not protected. Each --live path
  must now name a tree of the table (it, or a path inside it), and
  `--live none` stands alone. Anything else is usage, exit 64, decided
  before any repository is fetched.
- #170 B5: a tree this session recorded skips the transcript check,
  because the transcript is this one. --live was demanded only when the
  holder read as this session, so with the holder read as none, --yes
  removed trees this session's own writers could be in. Any inventory
  record whose writer is the caller now demands the count too.
- #170 B6: removals went on after a NOTED line failed. The first line
  the register refuses now stops the sweep. Every later tree and item
  is left as the table found it, with the reason, and the exit stays 1.

Cases: a typo'd --live path and `--live none <path>` exit 64 and touch
nothing; a tree recorded by this session refuses without --live and
goes with --live none; with the register refusing, the first tree goes,
the second stays, and exactly one line was attempted.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Count --branches by origin's own ref, never by upstream or an open PR alone

Two ways `--branches --dry-run --porcelain` gave #163's gate the wrong
answer (Copilot after the cap on #168):

- G2: every OPEN PR's branch was left out of the retire count, even a
  lane-owned one holding commits origin lacks, so the gate read 0. The
  delete protection stays. Such a branch is now counted unless
  refs/remotes/origin/<branch> holds its tip, and a read that failed
  counts it too.
- G7: a lane-owned branch was judged by its configured upstream alone.
  A branch made with `checkout -b X origin/main` tracks main, so once
  pushed under its own name it still read "ahead" and the gate read 3.
  Publication is now checked in origin's ref for the branch's own name
  first, and a branch origin holds that way is not listed. Unknown
  states are still counted.

Cases: an unpushed lane branch named by an open PR makes the dry run
exit 3 and survives --yes; a branch made from origin/main and pushed
as itself makes it exit 0.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Remove a tmp.* only on proof, and read hidden processes as unknown

#170 items 1 and 2 (Copilot on #168), with the coordinator's defaults,
which the PR body states for Brett Heap to overrule:

1. --include-sandboxes removed any account-owned tmp.* over an hour old
   with nobody in it, with no proof a suite made it, so a person's
   `mktemp -d` checkout or saved scratch could go. A tmp.* is now
   removed only with a suite's mark whose pid is gone (pytest's .lock,
   tests/run.sh's new .openrepotools-run marker, or run.sh's run-root
   layout of basetemp/ beside tmp/), or when nothing in it has been
   written for aging_days (14). Age is the newest mtime anywhere inside,
   not the top directory's. Any other tmp.* is a `list` row, kept. A
   marker's pid is read again at the act. tests/run.sh writes its pid
   into each run root it makes.
2. The /proc scan read a same-account process whose entries cannot be
   read (not dumpable) as absent, so its tree could be removed under
   it. Such a process is now in ProcScan.unknown and placed by what can
   be read: absolute paths in its command line, and its parent's
   working directory. A tree, scratch directory, cache owner or sandbox
   it is placed in is of unknown liveness and is kept, at the read and
   again at the act. One placed nowhere (ssh-agent re-parented to init:
   three on Eagle today) holds no tree, so a sweep is not frozen for
   ever. One whose status cannot be read at all could be anywhere. A
   process of another account is never a writer here. The human table
   names every unreadable pid in a note. Uid is read from
   /proc/<pid>/status, because a non-dumpable process's /proc entry is
   owned by root.

Cases: four tmp.* directories (unmarked and two hours old: listed and
kept; twenty days old, pytest-marked and run-root-shaped: removed), and
a non-dumpable child standing in a tree, which is kept. The existing
sandbox and report cases now age every file, not only the directory,
and the killed sandbox carries pytest's mark.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Document what #170's fixes change in the sweep

The manual's sweep section and --help now say:

- under --yes the register is fetched first, and a failed fetch refuses;
- each repository's fetch pins its refspec;
- other lanes' claims are read wherever #97 keeps them;
- an unreadable lane root, registration list or register refuses;
- --live must name a tree, and a tree this session recorded wants the
  count;
- the new keep rows (hidden edits, nested clones anywhere, clone tags,
  submodule branches, tags and stash, a partial dependents scan) and
  the rescue+prune row;
- untracked files go to the bundle only, unless --push-untracked;
- rescue rather than push onto another's branch, and no remote delete
  while gh answers OPEN;
- the loss plan, the reflog bundle and the self-check, and the stop on
  NOT WRITTEN;
- the LFS hooks, ignored files judged by their own name, scratch kept
  while trees lie under it;
- tmp.* removed only on proof, the bundle: rows that --expire never
  expires, and the exit contract's new 2 and 64.

The --yes switch and its paragraph go in the next commit, with the
switch itself.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Hold the existing cases to the register fetch, the untracked bundle and B5

Three of #170's fixes change what older cases see. A proof run of the
sweep module on CI (the workstation's pytest lock never came free)
failed these seven at the previous head:

- The table case asserted that the WIP rescue pushed the untracked
  new.txt. It now asserts new.txt is not on origin, and that the
  ledger's bundle: row for the dirty tree holds it (A9).
- The four refusal cases and the unreadable-claim case snapshot the
  estate around a refused --yes. --yes now fetches the register first
  (A1), which writes FETCH_HEAD in the workspace repository and nothing
  else, so the workspace is left out of those snapshots.
- The unreadable-record case wrote its record as this session's
  writer. B5 then refused first, with its own reason, so the record is
  written by the earlier session the fixture uses everywhere else.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Walk the whole estate only where a removal deletes a directory

Measured on Eagle, the whole-estate walk A11 asked for is 683,360
directories: 541,236 of them in xFactory alone, mostly spec trees. It
took 25 s warm and 397 s cold, where the gate's dry run took 15 s at
45fa45d. #163's gate would pay that at every lane-end, for nothing a
worktree's removal can break: a worktree's objects are its checkout's,
and the removal leaves them.

The whole walk now runs only where a removal deletes a directory: a
clone the table could take, or --include-scratch. Otherwise the
estate's shape walk is enough, as before. Other lanes' claims (G6)
follow #97's own rungs for every lane: the override, the parent of
every lane's recorded dir in the register, and $PROJECTS_ROOT. Each is
read beside this lane's own root and beside every checkout the shape
walk finds. So they no longer depend on the whole walk. A lane cannot
claim a tree without a register row.

The G6 case's nested checkout is now a repository, as a lane's is.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Refuse an inventory row that carries no id

#170 G9 (Copilot after the cap, on 87da332). lane_facts skipped a
`lane-trees` row whose id was empty. A tree such a row names outside the
scanned roots was then never discovered, and the dry run could exit 0
and clear #163's gate.

A nonempty row with no id is now an unreadable record. Discovery
refuses it, exit 2, as it refuses one of an unknown schema.

The case gives the inventory one id-less row naming a tree outside both
roots: exit 2, where 45fa45d exits 0.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Fail closed when the bytecode check cannot read the pathspec

#170 G13 (Copilot after the cap, on 45fa45d). bytecode_in_pathspec threw
both git reads' stderr away, and its awk exits 0 on no input. A read
that failed therefore printed nothing: a malformed magic pathspec, or an
index git cannot read, makes both `add --dry-run` and
`diff --cached` exit 128. `pathspec-check` then reported the pathspec
clean, and the commit path let it through.

Each git status is kept now, and the function answers 3 when a read
failed. `add --dry-run`'s exit 1 is not a failure: it means a named
path is ignored, which the add would not stage. `pathspec-check`
refuses with exit 2. The commit path refuses with exit 2 before it
stages anything.

The shell suite's #162 block gains four assertions: `pathspec-check
':(bogus)x'` exits 2 and says the read failed, and a commit of that
pathspec exits 2 and commits nothing. At 45fa45d the first exits 0 and
the commit fails later, at the add, with exit 6.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Document G9's id-less row and G13's failed read

The manual's inventory paragraph now names a row with no id among the
unreadable records that refuse a sweep. The pathspec-check usage line,
and the comment above the subcommand, now say exit 2 also covers a read
git could not make.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Read a .git file that is no pointer as no repository, not as unreadable

The read-only dry run over this lane's estate on Eagle kept every
--include-scratch directory as "the dependents scan was partial". The
cause was two empty .git files that uv keeps in its caches to stop git
looking upward. git_common_dir answers '' for those as it does for an
unreadable .git, and dependents_map counted both as unread.

A .git file that can be read and is no gitdir pointer is now skipped
as no repository. Only one that cannot be read leaves the scan partial.

The case puts uv's marker in the estate. A clone taken on a word is
still removed: the scan is whole.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Switch --yes back on: remove LANE_WORKTREES_ENABLE_YES

5f4bd84 switched --yes and --expire --yes off until #170's data-loss
paths were closed. Every item #170 lists for --yes now has a case that
fails against 45fa45d and passes here: items 1, 2 and 4-8, A1-A11,
B4-B6, G1, G2, G5-G7, G9 and G13. Before every removal the sweep also
asserts, of git itself, that each commit the removal would take is on
origin, in a ref that stays, or in a bundle this run verified. If not,
it refuses with exit 2 and a DISPOSITION.md line.

The switch, its refusal, the --help paragraph and the manual's
blockquote are gone. The suite's estates no longer set the variable.
The switched-off case is replaced by one that runs --yes and
--expire --yes with no variable in the environment.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Refuse a clone's removal when a reflog directory under it cannot be listed

#174 Copilot round 1 (lane-worktrees `_loss_plan`): the loss plan of a
clone collected its reflogs with `os.walk`, which passes over a directory
it cannot list in silence. A commit only `logs/refs/heads/<b>` named was
then in no plan: no bundle took it, the self-check asked the same blind
question, and the clone was deleted with it.

`reflog_files` walks `<gitdir>/logs` with an error handler: a `logs`
directory that is not there is an empty answer, anything else it cannot
list makes the loss plan unknown, and the clone is left in place.

The case seals a clone's `logs/refs/heads` (mode 000) with an experiment
only that branch reflog names, and wants the clone and the commit kept.

Lane: openRepoTools-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Keep a tree whose submodule names an unpublished commit only in its reflog

#174 Copilot round 1 (lane-worktrees `tree_guards`): a submodule's
experiment, made detached and checked out away from, is in no branch, tag
or stash of the submodule - only its reflog names it. Every submodule guard
passed, and the tree's removal took the submodule's repository, which lives
under the tree's own git directory, with the experiment in it.

The submodule's reflogs are read now (`unpublished_reflog`, through
`reflog_files`, so a directory it cannot list is unknown too): any commit
they name that no remote of the submodule holds keeps the tree, and says so.

Lane: openRepoTools-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Archive every ignored entry selected, whatever its ancestors are named

#174 Copilot round 1 (lane-worktrees `_tar`): #170 A6 selects an ignored
entry by its own name, so `docker/node_modules/prod.env` - an ignored file
in a tracked directory - is selected for the archive. The archive's member
filter then dropped any path with a cache- or venv-named part anywhere in
it, `top.env` beside it kept the archive non-empty, it verified, and the
tree was removed without prod.env.

The filter now judges only the parts of a member's path BENEATH the entry
it was added for, and always carries the entry itself; and the archive is
read back for every entry selected, so one missing leaves the tree.

Lane: openRepoTools-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Never remove a cache directory that holds a repository

#174 Copilot round 1 (lane-worktrees `_caches`): a tree kept because a
clone is nested in its venv (`pip install -e git+...` clones into
`<venv>/src/<pkg>`, #170 A3) still gave up its caches, and `.venv` is one.
`--include-caches --yes` removed it, and the clone and its unpushed fix
with it.

A cache candidate that is a repository, holds one anywhere inside, or
holds a directory that cannot be read is now a `keep` row when the table is
built, and asked again right before the removal. The venv case of A3 runs
`--include-caches --yes` too and wants the clone's commit kept.

Lane: openRepoTools-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* List an unmarked tmp.* that holds a repository, whatever its age

#174 (found auditing that a check guards every removal): `--include-
sandboxes` removed an unmarked `tmp.*` untouched for `aging_days` on age
alone - the second half of #170 item 1's default - so a person's `mktemp -d`
checkout with an unpushed commit in it went. No suite's mark says such a
directory's repositories are fixtures, so one that holds a repository, or
a directory that cannot be read, is listed and never removed; the check is
asked again right before the removal. A marked one is still the suite's,
and its repositories are its fixtures.

Lane: openRepoTools-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Bundle a branch's reflog-only commits and self-check before --branches deletes it

#174 Copilot round 1 (lane-worktrees `_act_item`): the loss plan, the
bundle and the self-check guarded a tree's branch delete only. With
`--branches --yes` a merged branch no worktree holds was deleted with
`update-ref -d`, which takes its reflog too - the last pointer to an
experiment committed on it and reset away from.

A branch item now asks what the delete would take (its tip and every
commit its reflog names, against origin, the other branches, tags, the
stash, this run's pushes and bundles), bundles what nothing keeps, with a
`bundle:` ledger row, and asks once more right before the delete. A refusal
there stops the sweep, exit 2, and DISPOSITION.md says so, as it does for a
tree; a refused item is no longer counted in the register's "swept branches"
line. The bundle helpers take a repository and a name instead of a tree.

Lane: openRepoTools-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Hold back untracked files by the act's own snapshots, and keep untracked git-lfs content

Two #174 Copilot round 1 findings in the WIP rescue (lane-worktrees
`_wip_rescue`), both about what goes to a bundle only (#170 A9).

Whether untracked files were held back was read from the table's status,
taken minutes earlier. A tree with only a tracked change when it was read,
and an untracked key file by the time of the rescue, had its full
snapshot - key included - pushed to origin. The pushed snapshot is now
always the tracked-only one (unless `--push-untracked`), and what the full
snapshot holds beyond it is what goes to the bundle alone.

An untracked file git-lfs filters is snapshotted as a POINTER: its bytes
go to the local LFS store, which no bundle carries and the removal may
take, so the bundle that was its only copy held no payload. Where git-lfs
is configured, such a tree is now `keep` - in the table, and again at the
act before anything is pushed (a `_Keep` found at the act leaves the tree
as the table would have).

The cases make the file arrive between the table and the act with a `git`
that writes it on the hidden-edit guard's second call.

Lane: openRepoTools-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Read a clone's annotated tag through its peeled commit, and bundle the tag object only origin lacks

#174 Copilot round 1 (lane-worktrees `lost_tips`, `_loss_plan`): a
clone's loss plan read every ref's raw `%(objectname)`, so an annotated
tag arrived as its tag object. `lost_tips` reported any object that was no
commit as lost whatever kept it - so the tag was bundled, then the
self-check reported it lost again, refused the removal and halted the
sweep, for every clone with an annotated tag.

A tag object is now kept where a SHA in the keep list names it - a
verified bundle's head, or origin's own copy of that very tag object,
read with `ls-remote --tags` (none when origin cannot be asked, so the tag
is bundled) - and its history is its peeled commit's, asked like any other
commit. A SHA in the keep list counts through the commit it peels to.

Lane: openRepoTools-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Document what #174's first Copilot round changes in the sweep

The manual's table and the command's own help now say that a submodule's
reflog-only commit keeps its tree, that untracked git-lfs content keeps
its tree and untracked files are read from the act's own snapshots, that
a clone's reflog directory that cannot be listed keeps the clone and its
annotated tags are bundled where origin lacks that very tag object, that
the ignored archive carries every entry selected whatever its ancestors
are named, that a `--branches` delete has its own loss plan, bundle and
self-check, and that neither a cache nor an unmarked `tmp.*` sandbox that
holds a repository is ever removed.

Lane: openRepoTools-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Keep a tree whose git directory keeps a submodule repository with work no remote of it holds, a deinitialized one's included

#174 Copilot round 2 (lane-worktrees `tree_guards`): the submodule
guards read only what `git submodule status` lists as checked out. A
DEINITIALIZED submodule shows `-`, its working tree is gone, and its
repository - branches, a stash, reflog entries - stays under
`<gitdir>/modules/<name>`, which the tree's removal takes. A branch no
remote held went with the tree.

Every repository kept under the tree's git directory's `modules/`
(nested ones included) is now read: a branch, tag or HEAD no remote of it
holds, a stash (read as its ref, since `git stash list` wants a working
tree) or a reflog entry no remote holds keeps the tree, and so does a
`modules/` directory that cannot be read.

Lane: openRepoTools-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Keep a tree whose submodule has a skip-worktree or assume-unchanged edit that git status hides

#174 Copilot round 2 (lane-worktrees `tree_guards`): #170 A2's
hidden-edit guard read the superproject only. A file flagged
skip-worktree or assume-unchanged in a submodule and edited there reads
as clean in that submodule exactly as in the superproject, no rescue
carries it, and it went with the tree. The same `hidden_edits` read now
runs in every checked-out submodule, and flags that cannot be read keep
the tree too.

Lane: openRepoTools-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Pass over nothing but .git when proving a removal takes no nested repository

#174 Copilot round 2 (lane-worktrees `nested_repos`): the walk skipped
directories named `__pycache__`, `.pytest_cache`, `.mypy_cache` and
`.ruff_cache`. It is the proof that a removal takes no repository, so a
checkout under a directory with one of those names was missed: a scratch
holding one was archived without it (the archive leaves caches out) and
removed. NESTED_SKIP is gone and every directory but `.git` is entered.

Lane: openRepoTools-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Read another lane's claims in every .lane-state the whole-estate walk finds

#174 Copilot round 2 (lane-worktrees `Sweep.gather`): where the whole
estate is walked - a clone the table could take, or `--include-scratch` -
`walk_estate` finds every `.lane-state`, one in a plain directory inside
a repository included (`host/vendor/.lane-state`), but the sweep threw
that list away and read claims only beside the shape walk's checkouts and
the register's recorded directories. With no log naming that place, a
clone another lane claimed from there was removed. The walk's control
roots are now read for claims as well, before liveness and the table.

Lane: openRepoTools-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Never push a lane's commits onto a branch gh still answers OPEN, whatever a LANDED line says

#174 Copilot round 2 (lane-worktrees `MergeEvidence.judge`, `_decide`):
a register LANDED line naming a pull request gh still answered OPEN, with
the local tip ahead of the PR's head, made the verdict "moved". That
verdict dropped gh's OPEN answer, so #170 A7's rule never fired and
push+remove put the lane's unreviewed commits onto the open pull
request's branch. The moved and merged-elsewhere verdicts now carry gh's
OPEN numbers, and a branch gh answers OPEN goes to a rescue branch, with
origin's branch left as it is.

Lane: openRepoTools-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Never prune a gone worktree's registration whose git directory keeps a submodule repository with work

#174 Copilot round 2 (lane-worktrees `_decide`, `_act_prune`): a
registration whose directory is gone still keeps its submodules'
repositories under `<admin>/modules/`, and the prune - which read only
the superproject's HEAD and reflog - removed them, a branch no remote held
with them. The same submodule-repository read as the tree guard now keeps
such a registration (`keep`), and is asked again right before the prune.

Lane: openRepoTools-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Keep a clone with a local git-lfs store when its commits would go to a bundle only

#174 Copilot round 2 (lane-worktrees `_act_tree`): a clean clone with a
commit only its reflog named had that commit bundled and was removed with
`.git/lfs/objects`. A bundle carries LFS pointers, never their bytes, and
no push uploaded them, so the bytes behind those pointers were lost. A
CLONE whose local LFS store holds anything (or cannot be read) is now kept
wherever a bundle would be the only copy of a commit - the `bundle+remove`
disposition and the reflog-only commits of step 2b alike.

Lane: openRepoTools-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Count a suite's .lock or run.sh marker as provenance only when it names a pid

#174 Copilot round 2 (lane-worktrees `sandbox_provenance`): an EMPTY or
malformed `.lock` (or `.openrepotools-run`) counted as a suite's mark,
so a person's two-hour-old `tmp.*` with a checkout in it was removed -
past coordinator default 1's 14-day rule and the repository guard both. A
mark now proves a suite made the directory only when it names a pid; the
run-root layout proof (`basetemp/` beside `tmp/`) is unchanged.

Lane: openRepoTools-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Document what #174's second Copilot round changes in the sweep

The manual's table and the command's own help now say that every
submodule repository a tree's or a gone registration's git directory keeps
- a deinitialized one's included - keeps it where it holds work no remote
of it holds, that a submodule's hidden edits keep the tree, that a
repository under a cache-named directory is still found, that the
whole-estate walk's `.lane-state` finds are read for claims, that gh's
OPEN wins over a LANDED line, that a clone's local git-lfs store keeps it
where a bundle would be a commit's only copy, and that a suite's mark must
name a pid.

Lane: openRepoTools-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Read a submodule repository kept under a git directory as that git directory alone, so a gone worktree's is read rather than refused

A submodule repository under `<gitdir>/modules/` names its working tree in
`core.worktree`. Where that directory is gone - every registration whose
worktree directory went, and a submodule removed after its deinit - every
git command run in the repository dies on "cannot chdir", so the guards
of this round's first and sixth commits read every such repository as
unreadable: a gone worktree with any submodule was kept for that reason
alone, never read. The proof run on the round's head showed it (the
prune's reason said the branches "could not be read" where the test
expected the unpublished branch named).

The submodule-repository reads now run each git command there with the
repository's own `objects/` as its working tree (`GIT_WORK_TREE`, through
`git_env(path)`); they are reads that need none - refs, reflogs,
rev-list, cat-file - and a branch no remote holds is named again.

Lane: openRepoTools-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Keep a tree or registration whose submodule repository has an annotated tag object no remote of it holds

#174 Copilot round 2 (lane-worktrees `module_repos_why`, submodule
guards): `unpublished_ref` asks whether an annotated tag's COMMIT is
published, never its tag object, so a submodule's local annotated tag on
a published commit passed every guard, and its message, which nothing
else held, went with the tree. A clone's own tags have been bundled since
round 1, but a submodule's are in no loss plan.

At the act, before anything is rescued, every submodule repository the
tree's (or a gone registration's) git directory keeps is asked: each
annotated tag object must be answered by some remote of it in
`ls-remote --tags` as that very object, else the tree is kept, and so it
is where no remote could be asked. It asks remotes, so the dry run, which
asks none, still reads `remove`.

Lane: openRepoTools-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Read the gone worktree's kept submodule repository in its regression the way the sweep reads it

The proof run on the round's head passed every assertion of
`test_a_gone_worktrees_kept_submodule_repository_is_never_pruned` about
the sweep - the registration kept, the reason naming the unpublished
branch - and then failed …
brettheap added a commit that referenced this pull request Oct 7, 2026
…e's trees, branches, scratch, caches or residue, --inventory-only as the logged door, and lane-worktrees add records every tree it makes (#163) (#175)

* Add lane-worktrees: the sweep that retires a lane's abandoned worktrees

A swap that does not finish gracefully leaves its writers' trees where
they stood, and nothing removed them: a person archived, verified and
removed them by hand. `lane-worktrees sweep <lane>` makes that one act,
dry run by default, under one rule: nothing is deleted that is not
first on origin or in a bundle under the sweeps directory, and a live
writer's tree is never touched.

Which trees are the lane's is #97's inventory and the disk, never the
derived index (Amendment 14(b)); a tree the inventory does not name is
FOREIGN and is left unless --include-foreign and a --word, and one
another lane's inventory names is never taken. Who may act is #97's
reconciliation, read before any write including the fetch: a lane bound
elsewhere, held by another live session, managed-owned or unreadable is
refused (exit 2); a lane this session holds acts only on the writer
count the coordinator states with --live.

"Merged" is the register's LANDED line for the branch's PR or gh's
MERGED for it, never ancestry alone. Unpublished commits are pushed
under the branch's own name, never its upstream's (a branch made from
origin/main tracks main), or to rescue/<lane>/<slice>-<UTC> where
origin diverged; dirty work becomes a WIP commit built through a copy
of the index, so a refused push leaves the tree exactly as it was.
Removal re-proves the head and the content at the moment it happens.

Also --branches, --include-scratch, --include-caches,
--include-sandboxes, --links, alternates and local-remote detection
(LOAD-BEARING clones are never removed), sweep --expire with 90-day
retention that never expires an archive whose rescue left origin, and
the porcelain contract lane-end's gate (#163) reads: 0 nothing to
retire, 3 something to retire, 2 refused.

Part of #162.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Test the sweep against every row of #162's disposition table

tests/test_lane_worktrees.py builds a lane's estate under tmp_path: a
bare origin reached through a url.insteadOf for a GitHub-shaped URL, the
lane's checkout and both worktree roots, and fakes for lanes-edit.sh,
gh and tmux. One lane holds a tree in every state, and the dry run is
held to the table row for row and to a whole-estate snapshot that does
not move. The same lane under --yes is held to every act: pushes,
rescue branches seen on origin, the WIP commit's subject and parent,
the bundles, the ignored-file archive without bytecode, a manifest
that verifies, and one register line per tree.

Also: a refused push leaves the dirty tree byte for byte; a live writer
(a process's cwd, a tmux pane) is never touched; this session's --yes
needs its writer count; bound elsewhere, held elsewhere and unreadable
are refused with 2 and change nothing; merged by register and by gh
against a branch on main by ancestry alone; no gh, nothing merged;
--include-foreign takes a word and never another lane's tree;
--branches; scratch, caches and sandboxes; --links; a LOAD-BEARING
clone; --expire at 89/90/120 days; the porcelain exit codes; and two
cases on the REAL lanes-edit.sh, for the inventory, the register line
and a lane bound on another host.

Part of #162.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Place lane-worktrees as the seventeenth installed file

`openRepoTools --install` places `lane-worktrees` at the end of
INSTALLABLES, so every index a test takes still names the file it did.
The file count moves 16 -> 17 and the artifact count 30 -> 31 wherever
they are stated, with the count history extended rather than restated;
the receipt sentence now says 31 artifacts, 29 rows. --help names the
new command.

The hygiene suite compiles `lane-worktrees` beside `lanes-index`: the
two shipped commands that are Python and have no .py suffix for the
glob to find.

Part of #162.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Document the sweep in the lanes manual

"Retiring a lane's worktrees": the rule, which trees are the lane's and
who may act, the disposition table as implemented in the order it is
decided, the other rows (--branches, scratch, caches, sandboxes, links,
bundles), the sweeps directory and its manifest, the one register line
per tree, retention and sweep.conf, the porcelain exit contract for
lane-end's gate, and the two protocol lines the act assumes, proposed
for the amendment that ratifies it.

Part of #162.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Walk the estate for --links with scandir

`os.walk` lstat()s every entry, and the estate on Eagle is tens of
thousands of directories: a read-only `--links` dry run took 245 s.
A scandir walk reads each entry's kind from the directory read itself,
so only a symlink or a `.git` file costs a call of its own. Measured
on the same estate: 16.7 s, with the same 403 broken links found (99
of them worktree gitdir pointers).

Part of #162.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Keep a test run's bytecode, cache and temp out of the worktree

A suite run left tests/__pycache__, .pytest_cache and, when killed, its
sandboxes in whichever worktree ran it; the estate cleanup found those
were 968 of 1,000 removals (#162, causes 3 and 4). tests/run.sh now
sends bytecode to ${XDG_CACHE_HOME:-~/.cache}/openRepoTools/pycache,
turns pytest's cache off, and roots --basetemp and TMPDIR under one run
root in ${XDG_STATE_HOME:-~/.local/state}/openRepoTools/tmp/<UTC>-<pid>/
that an EXIT trap removes however the run ends.

The suite now runs in the background and is waited for: bash runs a trap
only once its foreground child returns, so a TERM used to wait out the
whole suite. The INT and TERM handlers stop the suite, then exit, so the
EXIT trap removes the run root and, on the mkdir path, the lock. The
lock is computed before TMPDIR moves, so it stays the workstation's.
The repository venv is used when it has pytest, first on PATH so the
command line still reads `python3 -m pytest`.

tests/test_run_wrapper.py proves it against a stub suite: the
relocation, the run root gone after a pass, a failure, a TERM and an
INT, under flock and under the mkdir lock, and the venv.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Name the repository's virtual environment on --install

One virtual environment per repository, outside the estate, is the
convention the sweep's --include-caches row assumes (#162, cause 3): a
venv/ inside a worktree is a leftover to remove. --install now names
this repository's, ${XDG_CACHE_HOME:-~/.cache}/openRepoTools/venvs/
openRepoTools, and says whether it is there; when it is not, it prints
the two commands that make it. It never makes one: that needs pip and
the network, and an install from a checkout needs neither.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Seed the workspace .gitignore with bytecode and cache rules

Cause 19 of the cleanup analysis: a handoff's attachments were committed
with a whole virtualenv's __pycache__ inside them, and brett-wip carries
703 bytecode paths in its history. `wip init` now adds __pycache__/,
*.pyc, *.pyo, .pytest_cache/, .mypy_cache/, .ruff_cache/, node_modules/,
.venv/ and venv/ to the seeded .gitignore, in wip_substitute - the one
function both step-7 paths go through - so the bytes a seed writes and
the bytes a re-run compares are the same. A line the template already
carries is not repeated, so a template that adopts them upstream seeds
them once.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Refuse a workspace commit whose pathspec carries bytecode

The .gitignore lines keep a new workspace clean; an older one without
them still stages whatever a pathspec names. commit_push now asks git
what its pathspec would stage (git add --dry-run, which honours
.gitignore exactly as the real add does) and refuses, exit 2, nothing
staged, when any path has a __pycache__, cache, node_modules, venv or
site-packages component or is *.py[co] - and offers the .gitignore
lines that workspace lacks, with the one command that adds them.

Attachments are committed by hand, so the same question is a
subcommand: `lanes-edit.sh pathspec-check <path>...` answers 0 clean,
2 with the offending paths on stdout and the offer on stderr, 64 usage.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Run the estate report once a day from lane-start

The report is the net under every actor that never runs lane-end, and
it only works if it is read every day. lane-start now runs
`lane-worktrees sweep --all --dry-run --report` once per UTC day per
workstation, after the row is written and before the launch: the first
start of the day takes report-<YYYYMMDD>.stamp under the state
directory with an atomic `set -C` create, removes older stamps, and
starts the report detached, stdin, stdout and stderr closed, writing
reports/<UTC>.md. Every step either works or is skipped in silence, so
the report never delays a start and never fails one. --dry-run starts
none; LANE_WORKTREES_REPORT=off is the switch, and the suite sets it.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Report the estate's leftovers with sweep --all --dry-run --report

Workspace creation outpaces closeout, and nothing counted it. The
report reads every lane's #97 inventory and snapshot (beside each
checkout's parent, where #97 keeps them), the workspace register and
the disk - never the derived index - and lists, as one markdown
document: FOREIGN clones with size, last commit and Lane: owner;
orphaned trees of ENDED lanes; unmerged branches with a missing,
diverged or unpushed upstream; root-main divergence, with Amendment
4's remedy where only handoff/register paths moved; rescue branches
and dirty inventory trees awaiting disposition past aging_days; caches
and sandboxes by size; ignored directories over ignored_report_mb;
evidence-shaped paths; archives past retention (--expire's own table,
now shared as expiry_rows); the workspace's .gitignore and bytecode
history; and `status --all`'s findings, reported as what they are and
never counted as dirt. The head table carries the rescue-branch count
and the sweeps directory's size.

It changes nothing: no fetch, no index refresh, no expiry. --post
writes it to a file or comments it on owner/repo#n through gh.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Document the estate report and prevention at creation

The lanes manual gains the report (its sections, --post, the daily run
from lane-start and its switch) and what keeps leftovers from arriving:
the run.sh relocation, one venv per repository outside the estate, one
evidence root per repository under the state directory, and the
workspace's bytecode rules with lanes-edit.sh's refusal and
pathspec-check.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Take Copilot round 1's defects in the sweep

Every one of these let a destructive act rest on a read that was stale,
failed, or answered a different question:

- Merged now needs the PR's base to be the default branch (origin's HEAD,
  else main/master): a merge into a release branch is not a landing. An
  OPEN PR protects its branch before any older merged PR on that branch
  counts, unless the register LANDED that very PR.
- A failed `rev-list` distance is a read error, never "0 ahead", for a
  tree and for --branches' upstream state alike.
- A clone whose git directory linked worktrees share is kept. Removing it
  would take their repository with it.
- A tree that another lane's inventory also names is kept. An inventory
  record that cannot be read refuses the sweep (exit 2) instead of being
  skipped. The lane name goes through `canon-lane` before any path is
  derived from it, and an unreadable alias table refuses.
- Liveness is asked again before the rescue and again just before
  removal, afresh (processes, tmux, the recording session). A scan that
  cannot be made leaves the tree. Scratch is removed only if no writer
  arrived and nothing outside its caches changed while the tar ran. A
  cache is rechecked against its owning tree.
- Caches never come from a FOREIGN tree, a live one, or one whose
  liveness is unknown.
- Branches are deleted at the SHA that was judged: `update-ref -d <old>`
  locally, a --force-with-lease push for the remote. Each failure is
  counted, and the register claims "+ remote" only for a remote delete
  that happened.
- --branches fetches the lane's own checkout too, and a failed fetch
  deletes nothing.
- A stale registration is removed by `git worktree remove <path>` alone,
  never by a repository-wide prune.
- An ignored-file listing that failed stops the act. It is never read as
  "nothing ignored".
- Each invocation gets its own archive directory, created exclusively.
- An origin-less worktree under --bundle --yes is bundled and removed,
  as its dry run says, instead of being read as a failed fetch.
- --expire requires the rescued SHA itself on origin and an archive that
  is whole: a MANIFEST.sha256 listing every file at its digest, and a
  rescues.tsv whose rows parse.

Ten new or extended cases. Each one fails against the previous head and
passes here.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Document round 1's rules in the lanes manual

The manual now states what changed: the canonical lane name, refusal on
an unreadable record, contested trees, the single-registration prune,
the linked-worktree clone guard, merged-into-default with open PRs first,
SHA-fenced branch deletes, liveness asked again before removal, scratch
and cache rechecks, the exclusive archive directory, and expiry of whole
archives only.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Say what expiry_rows keeps now that #168 checks whole archives

The merge from #168 brought in archive_ledger and the exact-SHA check.
The report's archive section reads them through expiry_rows, so its
docstring now says it keeps archives that are not whole and those whose
rescue branch moved.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Stop the suite's whole process group when a run ends

Copilot on #169: a TERM to the pytest pid alone leaves whatever it is
waiting on (a shell suite, a git, a fixture's sleep) running, while the
EXIT trap deletes its temp root and releases the mkdir lock around it.
The suite now starts in a process group of its own, with `set -m` on for
that one line only. The INT/TERM handlers and the EXIT trap TERM the
whole group, reap the leader, wait up to ten seconds for running members
and then KILL the group. Running members are counted from `ps`, never
`kill -0`, because an orphan's zombie answers `kill -0` until whoever
adopted it reaps it.

The kill cases now give the stub suite a child of its own and require
it to be gone. Against the previous run.sh that case fails with "the
suite's own child outlived its wrapper".

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Offer and seed site-packages/ with the other bytecode rules

Copilot on #169: the refusal classifies any path under a site-packages
directory, since that is a virtual environment under any name, but
neither the offered lines nor the seeded ones covered it. Following the
offer therefore left the refusal standing. `site-packages/` now joins
BYTECODE_IGNORES and WIP_HYGIENE_LINES. The shell case adds a venv
named env-x: it is refused, `site-packages/` is among the lines offered,
and it is still refused until that line is added.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Report duplicate clones with no named checkout, over one estate

Copilot on #169, two report defects:

- Two clones of one origin, neither named for the repository, were both
  treated as canonical, so the duplicate finding vanished. The checkout
  is now chosen deterministically (the one named for the repository,
  else the shallowest), and every other clone is reported, with a note
  when the choice was ambiguous.
- `status --all` was pointed at the estate only when --estate was given.
  It now always gets the root the report resolved, and lane-start passes
  its own $PROJECTS_ROOT to the daily run.

The report's hygiene check wants site-packages/ too. Each new assertion
fails against the previous head.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Take Copilot round 2's defects in the sweep

Seven of round 2's eight. Each one let an act proceed on an unknown:

- Another lane's inventory record or directory that cannot be read, or
  that names no path, now refuses the sweep. Who else claims a tree is
  read before the fetch, so the refusal writes nothing.
- A submodule's ignored files (an .env) keep the tree. The tree's
  ignored archive covers the superproject only.
- Ignored files are printed before the archive and listed again at
  removal. A change, an addition or a failed listing leaves the tree.
- A prune candidate whose directory reappeared is left for the next
  sweep to classify.
- A pytest sandbox's .lock is read again at the act, and a live pid
  leaves it.
- `tracked()` returns None when a repository's index cannot be read,
  and such a cache is left.
- A manifest entry whose file is gone makes the archive not whole.

The eighth, unreadable /proc entries of same-account processes, is a
design trade and is filed in #170. On Eagle, 9 such processes exist at
any time (6 `timeout`, 3 `ssh-agent`), so reading them as "unknown"
would keep every tree on every sweep.

Four new or extended cases. Each fails against ae17742 and passes here.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Refuse bytecode that is already staged, not only what add would stage

Copilot round 2 on #169: `git add --dry-run` says nothing about a path
the index already holds at those bytes, yet the path-limited commit
still takes it. bytecode_in_pathspec now also reads `git diff --cached
--name-only --diff-filter=d` for the same pathspec. A staged deletion of
bytecode is a cleanup and is let through. The shell case force-stages a
.pyc after the ignore lines are in place: pathspec-check and the commit
path both refuse it, and nothing is committed.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Quote the venv paths in the command --install prints

Copilot round 2 on #169: the command is meant to be pasted into a
shell, and $XDG_CACHE_HOME is the person's to choose, spaces included.
Both paths are now `printf %q`-quoted. The new case installs with a
cache directory containing a space, and shlex reads each path back as
one word.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Report what the report could not read

Copilot round 2 on #169: an unreadable lane snapshot or inventory
record became an empty one, so a lane or tree dropped out of every
section and the report could look clean. Reads now go through _ls and
_record. A failure other than "not there", a tree record naming no
path, or an inventory tree whose git status fails is a row in a new
section, "Records the report could not read". The unused _sidecar
reader is gone.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Keep AGENTS.md and README.md within their line caps

test_repo_hygiene caps AGENTS.md at 316 lines and README.md at 486, and
both files were exactly at their caps on main. The run.sh paragraph had
taken AGENTS.md to 330 and the venv sentence README.md to 491. The full
text already lives in docs/README-lanes.md, so AGENTS.md now says the
same thing in the three lines the old sentence took, and README.md says
it on the line it extends. No cap is raised.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Assert the flock file only where there is flock

Copilot on #169: macOS has no flock, so the wrapper takes the mkdir lock
and never creates openrepotools-pytest.lock. The relocation case checked
for that file unconditionally and would have failed the macOS job, which
is the landing gate. Where there is no flock, the case now checks
instead that the mkdir lock was released.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Switch --yes off until #170; keep the gate and exit contract honest

The adversarial review of 3c0b188, reproduced with its probes against
the suite's own Estate fixture:

1. --yes and --expire --yes are refused, exit 2, changing nothing,
   unless LANE_WORKTREES_ENABLE_YES=1 is set. #170 lists data-loss paths
   that are still open. The suite's Estate sets the variable; a real
   estate should not until #170 lands. The dry run, --porcelain and
   --report are untouched.
2. B1: a tree that #97's inventory does not name is still the lane's if
   it stands under .lane-worktrees/<lane>/, or if it sits in
   <checkout>/.claude/worktrees on a branch whose own commits carry this
   lane's Lane: trailer. Another lane's claim still wins. Such trees keep
   the quiet-hours liveness rule. A lane whose state is NONE but which
   has trees of its own is refused, exit 2. On Eagle, `sweep
   openRepoTools-3 --dry-run --porcelain` gave exit 0, `summary 0 15 0
   15`. It now gives exit 2, `summary 9 13 4 4`: 9 trees are the lane's,
   and the snapshot is NONE.
3. B2: subprocess output and git metadata files are decoded with
   surrogateescape, and stdout and stderr write with it too, so a
   Latin-1 worktree name is reported rather than raising. An unreadable
   pytest-of-$USER is a kept sandbox row. A catch-all keeps errors that
   no read caught inside the contract: exit 2 on a dry run, and under
   --yes DISPOSITION.md is written first and the exit is 1.
4. B3: every porcelain field escapes backslash, TAB, newline and CR.
   Worktree registrations are read with `git worktree list -z` where git
   has it, so a newline in a path no longer becomes a phantom
   registration.

Five new cases (switch off, ownership plus NONE, escaping, non-UTF-8
path, unreadable sandbox root), each failing against 3c0b188. Two cases
were moved off the lane root to keep testing FOREIGN trees. 40 cases.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Document the --yes switch, lane-root ownership and porcelain escaping

The manual now leads the sweep section with the --yes switch and #170.
It also says which unrecorded trees are a lane's and that a NONE snapshot
with trees is refused. The exit contract now covers the escaped fields
and the catch-all.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Run the suite in the foreground when stdin is a terminal

Adversarial review B7: `set -m` puts the suite in a background process
group with the terminal as its stdin. Anything that reads the terminal
(--pdb, breakpoint(), input()) is then stopped by SIGTTIN, and the
wrapper waits on it for ever while holding the workstation flock. With
a terminal on stdin the suite now runs in the foreground, in the
terminal's own process group, and a Ctrl-C reaches all of it from the
terminal. Without a terminal the process-group stop is unchanged.

The new case runs the wrapper on a pseudo-terminal whose stub suite
prints a prompt and reads a line. It passes here. Against the previous
run.sh it hangs and fails, with the transcript showing the prompt and
the typed line that was never read.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Never adopt a standalone clone under the lane's root

5f4bd84 made every unrecorded tree under .lane-worktrees/<lane>/ the
lane's. That included standalone clones, which #162's first protocol
line and the manual keep FOREIGN ("a lane creates worktrees, never
clones"). Copilot flagged it on 296e2f0. Clones are now excluded from
both adoption paths. The ownership case adds a clone under the lane
root and requires it to stay foreign and not retire-counted. On Eagle
none of the lane's seven root trees is a clone, so the dry run is
unchanged there.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Fetch the register directly under --yes and refuse when it fails

#170 A1. lanes-edit.sh's log_sync answers 0 on every way it can fail to
fetch, and an inherited LANES_NO_FETCH=1 skips the fetch outright. A lane
rebound on another host after this workstation's last register fetch
therefore read as bound here, and --yes removed its trees (Amendment
18(b): from outside the binding a lane is UNKNOWN, never dead).

Under --yes the sweep now fetches the workspace repository's
origin/<branch> itself, with an explicit refspec, before anything else.
A fetch that fails refuses the run, exit 2, with nothing changed. Every
later helper call reads the ref that fetch left, so an inherited
LANES_NO_FETCH no longer decides. The dry run is unchanged.

The test estate now carries a workspace repository (the fetch's target,
and #170 G6's register) and records its inventory under an earlier
session, as a swept lane's trees are. The new case rebinds the lane on
another host after the last fetch, then runs --yes with origin
unreachable and with LANES_NO_FETCH inherited: both refuse and the tree
stays.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Pin the sweep's fetch refspec so --prune cannot delete local branches

#170 item 6 (Copilot round 3 on #168). With a mirror-style
remote.origin.fetch such as +refs/heads/*:refs/heads/*, the preflight
`git fetch --prune origin` deleted every local branch origin lacks,
before anything was classified or rescued.

The fetch now names its refspec and refmap, as `status --fetch` does:
+refs/heads/*:refs/remotes/origin/*, with --refmap set to the same, so
the configured refspec maps nothing. fetch.pruneTags and the remote's
pruneTags are forced off, so a local tag is never pruned with it.

The case configures the mirror refspec with nothing checked out that
origin has (git refuses to fetch into a checked-out branch, which hides
the prune) and a local-only branch and tag. Both survive --yes.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Refuse when a lane root or a registration list cannot be read

#170 G1 and G5 (Copilot after the cap). Discovery read a lane worktree
root that could not be listed as an absent root, and a failed
`git worktree list` as a repository with no worktrees. With an empty
inventory either one let the dry run exit 0 and clear #163's gate over
trees nobody could see.

Only a root that does not exist is skipped now; any other listing
failure refuses, exit 2. worktree_registrations returns None when both
listings fail. Discovery refuses on it. The prune's after-check, a
branch delete and --branches stop that act. The report records the
checkout as unreadable.

Two cases: a mode-000 lane root with an empty inventory, and a git shim
that fails `worktree list`. Both now exit 2.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Walk every estate directory for dependents; a partial scan deletes nothing

#170 A11. The estate walk entered a repository only through worktree
containers, so it never saw a plain directory inside a repository (it
found none of xFactory/xFactories/* on Eagle). A clone there that
borrowed a lane clone's objects was unseen, and the clone was deleted
from under it. An empty estate root read no dependents at all, and an
unreadable directory read as one with nothing in it.

walk_estate visits every directory but caches, tool environments and
site-packages. It never follows a symlink or enters a .git, and it
collects .lane-state directories for #170 G6. Whatever it, or the
alternates and config reads, could not read makes the dependents scan
partial. A partial scan, a missing estate root, or a tree outside the
estate root keeps a clone and a scratch directory. Both are removed by
deleting a directory, and a dependent nobody saw would lose its objects.
Worktrees are untouched by this: their objects live in the checkout's
repository, which a worktree removal leaves.

Two cases: a --shared dependent under host/vendor/ makes the clone
load-bearing, and a mode-000 directory in the estate keeps it.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Read every other lane's control root before granting a tree

#170 G6 (Copilot after the cap). Other lanes' claims were read only
under this lane's control-root parent and the LANES_LANE_STATE_ROOT
override. A lane in a nested estate keeps its .lane-state beside its own
recorded dir, so its claim was missed, the tree was not contested, and
--yes could take it.

The parents read now also include $PROJECTS_ROOT/.lane-state, every
.lane-state the estate walk found, and the parent of every lane's
recorded dir. The recorded dirs come from one `git grep` over the
register's lane logs on origin/<branch>, parsed as lanes-edit.sh's
payload_subfield parses them. A register that cannot be read refuses:
whose claims were missed would be unknown. Lane names compare without
case, as Amendment 15 has them.

The case puts another lane's claim on one of this lane's trees under
<estate>/group/.lane-state, and under a directory outside the estate
that only the register names. Both keep the tree.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Keep trees whose hidden edits, nested clones, tags or submodule refs would go

Four ways tree_guards let a removal take work no rescue carried:

- #170 A2: a file flagged skip-worktree or assume-unchanged reads clean
  in `git status`, and `git add -A` skips it, so its edit was in no
  rescue. hidden_edits hashes every flagged file present in the tree
  against its index blob, and a difference keeps the tree. A flagged
  file that is absent (a sparse checkout's) is no edit.
- #170 A3: the nested-repository walk passed over venvs and node_modules
  before it looked for a .git, so `pip install -e git+...`'s clone in
  <venv>/src/<pkg> was deleted with the tree. nested_repos skips only
  bytecode caches, and a directory it cannot read keeps the tree.
- #170 item 4: a clone's publication check read branches and the
  stash, not tags. unpublished_ref checks every branch, every tag
  (peeled to its commit) and HEAD against refs/remotes/origin in one
  rev-list. A tag that names no commit cannot be checked, and keeps it.
- #170 item 5: only a submodule's HEAD was checked. A worktree's
  submodules keep their repositories under .git/worktrees/<id>/modules/,
  so their branches, tags and stash went with the tree. Each initialized
  submodule now gets the same check against every remote of it, plus
  its stash. A `git submodule status` that fails keeps the tree; it used
  to skip the submodule checks.

Cases: both flags, a sparse checkout's absent file (still removed), a
clone in .venv/src, a clone's annotated tag on a commit no branch has,
and a submodule's unpublished branch and stash.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Judge an ignored entry by its own name, not an ancestor's

#170 A6. ignored_paths dropped an ignored file when any ancestor was
named like a cache or build output. With --directory an ignored cache or
build directory is listed as itself, so a path beneath a directory named
`build` is an ignored file in a tracked directory. docker/build/prod.env
was deleted unarchived while top.env beside it was archived.

Only the entry's own basename is compared with CACHE_NAMES, VENV_NAMES
and BUILD_NAMES now. An ignored /build/ directory is still build output
and is not archived.

The case puts prod.env in the tracked docker/build/ beside an ignored
/build/ and checks the archive holds prod.env and top.env and nothing
of build/.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Leave other people's open branches alone: rescue, and keep the remote

Two ways --yes acted on a branch someone else's pull request owns:

- #170 A7: push+remove pushed the lane's unreviewed commit onto a
  teammate's OPEN PR branch, because the decision ignored the merge
  state. Where an open PR names the branch, where origin's tip carries
  another lane's Lane: trailer, or where whether a PR names it could not
  be read (gh unavailable), the commits now go to
  rescue/<lane>/<slice>-<UTC> and origin's branch is left as it is.
- #170 A8: a register LANDED line beat gh's live OPEN for the same
  number, so a LANDED #21 typed for #20 deleted the remote branch of the
  still-open #21 and closed it. The tree and its local branch still go
  (the work is on origin), but the remote branch is never deleted while
  gh answers OPEN for it. The same holds under --branches.

Cases: the open PR, another lane's trailer and LANES_NO_GITHUB each send
the commit to a rescue branch with origin's branch unmoved, and a wrong
LANDED number leaves the open PR's branch on origin.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Rescue before a prune, bundle what only a reflog names, self-check each removal

Four #170 items that share one mechanism: before a removal the sweep now
asks git which commits it would take and where each one is kept.

- The loss plan. A worktree's removal takes its git directory: its HEAD
  and that HEAD's reflog, plus the branch and its reflog where the
  branch is deleted after it. A pruned registration takes the same,
  read from its git directory. A clone takes every ref but its
  remote-tracking ones, and every reflog. One rev-list says which of
  those commits no origin ref, surviving branch, tag or stash, push
  seen on origin this run, or bundle head of this run reaches.
- A4: `prune` dropped the only pointer to a detached commit. A
  registration whose git directory names such a commit is now
  rescue+prune: a rescue branch pushed where there is an origin, a
  bundle, then that one registration removed.
- A5: commits only a reflog names (an amend, a reset, checking out away
  from a detached commit) were lost on removal and on delete_local_branch.
  They go to a bundle of their own through temporary
  refs/lane-worktrees/* refs, which are deleted once it is verified.
- Item 8: a bundle that is the only copy of what it holds (bundle+remove
  with no origin, the reflog bundle, the untracked bundle below) gets a
  rescues.tsv row (origin `-`, branch `bundle:<file>`). `--expire` reads
  it as "no other copy" and never expires that archive.
- A9: the WIP rescue pushed every untracked, un-ignored file, a service
  account key included. The pushed WIP commit now carries the tracked
  changes only. A second commit holding the untracked files goes to the
  bundle alone, as the ledger's only copy. --push-untracked pushes them
  as before.

THE SELF-CHECK. Right before each removal (and each prune) the same
question is asked once more. If anything the removal would take is
neither on origin nor in a verified bundle, the removal is refused,
DISPOSITION.md says so, nothing after it is acted on, and the exit is 2.
LANE_WORKTREES_SEAM_NO_LOSS_BUNDLE=1 is the suite's seam: it skips the
reflog bundle so the case can prove the self-check stops the loss.

Cases: a pruned detached commit (rescued, bundled), a reflog-only
commit (bundled, ledger row), the self-check with the seam (exit 2,
both trees left, the refusal in DISPOSITION.md), untracked files with
and without a tracked change (never on origin, in the bundle,
temporary refs gone), --push-untracked, and an origin-less
bundle+remove archive surviving `--expire --yes` at retention 0.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Run the push hooks where git-lfs is configured

#170 A10. `git push --no-verify` skips git-lfs's pre-push hook, which is
what uploads LFS objects. A rescued branch therefore reached origin as
pointers only, and the tree, the one copy of the objects, was then
removed.

Where the repository has any filter.lfs.* setting (the global one
included) the push now runs its hooks. A hook that refuses fails the
push and leaves the tree. Without git-lfs, --no-verify stays, so an
unrelated pre-push hook cannot hold a rescue up.

The case installs a pre-push hook that records itself. It runs with
filter.lfs configured and does not run without it.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Keep scratch that holds a tree or a repository

#170 item 7 (Copilot round 3 on #168). A scratch directory was archived
and removed whenever it had no .git of its own, so a worktree or clone
nested beneath it went with the rmtree. A FOREIGN or live tree was not
protected either, and nor was an unpushed commit.

A scratch directory is now kept while any tree of the table lies under
it, or any .git does at any depth (bytecode caches aside). A directory
under it that cannot be read keeps it too. The tree table retires its
own children first, and the scratch goes on a later sweep. The check is
made again at the act and again after the tar.

The case nests a clone with an unpushed commit two levels down in a
scratch directory. --include-scratch --yes keeps the scratch and the
commit.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Check --live paths, want the writer count for own trees, stop on NOT WRITTEN

Three gaps in how --yes takes the coordinator's word and the register's:

- #170 B4: a misspelt --live path was accepted in silence, so the
  writer it was meant to protect was not protected. Each --live path
  must now name a tree of the table (it, or a path inside it), and
  `--live none` stands alone. Anything else is usage, exit 64, decided
  before any repository is fetched.
- #170 B5: a tree this session recorded skips the transcript check,
  because the transcript is this one. --live was demanded only when the
  holder read as this session, so with the holder read as none, --yes
  removed trees this session's own writers could be in. Any inventory
  record whose writer is the caller now demands the count too.
- #170 B6: removals went on after a NOTED line failed. The first line
  the register refuses now stops the sweep. Every later tree and item
  is left as the table found it, with the reason, and the exit stays 1.

Cases: a typo'd --live path and `--live none <path>` exit 64 and touch
nothing; a tree recorded by this session refuses without --live and
goes with --live none; with the register refusing, the first tree goes,
the second stays, and exactly one line was attempted.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Count --branches by origin's own ref, never by upstream or an open PR alone

Two ways `--branches --dry-run --porcelain` gave #163's gate the wrong
answer (Copilot after the cap on #168):

- G2: every OPEN PR's branch was left out of the retire count, even a
  lane-owned one holding commits origin lacks, so the gate read 0. The
  delete protection stays. Such a branch is now counted unless
  refs/remotes/origin/<branch> holds its tip, and a read that failed
  counts it too.
- G7: a lane-owned branch was judged by its configured upstream alone.
  A branch made with `checkout -b X origin/main` tracks main, so once
  pushed under its own name it still read "ahead" and the gate read 3.
  Publication is now checked in origin's ref for the branch's own name
  first, and a branch origin holds that way is not listed. Unknown
  states are still counted.

Cases: an unpushed lane branch named by an open PR makes the dry run
exit 3 and survives --yes; a branch made from origin/main and pushed
as itself makes it exit 0.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Remove a tmp.* only on proof, and read hidden processes as unknown

#170 items 1 and 2 (Copilot on #168), with the coordinator's defaults,
which the PR body states for Brett Heap to overrule:

1. --include-sandboxes removed any account-owned tmp.* over an hour old
   with nobody in it, with no proof a suite made it, so a person's
   `mktemp -d` checkout or saved scratch could go. A tmp.* is now
   removed only with a suite's mark whose pid is gone (pytest's .lock,
   tests/run.sh's new .openrepotools-run marker, or run.sh's run-root
   layout of basetemp/ beside tmp/), or when nothing in it has been
   written for aging_days (14). Age is the newest mtime anywhere inside,
   not the top directory's. Any other tmp.* is a `list` row, kept. A
   marker's pid is read again at the act. tests/run.sh writes its pid
   into each run root it makes.
2. The /proc scan read a same-account process whose entries cannot be
   read (not dumpable) as absent, so its tree could be removed under
   it. Such a process is now in ProcScan.unknown and placed by what can
   be read: absolute paths in its command line, and its parent's
   working directory. A tree, scratch directory, cache owner or sandbox
   it is placed in is of unknown liveness and is kept, at the read and
   again at the act. One placed nowhere (ssh-agent re-parented to init:
   three on Eagle today) holds no tree, so a sweep is not frozen for
   ever. One whose status cannot be read at all could be anywhere. A
   process of another account is never a writer here. The human table
   names every unreadable pid in a note. Uid is read from
   /proc/<pid>/status, because a non-dumpable process's /proc entry is
   owned by root.

Cases: four tmp.* directories (unmarked and two hours old: listed and
kept; twenty days old, pytest-marked and run-root-shaped: removed), and
a non-dumpable child standing in a tree, which is kept. The existing
sandbox and report cases now age every file, not only the directory,
and the killed sandbox carries pytest's mark.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Document what #170's fixes change in the sweep

The manual's sweep section and --help now say:

- under --yes the register is fetched first, and a failed fetch refuses;
- each repository's fetch pins its refspec;
- other lanes' claims are read wherever #97 keeps them;
- an unreadable lane root, registration list or register refuses;
- --live must name a tree, and a tree this session recorded wants the
  count;
- the new keep rows (hidden edits, nested clones anywhere, clone tags,
  submodule branches, tags and stash, a partial dependents scan) and
  the rescue+prune row;
- untracked files go to the bundle only, unless --push-untracked;
- rescue rather than push onto another's branch, and no remote delete
  while gh answers OPEN;
- the loss plan, the reflog bundle and the self-check, and the stop on
  NOT WRITTEN;
- the LFS hooks, ignored files judged by their own name, scratch kept
  while trees lie under it;
- tmp.* removed only on proof, the bundle: rows that --expire never
  expires, and the exit contract's new 2 and 64.

The --yes switch and its paragraph go in the next commit, with the
switch itself.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Hold the existing cases to the register fetch, the untracked bundle and B5

Three of #170's fixes change what older cases see. A proof run of the
sweep module on CI (the workstation's pytest lock never came free)
failed these seven at the previous head:

- The table case asserted that the WIP rescue pushed the untracked
  new.txt. It now asserts new.txt is not on origin, and that the
  ledger's bundle: row for the dirty tree holds it (A9).
- The four refusal cases and the unreadable-claim case snapshot the
  estate around a refused --yes. --yes now fetches the register first
  (A1), which writes FETCH_HEAD in the workspace repository and nothing
  else, so the workspace is left out of those snapshots.
- The unreadable-record case wrote its record as this session's
  writer. B5 then refused first, with its own reason, so the record is
  written by the earlier session the fixture uses everywhere else.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Walk the whole estate only where a removal deletes a directory

Measured on Eagle, the whole-estate walk A11 asked for is 683,360
directories: 541,236 of them in xFactory alone, mostly spec trees. It
took 25 s warm and 397 s cold, where the gate's dry run took 15 s at
45fa45d. #163's gate would pay that at every lane-end, for nothing a
worktree's removal can break: a worktree's objects are its checkout's,
and the removal leaves them.

The whole walk now runs only where a removal deletes a directory: a
clone the table could take, or --include-scratch. Otherwise the
estate's shape walk is enough, as before. Other lanes' claims (G6)
follow #97's own rungs for every lane: the override, the parent of
every lane's recorded dir in the register, and $PROJECTS_ROOT. Each is
read beside this lane's own root and beside every checkout the shape
walk finds. So they no longer depend on the whole walk. A lane cannot
claim a tree without a register row.

The G6 case's nested checkout is now a repository, as a lane's is.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Refuse an inventory row that carries no id

#170 G9 (Copilot after the cap, on 87da332). lane_facts skipped a
`lane-trees` row whose id was empty. A tree such a row names outside the
scanned roots was then never discovered, and the dry run could exit 0
and clear #163's gate.

A nonempty row with no id is now an unreadable record. Discovery
refuses it, exit 2, as it refuses one of an unknown schema.

The case gives the inventory one id-less row naming a tree outside both
roots: exit 2, where 45fa45d exits 0.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Fail closed when the bytecode check cannot read the pathspec

#170 G13 (Copilot after the cap, on 45fa45d). bytecode_in_pathspec threw
both git reads' stderr away, and its awk exits 0 on no input. A read
that failed therefore printed nothing: a malformed magic pathspec, or an
index git cannot read, makes both `add --dry-run` and
`diff --cached` exit 128. `pathspec-check` then reported the pathspec
clean, and the commit path let it through.

Each git status is kept now, and the function answers 3 when a read
failed. `add --dry-run`'s exit 1 is not a failure: it means a named
path is ignored, which the add would not stage. `pathspec-check`
refuses with exit 2. The commit path refuses with exit 2 before it
stages anything.

The shell suite's #162 block gains four assertions: `pathspec-check
':(bogus)x'` exits 2 and says the read failed, and a commit of that
pathspec exits 2 and commits nothing. At 45fa45d the first exits 0 and
the commit fails later, at the add, with exit 6.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Document G9's id-less row and G13's failed read

The manual's inventory paragraph now names a row with no id among the
unreadable records that refuse a sweep. The pathspec-check usage line,
and the comment above the subcommand, now say exit 2 also covers a read
git could not make.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Read a .git file that is no pointer as no repository, not as unreadable

The read-only dry run over this lane's estate on Eagle kept every
--include-scratch directory as "the dependents scan was partial". The
cause was two empty .git files that uv keeps in its caches to stop git
looking upward. git_common_dir answers '' for those as it does for an
unreadable .git, and dependents_map counted both as unread.

A .git file that can be read and is no gitdir pointer is now skipped
as no repository. Only one that cannot be read leaves the scan partial.

The case puts uv's marker in the estate. A clone taken on a word is
still removed: the scan is whole.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Switch --yes back on: remove LANE_WORKTREES_ENABLE_YES

5f4bd84 switched --yes and --expire --yes off until #170's data-loss
paths were closed. Every item #170 lists for --yes now has a case that
fails against 45fa45d and passes here: items 1, 2 and 4-8, A1-A11,
B4-B6, G1, G2, G5-G7, G9 and G13. Before every removal the sweep also
asserts, of git itself, that each commit the removal would take is on
origin, in a ref that stays, or in a bundle this run verified. If not,
it refuses with exit 2 and a DISPOSITION.md line.

The switch, its refusal, the --help paragraph and the manual's
blockquote are gone. The suite's estates no longer set the variable.
The switched-off case is replaced by one that runs --yes and
--expire --yes with no variable in the environment.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Refuse a clone's removal when a reflog directory under it cannot be listed

#174 Copilot round 1 (lane-worktrees `_loss_plan`): the loss plan of a
clone collected its reflogs with `os.walk`, which passes over a directory
it cannot list in silence. A commit only `logs/refs/heads/<b>` named was
then in no plan: no bundle took it, the self-check asked the same blind
question, and the clone was deleted with it.

`reflog_files` walks `<gitdir>/logs` with an error handler: a `logs`
directory that is not there is an empty answer, anything else it cannot
list makes the loss plan unknown, and the clone is left in place.

The case seals a clone's `logs/refs/heads` (mode 000) with an experiment
only that branch reflog names, and wants the clone and the commit kept.

Lane: openRepoTools-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Keep a tree whose submodule names an unpublished commit only in its reflog

#174 Copilot round 1 (lane-worktrees `tree_guards`): a submodule's
experiment, made detached and checked out away from, is in no branch, tag
or stash of the submodule - only its reflog names it. Every submodule guard
passed, and the tree's removal took the submodule's repository, which lives
under the tree's own git directory, with the experiment in it.

The submodule's reflogs are read now (`unpublished_reflog`, through
`reflog_files`, so a directory it cannot list is unknown too): any commit
they name that no remote of the submodule holds keeps the tree, and says so.

Lane: openRepoTools-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Archive every ignored entry selected, whatever its ancestors are named

#174 Copilot round 1 (lane-worktrees `_tar`): #170 A6 selects an ignored
entry by its own name, so `docker/node_modules/prod.env` - an ignored file
in a tracked directory - is selected for the archive. The archive's member
filter then dropped any path with a cache- or venv-named part anywhere in
it, `top.env` beside it kept the archive non-empty, it verified, and the
tree was removed without prod.env.

The filter now judges only the parts of a member's path BENEATH the entry
it was added for, and always carries the entry itself; and the archive is
read back for every entry selected, so one missing leaves the tree.

Lane: openRepoTools-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Never remove a cache directory that holds a repository

#174 Copilot round 1 (lane-worktrees `_caches`): a tree kept because a
clone is nested in its venv (`pip install -e git+...` clones into
`<venv>/src/<pkg>`, #170 A3) still gave up its caches, and `.venv` is one.
`--include-caches --yes` removed it, and the clone and its unpushed fix
with it.

A cache candidate that is a repository, holds one anywhere inside, or
holds a directory that cannot be read is now a `keep` row when the table is
built, and asked again right before the removal. The venv case of A3 runs
`--include-caches --yes` too and wants the clone's commit kept.

Lane: openRepoTools-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* List an unmarked tmp.* that holds a repository, whatever its age

#174 (found auditing that a check guards every removal): `--include-
sandboxes` removed an unmarked `tmp.*` untouched for `aging_days` on age
alone - the second half of #170 item 1's default - so a person's `mktemp -d`
checkout with an unpushed commit in it went. No suite's mark says such a
directory's repositories are fixtures, so one that holds a repository, or
a directory that cannot be read, is listed and never removed; the check is
asked again right before the removal. A marked one is still the suite's,
and its repositories are its fixtures.

Lane: openRepoTools-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Bundle a branch's reflog-only commits and self-check before --branches deletes it

#174 Copilot round 1 (lane-worktrees `_act_item`): the loss plan, the
bundle and the self-check guarded a tree's branch delete only. With
`--branches --yes` a merged branch no worktree holds was deleted with
`update-ref -d`, which takes its reflog too - the last pointer to an
experiment committed on it and reset away from.

A branch item now asks what the delete would take (its tip and every
commit its reflog names, against origin, the other branches, tags, the
stash, this run's pushes and bundles), bundles what nothing keeps, with a
`bundle:` ledger row, and asks once more right before the delete. A refusal
there stops the sweep, exit 2, and DISPOSITION.md says so, as it does for a
tree; a refused item is no longer counted in the register's "swept branches"
line. The bundle helpers take a repository and a name instead of a tree.

Lane: openRepoTools-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Hold back untracked files by the act's own snapshots, and keep untracked git-lfs content

Two #174 Copilot round 1 findings in the WIP rescue (lane-worktrees
`_wip_rescue`), both about what goes to a bundle only (#170 A9).

Whether untracked files were held back was read from the table's status,
taken minutes earlier. A tree with only a tracked change when it was read,
and an untracked key file by the time of the rescue, had its full
snapshot - key included - pushed to origin. The pushed snapshot is now
always the tracked-only one (unless `--push-untracked`), and what the full
snapshot holds beyond it is what goes to the bundle alone.

An untracked file git-lfs filters is snapshotted as a POINTER: its bytes
go to the local LFS store, which no bundle carries and the removal may
take, so the bundle that was its only copy held no payload. Where git-lfs
is configured, such a tree is now `keep` - in the table, and again at the
act before anything is pushed (a `_Keep` found at the act leaves the tree
as the table would have).

The cases make the file arrive between the table and the act with a `git`
that writes it on the hidden-edit guard's second call.

Lane: openRepoTools-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Read a clone's annotated tag through its peeled commit, and bundle the tag object only origin lacks

#174 Copilot round 1 (lane-worktrees `lost_tips`, `_loss_plan`): a
clone's loss plan read every ref's raw `%(objectname)`, so an annotated
tag arrived as its tag object. `lost_tips` reported any object that was no
commit as lost whatever kept it - so the tag was bundled, then the
self-check reported it lost again, refused the removal and halted the
sweep, for every clone with an annotated tag.

A tag object is now kept where a SHA in the keep list names it - a
verified bundle's head, or origin's own copy of that very tag object,
read with `ls-remote --tags` (none when origin cannot be asked, so the tag
is bundled) - and its history is its peeled commit's, asked like any other
commit. A SHA in the keep list counts through the commit it peels to.

Lane: openRepoTools-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Document what #174's first Copilot round changes in the sweep

The manual's table and the command's own help now say that a submodule's
reflog-only commit keeps its tree, that untracked git-lfs content keeps
its tree and untracked files are read from the act's own snapshots, that
a clone's reflog directory that cannot be listed keeps the clone and its
annotated tags are bundled where origin lacks that very tag object, that
the ignored archive carries every entry selected whatever its ancestors
are named, that a `--branches` delete has its own loss plan, bundle and
self-check, and that neither a cache nor an unmarked `tmp.*` sandbox that
holds a repository is ever removed.

Lane: openRepoTools-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* lane-end now refuses to end a lane while #162's sweep still finds its worktrees, branches, scratch, caches or residue on disk (exit 2, naming each and the exact sweep command; a gate that cannot be read is exit 1), with --inventory-only as the one door past it that writes its reason into the row and the ENDED line, and lane-worktrees add makes a lane's worktree and records it in the lane's #97 inventory in the same act, because a lane's inventory was written only at a handoff and lane openRepoTools-3's was empty while nine trees under its root were its own.

The gate reads `lane-worktrees sweep <lane> --branches --include-scratch
--include-caches --dry-run --porcelain` and refuses on 3 and 2, and beside
it reads every tree of the lane's with `git status --porcelain --ignored`
and every entry directly under `.lane-worktrees/<lane>/` that no row names,
so ignored residue counts. `--sweep` is refused by name until #170 switches
`--yes` back on. `--branches` no longer reads a lane directory that is no
repository as a branch read that failed, which held the gate shut for every
lane started outside a checkout.

Lane: openRepoTools-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* lane-worktrees keeps its add verb under its own header ahead of the main section, so the file still reads as utilities, sweep, report, add, then main.

Lane: openRepoTools-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Keep a tree whose git directory keeps a submodule repository with work no remote of it holds, a deinitialized one's included

#174 Copilot round 2 (lane-worktrees `tree_guards`): the submodule
guards read only what `git submodule status` lists as checked out. A
DEINITIALIZED submodule shows `-`, its working tree is gone, and its
repository - branches, a stash, reflog entries - stays under
`<gitdir>/modules/<name>`, which the tree's removal takes. A branch no
remote held went with the tree.

Every repository kept under the tree's git directory's `modules/`
(nested ones included) is now read: a branch, tag or HEAD no remote of it
holds, a stash (read as its ref, since `git stash list` wants a working
tree) or a reflog entry no remote holds keeps the tree, and so does a
`modules/` directory that cannot be read.

Lane: openRepoTools-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Keep a tree whose submodule has a skip-worktree or assume-unchanged edit that git status hides

#174 Copilot round 2 (lane-worktrees `tree_guards`): #170 A2's
hidden-edit guard read the superproject only. A file flagged
skip-worktree or assume-unchanged in a submodule and edited there reads
as clean in that submodule exactly as in the superproject, no rescue
carries it, and it went with the tree. The same `hidden_edits` read now
runs in every checked-out submodule, and flags that cannot be read keep
the tree too.

Lane: openRepoTools-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Pass over nothing but .git when proving a removal takes no nested repository

#174 Copilot round 2 (lane-worktrees `nested_repos`): the walk skipped
directories named `__pycache__`, `.pytest_cache`, `.mypy_cache` and
`.ruff_cache`. It is the proof that a removal takes no repository, so a
checkout under a directory with one of those names was missed: a scratch
holding one was archived without it (the archive leaves caches out) and
removed. NESTED_SKIP is gone and every directory but `.git` is entered.

Lane: openRepoTools-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Read another lane's claims in every .lane-state the whole-estate walk finds

#174 Copilot round 2 (lane-worktrees `Sweep.gather`): where the whole
estate is walked - a clone the table could take, or `--include-scratch` -
`walk_estate` finds every `.lane-state`, one in a plain directory inside
a repository included (`host/vendor/.lane-state`), but the sweep threw
that list away and read claims only beside the shape walk's checkouts and
the register's recorded directories. With no log naming that place, a
clone another lane claimed from there was removed. The walk's control
roots are now read for claims as well, before liveness and the table.

Lane: openRepoTools-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Never push a lane's commits onto a branch gh still answers OPEN, whatever a LANDED line says

#174 Copilot round 2 (lane-worktrees `MergeEvidence.judge`, `_decide`):
a register LANDED line naming a pull request gh still answered OPEN, with
the local tip ahead of the PR's head, made the verdict "moved". That
verdict dropped gh's OPEN answer, so #170 A7's rule never fired and
push+remove put the lane's unreviewed commits onto the open pull
request's branch. The moved and merged-elsewhere verdicts now carry gh's
OPEN numbers, and a branch gh answers OPEN goes to a rescue branch, with
origin's branch left as it is.

Lane: openRepoTools-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Never prune a gone worktree's registration whose git directory keeps a submodule repository with work

#174 Copilot round 2 (lane-worktrees `_decide`, `_act_prune`): a
registration whose directory is gone still keeps its submodules'
repositories under `<admin>/modules/`, and the prune - which read only
the superproject's HEAD and reflog - removed them, a branch no remote held
with them. The same submodule-repository read as the tree guard now keeps
such a registration (`keep`), and is asked again right before the prune.

Lane: openRepoTools-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Keep a clone with a local git-lfs store when its commits would go to a bundle only

#174 Copilot round 2 (lane-worktrees `_act_tree`): a clean clone with a
commit only its reflog named had that commit bundled and was removed with
`.git/lfs/objects`. A bundle carries LFS pointers, never their bytes, and
no push uploaded them, so the bytes behind those pointers were lost. A
CLONE whose local LFS store holds anything (or cannot be read) is now kept
wherever a bundle would be the only copy of a commit - the `bundle+remove`
disposition and the reflog-only commits of step 2b alike.

Lane: openRepoTools-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Count a suite's .lock or run.sh marker as provenance only when it names a pid

#174 Copilot round 2 (lane-worktrees `sandbox_provenance`): an EMPTY or
malformed `.lock` (or `.openrepotools-run`) counted as a suite's mark,
so a person's two-hour-old `tmp.*` with a checkout in it was removed -
past coordinator default 1's 14-day rule and the repository guard both. A
mark now proves a suite made the directory only when it names a pid; the
run-root layout proof (`basetemp/` beside `tmp/`) is unchanged.

Lane: openRepoTools-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Document what #174's second Copilot round changes in the sweep

The manual's table and the command's own help now say that every
submodule repository a tree's or a gone registration's git directory keeps
- a deinitialized one's included - keeps it where it holds work no remote
of it holds, that a submodule's hidden edits keep the tree, that a
repository under a cache-named directory is still found, that the
whole-estate walk's `.lane-state` finds are read for claims, that gh's
OPEN wins over a LANDED line, that a clone's local git-lfs store keeps it
where a bundle would be a commit's only copy, and that a suite's mark must
name a pid.

Lane: openRepoTools-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Read a submodule repository kept under a git directory as that git directory alone, so a gone worktree's is read rather than refused

A submodule repository under `<gitdir>/modules/` names its working tree in
`core.worktree`. Where that directory is gone - every registration whose
worktree directory went, and a submodule removed after its deinit - every
git command run in the repository dies on "cannot chdir", so the guards
of this round's first and sixth commits read every such repository as
unreadable: a gone worktree with any submodule was kept for that reason
alone, never read. The proof run on the round's head showed it (the
prune's reason said the branches "could not be read" where the test
expected the unpublished branch named).

The submodule-repository reads now run each git command there with the
repository's own `objects/` as its working tree (`GIT_…
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants