Repository navigation
THRIFT-6153: Expand Ruby Compact varint write coverage - #4017
Merged
Merged
Conversation
Client: rb Assert literal wire bytes and one write per varint across signed width boundaries, sequence IDs, collection sizes, field IDs, and binary lengths. Co-Authored-By: OpenAI Codex (gpt-6.1-sol) <codex@openai.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The focused test-only changes have independently verified encoding fixtures and no identified blocking issues.
0 open findings
What changed in this PR
Expands Ruby Compact Protocol regression coverage for the varint batching introduced in #3741, without changing production code.
Changes:
- Adds 47 explicit signed-integer encoding fixtures covering width transitions, extrema, and mixed payload bits.
- Checks batching across integer writes, sequence IDs, collection sizes, field IDs, and binary lengths.
- Replaces the native-only regression test with coverage shared by native and pure Ruby implementations.
| File | Description |
|---|---|
| lib/rb/spec/compact_protocol_spec.rb | Expands expected-byte and transport-write assertions for Compact varints. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The batching regression test added in #3741 covers only maximum-width native i32 and i64 values. It misses shorter varints and the other callers of the same write helpers.
This follow-up uses explicit expected bytes for 47 signed integer values, covering zero, both signs at every width transition, signed extrema, and mixed payload bits. For example, 150 must produce
ac 02and -150 must produceab 02; the expectations do not implement zigzag or varint encoding. Shared native and pure Ruby coverage checks complete varints arrive in one transport write, including sequence IDs, collection sizes, non-delta field IDs, and binary lengths.Validation on Ruby 4.0.7, aarch64-linux: the focused spec passes all 51 examples in both modes; the full native suite passes 1,006 examples and the full pure Ruby suite passes 907. The gem build and RuboCop pass (147 files).
Controlled native mutations demonstrate the added coverage against master
5248fb28acda184580bd490cea8a1bea6933535a: splitting only two-byte varints into separate writes passes all 45 existing examples but fails six enhanced examples; encoding i64 zero as80 00passes the existing examples but fails one enhanced example. These were injected regressions; the implementation was restored, rebuilt, and retested successfully.[skip ci]anywhere in the commit message to free up build resources.