Expand description
Native durable execution layer for Zeph.
zeph-durable is a Layer-0 infrastructure crate — analogous to zeph-db and zeph-common —
that journals the control flow of an execution (individual steps, their inputs and outputs,
promises, and timers) so a crashed or interrupted execution can resume at the point of failure
rather than restart from scratch.
§Architectural placement
Consumers of this crate span several layers (zeph-scheduler, zeph-subagent,
zeph-orchestration, zeph-agent-tools), so the crate must sit at Layer 0. It is a pure
infrastructure primitive: it sees opaque serialized payloads, never domain types, and it
MUST NOT depend on zeph-llm, zeph-memory, zeph-core, zeph-sanitizer, or any
business-layer crate (INV-1). Domain meaning lives in thin adapter modules inside each
consuming crate.
§Module map
Type-level foundation:
ids— the journal-boundary newtypes (ExecutionId,StepId,JournalSeq,IdempotencyKey,PromiseId,TimerId) and theExecutionKinddiscriminator.journal— theJournaltrait plus theJournalEntry/EntryKind/ExecutionStatusdata model.cipher— thePayloadCipherAEAD contract,PayloadAadbinding, and the read-sidemax_payloadguard. The concrete cipher lives in a consuming crate (INV-1).effect— theEffectClassside-effect contract referenced by journal entries.config— re-exports the pure-dataDurableConfigandRetentionPolicy(which live inzeph-config) and owns theencryption_gateAEAD enforcement policy.error— the crate-wideDurableError.
Persistence engine:
backend— the sealedExecutionBackendtrait,BackendCapabilities, theDurableBackendEnumenum dispatcher, andLocalBackend(a dedicateddurable.dbpool).writer— the backgroundJournalWriteractor and its cloneableJournalWriterHandle: group-commit for buffered appends, flush-before-commit ACKs for exactly-once entries, andMAX(seq)restart resume.
Execution surface:
step— the durable step typestate:StepDescriptor(with the construction-time ambiguity rule),StepHandle,StepError,StepOutcome, andDurableStep.handle— the&selfDurableContextfront door: deterministic step ids, replay with a BLAKE3 divergence guard, the exactly-once intent/result protocol, andParallelScopefor completion-order-independent parallel batches.
The promise, timer, and retention layers build on these in follow-up issues.
§Schema ownership
zeph-durable owns no .sql files and no sqlx::migrate!. All durable schema (the
four durable_* tables) lives as numbered migration files in
zeph-db/migrations/{sqlite,postgres}/ and is applied via zeph_db::run_migrations against a
dedicated durable.db pool (INV-14).
§Examples
use zeph_durable::{ExecutionId, IdempotencyKey, StepId};
// Each execution gets a fresh, runtime-minted identity.
let execution = ExecutionId::new();
// Idempotency keys are domain-separated and deterministic for a given step.
let key = IdempotencyKey::derive(execution, StepId::new(0), b"tool:read_file");
assert_eq!(key, IdempotencyKey::derive(execution, StepId::new(0), b"tool:read_file"));Re-exports§
pub use backend::BackendCapabilities;pub use backend::CancelOutcome;pub use backend::DurableBackendEnum;pub use backend::ExecutionBackend;pub use backend::ExecutionLock;pub use backend::ExecutionSummary;pub use backend::LocalBackend;pub use backend::RedactedEntry;pub use cipher::CipherError;pub use cipher::EntryKindTag;pub use cipher::PayloadAad;pub use cipher::PayloadCipher;pub use cipher::ensure_payload_within_limit;pub use config::EncryptionGate;pub use config::encryption_gate;pub use effect::EffectClass;pub use effect::EffectIntentSubClass;pub use effect::OnAmbiguous;pub use error::DurableError;pub use handle::DurableContext;pub use handle::ParallelScope;pub use ids::ExecutionId;pub use ids::ExecutionKind;pub use ids::IdempotencyKey;pub use ids::JournalSeq;pub use ids::PromiseId;pub use ids::StepId;pub use ids::TimerId;pub use journal::EntryKind;pub use journal::ExecutionStatus;pub use journal::Journal;pub use journal::JournalEntry;pub use promise::DurableHandle;pub use promise::DurablePromise;pub use retention::DurableRetentionService;pub use step::DurableStep;pub use step::StepDescriptor;pub use step::StepError;pub use step::StepHandle;pub use step::StepOutcome;pub use timer::DurableTimerService;pub use writer::JournalWriter;pub use writer::JournalWriterHandle;
Modules§
- backend
- The sealed execution-backend abstraction and its enum-dispatch front door.
- cipher
- The confidentiality and integrity boundary for journaled payloads.
- config
- Durable configuration and the AEAD enforcement gate.
- effect
- The per-step side-effect contract.
- error
- The crate-wide error type.
- handle
- The
&selfdurable execution context. - ids
- Journal-boundary newtypes.
- journal
- The append-only journal abstraction and its data model.
- promise
- Durable promises: externally-completed handles that survive a crash-resume.
- retention
- Journal retention, the background prune sweep, and the checkpoint-fold codec.
- step
- The durable step primitive and its typestate.
- timer
- Durable timers: wakes that survive a process restart.
- writer
- The background journal-writer actor.
Structs§
- Durable
Config - Configuration for the durable execution layer (
[durable]). - Retention
Policy - Journal retention and compaction policy (
[durable.retention]).
Enums§
- Durable
Backend - Which journal backend an execution uses.