Skip to content

fix(tools): make claude memory customId injective to stop silent file overwrites - #1586

Open
Sravanjangam wants to merge 1 commit into
supermemoryai:mainfrom
Sravanjangam:fix/claude-memory-customid-collision
Open

fix(tools): make claude memory customId injective to stop silent file overwrites#1586
Sravanjangam wants to merge 1 commit into
supermemoryai:mainfrom
Sravanjangam:fix/claude-memory-customid-collision

Conversation

@Sravanjangam

@Sravanjangam Sravanjangam commented Aug 22, 2026

Copy link
Copy Markdown

Fixes #1547.

Hi supermemory team 👋 Thanks for building such a great product! While running a security & quality audit of the repo we hit this issue and put together a small, tested fix — details below.

Problem

ClaudeMemoryTool.normalizePathToCustomId flattened / and . to _ non-injectively: /memories/notes.txt, /memories/notes_txt, and /memories/notes/txt all mapped to memories_notes_txt. Creating, viewing, or deleting one path therefore silently operated on a different file's document — silent data loss with no error surfaced.

Solution

Exported pure pathToCustomId() keeps the exact legacy id for the canonical single-segment shape (no underscore, exactly one dot, exactly one slash — e.g. /dir/file.ext) so already-stored documents keep resolving with zero migration, and appends an 8-hex sha256 digest of the original path for every other shape, making distinct paths map to distinct IDs again.

Changes

  • packages/tools/src/claude-memory.ts → private method now delegates to the new exported pathToCustomId() (all six call sites covered)
  • packages/tools/src/claude-memory.test.ts → +4 tests: three-way collision from the issue, legacy-id stability, determinism, distinct digests for distinct underscore paths

Verification

Fresh from the committed branch: bunx vitest run src/claude-memory.test.ts14/14 pass. packages/tools/test/** carries pre-existing type errors unrelated to this change (tracked in #1545) — this diff adds none.


Happy to iterate on any of this — feedback and reworks very welcome! 🙏

Environment

  • macOS 26.1 (arm64) · bun 1.4.0 · node v26.7.0
  • vitest 3.2.4 (workspace-pinned) · Biome lint clean
  • Branch fix/claude-memory-customid-collision — all gates re-run fresh at commit 049a50ee0ac6

…writes

normalizePathToCustomId flattened / and . to _ non-injectively, so
/memories/notes.txt, /memories/notes_txt and /memories/notes/txt all
mapped to memories_notes_txt — create/delete/view on one path silently
hit another file's document (supermemoryai#1547).

pathToCustomId now keeps the exact legacy id only for the canonical
/dir/file.ext shape (no underscore, one dot, one slash) so existing
documents keep resolving, and appends an 8-hex sha256 digest of the
original path for every other shape, making distinct paths map to
distinct ids. Round-trip collision tests included.
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.

Claude memory tool: path → customId normalization collides, silently overwriting unrelated memory files

1 participant