Repository navigation
perf(read-cache): cache every note resolve answer - #2076
Merged
Merged
Conversation
A client that reads the same note by the same identifier again and again reached the database on every read: note resolve stored only answers whose identifier equalled the stored title, permalink or file path character for character, so a path without .md or a slug under its folder was labelled a search and left uncached, and real fuzzy matches were never stored. - LinkResolver.match_entity reports whether the match was exact or chosen by fuzzy search; resolve_entity keeps its signature. - Note resolve caches every answer. Entries retire when the project's names change (a note created, renamed, moved or deleted). A fuzzy guess could also shift when a note's body changes; serving the earlier guess until the next name change is accepted. - The route's span records resolve.match (exact or fuzzy). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016N9c6ouiT4Wid3arGR41Dv Signed-off-by: phernandez <paul@basicmachines.co>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Note resolve now calls LinkResolver.match_entity. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016N9c6ouiT4Wid3arGR41Dv Signed-off-by: phernandez <paul@basicmachines.co>
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.
Why
A client that reads the same note by the same identifier repeatedly should be served from the read cache. Note resolve stored only answers whose identifier equalled the note's stored title, permalink or file path character for character. Exact matches spelled differently (a path without
.md, a slug under its folder, a permalink without the project prefix) were labelledsearchand left uncached, and real fuzzy matches were never stored. In Basic Memory Cloud this kept a polling client's database awake around the clock even though every other step of its reads was cached.What
LinkResolver.match_entityreturns the entity and whether an exact lookup found it (exactis False only when fuzzy search chose it, after every exact reading missed).resolve_entitykeeps its signature and delegates.QUERY /v2/projects/{id}/knowledge/resolvecaches every answer. Entries keep the project-group invalidation: they retire when a note is created, renamed, moved or deleted. A fuzzy guess could also shift when a note's body changes; serving the earlier guess until the next name change is accepted (a create that matches the identifier exactly retires it).resolve.match(exactorfuzzy) so we can see how often fuzzy resolution happens.resolution_methodin the response is unchanged.Testing
test-int/read_cache/test_cache_rules.py:test_an_exact_match_is_cached_whatever_spelling_found_it: a path without.mdand a slug under its folder are HITs on the second resolve. Both cases fail on main.test_a_fuzzy_resolution_is_cached_until_names_change(replaces the never-cached rule): a fuzzy match is a HIT on repeat; creating an exactly matching note retires it and the next resolve returns the new note.just fast-checkpasses.🤖 Generated with Claude Code
https://claude.ai/code/session_016N9c6ouiT4Wid3arGR41Dv