Bug: setup-worktrees can produce broken gitdir pointers in role worktrees

t-588·WorkTask·
·
·
Created1 week ago·Updated1 week ago

Dependencies

Description

Edit

While exercising dev-review-release on t-587.2 with a fresh root, setup-worktrees created directories that are not valid git worktrees.

Repro: 1. Run: Omni/Ide/dev-review-release.sh setup-worktrees --root _/tmp/t587-e2e --name t-587 --base live 2. setup logs show worktrees created and branches t-587-dev/test/live. 3. Run a loop once (review succeeded once for t-587.2). 4. Next loop invocation fails with: Workspace missing: /home/ben/omni/live/_/tmp/t587-e2e/dev 5. Inspecting shows directory exists but git fails: git -C /home/ben/omni/live/_/tmp/t587-e2e/dev rev-parse --is-inside-work-tree fatal: not a git repository: /home/ben/omni/live/.git/worktrees/dev1 6. /home/ben/omni/live/_/tmp/t587-e2e/dev/.git contains: gitdir: /home/ben/omni/live/.git/worktrees/dev1 but .git/worktrees/dev1 does not exist.

Impact:

  • Workflow cannot continue after one or more loop iterations because role worktrees become invalid.
  • Blocks exercising full dev→review→integrator flow for t-587.2.

Likely related to worktree creation/hook interaction (we also saw branchless hook noise: fatal bad object 000... during setup). Need robust detection/repair in setup/loop and root-cause in worktree management/hook integration.

Timeline (16)

🔄[human]Open → InProgress1 week ago
💬[human]1 week ago

Implemented fix in commit 5c1a2ab9: loop startup now validates role workspace health and auto-recovers broken gitdir worktrees by preserving broken dirs and force re-adding worktrees. Added loop --name for explicit branch prefix during repair, and updated setup/loop docs. Repro validated with intentionally broken .git pointer under _/tmp/t588-repro.

🔄[human]InProgress → Review1 week ago
🔄[system]Review → ReviewInProgress1 week ago
💬[human]1 week ago

Review (patchset 1): APPROVED

Changes reviewed:

  • Omni/Ide/dev-review-release.sh: +2 functions (workspace_is_valid_git_repo, ensure_role_workspace), new --name flag for loop subcommand, updated setup hints to include --name.
  • Omni/Ide/DEV_REVIEW_RELEASE.md: documents auto-recovery behavior and --name usage.
  • Omni/Ide/README.md: adds example with --name flag.

Verification:

  • Exactly 1 commit on branch relative to live ✓
  • lint passes (shellcheck) ✓
  • Commit message includes Task-Id trailer ✓
  • Manual testing of recovery logic with git worktree add -f confirms it correctly handles: (a) stale admin entry after mv, (b) missing admin dir (gitdir pointing to nonexistent path), (c) workspace dir doesn't exist at all ✓

Code quality:

  • Recovery preserves broken dirs as .broken-<timestamp> (safe, non-destructive) ✓
  • Uses -f flag correctly to allow re-checkout of same branch ✓
  • Validates workspace after recovery with return code ✓
  • --name defaulting from --root basename matches setup behavior ✓
🔄[human]ReviewInProgress → Approved1 week ago
💬[human]1 week ago

Automation (review) run review-t-588-20260211-221919 cost_cents=0 cumulative_cost_cents=0.

🔄[system]Approved → Integrating1 week ago
🔄[human]Integrating → Done1 week ago
💬[human]1 week ago

1a247c5f3629bd0cff6c343865d6082d2a3cf2ae: Integrated successfully. Lint verification passed.

💬[human]1 week ago

Automation (integrator) run integrator-t-588-20260211-222433 cost_cents=0 cumulative_cost_cents=0.