fix(core): canonicalize note type filters - #1189
Conversation
Signed-off-by: phernandez <paul@basicmachines.co>
There was a problem hiding this comment.
💡 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".
Signed-off-by: phernandez <paul@basicmachines.co>
There was a problem hiding this comment.
💡 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".
Signed-off-by: phernandez <paul@basicmachines.co>
Why
write_notealready treats note types as snake_case identities, but schema and searchselectors did not consistently use that same rule. This split one logical type across
spellings such as
Task Item,TaskItem,task-item, andtask_item, allowingvalidation or search to look complete while omitting part of the population.
Fixes #1180.
What Changed
normalize_note_type()function and made theNoteTypeboundary use itmultiword, 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 reindexstill repairs their storedmetadata deterministically. Schema validation uses the same compatibility principle.
Unrelated matching rules for titles, paths, tags, categories, and arbitrary metadata remain
unchanged.
Testing
Automated
just fast-check: Ruff fix/check, formatting, and ty type checking passedgit diff --check: passedManual
Risks / Follow-ups
spellings without forcing a rebuild. The query is bounded by the project's number of note types.
keeps normalization portable and bounded by the project's number of note types rather than its
number of notes.