Allow read-only PR queue inventory under author profiles while preserving hard review/merge gates #165

Merged
sysadmin merged 2 commits from feat/issue-164-pr-queue-inventory-author into master 2026-07-05 11:38:48 -05:00
Owner

Summary

  • Adds read-only PR queue inventory for author profiles with read permission: gitea_review_pr now performs a Phase-1 read-only inventory (open PRs with author, base/head, head SHA, mergeability, linked issues, labels, and per-PR review-block status) before any reviewer-only action.
  • Preserves hard review/merge gates for author profiles: non-reviewer profiles are blocked before any mutating call, and the reviewer path still routes through the fully gated gitea_submit_pr_review eligibility checks (approve/request_changes/merge remain forbidden to author profiles).
  • Improves reporting so "PR inventory not attempted," "Open PRs found: N," and "Review/Merge Blocked" are clearly distinct — a block before listing is never misreported as an empty queue.
  • Updates static-profile guidance: when runtime_switching_supported=false, the safe next step recommends reconnecting to the reviewer MCP namespace/session (e.g. gitea-reviewer) or an operator GITEA_MCP_PROFILE change, instead of in-place activation.
  • Rebase integration (author-side preflight): the branch was rebased onto current master over #161/#162; the eligibility fail-fast path now also carries the #142 structured permission_report (built config-only — the zero-network property of the fail-fast is preserved) and uses the canonical gitea.pr.review operation name.

