fix(cli): hermes insights opens state.db read-only (salvage #109737) - #110026
Closed
kshitijk4poor wants to merge 5 commits into
Closed
kshitijk4poor wants to merge 5 commits into
kshitijk4poor wants to merge 5 commits into
Conversation
`hermes insights` and the `/insights` slash command are pure readers, but they constructed `SessionDB()` read-write, so a one-shot CLI invocation took a writer connection on the live gateway's state.db. The field failure that motivated NousResearch#109737 (a sibling CLI close unlinking the live gateway WAL) was root-caused and fixed in e16f686 (NousResearch#109841); the Python 3.11 pin-every-writer branch and the NO_CKPT wrapper from the original PR are unnecessary and leak a connection per transient SessionDB, so they are not carried here. What remains is the hygiene: a reader must not open the store read-write. `SessionDB(read_only=True)` is the existing read-only path on main (NousResearch#77627). Salvaged subset of NousResearch#109737. Co-authored-by: Cursor <cursoragent@cursor.com>
Both `/insights` and `hermes insights` must open SessionDB read-only for the same reason, so one parametrised-by-loop test keeps the invariant count at one per fix and avoids two near-identical bodies drifting apart.
SessionDB(read_only=True) requires an existing state.db (the writer path used to create it), so a brand-new install would have printed "Error generating insights: unable to open database file". Check for the file first, as update_cmd_maint does before its read-only open.
hermes_state._default_db_path() honours a re-pointed DEFAULT_DB_PATH; re-deriving get_hermes_home()/state.db could disagree with the read-only open one line later (the test sandbox re-points it, which is how the mismatch surfaced). Same pre-check web_routers/status.py already uses.
5 tasks done
7 tasks done
yoniebans
added a commit
that referenced
this pull request
Sep 14, 2026
SessionDB(read_only=True) cannot create a missing store, so a fresh install running hermes insights / /insights errored instead of reporting no data (reported by @ehz0ah on #110718; guard shape from @kshitijk4poor's #110026). Co-authored-by: kshitijk4poor <kshitijk4poor@users.noreply.github.com>
teknium1
pushed a commit
that referenced
this pull request
Sep 14, 2026
SessionDB(read_only=True) cannot create a missing store, so a fresh install running hermes insights / /insights errored instead of reporting no data (reported by @ehz0ah on #110718; guard shape from @kshitijk4poor's #110026). Co-authored-by: kshitijk4poor <kshitijk4poor@users.noreply.github.com>
Collaborator
|
The insights read-only conversion landed on main via #110718 (9d75f20) with @B0on's commit kept under his authorship, plus the missing-store short-circuit. Redundant now; closing with thanks @kshitijk4poor. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
hermes insightsand/insightsare readers; they no longer open state.db as a writer.Salvage of #109737 by @B0on (cherry-picked with authorship preserved, reduced to the insights conversion), then three follow-up commits.
Changes
hermes_cli/cli_info_mixin.pyandhermes_cli/main_agent_cmds.py:SessionDB(read_only=True)(main's existing read-only path).No session data yet.instead ofError generating insights: unable to open database file(the read-only open requires the file; the writer path used to create it). The check useshermes_state._default_db_path(), the same resolver the constructor uses.Why the subset: #109737 also pinned every healthy writer open on Python 3.11 when other holders exist and added a NO_CKPT wrapper. The field failure it targeted (a sibling CLI close unlinking the live gateway's WAL) was root-caused and fixed by e16f686 (#109841), and the pin leaks one connection per transient
SessionDBin long-lived processes. The read-only hygiene is what remains worth landing.Validation
scripts/run_tests.sh tests/cli/test_cli_insights_command.pyread_onlyflags[False, False]; branch:[True, True]Follow-up (not this PR): samalone's report on #109737 that
tui_gateway/server.py::_profile_dbacquires a writer on a foreign profile's live store.