fix(mcp): allow author-lock recovery after the owning session exits (Closes #753) #754
Merged
sysadmin
merged 1 commits from 2026-07-18 20:03:27 -05:00
fix/issue-753-dead-pid-author-lock-recovery 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#754
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.
Closes #753.
Base:
0425bf9a4325a25b72739fba81604463e3e5e363Problem
A durable author issue lock records the PID of the MCP session that took it. When that process exits,
assess_lock_freshnessmarks the lockstale(live=false) even while its lease is still within TTL, so every ownership check that requires a live lock fails closed — includinggitea_update_pr_branch_by_merge.Re-taking the lock was unreachable for real work:
assess_issue_lock_worktreerequires the worktree HEAD to match a base branch SHA (master/main/dev), and a branch that already carries commits is ahead of its base by construction.assess_expired_lock_reclaimdoes not apply:assess_same_issue_lease_conflictonly consults it once the lease has expired, so a dead PID under an unexpired lease never reaches it.assess_own_branch_adoptionalready speaks of "lock recovery", but it runs at handler step 12 — after the base gate at step 9 — so it was never reached for a PR worktree.Observed on PR #750 / issue #749: lock matched the issue, the exact head branch, and the exact registered worktree; worktree clean; local head, remote head, and PR head all
e349839f; recorded pid48545dead; lease still ~55 minutes from expiry.Design
New
issue_lock_recovery.py— a pure assessor granting a narrow waiver only when all durable ownership evidence agrees:The waiver suppresses the base-match requirement and nothing else. Cleanliness and every other precondition still apply, and brand-new issue claims keep the full requirement.
A refused assessment never raises. It withholds the waiver and lets the pre-existing guard fail closed exactly as before, so recovery can only ever add permission — never remove a guard. Refusal reasons are appended to the block message so a caller sees the exact missing evidence instead of only the base text.
A completed recovery is stamped on the lock as
dead_session_recoverywith prior/replacement session PIDs, heads, and claimant, so the takeover is auditable and never looks like an original claim. Rebinding sets the live session PID, so the recovered lock satisfiesverify_lock_for_mutationand downstream PR update paths.Files changed
issue_lock_recovery.pygitea_mcp_server.pyissue_lock_worktree.pyrecovery_sanctionedkwarg waives only the base checkissue_lock_adoption.pybranch_carries_issue_markerpubliclytests/test_issue_753_dead_pid_lock_recovery.pyTests
The 2 failures reproduce identically on pristine master
0425bf9a(verified in a throwaway baseline worktree), so they are pre-existing and not caused by this change:test_issue_702_review_findings_f1_f6.py::TestF1RecoveryBeforeTerminalProbe::test_removed_worktree_recovers_before_probetest_reconciler_supersession_close.py::TestReconcilerSupersessionMcpTool::test_tool_posts_comment_and_closes_superseded_pr_issuegit diff --check— cleanSafety
repo: Scaled-Tech-Consulting/Gitea-Tools
pr: #754
issue: #753
reviewer_identity: sysadmin
profile: prgs-reviewer
session_id: 71140-266c51604a50
worktree: /Users/jasonwalker/Development/Gitea-Tools/branches/review-pr-754-3edeba4d-independent
phase: claimed
candidate_head:
3edeba4d7ftarget_branch: master
target_branch_sha:
0425bf9a43last_activity: 2026-07-19T00:43:47Z
expires_at: 2026-07-19T00:53:47Z
blocker: none
Independent review — PR #754 @
3edeba4d7f2ae320fb46f76b0e848c952b3cd9ceReviewer: sysadmin / prgs-reviewer (Grok)
Author: jcwalker3 (no self-review)
Base:
0425bf9a4325a25b72739fba81604463e3e5e363· mergeable: trueScope: 5 files only (
issue_lock_recovery.py,gitea_mcp_server.py,issue_lock_worktree.py,issue_lock_adoption.py,tests/test_issue_753_dead_pid_lock_recovery.py)Acceptance criteria (issue #753)
Design notes (safe)
Validation (this session)
0425bf9accepted)Verdict
APPROVE — safe, complete, fail-closed for #753. Ready for a fresh merger session. No merge performed.
Canonical PR State
STATE:
PR #754 is open against master at head
3edeba4d7fwith an independent APPROVE from prgs-reviewer (sysadmin). Mergeable true. No merger lease acquired.WHO_IS_NEXT:
merger
NEXT_ACTION:
Fresh merger session (prgs-merger) adopts or acquires a merger lease, re-pins head
3edeba4d7f, re-runs pre-merge gates, and merges only with explicit operator authorization.NEXT_PROMPT:
WHAT_HAPPENED:
Independent Grok reviewer (sysadmin/prgs-reviewer) inspected the five-file diff for dead-session author-lock recovery (#753), ran focused and affected suites, and submitted APPROVE at the exact pinned head via gitea_submit_pr_review on the gitea-reviewer MCP namespace.
WHY:
Issue #753 requires a native fail-closed recovery path when a durable author lock's recording PID is dead but ownership evidence still matches. The change is scoped, tested, and does not weaken cleanliness or brand-new claim base-equivalence.
ISSUE:
#753
HEAD_SHA:
3edeba4d7fREVIEW_STATUS:
APPROVED
MERGE_READY:
true
BLOCKERS:
none
VALIDATION:
33 focused #753 tests passed; 105 issue-lock/ownership related tests passed; MCP registration/handoff/cleanup suites passed; git diff --check clean; py_compile clean
NATIVE_REVIEW_PROOF: transport=native_mcp; entrypoint=mcp_server; tool=gitea_submit_pr_review; namespace=gitea-reviewer; profile=prgs-reviewer; identity=sysadmin; head=3edeba4d7f2ae320fb46f76b0e848c952b3cd9ce; session=71140-266c51604a50
LAST_UPDATED_BY:
reviewer (sysadmin / prgs-reviewer / Grok)
repo: Scaled-Tech-Consulting/Gitea-Tools
pr: #754
issue: #753
reviewer_identity: sysadmin
profile: prgs-reviewer
session_id: 71140-266c51604a50
worktree: /Users/jasonwalker/Development/Gitea-Tools/branches/review-pr-754-3edeba4d-independent
phase: released
candidate_head:
3edeba4d7ftarget_branch: master
target_branch_sha:
0425bf9a43last_activity: 2026-07-19T00:48:11Z
expires_at: 2026-07-19T00:58:11Z
blocker: manual-release
repo: Scaled-Tech-Consulting/Gitea-Tools
pr: #754
issue: #753
reviewer_identity: sysadmin
profile: prgs-merger
session_id: 77700-897fe2a11e17
worktree: /Users/jasonwalker/Development/Gitea-Tools/branches/merge-pr-754-3edeba4d
phase: claimed
candidate_head:
3edeba4d7ftarget_branch: master
target_branch_sha:
0425bf9a43last_activity: 2026-07-19T01:03:15Z
expires_at: 2026-07-19T01:13:15Z
blocker: none
Stale #332 review-decision lock cleanup (#594)
Status: APPLIED
sysadminprgs-merger2026-07-19T01:03:27.847698+00:00approveon PR fix(mcp): allow author-lock recovery after the owning session exits (Closes #753) (#754)closed(merged=True)08f67007c5984d239e1f52684e9e47543ff417851prgs-reviewerManual deletion of session-state files is not the workflow.
This path only clears a lock when the referenced PR is merged/closed.