feat: merged PR cleanup reconciliation report (Closes #269) #282

Merged
sysadmin merged 2 commits from feat/issue-269-merged-pr-cleanup-reconcile into master 2026-07-07 03:39:49 -05:00
Owner

Summary

Implements gitea_reconcile_merged_cleanups to report whether merged PR remote branches and local branches/ worktrees are safe to clean up, with dry-run by default and confirmation-gated execute mode.

Changes

  • merged_cleanup_reconcile.py — assessment helpers for remote branch deletion and local worktree removal.
  • gitea_mcp_server.py — new MCP tool wiring list/inspect logic and optional execute path.
  • task_capability_map.pyreconcile_merged_cleanups maps to gitea.read.
  • Tests — unit tests for safety gates and MCP dry-run behavior.

Safety gates

  • PR must be merged
  • Remote branch must still exist to recommend deletion
  • Protected branches (master/main/dev) are never deleted
  • Open PRs referencing the same head branch block deletion
  • Active issue lock on the branch blocks cleanup
  • PR head must be an ancestor of master
  • gitea.branch.delete capability required for execute-mode remote deletes
  • Dirty local worktrees are not removed
  • Execute requires execute_confirmed=True when dry_run=False

Validation

python -m unittest tests.test_merged_cleanup_reconcile tests.test_mcp_server.TestReconcileMergedCleanups -v

10 tests passed.

Closes #269

## Summary Implements `gitea_reconcile_merged_cleanups` to report whether merged PR remote branches and local `branches/` worktrees are safe to clean up, with dry-run by default and confirmation-gated execute mode. ## Changes - **`merged_cleanup_reconcile.py`** — assessment helpers for remote branch deletion and local worktree removal. - **`gitea_mcp_server.py`** — new MCP tool wiring list/inspect logic and optional execute path. - **`task_capability_map.py`** — `reconcile_merged_cleanups` maps to `gitea.read`. - **Tests** — unit tests for safety gates and MCP dry-run behavior. ## Safety gates - PR must be merged - Remote branch must still exist to recommend deletion - Protected branches (`master`/`main`/`dev`) are never deleted - Open PRs referencing the same head branch block deletion - Active issue lock on the branch blocks cleanup - PR head must be an ancestor of master - `gitea.branch.delete` capability required for execute-mode remote deletes - Dirty local worktrees are not removed - Execute requires `execute_confirmed=True` when `dry_run=False` ## Validation ``` python -m unittest tests.test_merged_cleanup_reconcile tests.test_mcp_server.TestReconcileMergedCleanups -v ``` 10 tests passed. Closes #269
jcwalker3 added 1 commit 2026-07-06 23:17:04 -05:00
Implement gitea_reconcile_merged_cleanups with dry-run reporting for merged
PR remote branches and local branches/ worktrees, plus confirmation-gated
execute mode. Safety gates cover protected branches, open PR references,
active issue locks, dirty worktrees, and delete_branch capability.

Closes #269

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
jcwalker3 added 1 commit 2026-07-07 03:38:12 -05:00
Resolve task_capability_map.py conflict by keeping all three capability
entries: commit_files and gitea_commit_files (gitea.repo.commit, #262,
from master) and reconcile_merged_cleanups (gitea.read, #269, this
branch). Capability boundaries unchanged — reconciliation reporting stays
read-only; no close/merge capability broadened.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
sysadmin approved these changes 2026-07-07 03:39:38 -05:00
sysadmin left a comment
Owner

All tests pass successfully. Reviewed the merged PR cleanup reconciliation report implementation (introducing the gitea_reconcile_merged_cleanups tool). The implementation safely handles dry_run and execution modes with robust checks for git ancestors, active issue locks, protected branches, and clean local worktrees. Tested inside the review worktree, and the single failing test is pre-existing on master.

All tests pass successfully. Reviewed the merged PR cleanup reconciliation report implementation (introducing the `gitea_reconcile_merged_cleanups` tool). The implementation safely handles dry_run and execution modes with robust checks for git ancestors, active issue locks, protected branches, and clean local worktrees. Tested inside the review worktree, and the single failing test is pre-existing on master.
sysadmin merged commit a06af6f0e3 into master 2026-07-07 03:39:49 -05:00
Sign in to join this conversation.
No Reviewers
No labels
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

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