Repository navigation
fix(scheduler): compute overlap_ms via union, not pairwise sum - #757
Conversation
overlap_ms summed overlap across every (left, right) interval pair, so when either side already held multiple intervals that overlap each other (pipelined model/proof sub-phases), the shared wall-clock window got counted once per overlapping pair and inflated investigation_proof_overlap_ms / model_proof_overlap_ms / proof_overlap_ms in scheduler.json. union_wall_ms already guards the same hazard for wall_ms (see LoopAccumulator::record); overlap_ms now reuses it via inclusion-exclusion (|A| + |B| - |A ∪ B|), which is exact whether or not either side self-overlaps. Adds a regression test demonstrating the double-count the old pairwise sum produced (200ms) versus the correct union-based overlap (150ms).
|
Warning Review limit reached
Next review available in: 36 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: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ 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 |
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
There was a problem hiding this comment.
Decision
- Needs reviewer attention before upstream: findings remain.
Confirmed findings
- overlap_ms now heap-allocates a Vec on every call (left+right len), replacing a pure saturating_add loop. For typical scheduler fan-out this is small, but the prior version was allocation-free; worth a note in PR or a SmallVec/reuse-buffer if metrics() is called frequently.
- contract-mirror lane found no mirror-pair drift. overlap_ms is a Rust-internal scheduler metric with no Bun/Python verifier twin in docs/REVIEW_LEDGER.md. Late-phase cargo-check/clippy/test/doc receipts gate compilation and behavior; cross-language parity is not applicable to this diff.
Verification questions
- Confirm single caller of overlap_ms is RunLoopTracker::metrics; union_wall_ms is the same file, no behavior drift beyond metrics helper.
- Confirm pR claims 'mathematically identical to the old formula in the already-common non-self-overlapping case' but does not prove via test or proof receipt — only via one existing test name.
- Confirm new regression test depends on union_wall_ms correctly handling multi-interval self-overlap, but no dedicated unit test exists for that helper in the visible diff/ledger.
- Confirm pR author claims run_loop_metrics_count_actual_model_proof_overlap still passes unchanged — this is a Rust-side behavioral test, not a verifier mirror parity check; cannot be cross-checked mechanically by the Bun/Python verifier.
- Confirm pR claims the existing run_loop_metrics_count_actual_model_proof_overlap test still passes unchanged — checks that pairwise-equivalence claim is also test-pinned, not merely argued.
- Confirm three lane requests (proof-0005/0007/0008/0009) duplicate the same single-test proof already merged into the red-green task proof-red-green-40f04a925995; running them as separate focused tests would consume the max_focused_tests=4 budget without changing the gate outcome.
Refuted
- Pairwise sum is correct in all cases; refuted because: Inclusion-exclusion via union_wall_ms is exact regardless of self-overlap; pairwise sum over-counts when a side has multiple overlapping intervals sharing the same wall window. Regression test demonstrates 200ms→150ms correction.
- Bun/Python verifier must be updated to track overlap_ms union formula change; refuted because: docs/REVIEW_LEDGER.md mirror-pair map does not list any scheduler metrics or overlap_ms as a mirrored contract; scripts/verify-bun-review-artifacts.py pins phrase/schema mirrors listed in the ledger, none of which this diff touches.
- Could overlap_ms feed gate_outcome or a reason-kind and thereby redden the gate if union_wall_ms is wrong?; refuted because: overlap_ms is consumed only by tracker.metrics() metric fields (investigation_proof_overlap_ms, model_proof_overlap_ms, proof_overlap_ms); these are report metrics, not gate_outcome inputs. Gate-semantics lane scope is gate_outcome/reason-kinds/[gate] policy keys/fail-on-gate resolution/pass policy; none are touched.
Proof results
Parked follow-ups
Evidence gaps
[review body truncated; see review artifacts]
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
…PR gap The overlap_ms regression test used interval values where the three intermediate unions (model's, proof's, and their combination) all happened to equal 150ms — a coincidental tie that a wrong-operand mutation of the formula couldn't have failed under. Rework the intervals so all three quantities (and the expected overlap) are pairwise distinct, giving each operand in the inclusion-exclusion formula its own value to be pinned against. The self-review gate still flagged both saturating_add/saturating_sub call sites as weakly exposed even with the stronger oracle: RIPR 0.10.0 cannot trace the assertion through the RunLoopTracker::metrics() -> overlap_ms() indirection to the intermediate locals inside the helper (the same limitation already suppressed for src/enable.rs under #737). Add matching .ripr/suppressions.toml receipts for both probes; verified locally with `ripr check --diff ... --mode ready` that this drops unsuppressed_exposure_gaps from 2 to 0 (status: pass).
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
Summary
overlap_ms(src/main.rs) computedinvestigation_proof_overlap_ms/model_proof_overlap_ms/proof_overlap_msby summing overlap across every(left, right)interval pair. When either side already held multiple intervals that overlap each other (pipelined model/proof sub-phases — the same hazardunion_wall_mswas written to guard against forwall_ms, seeLoopAccumulator::record), the shared wall-clock window got counted once per overlapping pair, inflating the scheduler metric.overlap_msto compute the overlap via inclusion-exclusion (union_wall_ms(left) + union_wall_ms(right) - union_wall_ms(combined)), reusing the existingunion_wall_mshelper. This is exact regardless of self-overlap on either side, and mathematically identical to the old formula in the already-common non-self-overlapping case (verified against the existingrun_loop_metrics_count_actual_model_proof_overlaptest, which still passes unchanged).run_loop_overlap_ms_does_not_double_count_self_overlapping_side, a regression test demonstrating the fix. Reworked its interval values so the three intermediate unions the formula combines are pairwise distinct (an earlier version had all three coincidentally equal to 150ms, a weak oracle that a wrong-operand mutation couldn't have failed under); with the stronger values, the old buggy pairwise sum gives 170ms against the correct union-based 120ms.ub-review/gateCI run flagged both newsaturating_add/saturating_subcall sites as RIPR "weakly exposed" (mutation-exposure) findings even with the strengthened test — RIPR 0.10.0 can't trace the assertion through theRunLoopTracker::metrics() -> overlap_ms()indirection to the function's private intermediate locals, the same known limitation already suppressed elsewhere in this repo forsrc/enable.rsunder chore(tools): align RIPR 0.10.0 finding-ID contract #737. Added two matching.ripr/suppressions.tomlreceipts; verified locally withripr check --diff ... --mode readythatunsuppressed_exposure_gapsdrops from 2 to 0 (status: pass).Policy receipts
If this PR adds or changes any controlled surface, link the TOML receipt here:
policy/allow.toml: none added —.ripr/suppressions.tomlis already covered by the existingnon-rust-ripr-suppressionsglob receipt (policy/allow.toml, review_after 2026-07-22)riprorunsafe-reviewsuppressions, only if needed: added 2riprexposure-gap suppressions (probe:src_main.rs:return_value:54397ad5,probe:src_main.rs:return_value:d3368aab) — see.ripr/suppressions.toml, both linking issue chore(tools): align RIPR 0.10.0 finding-ID contract #737Verification
Cheapest relevant proof first, deeper proof where it buys signal.
cargo fmt --all -- --check,cargo check --workspace --all-targets --locked,cargo clippy --workspace --all-targets --locked -- -D warningsall cleancargo test --workspace --all-targets --locked— 626 + 54 + 18 tests pass (1 pre-existing ignored subprocess-driver test, unrelated)cargo xtask policy-checkpasses (6 policy files, 11 allow receipts, 5 CI lanes, 2 risk packs; unchanged by this PR)ripr check --root . --diff <local diff> --mode readylocally — confirmedunsuppressed_exposure_gaps: 0,status: passafter adding the suppression receipts (the first push failed the gate on this:new_unsuppressed=2 exceeds configured maximum 0)CI budget
Agent notes
#[allow]; use#[expect(..., reason = "...")]with a receipt.ripris static mutation-exposure analysis; runtime mutation remains the slower backstop.unsafe-reviewowns unsafe/native reviewability; do not duplicate it in repo scripts.xtaskshould orchestrate repo-local receipts and checks, not replace specialized tools.