Skip to main content

Module storage

Module storage 

Source
Expand description

CRUD, zstd helpers, lifecycle sweep, and data types for memory_transcripts.

All I1/I2/I3 logic lives here. See super for the module-level overview of the v0.7.0 I-track substrate.

Structs§

SweepReport
v0.7.0 I3 — outcome of one sweep_transcript_lifecycle pass.
Transcript
Lightweight handle for a stored transcript. Does NOT carry the blob itself — callers fetch the decompressed content on demand via fetch. The Transcript handle is what insert/list operations return so the (potentially multi-MB) payload doesn’t need to flow through every API surface.
TranscriptLink
v0.7.0 I2 — provenance edge between a memory and a transcript span.

Constants§

MAX_DECOMPRESSED_BYTES
v0.7.0 I1 hardening — hard cap on the size of a single decompressed transcript. A pathological zstd blob (e.g. 1 KB compressed → 1 GB decompressed) would otherwise OOM the daemon when fetch runs. 16 MiB is large enough that no legitimate transcript stored via store is rejected (the store path itself ingests &str, so rows above this ceiling could only have been hand-crafted by a hostile writer with direct DB access). Surfaced as a constant so a downstream operator can audit the boundary in a code review without chasing magic numbers across modules.

Functions§

fetch
Fetch + decompress the transcript identified by id. Returns Ok(None) when no row matches; callers treat that as “transcript expired or never existed” and surface a structured error upstream.
fetch_metadata
v0.7.0 I4 — fetch the lightweight metadata for a transcript without pulling the (potentially multi-MB) decompressed content blob. Returns Ok(None) when no row matches, mirroring fetch. The Transcript handle carries created_at, compressed_size, and original_size, which I4’s memory_replay joins with the I2 link spans to assemble a per-transcript metadata block.
link_transcript
Insert (or replace) a provenance edge between a memory and a transcript. Both ids must already exist in their respective tables — the foreign keys are enforced (PRAGMA foreign_keys = ON is set on every connection opened by crate::db::open).
memories_for_transcript
Return every memory derived from a given transcript.
purge_expired
Delete every row whose expires_at is in the past (relative to “now”). Returns the number of rows removed.
store
Compress content with zstd-3 and write a row to memory_transcripts.
sweep_transcript_lifecycle
v0.7.0 I3 — drive the transcript archive→prune lifecycle once.
transcripts_for_memory
Return every transcript provenance edge for a given memory.