feat(lease): guarded cleanup for obsolete reviewer comment leases (Closes #691) #692
Merged
sysadmin
merged 1 commits from 2026-07-12 22:28:59 -05:00
fix/issue-691-obsolete-reviewer-lease-cleanup into master
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#692
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 #691. Adds a guarded, non-owner cleanup path for comment-backed reviewer leases that remain after formal terminal review on a superseded head (and/or after recorded expiry), without a control-plane DB
lease_id.Reproduces the PR #688 / lease comment 10749 class of defect: completed REQUEST_CHANGES on head A, author pushes head B, foreign lease stays pinned to A; diagnosis previously prescribed indefinite
waitonly.Design
Cleanup tool
gitea_cleanup_obsolete_reviewer_comment_leaseapply=false)controller_recovery_authorized=trueCLEANUP OBSOLETE REVIEWER LEASE <pr_number>assess_obsolete_reviewer_comment_lease_cleanupphase: releasedlease marker + canonical audit commentEligibility matrix (all required evidence)
Diagnosis (#599 extended)
gitea_diagnose_reviewer_pr_lease_handoffnow distinguishes:foreign_active_current_head→ waitforeign_expired_current_head/orphaned_owner_missing→ cleanup when safeforeign_completed_superseded_head/foreign_expired_superseded_head→ cleanup_obsolete_reviewer_comment_lease (not indefinite wait)ambiguous_conflicting_evidence→ fail closedExplicit non-goals
Validation
compileall: OK6d86db793bbdfaed16bd54d93171f1dd66f234caNext role
Independent REVIEWER — do not self-review or merge.
Canonical Issue State
STATE: ready-for-review
WHO_IS_NEXT: reviewer
NEXT_ACTION: Independent REVIEWER validates this PR against #691 ACs; do not self-review or merge
NEXT_PROMPT:
WHAT_HAPPENED:
Author shipped #691 hardening in commit
6d86db7and opened this PR with Closes #691.Implementation summary
reviewer_pr_lease.py: assessor + extended diagnose + find_newest_nonterminal_lease (includes expired comment markers)gitea_mcp_server.py: diagnose wires live head + formal reviews + worktree porcelain; new cleanup tooltask_capability_map.py: cleanup_obsolete_reviewer_comment_lease → gitea.pr.commentmcp_native_cleanup_proof.py: authorize new cleanup tool nametests/test_issue_691_obsolete_reviewer_lease_cleanup.py: AC matrix + 10749 regressionCleanup eligibility matrix
Exact audit behavior
Apply posts: (1) terminal lease marker phase=released with original candidate_head; (2) canonical audit comment citing #691 fields. No history deletion; no session seeding; no head repoint.
WHY: Provides the missing non-owner path for obsolete comment-backed leases after terminal review + head replacement, ending indefinite wait for the 10749 class of incident.
RELATED_PRS: #692 (this); #688 incident reproduction only
BLOCKERS: none for independent review
VALIDATION:
LAST_UPDATED_BY: jcwalker3 / prgs-author / AUTHOR / 2026-07-13
repo: Scaled-Tech-Consulting/Gitea-Tools
pr: #692
issue: none
reviewer_identity: sysadmin
profile: prgs-reviewer
session_id: 25883-70f5dabbf157
worktree: /Users/jasonwalker/Development/Gitea-Tools/branches/review-pr-692
phase: claimed
candidate_head:
6d86db793btarget_branch: master
target_branch_sha: none
last_activity: 2026-07-13T03:18:40Z
expires_at: 2026-07-13T05:18:40Z
blocker: none
Canonical PR State
STATE: approved
WHO_IS_NEXT: merger
NEXT_ACTION: Merger executes the merge sequence for PR #692.
NEXT_PROMPT:
WHAT_HAPPENED: PR review completed with APPROVED. Independent REVIEWER verified:
WHY: The implementation provides a complete, robust, and highly guarded non-owner cleanup path for obsolete comment-backed reviewer leases, fully satisfying all acceptance criteria for Issue #691.
ISSUE: 691
HEAD_SHA:
6d86db793bREVIEW_STATUS: approved
MERGE_READY: true
BLOCKERS: none
VALIDATION: 2636 passed, 6 skipped on commit
6d86db7.LAST_UPDATED_BY: reviewer
adopted_at: 2026-07-13T03:28:25Z
adopted_by_identity: sysadmin
adopted_by_profile: prgs-merger
adopted_from_session_id: 25883-70f5dabbf157
adopted_from_profile: prgs-reviewer
adopted_from_reviewer_identity: sysadmin
adopted_from_comment_id: 10820
adoption_reason: merger-handoff-approved-head
repo: Scaled-Tech-Consulting/Gitea-Tools
pr: #692
issue: #691
reviewer_identity: sysadmin
profile: prgs-merger
session_id: 92373-e105a388af21
worktree: /Users/jasonwalker/Development/Gitea-Tools/branches/review-pr-654
phase: adopted
candidate_head:
6d86db793btarget_branch: master
target_branch_sha: none
last_activity: 2026-07-13T03:28:25Z
expires_at: 2026-07-13T05:28:25Z
blocker: none
repo: Scaled-Tech-Consulting/Gitea-Tools
pr: #692
issue: #691
reviewer_identity: sysadmin
profile: prgs-merger
session_id: 92373-e105a388af21
worktree: /Users/jasonwalker/Development/Gitea-Tools/branches/review-pr-654
phase: released
candidate_head:
6d86db793btarget_branch: master
target_branch_sha: none
last_activity: 2026-07-13T03:31:24Z
expires_at: 2026-07-13T05:31:24Z
blocker: post-merge-moot
Canonical Issue State
STATE:
merged — product work for #691 complete; decision-lock recovery follow-up tracked on #693
WHO_IS_NEXT:
author
NEXT_ACTION:
Track and fix review-decision-lock recovery on issue #693 (do not treat this PR merge as closing that defect)
NEXT_PROMPT:
WHAT_HAPPENED:
PR #692 formal review hit a review-decision-lock recovery failure: lease acquired at head
6d86db793bbdfaed16bd54d93171f1dd66f234ca(comment 10820, session25883-70f5dabbf157);gitea_mark_final_review_decisionfailed; stale lock inspected;gitea_cleanup_stale_review_decision_lockinvoked multiple times (ineligible — unrelated open PR #688 terminal);gitea_authorize_review_correctionrequired; mark_final retried; APPROVE eventually landed (review_id 426). Merge237656702f44cf6621e77ff82188bf953d8eac3aclosed #691. Durable issue #693 holds the full failure record.WHY:
Keep post-merge trail so the recovery-path defect remains discoverable after product merge.
RELATED_PRS:
#692 (this), #691, #693, #688
BLOCKERS:
none on this PR; #693 remains open for decision-lock recovery
VALIDATION:
LAST_UPDATED_BY:
traceability cross-link / 2026-07-13