feat(profiles): make gitea.branch.delete a documented reconciler-owned capability
Merged-PR source-branch cleanup is reconciler work (task_capability_map maps cleanup_merged_pr_branch -> reconciler / gitea.branch.delete), but the reconciler profile schema, execution-profile docs, and tests never covered the permission, so no configured profile could run the guarded gitea_cleanup_merged_pr_branch path. - reconciler_profile.py: add gitea.branch.delete to RECONCILER_RECOMMENDED_OPERATIONS (not required; not forbidden) - docs/gitea-execution-profiles.md: document merged-branch cleanup ownership, least-privilege constraints, and the no-alias caveat - tests/test_reconciler_profile.py: reconciler profile with branch.delete stays valid and classified reconciler; missing grant is reported as missing-recommended - tests/test_branch_cleanup_guard.py: author- and merger-shaped profiles without gitea.branch.delete fail closed on gitea_cleanup_merged_pr_branch Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
This commit is contained in:
@@ -93,6 +93,44 @@ class TestMergedPrBranchCleanupTool(unittest.TestCase):
|
||||
self.assertEqual(res["required_permission"], "gitea.branch.delete")
|
||||
self.mock_api.assert_not_called()
|
||||
|
||||
def test_author_and_merger_without_delete_authority_fail_closed(self):
|
||||
role_profiles = {
|
||||
"author": [
|
||||
"gitea.read",
|
||||
"gitea.branch.create",
|
||||
"gitea.branch.push",
|
||||
"gitea.repo.commit",
|
||||
"gitea.pr.create",
|
||||
],
|
||||
"merger": ["gitea.read", "gitea.pr.merge"],
|
||||
}
|
||||
for name, allowed in role_profiles.items():
|
||||
with self.subTest(role=name):
|
||||
profile_patch = patch(
|
||||
"mcp_server.get_profile",
|
||||
return_value={
|
||||
"profile_name": name,
|
||||
"allowed_operations": allowed,
|
||||
"forbidden_operations": [],
|
||||
},
|
||||
)
|
||||
profile_patch.start()
|
||||
try:
|
||||
res = gitea_cleanup_merged_pr_branch(
|
||||
pr_number=487,
|
||||
confirmation="CLEANUP MERGED PR 487 BRANCH feat/branch",
|
||||
branch="feat/branch",
|
||||
remote="prgs",
|
||||
worktree_path="/tmp/repo/branches/cleanup",
|
||||
)
|
||||
finally:
|
||||
profile_patch.stop()
|
||||
self.assertFalse(res["performed"])
|
||||
self.assertEqual(
|
||||
res["required_permission"], "gitea.branch.delete"
|
||||
)
|
||||
self.mock_api.assert_not_called()
|
||||
|
||||
def test_root_checkout_cleanup_fails_closed(self):
|
||||
patch(
|
||||
"mcp_server.get_profile",
|
||||
|
||||
Reference in New Issue
Block a user