Repository navigation
Add Cloudflare Flagship flag provider - #6
Conversation
Land @pegma/flags-cloudflare-flagship as a thin FlagProvider that translates a host-injected Flagship *Details result. Targeting rules and percentage rollouts stay in Flagship; this package does not import the vendor SDK or own a client singleton. Co-authored-by: Fly Over Coder <FlyOverCoder@gmail.com>
|
You have reached your Codex usage limits for security reviews. Please try again later. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7e47d060c2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| for (const [key, value] of Object.entries(context.attributes ?? {})) { | ||
| if (isFlagshipAttributeValue(value)) { | ||
| attributes[key] = value; | ||
| } |
There was a problem hiding this comment.
Separate cache entries for targeting attributes
When evaluations reuse a targeting key but change an attribute such as plan, this helper sends the changed value to Flagship, but createFlagsClient builds its cache identity without context.attributes (packages/flags-core/src/client.ts:71-82). After the first evaluation, the second therefore returns the prior cached decision without invoking this reader, potentially mis-targeting users and contaminating experiment results until expiry. Include targeting-relevant context in the cache identity or require caching to be disabled when these attributes are used.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Intentional, not a Flagship adapter bug.
createFlagsClient keys the snapshot cache by flag + targeting key + tenant + environment on purpose. docs/PROJECT_PLAN.md (Cache key attributes) says: if a host needs attribute-sensitive caching, that is an adapter/host concern; do not hash arbitrary attribute maps in the core unless two consumers require it.
This provider still forwards context.attributes to Flagship on a real resolve. A second evaluate with the same targeting key and a different plan (etc.) will hit that cache until TTL expiry — that is the core client's contract, not a Flagship mis-target. Hosts that target on attributes should use a distinct targetingKey, a short/zero cache TTL, or invalidate after attribute changes.
Leaving this open for Nathan rather than changing the core cache identity in this PR.
Problem
Phase 3 already shipped the LaunchDarkly and AWS AppConfig adapters. Nathan authorized the remaining vendor adapters to be built now. This PR lands the next one —
@pegma/flags-cloudflare-flagship— and no others. flagd stays later.Behavior
createCloudflareFlagshipFlagProvidertakes a host-injected Flagship reader. The adapter translates an already-evaluated*Detailsresult into aFlagResolutionand does not import the Flagship SDK, own a client singleton, or evaluate targeting rules / percentage rollouts.Documented Flagship reason kinds only:
TARGETING_MATCH,SPLIT,DEFAULT, andCACHED→TARGETING_MATCHDISABLED→DISABLEDFLAG_NOT_FOUND→DEFAULT_FALLBACKERRORcodes and unknown reasons propagate so the flags client can recordERROROptional
flagshipEvaluationContextbuilds the documented flat context (targetingKeyplus scalar attributes). Hosts that needuserIdor non-scalar attributes mapEvaluationContextthemselves inside the reader.Tests
Date.now()on the production pathDocs
Plan status is Phase 3 LaunchDarkly, AWS AppConfig, and Cloudflare Flagship in-tree, unpublished. flagd stays later. MIT © RetireGolden, LLC.
Do not publish or tag from this PR.