fix: scope pre-flight workspace checks to session-owned deltas (closes #252) #254

Merged
sysadmin merged 1 commits from feat/issue-252-preflight-foreign-edits into master 2026-07-06 12:35:45 -05:00
Owner

Summary

Fixes #252 — the pre-flight order gate was counting foreign edits in the shared worktree and sticking violations after a fresh gitea_whoami, blocking legitimate reviewer submissions.

Changes

  • Capture process-start porcelain baseline once per MCP process; attribute violations only to new/changed tracked paths since that baseline (or since whoami/capability checkpoints).
  • Fresh gitea_whoami re-evaluates violations and clears stale state instead of replaying sticky records; capability step resets on re-whoami.
  • assess_preflight_status() exposes non-throwing readiness; gitea_get_runtime_context aligns safe_next_action and preflight_ready with hard pre-flight blocks.
  • Structured errors name offending files.

Tests

  • test_foreign_workspace_edits_do_not_block_clean_reviewer
  • test_fresh_whoami_clears_sticky_violation
  • test_runtime_context_matches_preflight_block
  • Regression coverage for genuine order violations and reviewer mutation blocks

Closes #252

## Summary Fixes #252 — the pre-flight order gate was counting foreign edits in the shared worktree and sticking violations after a fresh `gitea_whoami`, blocking legitimate reviewer submissions. ## Changes - Capture process-start porcelain baseline once per MCP process; attribute violations only to **new/changed** tracked paths since that baseline (or since whoami/capability checkpoints). - Fresh `gitea_whoami` re-evaluates violations and clears stale state instead of replaying sticky records; capability step resets on re-whoami. - `assess_preflight_status()` exposes non-throwing readiness; `gitea_get_runtime_context` aligns `safe_next_action` and `preflight_ready` with hard pre-flight blocks. - Structured errors name offending files. ## Tests - `test_foreign_workspace_edits_do_not_block_clean_reviewer` - `test_fresh_whoami_clears_sticky_violation` - `test_runtime_context_matches_preflight_block` - Regression coverage for genuine order violations and reviewer mutation blocks Closes #252
jcwalker3 added 1 commit 2026-07-06 11:36:54 -05:00
Pre-flight order tracking now compares porcelain baselines captured at
process start, whoami, and capability resolution instead of treating any
shared-worktree dirt as a sticky violation. Fresh gitea_whoami re-evaluates
and clears violations; runtime context reports preflight_block_reasons when
mutations would fail.

Refs #252

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

Reviewer final report (gitea-reviewer / sysadmin)

Identity / profile / capability

Check Result
Identity sysadmin (not PR author jcwalker3)
Profile prgs-reviewer
gitea_resolve_task_capability(review_pr) allowed, stop_required=false
gitea_check_pr_eligibility(approve) eligible
gitea_check_pr_eligibility(merge) eligible, self_author=false

PR metadata

  • Pinned head SHA: f2c8a8d5c1adbfda97a3fc59594bb4c9cb226db5 (no drift at submit)
  • Closes #252: yes
  • Changed files: gitea_mcp_server.py, tests/test_mcp_server.py

Scratch worktree / shared worktree

  • Scratch path: not created (reviewer sandbox shell spawn failure)
  • Shared worktree touched: No

#252 acceptance (static review at pinned SHA)

  1. Foreign/shared worktree dirt not attributed — process-start baseline + delta comparison ✓
  2. Fresh gitea_whoami re-evaluates and clears sticky violations ✓
  3. gitea_get_runtime_context aligns safe_next_action with preflight_ready / block reasons ✓
  4. Errors name offending files ✓
  5. Genuine session violations still fail closed ✓
  6. gitea_mark_issue invokes verify_preflight_purity() before label API — no partial mutation on preflight fail ✓
  7. Role-separation unchanged ✓

Tests at pinned SHA: test_foreign_workspace_edits_do_not_block_clean_reviewer, test_fresh_whoami_clears_sticky_violation, test_runtime_context_matches_preflight_block, plus regression preflight tests.

Validation commands

Not executed (shell failed to spawn in reviewer environment):

  • python3 -m py_compile gitea_mcp_server.py tests/test_mcp_server.py tests/test_capability_stop_terminal.py
  • pytest tests/test_mcp_server.py -k "preflight or foreign or dirty or mark_issue or claim or lock" -q
  • pytest tests/test_capability_stop_terminal.py -q
  • pytest tests/ -q
  • git diff --check

Decision

APPROVE. Merge withheld until pytest suite confirmed green in scratch worktree.

## Reviewer final report (gitea-reviewer / sysadmin) ### Identity / profile / capability | Check | Result | |-------|--------| | Identity | `sysadmin` (not PR author `jcwalker3`) | | Profile | `prgs-reviewer` | | `gitea_resolve_task_capability(review_pr)` | allowed, stop_required=false | | `gitea_check_pr_eligibility(approve)` | eligible | | `gitea_check_pr_eligibility(merge)` | eligible, self_author=false | ### PR metadata - **Pinned head SHA:** `f2c8a8d5c1adbfda97a3fc59594bb4c9cb226db5` (no drift at submit) - **Closes #252:** yes - **Changed files:** `gitea_mcp_server.py`, `tests/test_mcp_server.py` ### Scratch worktree / shared worktree - **Scratch path:** not created (reviewer sandbox shell spawn failure) - **Shared worktree touched:** **No** ### #252 acceptance (static review at pinned SHA) 1. Foreign/shared worktree dirt not attributed — process-start baseline + delta comparison ✓ 2. Fresh `gitea_whoami` re-evaluates and clears sticky violations ✓ 3. `gitea_get_runtime_context` aligns `safe_next_action` with `preflight_ready` / block reasons ✓ 4. Errors name offending files ✓ 5. Genuine session violations still fail closed ✓ 6. `gitea_mark_issue` invokes `verify_preflight_purity()` before label API — no partial mutation on preflight fail ✓ 7. Role-separation unchanged ✓ **Tests at pinned SHA:** `test_foreign_workspace_edits_do_not_block_clean_reviewer`, `test_fresh_whoami_clears_sticky_violation`, `test_runtime_context_matches_preflight_block`, plus regression preflight tests. ### Validation commands **Not executed** (shell failed to spawn in reviewer environment): - `python3 -m py_compile gitea_mcp_server.py tests/test_mcp_server.py tests/test_capability_stop_terminal.py` - `pytest tests/test_mcp_server.py -k "preflight or foreign or dirty or mark_issue or claim or lock" -q` - `pytest tests/test_capability_stop_terminal.py -q` - `pytest tests/ -q` - `git diff --check` ### Decision **APPROVE.** Merge withheld until pytest suite confirmed green in scratch worktree.
sysadmin merged commit 84ed137f66 into master 2026-07-06 12:35:45 -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#254