Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,11 @@ scaffold.

## Where things stand

Phase 3 lands `@pegma/flags-launchdarkly` and
`@pegma/flags-aws-appconfig` beside the Phase 1 packages and
`@pegma/flags-azure-appconfig` at `0.1.0` (unpublished). Remaining
vendor adapters (Cloudflare Flagship, flagd) are still later.
Phase 3 lands `@pegma/flags-launchdarkly`,
`@pegma/flags-aws-appconfig`, and `@pegma/flags-cloudflare-flagship`
beside the Phase 1 packages and `@pegma/flags-azure-appconfig` at
`0.1.0` (unpublished). Remaining vendor adapters (flagd) are still
later.

Siblings: [spine](https://github.com/pegma-dev/spine),
[health](https://github.com/pegma-dev/health),
Expand Down
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,17 @@ const detail = await client.evaluate("checkoutEnabled", {

## Packages

| Package | Responsibility |
| ------------------------------ | -------------------------------------------------- |
| `@pegma/flags-contracts` | Context, detail, reasons, provider port |
| `@pegma/flags-core` | Schema, client, cache, timeout, health helper |
| `@pegma/flags-static` | In-memory provider for tests and local development |
| `@pegma/flags-azure-appconfig` | Azure App Configuration provider |
| `@pegma/flags-aws-appconfig` | AWS AppConfig provider |
| `@pegma/flags-launchdarkly` | LaunchDarkly provider |

Remaining vendor adapters (Cloudflare Flagship, flagd) are named in
| Package | Responsibility |
| ---------------------------------- | -------------------------------------------------- |
| `@pegma/flags-contracts` | Context, detail, reasons, provider port |
| `@pegma/flags-core` | Schema, client, cache, timeout, health helper |
| `@pegma/flags-static` | In-memory provider for tests and local development |
| `@pegma/flags-azure-appconfig` | Azure App Configuration provider |
| `@pegma/flags-aws-appconfig` | AWS AppConfig provider |
| `@pegma/flags-cloudflare-flagship` | Cloudflare Flagship provider |
| `@pegma/flags-launchdarkly` | LaunchDarkly provider |

Remaining vendor adapters (flagd) are named in
[the plan](docs/PROJECT_PLAN.md) and stay later.

## Development
Expand Down
33 changes: 17 additions & 16 deletions docs/PROJECT_PLAN.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

## Status

**Stage:** Phase 3 LaunchDarkly and AWS AppConfig adapters implemented
in-tree; unpublished. Public API unstable (`0.x`).
**Stage:** Phase 3 LaunchDarkly, AWS AppConfig, and Cloudflare Flagship
adapters implemented in-tree; unpublished. Public API unstable (`0.x`).

**First named consumers:** RetireGolden.org (Azure App Configuration).
Remaining vendor adapters (Cloudflare Flagship, flagd) are still later.
Remaining vendor adapters (flagd) are still later.

**License:** MIT

Expand Down Expand Up @@ -104,7 +104,7 @@ package here would invite the wrong extractions.

- Flag authoring, admin UI, or a Pegma-owned flag store.
- A custom expression / rule language or AppConfig document evaluator.
- Cloudflare Flagship or flagd adapter packages in this phase.
- flagd adapter packages in this phase.
- Metrics, experiment assignment, or percentage math in the core.

## Package architecture
Expand All @@ -117,14 +117,14 @@ package here would invite the wrong extractions.
| `@pegma/flags-launchdarkly` | LaunchDarkly adapter | 3 |
| `@pegma/flags-azure-appconfig` | Azure App Configuration adapter | 2 |
| `@pegma/flags-aws-appconfig` | AWS AppConfig adapter | 3 |
| `@pegma/flags-cloudflare-flagship` | Cloudflare Flagship adapter | later |
| `@pegma/flags-cloudflare-flagship` | Cloudflare Flagship adapter | 3 |
| `@pegma/flags-flagd` | flagd / OpenFeature adapter | later |

Dependencies: `@pegma/spine` pinned exactly. `@pegma/flags-static`,
`@pegma/flags-azure-appconfig`, `@pegma/flags-aws-appconfig`, and
`@pegma/flags-launchdarkly` depend only on `@pegma/flags-contracts` (no
vendor SDK). Adapters pin contracts (and spine, if they need `Logger` /
`Clock`) exactly.
`@pegma/flags-azure-appconfig`, `@pegma/flags-aws-appconfig`,
`@pegma/flags-cloudflare-flagship`, and `@pegma/flags-launchdarkly`
depend only on `@pegma/flags-contracts` (no vendor SDK). Adapters pin
contracts (and spine, if they need `Logger` / `Clock`) exactly.

## Delivery phases

Expand All @@ -146,13 +146,14 @@ still carries those rules. Do not pre-build the other vendors.

### Phase 3 — remaining adapters

`@pegma/flags-launchdarkly` and `@pegma/flags-aws-appconfig` are
in-tree. Each translates an injected reader result and must pass the
Phase 1 conformance suite. Neither imports a vendor SDK nor evaluates
targeting rules. The AWS adapter maps an already-evaluated value or an
unconditional feature-flag setting and rejects an enabled document that
still carries multi-variant rules. Cloudflare Flagship and flagd remain
later, each as its own package.
`@pegma/flags-launchdarkly`, `@pegma/flags-aws-appconfig`, and
`@pegma/flags-cloudflare-flagship` are in-tree. Each translates an
injected reader result and must pass the Phase 1 conformance suite.
None import a vendor SDK or evaluate targeting rules. The AWS adapter
maps an already-evaluated value or an unconditional feature-flag
setting and rejects an enabled document that still carries
multi-variant rules. The Flagship adapter translates an already-evaluated
`*Details` result. flagd remains later as its own package.

### Phase 4 — publish

Expand Down
8 changes: 5 additions & 3 deletions docs/RELEASING.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Release operations

`@pegma/flags-contracts`, `@pegma/flags-core`, `@pegma/flags-static`,
`@pegma/flags-azure-appconfig`, `@pegma/flags-aws-appconfig`, and
`@pegma/flags-launchdarkly` publish
`@pegma/flags-azure-appconfig`, `@pegma/flags-aws-appconfig`,
`@pegma/flags-cloudflare-flagship`, and `@pegma/flags-launchdarkly`
publish
only from a stable GitHub release. Merging a pull request never
publishes, and the workflow has no manual-dispatch or npm-token
fallback. Phase 3 does not publish; this runbook exists so the first
Expand All @@ -14,7 +15,8 @@ Before the first release through this workflow:

- configure `@pegma/flags-contracts`, `@pegma/flags-core`,
`@pegma/flags-static`, `@pegma/flags-azure-appconfig`,
`@pegma/flags-aws-appconfig`, and `@pegma/flags-launchdarkly` on npm with
`@pegma/flags-aws-appconfig`, `@pegma/flags-cloudflare-flagship`,
and `@pegma/flags-launchdarkly` on npm with
the GitHub Actions trusted publisher
`pegma-dev/flags-core`, workflow `publish.yml`, environment
`npm-publish`, and allowed action `npm publish`;
Expand Down
21 changes: 21 additions & 0 deletions packages/flags-cloudflare-flagship/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026 RetireGolden, LLC

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
78 changes: 78 additions & 0 deletions packages/flags-cloudflare-flagship/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# `@pegma/flags-cloudflare-flagship`

Cloudflare Flagship `FlagProvider` for Pegma hosts.

> [!IMPORTANT]
> Pegma is in early `0.x` development. This package's public API is unstable.

The host constructs and injects a Flagship reader. This package never
imports the Flagship SDK, never owns a client singleton, and does not
evaluate targeting rules or percentage rollouts. It translates an already
evaluated `*Details` result into a `FlagResolution`.

```ts
import {
createCloudflareFlagshipFlagProvider,
flagshipEvaluationContext,
} from "@pegma/flags-cloudflare-flagship";
import { createFlagsClient, declareFlags, flag } from "@pegma/flags-core";
import type { Logger } from "@pegma/spine";

const schema = declareFlags({
checkoutEnabled: flag.boolean({ defaultValue: false }),
});

const logger: Logger = {
log(level, message, fields) {
console.log(level, message, fields);
},
};

const provider = createCloudflareFlagshipFlagProvider({
reader: {
async getDetails({ flagKey, context, defaultValue, kind }) {
const evaluationContext = flagshipEvaluationContext(context);
switch (kind) {
case "boolean":
return flags.getBooleanDetails(
flagKey,
defaultValue,
evaluationContext,
);
case "string":
return flags.getStringDetails(
flagKey,
defaultValue,
evaluationContext,
);
case "number":
return flags.getNumberDetails(
flagKey,
defaultValue,
evaluationContext,
);
case "json":
return flags.getObjectDetails(
flagKey,
defaultValue,
evaluationContext,
);
}
},
},
});

const client = createFlagsClient({ schema, logger, provider });
```

`flags` is the host's Workers binding or OpenFeature client. Import
`flagshipEvaluationContext` when the host wants the documented flat
context (`targetingKey` plus scalar attributes). Hosts that need `userId`
or non-scalar attributes can map `EvaluationContext` themselves inside
the reader.

A missing flag (`undefined` from the reader, or Flagship
`FLAG_NOT_FOUND`) is `DEFAULT_FALLBACK`. `DISABLED` is `DISABLED`.
`TARGETING_MATCH`, `SPLIT`, `DEFAULT`, and `CACHED` are
`TARGETING_MATCH` — Flagship already evaluated those rules. Other
Flagship `ERROR` codes propagate so the flags client can record `ERROR`.
39 changes: 39 additions & 0 deletions packages/flags-cloudflare-flagship/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "@pegma/flags-cloudflare-flagship",
"version": "0.1.0",
"description": "Cloudflare Flagship FlagProvider for Pegma hosts.",
"license": "MIT",
"type": "module",
"sideEffects": false,
"publishConfig": {
"access": "public"
},
"files": [
"dist/**/*.d.ts",
"dist/**/*.d.ts.map",
"dist/**/*.js",
"dist/**/*.js.map"
],
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js"
}
},
"engines": {
"node": ">=22"
},
"repository": {
"type": "git",
"url": "git+https://github.com/pegma-dev/flags-core.git",
"directory": "packages/flags-cloudflare-flagship"
},
"dependencies": {
"@pegma/flags-contracts": "0.1.0"
},
"scripts": {
"build": "tsc -p tsconfig.json",
"check": "tsc -p tsconfig.json --noEmit",
"prepack": "pnpm run build"
}
}
Loading
Loading