Skip to main content

Module retrieval_store

Module retrieval_store 

Source
Expand description

F-045: reversible evidence store and retrieval (roadmap.md F-045, interfaces.md “Retrieval Marker Grammar” and the [retrieval] tokenfold.toml schema block).

Granularity in this pass is whole-payload, not per-span: pipeline.rs stores the entire pre-transform input under its SHA-256 content hash when CompressionPolicy.store_originals is set and the payload contains no secret-shaped content. Per-span inline [tokenfold:retrieve ...] markers are an explicitly out-of-scope future enhancement (see the marker grammar’s own fallback rule: “If a format cannot carry markers safely, markers live only in CompressionReport.retrieval”).

Hash algorithm is SHA-256 only in this pass; blake3 is a documented, rejected scope cut (see RetrievalStore::open). Backends are memory (in-process, used in tests) and filesystem (the default persistent backend); sqlite is likewise a documented, rejected scope cut.

Structs§

GcOutcome
MemoryEntry
RetrievalMarker
One retrieval marker’s worth of metadata, per interfaces.md’s Retrieval Marker Grammar: [tokenfold:retrieve hash=<hex> alg=sha256 namespace=<ns> bytes=<n> ttl=<seconds>].

Enums§

RetrievalOutcome
Result of a retrieval lookup. Deliberately has no “partial” variant: a caller either gets the exact original bytes back, or an explicit reason it did not.
RetrievalStore
A content-addressed, namespaced store for reversible originals. Backend-dispatching enum rather than a trait object: only two live variants exist in this pass, so a trait would add indirection without buying any real polymorphism.

Constants§

DEFAULT_TTL_SECONDS
tokenfold.toml’s documented [retrieval].ttl_seconds default (7 days).

Functions§

default_store_path
$XDG_DATA_HOME/tokenfold/retrieve, falling back to <home>/.local/share/tokenfold/retrieve when XDG_DATA_HOME is unset — mirrors tokenfold-cli::config’s HOME/USERPROFILE fallback for home_dir(). Deliberately not a Windows-native path (e.g. %LOCALAPPDATA%): the rest of the codebase is XDG-everywhere by convention.
hex_sha256
Lowercase hex SHA-256 of bytes.