Skip to content

refactor(api): cleans up public API, soversion 6 - #545

Merged
hellobertrand merged 2 commits into
candidatefrom
refactor/api-1.0-surface
Oct 24, 2026
Merged

hellobertrand merged 2 commits into
candidatefrom
refactor/api-1.0-surface

Conversation

@hellobertrand

@hellobertrand hellobertrand commented Oct 23, 2026 •

Copy link
Copy Markdown
Owner

Prepares the library's public surface for a 1.0 release by removing inconsistencies that accumulated as the API grew.

Bound functions return size_t, not uint64_t

  • Changes zxc_compress_bound, zxc_compress_block_bound, zxc_decompress_block_bound, and zxc_estimate_cctx_size to return size_t instead of uint64_t, removing the awkward (size_t) casts (and the silent truncation risk) scattered across callers, bindings, and examples.
  • Fixes a latent overflow in zxc_compress_bound: very large inputs now return 0 (capacity would not fit a size_t) instead of wrapping silently.
  • Updates fuzzers, tests, and wrapper crates (Rust, Node.js, Python, Go) to match the new return type.

Renames dictionary API for consistency

  • zxc_train_dict -> zxc_dict_train_content
  • zxc_train_dict_huf -> zxc_dict_train_huf
  • zxc_dict_id -> zxc_dict_compute_id
  • zxc_dict_get_id -> zxc_dict_read_id
  • Groups all dictionary functions under the zxc_dict_* prefix, making their purpose (train/compute/read) clearer, and updates every caller, wrapper, doc, and golden/fuzz test accordingly.

Adds zxc_version_number()

  • Exposes the library's packed MAJOR*10000 + MINOR*100 + PATCH version at runtime, mirroring the new ZXC_VERSION_NUMBER header macro, so callers can detect a runtime library older than the one they compiled against.

Bumps SOVERSION to 6

  • Reflects the ABI break introduced by the renames and signature changes above. Updates CMake, Meson, and the ABI dump accordingly.

Summary by CodeRabbit

  • Breaking Changes
    • The shared-library ABI version is now 6. Applications using the C API must update to the renamed dictionary functions and the new size_t return types for buffer-size estimates.
  • New Features
    • Added a runtime version query so applications can compare the loaded library version with the version in their headers.
  • Improvements
    • Compression-bound calculations now return 0 when the required size cannot fit in size_t.

@hellobertrand hellobertrand added the enhancement New feature or request label Oct 23, 2026
@hellobertrand hellobertrand changed the title reafctor(api): cleans up public API, soversion 6 refactor(api): cleans up public API, soversion 6 Oct 23, 2026
@coderabbitai

coderabbitai Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 742efd21-ab5d-4a31-9f28-bb42a155c0e2
Commits

Reviewing files that changed from the base of the PR and between 019b6cc and 241b0e4.

Files selected for processing: 57
  • CMakeLists.txt
  • README.md
  • cmake/zxcWasm.cmake
  • conformance/gen_valid.c
  • conformance/invalid_cases.h
  • conformance/test_conformance.c
  • contrib/linux-kernel/selftest.c
  • contrib/windows-kernel/selftest.c
  • docs/API.md
  • docs/EXAMPLES.md
  • docs/FORMAT.md
  • docs/WHITEPAPER.md
  • docs/abi/libzxc-linux-x86_64.abi.xml
  • include/zxc_buffer.h
  • include/zxc_constants.h
  • include/zxc_dict.h
  • include/zxc_opts.h
  • meson.build
  • site/src/index.html
  • src/cli/main.c
  • src/lib/zxc_common.c
  • src/lib/zxc_compress.c
  • src/lib/zxc_dict.c
  • src/lib/zxc_dispatch.c
  • src/lib/zxc_driver.c
  • src/lib/zxc_pstream.c
  • src/lib/zxc_seekable.c
  • tests/format/gen_golden.c
  • tests/format/golden_cases.h
  • tests/format/test_golden.c
  • tests/fuzz_block.c
  • tests/fuzz_dict.c
  • tests/fuzz_inplace.c
  • tests/fuzz_pstream.c
  • tests/fuzz_roundtrip.c
  • tests/fuzz_seekable.c
  • tests/test_block_api.c
  • tests/test_buffer_api.c
  • tests/test_container.c
  • tests/test_context_api.c
  • tests/test_dict.c
  • tests/test_encoder_pin.c
  • tests/test_format.c
  • tests/test_misc.c
  • tests/test_seekable.c
  • tests/test_seekable_mt.c
  • tests/test_static_ctx.c
  • tests/test_stream_api.c
  • wrappers/go/zxc_dict.go
  • wrappers/nodejs/src/zxc_addon.cc
  • wrappers/python/src/zxc/_zxc.c
  • wrappers/rust/zxc-sys/src/lib.rs
  • wrappers/rust/zxc/README.md
  • wrappers/rust/zxc/src/ctx.rs
  • wrappers/rust/zxc/src/dict.rs
  • wrappers/rust/zxc/src/oneshot.rs
  • wrappers/wasm/zxc_wasm.js

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

