Skip to content

fix(hooks): show a file's memories before an edit in every session - #549

Open
kevintseng wants to merge 4 commits into
mainfrom
fix/recall-throttle-per-session
Open

kevintseng wants to merge 4 commits into
mainfrom
fix/recall-throttle-per-session

Conversation

@kevintseng

@kevintseng kevintseng commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Refs #521.

What was wrong

Before an edit, MeMesh shows the memories it has about the file being edited. It shows them only once per file per session. The list of "already shown" files was shared by every session on the machine, though. So once any session, or another agent, had been shown the memories for a file, every other session editing that file got nothing. The hook record then said "nothing to recall", which was not true.

What changed

  • Each session keeps its own list in ~/.memesh/pre-edit-recall/<session id>.json.
  • A repeat edit within one session is recorded as "already shown", not "nothing to recall".
  • Starting a session again (new start, /clear, resume, compact) clears only that session's list. A subagent's start leaves it alone.
  • A session id that is not safe as a file name is never used for a file, and that session is not throttled.
  • Lists not touched for 30 days are removed. A failed removal is reported on stderr. The old shared file is deleted.

Tests

  • New tests in tests/hooks/pre-edit-recall.test.ts and tests/hooks/session-start.test.ts fail without the fix and pass with it.
  • npm run verify is green.

Once any session on the machine had been shown the memories about a file, every
other session editing that file got nothing, and the hook record said "nothing
to recall". Each session now keeps its own list of files already shown, a
repeat within one session is recorded as already shown, and a new start of a
session clears only its own list. Lists idle for 30 days are removed.

Fixes #521
Comment thread tests/hooks/session-start.test.ts Fixed
The same-file check-then-write in one scenario was flagged by code scanning.
Two failures of the per-session pre-edit recall lists were silent:

- when the list directory itself could not be read, nothing was pruned and
  nothing was said; it now prints the same stderr line a failed per-file
  removal already prints;
- when SessionStart could not remove this session's list, the session kept
  its old list, so pre-edit recall stayed suppressed, while the start looked
  clean; it now prints the reason and records an error outcome.

Refs #521
The two #521 failure tests passed their preload to `--import` as a plain
absolute path. Node on Windows rejects that form
(ERR_UNSUPPORTED_ESM_URL_SCHEME) before the injected fault is reached; a
file URL is accepted on every platform.

Refs #521

[Verified-By: node scripts/run-tests-isolated.mjs tests/hooks/pre-edit-recall.test.ts tests/hooks/session-start.test.ts --maxWorkers=1 → exit 0, Test Files 2 passed, Tests 220 passed (macOS); Windows unverified until CI]

This branch has not been deployed

No deployments
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