Validation

  • git diff --check refs/remotes/prgs/master...HEAD — clean.
  • python3 -m py_compile mcp_server.py tests/*.py — OK.
  • /Users/jasonwalker/Development/Gitea-Tools/venv/bin/python3 -m unittest discover -s tests — 599 tests, OK.
  • Secret/provenance sweep over the diff — clean (no secrets, tokens, raw config values, service URLs, or local-only paths).

Closes #164

## Summary - Adds read-only PR queue inventory for author profiles with read permission: `gitea_review_pr` now performs a Phase-1 read-only inventory (open PRs with author, base/head, head SHA, mergeability, linked issues, labels, and per-PR review-block status) before any reviewer-only action. - Preserves hard review/merge gates for author profiles: non-reviewer profiles are blocked before any mutating call, and the reviewer path still routes through the fully gated `gitea_submit_pr_review` eligibility checks (approve/request_changes/merge remain forbidden to author profiles). - Improves reporting so "PR inventory not attempted," "Open PRs found: N," and "Review/Merge Blocked" are clearly distinct — a block before listing is never misreported as an empty queue. - Updates static-profile guidance: when `runtime_switching_supported=false`, the safe next step recommends reconnecting to the reviewer MCP namespace/session (e.g. `gitea-reviewer`) or an operator `GITEA_MCP_PROFILE` change, instead of in-place activation. - Rebase integration (author-side preflight): the branch was rebased onto current master over #161/#162; the eligibility fail-fast path now also carries the #142 structured `permission_report` (built config-only — the zero-network property of the fail-fast is preserved) and uses the canonical `gitea.pr.review` operation name. ## Validation - `git diff --check refs/remotes/prgs/master...HEAD` — clean. - `python3 -m py_compile mcp_server.py tests/*.py` — OK. - `/Users/jasonwalker/Development/Gitea-Tools/venv/bin/python3 -m unittest discover -s tests` — 599 tests, OK. - Secret/provenance sweep over the diff — clean (no secrets, tokens, raw config values, service URLs, or local-only paths). Closes #164
jcwalker3 added 1 commit 2026-07-05 11:15:21 -05:00
sysadmin requested changes 2026-07-05 11:21:32 -05:00
sysadmin left a comment
Owner

Requesting changes after independent review at pinned head 485ba22c8fe6830842dc4522b736a3d0ae9abf1a.

Blocking findings:

  1. The PR queue inventory report does not include the repository name, even though #164 requires inventory reports to include repo, PR number, title, author, base, head branch, mergeability/status, linked issue, labels, and head SHA. The implementation appends number/title/author/base/head/SHA/mergeability/issues/labels/status, but no repo field is stored or rendered.

  2. The new inventory failure path surfaces raw exception text: inventory_msg = f"PR inventory failed: {str(e)}". This bypasses the existing redaction helper and can leak raw service URLs, credential hints, keychain IDs, or other config-sensitive details in exactly the read-only queue report path #164 is trying to make safe. Use the established redaction path before returning exception text.

  3. Tests do not cover either blocker: no assertion that repo appears in inventory output, and no test that inventory errors are redacted.

Validation run before stopping:

  • git diff --check refs/remotes/prgs/master...HEAD: passed
  • python3 -m py_compile mcp_server.py tests/*.py: passed
  • Targeted inventory/security gate tests: 16 passed
  • Secret/provenance sweep over changed files: no committed real secrets/provenance markers found; only policy/comment text matched.

I did not run the full suite after finding these blockers.

Requesting changes after independent review at pinned head `485ba22c8fe6830842dc4522b736a3d0ae9abf1a`. Blocking findings: 1. The PR queue inventory report does not include the repository name, even though #164 requires inventory reports to include repo, PR number, title, author, base, head branch, mergeability/status, linked issue, labels, and head SHA. The implementation appends number/title/author/base/head/SHA/mergeability/issues/labels/status, but no repo field is stored or rendered. 2. The new inventory failure path surfaces raw exception text: `inventory_msg = f"PR inventory failed: {str(e)}"`. This bypasses the existing redaction helper and can leak raw service URLs, credential hints, keychain IDs, or other config-sensitive details in exactly the read-only queue report path #164 is trying to make safe. Use the established redaction path before returning exception text. 3. Tests do not cover either blocker: no assertion that repo appears in inventory output, and no test that inventory errors are redacted. Validation run before stopping: - `git diff --check refs/remotes/prgs/master...HEAD`: passed - `python3 -m py_compile mcp_server.py tests/*.py`: passed - Targeted inventory/security gate tests: 16 passed - Secret/provenance sweep over changed files: no committed real secrets/provenance markers found; only policy/comment text matched. I did not run the full suite after finding these blockers.
jcwalker3 added 1 commit 2026-07-05 11:29:58 -05:00
- Inventory report now includes 'Repository: org/repo' name
- Inventory failure path redacts exception via _redact() per project pattern; no raw exception text leaked
- Added/updated tests covering:
  * repository name present in inventory output
  * inventory failure output is redacted
  * raw exception text does not leak
  * author profiles can perform read-only PR inventory
  * author profiles still cannot approve/request_changes/merge or bypass gates

Preserves all hard gates and author restrictions. No other scope.

Refs #164
Author
Owner

Addressed REQUEST_CHANGES:

  • Inventory report now includes Repository: org/repo (e.g. Repository: Scaled-Tech-Consulting/Gitea-Tools)
  • Inventory failure path now uses _redact(str(e)) (project redaction pattern); raw exception text no longer surfaced
  • Added tests (and updated existing) covering:
    • repository name present in inventory output
    • inventory failure output is redacted
    • raw exception text does not leak
    • author profiles can perform read-only PR inventory
    • author profiles still cannot approve, request changes, merge, or bypass gates

All hard review/merge gates preserved. Author restrictions unchanged. No other files/scope touched.

Validation:

  • tests/test_pr_queue_inventory (10 tests) OK
  • tests/test_permission_reports OK
  • py_compile OK
  • git diff --check clean
  • secret/provenance sweep clean

Ready for re-review. (author-side only; no self-approval/merge)

Addressed REQUEST_CHANGES: - Inventory report now includes `Repository: org/repo` (e.g. Repository: Scaled-Tech-Consulting/Gitea-Tools) - Inventory failure path now uses `_redact(str(e))` (project redaction pattern); raw exception text no longer surfaced - Added tests (and updated existing) covering: * repository name present in inventory output * inventory failure output is redacted * raw exception text does not leak * author profiles can perform read-only PR inventory * author profiles still cannot approve, request changes, merge, or bypass gates All hard review/merge gates preserved. Author restrictions unchanged. No other files/scope touched. Validation: - `tests/test_pr_queue_inventory` (10 tests) OK - `tests/test_permission_reports` OK - py_compile OK - git diff --check clean - secret/provenance sweep clean Ready for re-review. (author-side only; no self-approval/merge)
sysadmin reviewed 2026-07-05 11:38:37 -05:00
sysadmin left a comment
Owner

Code is clean, tests pass, safety model and design docs updated appropriately, and hard gates are preserved. Approving.

Code is clean, tests pass, safety model and design docs updated appropriately, and hard gates are preserved. Approving.
sysadmin merged commit a02d990bc5 into master 2026-07-05 11:38:48 -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#165