Skip to main content

Module activity_stream

Module activity_stream 

Source
Expand description

Real-time “memory pipeline” event stream powering the TUI’s Activity tab.

Mirrors jcode’s MemoryEvent design: each retrieval / injection / reinforcement emits a small typed record to a JSONL file at $DIFFLORE_HOME/activity.jsonl. The TUI tail-reads this file and renders the last N events so users SEE rules being recalled and reinforced as their agent runs.

Why a JSONL file rather than an in-process channel: the MCP server, CLI fix command, and TUI run as separate processes. A file is the cheapest cross-process bus that survives a TUI restart and needs no daemon. Capped at 1000 lines via tail-rotation so it never grows without bound.

Structs§

ActivityEvent
One line in activity.jsonl. kind is the discriminant; payload fields live alongside it (flat layout — easier for ad-hoc jq inspection than a tagged enum).

Enums§

ActivityPayload

Constants§

MAX_EVENTS
Hard cap on retained events. When a write would exceed this, the file is truncated to the last MAX_EVENTS - 1 lines plus the new one. Keeps the file readable in cat and bounded on disk.

Functions§

record
Append payload to the activity log. Best-effort: any IO failure is swallowed so telemetry never breaks the caller. When the file would exceed MAX_EVENTS lines, rotates by tail-keeping the most recent.
record_to
Test-friendly variant of record that writes to an explicit path instead of $DIFFLORE_HOME/activity.jsonl. Production callers should use record; tests use this to avoid a shared-env-var race against the workspace-wide shared_test_home().
tail
Read the last n events from disk, newest-first. Best-effort: a missing or unreadable file yields an empty Vec so the TUI can render an empty state without erroring.
tail_from
Test-friendly variant of tail.