fix: support 8-char short ID prefix matching for memory tools (v0.2.2)#14
Merged
fix: support 8-char short ID prefix matching for memory tools (v0.2.2)#14
Conversation
memory_scope_promote, memory_delete, memory_feedback_wrong, memory_feedback_useful all failed with 'not found' when given an 8-character short ID (first 8 chars of a UUID), even though memory_search could find the same memory by text/vector. Root cause: hasMemory(), deleteById(), updateMemoryScope(), and updateMemoryUsage() all used strict === comparison against the full 36-char UUID stored in LanceDB. Fix: - Add matchesId(candidateId, query) private helper on MemoryStore: - query >= 36 chars → exact === match (unchanged behavior) - query < 36 chars → startsWith prefix match - Apply matchesId to all four methods - Change id schema validation from min(6) to min(8) on all memory tools to align with the short-ID convention - Fix latent data-loss bug: DELETE in updateMemoryScope and updateMemoryUsage now uses match.id (resolved full UUID) instead of the id argument, which could be a prefix Bump version to 0.2.2.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
memory_scope_promote,memory_delete,memory_feedback_wrong, andmemory_feedback_usefulall return "Memory X not found in current scope" when given an 8-character short ID, even thoughmemory_searchfinds the exact same memory.Root Cause
memory_searchoutputs the full UUID in its result ([0f229546-c7af-4183-8558-2c12209b9314]). When an AI or user copies only the first 8 characters (0f229546) as a short-hand reference, all the ID-based tools fail silently because they use strict===matching against the full 36-char stored UUID.Every affected method (
hasMemory,deleteById,updateMemoryScope,updateMemoryUsage) didrows.find(row => row.id === id)— an exact match that never fires on a prefix.Fix
private matchesId(candidateId, query)onMemoryStore: exact match for 36-char queries,startsWithprefix for shorter onesidschemamin(6)→min(8)on all memory toolsupdateMemoryScopeandupdateMemoryUsagenow usesmatch.id(the resolved full UUID), not theidparameterVerification
npm run verify— foundation 11/11, regression 18/18, retrieval 2/2, all 0 failures.