Skip to main content

Module state

Module state 

Source
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 list and stable across restarts.

Structs§

Durable
The durability façade: the single writer’s view of the store.
EntityRef
One live entity in the manifest index.
InboxEvent
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 manifest kind.
Policy
The checkpoint policy knobs (store.checkpoint, store.durability, store.on_error).
Restored
What a restore found.
StreamMeta
A stream’s durable counters.
TimerRecord
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§

InboxStatus
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 --fresh was given.
kill_point
A test kill point: with AGENTD_TEST_KILL_AT=<name> set (debug / internal-mocks builds 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 without internal-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::restore to compare against the manifest’s. First call wins — the configuration is loaded once, before any side effect.
request_fresh
--fresh was given: the next Durable opened in this process starts a new generation instead of resuming.