refactor(daemon): trim expired-lease admission code

Merged
TH
5h ago
+22-23

Summary

Trims daemon code added by #5151, with no intended behaviour change. cleanupExpiredLeasedSession now classifies its request once. bindOutsideRequestLocks stays: inlining it put createRequestExecutionScope over the Fallow cyclomatic threshold.

holdsSessionLocks stays because its invariant is false. resolveRequestExecutionLockPlan reads the session store before runLocked takes any lock. A close planned with no session omits the session's device lock unless its flags selected that device. An open ahead of it can then publish the session, and without the check close tears it down while another request holds the device.

normalizeLeaseId(leaseId) ?? leaseId stays: its caller passes the raw request id.

Value

  • Production lines: +19 / โˆ’23 (net โˆ’4).
  • Request predicates in lease-lifecycle.ts: 4 โ†’ 2.
  • isBoundedCompositeRequest call sites there: 2 โ†’ 1.

Validation

At b208b5bcb95ea9cb180e849493c8c81701b2def2 (bd7165196f restores the helper only):

  • lease-lifecycle.test.ts and request-execution-scope-lease-expiry.test.ts, unchanged: 29 passed. OXC formatted.

Item 2 evidence, on the base commit:

  • With the check removed, the existing test a close that finds its session busy ends it once that request finishes fails.
  • A temporary, uncommitted test through runLocked (session published after planning, device held) passed with the check and failed without it.

No gates run locally; CI pending. No independent review; the author re-read the diff.

Security

Typed refusals, dispatched: 'no', assertLeaseActive and redaction are unchanged. The lease end is still bound before locks are taken.

๐Ÿค– Generated with Claude Code


Open in [code]smith ยท Need help on this PR? Tag @codesmith-bot with what you need.