Add test coverage for pure modules + fix FTS and reranker bugs#10
Conversation
The previous regex only removed AND/OR/NOT/NEAR when surrounded by whitespace on both sides, so a leading or trailing keyword leaked through as a search token (`OR "injection"` became `OR:* | injection:*` instead of `injection:*`). Filter keywords at the token stage so they are dropped consistently regardless of position, matching the documented behavior. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Add unit tests for src/utils.ts: reciprocalRankFusion (list fusion, cross-list rank boost, k truncation, empty-list early returns, rrfK sensitivity, distance remap) and sanitizeFtsQuery (prefix-OR form, short-token drop, operator/keyword stripping, empty-input handling). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Add unit tests for src/text-style-rules.ts: each individual rule (dash and ellipsis normalization, AI lead-in stripping, first-letter capitalization, markdown bold/italic/code/header/link stripping), the idempotency invariant required of every rule, and applyStyleRules ordering and rule threading. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Add unit tests for the pure exports of src/rewrite-query.ts: questionNeedsRewrite (empty input, no-history, short follow-ups, deictic markers, leading conjunctions, long self-contained questions) and sanitizeRewritten (think-tag and code-fence stripping, answer-prefix removal, first-line selection, maxLength truncation, fallback on empty output). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Add unit tests for parseSlugList in src/grade-skills.ts: bare JSON array, code-fenced JSON, comma/newline-separated plain text, allowed-list filtering, empty input, empty array, and non-string element rejection. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
CohereReranker and JinaReranker mapped each API result with `...(hits[index] as KbSearchHit)`. The cast masked an `undefined` from `noUncheckedIndexedAccess`, so an index outside the input range produced a malformed hit carrying only `distance` — no `chunk_id`, `text`, or other KB fields. Switch to `flatMap` and drop results whose index has no corresponding hit. Adds test/reranker.test.ts covering both rerankers via a mocked fetch. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The biome-ignore above `outputSchema` no longer suppresses anything — the field is typed `z.ZodTypeAny`, not an explicit `any` — and biome flagged the comment itself as having no effect. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (8)
✨ 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 |
|
🎉 This PR is included in version 1.2.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Summary
Расширяет покрытие тестами непокрытых чистых функций и исправляет два реальных бага, найденных при написании тестов.
Фиксы:
sanitizeFtsQueryубирал булевы ключевые слова (AND/OR/NOT/NEAR) только когда они окружены пробелами с обеих сторон — ведущее/замыкающее ключевое слово протекало как поисковый токен (OR "injection"→OR:* | injection:*). Теперь фильтруются на этапе токенизации, в любой позиции, как и описано в docstring.CohereReranker/JinaRerankerмаппили результат API через...(hits[index] as KbSearchHit). Каст маскировалundefinedотnoUncheckedIndexedAccess, и индекс вне диапазона давал «битый» хит безchunk_id/text. Теперь такие результаты отбрасываются.Тесты: новые файлы для
utils.ts(RRF + FTS),text-style-rules.ts,rewrite-query.ts,grade-skills.ts,reranker.ts. Всего тестов: 91 → 148.Прочее: удалён мёртвый
biome-ignoreвanswer-types.ts.Test plan
bun test— 148 pass, 0 failbun run typecheck— без ошибокbun run check— без ошибок (warning изanswer-types.tsустранён)🤖 Generated with Claude Code