Skip to content

status's record layer: a deleted worktree is not a worktree, two checkouts of one workspace are one record, and a --no-push record is never sent to resume - #18

Merged
brettheap merged 10 commits into
mainfrom
fix/status-record-layer-copilot
Sep 11, 2026
Merged

brettheap merged 10 commits into
mainfrom
fix/status-record-layer-copilot

Conversation

@brettheap

@brettheap brettheap commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

The follow-up #13 owed to Copilot, whose two reviews on that PR carried ten findings; the independent review's commit 0b8dbe9 answered four of them and nothing followed the other six (two of them one bug named twice). Each is verified against status on main and either fixed here or cited to the line that already answers it.

Fixed, each with a regression test built the way the record-layer tests build estates (bare repositories in a temporary directory, a fake $HOME, no network):

  • record_candidates counted raw rows, so two checkouts of one workspace repository (the default path: plus an orgs: override) read as "2 records … in different orgs" and, with a filesystem-path origin, could not be settled: it now emits one row per <org>/<basename>, the other half of the physical-path dedup already in locate_record, the way resume counts (F4 of the review on openRepoShape One binding per lane: the record says host/os/container, liveness is pronounced only from inside that binding, and a second place ASKS for the handoff before it binds (Amendment 18 acts 1-10) #83).
  • A recorded feature whose worktree directory was deleted without git worktree prune read as present at the parked commit, hence clean: the stale worktree list --porcelain block is skipped unless its path is a directory, as read_worktrees has done since the local layer, so it is the "no worktree here" finding.
  • The unrecorded-worktree sweep fired "not in the parked record — never parked" for that same stale block: gated on the path existing.
  • A --no-push record with no worktree here said "resume refuses it" and then "resume <Name> brings it back": where both hold it is one line naming the only exit, parking again from the workstation that has the commit. AGENTS.md rule 4 and the README said the bare rule too; both now carry the exception, and the two line caps in tests/test_repo_hygiene.py move by that (140→142, 241→242) in dated entries.
  • The missing-parked-commit line said "or parked with --no-push" under a pushed: true record that rules it out: the wording is now conditional on pushed.

Three more commits from the reviews of this PR. From the independent review: a recorded feature whose worktree directory was deleted but whose registration git worktree list --porcelain still holds is not a case resume <Name> can bring back — the Speckit extension's resume.sh matches registrations by path alone in leg_registered_at and prints "already registered … left as it is", and a plain git worktree add over the ghost is refused by git — so worktree_on_branch now tells a held-but-gone registration apart from none at all, the finding names git -C <repo> worktree prune first and resume <Name> second, the --no-push line names the prune and still never names resume, and AGENTS.md rule 4 says a stale registration is git worktree prune's to clear, never worktree add --force. From Copilot's second review: the record/manifest lookup compares the basename case-insensitively in both status and resume, but the dedup key folded only the org, so TestOrg/Atlas.yaml and TestOrg/atlas.yaml in two checkouts of one workspace read as two orgs and resume refused with --org unable to answer; both keys now fold both halves, one line each. And status --fetch now fetches every repository of the estate FIRST, before any row is printed, exactly as the README and AGENTS.md rule 4 have said all along: fetch_estate_first stores each fetch's lines, findings and flags per repository, replay_fetch puts them back on their own row so the report reads as before, and read_record therefore runs after the leg's own fetch — a parked commit that lived only on the spec leg's origin was reported "not here" and then fetched further down the same report. Because the fetch is now first for every role, the missing-commit wording after a fetch that worked says origin has not got it either, the way no_origin_branch_finding does. Then a merge of main (the pin bump to openRepoShape 32450eb and #17) so the suite runs against the pin main carries, and one last commit from Copilot's third review and the second independent review: a LOCKED stale registration is git -C <repo> worktree unlock <path> first, because worktree prune skips a locked block (verified on git 2.43: unlock of a registration whose directory is gone exits 0, prune then clears it), and the finding, AGENTS.md rule 4, the README and status --help all say which kind it is; the fetch store is keyed by physical path so a leg spelled ./spec in project.yaml and spec in .gitmodules is one repository; a member a family lists twice is fetched once; and --fetch's help says every repository is fetched before the first row, so a blocking ssh prompt belongs to a fetch, not to the row on screen. And from Copilot's fourth review: a block git worktree list itself marks prunable is stale whatever is on disk — a worktree directory whose .git file is gone read as live and clean — and the exit then names the prune and a move of the leftover directory aside (never a delete; git worktree add refuses a path that exists, and worktree remove refuses a path with no .git); of two stale registrations for one branch (worktree add --force) the locked one is named, since unlock-then-prune clears both; the unrecorded sweep skips a prunable block too. AGENTS.md rule 4, the README and status --help carry the clause. From Copilot's fifth review: git never computes prunable for a locked block, so a locked registration whose directory remains but whose .git is gone read as live and clean; worktree_is_usable (the directory and its .git both exist — -e, since the main worktree's .git is a directory) now decides liveness in worktree_on_branch, the unrecorded sweep and the local layer's read_worktrees, so the three readers agree about what a worktree on disk is. The fifth review's other claim, that replay_fetch reorders a failed origin against a live upstream, is answered in the comments with a byte-identical diff against main. Suite on the final head with the submodule at 32450eb: see the last commit's CI run.

Already answered on main, cited in the review trail: the 0x1f field separator in read_record (0b8dbe9), the diverged-worktree test, the declared-leg path never falling through to the name fallback (proved with a throwaway test), and the no-block-for-this-root case still sweeping unrecorded worktrees (0b8dbe9).

🤖 Generated with Claude Code

Summary by Sourcery

Harden the status record layer so worktree state, record identity, fetch results, and recovery guidance remain accurate across stale registrations, duplicate checkouts, and no-push records.

Bug Fixes:

  • Correct record-layer status and resume handling for deleted, prunable, locked, or otherwise unusable worktree registrations.
  • Prevent duplicate records and repositories when the same workspace or manifest is referenced through multiple checkout paths or casing variants.
  • Ensure --fetch completes and stores every repository fetch before record-layer status rows are evaluated, producing accurate post-fetch findings.
  • Clarify missing parked-commit and --no-push diagnostics so each finding names a valid recovery path.

Enhancements:

  • Align worktree liveness detection across status, record scanning, and the local layer based on the presence of a usable .git entry.
  • Update status help and user guidance for stale registrations, locked worktrees, leftover directories, and --no-push records.

Documentation:

  • Document the updated recovery rules for no-push records and stale or locked worktree registrations in AGENTS.md and README.md.

Tests:

  • Add regression coverage for duplicate checkout and case-variant record deduplication, stale and locked worktrees, fetch ordering, fetch-store path normalization, and corrected diagnostics.

…eckouts of one workspace are one record, and a `--no-push` record is never sent to `resume`

Copilot's two reviews on PR #13 carried ten findings between them, most as suppressed comments; the independent review's 0b8dbe9 answered four and nothing followed, so this answers the rest. git worktree list --porcelain keeps a linked worktree's block until git worktree prune runs, and worktree_on_branch returned that path without checking it: a recorded feature whose directory was deleted read as present, at the parked commit, and therefore CLEAN — the one answer that hides the case the layer exists for — while the unrecorded sweep accused the same stale block of never having been parked. Both check the path now, as read_worktrees has since the local layer. record_candidates emits one row per <org>/<basename>, which is what resume counts as one record (F4 of the review on openRepoShape #83): two checkouts of one workspace repository — the default path: and an orgs: override that is a second clone of it — read as "two orgs record this id", and a local-path origin names no owner to settle that with, so a record that was never ambiguous was skipped unread. A leg parked with --no-push said resume refuses it and then that resume <Name> brings it back; where both states hold that is one line now, naming the only exit there is, and the missing parked commit no longer offers --no-push as a reason a pushed: true record rules out, nor promises a fetch this layer cannot speak for. Five tests, one per fix. AGENTS.md rule 4 and the README carry the --no-push exception, each cap raised in a dated entry. Four findings were already answered and are left alone: 0x1F between the record's fields, the diverged worktree's test, a declared leg path that is absent (it returns and never falls through to $root/<role>), and the sweep of a root the record does not mention. PR #13.

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

@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 3 days and 3 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

The PR fixes record-layer status handling by deduplicating equivalent workspace checkouts, treating deleted worktrees as absent rather than clean or unparked, and making no-push and missing-commit diagnostics mutually consistent; regression tests and documentation are updated accordingly.

Sequence diagram for no-push record recovery

sequenceDiagram
    participant User
    participant status
    participant resume
    participant park
    participant Workstation
    User->>status: status
    status->>resume: resume
    resume-->>status: refuses --no-push record
    status-->>User: report only exit is to park again
    User->>Workstation: return to workstation with commit
    User->>park: park
    park-->>Workstation: record parked commit again
Loading

Flow diagram for corrected record-layer status handling

flowchart TD
    A[status reads workspace records and worktrees] --> B[record_candidates deduplicates by org and basename]
    B --> C{worktree path is a directory}
    C -->|no| D[ignore stale worktree block]
    C -->|yes| E[compare worktree with parked record]
    E --> F{record has --no-push}
    F -->|yes| G[report resume refusal and park again from original workstation]
    F -->|no| H[report resume or worktree status]
Loading

File-Level Changes

Change Details Files
Correct record discovery and worktree interpretation for duplicate checkouts and deleted worktrees.
  • Deduplicate candidate records by organization and workspace basename, matching resume’s counting behavior.
  • Ignore stale Git worktree entries whose paths no longer exist when evaluating recorded and unrecorded worktrees.
status
tests/test_status_command.py
Make status diagnostics accurately describe records parked without pushing their commits.
  • Replace the contradictory resume guidance with the only valid recovery: re-park from the workstation holding the WIP commit.
  • Condition missing-commit explanations on the record’s pushed state.
  • Add regression coverage for no-push records and pushed versus unpushed missing commits.
status
tests/test_status_command.py
Align user-facing documentation and hygiene limits with the no-push recovery rule.
  • Document that resume can only restore a no-push record from its original workstation.
  • Update README and AGENTS.md line-count caps and dated explanatory test fixtures.
AGENTS.md
README.md
tests/test_repo_hygiene.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

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

status --help still omits the --no-push recovery exception.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR improves status record handling for deleted worktrees, duplicate checkouts, and --no-push records.

Changes:

  • Ignore stale deleted worktree metadata.
  • Deduplicate equivalent workspace records.
  • Clarify diagnostics, recovery guidance, and add regression tests.
File summaries
File Description
tests/test_status_command.py Adds regression coverage.
tests/test_repo_hygiene.py Updates documentation caps.
status Updates record discovery and worktree diagnostics.
README.md Clarifies parked-record behavior.
AGENTS.md Documents --no-push recovery.
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
…, so the help text no longer sends somebody to a `resume` that refuses that record

Copilot's review of PR #18 (anchored at status:83): the usage heredoc still said a recorded feature with no worktree here is brought back by `resume <Name>`, full stop, while the finding it describes now says the opposite where the record was parked with --no-push — the same contradiction inside `status` that this branch took out of the findings, the header, AGENTS.md rule 4 and the README. The parked-record sentence in the help gains the exception in the README's compressed form, at the paragraph's own width. One test holds it, reading the help with the wrapping normalised so the paragraph can be re-wrapped and not the sentence. Every other `resume <Name>` line in park and status was read too: each is the ESTATE-level one — "brings one back", about an estate that is not on this machine at all, which resume does clone and bootstrap — and none of them states the per-feature rule, so none changes.

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

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

Address the two moderate status findings involving case-insensitive deduplication and fetch ordering.

Review details

Suppressed comments (2)

status:1487

  • The lookup above is case-insensitive, but this deduplication key keeps the basename's original case. If two configured checkouts contain the same record as Atlas.yaml and atlas.yaml, both candidates match want yet produce different keys, so a single logical record can still be reported as ambiguous. Normalize the basename in the key as well.
                key="$(lower "${dir##*/}")/$base"

status:1756

  • With --fetch, this check still runs before the mounted leg's row is processed: read_record is called from the root row, while fetch_remote for mounted legs runs later. A pushed parked commit that is only on the leg's origin therefore triggers this “not here” finding even though the same run fetches it immediately afterward, contradicting the command's “fetched first” contract. Fetch all repositories before read_record, or defer this comparison until after the leg fetch.
        # exit: this runs in the ROOT's row, and a leg's own repository is
        # fetched after it, so `FETCHED_OK` is not this repository's answer.
  • Files reviewed: 5/5 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

brettheap and others added 4 commits September 11, 2026 13:57
…, because a registration git still holds is what stops the exit the record layer would otherwise name

The independent review of PR #18: the previous commit stopped calling a deleted worktree clean, but routed it to "no worktree on that branch here … `resume <Name>` brings it back", and `resume` will not bring it back. The extension's resume.sh matches a leg in leg_registered_at on the REGISTERED PATH alone — git-common.sh's load_git_worktrees hands it `worktree list --porcelain -z` raw, with no test that the directory is there — so a stale block at the path it computes reads as already done ("worktree already registered at …; left as it is") and nothing is recreated, and a stale block at another path leaves its plain `git worktree add` to be refused ("already used by worktree at …" / "is a missing but already registered worktree; use 'add -f' to override, or 'prune' or 'remove' to clear", both confirmed against git 2.43). resume.sh names the hazard itself where it rolls back what it created: "a phantom registration a later resume reads as 'already registered' for a path that is not there". So worktree_on_branch now has three answers rather than two — the worktree, or 2 and the stale path, or nothing — and check_parked_leg names the prune first and the resume second; a --no-push record with a stale registration names the prune and still never names resume, since there is nothing here to resume. The scan's comment ends where git does: only `worktree add --force` makes a live worktree beside a stale block for the same branch. AGENTS.md rule 4 gains the rule the two findings imply — a stale registration is `git worktree prune`'s to clear, never `worktree add --force` and never a delete under `.git/worktrees/` — and its cap moves 142 -> 145 in a dated entry. The README is unchanged: it lists the four states the layer reads, and this is not a fifth one, it is the same "no worktree here" with a step in front of its exit, which the finding itself spells out.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
…rds, as they already fold the org and as both of them matched it, so `Atlas.yaml` and `atlas.yaml` in two checkouts are one record

Copilot's second review of PR #18, on status:1487: the lookup is case-insensitive and the key was not. Both files match the basename with lower (resume's manifest_candidates says so in its own comment, "compared CASE-INSENSITIVELY", and status's record_candidates mirrors it), so two checkouts of one workspace repository holding testfam.yaml and TestFam.yaml both matched the wanted name and then produced two different keys: resume REFUSED with "2 workspace manifests record 'TestFam', in different orgs" listing testorg twice, which --org cannot answer, and status noted "2 records for 'atlas' in different orgs" and read none. One line in each file, the same fold on both halves of the key, so the mirror the record layer promises — status judging the record the way resume will — still holds; the shared resolver block and expand_home are untouched. A test in each suite, each built the way that suite builds estates: two checkouts spelling the one record differently, one answer. Two DISTINCT orgs are still ambiguous, which is the case --org exists for, and the tests that hold that are unchanged and still pass.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
…any of them, which is what it has always said it does, so the record layer no longer reports a parked commit as missing in the run that fetches it

Copilot's second review of PR #18, on status:1756: the fetches ran row by row while the record layer is read on the ROOT's row, so a feature parked from another workstation into a LEG's origin was reported as a parked commit that "is not here" by the very run that fetched it a moment later — a finding that vanished on the second run, and the opposite of the sentence the README, AGENTS.md rule 4 and the command's own header carry ("in every repository first, so the answers are current"). The independent reviewer of this branch recorded the same hazard. So fetch_estate_first makes every fetch before any row is printed and stores each repository's result by path — the lines it printed, the findings it made, FETCHED_OK and UPSTREAM_FETCHED_OK — and replay_fetch puts them back on their own row, which is why the report reads exactly as it did: the failure of the root's fetch is still the root's finding and the leg's "nothing new" is still the leg's line, now asserted in the failed-fetch test. estate_repos is read once into `rows` and both passes walk it. With every repository fetched first, FETCHED_OK is this repository's answer for every role, so the missing parked commit says which of the two reasons is left: after a fetch that worked, "never fetched" is ruled out and the line says origin has not got it either, the way no_origin_branch_finding has always split that case. Two tests: a spec leg whose parked commit only its own bare origin has, read under --fetch, and a parked commit still missing after this run's fetch. No document changes: both already describe this order, and now it is the one the command runs in.

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

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

Locked stale worktree registrations are not handled, and related recovery guidance is incomplete.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 7/7 changed files
  • Comments generated: 4
  • Review effort level: Lite

Comment thread status Resolved
Comment thread AGENTS.md Resolved
Comment thread README.md Resolved
Comment thread status Resolved
…n, keys the fetch store by physical path and fetches each repository once, because an exit that git skips is not an exit

Copilot's third review of PR #18, four comments on the one gap the previous commit's own comment named: `git worktree prune` SKIPS a locked registration, and every line and document said prune. Verified here against git 2.43: for a locked worktree whose directory is gone, `prune -v` prints nothing and clears nothing, `worktree remove --force` refuses ("cannot remove a locked working tree; use 'remove -f -f' to override or unlock first"), and `worktree unlock <path>` on a registration whose directory is gone exits 0, after which prune removes it and `worktree add` succeeds. So worktree_on_branch has four answers rather than three — the porcelain's `locked` line comes after `branch` in the same block, so the block is read to its blank line before the answer is settled — and both ghost findings, the plain one and the --no-push one, name unlock then prune for a locked registration and prune alone for an unlocked one. The --no-push line still never names `resume`. AGENTS.md rule 4, the README's `status` paragraph and `status --help` carry the same state and the same exit; the two caps move 145 -> 147 and 242 -> 244 in dated entries.

With it, the second independent review's three nits. The fetch store is keyed by PHYSICAL path (`physical_path`, the idiom locate_record already uses on workspace checkouts): `estate_repos` builds a leg's path out of `.gitmodules` and the record layer asks about the path `project.yaml` gives that role, so `./spec` and `spec` were one leg and two keys, and a leg fetched two rows below was told this repository had never fetched it — a test with those two spellings holds it. fetch_estate_first skips a path it has already fetched, so a `family.yaml` that lists a member twice is fetched once and the duplicate row replays the one fetch that was made; no test, because the report cannot see the difference — replay_fetch answers both rows from the first entry either way, and a second fetch that transfers nothing does not even reach the server's post-upload-pack hook, which I probed. And `--fetch`'s help block says every repository is fetched before the first row is printed, so an ssh prompt that blocks with no row in front of it belongs to a fetch.

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

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

Unresolved critical and moderate findings remain in status worktree-registration handling.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Suppressed comments (1)

status:1847

  • When there are multiple stale registrations for the same branch, locked is only recorded while stale is still empty. If an unlocked stale block is followed by a locked one (possible with the worktree add --force duplicate state this parser explicitly discusses), this returns 2 and reports the first path, so the suggested worktree prune skips the later locked registration and resume remains blocked. Track the locked registration independently and prioritize/report it before choosing the cleanup command.
            if [ "$hit" -eq 1 ] && [ -z "$stale" ]; then locked=1; fi
            ;;
        "")
            if [ "$hit" -eq 1 ] && [ -z "$stale" ]; then stale="$path"; fi
  • Files reviewed: 7/7 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment thread status Resolved
…es the LOCKED one of two stale registrations, because the exit has to clear what actually blocks `resume`

Copilot's fourth review of PR #18, two findings on worktree_on_branch, both verified against git 2.43 before a word of the fix was written. Delete only a worktree's .git file and the DIRECTORY stays while git calls the registration "prunable gitdir file points to non-existent location": the -d test alone read that as a live worktree and, sitting at the parked commit, said nothing at all, while resume still saw the registration. So a `prunable` block is stale whatever is on disk, and -d still decides the blocks git has not judged — it computes no `prunable` for a `locked` one, which is exactly the case whose directory can be gone with nothing said about it. The prune clears such a registration and leaves the directory, and `git worktree add` then refuses the path in its own words, "already exists" (`worktree remove` refuses it too: "validation failed, cannot remove working tree: '…/.git' does not exist"), so the finding names both halves and says the directory is MOVED ASIDE — it holds whatever the worktree held. The same `prunable` reading gates the unrecorded sweep, because a registration git itself calls stale is not a worktree `park` could carry.

The second: `worktree add --force` is how one branch ends up with two stale registrations, and `prune` takes every unlocked one with it while skipping the locked one, so the locked registration is now tracked across the whole scan and is the one reported — an unlock of it plus that prune clears both, where naming the unlocked path left the locked one standing and resume still blocked. The whole list is read before the answer is chosen: a live worktree beats any stale registration, a locked stale one beats an unlocked one. Two regression tests, each biting against 8cecba1 (the prunable one reported 0 findings there; the double one named the unlocked path). AGENTS.md rule 4, the README and `status --help` carry the leftover directory; the caps move 147 -> 149 and 244 -> 245 in dated entries.

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

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

Two moderate issues remain in status involving unusable locked worktrees and fetch-event ordering.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Suppressed comments (2)

status:2047

  • The unrecorded-worktree sweep has the same gap for a locked stale registration: when the directory remains but its .git/gitdir is unusable, Git reports locked rather than prunable, so this guard emits never parked for a path that is not a worktree at all. Require the worktree gitdir to validate before treating the block as an on-disk worktree, consistently with worktree_on_branch.
                elif [ -n "$branch" ] && [ -d "$path" ] && [ "$prunable" -eq 0 ]; then

status:1010

  • The new store separates successful fetch lines from fetch findings, so it loses the old per-remote event order. If origin fails and upstream succeeds, the old row-by-row code recorded the origin failure first, but replay_fetch prints the upstream success line before the stored failure; this contradicts the claim that the report reads exactly as before and makes the row's fetch diagnostics misleading. Preserve an ordered event stream (or replay the origin/upstream results in call order) instead of storing the two classes separately.
        FETCH_SAID+=("$FETCH_SAY")
        FETCH_FOUND+=("$(printf '%s\n' ${FINDINGS[@]+"${FINDINGS[@]}"})")
  • Files reviewed: 7/7 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment thread status Resolved
… is there, because git computes no `prunable` for a LOCKED block and a locked one can be a directory with nothing in it

Copilot's fifth review of PR #18, its first finding, verified against git 2.43 before the fix: lock a worktree, delete only its `.git` file, and the porcelain says `locked` and nothing else — no `prunable`, because git does not judge a locked block — so the directory test alone called it a live worktree, the record layer reported the parked feature CLEAN (0 findings, proved against 86aea4d), and the sweep accused the leftover directory of never having been parked. What a worktree has is its own `.git`: a FILE holding `gitdir: <repo>/.git/worktrees/<name>` for a linked one, a DIRECTORY for the main one. worktree_is_usable is that test, and both readers use it — worktree_on_branch calls a block live only when git has not called it prunable AND the worktree is usable, otherwise it takes the stale path, locked or not; the sweep skips what is not a worktree, as it already skipped what git calls prunable. The exit is the one already documented for a locked registration with its directory left behind, unlock then prune then move the directory aside, so AGENTS.md, the README and the help are unchanged. Two tests, both biting against 86aea4d.

The review's second finding is WRONG and nothing changed for it. It says the store "loses the old per-remote event order", so a row with a failed origin and a live upstream now prints the upstream success before the origin failure where the row-by-row code printed the failure first. The row-by-row code did not: `finding` never prints, it appends to FINDINGS, and a row prints its findings only after every read of that row is done — so main printed the upstream `say` line first too, and `replay_fetch` puts the stored lines and the stored findings back in exactly those two places. Settled empirically as well, not just by reading: twin estates (dead origin, live upstream remote, `--fetch`), main's `status` from 9d4c8ae beside this one, temp root and hex normalised — identical exit code, stdout and stderr, both printing "fetched upstream: upstream/main is here now" above "- fetch failed: …".

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

Copy link
Copy Markdown
Contributor Author

On Copilot's fifth-review comment at status:1010 (the fetch store "loses the old per-remote event order" when origin fails and upstream succeeds): settled empirically, nothing changed. finding never prints; it appends to FINDINGS, and a row prints its findings only after every read of that row has run, while say lines print immediately. So on main a row whose origin fetch failed and whose upstream fetch succeeded already printed the upstream fetched upstream: … line first and the origin failure at the end of the row. replay_fetch puts the stored say lines and the stored findings back in exactly those two places. Twin estates built by the suite's fixtures — a dead origin (remote set-url origin <home>/nowhere/Atlas.git) beside a live upstream — run under --fetch with status from 9d4c8ae and from this branch give identical exit code, stdout and stderr after normalising the temp root and hex:

  root   main   <HOME>/projects/Atlas
    fetched upstream: upstream/main is here now, at <SHA>
    - fetch failed: fatal: '<HOME>/nowhere/Atlas.git' does not appear to be a git repository; what follows is as of the last fetch that worked

The second independent review's 39-scenario differential harness found the same for this scenario. The other fifth-review finding (a locked registration whose directory remains but whose .git is gone is never marked prunable, so it read as live) stands and is fixed in ff3bc65 with worktree_is_usable, used by worktree_on_branch and the sweep.

…er directory under the root no longer has `git status` run inside it and the root's own dirty paths reported on that row

Brett Heap's RULING of 2026-09-11 on the note this branch left: take it now. `read_worktrees` gated on the DIRECTORY alone, while the record layer and its sweep had moved to `worktree_is_usable` — a directory with its own `.git`, the file a linked worktree has and the directory the main one has. The extension puts feature worktrees UNDER the root, so a registered path whose `.git` is gone is a plain directory inside the root's own working tree: `git status` there finds no repository, walks UP, and hands back the ROOT's dirty paths, which this layer then printed on the worktree's row under a branch that has nothing to do with them — proved against ff3bc65, where the row read "worktrees/001-a-thing on 001-a-thing: dirty, 1 path(s)" and the one path was the root's own untracked directory. One line, and now the three readers of `worktree list --porcelain` agree about what a worktree on disk is. One test, biting against ff3bc65, and it is the realistic shape rather than a contrived one: the worktree is placed under the root, as `worktree_root:` puts it.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Copilot AI review requested due to automatic review settings September 11, 2026 15:27
@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.

🟡 Changes recommended

Three unresolved moderate findings remain in status.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Suppressed comments (2)

status:1945

  • The recovery commands emitted here are not copyable when either repo or ghost contains whitespace (for example, a custom $PROJECTS_DIR with spaces): git -C /path with spaces ... is parsed as separate arguments. Quote or shell-escape both paths in this locked form and in the prune-only assignment above before presenting this as the required way to unblock resume.
        ghost="$out"
        ghost_is="a stale worktree registration for it is still recorded at $ghost and LOCKED, which \`worktree prune\` skips"
        clear="\`git -C $repo worktree unlock $ghost\`, then \`git -C $repo worktree prune\`"

status:1893

  • When a branch has both a locked and an unlocked stale registration, returning only stale_locked loses the other path. git worktree prune clears both registrations but leaves every stale directory in place; if the unlocked path is the feature path that resume will recreate, the emitted guidance moves only the locked path and resume still fails because the target directory exists. Preserve/report all stale paths that still have directories, or explicitly instruct moving all of them aside.
    [ -z "$stale_locked" ] || { printf '%s\n' "$stale_locked"; return 3; }
  • Files reviewed: 7/7 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment thread status
if [ "$first" -eq 1 ]; then
first=0
elif [ -n "$path" ] && [ -d "$path" ]; then
elif [ -n "$path" ] && worktree_is_usable "$path"; then
@brettheap

Copy link
Copy Markdown
Contributor Author

On Copilot's sixth-review comment at status:803 (read_worktrees should carry prunable through and require it to be zero before worktree_is_usable, because a leftover directory reused as another repository, or one whose .git entry remains, would be prunable and have git status read under the old branch): settled empirically, nothing changed.

git worktree list --porcelain computes prunable for a listed, unlocked block from ONE test — whether the path its gitdir file names, <path>/.git, exists (should_prune_worktree; list runs it with no expiry) — and that is the file worktree_is_usable tests. So a listed block is never both prunable and usable, on any git that prints prunable at all: delete <path>/.git and the block says prunable gitdir file points to non-existent location while worktree_is_usable says no; put a .git back — git init in the leftover directory, or a copied gitfile — and the block says nothing, and git itself lists that path as a worktree on the old branch, which all three readers then agree with. A locked block gets no prunable either way, so there too worktree_is_usable alone decides. The prunable test in worktree_on_branch and unrecorded_worktrees earns its place against what a bare -d test let through (Copilot's fourth review), not against anything worktree_is_usable lets through; adding it to read_worktrees would change no output for any registration. Verified against git 2.43.0:

git init -q root && cd root && git commit -q --allow-empty -m init && git branch -q feat
git worktree add -q wt feat
rm -rf wt && mkdir wt && git init -q wt          # the leftover directory reused as another repository
git worktree list --porcelain | grep -c prunable  # 0 — not prunable; `.git` exists, so `worktree_is_usable` is true too
rm -rf wt/.git                                    # now only the directory remains
git worktree list --porcelain | grep prunable     # prunable gitdir file points to non-existent location — and `worktree_is_usable` is false

@brettheap
brettheap merged commit a2c8521 into main Sep 11, 2026
7 checks passed
@brettheap
brettheap deleted the fix/status-record-layer-copilot branch September 11, 2026 16:30
brettheap added a commit that referenced this pull request Sep 11, 2026
…adable rather than as pushed, so a hand-edited record no longer draws "the record says it was pushed" and is no longer offered the one exit `resume` refuses it for

The follow-up to note (d) of the second independent review of #18 (2026-09-11), taken as that reviewer's note — nobody has ruled on it: "a hand-edited record whose `pushed:` is valueless is neither `false` nor `true`, and `status`'s missing-commit arms then say 'the record says it was pushed' (pre-existing from 2a488b4)". Every arm of the record layer tested `[ "$pushed" = false ]` and read everything else as `true`, so a bare `pushed:`, `pushed: ""` and `pushed: yes` alike drew "the record says it was pushed" — a claim the record does not make — and, with no worktree here, were offered "`resume <Name>` brings it back", the exit the extension's own `resume.sh` refuses such a leg for (its RR6 is `[ "$pushed" != true ]`, so an unreadable value is refused exactly as `--no-push` is). The field now has three readings: a value that is neither word is named for what it is, in a finding of its own as `--no-push` has one; the no-worktree line names the exit that works (park it again from the workstation that parked it, which writes the record afresh); and the missing-commit line names every reason still standing rather than the one the record would have to be read as `true` to support, dropping "never fetched it" after a fetch that worked, as the `pushed: true` arm already did. `resume` is untouched: it reads no `pushed:` and hands the record to `make resume`, and `resume.sh` settles it before anything is fetched — proved by loading a record with `pushed:` valueless and `pushed: yes` through the extension's own `workspace_load_project`, which yields "" and "yes", each failing its `!= true`. `park.sh` writes `true` or `false` for every leg it parks and carries an existing entry forward untouched for one it refuses (`workspace_write_manifest` drops a key whose value is empty, so it never writes `pushed:` bare), so such a record is a hand-edit or a bad merge. And because `workspace_load_project` strips a `#` comment from every line before it reads a value, `pushed:` — the one field this layer judges rather than matches or prints — loses one here too, so `pushed: true # note` reads as `true` here as it does in `resume.sh`, and `false # note` as the `--no-push` record it is. `status --help`, AGENTS.md rule 4 and the README carry the second exception, one line each; hygiene caps AGENTS.md 149→150, README 245→246 in dated entries. Five regression tests beside the record-layer tests they belong with, each failing against main. The independent review's 22-pair guard (11 record-layer scenarios × `pushed: true` / `false`, main's `status` against this branch's) found no byte of difference for a well-formed record. Recorded for later, not taken here: a leg whose `pushed:` KEY is absent is dropped by `record_rows` while `resume.sh` defaults it to `false` and refuses, so `status` says nothing about a record `resume` refuses; and `resume.sh`'s own refusal line says "was parked with --no-push" for any value that is not `true`, in another repository.

PR #19

Co-Authored-By: Claude Fable 5.1 <[email protected]>
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