[bug][author-lock] Dead-session recovery deadlocks a second cross-session PR base-sync after a sanctioned server-side update_pr_branch_by_merge advanced the remote head #872
Open
opened 2026-07-24 01:33:16 -05:00 by jcwalker3
·
0 comments
No Branch/Tag Specified
master
fix/issue-860-dirty-orphan-worktree-recovery
feat/issue-657-mcp-restart-path-inventory-guard
feat/issue-658-mcp-restart-coordinator
feat/issue-639-webui-system-health-dashboard
feat/issue-642-sanctioned-restart-controls
fix/issue-850-native-mcp-bootstrap
fix/issue-842-conflict-fix-lease-lifecycle
feat/issue-628-autonomous-handoffs-orchestration
feat/issue-651-usage-cost-analytics
fix/issue-790-slice-a-heartbeat-policy
feat/issue-646-policy-guardrail-visibility
feat/issue-638-webui-app-shell-phase1
feat/issue-634-readonly-system-health-api
feat/issue-822-atomic-install-authority-kernel
feat/issue-636-inventory-api
feat/issue-798-worker-registry-schema
chore/issue-681-preserve-review-session-wip
v1.1.0
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
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#872
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
gitea_lock_issuedead-session recovery (published_owning_prmode) cannot recover an author binding after a prior sanctioned server-side base-sync (gitea_update_pr_branch_by_merge) advanced the live PR head beyond the clean local worktree head. This produces a reproducible deadlock for any PR that needs more than one base-sync across author sessions, and surfaces as an internal, non-retryableRuntimeErrorinstead of a structured reason.Observed live on PR #866 / issue #855 (do not modify those resources while fixing this — they are the frozen reproduction case).
Confirmed reproduction (PR #866 / #855)
24c52abf6b80e7ed562294371eee9fe8620b686e; clean registered worktree at A; durable lock records A.gitea_update_pr_branch_by_mergeperforms a server-side merge of master into the branch. The live remote PR head advances A → B =499b87c48218cf03a3b1f34a5d8a17549d820564. The clean local worktree stays at A. The durable lock still records A. The owning PR now points at B.Result: deadlock.
Root cause (confirmed in code)
gitea_mcp_server.py_evaluate_issue_lock_recoveryprobes head ancestry in one direction only:read_head_ancestry(ancestor_sha=remote_head, descendant_sha=local_head)— i.e. it only ever asks "does the local head descend from the remote head?" (the #768 "author committed local remediation, not yet pushed" case).issue_lock_recovery.assess_dead_session_lock_recoverypublished-mode head agreement accepts only:local_head == remote_head(#753), orlocal_headstrictly descendsremote_head(#768).REFUSED("local head A does not match remote branch head B").recovery_sanctioned=False,assess_issue_lock_worktreeblocks (a branch carrying committed work is never base-equivalent), andgitea_lock_issueraisesRuntimeErrorat the base-equivalence gate — an internal, non-retryable error.Net: base-sync advances the remote/PR head but leaves the durable lock recorded head and the clean local worktree at the pre-sync head, and no recovery relation covers "remote legitimately advanced past local via a sanctioned merge."
Required fix
Add a third
published_owning_prhead relation — remote head is a proven strict descendant of the clean local/recorded head via a sanctioned base-sync merge — and sanction dead-session recovery only when every safety fact is server-proven:On sanction, rebind ownership so a subsequent sanctioned base-sync can run from PR head B, without discarding work, force-pushing, resetting, or rewriting history, and without mutating the local worktree except through an explicitly sanctioned, validated mechanism. Return structured reason codes on refusal instead of an internal
RuntimeError. Keep every existing recovery path (first-time lock, #753/#768 dead-session recovery, dirty same-claimant rebind, unpublished-branch recovery, update-by-merge head/base race protection) unchanged.Acceptance / tests
Boundaries
Do not manually rewrite the issue #855 lock as the solution. Do not modify PR #866, its branch, or its worktree during development. Preserve the distinction between local worktree head, recorded lock head, authoritative remote PR head, and current base/master head.