Skip to content

About

Provider-neutral feature flag evaluation for Pegma hosts: typed schemas, evaluation context, and adapter conformance.

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Flags Core

CI License: MIT

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.

Why it exists

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.

Constraint that shapes everything

Read and evaluate; never author. No control-plane UI. No custom rule language. No global client. No silent fallback.

Owns

  • Typed flag schema (declareFlags / flag.boolean|string|number|json)
  • Standardized EvaluationContext and EvaluationDetail<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

Refuses

  • Flag authoring or a control-plane UI (@pegma/flags-storage is 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

Usage

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",
});

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-cloudflare-flagship Cloudflare Flagship provider
@pegma/flags-flagd flagd / OpenFeature provider
@pegma/flags-launchdarkly LaunchDarkly provider

Development

Requires Node.js 22 or 24.

corepack enable
pnpm install --frozen-lockfile
pnpm run format:check
pnpm run check
pnpm test

Maintainers should follow the release runbook. Releases publish only from protected signed tags through npm trusted publishing.

License

MIT © RetireGolden, LLC

About

Provider-neutral feature flag evaluation for Pegma hosts: typed schemas, evaluation context, and adapter conformance.

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages