Skip to content

desktop sidebar profile migration - #70964

Open
webtecnica wants to merge 1 commit into
NousResearch:mainfrom
webtecnica:fix/desktop-sidebar-profile-migration
Open

desktop sidebar profile migration#70964
webtecnica wants to merge 1 commit into
NousResearch:mainfrom
webtecnica:fix/desktop-sidebar-profile-migration

Conversation

@webtecnica

Copy link
Copy Markdown
Contributor

Fixes issue

… profile state.db (NousResearch#70944)

After a Hermes update, profile state.db files can lag the current schema
because the gateway only migrates the default DB on startup. The desktop
sidebar aggregator opens profile DBs read-only, so list_sessions_rich fails
with sqlite3.OperationalError (no such column) and the profile contributes
zero sessions — an empty sidebar that looks like data loss.

Fix both cross-profile endpoints:
  - GET /api/profiles/sessions
  - GET /api/profiles/sessions/sidebar

When they catch sqlite3.OperationalError with 'no such column', they close
the read-only connection, open the DB read-write once (triggers _init_schema
→ column reconciliation), then re-open read-only and retry the query.

The write lock is brief (column reconciliation only) and happens at most
once per lagging profile.

Adds:
  - _migrate_db_if_schema_lags(db_path) helper
  - Schema-aware OperationalError handling in get_profiles_sessions
  - Two-attempt retry loop in get_profiles_sessions_sidebar
  - 5 tests covering both endpoints + idempotency + non-schema errors

Closes NousResearch#70944
Related to NousResearch#42467 (original diagnosis), unmerged NousResearch#42487 (partial fix)
@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/dashboard Web dashboard / control panel UI (dashboard/, landing) area/profiles Multi-profile isolation, HERMES_HOME scoping area/sessions Session lifecycle, resume, persistence, history sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades labels Jul 24, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Related to #42487: its current diff covers /api/profiles/sessions; this PR additionally repairs the batched /api/profiles/sessions/sidebar path.

@teknium1

Copy link
Copy Markdown
Contributor

Thanks for covering both the legacy list endpoint and the batched sidebar path; the schema-lag premise is still present on current main. hermes_cli/web_routers/profiles.py:130-171 and :285-307 open profile databases read-only and turn query failures into per-profile errors, while hermes_state.py:1840-1845 confirms that read-only opens skip column reconciliation.

Problems

  • The PR modifies the former hermes_cli/web_server.py route bodies. Current main extracted these endpoints to hermes_cli/web_routers/profiles.py:57 and :195 in 27b1377b4c, so this needs a manual port rather than a direct cherry-pick.
  • The proposed writable retry conflicts with the current sidebar contract. hermes_cli/web_routers/profiles.py:127-130 requires refresh-time aggregation not to DDL/write-lock another profile, and writable SessionDB initialization invokes _init_schema() at hermes_state.py:1918.

Suggested changes

  • Move migration to a write-permitted update/profile-start lifecycle path, keeping the aggregation endpoints read-only.
  • Port the two-endpoint regression coverage to the extracted router and assert that a normal sidebar refresh remains non-writing.

Automated hermes-sweeper review.

@teknium1 teknium1 added the sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform label Jul 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/profiles Multi-profile isolation, HERMES_HOME scoping area/sessions Session lifecycle, resume, persistence, history comp/dashboard Web dashboard / control panel UI (dashboard/, landing) P3 Low — cosmetic, nice to have sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants