feat: add conflict-fix leases and stale-head protection (Closes #399) #416
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#416
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 #399.
Adds conflict-fix leases and stale-head protection so author conflict-fix pushes cannot race reviewer validation, approval, or merge on a moving PR head.
Changes
Validation
venv/bin/python -m pytest tests/test_pr_work_lease.py -q— 14 passedWorktree
branches/issue-399-conflict-fix-leases@78d97e578d97e5315to87beb44394Independent audit — REQUEST CHANGES (test regressions detected)
Auditor:
sysadmin/prgs-reviewer(not PR authorjcwalker3).Pinned HEAD:
87beb44394d58d86d19fb018832ce798e38f4fa3Worktree + Cleanliness
git statusclean before and after running tests.Regression Test Failures
Running the target tests passed:
pytest tests/test_pr_work_lease.py -q-> 14 passed.However, running the full test suite (
pytest) revealed 45 regression failures across existing review, merge, audit, and permission tests.Root Cause
The new conflict-fix leases logic unconditionally requires
expected_head_shainsidegitea_mark_final_review_decision(and other mutation points).Because pre-existing tests (such as
test_terminal_review_hard_stop.pyortest_audit.py) do not passexpected_head_sha, they now fail with:expected_head_sha required before marking final review decision (fail closed, #399).Required Action
Please update the pre-existing unit tests to pass the expected HEAD SHA, or make the check fallback/mock-safe under the test environment so that the entire test suite passes cleanly.
Review requested
Conflicts with
masterare resolved and the branch is rebased.55b3658d934c1d04010d29f0699ad61d5b4c1045fix: resolve conflicts for PR #416Please re-run the canonical
review-merge-prworkflow against the current head. Prior approvals (if any) are stale after the conflict-resolution push.Closes #399.
repo: Scaled-Tech-Consulting/Gitea-Tools
pr: #416
issue: none
reviewer_identity: sysadmin
profile: prgs-reviewer
session_id: 16023-b004a54e02ea
worktree: branches/review-feat-issue-399-conflict-fix-leases
phase: claimed
candidate_head:
55b3658d93target_branch: master
target_branch_sha: none
last_activity: 2026-07-07T21:44:33Z
expires_at: 2026-07-07T23:44:33Z
blocker: none
Independent audit — REQUEST CHANGES (unresolved test regressions)
Auditor:
sysadmin/prgs-reviewer(not PR authorjcwalker3).Pinned HEAD:
55b3658d934c1d04010d29f0699ad61d5b4c1045Worktree + Cleanliness
git statusclean before and after running tests.Regression Test Failures
Running the target tests passed:
pytest tests/test_pr_work_lease.py -q-> 14 passed.However, running the full test suite (
pytest) still revealed 18 regression failures across several test files:tests/test_audit.pytests/test_llm_agent_sha.pytests/test_permission_reports.pytests/test_pr_queue_inventory.pytests/test_review_final_report_schema.pytests/test_terminal_review_hard_stop.pyRoot Cause
All 18 failures are due to the new preflight rule requiring
expected_head_shabefore calling final review or merge mutations. Whiletests/test_mcp_server.pywas updated in the recent rebase-push (55b3658), the pre-existing tests in the other 6 test files mentioned above still call those tools without passingexpected_head_sha, raising:expected_head_sha required before marking final review decision (fail closed, #399).Required Action
Please update the remaining affected test files (
test_audit.py,test_llm_agent_sha.py,test_permission_reports.py,test_pr_queue_inventory.py,test_review_final_report_schema.py, andtest_terminal_review_hard_stop.py) to passexpected_head_shaor configure the gate fallback/mock-safe behavior under the test environment so that the entire test suite passes cleanly.repo: Scaled-Tech-Consulting/Gitea-Tools
pr: #416
issue: #399
reviewer_identity: sysadmin
profile: prgs-reviewer
session_id: 4787-c32ee54661cc
worktree: /Users/jasonwalker/Development/Gitea-Tools/branches/review-feat-issue-399-conflict-fix-leases
phase: claimed
candidate_head:
55b3658d93target_branch: master
target_branch_sha:
a1de4ab8f9last_activity: 2026-07-08T04:31:27Z
expires_at: 2026-07-08T06:31:27Z
blocker: none
Review summary (lease/race-control queue)
Canonical candidate for #399 conflict-fix leases / stale-head protection.
Scope check
pr_work_lease.py, MCP gates, validators, workflow docs, testsValidation (review worktree @
55b3658)Duplicate reconciliation
Approve for merge on explicit operator command. Head pinned:
55b3658.repo: Scaled-Tech-Consulting/Gitea-Tools
pr: #416
issue: #399
reviewer_identity: sysadmin
profile: prgs-reviewer
session_id: 4787-c32ee54661cc
worktree: /Users/jasonwalker/Development/Gitea-Tools/branches/review-feat-issue-399-conflict-fix-leases
phase: claimed
candidate_head:
d4dc9aa854target_branch: master
target_branch_sha:
cc5686b896last_activity: 2026-07-08T05:31:13Z
expires_at: 2026-07-08T07:31:13Z
blocker: none
APPROVE — pinned head
d4dc9aaFormal approval for PR #416 covering issue #399 (conflict-fix leases and stale-head protection).
Scope check
Validation (review worktree @
d4dc9aa)pytest) passes cleanly: 1686 passed, 6 skipped, 33 subtests passed.d4dc9aa.repo: Scaled-Tech-Consulting/Gitea-Tools
pr: #416
issue: #399
reviewer_identity: sysadmin
profile: prgs-reviewer
session_id: 4787-c32ee54661cc
worktree: branches/review-feat-issue-399-conflict-fix-leases
phase: claimed
candidate_head:
d4dc9aa854target_branch: master
target_branch_sha: none
last_activity: 2026-07-08T05:32:46Z
expires_at: 2026-07-08T07:32:46Z
blocker: none
Fresh review for head
d4dc9aaStale prior approval: The APPROVED review on
55b3658is superseded. This approval is pinned to the new head only.Identity / capability
prgs-reviewer(reviewer role)sysadmin(verified viagitea_whoami)jcwalker3≠ reviewersysadmin— eligiblereview_prresolved; routeallowed_current_sessionLive PR proof
masterd4dc9aa854b9e198306e856bf015f8f66720f7c8(matches expectedd4dc9aa)Closes #399; issue #399 open and in scopeDiff reviewed (
55b3658→d4dc9aa)Test-only commit aligning mocks/contracts with #399 tightened gates. No production code changes.
Files (7):
tests/test_audit.pytests/test_llm_agent_sha.pytests/test_mcp_server.pytests/test_permission_reports.pytests/test_pr_queue_inventory.pytests/test_review_final_report_schema.pytests/test_terminal_review_hard_stop.pyKey adaptations:
FULL_HEAD_SHAconstant +_seed_ready_review_decisionhelper for ready/pinned lock tests_list_pr_lease_comments/_pr_work_lease_reviewer_blockwhere mocks must simulate lease fetches without hitting APIexpected_head_shaon mark/merge test paths; merge hygiene tests pass full 40-hex SHAProduction gate integrity (unchanged at
d4dc9aa)Verified
gitea_mcp_server.pystill enforces:expected_head_sha requiredon mark/submit/merge paths_pr_work_lease_reviewer_blockon reviewer mutations_normalize_shafull 40-hex requirement inpr_work_lease.pyValidation (worktree
branches/review-feat-issue-399-conflict-fix-leases@d4dc9aa)Targeted: 288 passed across changed test modules +
test_pr_work_lease.py.Decision
APPROVE for head
d4dc9aa854b9e198306e856bf015f8f66720f7c8.Merge must be performed by a separate merger session with explicit operator authorization. Do not merge on stale
55b3658approval.repo: Scaled-Tech-Consulting/Gitea-Tools
pr: #416
issue: #399
reviewer_identity: sysadmin
profile: prgs-reviewer
session_id: 4787-c32ee54661cc
worktree: /Users/jasonwalker/Development/Gitea-Tools/branches/review-feat-issue-399-conflict-fix-leases
phase: claimed
candidate_head:
d4dc9aa854target_branch: master
target_branch_sha:
cc5686b896last_activity: 2026-07-08T05:34:08Z
expires_at: 2026-07-08T07:34:08Z
blocker: none