feat(daemon): keep a caller-owned lease through session close with retainOnClose
Summary
Session close always releases the session's lease. That has been the rule since #890, so a failed close can't strand a lease, and the CLI proxy flow relies on it to free devices. tester-army/e2e later started allocating leases itself and releasing them at run end (tester-army/e2e#416). It also closes sessions mid-run, on device.closeApp() and when it replaces a worker after a failing test file. Every later command fails UNAUTHORIZED: Lease is not active, and a provider-created Limrun instance gets deleted.
This adds an opt-in retainOnClose to leases.allocate. That lease survives close and ends through leases.release, expiry, or daemon shutdown, which now also releases leases no session holds. The default is unchanged, and an older daemon ignores the field.
await client.leases.allocate({ tenant, runId, leaseBackend: 'ios-instance', leaseProvider: 'limrun', retainOnClose: true });
22 files. Fixing this in e2e would cost it a fresh session after failures and leave closeApp broken. tester-army/e2e#792 covers local claims, unchanged here.
Validation
Tested commit 918e01b; CI pending on this head.
pnpm check:affected --run: 4803 tests pass. Each new test fails under its mutation.- Live Limrun iOS and Android, e2e unchanged, provider passing
retainOnClose:closeAppthenopen, a failing file then the next, and a 75 s idle pass. Without the flag, it fails aftercloseApp. - Org-key Android: the instance stays
readyafterclose,terminatedafterdaemon stop.