Skip to content

Memory: synthetic state-change regression test #312

Closed

Description

@currentbits

From the memory-systems research: every public benchmark number in this space is vendor-run and judge-noisy (Mem0's own scorer has a refusal-matcher bug; rankings flip with memory tenure). The recommended alternative is a cheap synthetic test immune to judge variance.

For memory-server: inject a state change ('project X migrated from Postgres to MySQL on date D' as a supersede), then later query current state and assert the new fact wins and the old one is only reachable as history. Extend to: near-dup rejection, invalidation tombstoning, scope isolation (#179 regression), and bootstrap budget behavior. Runs in CI against a scratch DB.

Activity

  1. added
    enhancement
    plan:todo
    plan:doing
    and removed
    plan:todo
    on Aug 17, 2026
  2. currentbits commented on Aug 18, 2026

    @currentbits
    OwnerAuthor

    Scoping note before implementation.

    Four of the five listed scenarios already have tests in memory-server/test/:

    • near-dup rejection → dedup.test.js (block at ≥0.7, force bypass, warn band, semantic near-dup)
    • invalidation tombstoning → resolve.test.js ("tombstones the older loser and hides it from search/recent/bootstrap")
    • scope isolation (Memory project keys collide for same-named repos; conventions leak across projects #179) → project-key.test.js, describe memory is project-scoped (no global leakage)
    • bootstrap budget → memory.test.js ("bootstrap budgets drop whole entries from the end")

    The genuinely uncovered part is the one the issue leads with: the end-to-end state change itself. memory.test.js only asserts supersede marks old and returns new id — nothing covers a multi-step supersede chain, or that the predecessor is excluded from every read surface while staying reachable as history via the superseded_by pointer.

    So: one new test/state-change.test.js for the supersede scenario, plus an audit of the other four for real holes (particularly whether liveSql()/projectScopeSql() are applied on graphSearch and vectorSearch, not just search/recent/bootstrap). No CI change needed — npm test already globs memory-server/test/*.test.js.

  3. currentbits commented on Aug 18, 2026

    @currentbits
    OwnerAuthor

    Done on coder/memory-synthetic-state-change-regression-a73cec (2 commits, local — not pushed yet).

    New: memory-server/test/state-change.test.js (3 tests) — the synthetic state change the issue asks for. Store "Project X uses Postgres", supersede with "migrated from Postgres to MySQL on 2026-03-04", then assert:

    • successor is a live hit on search, recent, bootstrap and graphSearch; predecessor appears on none of them, and the old claim text never surfaces in a live excerpt
    • get(oldId) returns only {superseded_by, hint} — title/body are undefined, so the predecessor is reachable only as a history pointer
    • a three-step chain A→B→C: only C is live, and walking A's pointers reaches C
    • supersede on an already-superseded id throws

    The other four scenarios were already covered, so rather than duplicate them the second worker audited them and found one real hole, now pinned in project-key.test.js:

    search() fuses graph + vector + FTS candidates and re-scores them at src/memory.js:913 with liveSql('e') only — no projectScopeSql. Project isolation on those two paths rests entirely on the filters inside graphSearch (:645) and vectorSearch (:701). The existing #179 tests never seed entities, so nothing exercised the graph path at all: dropping the filter at :645 would have leaked a sibling project's entries through fusion with every existing test still green.

    No bug today — both filters are present and correct. The new test seeds a shared entity across two projects and asserts graphSearch('…', 'coder') returns only the coder row. Mutation-checked: removing the :645 filter fails it with graphSearch leaked out of project: ["Other hidden graph target","Coder hidden graph target"].

    Full suite: 164 pass, 0 fail (cd memory-server && node --test test/*.test.js). No CI change needed — the root npm test already globs memory-server/test/*.test.js.

  4. currentbits commented on Aug 18, 2026

    @currentbits
    OwnerAuthor

    PR: #429

  5. added
    plan:done
    and removed
    plan:doing
    on Sep 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementplan:done

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions