Skip to content

fix(conn-server): pass 9 search fixes: agent search by linked PR, accent-folded message search, as T3 - #285

Merged
nckrtl merged 9 commits into
mainfrom
fix/pass9-search
Nov 24, 2026
Merged

nckrtl merged 9 commits into
mainfrom
fix/pass9-search

Conversation

@nckrtl

@nckrtl nckrtl commented Nov 23, 2026 •

Copy link
Copy Markdown
Owner

Pass 9, findings 9.4 (conn-mcp) and 9.5 (conn-engine), with the gate findings on them fixed.

9.4: An agent can't find an active thread from its linked PR. conn_thread_search matched title, branch and project only. It now reads the thread's PRs as T3's threadSearchPullRequests and scoreThreadSearch do:

  • the branch PR, then visible linked PRs newest first (dismissed stack members excluded), else the legacy linkedPullRequest;
  • the query folds as foldSearchQuery: wrapping quotes stripped, NFC, case and accents folded. Titles, branches and project names fold the same way (foldInPlace);
  • each PR's #N and, for the newest three, its title: every query word must start a word there (matchToken without mid-word hits; filler words optional), after a pr, pull or # prefix. "resume" and "indexing resume" find "Résumé indexing"; "sume" doesn't;
  • owner/repo#N, the PR URL and the thread id, by matchReference's rule. A quoted "example/fixture#7483" now matches too.

Test (pull_request_watches.rs): link, sync a snapshot titled "Résumé indexing", search, unlink, all over MCP. Fails on main and on 2d5a8beb94 (resume and the quoted reference).

9.5: A search without accents misses an accented message.

  • message_search stores text folded as T3's index tokenizer (trigram remove_diacritics 1) folds it, as the public conn_engine::fold(text) -> String (src/fold.rs): lower case, Latin letters lose their diacritics (SQLite's remove_diacritics mark set), and other scripts' marks stay. "かかく" doesn't find "かがく"; "ß", "ø" and "fi" stay distinct. Ordinary writes (index_message) and the T3 import both fold what they index.
  • Queries are NFC first, then fold the same way (messageSearchTokens): decomposed "한글" finds composed "한글".
  • A query word shorter than four characters must start a word in the message (messageMatcher, MESSAGE_WORD_START_LENGTH): "marker me" no longer finds "marker fermé", and "fts" no longer finds "drafts".
  • Snippets come from the original text.
  • The meta mark message_search_folded is now 2. A store with no mark or mark 1 is folded again once, from the message texts, in batches of 500 inside one transaction. It stays a mark, not a schema version, so it composes with fix(conn-server): an undone settle keeps the thread's place in Active #260 (user_version = 5) and fix(conn-server): preview tunnel, peer tool names, thread chips, orphaned subagents, resumed Claude MCP #256 (v6, whose citation re-index can call conn_engine::fold).
  • The refold prints T3's migration lines (databaseMigrationLog.ts): started, a progress line every 10,000 messages, then finished. The desktop's readiness check (DesktopBackendManager.ts, isRunningDatabaseMigrations) keeps waiting past its 3-minute limit while they run. The three messages are now generated into conn-contract by tools/gen-upstream.mjs, not copied by hand.

Depends on #261: moving SqliteEngine::open (and so this refold) off the runtime thread onto spawn_blocking is #261's change. This PR doesn't duplicate it. Until #261 lands, a large refold still runs on the runtime thread during start, before the server listens. Merge order: #260, this PR, then #256.

Tests (engine_tests.rs, store.rs, t3_import/tests.rs, fold.rs):

  • search_folds_latin_accents_only_and_normalizes_the_query: kana, Hangul, French and ß/ø/fi; a mark-1 store refolds once from the message text.
  • search_short_words_must_start_a_word: "marker me", "marker ke" and "fts" find nothing; "marker fe", "dra" and "afts" still match.
  • a_refold_reports_its_start_progress_and_end_once: 10,001 messages give started, one progress line and finished, and nothing on a second open.
  • The import test asserts the indexed text is folded.
  • The earlier search_folds_case_and_accents_before_and_after_the_upgrade still passes.

New dependency: unicode-normalization 0.1.26 (unicode-rs; MIT/Apache-2.0 and Unicode-3.0), with tinyvec. Measured on the first commit: +113 KiB in a stripped LTO release binary. Static tables only.

Checks. cargo fmt --check, cargo clippy -p conn-engine -p conn-mcp -p conn-contract --all-targets -D warnings, and all conn-engine (217), conn-mcp (104) and conn-contract tests pass. gen-upstream.mjs --check passes. tools/check.sh was not run locally (disk); CI runs it. The serve.rs T3 import still keeps its own copy of the three messages; switching it to the generated constants is left out, because conn-server was not built here.

🤖 Generated with Claude Code (Claude Opus 5.5)

nckrtl and others added 2 commits November 23, 2026 19:18
…, as T3

conn_thread_search matched title, branch and project only, so an agent given
#7483, example/fixture#7483 or the PR URL could not find the active thread
that owns the PR. The candidate filter now reads the thread's visible PRs as
threadSearchPullRequests does: the number after a pr/pull/# prefix, the
newest three titles, and owner/repo#N, the URL and the thread id by
matchReference's whole-query rule. Dismissed stack members stay out.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…too, as T3

