Skip to content

feat: Add the FDv2 cache initializer and per-context freshness to the client - #613

Merged
beekld merged 5 commits into
bklimt/SDK-3032/client-fdv2-orchestratorfrom
bklimt/SDK-3033/client-fdv2-cache-initializer
Oct 5, 2026
Merged

beekld merged 5 commits into
bklimt/SDK-3032/client-fdv2-orchestratorfrom
bklimt/SDK-3033/client-fdv2-cache-initializer

Conversation

@beekld

@beekld beekld commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds an FDv2 cache initializer so the client can begin evaluating from its local per-context cache before the network responds, and tracks how fresh each context's cached data is.

  • A cache hit produces a full basis with no selector. The cached flags are applied so evaluation can begin, but the missing selector keeps them from becoming a delta basis, so initialization continues to a network source for verified data and a real selector. A miss produces a "none" result, and the next initializer runs.
  • Cache-sourced data is marked so it is not written back to the cache it came from.
  • The client records a freshness timestamp per context, keyed by a hash of the full context, updated when a payload arrives or a "none" intent confirms the current data, and persisted alongside the cached flags.

Design note: this client persists a per-context freshness timestamp keyed by a hash of the full context, matching Android. Flutter's FDv2 freshness is different -- an in-memory, per-synchronizer timestamp that is neither persisted nor keyed by context.

Internal only. Not user-selectable yet.


Note

Overview
Adds an FDv2 cache initializer so startup can apply locally persisted flags before the network responds. A cache hit yields a full changeset without a selector (so deltas cannot treat unverified cache as a basis); a miss yields a none intent and the initializer chain continues. Cache-sourced applies are marked from_cache and are not written back or treated as service-confirmed.

Flag persistence now exposes ReadCached / ReadFreshness, records per-context freshness (hashed full context attributes) when the service sends a payload or a none confirmation, prunes freshness with LRU limits, and refuses to report freshness after flag data is evicted or overwritten under the same canonical key. FlagManager::Cache() exposes the persistence layer for the initializer.

Tests cover cache hit/miss behavior, freshness semantics, and eviction edge cases.

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

@beekld
beekld force-pushed the bklimt/SDK-3033/client-fdv2-cache-initializer branch from e05b5ed to db55b09 Compare September 15, 2026 00:32
@beekld
beekld force-pushed the bklimt/SDK-3033/client-fdv2-cache-initializer branch from db55b09 to d2cdc4e Compare September 16, 2026 20:19
@beekld
beekld force-pushed the bklimt/SDK-3033/client-fdv2-cache-initializer branch 2 times, most recently from bd219dc to e78670c Compare September 16, 2026 21:25
@beekld
beekld force-pushed the bklimt/SDK-3033/client-fdv2-cache-initializer branch from e78670c to 20d58d0 Compare September 17, 2026 00:03
@beekld
beekld force-pushed the bklimt/SDK-3033/client-fdv2-cache-initializer branch 2 times, most recently from 6146cea to 44884f9 Compare September 17, 2026 23:33
@beekld
beekld force-pushed the bklimt/SDK-3033/client-fdv2-cache-initializer branch from 44884f9 to d675917 Compare September 24, 2026 21:15
@beekld
beekld force-pushed the bklimt/SDK-3033/client-fdv2-cache-initializer branch from d675917 to eb8ad4a Compare September 24, 2026 21:30
@beekld
beekld marked this pull request as ready for review September 25, 2026 16:59
@beekld
beekld requested a review from a team as a code owner September 25, 2026 16:59
@beekld
beekld added this pull request to stack #608 September 25, 2026 17:01

@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 using default effort 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 fc7d735. Configure here.

Comment thread libs/client-sdk/src/flag_manager/flag_persistence.cpp
@beekld
beekld force-pushed the bklimt/SDK-3033/client-fdv2-cache-initializer branch from fc7d735 to 60b04ea Compare September 26, 2026 05:54

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

Not directly related to this PR, but it seems like ValueAsOpt may need some hardening.

@beekld
beekld force-pushed the bklimt/SDK-3033/client-fdv2-cache-initializer branch from 60b04ea to a1f1bec Compare October 2, 2026 23:36
@beekld
beekld removed this pull request from stack #608 October 3, 2026 01:24
@beekld
beekld force-pushed the bklimt/SDK-3033/client-fdv2-cache-initializer branch from 14273b6 to f45dfd4 Compare October 5, 2026 18:00
@beekld
beekld added this pull request to stack #627 October 5, 2026 18:00
@beekld
beekld removed this pull request from stack #627 October 5, 2026 18:05
@beekld
beekld added this pull request to stack #628 October 5, 2026 18:10
@beekld
beekld removed this pull request from stack #628 October 5, 2026 19:18
@beekld
beekld added this pull request to stack #629 October 5, 2026 19:24
@beekld

beekld commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

Not directly related to this PR, but it seems like ValueAsOpt may need some hardening.

I filed a task to follow up on this.

@beekld
beekld merged commit a33e3f0 into main Oct 5, 2026
199 of 221 checks passed
@beekld
beekld deleted the bklimt/SDK-3033/client-fdv2-cache-initializer branch October 5, 2026 23:25
@github-actions github-actions Bot mentioned this pull request Oct 5, 2026
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.

2 participants