-
Notifications
You must be signed in to change notification settings - Fork 0
Feature Flags
Permanent switches, and temporary ones that cannot be forgotten. Package @ultimat3/flags
(tier 1) — the full reference is
packages/flags/README.md.
N flags are 2^N states nothing tested. This package takes that trade only on terms that bound the
exponent: every flag declares one of two kinds, and a temporary flag cannot be declared without an
expiry.
| Kind | Meaning | Lifecycle |
|---|---|---|
permanent |
a real product or ops switch — a plan capability, a kill switch | none |
temporary |
scaffolding around an in-progress change |
expiresAt and owner are required by the type; past the expiry every evaluation reports X_FLAG_EXPIRED to the app's error monitor |
defineFlag() is a define* helper, not a ninth primitive: a flag has no handler, no input schema
and no surface of its own (The eight primitives).
import { defineFlag, isEnabled } from '@ultimat3/flags';
export const newTaxEngine = defineFlag({
kind: 'temporary',
key: 'checkout.new-tax-engine',
description: 'routes checkout through the rewritten tax engine',
owner: 'payments',
expiresAt: '2026-12-01',
targeting: { default: false, rollout: 10, roles: ['staff'] },
});
if (isEnabled('checkout.new-tax-engine', actor)) {
// …
}isEnabled is synchronous, for the reason can() is: it runs inside policy predicates and
render passes. An undeclared key throws X_FLAG_UNKNOWN rather than answering false — a typo read
as "off" is a branch that never runs in production.
Allow lists first, then the rollout, then default:
| Field | Meaning |
|---|---|
actors, roles, orgs
|
always on for these ids, roles or tenants |
subjects |
allow lists for the app's own record kinds — { bank: ['bank_integration:bbva'] }, read from the call site's third argument |
rollout |
whole percentage 0–100, stable per subject: fnv1a(key + ':' + id) % 100, never Math.random()
|
bucketBy |
what the rollout divides — 'actor' (default), 'org', or any subject kind, so a tenant is on one side whole
|
Targeting by a subject kind the call does not carry throws X_FLAG_SUBJECT_REQUIRED — never a
fallback to the actor or to default.
applyFlagSnapshot({ key: targeting }) lands targeting from outside — a poller, a job, a channel —
so evaluation never loads anything. Keys this build does not declare come back in unknown rather
than throwing: a control plane is often ahead of a deploy. An overdue flag is reported through
core's one error-reporting seam (configureErrorReporting), at most once an hour per flag.
flagsReport() projects every flag with its kind, owner and expiry. Nothing reads it yet: no CLI
command prints it and no manifest section carries it.
Codes: X_FLAG_DUPLICATE, X_FLAG_EXPIRED, X_FLAG_EXPIRY_INVALID, X_FLAG_SUBJECT_REQUIRED,
X_FLAG_TARGETING_INVALID, X_FLAG_UNKNOWN — Error codes.
Ultimate — v22.3.0 As of 2026-09. Stable API, semver from here. MIT licensed. What npm serves is npm view @ultimat3/core version, never this line.
This footer is the only page that stamps a version. It renders under every wiki page, so one release bumps one line; a stamp on a second page is 46 hand-copies of one fact, and every one of them goes stale on the next tag.
Repository · Issues · Changelog · llms.txt
Edits to these pages are synced from wiki/ in the repository — change the file there, not the wiki, or the next sync overwrites it.
Start
Tutorials
- 1 · First app
- 2 · First feature
- 3 · Auth and admin
- 4 · Jobs and realtime
- 5 · Deploy free
- 6 · Growing up
Primitives
- The eight primitives
- Building your own base
- Actions
- Entities and migrations
- Policies and authz
- Queries and live queries
- Client data
- Jobs and workflows
- Scheduled tasks
- Routes and render modes
Capabilities
- Realtime
- Caching and invalidation
- Batching and preloading
- N+1 detection
- PWA and offline
- MCP and AI
- Agents
- Admin dashboard
- Scraping
- Auth
- Notify
- Storage and uploads
- Feature flags
- SEO
- Static assets
Cross-cutting
- I18n
- Theming
- UI components
- Interface rules
- Timezones and dates
- Money
- Resource management
- Migrations and backfills
- Testing
Reference