Skip to content

fix: two bugs in PR #106's identity-memory test fixture blocking CI#108

Merged
AxDSan merged 1 commit into
AxDSan:mainfrom
kohai-ut:fix/beam-init-string-db-path-coercion
May 13, 2026
Merged

fix: two bugs in PR #106's identity-memory test fixture blocking CI#108
AxDSan merged 1 commit into
AxDSan:mainfrom
kohai-ut:fix/beam-init-string-db-path-coercion

Conversation

@kohai-ut
Copy link
Copy Markdown
Contributor

Summary

PR #106 added tests/test_identity_memory.py whose fixture errors on every PR's CI matrix with two separate setup failures, currently blocking all five of my open PRs (#98, #101, #102, #105, #107). Same fixture errors would block every future PR until fixed.

The fixture is correct in intent — the test BODIES exercise real behavior. Only the setup has two bugs that combined to make the suite show 5 errors and mark the CI run failed.

Two bugs in the same fixture

Bug 1: BeamMemory(db_path=<str>) crashes at first connection

beam = BeamMemory(db_path=db_path)  # db_path is a tempfile string

BeamMemory.__init__ stored the string as-is, then _get_connection at beam.py:326 did path.parent.mkdir(parents=True, exist_ok=True)AttributeError: 'str' object has no attribute 'parent'.

Fix: BeamMemory.__init__ now coerces any non-Path db_path via Path(db_path) before storage. Backward-compatible — real Path inputs stay Path, strings get coerced, None still falls back to _default_db_path(). The implicit Path-only contract is now explicit and tolerant.

Bug 2: beam.initialize() is not a thing

beam = BeamMemory(db_path=db_path)
beam.initialize()  # <-- AttributeError

BeamMemory has no initialize() method. MnemosyneMemoryProvider does, and the test author may have left this over from a refactor. BeamMemory.__init__ already opens the connection and runs init_beam() for schema setup.

Fix: drop the spurious beam.initialize() call from the fixture.

Test plan

  • New tests/test_beam_db_path_string_coercion.py: 4 regression tests pinning the db_path acceptance contract across str / Path / None inputs, plus an end-to-end smoke that exercises the .parent.mkdir(parents=True) path that the original AttributeError hit.
  • PR feat: identity memory source type — auto-capture when users express identity-significant feelings #106's 5 identity tests now pass (verified locally with the fix).
  • 143/143 in the broader slice across hermes_memory_provider, hermes_plugin_session, plugins, integration, data_dir_scripts.
  • CI matrix will confirm.

Why this PR exists

This fix could/should land on main directly without going through a PR, but since the CI bug is blocking five separate open PRs that I've been shipping, this is the fastest path to unblock all of them at once. Maintainer can land this first, then rebase the other five PRs onto the cleaned main.

If you'd prefer to fold these two changes into a different PR, happy to close this one — just say the word.

🤖 Generated with Claude Code

…g CI

PR AxDSan#106 added tests/test_identity_memory.py whose fixture errors on
every PR's CI matrix with two separate setup failures, blocking all
five currently-open PRs (AxDSan#98, AxDSan#101, AxDSan#102, AxDSan#105, AxDSan#107):

  1. AttributeError: 'str' object has no attribute 'parent'
     The fixture does `BeamMemory(db_path=db_path)` where db_path is
     a string from tempfile. BeamMemory.__init__ stored it as-is, then
     _get_connection at beam.py:326 did `path.parent.mkdir(...)` --
     strings don't have .parent.

  2. AttributeError: 'BeamMemory' object has no attribute 'initialize'
     The fixture then calls `beam.initialize()`. BeamMemory has no
     such method; __init__ already opens the connection and runs
     init_beam() (schema setup, sleep_log, etc.). The .initialize()
     call must have been left over from a refactor where the test
     was rewritten to use BeamMemory directly instead of
     MnemosyneMemoryProvider (which DOES have an initialize()).

Both bugs caused 5 ERROR records in CI, marking the run failed even
though the actual test bodies are correct.

Fixes:

  - mnemosyne/core/beam.py BeamMemory.__init__: coerce non-Path
    db_path via Path(db_path) before storage. Backward-compatible --
    real Path inputs stay Path, strings get coerced, None still falls
    back to _default_db_path(). The implicit Path-only contract is
    now explicit and tolerant.

  - tests/test_identity_memory.py fixture: drop the spurious
    beam.initialize() call. __init__ already does the setup work.

Regression test: tests/test_beam_db_path_string_coercion.py pins the
db_path acceptance contract across str / Path / None inputs, plus an
end-to-end smoke that exercises the .parent.mkdir(parents=True) path
that the original AttributeError hit.

Empirics:
  - 9/9 in the targeted slice (4 new coercion tests + 5 PR AxDSan#106
    identity tests now pass)
  - 143/143 in the broader slice across
    hermes_memory_provider/plugin_session/plugins/integration/
    data_dir_scripts.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@kohai-ut
Copy link
Copy Markdown
Contributor Author

FYI, this PR will fix the failing CI on the other waiting PRs I did.

ether-btc pushed a commit to ether-btc/mnemosyne that referenced this pull request May 13, 2026
Fixes the upstream beam.py:326 AttributeError where BeamMemory(db_path=str)
crashes because _get_connection calls path.parent.mkdir() on a string.

Also drops spurious beam.initialize() call from test_identity_memory.py
fixture — BeamMemory has no initialize() method; __init__ does all setup.

Ported from upstream PR AxDSan#108 (kohai-ut) which passes CI on all Python
versions. Includes regression test file test_beam_db_path_string_coercion.py
with 4 coverage cases.

All 9 tests pass locally:
  - 4 new db_path coercion tests
  - 5 test_identity_memory.py identity signal tests
ether-btc pushed a commit to ether-btc/mnemosyne that referenced this pull request May 13, 2026
@AxDSan AxDSan merged commit a35ca9b into AxDSan:main May 13, 2026
5 checks passed
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.

2 participants