pub fn sweep_transcript_lifecycle(
conn: &Connection,
cfg: &TranscriptsConfig,
) -> Result<SweepReport>Expand description
v0.7.0 I3 — drive the transcript archive→prune lifecycle once.
Two phases run in order against the supplied connection. Per the
I3 contract the connection is held for the full sweep so the two
phases see a consistent now:
-
Phase 1 — ARCHIVE. For every live transcript (non-NULL
archived_atis skipped), resolve the per-namespace lifecycle fromcfg, then archive the row when:created_at + default_ttl_secs < now(transcript itself is old enough to retire), and- every memory linked to the transcript via the I2 join table has either expired or been deleted (a transcript with no linked memories trivially satisfies this — there is nothing keeping it live).
-
Phase 2 — PRUNE. Hard-DELETE every archived row whose
archived_at + archive_grace_secs < now. TheON DELETE CASCADEdeclared onmemory_transcript_linkscleans up the join table without an explicit second statement.
Phase 2 runs even if Phase 1 had errors so a single poisonous row
in the archive scan does not block the prune side. SweepReport
is the wire-shape returned to the daemon’s metrics emitter.
§Errors
Returns an error only on infrastructure-level SQLite failures
(connection lost, disk full). Per-row failures are folded into
SweepReport::errors.