A search for "ecole fermee" or "fermée éc" missed a message that reads
"École fermée à Lyon": the trigram index and the short-word check folded
ASCII case only. The index now stores text folded as T3's foldCharacter does
(NFKD, marks dropped, lower case), queries fold the same way, and the
short-word check reads the folded index text. Snippets still show the
original text. An existing index is refolded once, in batches inside one
transaction, under a meta mark rather than a schema version (PR #260 also
adds version 5). A T3 import folds what it indexes.

New dependency: unicode-normalization 0.1.26 (unicode-rs, MIT/Apache-2.0
and Unicode-3.0, both allowed), with tinyvec. Measured cost: +113 KiB in a
stripped LTO release binary, static tables only, no heap.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:L labels Nov 23, 2026
…he refold

Gate findings 9.4 and 9.5 on #285.

- conn-mcp: the query folds as `foldSearchQuery` (wrapping quotes, NFC, case and
  accents), and so do titles, branches and projects. A PR's `#N` and searched
  title match word by word at word starts (`matchToken`), so "resume" finds
  "Résumé indexing" and a quoted "example/fixture#7483" finds its thread.
- conn-engine: the index folds as SQLite's `trigram remove_diacritics 1`, now the
  public `conn_engine::fold`: Latin diacritics go, but dakuten, Hangul and other
  letters stay apart. Queries are NFC first. The `message_search_folded` mark is
  2, so a store folded by the first fold is folded again once, from message text.
- conn-engine: a query word shorter than four characters must start a word in the
  message (`messageMatcher`), so "marker me" no longer finds "marker fermé".
- conn-engine: the refold prints T3's migration lines (start, every 10,000
  messages, finished), now generated into conn-contract from
  `databaseMigrationLog.ts`, so the desktop keeps waiting past its readiness limit.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Round-2 gate findings on pass 9 search:

- conn_thread_search matched a project name and a PR only as one
  substring, so "lakebed #7483" missed a thread of project Lakebed linked
  to #7483. It now matches word by word across title, PR number and
  titles, branch and project, as scoreThreadSearch, and keeps matchHint's
  rule that a field explains the words left after the project's name.
- The index fold used Rust's Unicode tables and differed from SQLite on
  461 code points (it took both marks off "ǡ", and kept "ſ"). It now reads
  a table generated from the bundled SQLite's trigram tokenizer
  (sqlite-fold.txt); a test fails when SQLite folds differently. The fold
  mark goes to 3, so stores at 2 refold.
- The matcher ports findMessageToken: word length counts before the
  index fold ("İce" finds "service"), hits inside a hex id do not count,
  and the snippet starts at the accepted occurrence.
- A refold batch ends at 4 MiB of text or 500 rows, read in rowid order
  without a sort.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added size:XXL and removed size:L labels Nov 23, 2026
nckrtl and others added 5 commits November 23, 2026 22:30
…atcher

Round 3 of the gate on pass 9 (audit 9.4, 9.5):

- Message queries are lowercased before the index fold, as messageSearchTokens:
  uppercase Georgian finds lowercase, though SQLite's fold leaves Mtavruli alone.
- Words follow T3's general categories (\p{L}, \p{N}, \p{Ll}, \p{Lu}, \p{So}, from
  regex-syntax, already in the binary): a symbol starts a word only where a letter
  would, in fields and in messages. Messages read in UTF-16 units, so an emoji above
  U+FFFF still brings its own boundary, as in T3.
- messageMatcher's snippet offset: the lowercase pass first, the accent-folded pass
  only without a whole word; words side by side as typed first, then the shortest
  stretch, all in UTF-16 units; the snippet reads the offset back.
- A refold batch never passes its byte budget: a row that would is read again as
  the next batch's first, and a row larger than the budget is folded alone.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The snippet started 80 characters before the match. It now follows
buildSearchSnippet in ThreadSearch.ts, in UTF-16 units: from the next word start
within 24 units before the match, never inside a surrogate pair, emphasis and code
marks dropped, whitespace collapsed, at most 240 units with ellipses where the text
was cut.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A thread titled as the query dropped out under a small limit when a newer
thread only linked a PR of that title. Hits now rank whole title, then
title, then other fields, before the limit; recency breaks ties.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…as T3

The matcher saw the link address, so 'quartz' found a message that only
shows 'release notes'. Links reduce to their label before matching and the
snippet, like ThreadSearch.ts's MARKDOWN_LINK.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts:
#	apps/conn-server/Cargo.lock
#	apps/conn-server/crates/conn-contract/src/lib.rs
#	apps/conn-server/crates/conn-contract/src/upstream.rs
#	apps/conn-server/crates/conn-engine/Cargo.toml
#	apps/conn-server/crates/conn-engine/src/store.rs
#	apps/conn-server/tools/gen-upstream.mjs
@nckrtl
nckrtl merged commit 0da14b3 into main Nov 24, 2026
48 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant