Skip to content

memory: file-path tests write the real default graph files and fail intermittently #4922

Closed

Description

@cliffhall

Found while building the pre-push gate (#4871, PR #4920). Not caused by that PR, which changes no server code.

Problem

src/memory/__tests__/file-path.test.ts failed once inside an npm run local:gate run and then passed seven consecutive re-runs of npm test -w src/memory with no change in between:

FAIL  __tests__/file-path.test.ts > ensureMemoryFilePath > without MEMORY_FILE_PATH environment variable > should use new file when both old and new files exist
AssertionError: expected false to be true
 ❯ __tests__/file-path.test.ts:158:29
    157|       expect(newFileExists).toBe(true);
    158|       expect(oldFileExists).toBe(true);

So src/memory/memory.json was gone by the time the test checked for it, although the test had just written it.

What is known, and what is not

  • The tests in this file do not use a temporary directory. They write, migrate and delete the real default paths beside the source, src/memory/memory.json and src/memory/memory.jsonl, the same paths the server itself uses when MEMORY_FILE_PATH is unset.
  • Anything else that calls ensureMemoryFilePath() with no MEMORY_FILE_PATH while this test runs will migrate memory.json away (rename to memory.jsonl) between the test's write and its assertion. Candidates: another test file in the same Vitest run (files run in parallel), or a memory server started from this checkout at that moment.
  • The actual second writer was not identified. It reproduced once in roughly ten runs on macOS, Node 26.

Expected

The suite gives the same result every run. The file-path tests should not share state with anything else: point them at a per-test temporary directory (which needs ensureMemoryFilePath to take its base directory as a parameter, or an equivalent seam) instead of the package directory. Writing into the package directory also means a failed run can leave a memory.json or memory.jsonl behind in the working tree.

Notes

Activity

  1. added this to the v2.0.0 milestone on Oct 1, 2026
  2. added
    bug
    server-memory
    on Oct 1, 2026
  3. cliffhall commented on Oct 1, 2026

    @cliffhall
    MemberAuthor

    Another occurrence, 2026-10-01, inside npm run local:gate on the #4928 branch (v2/feat/4873-milestone-release-flow): the same test, the same assertion at file-path.test.ts:158, oldFileExists false. The change under test touched only .github/workflows/release.yml, RELEASING.md and scripts/pack-and-verify.mjs; no memory source. It was the only failure in the run (86 of 87 passed in that workspace), and the gate is being re-run unchanged.

  4. self-assigned this
    on Oct 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugserver-memoryv2

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions