Expand description
Daily wrap generator (Addendum A §9.1).
When a session ends after more than 2 hours of live use, the
CLI renders a wrap: a short, honest summary of what the
operator did this session. The wrap is saved under
~/.zero/state/wraps/<session_ulid>.json and printed as a
single advisory line on stderr. The next session does not see
the wrap — it is a closing statement, not a reminder.
§Honesty contract
- The wrap is computed, never curated. Every number traces back to rows in the session store; no rankings, no gamification, no “streak” counters (§15’s “no cute” locks those out).
- The wrap never editorialises. It reports: duration,
command counts grouped by risk direction, a few top-N
tallies, and — if present — the number of
warn/alertlines the dispatcher emitted. That is it. /wrap-offsuppresses the current session’s wrap only. The operator cannot permanently disable it (§15).
§Separation of concerns
generate is pure: it takes a SessionRow + its stored
events and returns a WrapReport. No disk I/O, no clock.
This lets tests run fast and deterministically.
write_wrap is the I/O half: it takes a report + a target
dir and writes <ulid>.json, returning the final path. Tests
use tempfile::TempDir or a throwaway path under
std::env::temp_dir() so production ~/.zero is never
touched.
Structs§
- Command
Count - A single entry in
WrapReport::top_commands. - Event
Counts - Per-kind event counts. Named fields rather than a HashMap so the JSON shape is self-documenting and readers do not have to probe for keys.
- Wrap
Report - The wrap artifact as persisted to disk and printed as a line in the log.
Constants§
- MIN_
WRAP_ DURATION - Minimum session length before a wrap is generated. The spec (Addendum A §9.1) says “session exit >2h”; re-declaring the threshold here lets callers avoid importing a magic number.
Functions§
- generate
- Pure wrap computation. No clock, no disk.
- should_
wrap - Determine whether this session qualifies for a wrap.
- write_
wrap - Persist a wrap report as
<dir>/<session_ulid>.json, creatingdirif needed. Returns the final path.