Skip to content

fix: support current Hermes state.db and platform-aware paths - #25

Merged
pingchesu merged 2 commits into
mainfrom
fix/modern-session-backfill-issue-24
Aug 31, 2026
Merged

pingchesu merged 2 commits into
mainfrom
fix/modern-session-backfill-issue-24

Conversation

@pingchesu

@pingchesu pingchesu commented Jul 21, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • prefer the active Hermes profile's state.db for historical session backfill
  • read modern sessions through SessionDB(read_only=True) while preserving explicit legacy session_*.json imports
  • include durable display-history rows archived by Hermes in-place compaction when the installed get_messages API supports include_compacted
  • retain compatibility with pre-August-2026 Hermes versions that do not expose include_compacted
  • resolve skills, config, backup, log, evidence, and session defaults through the profile-aware Hermes home
  • mirror Hermes' %LOCALAPPDATA%\hermes fallback on Windows when hermes_constants is unavailable
  • expose --state-db and keep --sessions-dir as a mutually exclusive legacy override
  • surface missing/unreadable backfill sources instead of reporting a misleading successful zero-import

Why

Current Hermes persists durable session history in <HERMES_HOME>/state.db. The previous importer only scanned ~/.hermes/sessions/session_*.json, and several defaults bypassed Hermes' platform/profile-aware home resolver. As a result, modern session history was not backfilled and Windows default paths incorrectly targeted ~\.hermes instead of %LOCALAPPDATA%\hermes.

After this PR's original head was published, Hermes added get_messages(..., include_compacted=True) in f71f91a39 so transcript consumers can include durable rows archived by in-place compaction. Calling the old default shape silently imports only active rows and drops earlier durable turns. The refreshed PR detects that callable capability once per backfill run, opts in when available, and keeps the old call shape for older Hermes versions.

request_dump_*.json remains intentionally excluded because those files are debug request snapshots, not the durable session transcript contract.

Safety and compatibility

  • state.db is opened read-only through Hermes' existing SessionDB API.
  • Compacted-history support is detected from the callable signature; the importer does not catch and misclassify a TypeError raised inside get_messages.
  • Active sessions do not receive fabricated completion events.
  • Existing --sessions-dir behavior remains available for legacy exports.
  • Repeated state DB and legacy imports remain duplicate-safe.
  • The importer writes only Curator Evolver's evidence database; it does not mutate Hermes sessions or skills.

Verification

  • python -m pytest -q -p no:cacheprovider — passed on Python 3.11
  • python3.12 -m pytest -q -p no:cacheprovider — passed on Python 3.12
  • python -m ruff check --select F,I hermes_curator_evolver/backfill.py tests/test_backfill_sessions.py — passed
  • python -m compileall -q hermes_curator_evolver tests — passed
  • python -m pip wheel . --no-deps — built hermes_curator_evolver-0.10.0-py3-none-any.whl; a clean temporary venv installed it and rendered the backfill-sessions and bootstrap help paths
  • real E2E against current Hermes a9c783f21995723c812dcb2f8ae58bc6a4323e2f: created a temporary state.db, archived one turn through in-place compaction, reopened it read-only, and imported both archived + active turns with files_failed=0
  • pinned control: original PR head 07eb1be78566f479fcfa420005401aa623517199 imported only 1 active turn from that fixture; refreshed head 6c4d5c52d3d07b1b774165566f80504ee0983227 imported 2 turns, including the archived turn
  • current Hermes context-local profile override resolved through the plugin path helper in the same E2E
  • Windows %LOCALAPPDATA%\hermes fallback remains unit-covered; no live Windows host was used for this refresh

Closes #24

@pingchesu
pingchesu merged commit 45328db into main Aug 31, 2026
2 checks passed
@pingchesu
pingchesu deleted the fix/modern-session-backfill-issue-24 branch August 31, 2026 05:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Plugin outdated or version mismatch?

1 participant