Agents Builders

Doctor reconcile git worktrees

Archived
doctor-reconcile-worktrees

Created

Jun 23, 18:36

Started

Jun 23, 19:15

Completed

Jun 23, 19:57

DevOps handoff

Type

Bug

Shape

backend

Worktree Slug

doctor-reconcile-worktrees

Repositories

mcritchie-studio

Release Train

Branch

feat/doctor-reconcile-worktrees

QA URL

Production URL

tooling devops

Acceptance Criteria

  • doctor diffs git worktree list against registry
  • orphan or untracked worktrees flagged with path
  • clean managed state still reports no issues

Expected Test Plan

  • unit

Checks Run

  • [unit] orphan_label: same-basename dirs get distinct deterministic path-hash labels
  • [unit] pure orphan_worktree_dirs reconciliation flags only untracked git worktrees
  • [integration] doctor exits 0 on a prunable orphan (dir deleted, not pruned); labelled prunable
  • [integration] snapshot --write exits 0 on a prunable orphan worktree; registry still written
  • [integration] doctor exits 0 when a satellite has no local clone
  • [integration] doctor still flags a live out-of-tree orphan worktree (no regression)
  • [unit+integration] full file green: 21 runs, 470 assertions, 0 failures (env -u DATABASE_URL RAILS_ENV=test)
  • [lint] rubocop clean on bin/agent-worktree + test/commands/agent_worktree_test.rb

Agent Context

REWORK (carl HEAVY block): prunable worktree (git lists it, dir rm'd on disk) crashed BOTH doctor and snapshot --write with uncaught Errno::ENOENT (capture_status chdir into missing dir). Fix: (1) capture_status now rescues SystemCallError -> [false] defense-in-depth; (2) orphan_worktree_issues guards !Dir.exist?(dir) -> distinct 'prunable' label, skips git calls; (3) NIT: orphan_label() appends 8-char SHA1 path hash so same-basename orphans don't collapse under doctor_issues_by_label. Repro confirmed pre-fix crash + 3/4 new tests fail without fix. Rebased onto origin/release.

Stage Timeline

Who handled each stage, the time it took (measured), and the model / tokens / cost reported (best-effort) — plus who's on it right now. means the agent didn't report that metric.

  1. Created Designed
    N Nidoran♀
    Nidoran♀
    Model
    Duration
    Tokens
    Cost
    Completed Jun 23, 18:36 · 4 days ago
    api
  2. Designed Building
    N Nidoran♀
    Nidoran♀
    Model
    claude-opus-4-8
    Duration
    2 minutes
    Tokens
    Cost
    Started Jun 23, 18:36
    Completed Jun 23, 18:38 · 4 days ago
    cli
  3. Building Submitted
    N Nidoran♀
    Nidoran♀
    Model
    claude-opus-4-8
    Duration
    6 minutes
    Tokens
    1,330,750
    Cost
    ~$2.29
    Started Jun 23, 18:38
    Completed Jun 23, 18:44 · 4 days ago
    cli
  4. Submitted Blocked
    Model
    Duration
    28 minutes
    Tokens
    Cost
    Started Jun 23, 18:44
    Completed Jun 23, 19:12 · 4 days ago
    api
  5. Blocked Building
    N Nidoran♀
    Nidoran♀
    Model
    claude-opus-4-8
    Duration
    3 minutes
    Tokens
    8,204,374
    Cost
    ~$8.19
    Started Jun 23, 19:12
    Completed Jun 23, 19:15 · 4 days ago
    cli
  6. Building Submitted
    N Nidoran♀
    Nidoran♀
    Model
    claude-opus-4-8
    Duration
    10 minutes
    Tokens
    439,672
    Cost
    ~$0.40
    Started Jun 23, 19:15
    Completed Jun 23, 19:25 · 4 days ago
    cli
  7. Submitted Reviewed
    C Carl
    Carl primary
    S Shannon
    Shannon light
    Model
    claude-opus-4-8
    Duration
    7 minutes
    Tokens
    Cost
    Started Jun 23, 19:25
    Completed Jun 23, 19:31 · 4 days ago
    cli
  8. Reviewed Assembled
    S Steffon
    Steffon
    Model
    Duration
    under a minute
    Tokens
    Cost
    Started Jun 23, 19:31
    Completed Jun 23, 19:32 · 4 days ago
  9. Assembled Shipped
    A Avi
    Avi
    Model
    Duration
    25 minutes
    Tokens
    Cost
    Started Jun 23, 19:32
    Completed Jun 23, 19:57 · 4 days ago
  10. Shipped Archived
    Model
    Duration
    about 8 hours
    Tokens
    Cost
    Started Jun 23, 19:57
    Completed Jun 24, 03:44 · 3 days ago

Conversation

QA review feedback, agent handoffs, and follow-up notes for this task.

QA Feedback avi 4 days ago

2-senior review: carl (HEAVY) REQUEST_CHANGES; jasper (LIGHT) approve. Fix before resubmit: (1) MAJOR bin/agent-worktree (orphan_worktree_issues ~1393 + capture_status/git_value chdir ~164): a PRUNABLE worktree (git still lists it but its dir was deleted on disk) is flagged orphan, then git_branch/git_dirty?/base_ref_for chdir into the missing dir and raise uncaught Errno::ENOENT — crashing BOTH doctor AND snapshot --write (runs in QA/conductor automation). Reproduced by carl. NEW crash path on exactly the drift the feature targets. Fix: guard orphan dirs where !Dir.exist?(dir) — skip or label 'prunable' BEFORE computing branch/merge/clean — and add a regression test that deletes a listed worktree dir and asserts doctor exits 0. (2) MINOR: cover the prunable path + the missing-satellite-repo path. (3) NIT: two orphan dirs sharing a basename produce identical slug/orphan:<basename> labels grouped under one key — disambiguate with a short path hash. Then rebase onto origin/release before resubmitting.

QA Feedback avi 4 days ago

Rework RE-REVIEW PASS: carl (HEAVY) approve — prunable-orphan ENOENT crash RESOLVED (two-layer: orphan_worktree_issues guards !Dir.exist? + emits 'prunable' issue; capture_status rescues SystemCallError); both doctor and snapshot --write exit 0, verified failing-first vs pre-fix commit; label-collision nit fixed (path-hash). jasper (LIGHT) approve. No blockers. Non-blocking: orphan issues counted in snapshot.summary but not per-worktree (enhancement).

Sealed-bid sizing

Edit →

Alex (PM)

Avi (PO)

Dev

Actual