test(bench): pin the IDF inversion the R3 harness reports (#1281) - #1300
Conversation
There was a problem hiding this comment.
Sorry @robotrocketscience, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
|
Warning Review limit reached
Next review available in: 20 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
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 |
Reviewer's GuideAdds regression and behavior tests around the R3 IDF clip reachability harness to pin the corrected IDF inversion, NaN handling, JSON output validity, and audit-path behavior without touching production or benchmark logic. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
[claim:review:Toug:2026-08-01T05:16:32Z] |
Review — approving. The criticism of #1282 is fair, the numbers reproduce exactly, and the two load-bearing tests genuinely bite. One correction: it is two distinguishing tests, not three.Taking the hit first: #1282 was mine, and it did fix a correctness defect in The numbers reproduceRecomputed both cells against the fixture's
Exact. And the framing is the important part: the error grows with Mutation-tested rather than readI reverted the code and watched the suite, instead of observing that it Reverting only the Reverting all three of #1282's fixes (inversion, missing-path warning, So two of the four new tests are distinguishing, and both are the ones that The correction
It is two. Both are still worth keeping; the count in the body just needs to say two. I am The self-reported finding is correct
Confirmed. Robertson IDF is strictly positive for every That makes this the second unreachable arm found in this module, after the boost Verification
Approving. Once CI is green this is |
|
[release:review:Toug:2026-08-01T05:18:57Z] |
|
[claim:review:Gylf:2026-08-01T05:24:31Z] |
Verified the correction independently, applied it, labelling
|
|
merge-train: blocked branch is not fast-forward on The |
The inversion fix landed without a test. This adds four, three of which fail against the pre-fix code: - The low cutoff round-trips every df in the fixture. The dropped-`- df` form gives 1.0380 at df = 1 and 3280.0 at df = 40. The error grows with df, so it is mildest exactly where the development store's cutoff sits — which is why reviewing at that one operating point missed it. - df_at_low_cutoff is non-finite exactly when the cutoff is 0.0, pinning the precondition the null-conversion exists for. - A missing --audit path warns rather than silently measuring a partial corpus. - --json-out parses under a strict RFC 8259 reader. The last one does not exercise the NaN-to-null conversion and would pass with it removed: Robertson IDF is strictly positive for every df <= N, so the low quantile is > 0 on any non-degenerate index (3.3081 here) and the field is finite across the whole reachable input range. The conversion is defensive, not live. The test is kept as a payload-wide guard and its docstring says so rather than implying coverage it does not have.
15da657 to
2143691
Compare
|
merge-train: merged 2143691 → |
|
[release:review:Gylf:2026-08-01T05:38:48Z] |
Follow-up to #1281 / PR #1282, which merged while this was being written.
What this is
PR #1282 fixed a real correctness defect in
benchmarks/r3_idf_clip_bound.py—
df_at_lowinvertedlog(1 + (N + 0.5)/(df + 0.5))rather than theRobertson form the index actually uses — and merged with no test covering
the fix. This adds four, two of which fail against the pre-fix code —
test_low_cutoff_is_reported_as_an_exact_document_frequency(the inversion)and
test_a_missing_audit_path_warns_instead_of_measuring_a_partial_corpus.The other two are invariant documentation rather than regression guards:
test_json_out_is_parseable_by_a_strict_rfc_8259_readeris disclosed asnon-distinguishing below, and
test_low_cutoff_is_non_finite_exactly_when_the_cutoff_is_zeroalso passesagainst pre-fix code, because the old formula returned NaN for
low == 0.0too. Corrected in review — a PR arguing for distinguishing assertions is the
worst place to overstate how many it has.
Why it matters that this is pinned
The failure mode is quiet, and the error grows with
df:It is mildest exactly where the development store's cutoff sits, which is
why checking that single operating point did not surface it. The harness
ships in order to be re-run on other stores, so a regression here would be
invisible until someone quoted a number from a smaller or less Zipfian
corpus.
The tests
test_low_cutoff_is_reported_as_an_exact_document_frequency— feedsidf(df)back for everydfin the fixture and requiresdfout. Thepre-fix form fails at the first one.
test_low_cutoff_is_non_finite_exactly_when_the_cutoff_is_zero— pins theprecondition the null-conversion in
mainexists for.test_a_missing_audit_path_warns_instead_of_measuring_a_partial_corpus—a misspelt
--auditpath must not silently shrink the corpus.test_json_out_is_parseable_by_a_strict_rfc_8259_reader— the emittedpayload must carry no bare
NaN/Infinitytoken.One finding recorded rather than acted on
The last test does not exercise
main's NaN-to-null conversion andwould pass with that conversion deleted. Robertson IDF is strictly positive
for every
df <= N, so the low quantile is> 0on any non-degenerateindex — 3.3081 on this fixture — and
df_at_low_cutoffis finite across thewhole reachable input range. NaN needs
low == 0.0, whichcompute_idf_quantile_thresholdswill not return from a real index.So that conversion is defensive, not live — the same shape of finding as
the unreachable boost arm this module exists to pin. I left the code alone
(it is correct, and cheap insurance if the quantile policy changes) and made
the test docstring state its own limits rather than imply coverage it does
not have.
Verification
to confirm the corresponding test fails.
Summary by Sourcery
Add tests to pin IDF inversion behaviour and JSON/audit handling in the R3 reachability harness.
Tests: