feat: harden issue lock store against concurrent session clobbering (Closes #438) #464
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#464
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 #438. Replaces the global read-modify-write issue lock with atomic per-issue locks so concurrent author sessions working different issues no longer clobber
/tmp/gitea_issue_lock.json.Changes
issue_lock_store.py— flock-serialized per-issue locks underGITEA_ISSUE_LOCK_DIR, PID/session metadata, stale recovery gates, lock proof formatting, live-lock inventorygitea_mcp_server.py— wire atomic acquire intogitea_lock_issue; re-check lock freshness beforegitea_create_pr; exposelive_issue_locksin claim inventorymerged_cleanup_reconcile.py— treat live per-issue locks as active branch protectionscripts/worktree-start— resolve locks by branch via per-issue storetests/test_issue_lock_store.py— concurrency + stale recovery regression casesdocs/llm-workflow-runbooks.md— lock proof reporting guidanceVerification
Worktree
branches/issue-438-lock-hardening@992d055992d055998to2cace4f7cdrepo: Scaled-Tech-Consulting/Gitea-Tools
pr: #464
issue: none
reviewer_identity: sysadmin
profile: prgs-reviewer
session_id: 47646-67c1146dc04f
worktree: branches/review-feat-issue-438-lock-hardening
phase: claimed
candidate_head:
2cace4f7cdtarget_branch: master
target_branch_sha: none
last_activity: 2026-07-07T21:54:23Z
expires_at: 2026-07-07T23:54:23Z
blocker: none
Independent audit — REQUEST CHANGES (syntax error & rebase required)
Auditor:
sysadmin/prgs-reviewer(not PR authorjcwalker3).Pinned HEAD:
2cace4f7cd8dd7903a83c6cbcc735089f2c5b654Worktree + Cleanliness
git statusclean before and after running tests.Blockers & Regression Failures
Running the full test suite (
pytest) revealed 10 failures:1. Syntax error in
scripts/worktree-start:6 tests in
tests/test_worktrees.pyfailed with:scripts/worktree-start: line 50: syntax error near unexpected token '('Root Cause: On line 45, the command substitution closing parenthesis was incorrectly placed at the end of the line:
locked_branch=$(PYTHONPATH="$repo_root" python3 - <<'PY' "$branch"). This ends the substitution immediately, causing bash to attempt parsing the python heredoc content on lines 46-55 as bash commands.Fix: Move the closing parenthesis from the end of line 45 to line 56, right after the heredoc terminator
PY.2. Network connection regressions:
4 other tests (in
test_agent_temp_artifacts.py,test_issue_work_duplicate_gate.py, andtest_mcp_server.py) failed with:RuntimeError: network error contacting Gitea: [Errno 8] nodename nor servname provided, or not knownRoot Cause: The branch is not rebased onto the current master (post-PR #449/post-PR #462), causing a mock-safety mismatch for the Gitea API requests.
Required Action
scripts/worktree-startby correcting the command substitution parenthesis.repo: Scaled-Tech-Consulting/Gitea-Tools
pr: #464
issue: #438
reviewer_identity: sysadmin
profile: prgs-reviewer
session_id: 47646-67c1146dc04f
worktree: /Users/jasonwalker/Development/Gitea-Tools/branches/review-feat-issue-438-lock-hardening
phase: claimed
candidate_head:
2cace4f7cdtarget_branch: master
target_branch_sha: none
last_activity: 2026-07-07T21:56:53Z
expires_at: 2026-07-07T23:56:53Z
blocker: none
842776f916tod306c0a5ecrepo: Scaled-Tech-Consulting/Gitea-Tools
pr: #464
issue: #438
reviewer_identity: sysadmin
profile: prgs-reviewer
session_id: 47646-67c1146dc04f
worktree: branches/review-pr464-issue-438-lock-hardening
phase: claimed
candidate_head:
d306c0a5ectarget_branch: master
target_branch_sha:
3c41d2af5clast_activity: 2026-07-07T22:36:04Z
expires_at: 2026-07-08T00:36:04Z
blocker: none
Fresh review at head
d306c0a5ec0c33ce8168c2c0db6afc8062ebba58Supersedes stale review/REQUEST_CHANGES at
2cace4f.Prior REQUEST_CHANGES resolution
scripts/worktree-startbash syntax (bash -nfailure on heredoc)python3 -c+resolve_locked_branch_for_session;bash -npasses;pytest tests/test_worktrees.pypassesbind_session_lockfoundation; merge simulation into current master (3c41d2a) auto-merges cleanly and retains #461 boundary-aware adoptionPreflight
master@3c41d2asysadmin/prgs-reviewerreview_pr: allowed; self_author false (authorjcwalker3)d306c0aexact match; mergeable true54a7515; #461 landed:3c41d2aScope reviewed (vs
prgs/master)issue_lock_store.py— flock serialization,assess_lock_freshness,verify_lock_for_mutation,list_live_locks,format_lock_proofgitea_mcp_server.py— lock proof ongitea_lock_issue,verify_lock_for_mutationbeforegitea_create_pr,live_issue_locksinventorytests/test_issue_lock_store.py— concurrency + stale-lock casesNote: branch tip is based on
54a7515(pre-#461) but merges cleanly into3c41d2a; simulated merge keeps_branch_carries_issue_markerfrom #461.Clobber-hazard verdict — PASS
fcntl.flockwrapsbind_session_lockread-check-writeassess_foreign_lock_overwrite+assess_same_issue_lease_conflictenforced inside critical sectionLockContentionErrorsurfaces concurrent same-issue contention fail-closedTests
pytest tests/test_issue_lock_store.py tests/test_issue_lock_adoption.py tests/test_issue_lock_worktree.py -q→ 27 passedpytest tests/test_mcp_server.py -k "lock or adopt"→ 47 passedgit diff --check→ cleanDecision: APPROVE at
d306c0a. Separate merge session recommended. Keep #473 parked until #464 merges and #438 closes.repo: Scaled-Tech-Consulting/Gitea-Tools
pr: #464
issue: none
reviewer_identity: sysadmin
profile: prgs-reviewer
session_id: 47646-67c1146dc04f
worktree: branches/review-feat-issue-438-lock-hardening
phase: claimed
candidate_head:
d306c0a5ectarget_branch: master
target_branch_sha: none
last_activity: 2026-07-07T22:37:43Z
expires_at: 2026-07-08T00:37:43Z
blocker: none