Reviewer mutation tools must use the active branches worktree, not stale MCP server process root #503

Closed
opened 2026-07-08 02:25:58 -05:00 by jcwalker3 · 2 comments
Owner

Problem

Reviewer mutation tools are failing closed under #274/#475 because they resolve their mutation workspace from the MCP server process root instead of the active review worktree.

In the observed PR #487 session, get_runtime_context reported:

  • MCP server process root: /Users/jasonwalker/Development/Gitea-Tools
  • Prepared clean review worktree: /Users/jasonwalker/Development/Gitea-Tools/branches/review-pr487-submit
  • Preflight with worktree path: passed
  • Mutation tools: still failed because they resolved workspace to the root checkout

The worktree_path argument appears to affect read-only/preflight reporting and lease metadata, but does not redirect mutation execution. Tools including lease acquisition, dry-run review, final decision marking, and review submission either ignore the worktree argument for execution or do not accept one at all.

Impact

  • Valid clean branches/ worktrees cannot submit formal reviews.
  • Reviewers can validate PRs but cannot post approvals/comments.
  • Sessions repeatedly fail despite correct user behavior.
  • The root checkout remains a hard blocker whenever the MCP server was launched from the control checkout.
  • This creates false PR blockers and noisy handoffs.

Required behavior

  1. Mutation tools must resolve workspace from the active task worktree, not only from MCP server process root.
  2. If mutation tools intentionally require server launch from the worktree, get_runtime_context and preflight must fail early with a clear message before any review attempt.
  3. Passing a worktree path must either:
    • fully redirect mutation workspace validation, or
    • be rejected as metadata-only with a clear error.
  4. dry_run_pr_review, mark_final_review_decision, and submit_pr_review need an explicit workspace/worktree binding check or must inherit the validated active task workspace.
  5. The error message should say exactly how to fix it:
    • relaunch/reconnect MCP server from the branches worktree, or
    • set the required environment variable, or
    • use the supported workspace-scoping mechanism.

Acceptance criteria

  1. Add tests proving reviewer mutations succeed when the active workspace is a clean branches/ worktree.
  2. Add tests proving mutations fail closed when the MCP server is rooted at the control checkout.
  3. Add tests proving preflight and mutation tools agree on the same workspace root.
  4. Add tests proving a metadata-only worktree_path cannot produce a misleading preflight_ready: true state when mutation tools will still fail.
  5. Add a canonical handoff/error message for stale MCP server workspace binding.
  6. Confirm root checkout remains protected and cannot be used for author/reviewer mutations.

Non-goals

  • Do not weaken #274/#475 branches-only mutation guards.
  • Do not allow reviewer mutations from the stable control checkout.
  • Do not bypass existing capability or lease gates.

Related

  • #274 — branches-only author mutation guard
  • #475 — hard guard preventing root checkout drift
  • #460 — branches-only guard vs runtime_context worktree resolution
  • #487 — observed failure session (if applicable)
