Skip to content

test(eval): add compression ratio gate - #135

Merged
KooshaPari merged 1 commit into
mainfrom
feat/sl-w12-c08
Jul 13, 2026
Merged

test(eval): add compression ratio gate#135
KooshaPari merged 1 commit into
mainfrom
feat/sl-w12-c08

Conversation

@KooshaPari

Copy link
Copy Markdown
Owner

Summary

  • Add a feature-gated zstd fixture compression ratio test with a 65% threshold.
  • Document the compression method, threshold policy, and rough token-burn proxy.
  • Add a SHA-pinned CI workflow that runs the focused compression evaluation gate.

Test plan

  • cargo fmt --all --check
  • cargo test -p session-ledger --features compress --test compression_eval --locked

Made with Cursor

Co-authored-by: Cursor <cursoragent@cursor.com>
@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@KooshaPari, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 17 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: ce68f858-7399-41e1-a787-c5d8a05205d1

📥 Commits

Reviewing files that changed from the base of the PR and between 002fe51 and cada6c9.

📒 Files selected for processing (3)
  • .github/workflows/eval-compression.yml
  • docs/ops/eval-compression.md
  • tests/compression_eval.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/sl-w12-c08
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch feat/sl-w12-c08

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread tests/compression_eval.rs

assert_eq!(decoded, FIXTURE, "zstd must preserve fixture bytes");

let ratio_bps = compressed.len() * 10_000 / FIXTURE.len();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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;

@KooshaPari
KooshaPari merged commit 36b65c8 into main Jul 13, 2026
22 of 23 checks passed
@KooshaPari
KooshaPari deleted the feat/sl-w12-c08 branch July 13, 2026 21:26
KooshaPari added a commit that referenced this pull request Jul 13, 2026
Re-score C05/C07/C08/C10 on #135-#138. Overall 294/402 (73% C) ->
302/402 (75% B); PLAN-W8-B threshold met.
Comment thread tests/compression_eval.rs

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;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@kilo-code-bot

kilo-code-bot Bot commented Jul 13, 2026

Copy link
Copy Markdown

Code Review Summary

Status: 1 Issue Found | Recommendation: Merge with notes (non-blocking)

Overview

Severity Count
CRITICAL 0
WARNING 0
SUGGESTION 1
Issue Details (click to expand)

SUGGESTION

File Line Issue
tests/compression_eval.rs 8 Hardcoded MAX_RATIO_BPS threshold is sensitive to zstd library version drift; an unrelated zstd/zstd-sys dependency bump can shift the ratio across the 6500 boundary and break CI.
Files Reviewed (3 files)
  • .github/workflows/eval-compression.yml
  • docs/ops/eval-compression.md
  • tests/compression_eval.rs

Note: An existing active review comment on tests/compression_eval.rs:19 (32-bit usize overflow / division-by-zero on empty fixture) is already tracked and was not duplicated here.

Fix these issues in Kilo Cloud


Reviewed by hy3:free · Input: 85.8K · Output: 9.1K · Cached: 105.2K

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant