Skip to content

perf(read-cache): cache every note resolve answer - #2076

Merged
phernandez merged 2 commits into
mainfrom
read-cache-resolve-matches
Nov 7, 2026
Merged

phernandez merged 2 commits into
mainfrom
read-cache-resolve-matches

Conversation

@phernandez

Copy link
Copy Markdown
Member

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 labelled search and 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_entity returns the entity and whether an exact lookup found it (exact is False only when fuzzy search chose it, after every exact reading missed). resolve_entity keeps its signature and delegates.
  • QUERY /v2/projects/{id}/knowledge/resolve caches 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).
  • The route's span records resolve.match (exact or fuzzy) so we can see how often fuzzy resolution happens.
  • resolution_method in 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 .md and 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-check passes.

🤖 Generated with Claude Code

https://claude.ai/code/session_016N9c6ouiT4Wid3arGR41Dv

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>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-07T23:02:08.260848Z 923b1fd New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

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>
@phernandez
phernandez merged commit eddb4c0 into main Nov 7, 2026
41 of 42 checks passed
@phernandez
phernandez deleted the read-cache-resolve-matches branch November 7, 2026 23:12
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.

1 participant