Bound the terminal spool and the history store; key spool records by session #6

closed cmc opened this on 2026-09-04 03:56 UTC · milestone v0.4 — one bus

cmc 2026-09-04 03:56 UTC

Three related growth and correctness problems.

Spool never truncated. shell-hooks/signald-hooks.zsh appends one record per precmd and nothing removes them. collectors::terminal::collect reads the whole file every tick (default 2 s) and re-derives the same values.

Spool records are not per-session. Every shell appends to the same file. keys_per_min in crates/signald/src/lib.rs compares the last two records regardless of which shell wrote them, so with two or more terminals open the rate mixes sessions and is meaningless. session_seconds likewise reports whichever shell flushed last.

History grows unbounded. History::record inserts every published signal. At the default interval one watched repo produces roughly 260k rows per day with no pruning.

Done when:

  • Spool records carry a session id (the shell's $$ is fine; it is a number, not content) and the collector aggregates per session, publishing one keys_per_min per active session or a documented cross-session sum.
  • The collector consumes the spool (truncate after read, or track an offset) so it does not regrow forever and is not re-read in full each tick.
  • History prunes rows older than a configurable retention (default on the order of days) on open and periodically.
  • The differential secret-typing tests still pass; the spool format change must not add any field capable of carrying content.

closed by commit bee32a07c9 by cmc: Bound the terminal spool and the history store

2026-09-04 04:50 UTC