## Problem Reviewer mutation tools are failing closed under #274/#475 because they resolve their mutation workspace from the MCP server process root instead of the active review worktree. In the observed PR #487 session, `get_runtime_context` reported: - MCP server process root: `/Users/jasonwalker/Development/Gitea-Tools` - Prepared clean review worktree: `/Users/jasonwalker/Development/Gitea-Tools/branches/review-pr487-submit` - Preflight with worktree path: passed - Mutation tools: still failed because they resolved workspace to the root checkout The `worktree_path` argument appears to affect read-only/preflight reporting and lease metadata, but does not redirect mutation execution. Tools including lease acquisition, dry-run review, final decision marking, and review submission either ignore the worktree argument for execution or do not accept one at all. ## Impact - Valid clean `branches/` worktrees cannot submit formal reviews. - Reviewers can validate PRs but cannot post approvals/comments. - Sessions repeatedly fail despite correct user behavior. - The root checkout remains a hard blocker whenever the MCP server was launched from the control checkout. - This creates false PR blockers and noisy handoffs. ## Required behavior 1. Mutation tools must resolve workspace from the active task worktree, not only from MCP server process root. 2. If mutation tools intentionally require server launch from the worktree, `get_runtime_context` and preflight must fail early with a clear message before any review attempt. 3. Passing a worktree path must either: - fully redirect mutation workspace validation, or - be rejected as metadata-only with a clear error. 4. `dry_run_pr_review`, `mark_final_review_decision`, and `submit_pr_review` need an explicit workspace/worktree binding check or must inherit the validated active task workspace. 5. The error message should say exactly how to fix it: - relaunch/reconnect MCP server from the branches worktree, or - set the required environment variable, or - use the supported workspace-scoping mechanism. ## Acceptance criteria 1. Add tests proving reviewer mutations succeed when the active workspace is a clean `branches/` worktree. 2. Add tests proving mutations fail closed when the MCP server is rooted at the control checkout. 3. Add tests proving preflight and mutation tools agree on the same workspace root. 4. Add tests proving a metadata-only `worktree_path` cannot produce a misleading `preflight_ready: true` state when mutation tools will still fail. 5. Add a canonical handoff/error message for stale MCP server workspace binding. 6. Confirm root checkout remains protected and cannot be used for author/reviewer mutations. ## Non-goals - Do not weaken #274/#475 branches-only mutation guards. - Do not allow reviewer mutations from the stable control checkout. - Do not bypass existing capability or lease gates. ## Related - #274 — branches-only author mutation guard - #475 — hard guard preventing root checkout drift - #460 — branches-only guard vs runtime_context worktree resolution - #487 — observed failure session (if applicable)
Author
Owner

Canonical Issue State

STATE: ready-for-author
WHO_IS_NEXT: author
NEXT_ACTION: Fix reviewer mutation workspace binding so tools use the active branches worktree instead of stale MCP process root
NEXT_PROMPT:

