Prevent overlapping autonomous release runs with a repository-scoped lease #335

Closed
opened 2026-08-08 19:49:59 +00:00 by rockachopa · 0 comments
Member

Problem

The autonomous release engine has restart-safe checkpoints but no single-writer boundary. Two scheduler/manual invocations can select and claim the same eligible issue, mutate the same deterministic branch/worktree, run duplicate agent/test work, and race StateStore.save() through the shared state.json.tmp path. A read-only audit reproduced checkpoint temporary-file collisions under concurrent saves.

This is not duplicate work: all 170 historical issue titles, 161 PR titles, and recent origin/main commits were inspected. Existing work covers command deadlines, durable resume checkpoints, and subprocess credential isolation, but not repository-scoped run serialization.

User value

Protect release integrity and avoid duplicate coding-agent cost when an hourly run overlaps a manual or slow prior run. Contended invocations should fail fast without touching Gitea, Git, or agent processes.

Acceptance criteria

  • Acquire a non-blocking OS-backed lease scoped to the canonical repository before issue discovery and hold it through final state/PR creation.
  • A contended run exits promptly with an explicit release run already active outcome before any Gitea request, Git command, or agent execution.
  • Different repository identities can run concurrently.
  • Process termination releases the lease automatically; stale metadata cannot permanently block work.
  • Lease metadata provides bounded PID/acquisition diagnostics.
  • Checkpoint writes use writer-unique temporary files plus flush/atomic replace so concurrent save stress has no temp-path collisions or partial JSON.
  • Focused concurrency/crash/no-side-effect tests and the full suite pass.
  • Document the single-active-run invariant and operator recovery behavior.
## Problem The autonomous release engine has restart-safe checkpoints but no single-writer boundary. Two scheduler/manual invocations can select and claim the same eligible issue, mutate the same deterministic branch/worktree, run duplicate agent/test work, and race `StateStore.save()` through the shared `state.json.tmp` path. A read-only audit reproduced checkpoint temporary-file collisions under concurrent saves. This is not duplicate work: all 170 historical issue titles, 161 PR titles, and recent `origin/main` commits were inspected. Existing work covers command deadlines, durable resume checkpoints, and subprocess credential isolation, but not repository-scoped run serialization. ## User value Protect release integrity and avoid duplicate coding-agent cost when an hourly run overlaps a manual or slow prior run. Contended invocations should fail fast without touching Gitea, Git, or agent processes. ## Acceptance criteria - Acquire a non-blocking OS-backed lease scoped to the canonical repository before issue discovery and hold it through final state/PR creation. - A contended run exits promptly with an explicit `release run already active` outcome before any Gitea request, Git command, or agent execution. - Different repository identities can run concurrently. - Process termination releases the lease automatically; stale metadata cannot permanently block work. - Lease metadata provides bounded PID/acquisition diagnostics. - Checkpoint writes use writer-unique temporary files plus flush/atomic replace so concurrent save stress has no temp-path collisions or partial JSON. - Focused concurrency/crash/no-side-effect tests and the full suite pass. - Document the single-active-run invariant and operator recovery behavior.
timmy was assigned by rockachopa 2026-08-08 19:49:59 +00:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: stackchain/stackchain-dashboard#335
No description provided.