7 Commits

Author SHA1 Message Date
teknium1 496eb13bd7 fix(state): one corrupt timestamp row no longer kills sessions list, export or insights
SQLite dynamic typing lets a TEXT cell ('not-a-timestamp'), inf/nan or a
garbage double (8.4e252 salvaged from a damaged page) sit in a REAL
timestamp column. Every reader called datetime.fromtimestamp()/float
arithmetic on the raw cell, so ONE bad row raised TypeError/OverflowError
out of the row loop and took down the whole `hermes sessions list`/browse
table (#102399), all three exporters — JSONL/MD, QMD, HTML (#102352) —
and `hermes insights` (#99959).

Fix the class with ONE helper, hermes_cli.timefmt.coerce_epoch(): a
stored cell becomes float epoch seconds inside a sane 1970..2103 window
or None after a WARNING that names the session id. Every reader routes
through it — relative_time (list/browse/resume picker), format_epoch
(prune/candidates tables), the three exporters' timestamp formatters,
insights' _get_sessions/_day/period range — so a bad row renders as
'?'/'N/A'/raw text for that one cell and the command completes.

Write side: hermes_state_messages._coerce_timestamp (append_message,
append_messages_batch, import) and the import path's started_at now use
the same window, so a new out-of-range timestamp falls back to now()
instead of being persisted — new bad rows cannot be written by Hermes.

Reported-by: #102399, #102352, #99959 reporters; kokhlo's insights
analysis pointed at every reporting site, not just line 860.
2026-09-11 06:24:54 -07:00
Teknium d489d01dce refactor(hermes_cli): browse key handling early-returns; salvage helper one-liners 2026-09-02 23:42:50 -07:00
Teknium 4dacaa265d refactor(hermes_cli): sessions_cmd_browse _clip helper, hoisted invariants 2026-09-02 22:59:16 -07:00
Teknium 679b303ba1 refactor(hermes_cli): drop intra-function blank separators in session modules (AST-identical) 2026-09-02 22:55:35 -07:00
Teknium a0e05e686a refactor(hermes_cli): compact sessions_cmd_browse and session_recap 2026-09-02 21:56:55 -07:00
Teknium 1d2b39305f refactor(cli/sessions_cmd): unify output writer, compact browser class, tighten comments 2026-09-02 15:57:43 -07:00
Teknium 1172735295 refactor(cli/sessions_cmd): split cmd_sessions into per-subcommand handlers + dispatch dicts; extract browse picker to sessions_cmd_browse 2026-09-02 15:45:35 -07:00