Repository navigation
fix(chunker): heading duplication + multibyte infinite loop; 40 mutation-killing tests (50%→97%) - #1024
Merged
Conversation
…ion-killing tests (score 50%→97%)
Two production bugs found by mutation testing:
1. Heading duplication: oversized markdown sections had their heading
prepended twice in the first sub-chunk (once by split_by_headings,
once more by the sub-chunk loop), corrupting downstream embeddings.
Fixed by removing the dead heading_prefix re-prepend path entirely.
2. Multibyte infinite loop: split_long_text's zero-progress guard
advanced by raw byte offsets that could land inside multi-byte UTF-8
characters (CJK/emoji), flooring back to start forever.
chunk_markdown("日本語", 2) would hang. Fixed with a proper
forward-char-boundary advance in the guard.
Also:
- 40 new mutation-killing tests (chunker: 20 → 60 tests)
- cargo-mutants config moved to .cargo/mutants.toml (v27 schema:
exclude_globs/exclude_re, valid keys only); glob paths fixed to
match from workspace root; CLI update_check also excluded
- 3 proven-equivalent mutants excluded with documented reasoning
- docs/mutation-testing.md: final scores, bug postmortem, timeout notes
Verify run: 164 mutants, 149 caught, 0 missed, 5 timeout, 10 unviable (97%)
🔍 Cora AI Code Review✅ No issues found. Code looks good! Review powered by cora-code · BYOK · MIT |
What
Mutation testing hardening for
chunker.rs— plus two production bug fixes the process uncovered.Why
chunker.rsbaseline mutation score was 50% (68/163 missed) — the test suite could not detect real logic regressions. Mutation testing exposed two genuine production bugs as proof the gaps were real, not theoretical.Changes
split_by_headings, once more by the sub-chunk loop), corrupting downstream embeddings. Removed the deadheading_prefixre-prepend path entirely.split_long_text's zero-progress guard advanced by raw byte offsets that could land inside multi-byte UTF-8 characters (CJK/emoji), flooring back to start forever.chunk_markdown("日本語", 2)would hang. Fixed with a proper forward-char-boundary advance.docs/mutation-testing.md.cargo/mutants.toml(v27 schema:exclude_globs/exclude_re, valid keys only). Previous config atcrates/uteke-core/mutants.tomlwas silently never read (invalid keyexclude_files→ defaults). Glob paths fixed to match from workspace root; CLIupdate_checkalso excluded.docs/mutation-testing.md: final scores table, production bug postmortem, timeout/equivalent mutant notesTesting
test_md_subchunk_no_heading_duplication,test_split_long_text_multibyte_tiny_limit)Note: mutants output dirs are gitignored local artifacts; ~40 MB of stale run outputs cleaned from disk.