Skip to main content

Module lifecycle

Module lifecycle 

Source
Expand description

The pure lifecycle state machine every Registry backend composes over.

This is the single source of the pact lifecycle semantics — the claim-eligibility predicate, the state transitions, the current-holder authority check, and the lease arithmetic. A backend owns its own storage and mints its own retainer (a fencing value); it delegates every eligibility decision and transition here, so the semantics are defined once and cannot drift between backends (or between a synchronous and a future asynchronous binding).

It is colorless and sans-I/O: it reads no clock (time is an injected parameter), performs no I/O, and mints nothing non-deterministic (the retainer is supplied by the caller). Named lifecycle to distinguish it from the executor step-driver kernel, which is a different pure machine.

Structs§

NotCurrentHolder
A transition was attempted by something that is not the state’s current holder — a stale retainer, or a state (available, deferred, settled) with no holder at all.

Enums§

State
A pact’s position in its claim lifecycle: the pure state a backend maps to its own storage. The backend owns where it lives; this owns what it means.

Functions§

is_claimable
Whether a pact in state may be claimed at now: the eligibility invariant. Available always; a Held lease that has lapsed; a Deferred pact at or past its instant; never a Settled one. Only positive, unambiguous eligibility.
lease_expiry
The lease expiry for a claim taken at now for lease_millis — the single source of the lease arithmetic.
on_claim
The state a successful claim produces: Held by retainer until the lease expiry for now/lease_millis. The backend mints retainer and passes it in.
on_heartbeat
The state a heartbeat produces: the lease extended to the expiry for now/lease_millis, provided retainer currently holds state and the lease has not already lapsed. A lapsed lease is not revived — the holder must re-claim.
on_release
The state a release produces: Deferred until reclaimable_at, provided retainer currently holds state. Non-terminal; rotates authority away.
on_settle
The state a settlement produces: Settled, provided retainer currently holds state. Fulfill and breach share this — the lifecycle state records that the obligation concluded, not which outcome concluded it.