Walkthrough

The library updates its ABI version, changes size-bound APIs to return size_t, adds runtime version reporting, and renames dictionary APIs. The changes also update internal callers, language bindings, tests, examples, and documentation.

Changes: Public API and ABI updates

Layer / File(s) Summary
Size bounds and runtime version
src/lib/zxc_common.c, src/lib/zxc_pstream.c, include/zxc_buffer.h, include/zxc_constants.h, wrappers/rust/*, tests/*, CMakeLists.txt, meson.build, docs/API.md
Bound and context-size APIs now return size_t. zxc_compress_bound returns 0 when the required size does not fit. The library adds zxc_version_number() and ZXC_VERSION_NUMBER, and the shared-library SOVERSION changes to 6. Tests check near-SIZE_MAX bounds and compare runtime and header version numbers.
Dictionary API rename and integration
include/zxc_dict.h, src/lib/zxc_dict.c, src/lib/zxc_dispatch.c, src/lib/zxc_driver.c, src/lib/zxc_seekable.c, src/cli/main.c, wrappers/*, cmake/zxcWasm.cmake, tests/*, docs/*
Dictionary ID and training APIs use the names zxc_dict_compute_id, zxc_dict_read_id, zxc_dict_train_content, and zxc_dict_train_huf. The library and its callers, bindings, documentation, and tests use the updated names. Dictionary ID and training behavior remains unchanged in the described changes.

Priority: Normal

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Refactor

Merge Risk: Minimal · up to 241b0

The reviewed API and ABI changes have no identified merge-blocking issue. Merge after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 62.05% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 166 functions across 46 files. (10 skippe… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title accurately summarizes the primary changes: public API refactoring and the SOVERSION 6 ABI update.
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 62.05% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 166 functions across 46 files. (10 skipped: 10 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

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
  • 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 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.47368% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/lib/zxc_pstream.c 42.85% 4 Missing ⚠️

📢 Thoughts on this report? Let us know!

Align dictionary API naming (`zxc_dict_train_content`, `zxc_dict_train_huf`, `zxc_dict_compute_id`, `zxc_dict_read_id`), switch bound/size functions to `size_t`, and add `zxc_version_number()`.
Breaks ABI for the 1.0 surface cleanup.

Signed-off-by: Bertrand Lebonnois <[email protected]>
Drop now-redundant (size_t) casts on zxc_compress_bound/zxc_compress_block_bound call sites across docs, tests, fuzzers, and wrappers following their size_t signature
change. Tighten zxc_compress_bound's overflow check to report 0 only when the result truly can't fit a size_t, and add regression tests for near-SIZE_MAX inputs. Also
export zxc_version_number in the Wasm build and include zxc_constants.h from zxc_buffer.h for ZXC_VERSION_NUMBER.

Signed-off-by: Bertrand Lebonnois <[email protected]>
@hellobertrand
hellobertrand force-pushed the refactor/api-1.0-surface branch from 614d47d to 241b0e4 Compare October 23, 2026 20:06
@hellobertrand

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@hellobertrand
hellobertrand merged commit 93ec7ea into candidate Oct 24, 2026
171 of 172 checks passed
@hellobertrand
hellobertrand deleted the refactor/api-1.0-surface branch October 24, 2026 04:47
hellobertrand added a commit that referenced this pull request Oct 25, 2026
* refactor: rename dict API fns, bump SOVERSION to 6

Align dictionary API naming (`zxc_dict_train_content`, `zxc_dict_train_huf`, `zxc_dict_compute_id`, `zxc_dict_read_id`), switch bound/size functions to `size_t`, and add `zxc_version_number()`.
Breaks ABI for the 1.0 surface cleanup.

Signed-off-by: Bertrand Lebonnois <[email protected]>

* refactor: clean up size_t bound usage, fix overflow

Drop now-redundant (size_t) casts on zxc_compress_bound/zxc_compress_block_bound call sites across docs, tests, fuzzers, and wrappers following their size_t signature
change. Tighten zxc_compress_bound's overflow check to report 0 only when the result truly can't fit a size_t, and add regression tests for near-SIZE_MAX inputs. Also
export zxc_version_number in the Wasm build and include zxc_constants.h from zxc_buffer.h for ZXC_VERSION_NUMBER.

Signed-off-by: Bertrand Lebonnois <[email protected]>

---------

Signed-off-by: Bertrand Lebonnois <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant