Repository navigation
Description
Problem
The deferred v1 pitfall, verbatim from docs/known-pitfalls.md: a backgrounded
pitlane lease does not die with its agent. It gets reparented (launchd on
macOS) and keeps its daemon socket open, holding the lease until the TTL
backstop fires. A crashed agent therefore squats a device — the exact failure
Pitlane exists to prevent.
This is now blocking, not merely deferred. #12 makes lease lifetime track
"the holder process is alive". A reparented holder is alive and will happily
answer heartbeats forever, so enabling the sliding TTL for CLI held mode would
turn today's bounded 1-hour leak into an unbounded one. The CLI cannot declare
the heartbeat capability until this ships.
Proposed change
Per the plan already recorded in docs/known-pitfalls.md and docs/IDEAS.md:
- macOS:
kqueuewithEVFILT_PROC/NOTE_EXITon the parent pid captured
at startup. - Linux:
prctl(PR_SET_PDEATHSIG, SIGTERM). --bind-pid <pid>escape hatch for holders spawned from a short-lived
subshell, where the immediate parent dies even though the agent is alive.- On parent death, release the lease and exit cleanly through the existing
signal path inrunLease.
Then flip CLI held mode to declare the heartbeat capability from #12, so both
frontends get the sliding TTL.
Notes
- New external mechanism → new port first (architecture rule 9). A
ParentWatchport with real macOS/Linux adapters and a fake for tests, so
the CLI logic stays deterministic and testable. - Machine sleep and zombie sockets still fall back to the TTL backstop; this
fix is about the holder outliving its owner, nothing more.
Acceptance criteria
- The holder releases its lease and exits when its watched parent dies
(tested through the fake port). -
--bind-pidoverrides the watched pid. - Platforms without support degrade to current behavior rather than
failing to start. - CLI held mode declares the Keep held leases alive while their holder is alive (heartbeat-negotiated sliding TTL) #12 heartbeat capability, and
docs/CLI.md
switches from "hand-renewed" to automatic. - The orphaned-holder section of
docs/known-pitfalls.mdis removed or
rewritten to reflect the shipped fix. -
pnpm checkgreen.
Activity
feat(cli): self-terminate held lease holders when their parent dies (#54