Skip to main content

Module capture

Module capture 

Source
Expand description

Capture — importing sessions from the agent CLIs a user actually runs.

crate::transcript says where each CLI’s sessions live and how to read one. This module decides which of them to read and turns them into archives, for the two callers that need it: recall-echo ingest on demand, and the daemon’s background sweep once the machine is quiet.

§Not ingesting anything twice

Two filters, and the cheap one is not the authoritative one.

  • A watermark per CLI (capture/<cli>.watermark) holds the last write time already dealt with, so a sweep does not re-read a year of transcripts to learn it has nothing to do. It advances only over transcripts that were actually handled, and stops advancing at the first failure — losing a watermark costs a rescan, and that is the only thing it may ever cost.
  • The archives themselves decide. A session whose id already appears in conversations/ is skipped, and the check is made twice: once on the id discovery derived from the file’s name, and again on the id the parsed transcript reports, in case a CLI’s two answers ever disagree.

§Sessions that are still going

A transcript is a live file. Importing one mid-session would archive half a conversation and then mark that session captured forever, so a transcript is only imported once it has been untouched for [capture] settle_secs. That is also what stops recall-echo ingest, run from inside a Codex or Grok session, from capturing the session it is being run from.

Structs§

CaptureOptions
How a sweep decides what is ready.
CaptureReport
What one CLI’s sweep did.
Pending
The transcripts of one CLI, sorted into what a sweep may do with them.
Watermark
Tracks how far a sweep may claim to have got.

Functions§

archive_transcript
Read one transcript and archive it.
archived_sessions
Session ids already represented in conversations/.
configured_sources
The CLIs ingest and the daemon sweep work on, given a config.
ingest
Import every configured CLI’s finished sessions, reporting to stderr.
pending
The transcripts of one CLI that are worth reading right now.
read_watermark
The last write time this CLI has been swept up to, if any.
sweep
Import one CLI’s finished, unarchived sessions.
write_watermark
Record how far this CLI has been swept.