Repository navigation
feat(#74): implement graceful shutdown for sequant run - #77
Merged
admarble merged 1 commit intoJan 12, 2026
Merged
Conversation
- Add ShutdownManager class with SIGINT/SIGTERM handling - Support graceful cleanup via registered tasks (LIFO order) - Wire LogWriter finalization as cleanup task - Wire worktree cleanup for newly created worktrees - Abort active phase on shutdown via AbortController - Double Ctrl+C forces immediate exit - Configurable timeout (default 10s) for cleanup operations - 18 unit tests for ShutdownManager Closes #74 Co-Authored-By: Claude Opus 4.5 <[email protected]>
admarble
deleted the
feature/74-feat-implement-graceful-shutdown-for-sequant-ru
branch
January 12, 2026 01:20
admarble
added a commit
that referenced
this pull request
May 13, 2026
…tinel (#634) * fix(#633): eliminate locks-cli takeover test flake via cross-host sentinel The takeover test wrote a lock with pid: 9999 and hostname: os.hostname(), then invoked `sequant locks acquire --force --signal-other`. signalOther's same-host branch (lock-manager.ts:290) then called process.kill(9999, 'SIGTERM'). On a busy CI runner PID 9999 can be a live sibling/ancestor process (linux pid_max default 32768; PIDs assigned sequentially), so the SIGTERM landed on a real process — when that process was an ancestor of the spawned CLI it tore down the stdout pipe and the CLI died with SIGPIPE, surfacing as result.status === null. Fix: set hostname to a sentinel non-host string so signalOther's cross-host short-circuit (lock-manager.ts:289) returns false without ever calling process.kill. The CLI emits the same 'Could not signal PID 9999 for #77 (cross-host or already exited)' line, matching the existing regex assertion. Same fix applied to the sibling --force-without-signal-other fixture for consistency. Same-host-dead-PID branch retains unit coverage in lock-manager.test.ts:294 via the isPidAlive constructor seam. Verified: 20/20 local repeats of the takeover test pass; full locks surface (59 tests across 3 files) green. * fix(#633): rename takeover test + tighten cross-host assertion The test title still claimed "for dead PID" after the cross-host fix even though the test no longer exercises the dead-PID branch — signalOther short-circuits on the cross-host check before isPidAlive runs. Rename to match what the test actually verifies. Tighten the stdout regex to anchor on the full "(cross-host or already exited)" suffix so a future refactor that accidentally takes the "Signaled ..." (sent) branch would fail loudly instead of slipping through a loose substring match. Expand the explanatory comment to document the CLI-message-level limitation: the same suffix is printed for both signalOther false branches (cross-host vs same-host-dead-PID), so the integration assertion cannot distinguish which internal branch ran. The same-host-dead-PID branch retains unit coverage at lock-manager.test.ts:294 via the isPidAlive constructor seam.
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
ShutdownManagerclass to handle SIGINT/SIGTERM signals gracefullyImplementation Details
New files:
src/lib/shutdown.ts- Core ShutdownManager classsrc/lib/shutdown.test.ts- 18 unit tests covering all functionalityModified:
src/commands/run.ts- Wire ShutdownManager into run workflowTest Plan
sequant runshows cleanup messages and exits cleanlyAC Coverage
Closes #74
🤖 Generated with Claude Code