Skip to content

feat(api): clamp negative compression levels to FASTEST - #541

Merged
hellobertrand merged 1 commit into
mainfrom
feat/reserve-negative-levels
Oct 21, 2026
Merged

hellobertrand merged 1 commit into
mainfrom
feat/reserve-negative-levels

Conversation

@hellobertrand

@hellobertrand hellobertrand commented Oct 21, 2026 •

Copy link
Copy Markdown
Owner

Update compression level logic to clamp negative values to ZXC_LEVEL_FASTEST instead of treating them as ZXC_LEVEL_DEFAULT. This reserves negative values for potential future use while ensuring consistent behavior across all APIs and language bindings. Updates documentation and tests to reflect this change in policy.

Summary by CodeRabbit

  • Documentation

    • Clarified compression-level behavior across the API and Python interface.
    • Level 0 selects the default; other values are clamped to the supported range of 1–7.
  • Bug Fixes

    • Negative compression levels now correctly use the fastest compression level.
    • Values above the maximum continue to use the highest supported level.

Update compression level logic to clamp negative values to `ZXC_LEVEL_FASTEST` instead of treating them as `ZXC_LEVEL_DEFAULT`. This reserves negative values for potential future use while ensuring consistent behavior across all APIs and language bindings. Updates documentation and tests to reflect this change in policy.

Signed-off-by: Bertrand Lebonnois <5901952+hellobertrand@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5d59d0c7-ee22-4c97-8136-d07767dd896f
📥 Commits

Reviewing files that changed from the base of the PR and between 56ab5e3 and 3566ba4.

📒 Files selected for processing: 6
  • docs/API.md
  • include/zxc_buffer.h
  • src/lib/zxc_internal.h
  • tests/test_context_api.c
  • tests/test_stream_api.c
  • wrappers/python/src/zxc/__init__.py

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.

📝 Walkthrough

Compression level 0 selects the default. Other levels clamp to 1–7. Tests cover negative and oversized levels in one-shot, context, and streaming compression.

Changes: Compression Level Handling

Layer / File(s) Summary
Level selection and clamping
include/zxc_buffer.h, src/lib/zxc_internal.h, tests/test_context_api.c, tests/test_stream_api.c, docs/API.md, wrappers/python/src/zxc/__init__.py
Only level 0 selects the default. Other levels clamp to 1–7. Tests compare negative and oversized levels with the supported boundary levels. Documentation describes the updated behavior.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Feature

Merge Risk: ⚪ Minimal · up to 3566b

The static-workspace exception is already documented; no identified issue prevents merging after normal checks.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: negative compression levels now clamp to FASTEST. It matches the documented behavior, implementation changes, and test updates.
Docstring Coverage Passed Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 5 files. (1 skipped: 1 u…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 5 files. (1 skipped: 1 unsupported.)

✨ Finishing Touches: 💡 1
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@codecov

codecov Bot commented Oct 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@hellobertrand
hellobertrand merged commit 3fdd71c into main Oct 21, 2026
161 of 162 checks passed
@hellobertrand
hellobertrand deleted the feat/reserve-negative-levels branch October 21, 2026 18:26
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