fix(daemon): keep an idle daemon alive only for retained leases
Merged
TH
2mo ago+157+157+012345678901234567890123456789-17-17-01234567890123456789
Summary
Follow-up to #3208, which merged while this was in review. It answers the open question there: idle reap now waits only while an unexpired retainOnClose lease is active. As merged, #3208 counted every lease, so a human-control hold with no expiresAt kept an otherwise idle daemon alive, where before it was reaped. Other leases now reap as they did before #3208.
LeaseRegistry.hasRetainedLeases()owns the rule. Reading it also expires leases past their window, so an abandoned retained lease still ends. The daemon wiring is a one-line call.- ADR 0007 says that only
retainOnCloseleases keep an idle daemon alive. - A lifecycle-shutdown test restores the coverage the old
beforeDeleteassertions gave: a session-bound lease whose session teardown rejects is still released by the shutdown sweep.
7 files, 91 gross lines.
Validation
At e0d5f4c2d3: pnpm check:affected --run passes. A retained lease counts only while its own expiresAt is in the future, so a human-control hold cannot keep an idle daemon alive. Registry, runtime idle-reap and shutdown tests each fail under their mutation.