The flag model
Every flag — even boolean — is variant-based. Evaluation is a deterministic order; the first thing that resolves wins:
flowchart TD
A([evaluate flag, context]) --> B{enabled?}
B -- no --> Z["default variant · DISABLED"]
B -- yes --> S{"within schedule window?"}
S -- no --> Z2["default variant · SCHEDULED / EXPIRED"]
S -- yes --> P{"prerequisites all satisfied?"}
P -- no --> Z3["default variant · PREREQUISITE_FAILED"]
P -- yes --> O{"exact override on bucketing key?"}
O -- yes --> ZO["override variant · STATIC"]
O -- no --> R{"targeting rule matches? first match wins"}
R -- yes --> ZR["rule variant · TARGETING_MATCH / SPLIT"]
R -- no --> F["fallthrough · STATIC / SPLIT"]
- Splits are deterministic:
same flagKey + same targetingKey + same salt → same variant(MurmurHash3, neverMath.random). Weights need not total 100. - Targeting rules are conditions combined with AND / OR / NOT groups (nest arbitrarily; a flat list is a plain AND). Operators cover equality, membership, string, numeric, dates (ISO-8601 / epoch /
Date/Temporalvia ordering operators), semver,inSegment/notInSegment, andmatches/notMatches— a JSON query document evaluated by a pluggable matcher (built-inregex, orsift/mingovia a registered matcher). - Value objects are understood out of the box for ordering/equality (the whole Temporal family +
BigInt); for types that don’t follow that convention — Dinero, Decimal — register a custom comparator. - Reusable segments are named audiences referenced by rules; prerequisites express flag-to-flag dependencies (acyclic, validated at publish).
- Scheduled active window (
schedule.enableAt/disableAt) — outside it the evaluator serves the default variant (SCHEDULED/EXPIRED); behavioral, checked live, never flipsenabled. - Organizational metadata: tags, owner, archiving (excluded from snapshots), and advisory stale detection (a
lifecyclepolicy that only shows a badge — it never changes behavior).
Full reference: docs/OPERATORS.md.