You are the author LLM fixing MCP workspace binding for reviewer mutations in Scaled-Tech-Consulting/Gitea-Tools (issue #503).

Goal: Reviewer mutation tools (lease acquire, dry_run_pr_review, mark_final_review_decision, submit_pr_review) must resolve workspace from the active task worktree, not only MCP server process root.

Observed failure: clean branches/review-pr487-submit worktree passes preflight with worktree_path, but mutations still fail because execution resolves to control checkout.

Hard rules:
1. Live identity/profile/runtime checks first.
2. Work only in a valid branches/ worktree.
3. Do not weaken #274/#475 branches-only guards.
4. Do not allow mutations from stable control checkout.
5. Do not self-review or merge.

Implementation:
- Unify workspace resolution across get_runtime_context, preflight, and mutation tools
- Either fully redirect mutation validation via worktree_path/env, or fail early with clear metadata-only error
- Add explicit binding check to dry_run_pr_review, mark_final_review_decision, submit_pr_review
- Error messages must say how to fix: relaunch MCP from worktree, set env var, or use supported scoping mechanism
- Add canonical handoff/error message for stale MCP server workspace binding

Tests:
- reviewer mutations succeed with clean branches/ worktree as active workspace
- mutations fail closed when MCP rooted at control checkout
- preflight and mutation tools agree on workspace root
- metadata-only worktree_path cannot yield misleading preflight_ready:true when mutations will fail

Run focused workspace-binding tests then broader MCP server tests.

WHAT_HAPPENED: Durable issue filed for reviewer MCP workspace-binding defect observed in PR #487 session
WHY: Valid clean review worktrees cannot submit formal reviews when MCP server launches from control checkout
RELATED_PRS: PR #487
BLOCKERS: none
VALIDATION: not yet implemented
LAST_UPDATED_BY: prgs-author / jcwalker3

## Canonical Issue State STATE: ready-for-author WHO_IS_NEXT: author NEXT_ACTION: Fix reviewer mutation workspace binding so tools use the active branches worktree instead of stale MCP process root NEXT_PROMPT: ```text You are the author LLM fixing MCP workspace binding for reviewer mutations in Scaled-Tech-Consulting/Gitea-Tools (issue #503). Goal: Reviewer mutation tools (lease acquire, dry_run_pr_review, mark_final_review_decision, submit_pr_review) must resolve workspace from the active task worktree, not only MCP server process root. Observed failure: clean branches/review-pr487-submit worktree passes preflight with worktree_path, but mutations still fail because execution resolves to control checkout. Hard rules: 1. Live identity/profile/runtime checks first. 2. Work only in a valid branches/ worktree. 3. Do not weaken #274/#475 branches-only guards. 4. Do not allow mutations from stable control checkout. 5. Do not self-review or merge. Implementation: - Unify workspace resolution across get_runtime_context, preflight, and mutation tools - Either fully redirect mutation validation via worktree_path/env, or fail early with clear metadata-only error - Add explicit binding check to dry_run_pr_review, mark_final_review_decision, submit_pr_review - Error messages must say how to fix: relaunch MCP from worktree, set env var, or use supported scoping mechanism - Add canonical handoff/error message for stale MCP server workspace binding Tests: - reviewer mutations succeed with clean branches/ worktree as active workspace - mutations fail closed when MCP rooted at control checkout - preflight and mutation tools agree on workspace root - metadata-only worktree_path cannot yield misleading preflight_ready:true when mutations will fail Run focused workspace-binding tests then broader MCP server tests. ``` WHAT_HAPPENED: Durable issue filed for reviewer MCP workspace-binding defect observed in PR #487 session WHY: Valid clean review worktrees cannot submit formal reviews when MCP server launches from control checkout RELATED_PRS: PR #487 BLOCKERS: none VALIDATION: not yet implemented LAST_UPDATED_BY: prgs-author / jcwalker3
Author
Owner

Status: Reconciled / terminal

Summary

  • Issue #503 is already closed.
  • PR #508 is closed unmerged as superseded.
  • PR #512 merged and closed Issue #510.
  • Issue #510 implemented namespace-aware workspace binding through namespace_workspace_binding.py and verify_preflight_purity_resolve_namespace_mutation_context.
  • #510 / #512 subsume #503 AC1–AC6.
  • Merging #508 would reintroduce duplicate narrower reviewer-only logic, so leaving #508 closed unmerged is correct.
  • No action is needed on #503.

Mutation ledger

  • This comment is documentation-only.
  • No issue close/reopen was performed.
  • No PR merge/close/reopen was performed.
  • PR #493 was untouched.

Next state

  • #503 remains closed.
  • #508 remains closed unmerged as superseded.
  • #510 remains closed.
  • #512 remains merged.
  • Resume #493 separately only after a fresh live refetch confirms it is still open and still conflicted.
## Status: Reconciled / terminal ### Summary - Issue **#503** is already **closed**. - **PR #508** is **closed unmerged** as superseded. - **PR #512** merged and closed **Issue #510**. - Issue **#510** implemented namespace-aware workspace binding through `namespace_workspace_binding.py` and `verify_preflight_purity` → `_resolve_namespace_mutation_context`. - **#510 / #512** subsume **#503** AC1–AC6. - Merging **#508** would reintroduce duplicate narrower reviewer-only logic, so leaving **#508** closed unmerged is correct. - **No action is needed on #503.** ### Mutation ledger - This comment is **documentation-only**. - No issue close/reopen was performed. - No PR merge/close/reopen was performed. - **PR #493** was untouched. ### Next state - **#503** remains closed. - **#508** remains closed unmerged as superseded. - **#510** remains closed. - **#512** remains merged. - Resume **#493** separately only after a fresh live refetch confirms it is still open and still conflicted.
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

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