Skip to content

Harden auto-review worktree recycling after invalid reusable checkout #273

@shiny-code-bot

Description

@shiny-code-bot

Summary

Auto Review can fail during worktree_prepare when it tries to reset or reuse a stale/corrupted reusable review worktree. The observed failure was:

Failed to reset reusable worktree: fatal: not a git repository: (null)

The primary repository was valid, so the user-facing hint to verify the current workspace was misleading. The failure appears to come from the reusable auto-review worktree state, not from the source checkout.

Expected behavior

When preparing an auto-review worktree:

  • validate that the candidate reusable worktree path is a usable Git worktree before attempting reset
  • if validation or reset fails because the reusable checkout is invalid, quarantine/remove that reusable checkout and create a fresh worktree
  • run a safe git worktree prune or equivalent cleanup for stale registry entries where appropriate
  • surface an error that distinguishes source-repo failures from reusable-worktree failures
  • add regression coverage for broken .git pointers, missing worktree directories, and reset failure recovery

Notes

This was discovered while diagnosing an Auto Review failure. A separate Every Code runtime panic caused by UTF-8-unsafe exec stream truncation was fixed independently in PR #272.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions