leaseTransition
leaseTransition(
state,event):LeaseTransition
Defined in: packages/core/src/state-machine/index.ts:417
The single-writer lease protocol.
Invariants (checked exhaustively in machines.test.ts, by the reference
model in invariants.property.test.ts and by TLC in
specs/SessionStore.tla):
- A live lease (
until > now) has exactly one owner. acquireby a different owner never succeeds while another live lease exists.renewnever changes the owner and never resurrects an expired lease.- Only the owner can release.
- TTL is measured from the caller’s
now; an expired lease is free.
The legal source states come from leaseMachine; the guards and next values
are the pure may* and heldAfter* functions above, shared with the model
tests and the reference property model.
Parameters
Section titled “Parameters”{ _tag: "free"; } | { _tag: "held"; owner: string; until: number; }
{ _tag: "acquire"; now: number; owner: string; ttlMs: number; } | { _tag: "renew"; now: number; owner: string; ttlMs: number; } | { _tag: "release"; owner: string; } | { _tag: "expire"; now: number; }