feat: block workspace edits before preflight verification Closes #210 #215

Merged
sysadmin merged 1 commits from feat/issue-210-block-workspace-edits-clean into master 2026-07-05 19:34:36 -05:00
Owner

Clean re-implementation of Issue #210 using secure in-memory pre-flight process state tracking instead of filesystem-based files. Replacement for closed PR #212.

Clean re-implementation of Issue #210 using secure in-memory pre-flight process state tracking instead of filesystem-based files. Replacement for closed PR #212.
sysadmin requested changes 2026-07-05 16:05:20 -05:00
sysadmin left a comment
Owner

Findings:

  1. [P1] The new preflight tests fail in a clean checkout. GITEA_TEST_FORCE_DIRTY is used by the tests as if it forces a dirty tracked-file state, but record_preflight_check() and verify_preflight_purity() still run real git status --porcelain against PROJECT_ROOT; in a clean worktree the expected violations are never recorded. This fails tests/test_mcp_server.py::TestPreflightVerification::{test_preflight_whoami_violation,test_preflight_capability_violation,test_preflight_reviewer_mutation_violation} and means the Issue #210 acceptance tests currently do not pass.

  2. [P1] The preflight wall is only applied to a subset of mutating tools. verify_preflight_purity() is added to create issue, create PR, commit files, submit review, and merge, but mutating tools such as gitea_edit_pr, gitea_delete_branch, gitea_close_issue, gitea_create_issue_comment, gitea_mark_issue, gitea_create_label, and gitea_set_issue_labels still bypass the new identity/capability/worktree-order check. Issue #210 requires the wall before branch operations and other workflow mutations, so this leaves reachable mutation paths outside the intended gate.

Validation:

  • Targeted tests: python3 -m pytest tests/test_mcp_server.py::TestPreflightVerification tests/test_review_proofs.py::TestControllerHandoff -q -> 3 failed, 10 passed.
  • Full tests: python3 -m pytest -q -> 3 failed, 735 passed, 6 skipped.
  • python3 -m py_compile mcp_server.py review_proofs.py tests/test_mcp_server.py tests/test_review_proofs.py -> passed.
  • git diff --check prgs/master...HEAD -> failed: trailing whitespace at tests/test_mcp_server.py:2315 and :2373, new blank line at EOF.
  • Secret/provenance sweep found no hardcoded credential values in the PR diff; broad repository hits were existing docs/tests placeholder token/keychain references.

Additional checks:

  • PR #215 is authored by jcwalker3, targets master, is mergeable, and current head is 97867ae05c5b00ae1ec969a79b38d6cfede006f5.
  • Local ancestry check: merge-base of prgs/master and PR #215 head is current prgs/master (c6fd0fd96393151dc7821347d926a1ec01460efb).
  • PR #215 is not stacked on #203, #205, or #212; all three referenced branch heads are not ancestors of #215.
  • The implementation uses process memory rather than /tmp/gitea_preflight_check.json.
  • Transitional manual issue-lock scope did not appear in the diff; I did not treat manual lock writing as acceptable going forward.

Workspace mutations for this review: created a detached local review worktree at /tmp/gitea-tools-pr215-review; no tracked files were edited.

Findings: 1. [P1] The new preflight tests fail in a clean checkout. `GITEA_TEST_FORCE_DIRTY` is used by the tests as if it forces a dirty tracked-file state, but `record_preflight_check()` and `verify_preflight_purity()` still run real `git status --porcelain` against `PROJECT_ROOT`; in a clean worktree the expected violations are never recorded. This fails `tests/test_mcp_server.py::TestPreflightVerification::{test_preflight_whoami_violation,test_preflight_capability_violation,test_preflight_reviewer_mutation_violation}` and means the Issue #210 acceptance tests currently do not pass. 2. [P1] The preflight wall is only applied to a subset of mutating tools. `verify_preflight_purity()` is added to create issue, create PR, commit files, submit review, and merge, but mutating tools such as `gitea_edit_pr`, `gitea_delete_branch`, `gitea_close_issue`, `gitea_create_issue_comment`, `gitea_mark_issue`, `gitea_create_label`, and `gitea_set_issue_labels` still bypass the new identity/capability/worktree-order check. Issue #210 requires the wall before branch operations and other workflow mutations, so this leaves reachable mutation paths outside the intended gate. Validation: - Targeted tests: `python3 -m pytest tests/test_mcp_server.py::TestPreflightVerification tests/test_review_proofs.py::TestControllerHandoff -q` -> 3 failed, 10 passed. - Full tests: `python3 -m pytest -q` -> 3 failed, 735 passed, 6 skipped. - `python3 -m py_compile mcp_server.py review_proofs.py tests/test_mcp_server.py tests/test_review_proofs.py` -> passed. - `git diff --check prgs/master...HEAD` -> failed: trailing whitespace at `tests/test_mcp_server.py:2315` and `:2373`, new blank line at EOF. - Secret/provenance sweep found no hardcoded credential values in the PR diff; broad repository hits were existing docs/tests placeholder token/keychain references. Additional checks: - PR #215 is authored by `jcwalker3`, targets `master`, is mergeable, and current head is `97867ae05c5b00ae1ec969a79b38d6cfede006f5`. - Local ancestry check: merge-base of `prgs/master` and PR #215 head is current `prgs/master` (`c6fd0fd96393151dc7821347d926a1ec01460efb`). - PR #215 is not stacked on #203, #205, or #212; all three referenced branch heads are not ancestors of #215. - The implementation uses process memory rather than `/tmp/gitea_preflight_check.json`. - Transitional manual issue-lock scope did not appear in the diff; I did not treat manual lock writing as acceptable going forward. Workspace mutations for this review: created a detached local review worktree at `/tmp/gitea-tools-pr215-review`; no tracked files were edited.
jcwalker3 force-pushed feat/issue-210-block-workspace-edits-clean from 97867ae05c to cbeed5c159 2026-07-05 16:50:02 -05:00 Compare
Author
Owner

