Skip to main content

Module session

Module session 

Source
Expand description

~/.omni-dev/voice/<id>/ session directory I/O.

Lays out and reads the session directory format from #799:

~/.omni-dev/voice/<session-id>/
  meta.yaml          # session config (this issue: last_reflected_event_id + ttl defaults)
  transcript.jsonl   # append-only TranscriptEvent stream from `voice transcribe`
  events.jsonl       # append-only Event stream from `voice reflect` (and later `voice review`)
  reflections.log    # per-reflection summary line (cost, latency, status)

Shared with #804 (voice review), which reads the same events.jsonl to produce materialised markdown projections. The session root path is derived from dirs::home_dir() by default; the OMNI_DEV_VOICE_ROOT environment variable overrides it (intended for tests, not a stable user-facing knob).

Structs§

Session
Combination of paths and the parsed meta document.
SessionMeta
Parsed contents of meta.yaml.
SessionPaths
Filesystem paths under a single session directory.
TtlDefaults
Default TTLs per item class (per #799), stored in meta.yaml so a session can override them. Serialised as integer seconds.

Functions§

append_events
Appends events as JSONL to path. Each event is one line, flushed after the batch. Skips silently when events is empty.
append_log_line
Appends a single line (with newline) to reflections.log. Creates the file if it does not exist.
open_or_create
Opens an existing session, or creates an empty one if the directory doesn’t exist. Bootstrap is idempotent: re-running against an already-populated session reads the existing meta.yaml.
open_or_create_under
Variant of open_or_create that takes an explicit voice root — useful for tests that drive several sessions under a tempfile directory.
read_events
Reads all reflection Events from events.jsonl. Returns an empty vec if the file doesn’t exist (greenfield session).
read_meta
Reads and parses meta.yaml.
read_transcript
Reads all TranscriptEvents from a JSONL file. Blank lines are skipped; parse errors include the line number.
read_transcript_finals_after
Reads only Final transcript events after the optional marker.
voice_root
Resolves the session root: $OMNI_DEV_VOICE_ROOT if set, else ~/.omni-dev/voice.
write_meta
Writes meta.yaml atomically (write-temp-then-rename).