Skip to content

Stale worktree registrations fail a Run's acquisition with 'cannot inspect every registration' #2041

Open

Description

@JacobStephens2

This was generated by AI during triage.

From a 2026-11-11 check of stuck pull requests (thirdshift 0.27.2).

Agent Brief

Category: bug
Summary: Stale worktree registrations, whose checkout directories no longer exist, accumulate in a Launch directory's .git/worktrees until a Run fails with cannot inspect every registration … checkout path and head unknown. The failure doesn't say what to do, and nothing prunes them.

Current behavior:

On stephens, a Ticket run for #2016 (PR #2021) failed at 11:17 EST:

cannot synchronize acquired checkout /home/jacob/repos/thirdshift-issue-2016 on expected Issue branch issue-2016: cannot inspect every registration in /home/jacob/repos/thirdshift/.git/worktrees; checkout path and head unknown

git worktree list showed 11 registrations marked prunable (issue-51, 666, 671, 701, 732, 734, 765, 786, 793, 803 and /tmp/thirdshift-1029-base), some weeks old. git worktree prune --dry-run reported each as gitdir file points to non-existent location.

src/worktree/acquisition.rs (around line 621) counts the administrative directories and refuses when git worktree list returns a different number, because "an incomplete listing cannot prove that a branch is unused". After git worktree prune by hand, the same Recovery command got past acquisition at once.

The issue was agent-failed, and its pull request a draft, so nothing scheduled took it again: it stayed stuck until someone SSHed in.

Desired behavior:

  • Registrations that Git itself would prune (gitdir pointing to a non-existent location) don't fail an acquisition. Either thirdshift runs git worktree prune for them under the existing disposal locks before inspecting, or it leaves them out of the count once Git has confirmed they are prunable. Choose in triage, keeping the existing refusal for any registration that is damaged in another way.
  • Wherever the refusal remains, its message names the registrations it couldn't account for and says what to check, e.g. git worktree prune --dry-run -v.
  • Optional: find out why these Runs' cleanup removed the checkout directory without removing its registration, and fix that.

Key interfaces:

  • src/worktree/acquisition.rs: the registration count check.
  • Worktree cleanup paths that remove a checkout directory (src/worktree/).
  • docs/guide.md, wherever Worktree acquisition failures are described.

Acceptance criteria:

  • With a registration whose checkout directory has been deleted, a Ticket run in that Launch directory acquires its worktree and runs.
  • A registration that is damaged in some other way, e.g. an administrative directory with no gitdir, still refuses, naming the directory.
  • A live worktree of another Command is never pruned.
  • Tests run through the CLI.

Out of scope:

Activity

  1. added
    bug
    needs-triage
    in-progress
    and removed
    needs-triage
    on Nov 11, 2026
  2. JacobStephens2 commented on Nov 11, 2026

    @JacobStephens2
    OwnerAuthor

    This was generated by AI during triage.

    Investigation summary

    Investigated selected Base branch main at 4a301fa (thirdshift 0.29.0), using Git 2.52.0. src/worktree/acquisition.rs is unchanged from the reported v0.27.2 release.

    The reported causal explanation was not reproduced. An unrelated registration with intact administrative files and a deleted checkout remains in Git's porcelain listing, marked prunable. It therefore passes the count check at src/worktree/acquisition.rs:621-650. An isolated CLI Ticket run completed successfully with that registration present, without pruning it. A locked deleted checkout also allowed the run to complete. Another live worktree remained intact in every fixture.

    The exact 'cannot inspect every registration' failure WAS reproduced through the CLI with a missing or empty gitdir file. Git omits those administrative entries from its listing, producing the count mismatch. Both cases refused before the agent started and preserved the registrations and live worktrees. A missing HEAD produced the separate checkout-identity/head refusal.

    The diagnostic gap is confirmed: the count-mismatch error names only the worktrees directory, omitting the individual unaccounted registrations and recovery guidance. The checker is also used during acquired-checkout synchronization through src/worktree/ownership.rs:310, consistent with the reported error prefix.

    A blanket git worktree prune is unsuitable: a separate Git fixture demonstrated that prune --dry-run -v also selects missing/empty-gitdir registrations whose checkout directories still exist. ADR-0014 deliberately preserves damaged or uncertain ownership. Cleanup uses git worktree remove through src/worktree/ownership.rs:436, and fetch disables automatic maintenance in src/git.rs:261-278; no evidence established why the reported registrations accumulated.

    Keep #2041 open pending the operator evidence below. Preserve the existing ownership refusals. Once the omitted registration or Git-version-specific behavior is identified, shape the narrow handling change, add CLI regressions, name unaccounted administrative paths in refusals, and document read-only inspection guidance in docs/guide.md. Ordinary listed deleted-checkout registrations already pass on the investigated version. No duplicate covering this registration-accounting problem was found.

    Questionnaire

    For the reporter/operator of stephens: local CLI reproduction found that ordinary deleted-checkout registrations pass, while missing or empty gitdir files reproduce the exact count-mismatch error. We need the following evidence to distinguish the original host failure before changing ownership safeguards.

    1. Which Git executable and version did the failing thirdshift Command use, and which executable/version produced the manual worktree listing? Include any known PATH difference between the scheduled Command and the interactive shell. This will establish whether Git-version or environment differences explain the discrepancy.
    2. Do you retain the pre-prune porcelain worktree listing, verbose prune dry-run output, and an inventory of every administrative directory under the Launch repository's Git common directory/worktrees? Please provide redacted copies, including whether each gitdir and HEAD file was present, empty, or unreadable. If those observations were not saved, capture them on the next recurrence before pruning. This will identify entries omitted from Git's listing; the eleven visible prunable entries alone did not reproduce the mismatch locally.
  3. added
    needs-info
    and removed
    in-progress
    on Nov 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugneeds-info

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions