feat: hard-stop review mutations on already-landed PR heads (Closes #292) #368
Labels
Clear labels
allocator
anti-stomp
architecture
bug
chore
codex
concurrency
contamination
control-plane
dashboard
database
design
documentation
enhancement
gitea
glitchtip
important
incident
incident-bridge
integration
jenkins
labels
leases
mcp
mcp-health
mcp-menu
multi-project
mutating
nice-to-have
observability
portability
preflight
protected-branch
queue
read-only
reconnect
recovery
refactor
release
reliability
resumable-review
reviewer
roadmap
safety
security
self-hosted
sentry
stale-runtime
status:blocked
status:in-progress
status:pr-open
status:ready
terminal-lock
testing
tracker
type:bug
type:feature
type:feature
type:guardrail
visibility
workflow
workflow-hardening
workflow-hardening
Controller-owned work allocator
Prevent concurrent LLM session stomping
Architecture / structural design
OpenAI Codex client / workflow session surface
Concurrent session safety
Workflow or session contamination incident
MCP control-plane coordination and allocation authority
MCP operational dashboard/queue view
Internal coordination storage (SQLite/Postgres)
Design / investigation, no implementation
Docs / runbooks
New feature or improvement
Gitea MCP workflow
GlitchTip integration
Operational or process incident requiring durable audit trail
Sentry-to-Gitea incident bridging
Integration testing
Jenkins integration
Label taxonomy management
Lease adopt/release/expire lifecycle
MCP server / tooling
MCP namespace and runtime health
MCP menu surface
Work spanning multiple monitoring projects or Gitea repos
Mutating action; requires gating
Observability, metrics, traces, error reporting
Cross-platform / portability
Shared preflight gates before mutation
Protected branch / stable-branch policy concern
Work queue visibility and allocation
Read-only, no mutation
MCP client reconnect/reload recovery path
Recovery paths for stale/foreign leases
Code refactor / restructure
Release / versioning
Reliability / failure handling
Persist and resume prepared review verdicts across sessions
Reviewer workflow tooling
Roadmap / umbrella issue
Safety rails and fail-closed mutation guards
Security / trust boundary
Self-hosted infrastructure integration
Sentry error monitoring integration
Stale backend daemon / runtime-vs-master parity failures
Issue is blocked
Issue is being worked on
Issue has an open pull request
Issue is ready for work
Terminal review lock (#332) path
Tests / test coverage
Issue tracker hygiene / meta
Bug or defect
Feature or enhancement
Feature or enhancement
Safety gate or guardrail
Workflow state visibility for LLMs/operators
Cross-tool workflow
LLM workflow coordination hardening
LLM workflow coordination hardening
No labels
Milestone
No items
No Milestone
Projects
Clear projects
No projects
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: Scaled-Tech-Consulting/Gitea-Tools#368
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Summary
Closes #292.
A reviewer workflow approved PR #278 and called the merge API although the PR head was already an ancestor of
master, ending in a Gitea HTTP 405 and manual reconciliation. The #327 validator (merged as PR #348) rejects bad wording in reports that admit the landed state; what was missing is the pre-mutation gate itself and a gate-aware report check. This PR adds both.Changes
review_proofs.pyassess_already_landed_review_gate(pr_number, candidate_head_sha, target_branch, target_branch_sha, head_is_ancestor_of_target, live_head_sha=None, real_blocker=False, mergeable=None)— runs after PR selection and head pinning, before any review mutation:ALREADY_LANDED_RECONCILE_REQUIRED: approval blocked, merge API blocked, request-changes allowed only with a real blocker, reconciliation handoff required with the full field list (PR number/title, candidate head SHA, target branch, target branch SHA, ancestor proof, linked issue status, recommended reconciliation action, capability proof for close/comment mutations).NORMAL_REVIEW_CANDIDATE; mergeability/conflicts stay a separate gate.GATE_NOT_PROVEN(all mutations blocked) when the ancestry check was not run, the candidate or target SHA is not a full 40-hex SHA, the target branch is missing, or the live head no longer matches the pinned candidate head.assess_already_landed_report_state(report_text, gate_fired)— when the session's own gate fired, rejectsAPPROVED/MERGED/READY_TO_MERGEwording and requires theALREADY_LANDED_RECONCILE_REQUIREDstate. Complements the #327 text rules, which only trigger when the report itself mentions the landed state.ALREADY_LANDED_STATEandALREADY_LANDED_HANDOFF_FIELDS.tests/test_review_proofs.py—TestAlreadyLandedReviewGate(8 tests) andTestAlreadyLandedReportState(6 tests): already-landed, normal mergeable, non-mergeable normal, changed head since pin, unchecked ancestry, invalid SHAs, real-blocker request-changes, handoff field list, and all report-state verdicts including gate-not-fired passthrough.Acceptance criteria mapping (#292)
APPROVEDwhen the already-landed gate fired.Validation
python -m pytest tests/in the issue worktree (base634d8a1): 1213 passed, 1 failed, 6 skipped, 20 subtests passed.The single failure (
tests/test_agent_temp_artifacts.py::TestIssueLockArtifactWarning::test_lock_success_includes_artifact_warning) is pre-existing on the clean base with this change stashed and is tracked by issue #359 (in progress). One transient failure oftests/test_worktrees.py::TestWorktreeStart::test_accepts_issue_linked_impl_branchesappeared in a single run while a concurrent session mutated live worktrees; it passes in isolation, in its module, and in the final full-suite rerun.Overlap note: #294 asks for the identical gate plus target-SHA reporting (both included here); #295/#298 wording rules already landed via #327.
🤖 Generated with Claude Code
All tests pass successfully after merging master (1314 passed, 1 failed [pre-existing]). Reviewed the implementation of
assess_already_landed_review_gateandassess_already_landed_report_stateinreview_proofs.pyand the test coverage intests/test_review_proofs.py. It correctly blocks approvals and merges on already-landed PR heads, while requiring a proper reconciliation handoff. Verified that the remaining failure is pre-existing on master.