feat: align mutation guard with runtime_context workspace resolution (Closes #460) #462

Merged
sysadmin merged 1 commits from feat/issue-460-workspace-guard-alignment into master 2026-07-07 16:53:07 -05:00
Owner

Summary

Closes #460. Unifies workspace resolution between gitea_get_runtime_context and verify_preflight_purity so a valid branches/ worktree is evaluated consistently — even when the MCP process PROJECT_ROOT differs from the stable control checkout.

Root cause

git rev-parse --git-common-dir can return a relative .git path; resolving it against the Python process cwd (often a branches/ worktree) produced the wrong canonical repository root and false "does not belong to the target repository" failures.

Changes

  • author_mutation_worktree.pyresolve_canonical_repo_root, resolve_author_mutation_context, assess_workspace_repo_membership; relative git-common-dir fix
  • gitea_mcp_server.py — shared _resolve_author_mutation_context; preflight/runtime workspace details include canonical root + mismatch hint
  • tests/test_workspace_guard_alignment.py — 9 regression cases (#460 acceptance criteria)
  • tests/test_create_issue_workspace_guard.py — updated wrong-repo subprocess mock

Verification

venv/bin/python -m unittest tests.test_workspace_guard_alignment tests.test_create_issue_workspace_guard tests.test_author_mutation_worktree -q
# 24 tests OK

Worktree

branches/issue-460-workspace-guard-alignment @ b33844d

## Summary Closes #460. Unifies workspace resolution between `gitea_get_runtime_context` and `verify_preflight_purity` so a valid `branches/` worktree is evaluated consistently — even when the MCP process `PROJECT_ROOT` differs from the stable control checkout. ## Root cause `git rev-parse --git-common-dir` can return a relative `.git` path; resolving it against the Python process cwd (often a `branches/` worktree) produced the wrong canonical repository root and false "does not belong to the target repository" failures. ## Changes - `author_mutation_worktree.py` — `resolve_canonical_repo_root`, `resolve_author_mutation_context`, `assess_workspace_repo_membership`; relative git-common-dir fix - `gitea_mcp_server.py` — shared `_resolve_author_mutation_context`; preflight/runtime workspace details include canonical root + mismatch hint - `tests/test_workspace_guard_alignment.py` — 9 regression cases (#460 acceptance criteria) - `tests/test_create_issue_workspace_guard.py` — updated wrong-repo subprocess mock ## Verification ```bash venv/bin/python -m unittest tests.test_workspace_guard_alignment tests.test_create_issue_workspace_guard tests.test_author_mutation_worktree -q # 24 tests OK ``` ## Worktree `branches/issue-460-workspace-guard-alignment` @ `b33844d`
jcwalker3 added 1 commit 2026-07-07 15:12:31 -05:00
Share canonical workspace/repo-root resolution between gitea_get_runtime_context
and verify_preflight_purity so valid branches/ worktrees are not rejected when
the MCP process root differs from the stable control checkout. Fix relative
git-common-dir resolution and add regression tests.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Owner

repo: Scaled-Tech-Consulting/Gitea-Tools
pr: #462
issue: none
reviewer_identity: sysadmin
profile: prgs-reviewer
session_id: 34570-a5ee6d373eec
worktree: branches/review-feat-issue-460-workspace-guard-alignment
phase: claimed
candidate_head: b33844d74a
target_branch: master
target_branch_sha: none
last_activity: 2026-07-07T21:49:47Z
expires_at: 2026-07-07T23:49:47Z
blocker: none

<!-- mcp-review-lease:v1 --> repo: Scaled-Tech-Consulting/Gitea-Tools pr: #462 issue: none reviewer_identity: sysadmin profile: prgs-reviewer session_id: 34570-a5ee6d373eec worktree: branches/review-feat-issue-460-workspace-guard-alignment phase: claimed candidate_head: b33844d74a1c3c35d279eb545f77c3ebee7000a6 target_branch: master target_branch_sha: none last_activity: 2026-07-07T21:49:47Z expires_at: 2026-07-07T23:49:47Z blocker: none
sysadmin approved these changes 2026-07-07 16:49:50 -05:00
sysadmin left a comment
Owner

Independent audit — APPROVE

Auditor: sysadmin / prgs-reviewer (not PR author jcwalker3).
Pinned HEAD: b33844d74a1c3c35d279eb545f77c3ebee7000a6

Worktree + Cleanliness

  • Fresh isolated review worktree created successfully.
  • git status clean before and after running tests.

Verification & Tests

  • Focused tests passed: pytest tests/test_workspace_guard_alignment.py tests/test_create_issue_workspace_guard.py tests/test_author_mutation_worktree.py -q -> 24 passed.
  • Focused issue lock tests passed: 12 passed.
  • Full test suite passed: pytest -> 1649 passed cleanly.
  • git diff --check passed against master.

Findings

  • The PR successfully resolves the relative-path repository membership resolution bug (#460) by introducing resolve_canonical_repo_root to correctly normalize git common-dir paths.
  • Properly aligns workspace validation behavior between verify_preflight_purity and gitea_get_runtime_context while retaining all of #449's security gates.
## Independent audit — APPROVE Auditor: `sysadmin` / `prgs-reviewer` (not PR author `jcwalker3`). Pinned HEAD: `b33844d74a1c3c35d279eb545f77c3ebee7000a6` ### Worktree + Cleanliness - Fresh isolated review worktree created successfully. - `git status` clean before and after running tests. ### Verification & Tests - Focused tests passed: `pytest tests/test_workspace_guard_alignment.py tests/test_create_issue_workspace_guard.py tests/test_author_mutation_worktree.py -q` -> 24 passed. - Focused issue lock tests passed: 12 passed. - Full test suite passed: `pytest` -> 1649 passed cleanly. - `git diff --check` passed against master. ### Findings - The PR successfully resolves the relative-path repository membership resolution bug (#460) by introducing `resolve_canonical_repo_root` to correctly normalize git common-dir paths. - Properly aligns workspace validation behavior between `verify_preflight_purity` and `gitea_get_runtime_context` while retaining all of #449's security gates.
Owner

repo: Scaled-Tech-Consulting/Gitea-Tools
pr: #462
issue: #460
reviewer_identity: sysadmin
profile: prgs-reviewer
session_id: 34570-a5ee6d373eec
worktree: /Users/jasonwalker/Development/Gitea-Tools/branches/issue-460-workspace-guard-alignment
phase: claimed
candidate_head: b33844d74a
target_branch: master
target_branch_sha: none
last_activity: 2026-07-07T21:52:47Z
expires_at: 2026-07-07T23:52:47Z
blocker: none

<!-- mcp-review-lease:v1 --> repo: Scaled-Tech-Consulting/Gitea-Tools pr: #462 issue: #460 reviewer_identity: sysadmin profile: prgs-reviewer session_id: 34570-a5ee6d373eec worktree: /Users/jasonwalker/Development/Gitea-Tools/branches/issue-460-workspace-guard-alignment phase: claimed candidate_head: b33844d74a1c3c35d279eb545f77c3ebee7000a6 target_branch: master target_branch_sha: none last_activity: 2026-07-07T21:52:47Z expires_at: 2026-07-07T23:52:47Z blocker: none
sysadmin merged commit 5dfc00319f into master 2026-07-07 16:53:07 -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#462