Bound the terminal spool and the history store !3

merged merged by cmc on 2026-09-04 04:50 UTC · krz/ambient-companions:fix/spool-history-bounds into main

cmc

Stacked on feat/hw-ingest; merge that first, then retarget this to main.

The zsh hook appends the shell's pid as a fourth field, so several shells can share one spool and the daemon keeps their rates apart. collectors::terminal is now a stateful Collector: each tick it consumes the spool (rename aside, read, delete) instead of re-reading a file that grew forever, and keeps the last two flushes per session. keys_per_min is each active session's rate summed; session_seconds is the longest active session. Sessions idle for five minutes age out.

History prunes rows older than --retention-days (default 7) on open and every 1000 inserts.

Both differential secret-typing tests drive the changed hook and pass; the spool still carries nothing but integers. Verified live with two interleaved sessions in one spool.

Closes #6

retargeted from feat/hw-ingest to main: !2 merged

2026-09-04 04:50 UTC