Skip to content

fix(hermes): make mnemosyne CLI bank-aware under profile_isolation (#362)#363

Open
doziedotdev wants to merge 2 commits into
AxDSan:mainfrom
doziedotdev:fix/issue-362-stats-profile-bank
Open

fix(hermes): make mnemosyne CLI bank-aware under profile_isolation (#362)#363
doziedotdev wants to merge 2 commits into
AxDSan:mainfrom
doziedotdev:fix/issue-362-stats-profile-bank

Conversation

@doziedotdev

Copy link
Copy Markdown

Summary

hermes mnemosyne <stats|inspect|sleep|export> built its beam with a bare BeamMemory(session_id="hermes_default"), which always binds to the default/legacy bank (<data_dir>/mnemosyne.db). Under profile_isolation the provider writes to a per-profile bank (<data_dir>/banks/<profile>/mnemosyne.db), so these commands reported empty results even when the profile bank held data.

This makes the CLI resolve the active bank the same way the provider does:

  • New --bank flag on stats, sleep, inspect, export for explicit targeting.
  • When no --bank is given and profile_isolation is enabled, auto-resolve the profile bank from HERMES_HOME (mirroring the provider's _resolve_profile_bank fallback), reusing MnemosyneMemoryProvider._sanitize_bank_name.
  • The beam is then built via Mnemosyne(session_id="hermes_default", bank=...).beam, matching how the provider builds its own beam.

import --bank is left untouched — it names the source provider bank (e.g. Hindsight), not the Mnemosyne target, so it is explicitly excluded from target resolution.

Backward-compatible: with isolation off, no --bank, or an unresolvable bank, the CLI uses the default bank exactly as before. Resolution never raises — any failure falls back to the default bank.

Fixes #362.

Test plan

  • New integrations/hermes/tests/test_cli_bank.py covers: explicit --bank (sanitized), profile bank resolved when isolation is on, default bank when isolation is off / no config / root .hermes home, and import --bank not redirecting the target.
  • pytest integrations/hermes/tests/16 passed (6 new), no regressions.
    • Note: test_install_status.py currently fails to collect on main due to a pre-existing missing from enum import Enum in install.py (class PluginState(Enum) at install.py:16) — unrelated to this change; excluded from the run.

The `hermes mnemosyne` CLI built its beam with a bare
`BeamMemory(session_id="hermes_default")`, always binding to the default/
legacy bank. Under `profile_isolation` the provider writes to a per-profile
bank (`banks/<profile>/mnemosyne.db`), so `stats`/`inspect`/`sleep`/`export`
reported empty state while the real data lived in the profile bank.

Resolve the active bank the same way the provider does — explicit `--bank`,
else the profile bank derived from HERMES_HOME when `profile_isolation` is
enabled — and build a bank-aware beam via `Mnemosyne(bank=...).beam`.
Behavior is unchanged when isolation is off or no bank resolves.

Fixes AxDSan#362.

@AxDSan AxDSan left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay, was IRL busy the last few days. Catching up on the board now.

LGTM, this is a clean targeted fix for issue 362.

What I verified:

  • _resolve_cli_bank correctly mirrors the provider's _resolve_profile_bank fallback: HERMES_HOME basename, isolation guard, default-bank treatment of .hermes, hermes, and default. Diff is small and surgical.
  • Explicit bank flag precedence over profile resolution is right. The import bank argument is correctly excluded since it names the source provider, not the target. Good catch calling that out.
  • Backward compatible. With isolation off, no bank flag, or any resolution failure, the CLI falls through to the bare BeamMemory(session_id="hermes_default") path. No exceptions leak.
  • The bank-aware path uses Mnemosyne(session_id="hermes_default", bank=bank).beam, matching how the provider itself constructs the beam under profile_isolation. Consistent surface.
  • Local run: pytest integrations/hermes/tests/ → 16 passed (including the 6 new in test_cli_bank.py). The test_install_status.py collection failure is pre-existing on main (missing from enum import Enum in install.py:16), confirmed unrelated to this PR.
  • CI: all 6 checks green on the latest run.

Minor asks before merge:

  • Please add a one-line entry under [Unreleased] in CHANGELOG.md noting the CLI bank awareness under profile_isolation. A 3.10.2 PATCH bump in mnemosyne/__init__.py would be appropriate when this lands, since this is a user-facing behavior fix in the integration layer.
  • The _profile_isolation_enabled helper re-parses config.yaml here while the provider caches its parsed config. Not blocking, but worth a follow-up to share the parser if more CLI commands grow profile awareness.

Approve. Solid fix, well-scoped test coverage. Thanks for the clear writeup.

Addresses maintainer review on AxDSan#363:
- bump mnemosyne.__version__ to 3.10.2 (PATCH; user-facing fix in the
  hermes integration layer) and drop a stray duplicate __version__ line
- add an [Unreleased] CHANGELOG entry noting hermes mnemosyne CLI bank
  awareness under profile_isolation (AxDSan#362, AxDSan#363)
@doziedotdev

Copy link
Copy Markdown
Author

Thanks for the feedback @AxDSan

I made the changes to both the CHANGELOG.md and the init.py files.

The PR should be good to merge once you eyeball it.

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.

mnemosyne stats ignores profile_isolation banks — always reads the default bank, reports 0 while data lives in banks/<profile>/

2 participants