Lease keeper
Spec companion · demoEvery cloud machine now runs under a lease. No heartbeat, no machine — worst-case zombie cost is one TTL.
TL;DR
Scope
In scope
- Lease issue, renew, expire
Not in scope
- Multi-region failover
Launch checklist
- Shadow mode ran 7 days clean
- Runbook reviewed by on-call
- Lease
- A time-limited permit to keep one machine running.
- Zombie
- A machine still billing after its work ended.
Reclaim runs off a heartbeat, so a crashed run can't outlive one TTL. Hover or focus a dotted term to read it in the legend panel.
What changes
Engine grabbed machines directly; crashed runs billed for weeks.
BeforeEvery machine runs under a lease with forced reclaim.
After- Specsigned off
- Shadowday 4 of 7
- Cutovergated on shadow
Promised vs delivered
Trace appendix (not for reading)
keeper/lease.ts:42
Code exhibit
Click a line to annotate it; shift-click extends the range. The floating button copies every note in agent-ready form.
keeper/lease.tsclick a line to annotate · shift-click extendsasync function renewLease(lease: Lease) {
const deadline = lease.expiresAt - RENEW_MARGIN_MS;
if (Date.now() < deadline) return;
await keeper.renew(lease.id, TTL_MS);
metrics.count("lease.renewed");
}
Structure: stack and shapes
Before/after of who calls whom and what flows through — the abstractions at a glance.
-
handleRequest
-
renewLeasevalidation, IO, and billing inline
-
renewLeasevalidation, IO, and billing inline
renewLease
(id: string) → Promise<boolean>
-
handleRequest
-
renewLease
-
validateTtl
-
persistLeaseall IO now lives here
-
validateTtl
-
renewLease
renewLease
(lease: Lease, ttl: Ms) → Renewed | Expired
outcome is a value, not a boolean
persistLease
(lease: Lease) → Promise<void>
Recall what stuck
The preferred check: flip cards that ask before they tell. Answer in your head, flip, then mark yourself. "Copy missed" emits the cards you missed as agent-ready text.
Check yourself
What forces a zombie machine off?
Why did the TTL ship at 15 minutes instead of 5?