Repository navigation
Conversation
Problem: unicode61's remove_diacritics option folds ordinary combining-mark diacritics (o-acute, z-dot, a-ogonek, ...) symmetrically for indexed and MATCH query text, but Unicode assigns l/L-stroke no canonical decomposition, so neither NFD normalization nor remove_diacritics can fold it. A plain-ASCII query like "latwo" never found seeded "latwo-with-stroke" content, and remove_diacritics wasn't even enabled. Verified empirically with a live sqlite3 fts5vocab probe before implementing (unicode61 remove_diacritics 2 folds z-dot/o-acute correctly on its own; only the stroke letter needs an explicit fold). What changed: - polylogue/storage/fts/pl_fold.py: one canonical PL_FOLD_TABLE (l/L-stroke only) expressed three ways -- pl_fold() (Python, query-side), the registered SQL scalar function (ad-hoc/diagnostics), and pl_fold_sql_expr() (an inline REPLACE-chain embedded directly in trigger/insert DDL text so write-side folding does not depend on every connection that fires a blocks/threads/session_work_events trigger having registered a custom function first). - All three unicode61 contentless FTS surfaces (messages_fts, threads_fts, session_work_events_fts) move to tokenize='unicode61 remove_diacritics 2' and fold search_text through pl_fold_sql_expr before insertion, in both canonical DDL sites (archive_tiers/index.py, fts/fts_lifecycle.py, fts/sql.py bulk-insert helpers). - escape_fts5_query -- the single chokepoint every production MATCH builder routes through (8+ call sites) -- applies the identical Python pl_fold to query text before quoting, so write/query folding cannot drift apart. - register_pl_fold wired into both sync (storage/sqlite/connection.py) and async (storage/sqlite/async_sqlite.py) read/write connection setup. - INDEX_SCHEMA_VERSION 34 -> 35 (derived-tier rebuild: polylogue ops reset --index && polylogued run). docs/internals.md + docs/search.md updated. Explicitly out of scope (per the bead's own AC): a trigram fallback lane stays off pending a measured size/precision report -- tracked as polylogue-xul7, not built here. Verification: devtools test tests/unit/storage/test_pl_fold.py (12 passed, covers idempotency, Python/SQL/REPLACE-chain agreement, the DDL-site drift-lock, and end-to-end recall against the real trigger-backed schema) plus the surrounding FTS suite (211 passed) and schema-version-sensitive tests (test_archive_tiers_assertions.py, test_schema_policy_contracts.py, test_status_diagnostics.py, test_tutorial.py, 2 targeted daemon_cli tests -- all passed except one pre-existing unrelated failure filed as polylogue-gxly). mypy --strict clean on touched files. devtools render all --check clean. Ref polylogue-9jsi Co-Authored-By: Claude <[email protected]>
|
Warning Review limit reached
Next review available in: 13 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (14)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8200633d7e
ℹ️ 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".
|
Superseded by merged PR #2754. The replacement includes the original Polish fold plus the audited ArchiveStore rebuild and dangling-repair coverage. |
|
Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.
Only the rows listed above are dispositioned. Held findings remain open. |
Summary
Closes the specific Polish-search recall hole named in polylogue-9jsi:
unicode61FTS5 tokenization alone cannot foldł/Ł(Latin L with stroke) because Unicode assigns it no canonical decomposition, so a plain-ASCII query likelatwonever found seededłatwocontent. This PR adds a narrow, deterministicpl_foldlayer around FTS5, expressed once and used identically on the write and query sides, plus enablesunicode61 remove_diacritics 2(which handles the other Polish diacritics —ó,ż,ą, ... — on its own).Problem
Verified empirically before implementing (see
tests/unit/storage/test_pl_fold.pyand the PR discussion below): withtokenize='unicode61 remove_diacritics 2', indexingróżowyand queryingrozowyalready matches — the tokenizer folds ordinary combining-mark diacritics correctly and symmetrically on both sides. Butżółtytokenizes tozołty(ż and ó folded, ł left untouched), becauseł/Łhas no NFD/NFKD decomposition forremove_diacriticsor Unicode normalization to reach. So even with the tokenizer bump alone,latwowould still missłatwo, andremove_diacriticswas not even enabled to begin with — both problems compound.Solution
polylogue/storage/fts/pl_fold.py: a singlePL_FOLD_TABLE(ł→l,Ł→L) expressed three ways so write-side and query-side folding cannot drift apart:pl_fold()— Python implementation, used for query-side normalization.pl_fold_sql_expr()— an inline SQLREPLACE-chain, embedded directly into trigger/insert DDL text. This is deliberately not a call to a registered custom function, because SQLite trigger bodies execute on whatever connection performs the write — including raw test/tooling connections that reuse the shared trigger DDL (fts_lifecycle.py's_BLOCKS_FTS_TRIGGER_DDLetc.) without ever registering a UDF. An inlineREPLACEchain has no such dependency.register_pl_fold()— registers the identical transform as a SQL scalar functionpl_fold(x), wired into both sync (storage/sqlite/connection.py) and async (storage/sqlite/async_sqlite.py) read/write connection setup, for ad-hoc queries, diagnostics, and the Python/SQL agreement test.unicode61contentless FTS surfaces —messages_fts,threads_fts,session_work_events_fts— move totokenize='unicode61 remove_diacritics 2'and foldsearch_textthroughpl_fold_sql_exprbefore insertion, at every DDL/trigger/bulk-insert site (archive_tiers/index.py,fts/fts_lifecycle.py,fts/sql.py).threads_fts/session_work_events_ftswere included alongsidemessages_fts(beyond the bead's literal example) because query-side folding viaescape_fts5_queryis already global across all FTS surfaces — leaving those two write-side unfolded would have reintroduced exactly the "silent recall loss" drift the bead calls out as the top risk.escape_fts5_query— the single chokepoint every productionMATCHbuilder in the archive routes through (8+ call sites acrossarchive_tiers/archive.py,search/query_builders.py,search_providers/fts5.py,sqlite/queries/session_insight_*_queries.py,insights/resume.py) — applies the identical Pythonpl_foldto query text before quoting.INDEX_SCHEMA_VERSION34 → 35 (derived-tier, no migration chain — existing archives rebuild viapolylogue ops reset --index && polylogued run).docs/internals.mdanddocs/search.mdupdated.Deliberately out of scope (per the bead's own AC, which requires trigram to stay off "until benchmarked with size+precision report" and never silently default): no trigram fallback lane is added here. Tracked as follow-up polylogue-xul7.
Also discovered, filed, left unfixed (confirmed pre-existing and unrelated via
git log):tests/unit/storage/test_archive_tiers_assertions.py::test_fresh_user_tier_has_no_legacy_overlay_tablesfails on any fresh checkout since #2703 addedcontext_deliveriestouser.dbwithout updating this assertion. Filed as polylogue-gxly.Verification
devtools test tests/unit/storage/test_pl_fold.py— 12 passed. Covers:ł/Ł-only folding, idempotency, Python/registered-UDF/inline-REPLACE-chain 3-way agreement, the two-canonical-DDL-site tokenizer drift lock, and end-to-end recall (latwo/zrobilemfinding seededłatwo/zrobiłem, plus a literalłquery, plusremove_diacriticsalone findingróżowy/zrobię) against the real trigger-backed schema via thetest_connfixture.devtools test tests/unit/storage/test_fts5.py tests/unit/storage/test_fts_repair_sql.py tests/unit/storage/test_fts_bloat_invariants.py tests/unit/storage/test_dangling_fts_derived_surfaces.py tests/unit/storage/test_index.py tests/unit/storage/test_fts5_query_correctness.py tests/unit/storage/test_fts_escape_in_insights.py tests/unit/storage/test_blocks_command_trigram.py— 211 passed.devtools test tests/unit/storage/test_archive_tiers_assertions.py tests/unit/storage/test_schema_policy_contracts.py tests/unit/cli/test_status_diagnostics.py tests/unit/cli/test_tutorial.py— 63/64 passed (1 pre-existing unrelated failure, polylogue-gxly).devtools test -k "test_polylogued_status_json_reports_schema_mismatch_not_ready or test_polylogued_status_plain_reports_schema_mismatch" tests/unit/daemon/test_daemon_cli.py— 2 passed (the schema-version-sensitive daemon status tests; the fulltest_daemon_cli.pyfile was not run in full, it contains an unrelated slow periodic-loop test).mypy --stricton every touched file — clean.devtools render all --check— clean (topology projection regenerated for the new module).devtools verify --quick(format + lint + mypy + render-all-check) — passed.Ref polylogue-9jsi