Skip to content

Conversation

@marcusquinn
Copy link
Owner

Summary

Fixes five issues in the supervisor worktree cleanup pipeline that caused orphaned worktree directories to persist after PR merge and deploy.

Context

After the cmd_transition scoping fix (PR #967), cleanup_after_merge was no longer receiving cross-contaminated worktree/branch values. However, the cleanup itself had several gaps that could still leave worktrees behind.

Changes

cleanup_task_worktree (3 fixes):

  1. Runtime file cleanup before removal — Added rm of .agents/loop-state, .agents/tmp, .DS_Store before git worktree remove, matching the pattern in worktree-helper.sh cmd_remove. Without this, git worktree remove --force can fail with "contains untracked files" errors.
  2. Fixed wt remove invocation — Was passing -C flag which wt (worktrunk CLI) does not support (unlike git). Now passes the worktree path directly.
  3. Explicit rm -rf fallback with verification — After git worktree remove --force, checks if the directory still exists. If so, force-removes it and prunes stale git worktree references.

cleanup_after_merge (2 fixes):
4. Verification logging + stale DB cleanup — Logs whether removal succeeded. Handles the case where the worktree path exists in the DB but the directory is already gone (cleans up DB reference and registry entry). Also clears the branch field in DB after branch cleanup.
5. No-PR shortcut paths now clean up worktrees — Both cmd_pr_lifecycle (no-PR early return) and process_post_pr_lifecycle (batch no-PR path) previously skipped cleanup_after_merge entirely when transitioning tasks directly to deployed. Now both call it before the transition.

Testing

  • ShellCheck clean on all modified functions
  • No existing tests for these functions (cleanup is integration-level)
  • Changes are defensive (all cleanup operations are non-blocking with || true)

Closes t240

Five issues fixed in cleanup_after_merge and cleanup_task_worktree:

1. cleanup_task_worktree: Add runtime file cleanup (.agents/loop-state,
   .agents/tmp, .DS_Store) before git worktree remove — matches the
   pattern in worktree-helper.sh cmd_remove that prevents "contains
   untracked files" errors.

2. cleanup_task_worktree: Fix wt remove invocation — was passing -C flag
   which wt does not support (unlike git). Now passes path directly.

3. cleanup_task_worktree: Add explicit rm -rf fallback with verification
   when git worktree remove --force fails silently (corrupted .git file,
   stale lock, remaining untracked files).

4. cleanup_after_merge: Add verification logging after worktree removal,
   handle stale DB references (worktree path in DB but directory already
   gone), and clear branch field in DB after branch cleanup.

5. No-PR shortcut paths: Both cmd_pr_lifecycle (line 7735) and
   process_post_pr_lifecycle (line 8209) previously skipped worktree
   cleanup entirely when transitioning no-PR tasks to deployed. Now
   both call cleanup_after_merge before the transition.
@gemini-code-assist
Copy link

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@marcusquinn marcusquinn marked this pull request as ready for review February 10, 2026 19:15
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 10, 2026

Warning

Rate limit exceeded

@marcusquinn has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 0 minutes and 15 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/t240

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@github-actions
Copy link

🔍 Code Quality Report

�[0;35m[MONITOR]�[0m Code Review Monitoring Report

�[0;34m[INFO]�[0m Latest Quality Status:
SonarCloud: 0 bugs, 0 vulnerabilities, 36 code smells

�[0;34m[INFO]�[0m Recent monitoring activity:
Tue Feb 10 19:16:14 UTC 2026: Code review monitoring started
Tue Feb 10 19:16:15 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 36

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 36
  • VULNERABILITIES: 0

Generated on: Tue Feb 10 19:16:17 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

@sonarqubecloud
Copy link

@marcusquinn marcusquinn merged commit f1c27ca into main Feb 10, 2026
10 checks passed
@marcusquinn marcusquinn deleted the feature/t240 branch February 10, 2026 19:31
marcusquinn added a commit that referenced this pull request Feb 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant