Skip to content

fix(core): canonicalize note type filters - #1189

Merged
phernandez merged 3 commits into
mainfrom
codex/note-type-canonicalization
Aug 5, 2026
Merged

fix(core): canonicalize note type filters#1189
phernandez merged 3 commits into
mainfrom
codex/note-type-canonicalization

Conversation

@phernandez

@phernandez phernandez commented Aug 5, 2026

Copy link
Copy Markdown
Member

Why

write_note already treats note types as snake_case identities, but schema and search
selectors did not consistently use that same rule. This split one logical type across
spellings such as Task Item, TaskItem, task-item, and task_item, allowing
validation or search to look complete while omitting part of the population.

Fixes #1180.

What Changed

  • added one named normalize_note_type() function and made the NoteType boundary use it
  • canonicalized note-type filters at SearchQuery, MCP, and search-service boundaries
  • made schema validate, infer, and diff resolve canonical plus legacy stored spellings as one type
  • canonicalized note-type metadata whenever regular or accepted-note hot-search rows are written
  • added API, MCP, schema-model, service, accepted-write, SQLite, and Postgres regressions using
    multiword, camel-case, and punctuation variants

Implementation Details

Schema lookups first collect the exact note-type spellings present in the project, normalize
those values in Python with the shared write-side function, and then query the matching stored
values. This avoids backend-specific SQL normalization and lets SQLite and Postgres handle
camel-case legacy rows identically.

Search filters are canonicalized before repository access. Every search-row builder,
including the DB-first accepted-note hot path, now writes canonical note-type metadata.
Before search and count reach either backend, canonical filters are expanded with the exact
legacy entity spellings that normalize to the requested identity. Existing legacy search rows
therefore remain searchable without an eager reindex; bm reindex still repairs their stored
metadata deterministically. Schema validation uses the same compatibility principle.

Unrelated matching rules for titles, paths, tags, categories, and arbitrary metadata remain
unchanged.

Testing

Automated

  • original focused schema/search normalization suite: 34 passed
  • broader search and MCP suite: 151 passed
  • original targeted Postgres regressions: 2 passed
  • accepted-note hot-search review regression and related writer suites: 32 passed
  • widened note-type plus accepted-note suite after compatibility review: 67 passed
  • broader search service, MCP, and API suite: 151 passed
  • targeted Postgres hot-search and normalization suite: 6 passed
  • just fast-check: Ruff fix/check, formatting, and ty type checking passed
  • git diff --check: passed

Manual

  • No separate manual UI verification; this change is covered at the API and MCP boundaries.

Risks / Follow-ups

  • Note-type-filtered search performs one small distinct-type query so it can include exact legacy
    spellings without forcing a rebuild. The query is bounded by the project's number of note types.
  • The schema path performs one small distinct-type query before selecting matching entities. This
    keeps normalization portable and bounded by the project's number of note types rather than its
    number of notes.

Signed-off-by: phernandez <paul@basicmachines.co>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4b1d49ca79

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/basic_memory/services/search_service.py
Signed-off-by: phernandez <paul@basicmachines.co>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b9e27bf278

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/basic_memory/services/search_service.py
Signed-off-by: phernandez <paul@basicmachines.co>
@phernandez
phernandez merged commit 557c067 into main Aug 5, 2026
28 checks passed
@phernandez
phernandez deleted the codex/note-type-canonicalization branch August 5, 2026 02:58
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.

[BUG] write_note lowercases note_type while type matching stays case-sensitive, splitting one logical type into two populations

1 participant