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§
- Sweep
Report - v0.7.0 I3 — outcome of one
sweep_transcript_lifecyclepass. - Transcript
- Lightweight handle for a stored transcript. Does NOT carry the blob
itself — callers fetch the decompressed content on demand via
fetch. TheTranscripthandle is what insert/list operations return so the (potentially multi-MB) payload doesn’t need to flow through every API surface. - Transcript
Link - 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
fetchruns. 16 MiB is large enough that no legitimate transcript stored viastoreis 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. ReturnsOk(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, mirroringfetch. TheTranscripthandle carriescreated_at,compressed_size, andoriginal_size, which I4’smemory_replayjoins 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 = ONis set on every connection opened bycrate::db::open). - memories_
for_ transcript - Return every memory derived from a given transcript.
- purge_
expired - Delete every row whose
expires_atis in the past (relative to “now”). Returns the number of rows removed. - store
- Compress
contentwith zstd-3 and write a row tomemory_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.