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]>
Resolve the replacement branch's JSONL conflict by bead identity and updated_at while retaining master-only and branch-only records. Preserve master's raw lines so the resolution does not reserialize unrelated beads. Ref polylogue-9jsi Co-Authored-By: Claude <[email protected]>
Problem: query normalization folded Polish l-stroke globally, but the public message-index rebuild and keyed dangling repairs still indexed raw search_text. Running those maintenance routes silently removed the recall guarantee until another full repair rewrote the rows. Apply the canonical inline fold to all three missed writers. Add real-route proofs through ArchiveStore.rebuild_index and dangling derived-surface repair; each assertion depends on its production fold call and checks both ASCII and literal Polish queries. Clarify the derived-tier rebuild contract and regenerate topology against current master. Ref polylogue-9jsi Co-Authored-By: Claude <[email protected]>
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ 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 |
…) (#2754) ## Summary Add deterministic Polish lexical folding across every FTS5 surface and every fresh-write, bulk-write, rebuild, and dangling-repair route. Plain-ASCII queries such as `latwo` and `zrobilem` now find `łatwo` and `zrobiłem` content. This fresh-master replacement preserves the logical work from PR #2753 without rewriting that branch and corrects the schema overview to index version 35. ## Problem SQLite FTS5 `unicode61 remove_diacritics 2` folds ordinary Polish diacritics but cannot fold `ł`/`Ł`, because those code points have no Unicode decomposition. Query-side folding without matching write-side coverage creates silent recall loss: the original implementation missed the public `ArchiveStore.rebuild_index()` writer and the keyed dangling-row repair writers for threads and session work events. The prior branch also conflicted with current master and left `docs/schema.md` reporting index version 34 after the canonical DDL moved to version 35. ## Solution - Derive Python, registered SQLite-function, and inline SQL-expression projections from one `PL_FOLD_TABLE` (`ł` → `l`, `Ł` → `L`). - Use `unicode61 remove_diacritics 2` for `messages_fts`, `threads_fts`, and `session_work_events_fts`. - Apply the inline fold at canonical triggers, bulk/missing-row writers, full rebuilds, `ArchiveStore.rebuild_index()`, and both keyed dangling-derived repair paths. - Fold production `MATCH` query text at the shared `escape_fts5_query` chokepoint. - Keep trigram fallback disabled pending the measured opt-in work in `polylogue-xul7`. - Bump the rebuildable derived index tier from 34 to 35 and document `polylogue ops reset --index && polylogued run`; no in-place migration helper is added. - Regenerate topology from current master and update `docs/schema.md` to the canonical version 35. - Preserve current-master Beads records semantically: the branch changes six issue records whose `updated_at` values are newer than master and adds ten related interaction records. ## Acceptance criteria | Criterion | Status | Evidence | | --- | --- | --- | | `latwo` / `zrobilem` find seeded `łatwo` / `zrobiłem` | Satisfied | Real trigger-backed tests in `tests/unit/storage/test_pl_fold.py` | | Fold is idempotent and Python/SQL projections agree | Satisfied | Python, registered-UDF, and inline-`REPLACE` agreement tests | | Canonical DDL tokenizer sites cannot drift | Satisfied | Tokenizer contract tests cover all three surfaces | | Production `MATCH` builders normalize query text | Satisfied | Shared `escape_fts5_query` / `normalize_fts5_query` routing plus static call-site audit | | Rebuild and repair writers preserve folding | Satisfied | Public `ArchiveStore.rebuild_index()` test and real dangling-repair test for both derived surfaces | | Trigram remains off until measured | Satisfied | No fallback added; `polylogue-xul7` has the size/precision acceptance criteria | | Derived schema change has an explicit rebuild plan | Satisfied | Index version 35 and documented reset/reingest command; `docs/schema.md` agrees | Anti-vacuity was checked independently before publishing the replacement: removing the public-rebuild fold failed `test_pl_fold.py` at the ASCII recall assertion; removing the work-event and thread repair folds independently failed the derived-surface test at their respective assertions. The tests seed canonical source rows before repair and exercise production entrypoints. ## Verification - `devtools test tests/unit/storage/test_pl_fold.py tests/unit/storage/test_fts_repair_sql.py tests/unit/storage/test_dangling_fts_derived_surfaces.py tests/unit/storage/test_schema_policy_contracts.py` — **46 passed in 33.01s**. - `devtools test -k schema_mismatch tests/unit/daemon/test_daemon_cli.py` — **2 passed, 73 deselected in 12.09s**. - `devtools render all --check` — **exit 0**; all generated surfaces and site links are in sync. - `devtools verify --quick` — **exit 0**, run `20260712T090941Z-quick-1151050-a475c192`; ruff format/check, mypy, render, topology, layering, schema roundtrip, manifests, workflow, docs, and test-infrastructure gates all passed. - `.agent/scripts/bd-graph-lint` — no cycles, duplicate labels, or inversions; it reports the two inherited master missing-AC records `polylogue-2ilz` and `polylogue-nu2h`, neither modified by this branch. - `jq -e -c . .beads/issues.jsonl` and `.beads/interactions.jsonl` — exit 0. - `git diff --check origin/master...HEAD` — exit 0. ## CI and review note At publication time, GitHub Actions jobs on the superseded PR were zero-step failures with the annotation that the account was locked due to a billing issue. Those failures did not execute repository code and are not represented as green evidence here. This ready-for-review replacement intentionally triggers whatever automated review/check capacity is available; any repeated billing-locked jobs remain an external red publish gate until they can actually run. Ref polylogue-9jsi --------- Co-authored-by: Claude <[email protected]>
|
Superseded by merged PR #2754, rebuilt from current master with the schema-version documentation fix and equivalent focused verification. |
Summary
Add deterministic Polish lexical folding for every FTS5 surface and every write, rebuild, and repair route. Plain-ASCII queries such as
latwoandzrobilemnow findłatwoandzrobiłemcontent without introducing an unmeasured trigram fallback. This replacement is based on currentmasterand supersedes conflicted PR #2751.Problem
SQLite FTS5
unicode61does not foldł/Łbecause those code points have no Unicode decomposition.remove_diacritics 2handles ordinary Polish diacritics, but not l-stroke.The first implementation correctly folded fresh-write triggers and normal queries, but audit found three production maintenance paths that still inserted raw
search_text: the publicArchiveStore.rebuild_index()path and the dangling-row repair paths for threads and session work events. Because query text was always folded, running one of those maintenance routes silently removed the new recall guarantee for the repaired rows.Solution
PL_FOLD_TABLEforł->landŁ->L, with Python, registered SQLite-function, and inline SQL-expression projections derived from it.messages_fts,threads_fts, andsession_work_events_ftstounicode61 remove_diacritics 2.escape_fts5_querychokepoint used by productionMATCHbuilders.INDEX_SCHEMA_VERSIONat 35. This is a rebuildable derived-tier change; existing archives usepolylogue ops reset --index && polylogued run, with no in-place migration helper.Acceptance criteria
latwo/zrobilemfind seededłatwo/zrobiłemtest_pl_fold.pyMATCHbuilders normalize query textescape_fts5_query/normalize_fts5_queryrouting and call-site auditArchiveStore.rebuild_index()test plus actual dangling repair test for both derived surfacespolylogue-xul7carries the measured opt-in laneAnti-vacuity: removing the fold from
rebuild_archive_messages_ftsmakes the public rebuild test lose both ASCII and literal Polish hits. Removing either fold fromdangling_repair.pymakes the corresponding thread or work-event assertions fail afterrepair_missing_fts_rows; the tests seed source rows before repair and do not rely on fresh-write triggers.Verification
devtools test tests/unit/storage/test_pl_fold.py— 13 passed.devtools test tests/unit/storage/test_fts_repair_sql.py— 8 passed.devtools test tests/unit/storage/test_dangling_fts_derived_surfaces.py— 11 passed.devtools test tests/unit/storage/test_schema_policy_contracts.py— 14 passed.devtools test -k schema_mismatch tests/unit/daemon/test_daemon_cli.py— 2 passed, 73 deselected.devtools render topology-projection— wrote 912 rows, 6 existing TBD cells.devtools render topology-status— clean.devtools render all --check— exit 0; all generated surfaces in sync..agent/scripts/bd-graph-lint— reports two inherited master missing-AC records (polylogue-2ilz,polylogue-nu2h); no dependency cycles, duplicate labels, or inversions, and this branch does not modify either record.git diff --check— exit 0.jq -e -c . .beads/issues.jsonl >/dev/null— exit 0.devtools verify --quick— exit 0; repeated successfully by the pre-push hook at commit31eb97de6.Ref polylogue-9jsi