Repository navigation
fix(#637): guard signalOther against self/parent PID - #639
Merged
admarble merged 2 commits intoMay 14, 2026
Merged
Conversation
Adds a self-PID / parent-PID short-circuit in `LockManager.signalOther` before the `isPidAlive` probe. Defense-in-depth follow-up to the #633 flake fixed in #634 — production users can still hit the underlying weakness if a recycled PID lands on the manager's own PID or its parent shell. - src/lib/locks/lock-manager.ts: insert guard after hostname check - src/lib/locks/lock-manager.test.ts: two new tests assert the guard short-circuits BEFORE invoking the isPidAlive spy Fixes #637
…ller logs
Promotes `LockManager.signalOther` return from `boolean` to
`{ sent: boolean; reason: SignalReason }` so callers can produce a
correct log line in each refusal branch — including the new
self-or-parent guard added earlier in this PR, which previously
collapsed into the misleading "(cross-host or already exited)" suffix.
- src/lib/locks/types.ts: add SignalReason / SignalOtherResult
- src/lib/locks/index.ts: re-export new types
- src/lib/locks/lock-manager.ts: rewrite signalOther to return reason
- src/lib/locks/lock-manager.test.ts: assert reason discriminator in
existing + #637 tests; AC-1 test now uses process.pid for the
manager (mirrors production; pid=1 was unrealistic)
- src/commands/locks.ts + run-orchestrator.ts: per-branch log mapper
- src/commands/__tests__/locks-cli.integration.test.ts: anchor on
the new "(cross-host holder)" suffix
2 tasks done
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
Defense-in-depth follow-up to #633/#634. Adds a self-PID / parent-PID short-circuit in
LockManager.signalOtherbefore theisPidAliveprobe. A malformed lock file or a recycled PID could otherwise let the manager SIGTERM its own shell.src/lib/locks/lock-manager.ts: 5-line guard after the hostname checksrc/lib/locks/lock-manager.test.ts: two unit tests assert the guard short-circuits before theisPidAlivespy runs (verifies guard ordering, not just the return value)Why not just rely on #634?
PR #634 fixed the test fixture that caused the flake (cross-host sentinel hostname routes around
process.kill). The production-code weakness insignalOther— trusting the lock file's claimed PID once same-host + alive checks pass — was left for this follow-up. Real users with low-pid_maxkernels could still hit recycled-PID footguns.Scope
process.ppid) guardTest plan
npx vitest run src/lib/locks/lock-manager.test.ts— 45/45 passing (43 existing + 2 new)npm run build— cleansignalOther only signals same-host alive PIDstest unchanged (holder.pid=9999, manager.pid=1 — guard does not engage)Fixes #637