Teach merged-cleanup reconcile to discover actual issue worktree aliases #532

Closed
opened 2026-07-08 04:07:58 -05:00 by jcwalker3 · 0 comments
Owner

Problem:
During PR #512 / issue #510 cleanup, gitea_reconcile_merged_cleanups(dry_run=true) expected the local worktree path:

branches/feat-issue-510-workspace-binding-isolation

But the actual clean author worktree was:

branches/issue-510-workspace-binding-isolation @ 3d11e1f

Because the tool only checked the derived feat-issue-* path, it reported local worktree removal unsafe even though the real issue worktree existed and was clean.

Risk:
Merged cleanup may leave safe local worktrees behind indefinitely, or future operators may be tempted to delete them manually outside the reconciler guard path.

Required behavior:

  1. Reconcile cleanup must discover valid worktree aliases for the same issue/PR.
  2. It must verify the discovered worktree points to the merged PR head or an otherwise safe cleanup commit.
  3. It must fail closed when multiple ambiguous worktrees match.
  4. It must report both the derived expected path and the actual discovered path in dry-run output.
  5. It must not remove any worktree unless dry-run marks it safe.

Acceptance criteria:

  • Add tests for branches/issue-510-* alias discovery when the derived path is branches/feat-issue-510-*.
  • Add tests for ambiguous duplicate worktree matches failing closed.
  • Add tests proving clean discovered worktrees can be removed only after dry-run reports safe.
  • Update cleanup handoff output to show expected path, discovered path, and reason.
Problem: During PR #512 / issue #510 cleanup, `gitea_reconcile_merged_cleanups(dry_run=true)` expected the local worktree path: `branches/feat-issue-510-workspace-binding-isolation` But the actual clean author worktree was: `branches/issue-510-workspace-binding-isolation @ 3d11e1f` Because the tool only checked the derived `feat-issue-*` path, it reported local worktree removal unsafe even though the real issue worktree existed and was clean. Risk: Merged cleanup may leave safe local worktrees behind indefinitely, or future operators may be tempted to delete them manually outside the reconciler guard path. Required behavior: 1. Reconcile cleanup must discover valid worktree aliases for the same issue/PR. 2. It must verify the discovered worktree points to the merged PR head or an otherwise safe cleanup commit. 3. It must fail closed when multiple ambiguous worktrees match. 4. It must report both the derived expected path and the actual discovered path in dry-run output. 5. It must not remove any worktree unless dry-run marks it safe. Acceptance criteria: - Add tests for `branches/issue-510-*` alias discovery when the derived path is `branches/feat-issue-510-*`. - Add tests for ambiguous duplicate worktree matches failing closed. - Add tests proving clean discovered worktrees can be removed only after dry-run reports safe. - Update cleanup handoff output to show expected path, discovered path, and reason.
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Scaled-Tech-Consulting/Gitea-Tools#532