Skip to content

feat: worktree registry prune command - clean dead/corrupted entries (t197)#833

Closed
marcusquinn wants to merge 1 commit intomainfrom
feature/t197
Closed

feat: worktree registry prune command - clean dead/corrupted entries (t197)#833
marcusquinn wants to merge 1 commit intomainfrom
feature/t197

Conversation

@marcusquinn
Copy link
Owner

@marcusquinn marcusquinn commented Feb 9, 2026

Summary

  • Enhanced worktree-helper.sh registry prune to detect and clean dead/corrupted registry entries
  • Added --dry-run, --all, --quiet flags for safe, flexible pruning
  • Fixed corrupted entry handling (ANSI escape codes, embedded newlines in paths)

Changes

shared-constants.sh - prune_worktree_registry()

  • Rowid-based iteration: Handles entries with embedded newlines/ANSI codes that broke pipe-separated parsing
  • Corruption detection: Empty paths, control characters in paths, missing PIDs, non-worktree directories
  • --dry-run: Preview what would be pruned without removing
  • --verbose: Show per-entry reason (missing directory, dead PID, corrupted, orphaned)
  • --all: Also detect orphaned entries not in git worktree list
  • PRUNE_COUNT global: Callers can report results
  • Safe deletion by rowid: Avoids SQL issues from corrupted path values

worktree-helper.sh - cmd_registry

  • prune subcommand: Full CLI with --dry-run/-n, --all/-a, --quiet/-q
  • list subcommand: Fixed count accuracy (was inflated by corrupted entries), added alive/dead summary
  • Path sanitization: Strip control chars and truncate for display
  • Help text: Documented all prune options with examples

Testing

  • Verified dry-run preserves all entries (count unchanged)
  • Verified PRUNE_COUNT matches actual DB count
  • Verified verbose output includes all reason categories (missing directory, dead PID, corrupted)
  • Verified quiet mode suppresses per-entry details
  • ShellCheck clean, bash syntax validation passes

Summary by CodeRabbit

  • New Features

    • Added --dry-run flag to preview pruning without making changes
    • Added --all flag to include orphaned entries in pruning operations
    • Added --verbose flag for detailed per-entry information during pruning
    • Enhanced registry listing with alive/dead status indicators and entry count summaries
  • Bug Fixes

    • Improved detection and safe removal of corrupted registry entries
    • Enhanced handling of special characters and edge cases in worktree paths
    • Better identification of missing directories and invalid git worktrees

…s (t197)

Enhanced prune_worktree_registry() in shared-constants.sh:
- Iterate by rowid to handle entries with embedded newlines/ANSI codes
- Detect corrupted paths (control characters, empty paths, missing PIDs)
- Detect missing directories and dead owner PIDs
- Support --dry-run, --verbose, --all flags
- --all flag detects orphaned entries not in git worktree list
- Set PRUNE_COUNT global for callers to report results
- Delete by rowid for safe handling of corrupted paths

Enhanced cmd_registry in worktree-helper.sh:
- prune subcommand: --dry-run/-n, --all/-a, --quiet/-q flags
- list subcommand: rowid-based iteration (fixes count with corrupted entries)
- list subcommand: summary line with alive/dead counts
- Sanitize paths for display (strip control chars, truncate)
- Help text for registry subcommands with examples
@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!

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 9, 2026

Caution

Review failed

The pull request is closed.

Walkthrough

Two shell scripts enhanced to support robust worktree registry pruning with dry-run capability, comprehensive validation (corrupted paths, dead PIDs, missing directories), and verbose reporting with entry counts.

Changes

Cohort / File(s) Summary
Registry Pruning Function Enhancement
.agents/scripts/shared-constants.sh
Enhanced prune_worktree_registry with --dry-run, --verbose, and --all flags; added PRUNE_COUNT tracking; introduces rowid-based iteration for safer handling of special characters; implements multi-point validation (empty paths, control characters, missing directories, corrupted git status, dead PIDs, orphaned entries) with detailed reason tracing and per-entry reporting.
Registry Command Helpers
.agents/scripts/worktree-helper.sh
Refactored cmd_registry list to use rowid iteration with per-row field retrieval; adds alive/dead PID status checking and displays formatted output with totals. Enhanced cmd_registry prune with --dry-run, --all, and --quiet flags; computes before/after counts and displays conditional messages; updated help text and examples for new options.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Possibly related PRs

Poem

🌿 Registry gardens grow wild with entries astray,
Corrupted paths and dead PIDs lead the way,
Validation chains now catch each broken sign,
Dry-run previews before the final line,
Dead worktrees pruned with surgical precision,
Zero debt maintained with DevOps vision. ✨

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

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.

@github-actions
Copy link

github-actions bot commented Feb 9, 2026

🔍 Code Quality Report

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

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

�[0;34m[INFO]�[0m Recent monitoring activity:
Mon Feb 9 23:55:05 UTC 2026: Code review monitoring started
Mon Feb 9 23:55:05 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 61

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 61
  • VULNERABILITIES: 0

Generated on: Mon Feb 9 23:55:07 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

@marcusquinn marcusquinn closed this Feb 9, 2026
@marcusquinn marcusquinn deleted the feature/t197 branch February 9, 2026 23:55
@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 9, 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