Skip to content

cue.digest

Haiku-backed periodic summarizer for the streaming recorder.

Pruner is the arbiter of "meaningful activity" — its keyframes are the truth. The digest: 1. fires when digest_every_keyframes new keyframes have appeared (or when the timer digest_every_s elapses, or on a hotkey trigger); 2. sends the last digest_window_keyframes keyframe JPEGs plus a text log of the raw MCAP events in that same time range to Haiku; 3. writes the resulting 3-line Korean summary atomically to digest.md.

The hotkey path reads digest.md via read_digest() so Opus gets an accumulated memory without paying for a Haiku round-trip at trigger time.

read_digest

read_digest() -> str | None

Return current digest contents or None if missing/empty.

run_digest_loop

run_digest_loop(cfg: dict, stop_event: Event, is_idle_fn) -> None

Background thread entry. Owned/launched by recorder.py.

Pure keyframe-count trigger: fires once digest_every_keyframes new keyframes have appeared since the last run (scheduled or hotkey-forced). Polls every _SCHEDULED_TICK_SECS (5 s). Sub-second wake isn't worth an IPC hop — pruner runs in the ocap subprocess and writes keyframes to disk, so the only signal that crosses the process boundary is file appearance, which polling observes just fine.

trigger_now

trigger_now(cfg: dict | None = None) -> str | None

Run the digest synchronously (hotkey path).

Uses the same new_since_last + context window as the scheduled loop — we don't re-digest the full 30-frame window on every hotkey press, we re-digest the un-summarised tail plus a small context lead-in.

evict_entries_newer_than

evict_entries_newer_than(cutoff_ns: int) -> int

Privacy-pause cascade: remove digest rows captured at or after cutoff_ns and rewrite digest.md from whichever older row survives.

digest.md in the current architecture holds only the single most-recent summary (the history lives in the SQL digests table). If the purge took out the most recent row, we rewrite digest.md from the newest surviving row so Opus still sees a coherent (older) context. If the table is empty afterwards, the file is deleted.

Inclusive >= matches the recorder/pruner purge convention.