Skip to content

refactor(remote-config): RC Container Format v1 support#3534

Merged
tonidero merged 7 commits into
mainfrom
poc/rc-container-format-deserializer
Jun 18, 2026
Merged

refactor(remote-config): RC Container Format v1 support#3534
tonidero merged 7 commits into
mainfrom
poc/rc-container-format-deserializer

Conversation

@tonidero

@tonidero tonidero commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

This adds support for a new binary format that will be used for remote config support from our SDKs. This is currently unused and untested against the backend, but will be in later PRs of the stack


Note

Low Risk
New internal networking types with no production call sites yet; risk is limited to future integration and binary parsing edge cases, which are heavily tested.

Overview
Introduces an internal parser for RC Container Format v1 binary payloads, intended for upcoming remote config delivery. RCContainer.parse reads the RC header, treats element 0 as config, and exposes further blobs as zero-copy RCElement views with optional SHA-256 checksum verification and lazy lookup by URL-safe base64 refs (matching backend blob_ref encoding).

Invalid or truncated wire data surfaces as RCContainerFormatException. Parsing is careful about 8-byte alignment, little-endian sizes, and not mutating the caller’s ByteBuffer position.

Coverage includes in-memory unit tests plus frozen .bin fixtures so accidental v1 wire-format regressions are caught before integration with the backend.

Reviewed by Cursor Bugbot for commit a53127d. Bugbot is set up for automated code reviews on this repo. Configure here.

@codecov

codecov Bot commented Jun 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.44444% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.46%. Comparing base (00001b7) to head (a53127d).

Files with missing lines Patch % Lines
...enuecat/purchases/common/networking/RCContainer.kt 92.85% 1 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3534      +/-   ##
==========================================
+ Coverage   80.40%   80.46%   +0.06%     
==========================================
  Files         379      382       +3     
  Lines       15522    15594      +72     
  Branches     2157     2166       +9     
==========================================
+ Hits        12480    12548      +68     
- Misses       2171     2172       +1     
- Partials      871      874       +3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@emerge-tools

emerge-tools Bot commented Jun 16, 2026

Copy link
Copy Markdown

📸 Snapshot Test

593 unchanged

Name Added Removed Modified Renamed Unchanged Errored Approval
TestPurchasesUIAndroidCompatibility
com.revenuecat.testpurchasesuiandroidcompatibility
0 0 0 0 335 0 N/A
TestPurchasesUIAndroidCompatibility Paparazzi
com.revenuecat.testpurchasesuiandroidcompatibility.paparazzi
0 0 0 0 258 0 N/A

🛸 Powered by Emerge Tools

@tonidero tonidero marked this pull request as ready for review June 16, 2026 15:06
@tonidero tonidero requested a review from a team as a code owner June 16, 2026 15:06

@ajpallares ajpallares left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Took a look, and have some comments. Mostly documentation nits and one suggestion about a missing test. But I think it looks good! Good job!

Comment thread purchases/src/main/kotlin/com/revenuecat/purchases/common/networking/RCElement.kt Outdated

@rickvdl rickvdl left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Great work!! 💪 Couple of questions

Comment thread purchases/src/main/kotlin/com/revenuecat/purchases/common/networking/RCElement.kt Outdated

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 44386ff. Configure here.

val padding = alignment - remainder
if (padding > remaining()) {
// Trailing alignment padding past the end of the buffer; nothing more to read.
position(limit())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Missing padding bytes not rejected

Medium Severity

When an element’s required alignment padding exceeds the bytes left before the buffer limit, alignTo sets the position to the limit and returns instead of throwing RCContainerFormatException. A truncated payload can therefore parse successfully even though mandatory padding is missing, which weakens the format’s truncation checks elsewhere.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 44386ff. Configure here.

tonidero and others added 6 commits June 17, 2026 15:01
Standalone, pure-Kotlin deserializer evaluating a custom binary container
format for potential future use in network requests. Provides zero-copy
field access via read-only ByteBuffer views that share the backing buffer;
element bytes are never copied during parsing.

- RCContainer: parses header (magic "RC", version, flags, big-endian
  config_size) then elements until EOF, with 8-byte alignment padding and
  full bounds checking.
- RCElement: 32-byte checksum view + zero-copy data view; lazy opt-in
  SHA-256 verification via isChecksumValid().
- RCContainerFormatException: extends existing SerializationException.
- RCContainerTest: 16 tests covering parsing, padding, big-endian sizes,
  checksum, zero-copy semantics, and error paths.

Not wired into HTTPClient/Backend; evaluation only. All internal, no
public API change.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…pri #21221)

Sync the deserializer with khepri PR #21221:
- CHECKSUM_SIZE 32 -> 24 bytes (SHA-256 truncated to 192 bits); element
  header shrinks 40 -> 32 bytes accordingly.
- isChecksumValid() truncates the computed SHA-256 to the stored checksum
  length before comparing.
- Content-addressed elements map keyed by URL-safe base64 (no padding),
  matching the backend's ref encoding in the config JSON / URLs.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: Antonio Pallares <ajpallares@users.noreply.github.com>
Co-authored-by: Antonio Pallares <ajpallares@users.noreply.github.com>
@tonidero tonidero force-pushed the poc/rc-container-format-deserializer branch from 9cd9f13 to 4288db2 Compare June 17, 2026 13:05
@tonidero tonidero added this pull request to the merge queue Jun 18, 2026
Merged via the queue into main with commit 4ade8e4 Jun 18, 2026
38 checks passed
@tonidero tonidero deleted the poc/rc-container-format-deserializer branch June 18, 2026 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants