Skip to content

Add Cloudflare Flagship flag provider - #6

Merged
FlyOverCoderKY merged 1 commit into
mainfrom
cursor/flags-cloudflare-flagship-d3f3
Aug 15, 2026
Merged

FlyOverCoderKY merged 1 commit into
mainfrom
cursor/flags-cloudflare-flagship-d3f3

Conversation

@FlyOverCoderKY

Copy link
Copy Markdown
Contributor

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

createCloudflareFlagshipFlagProvider takes a host-injected Flagship reader. The adapter translates an already-evaluated *Details result into a FlagResolution and 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, and CACHED → TARGETING_MATCH
  • DISABLED → DISABLED
  • missing reader result, or FLAG_NOT_FOUND → DEFAULT_FALLBACK
  • other ERROR codes and unknown reasons propagate so the flags client can record ERROR

Optional flagshipEvaluationContext builds the documented flat context (targetingKey plus scalar attributes). Hosts that need userId or non-scalar attributes map EvaluationContext themselves inside the reader.

Tests

  • Unit tests for reason translation, injected key mapping, unknown reasons, reader errors, and no Flagship SDK / Date.now() on the production path
  • Phase 1 conformance suite against a memory reader
  • Release inventory includes the new public package

Docs

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.

Open in Web Open in Cursor 

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>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 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".

Comment on lines +104 to +107
for (const [key, value] of Object.entries(context.attributes ?? {})) {
if (isFlagshipAttributeValue(value)) {
attributes[key] = value;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

@FlyOverCoderKY
FlyOverCoderKY merged commit 682b979 into main Aug 15, 2026
5 checks passed
@FlyOverCoderKY
FlyOverCoderKY deleted the cursor/flags-cloudflare-flagship-d3f3 branch August 15, 2026 21:45
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