Repository navigation
feat(#625): per-issue concurrency lock prevents concurrent sequant sessions - #626
Merged
admarble merged 5 commits intoMay 11, 2026
Conversation
…ssions
New src/lib/locks/ module with LockManager that claims
.sequant/locks/<issue>.lock via open(O_CREAT|O_EXCL) when sequant run
starts. A second session attempting the same issue is skipped with a
clear error message; the rest of the batch continues.
- Stale detection: same-host PID-dead clears immediately (covers
SIGKILL); cross-host clears by 2h age fallback.
- --force takes over the lock; --force --signal-other also SIGTERMs the
prior PID (same-host alive only).
- Read-only commands (status, merge) warn but proceed.
- New sequant locks list/clear subcommands.
- SEQUANT_ORCHESTRATOR env var no-ops the entire mechanism (MCP path).
- SEQUANT_LOCKS_DIR env var overrides the directory for test isolation.
Lock cleanup wired through ShutdownManager and process.on('exit') for
uncaught-exception coverage; SIGKILL recovery happens on the next run.
27 unit tests cover the stale-detection matrix, atomic acquire, force
semantics, orchestrator no-op, error format, and list/clear. Integration
tests spawn real child processes to verify O_EXCL atomicity and
SIGKILL stale-recovery.
Addresses one of the failure modes behind the 29% chain-mode failure
rate documented in #604 / #621.
21 tasks
…-16/AC-18 Addresses the QA AC_NOT_MET gaps on PR #626. The lock primitive shipped in the prior commit was solid for the CLI path but didn't reach the motivating example (npx sequant run vs /fullsolve collision) because the /fullsolve skill never claimed it. - LockFile schema: add optional skipPidCheck flag. classifyStaleness now skips the same-host PID probe when set, falling back to age-only (2h). Required because skill shells exit immediately after `locks acquire`, leaving the lock's PID dead between acquire and release. - LockManager: new releaseExternal() releases same-host skipPidCheck locks from any PID (the next skill shell's PID, not the original). - CLI: new `sequant locks acquire/release/check <issue>` subcommands. - Skills: /fullsolve SKILL.md Phase 0.3 acquires with --skip-pid-check; Phase 5.5 releases. /assess Step 1 probes via `locks check --json` and surfaces a dashboard warning when held. Mirrored across all three skill dirs (.claude/skills, templates/skills, skills). - Tests: 8 new unit tests for skipPidCheck + releaseExternal, 1 RunOrchestrator lockedResults flow test (AC-18), 1 SIGINT integration test verifying ShutdownManager.gracefulShutdown → releaseAll (AC-16). Total: 36 unit + 3 integration = 39 (was 29). - README §Concurrency and CHANGELOG entry document skill wiring + --skip-pid-check rationale (2h orphan window if skill crashes). QA verdict reference: AC-2 + AC-4 now MET (skill wiring); AC-16 covered by SIGINT integration test; AC-18 covered by orchestrator lockedResults unit test.
Closes the literal AC-18 gap: prior test exercised the orchestrator's per-issue acquire loop but didn't verify that buildLockedResult produces the IssueResult shape the summary depends on (abortReason + locked metadata flowing into run-display.ts:100). 40 lock tests now pass.
…anup obligations Addresses gaps surfaced post-QA review: 1. Skill-shell locks now use a SEPARATE 6h TTL (DEFAULT_SKILL_LOCK_TTL_MS) instead of inheriting the 2h cross-host staleAgeMs — long /fullsolve runs with multi-iteration QA loops no longer risk self-expiring their own lock. SEQUANT_SKILL_LOCK_TTL_MS env override. 2. New `sequant locks check-batch <issues...>` subcommand. Text mode emits one canonical ⚠ warning line per held issue (ready to paste into the /assess dashboard); JSON mode emits structured output. /assess SKILL.md updated to use the single batch call instead of per-issue probes. 3. New `locks-cli.integration.test.ts` exercises dist/bin/cli.js for the actual SKILL.md contract: acquire→block→release→check sequence, check-batch text/JSON/empty/orchestrator modes, and --force --signal-other --skip-pid-check skill-lock takeover (Gap 4). 4. /fullsolve SKILL.md now releases the lock on every halt branch (Phase 1.3 spec failure, Phase 2.3 exec exhausted, Error Recovery section) and includes an explicit "release contract" at Phase 0.3 listing all known abort branches. Aborted runs no longer wait for the 6h TTL. Tests: +19 (8 unit for skillLockTtlMs boundary cases + resolveSkillLockTtlMs env parse; 13 CLI integration tests; minor: 1 SIGINT integration; AC-18 buildLockedResult). Full suite: 3067/3067. Orchestrator-mode release JSON gains an `issue` field for shape consistency with the non-orchestrator path.
…e-prevent-concurrent-sequant-sessions-fro # Conflicts: # CHANGELOG.md
admarble
deleted the
feature/625-feat-state-prevent-concurrent-sequant-sessions-fro
branch
May 11, 2026 23:28
This was referenced May 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a per-issue filesystem lock at
.sequant/locks/<issue>.lock(atomicopen(O_CREAT|O_EXCL)) so two sequant sessions can't target the same issue at the same time. The collision from #604 (10m 38s wasted; 3× exec "no changes" retries) now skips cleanly with a clear error and the rest of the batch continues.src/lib/locks/module:LockManager,classifyStaleness,formatLockedMessageRunOrchestrator.run()claims/releases the lock around each issue--forcetakes over;--force --signal-otheralso SIGTERMs the prior PID (same-host alive only)status,merge) warn but proceedsequant locks list/sequant locks clear <issue>subcommandsSEQUANT_ORCHESTRATORenv var no-ops the mechanism (MCP path, matchesOrchestratorRenderer)SEQUANT_LOCKS_DIRenv var overrides the directory for test isolationStale recovery
AC coverage
.sequant/locks/created on demandLockManager.ensureLocksDir()process.on('exit')run-orchestrator.ts:524-578RunOrchestrator.run()acquiresstatus.ts,merge.tsSEQUANT_ORCHESTRATORno-opisOrchestratorMode()guard at every methodclassifyStaleness()+ unit tests--forceclaims without signalingforceAcquire()separated fromsignalOther()--force --signal-otherSIGTERMs prior PIDsignalOther()(same-host alive only)formatLockedMessage()+ verbatim testbuildLockedResult()synthetic IssueResultsequant locks list/clear <issue>src/commands/locks.tsSEQUANT_LOCKS_DIRenv overrideresolveLocksDir()## ConcurrencysectionTest plan
npm run build— passesnpm run lint— passes (0 warnings)src/lib/locks/lock-manager.test.ts) — 27/27 passlock-manager.integration.test.ts) — 2/2 pass; two real Node processes race onO_EXCL; SIGKILL leaves a stale lock that next run auto-clearssrc/lib/+src/commands/) — 2434/2434 passnpx sequant locks listshows fake locks with staleness flags;clearremoves themCloses #625