f45813ea77
After `hermes update`, an existing state.db on an old schema made every GET /api/sessions poll fail with sqlite3.OperationalError "no such column: s.last_read_at" (or s.last_activity_at) until something unrelated forced a writable open — the desktop sidebar showed "No sessions yet" while every row sat intact on disk (#79531, #80037). Two remaining root causes (the stale hand-written read probe was already replaced by the SCHEMA_SQL-derived probe on main, prototyped in draft PR #80030 by @Tilly-YL): 1. Migrations ran lazily: _init_schema/_reconcile_columns only ran on a writable open, typically the user's first NEW session. The dashboard backend now schedules one writable open of its own state.db from the lifespan (daemon thread, never blocks the ready-probe socket, never raises), so the store is brought current before the first session- list poll on every `hermes serve` / `hermes dashboard` / Desktop headless entrypoint. 2. _reconcile_columns caught sqlite3.OperationalError around every ALTER TABLE ADD COLUMN and logged at DEBUG. Lock contention from orphaned sibling backends made the ALTER fail silently — startup "succeeded" with a half-reconciled schema, and the open-time lock patience (#74478) never saw the error because it was swallowed inside first. Now: "duplicate column" races stay at DEBUG, locked/busy re-raises so _connect_and_init_with_lock_patience retries the whole idempotent init with jittered backoff, and any other failure (e.g. un-ADDable NOT NULL) logs at WARNING. Regression tests: a store missing sessions.last_read_at is healed by the eager startup reconcile and serves list_sessions_rich; a locked ALTER propagates and is retried to success by the open lock patience; duplicate-column races stay quiet; other ALTER failures warn. Fixes #79531 Fixes #80037 Reported-by: @yenhunghuang (#79531) and @FLOW3R0111 (#80037) Root-cause analysis: @wangyi0177-eng (stale read probe) and @www654cc-pixel (_reconcile_columns DEBUG-swallow under lock contention); draft PR #80030 by @Tilly-YL prototyped the probe fix.