test(eval): add compression ratio gate - #135
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
|
Warning Review limit reached
Next review available in: 17 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 (3)
✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
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 |
There was a problem hiding this comment.
Code Review
This pull request introduces a compression evaluation gate, adding documentation and an integration test to verify that the zstd compression ratio of a representative OKF session remains below a specified threshold. Feedback on the integration test highlights a potential integer overflow on 32-bit architectures and a division-by-zero risk if the fixture is empty, suggesting the use of u64 casting and checked_div to perform the calculation safely.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
|
||
| assert_eq!(decoded, FIXTURE, "zstd must preserve fixture bytes"); | ||
|
|
||
| let ratio_bps = compressed.len() * 10_000 / FIXTURE.len(); |
There was a problem hiding this comment.
On 32-bit architectures (such as certain WASM targets or 32-bit ARM/x86), usize is 32-bit. If the session fixture or compressed payload grows beyond ~430 KB, the multiplication compressed.len() * 10_000 will overflow u32::MAX, causing a panic during test execution. Additionally, if the fixture is ever empty, this will panic with a division-by-zero error.
Using u64 casting and checked_div prevents both overflow and division-by-zero issues safely.
let ratio_bps = (compressed.len() as u64 * 10_000)
.checked_div(FIXTURE.len() as u64)
.expect("fixture must not be empty") as usize;|
|
||
| const FIXTURE: &str = include_str!("fixtures/okf/auth-fix-session-001.okf.json"); | ||
| const ZSTD_LEVEL: i32 = 3; | ||
| const MAX_RATIO_BPS: usize = 6_500; |
There was a problem hiding this comment.
SUGGESTION: Hardcoded MAX_RATIO_BPS gate is sensitive to zstd library version drift
The compressed byte count depends on the zstd version linked transitively by the zstd/zstd-sys crates. A routine dependency bump that changes zstd's output size at a fixed level can shift ratio_bps across the 6500 boundary and fail this CI gate even with no fixture or code change. Consider documenting this version-dependency in docs/ops/eval-compression.md alongside the existing fixture-change policy, or basing the assertion on a small tolerance band, so unrelated dependency bumps don't break the build.
Reply with @kilocode-bot fix it to have Kilo Code address this issue.
Code Review SummaryStatus: 1 Issue Found | Recommendation: Merge with notes (non-blocking) Overview
Issue Details (click to expand)SUGGESTION
Files Reviewed (3 files)
Fix these issues in Kilo Cloud Reviewed by hy3:free · Input: 85.8K · Output: 9.1K · Cached: 105.2K |
Summary
Test plan
Made with Cursor