Skip to content

test(core): kill the document and skill search mutants left open by the v0.24.0 gate - #1811

Merged
ajianaz merged 2 commits into
developfrom
test/doc-skill-search-windows-1766
Nov 26, 2026
Merged

ajianaz merged 2 commits into
developfrom
test/doc-skill-search-windows-1766

Conversation

@ajianaz

@ajianaz ajianaz commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

What

Killing tests for 29 of the 31 mutants that the v0.24.0 mutation gate left open in doc_search_semantic, doc_search_hybrid, skill_search and doc_list_children, and three small simplifications of code that only the gate showed to be redundant (same behaviour). The other 2 mutants are k * 4 in index.search, which cannot be observed (below).

Why

Part of #1766, which stays open. The comment on the issue said these needed the embedding model. They do not: the keyword test embedder gives a chunk the cosine 1 / sqrt(distinct words), so a fixture can choose every rank and every window. I re-ran the gate on the code of develop first (88 mutants in the functions of the checklist: 51 caught, 6 unviable, 31 missed) so that this list is measured, not remembered from the issue. doc_duplicate_report and embed_need were already caught: that item of the checklist is confirmed.

How

Ten tests in a new search_window_tests.rs, each naming the behaviour it pins:

  • hybrid: each list is asked for limit * 2 documents. With limit 1 the document second in both lists (1/62 + 1/62) beats the ones first in a single list, and a third place in either list would change the winner, so a wider or empty window changes the result. A score is the sum of 1 / (60 + rank) over the lists, with exact values for all three documents.
  • semantic: the index window is limit * 10 chunks past chunks of the other kind (14 files of skills before the plain document, limit 2); the cap is limit * 3 chunks of the wanted kind (six chunks of one document leave b-doc out at limit 2, and reaching all eight at limit 3); a snippet is cut only above 200 bytes (199, 200 and 201); a document keeps the first of two chunks with exactly the same vector. That last expectation is read from the index, so it does not depend on how ties are ordered.
  • skill_search: limit * 5 files are asked for (nine files of one skill before the next skills), and semantic mode returns the embedding error where hybrid answers from FTS.
  • doc_list_children: a skill lists nothing by slug or by id.

Simplifications, with the behaviour pinned by the tests above and by the existing suite:

  • In the hybrid fusion the semantic loop inserts instead of adding to an entry. The semantic list holds each document once, so the "already there" branch never ran (4 mutants that could not be killed).
  • doc_list_children checked for a skill twice; the check after the slug is resolved covers both inputs.
  • skill_search no longer tracks best_semantic: the semantic list is ordered best first and read first, so the first file of a skill is its best (3 mutants).

The cosine values in the tests are compared with a tolerance, because the quantized vecq engine returns them approximately; the ranks, slugs, windows and RRF scores are exact. The tests pass on both engines.

Not killed, listed as the owner rule asks: lib.rs index.search(&query, k, k * 4), * → + and * → / (2 mutants). The third argument is the breadth of the HNSW search, a tuning value; on any store the tests can build the result is the exact nearest set, so no assertion can tell the values apart.

Testing

  • cargo test --workspace passes
  • cargo fmt --all -- --check passes
  • cargo clippy --workspace --all-targets -- -D warnings passes
  • Cora review run locally (cora review --base origin/develop)
  • Manual smoke-test of the affected feature

The new tests also pass on the other engine: cargo test -p uteke-core --no-default-features --features "onnx,vecq" --lib -- search_window_tests.

Mutation gate (owner rule 2026-08-19), cargo mutants -p uteke-core -F 'doc_search_hybrid|doc_search_semantic|skill_search|doc_duplicate_report|doc_list_children|embed_need|EmbedGate|MAX_SCAN_DIRS' -- --lib, same filter before and after:

mutants caught unviable missed
develop 88 51 6 31
this PR 77 69 6 2 (k * 4, above)

After the last edit (tolerance on the cosine) the two functions whose tests changed were run again: 46 mutants, 42 caught, 2 unviable, the same 2 missed. The 88 to 77 comes from the code removed above.

Related Issues

Refs #1766 (does not close it).

Checklist

  • Branch name follows convention (fix/, feat/, docs/, chore/, refactor/, test/, perf/, security/)
  • Branch is from develop
  • Commit messages follow Conventional Commits
  • No secrets or credentials committed
  • One logical change per PR (no mixed concerns)

…te left open (#1766)

The gate reported 31 missed mutants in doc_search_semantic, doc_search_hybrid,
skill_search and doc_list_children. They need no ONNX model: the keyword test
embedder gives a chunk the cosine 1 / sqrt(distinct words), so a fixture can
choose every rank.

- hybrid: each list is asked for limit * 2 documents (limit 1: the document
  second in both lists beats the one first in a single list, and a third place
  in either list would change the winner), and a score is the sum of
  1 / (60 + rank) over the lists, with exact values.
- semantic: the index window is limit * 10 chunks past chunks of the other
  kind, the cap is limit * 3 chunks of the wanted kind (reached with fewer than
  limit documents, and reaching past a long document), the snippet is cut only
  above 200 bytes, and a document keeps the first of two equally close chunks
  (the expectation is read from the index, not from how ties are ordered).
- skill_search: limit * 5 files are asked for, and the semantic mode returns
  the embedding error where hybrid falls back on FTS.
- doc_list_children: a skill lists nothing by slug or by id.

Three pieces of code only the gate saw as live are simplified, with the same
behaviour: the semantic loop of the hybrid fusion inserts instead of adding to
an entry that cannot exist (the semantic list holds each document once), the
first skill guard of doc_list_children repeated the check after the slug is
resolved, and skill_search no longer tracks a best_semantic score (the semantic
list is ordered best first, so the first file of a skill is its best).
The quantized vecq engine returns a similarity approximately, so the exact
cosine values failed there. The ranks, the slugs and the windows the tests
pin do not depend on the value; the RRF scores, which come from ranks, stay
exact.
@github-actions

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

@ajianaz
ajianaz merged commit 599f103 into develop Nov 26, 2026
18 checks passed
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.

1 participant