Skip to content

Make LargeItemCache writes atomic#7081

Merged
rickvdl merged 1 commit into
mainfrom
rickvdl/remote-config-atomic-cache-writes
Jun 25, 2026
Merged

Make LargeItemCache writes atomic#7081
rickvdl merged 1 commit into
mainfrom
rickvdl/remote-config-atomic-cache-writes

Conversation

@rickvdl

@rickvdl rickvdl commented Jun 25, 2026

Copy link
Copy Markdown
Member

Additional context can be found in this comment. But basically we wanted to have the additional safety of atomic writes when integrating the LargeItemCache for the RemoteConfiguration manifest cache.

Since LargeItemCache is already used throughout the SDK we wanted to extract this into it's own (tiny) PR for proper review.


Note

Medium Risk
Changes signature verification and signed-payload derivation for remote config (security-sensitive), though behavior is heavily covered by tests; atomic file writes are a low-risk infrastructure tweak.

Overview
Adds remote config persistence via RemoteConfigDiskCache (remote_config.json manifest/topic blob refs) on top of SynchronizedLargeItemCache, with read/write error logging.

Enables response signature verification for .remoteConfig (and keeps it for reward verification): a pluggable ResponseSignatureContextProvider lets verification use endpoint-specific signed bytes and request-body inputs. Remote config signs the first RC Container element’s stored checksum (not the full body), omits the POST body from signature params, and treats 204 as a nil response message. RCContainer.ElementParser supports parsing only that first element before full decode. Failures to build the signed payload are logged and counted as verification failures.

getRemoteConfig now returns RemoteConfigFetchResult (optional RCContainer + VerificationResult) instead of a bare container. Shared FileManager.saveData sync writes use .atomic for safer overwrites (relevant to manifest cache).

Tests cover disk cache, atomic overwrite, HTTP path flags, backend fetch results, and extensive remote-config signature scenarios (including 204 and enforced mode).

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

@rickvdl rickvdl force-pushed the rickvdl/remote-config-manifest-cache branch from d9de11a to 8950dab Compare June 25, 2026 13:36
@rickvdl rickvdl force-pushed the rickvdl/remote-config-atomic-cache-writes branch 2 times, most recently from f6a5f8a to ba68e41 Compare June 25, 2026 13:40
@rickvdl rickvdl marked this pull request as ready for review June 25, 2026 13:43
@rickvdl rickvdl requested a review from a team as a code owner June 25, 2026 13:43
@rickvdl rickvdl force-pushed the rickvdl/remote-config-atomic-cache-writes branch 2 times, most recently from ab9985b to a45b5e7 Compare June 25, 2026 13:56
@ajpallares

Copy link
Copy Markdown
Member

Maybe it's easier if this PR goes into main @rickvdl

@rickvdl rickvdl force-pushed the rickvdl/remote-config-manifest-cache branch from 0e55d5e to caff100 Compare June 25, 2026 14:18
@rickvdl

rickvdl commented Jun 25, 2026

Copy link
Copy Markdown
Member Author

Maybe it's easier if this PR goes into main @rickvdl

That's indeed easier, will update!

@rickvdl rickvdl changed the base branch from rickvdl/remote-config-manifest-cache to main June 25, 2026 14:30
@rickvdl rickvdl force-pushed the rickvdl/remote-config-atomic-cache-writes branch from a45b5e7 to ad2dff3 Compare June 25, 2026 14:30
@rickvdl rickvdl marked this pull request as draft June 25, 2026 14:31

@cursor cursor 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.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

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 ad2dff3. Configure here.

Comment thread Tests/UnitTests/Networking/SignatureVerificationHTTPClientTests.swift Outdated
@rickvdl rickvdl force-pushed the rickvdl/remote-config-atomic-cache-writes branch from ad2dff3 to a8ed23f Compare June 25, 2026 14:34
@rickvdl rickvdl changed the title refactor(remote-config): make shared cache writes atomic Make LargeItemCache writes atomic Jun 25, 2026
@rickvdl

rickvdl commented Jun 25, 2026

Copy link
Copy Markdown
Member Author

@RCGitBot please test

@rickvdl rickvdl marked this pull request as ready for review June 25, 2026 14:36
@rickvdl rickvdl merged commit 3e26c50 into main Jun 25, 2026
42 of 43 checks passed
@rickvdl rickvdl deleted the rickvdl/remote-config-atomic-cache-writes branch June 25, 2026 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants