Provider-neutral feature flag evaluation for Pegma hosts: typed schemas, evaluation context, and adapter conformance.
Important
Pegma is in early 0.x development. The eight public packages are on npm
at 0.1.1. No public API is stable.
Hosts need one evaluation client that every flag provider can satisfy: a strongly typed schema, a standard context, a uniform detail record with an honest reason, and a cache that never blocks a request on the network. This repository owns that contract. The host owns wiring. The provider owns targeting rules.
Read and evaluate; never author. No control-plane UI. No custom rule language. No global client. No silent fallback.
- Typed flag schema (
declareFlags/flag.boolean|string|number|json) - Standardized
EvaluationContextandEvaluationDetail<T> - Local snapshot / TTL cache with stale-while-revalidate
- A conformance suite every adapter must pass
- Ports for Spine
Logger,Clock, and a health probe helper
- Flag authoring or a control-plane UI (
@pegma/flags-storageis not in scope) - A custom rule or expression language
- Global singletons or ambient request context
- Blocking synchronous network on the request path
- Returning a default without a log line and an evaluation reason
import { declareFlags, flag, createFlagsClient } from "@pegma/flags-core";
import { createStaticFlagProvider } from "@pegma/flags-static";
import type { Logger } from "@pegma/spine";
const schema = declareFlags({
checkoutEnabled: flag.boolean({ defaultValue: false }),
theme: flag.string({ defaultValue: "light" }),
maxItems: flag.number({ defaultValue: 10 }),
payload: flag.json({ defaultValue: { experiment: "off" } }),
});
const logger: Logger = {
log(level, message, fields) {
console.log(level, message, fields);
},
};
const client = createFlagsClient({
schema,
logger,
provider: createStaticFlagProvider({
flags: { checkoutEnabled: true, theme: "dark" },
}),
});
const detail = await client.evaluate("checkoutEnabled", {
targetingKey: "user-1",
});| 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-flagd |
flagd / OpenFeature provider |
@pegma/flags-launchdarkly |
LaunchDarkly provider |
Requires Node.js 22 or 24.
corepack enable
pnpm install --frozen-lockfile
pnpm run format:check
pnpm run check
pnpm testMaintainers should follow the release runbook. Releases publish only from protected signed tags through npm trusted publishing.
MIT © RetireGolden, LLC