Repository navigation
fix: fetch flags only when storage holds another identity's flags - #95
Conversation
41e8c0a to
afa7586
Compare
|
@themis-blindfold review |
d3363ca to
d954910
Compare
⚖️ Themis review: 🟠 Fix before mergeThe identity marker fixes the ordinary identity-switch path, but two cache-validity gaps remain: trait-bearing experiment reads can ignore the traits, and reinitialising storage can retain a marker for flags that were removed. CI passed: Dart Publish Package Test, Dart Analyze, and Flutter Test. Flutter is unavailable in this environment, so I could not rerun them locally.
🟠 Majors
📝 Walkthrough
🧪 How to verify
Product take: This is a solid request-reduction improvement, but stale evaluation is especially costly for targeting and experiment exposure data. Fixing the two invalidation cases keeps the optimisation transparent to users. 🧭 Assumptions & unverified claimsNo unverified assumptions or claims. The cache now knows its owner; it just needs to notice when the furniture moves. · reviewed at afa7586 |
d954910 to
bfbc092
Compare
|
@themis-blindfold review |
⚖️ Themis review: 🟠 Fix before mergeThe identity-cache optimisation tracks only an identifier, and some storage-reset paths never invalidate that marker. Fix these cache-owner transitions before merging. Dart Analyze completed successfully; Flutter Test was still running.
🟠 Majors
⚖️ Acknowledged
📝 Walkthrough
🧪 How to verify
Product take: Avoiding redundant identity calls is a solid improvement. Predicted: a stale evaluation context could serve and record the wrong experiment variant, making these fixes important for identity-targeted flags. 🧭 Assumptions & unverified claimsNo unverified assumptions or claims. A good cache needs to remember when it has forgotten · reviewed at bfbc092 |
bfbc092 to
8afcac2
Compare
|
@themis-blindfold review |
⚖️ Themis review: ✅ Ship itThe identity marker now tracks the stored assignment through environment refreshes, resets, clears, and transient evaluations. The completed Flutter Test and Dart Analyze checks passed.
⚖️ Acknowledged
📝 Walkthrough
🧪 How to verify
Product take: A solid correctness and efficiency improvement for identity-based flag and experiment reads, avoiding redundant evaluations without reusing another identity's assignment. 🧭 Assumptions & unverified claims
The flag cache now knows whose coat it is wearing · reviewed at 8afcac2 |
Thanks for submitting a PR! Please check the boxes below:
docs/if required so people know about the feature.Changes
Follow-up to #94.
The client now remembers which identity the stored flags were fetched for (
nullfor environment flags,reset()and a fresh process). Lookups that take auserfetch from the API only when that identity differs from the stored one, and read storage otherwise. An explicitreloadstill wins.getExperimentFlag(user:)no longer hits/identitieson every call; same identity as the last fetch is served from storage, a different identity is fetched. Exposures keep the guarantee from feat: surface experiment metadata on flags and add event tracking #94: never attributed against another identity's assignment.hasFeatureFlag,isFeatureFlagEnabledandgetFeatureFlagValueshare the same rule through_getFlagByName. Previously auserdifferent from the last fetch silently returned the previous identity's flags from storage; now it fetches once. Same identity or nouser: unchanged, no request.Behaviour change to the three existing methods only on the path that returned the wrong identity's flags. They also no longer forget
cachedUserwhen called without auser, andgetExperimentFlagfetches whenevertraitsare supplied so they reach the server.How did you test this code?
flutter analyzeclean,flutter test169 passing. New cases: same identity makes no request; environment flags overwriting storage trigger a fetch for the cached identity;hasFeatureFlagwith a switched identity fetches once and then reads storage; traits force a fetch; a read withoutuserkeeps the identity;clearStoreandinitStore(clear: true)drop the marker; a transient evaluation is never reused as a baseline.