History: read-only open and last_activity_ms !26

merged merged by cmc on 2026-09-04 17:17 UTC · krz/ambient-companions:feat/history-read-only into main

cmc

First of the menubar-pet stack.

open_read_only exists because open prunes, creates and migrates on the way in — a face polling every five seconds must not mutate the daemon's store as a side effect of reading it. A test proves the contrast directly: a read-only open leaves an over-retention row alone, and a normal open then prunes it.

last_activity_ms counts only a keystroke rate or commit count above zero. SessionSeconds is excluded — a shell left open is not attention — and so are the hardware signals, since a sleeping machine still reports a battery percentage. A zero is not activity either, or a quiet day would keep the pet alive indefinitely.

Verified against the live 39,329-row database: the timestamp resolves to a minute earlier, and the row count is identical before and after.

Closes #16