Expand description
Phase 18.2: Memory entry provenance.
Structural security gap #3 in docs/protocols/STRUCTURAL-SECURITY-FIXES.md
points out that agent memory writes (vector DBs, conversation history,
scratchpads) normally happen outside Chio’s guard pipeline, which lets a
compromised or confused agent plant cross-session prompt-injection
payloads with no attribution. Phase 18.1 governs the writes at the
guard layer; Phase 18.2 is the evidence side of that story: every
governed write appends an entry to an append-only, hash-chained
provenance log that ties the write to the capability and receipt that
authorized it. On read, the kernel looks up the latest provenance
entry for the (store, key) pair and attaches it to the receipt as
memory_provenance evidence.
Keys are pairs (store, key); the empty key string is the
canonical “whole-collection” marker emitted by MemoryRead when a
read does not target a specific document id. Reads whose key has no
chain entry are marked ProvenanceVerification::Unverified so the
caller can distinguish “never governed” from “tampered chain”.
Fail-closed semantics:
- Append returns
MemoryProvenanceErroron any store failure; the kernel wiring treats that as a fatal error on the memory-write path (the write has already been signed as allowed, but the provenance chain must not silently drop entries). - Verification returns
ProvenanceVerification::Unverifiedrather than an error when the chain is intact but no entry exists, and returns it with atampered: truereason when the stored hash disagrees with what canonical-JSON + SHA-256 would produce.
The trait is intentionally synchronous and mirrors the pattern used
by crate::approval::ApprovalStore,
crate::execution_nonce::ExecutionNonceStore, and the other kernel
stores: in-memory reference impl lives here, SQLite impl lives in
chio-store-sqlite.
Structs§
- InMemory
Memory Provenance Store - Thread-safe in-memory
MemoryProvenanceStore. Useful for tests and for ephemeral deployments; production deployments should use the SQLite-backed store inchio-store-sqlite. - Memory
Provenance Append - Input accepted by
MemoryProvenanceStore::append. - Memory
Provenance Entry - Entry committed to the append-only provenance chain.
Enums§
- Memory
Action Kind - Classification of a memory-shaped tool call extracted from a
ToolCallRequest. Emptykeyvalues mean “whole collection”. - Memory
Provenance Error - Errors returned by
MemoryProvenanceStoreimplementations. - Provenance
Verification - Result of looking up provenance for a
(store, key)pair. - Unverified
Reason - Why a memory read could not be verified against the provenance chain.
Constants§
- MEMORY_
PROVENANCE_ ENTRY_ SCHEMA - Schema tag used in canonical-JSON hashing. Bumping this invalidates existing chains.
- MEMORY_
PROVENANCE_ GENESIS_ PREV_ HASH - Sentinel
prev_hashused for the first entry in a chain. Kept as a fixed 64-character hex string of zeros so canonical-JSON hashing is deterministic and the chain has no special-case branch.
Traits§
- Memory
Provenance Store - Contract for the append-only, hash-chained memory provenance log.
Functions§
- classify_
memory_ action - Inspect
tool_name+argumentsand return a memory action if the call matches one of the well-known memory-write / memory-read tool name conventions. ReturnsNonefor everything else so non-memory tool calls bypass the provenance hook entirely. - next_
entry_ id - Mint a new entry id. UUIDv7 so ids sort monotonically by issuance
time, matching [
crate::receipt_support::next_receipt_id]. - recompute_
entry_ hash - Compute the canonical hash that binds every field of an entry into the chain.