Expand description
The durable state model: entity kinds, the manifest, the write-ahead
inbox, timers, the checkpoint policy and the restore protocol — one façade
(Durable) over a crate::store::Store that the runtime is the single
writer of.
Every entity is a versioned Envelope under <prefix>/<instance>/<kind>/<id>;
Durable::put allocates the next seq per key and treats a CAS conflict
on a key it already owns as fatal (a second writer). The manifest indexes
the live entities so a store without list can still be restored; it is
flushed debounced (store.checkpoint.debounce_ms) and at drain.
Modules§
- ulid
- A dependency-free ULID (Universally Unique Lexicographically Sortable
Identifier): 48-bit ms timestamp + 80 random bits, Crockford base32, 26
chars, monotonic within one process for the same millisecond. Used for
inbox events, runs, artifacts, audit records — sortable by time in the
store’s
listand stable across restarts.
Structs§
- Durable
- The durability façade: the single writer’s view of the store.
- Entity
Ref - One live entity in the manifest index.
- Inbox
Event - A write-ahead inbox event: durably recorded before it is acted on, so a crash between arrival and handling replays it instead of dropping it.
- Manifest
- The instance manifest: the index of everything a restore must find, stored
as one record under the
manifestkind. - Policy
- The checkpoint policy knobs (
store.checkpoint,store.durability,store.on_error). - Restored
- What a restore found.
- Stream
Meta - A stream’s durable counters.
- Timer
Record - A durable timer: an absolute deadline plus who owns it. The deadline is absolute rather than a remaining duration so that time spent down still counts, and a timer that came due while the process was gone fires at once.
Enums§
- Inbox
Status - Kind
- The entity kinds a durable record can carry. The kind is a key segment, so adding one changes what a restore can enumerate by prefix.
Functions§
- config_
digest - The digest of the settings that shaped the durable state: section name → SHA-256 hex of that section’s canonical JSON.
- fresh_
requested - Whether
--freshwas given. - kill_
point - A test kill point: with
AGENTD_TEST_KILL_AT=<name>set (debug /internal-mocksbuilds only), the process SIGKILLs itself here — the chaos suite’s way of dying at an exact instant between two durable writes. It compiles to nothing in a release build withoutinternal-mocks, so a production binary carries no self-kill path. - record_
config_ digest - Record the digest of the configuration this process runs under, for
Durable::restoreto compare against the manifest’s. First call wins — the configuration is loaded once, before any side effect. - request_
fresh --freshwas given: the nextDurableopened in this process starts a new generation instead of resuming.