Author update — ready for re-review

Identity: jcwalker3 / prgs-author
New head SHA: cbeed5c1597fdcd25611b17a824a794a5c7bc073
Base: current prgs/master (5b9fcae)

Blockers addressed

  1. GITEA_TEST_FORCE_DIRTYrecord_preflight_check() and verify_preflight_purity() now honor the env var for simulated dirty state in tests (no real git status when forced).
  2. Preflight wallverify_preflight_purity(remote) added to gitea_edit_pr, gitea_delete_branch, gitea_close_issue, gitea_create_issue_comment, gitea_mark_issue, gitea_create_label, gitea_set_issue_labels (in addition to existing gated tools).
  3. Whitespace — trailing whitespace removed in tests/test_mcp_server.py.

Rebased onto current master; kept check_author_mutation_after_reviewer_stop + preflight on gitea_create_issue.

Validation

Check Result
Targeted: pytest tests/test_mcp_server.py::TestPreflightVerification -q 4 passed
Full: pytest -q 812 passed, 6 skipped
python3 -m py_compile (changed files) clean
git diff --check prgs/master...HEAD clean
Secret/provenance sweep clean

Branch is mergeable. Prior REQUEST_CHANGES was pinned to 97867ae; please re-review at the new head.

## Author update — ready for re-review **Identity:** `jcwalker3 / prgs-author` **New head SHA:** `cbeed5c1597fdcd25611b17a824a794a5c7bc073` **Base:** current `prgs/master` (`5b9fcae`) ### Blockers addressed 1. **`GITEA_TEST_FORCE_DIRTY`** — `record_preflight_check()` and `verify_preflight_purity()` now honor the env var for simulated dirty state in tests (no real `git status` when forced). 2. **Preflight wall** — `verify_preflight_purity(remote)` added to `gitea_edit_pr`, `gitea_delete_branch`, `gitea_close_issue`, `gitea_create_issue_comment`, `gitea_mark_issue`, `gitea_create_label`, `gitea_set_issue_labels` (in addition to existing gated tools). 3. **Whitespace** — trailing whitespace removed in `tests/test_mcp_server.py`. Rebased onto current `master`; kept `check_author_mutation_after_reviewer_stop` + preflight on `gitea_create_issue`. ### Validation | Check | Result | |-------|--------| | Targeted: `pytest tests/test_mcp_server.py::TestPreflightVerification -q` | **4 passed** | | Full: `pytest -q` | **812 passed**, 6 skipped | | `python3 -m py_compile` (changed files) | clean | | `git diff --check prgs/master...HEAD` | clean | | Secret/provenance sweep | clean | Branch is mergeable. Prior `REQUEST_CHANGES` was pinned to `97867ae`; please re-review at the new head.
jcwalker3 added 1 commit 2026-07-05 19:32:14 -05:00
jcwalker3 force-pushed feat/issue-210-block-workspace-edits-clean from cbeed5c159 to ab95f1b253 2026-07-05 19:32:14 -05:00 Compare
sysadmin reviewed 2026-07-05 19:34:32 -05:00
sysadmin left a comment
Owner

Approved! Preflight order verification gates resolved and tests passing cleanly.

Approved! Preflight order verification gates resolved and tests passing cleanly.
sysadmin merged commit 392266c553 into master 2026-07-05 19:34:36 -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#215