fix(author): refresh durable issue-lock head after branch sync; recover merge-sync-drifted dead-session locks (Closes #871) #874
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#874
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 #871.
gitea_update_pr_branch_by_mergeadvances a PR's remote head but never advances the linked durable issue-lock's recorded head (head_sha). After the owning author session dies, the drifted lock can no longer be recovered bygitea_lock_issue, and the PR is stranded behind master. This is a control-plane lifecycle defect. This PR fixes it on both the write side and the read side.Motivating failure
Surfaced live on PR #866 / Issue #855 (branch
fix/issue-855-pr-scoped-merged-cleanup). A second cross-session base-sync deadlocked: the durable lock recorded head24c52ab…while the live PR head had advanced to499b87c…through a sanctioned merge-based branch sync, and no dead-session recovery relation covered "remote advanced past the recorded head via a sanctioned merge." PR #866, Issue #855, and their branch, worktree, durable lock, reviews, and leases are NOT modified by this PR.Changes
gitea_update_pr_branch_by_merge, refresh the durable linked-issue lock's recorded head from the exact former head to the resulting head using compare-and-swap with read-after-write. A remote-head advance followed by a durable-lock refresh failure is reported as an explicit partial lifecycle failure, never as a fully successful synchronization.published_owning_prrecovery relation for an already-drifted dead-session lock: recorded head is a proven strict ancestor of the live PR head via sanctioned merge-sync provenance, the former owner is dead, the worktree is clean, and no competing claimant/lease exists. Non-ancestor, rewritten/force-pushed, dirty, or live-foreign states stay protected.gitea_mcp_server.py,issue_lock_recovery.py,issue_lock_store.py,issue_lock_worktree.py,tests/test_issue_871_durable_lock_head_refresh.py.Tests
New suite: 32 passed. Relevant suites: 272 passed. Full suite: 4,789 passed, 13 baseline-identical failures, 6 skipped.
Concurrent duplicate: #872
Issue #872 was filed concurrently and describes the read-side half of this same deadlock as a separate bug. It is a concurrent duplicate of #871 and is left open for controller or post-review deduplication. This PR makes no claim that #872 was independently fixed or merged, and does not publish #872's alternate uncommitted work.
Provenance disclosure
The single local commit
5d59c57c98a5c8709bbbe1d5d5ed13eab721b14don this branch was created by a prior author session using a shellgit commit, not the sanctioned author commit tool. Per governance the commit was not amended, cherry-picked, recreated, or rewritten to erase that history. It was published only after the native author workflow affirmatively authorized adoption: sanctioned dead-session ownership was read from the durable issue-lock record (recorded claimantjcwalker3/prgs-author, generation 1); provenance was verified (parent = base master89657a06…, clean registered worktree, exact head); andgitea_publish_unpublished_issue_branchreturnedpublish_sanctionedbefore the remote head was created at the pinned SHA.repo: Scaled-Tech-Consulting/Gitea-Tools
pr: #874
issue: #871
reviewer_identity: sysadmin
profile: prgs-reviewer
session_id: 950-11a3a5205c9f
worktree: /Users/jasonwalker/Development/Gitea-Tools/branches/review-pr-874-5d59c57
phase: claimed
candidate_head:
5d59c57c98target_branch: master
target_branch_sha:
60df5087e9last_activity: 2026-07-24T07:40:09Z
expires_at: 2026-07-24T07:50:09Z
blocker: none
repo: Scaled-Tech-Consulting/Gitea-Tools
pr: #874
issue: #871
reviewer_identity: sysadmin
profile: prgs-reviewer
session_id: 950-11a3a5205c9f
worktree: /Users/jasonwalker/Development/Gitea-Tools/branches/review-pr-874-5d59c57
phase: released
candidate_head:
5d59c57c98target_branch: master
target_branch_sha:
60df5087e9last_activity: 2026-07-24T07:43:22Z
expires_at: 2026-07-24T07:53:22Z
blocker: manual-release
repo: Scaled-Tech-Consulting/Gitea-Tools
pr: #874
issue: none
reviewer_identity: sysadmin
profile: prgs-reviewer
session_id: 3847-094f5a87c66a
worktree: /Users/jasonwalker/Development/Gitea-Tools/branches/review-pr-874-e151759
phase: claimed
candidate_head: none
target_branch: master
target_branch_sha:
60df5087e9last_activity: 2026-07-24T07:48:51Z
expires_at: 2026-07-24T07:58:51Z
blocker: none
Canonical PR State
STATE: approved-pending-merge
WHO_IS_NEXT: merger
NEXT_ACTION: Merge PR #874 at exact head
e151759212via the sanctioned merger workflow (adopt this reviewer lease; do NOT base-sync — PR is 0 behind and mergeable).NEXT_PROMPT:
WHAT_HAPPENED: Author base-synced PR #874 from former head
5d59c57toe151759(sanctioned merge of base master60df5087). Fresh independent review at the new exact head; prior unrecorded analysis NOT reused. APPROVE recorded via native MCP review mutation.WHY: Both required behaviors (write-side durable-lock CAS refresh + read-side merge-sync recovery relation) and all 17 acceptance criteria are met; fail-closed throughout (server-derived provenance, live-owner CAS, no self-grant/foreign-lock-renew); scope is exactly the 5 declared files; zero regressions in the touched subsystem at the reviewed head.
ISSUE: #871
HEAD_SHA:
e151759212REVIEW_STATUS: APPROVED
MERGE_READY: true
BLOCKERS: none
VALIDATION: worktree branches/review-pr-874-e151759 @
e151759(clean before/after); tests/test_issue_871_durable_lock_head_refresh.py = 32 passed; related lock/recovery subsystem (753/755/768/772 + lock_store/worktree/provenance/adoption + #871) = 213 passed + 2 subtests; clean-merge proof:git diff 5d59c57 e151759 -- <5 PR files>empty andgit diff 60df5087 e151759 -- <non-PR files>empty. Runner: venv/bin/python -m pytest.LAST_UPDATED_BY: sysadmin / prgs-reviewer
NATIVE_REVIEW_PROOF: native MCP review mutation via gitea_submit_pr_review on prgs-reviewer; native_mcp_transport=true, production_native_mcp_transport=true, entrypoint=mcp_server (/Users/jasonwalker/Development/Gitea-Tools/gitea_mcp_server.py), native_token_fingerprint=fc2fec9ad753f652, pid=3847; no offline/import/helper path used.
Review detail
e151759is a merge commit parent1=5d59c57 (PR head, byte-identical PR content) parent2=60df5087 (base master).gitea_update_pr_branch_by_merge): durable-lock head refresh via CAS on expected_old_head; server-derived claimant; read-after-write; refresh failure => explicit partial_lifecycle_failure with success=false. ACs 1/5/6/16._assess_remote_merge_synced/ HEAD_RELATION_REMOTE_MERGE_SYNCED): older recorded head accepted ONLY on server-proven merge-sync provenance; provenance prior/synced heads re-validated against heads under assessment (blocks stale/hand-built reuse); requires prior_is_ancestor + is_merge_sync. ACs 3/4/7/8.read_merge_sync_provenance): pure server-side git — both-present, strict-ancestor, merge-commit(>=2 parents), first-parent-reaches-prior; every subprocess failure fails closed. Blocks rewrite/rebase/force-push.assess_/apply_durable_lock_head_refresh): full ownership re-verification (repo/issue/branch/worktree-realpath/identity/profile) + live-owner pid required (blocks foreign-lock renewal & self-grant) + synced-head CAS + generation CAS + read-after-write.Files reviewed: gitea_mcp_server.py, issue_lock_recovery.py, issue_lock_store.py, issue_lock_worktree.py, tests/test_issue_871_durable_lock_head_refresh.py.
adopted_at: 2026-07-24T07:54:08Z
adopted_by_identity: sysadmin
adopted_by_profile: prgs-merger
adopted_from_session_id: 3847-094f5a87c66a
adopted_from_profile: prgs-reviewer
adopted_from_reviewer_identity: sysadmin
adopted_from_comment_id: 15572
adoption_reason: merger-handoff-approved-head
repo: Scaled-Tech-Consulting/Gitea-Tools
pr: #874
issue: none
reviewer_identity: sysadmin
profile: prgs-merger
session_id: 3855-59630be2aa96
worktree: /Users/jasonwalker/Development/Gitea-Tools/branches/merge-pr-874
phase: adopted
candidate_head:
e151759212target_branch: master
target_branch_sha:
60df5087e9last_activity: 2026-07-24T07:54:08Z
expires_at: 2026-07-24T08:04:08Z
blocker: none
adopted_at: 2026-07-24T08:03:48Z
adopted_by_identity: sysadmin
adopted_by_profile: prgs-merger
adopted_from_session_id: 3855-59630be2aa96
adopted_from_profile: prgs-merger
adopted_from_reviewer_identity: sysadmin
adopted_from_comment_id: 15575
adoption_reason: merger-handoff-approved-head
repo: Scaled-Tech-Consulting/Gitea-Tools
pr: #874
issue: #871
reviewer_identity: sysadmin
profile: prgs-merger
session_id: 66164-bef8359d36bb
worktree: branches/merge-pr-874
phase: adopted
candidate_head:
e151759212target_branch: master
target_branch_sha:
60df5087e9last_activity: 2026-07-24T08:03:48Z
expires_at: 2026-07-24T08:13:48Z
blocker: none
Stale #332 review-decision lock cleanup (#594)
Status: APPLIED
sysadminprgs-merger2026-07-24T08:04:26.927322+00:00approveon PR fix(author): refresh durable issue-lock head after branch sync; recover merge-sync-drifted dead-session locks (Closes #871) (#874)closed(merged=True)cc7dc8ac1440ac2f6c3eb232ff7b303f885b4bed1prgs-reviewerManual deletion of session-state files is not the workflow.
This path only clears a lock when the referenced PR is merged/closed.
repo: Scaled-Tech-Consulting/Gitea-Tools
pr: #874
issue: #871
reviewer_identity: sysadmin
profile: prgs-merger
session_id: 66164-bef8359d36bb
worktree: branches/merge-pr-874
phase: released
candidate_head:
e151759212target_branch: master
target_branch_sha:
60df5087e9last_activity: 2026-07-24T08:11:25Z
expires_at: 2026-07-24T08:21:25Z
blocker: post-merge-moot