Skip to main content

Module store

Module store 

Source
Expand description

The state store contract and adapters (RFC 0025 §2, §4).

agentd’s durability rests on four operations — put(key, seq, envelope) / get(key[, seq]) / list(prefix) / delete(key) — implemented by an adapter chosen in store.kind: mcp (any MCP server’s tools, mapped), http (plain HTTP), [file] (the local filesystem, RFC 0033 — durable for one host, single-writer), or memory (in-process; tests and dev). put is a compare-and-set on seq: the stored seq must be lower, else Conflict — the split-brain guard every caller treats as fatal. agentd links no database client and defines no schema beyond the Envelope.

Modules§

file
The local-filesystem store (RFC 0033) — store.kind: file. One file per key, atomic writes, an exclusive instance lock, and traversal closed at the adapter.
http
The HTTP store (RFC 0025 §4.2): the four operations as plain HTTP requests built from store.http.{get,put,list,delete} templates — GET/PUT/POST/DELETE {url} with an optional JSON body, extraction from body/status/headers. HTTPS (loopback http:// for dev), headers may carry {{secret:…}} references (resolved at dial time, never logged), the idempotency key rides as Idempotency-Key; conflict_status (default 409) maps to Conflict, 404 on a read to absent.
mapping
The mapping language the store adapters and the tool overrides share (RFC 0025 §4, RFC 0028 §4): render an argument object / URL / body from a template over named inputs, and extract a value from a result.
mcp
The MCP-mapped store (RFC 0025 §4.1): the four store operations are tools/calls against a declared MCP server, with argument templates and result extraction from store.mcp.{put,get,list,delete}. The default mapping is the RFC 0021 §8.3 checkpointer profile (state.put/get/list, state.delete), so a server advertising those tools needs no mapping.
memory
The in-process store (RFC 0025 §4.3) — store.kind: memory. Keeps per-key history (so get(key, seq) works like a history-keeping server), enforces the seq CAS, supports list/delete, and offers fault injection for tests: fail the next N operations, add latency, or refuse a specific key. Not durable across the process (dev/test only — the loader warns).

Structs§

Envelope
A versioned store record: state is the kind-specific payload; a tombstone carries state: null.
KeySeq
A list entry.

Enums§

PutOutcome
The outcome of a put.
StoreError

Constants§

ENVELOPE_VERSION
The envelope major this build writes and accepts (RFC 0025 §3.2).

Traits§

Store
The four-operation contract (RFC 0025 §2). Implementations are Send + Sync so the runtime’s executor pool can call them; every operation is bounded by the adapter’s timeout.

Functions§

default_timeout
The store timeout class: the management timeout (RFC 0016 §10) unless the settings say otherwise.
key
<prefix>/<instance>/<kind>/<id> (RFC 0025 §3.1).
open
Build the store an instance is configured with (RFC 0030 §3.5). servers resolves the mcp adapter’s coordination server by name; kind: none yields no store (the caller decides whether that is allowed).
parse_key
Split a key produced by key back into (kind, id) for the given prefix/instance; None for a foreign key.
with_retry
Bounded retry on Io errors (never on Conflict/Mapping/Corrupt).

Type Aliases§

SharedStore
A shared store handle.