Feature Flags Architecture
Feature Flags Architecture
Overview
This document defines the architecture for our feature flag evaluation system. The system provides real-time targeting, gradual rollouts, and instant kill-switch capabilities across all product surfaces.
See ⟦ API Design Spec ⟧ for the REST endpoints used to fetch flag states, and ⟦ Agent Runbook — Feature Flags ⟧ for operational procedures.
Core Concepts
Flag Evaluation Engine
The evaluation engine processes flags in the following order:
Flag Types
| Type | Description | Use Case | |------|-------------|----------| | Boolean | Simple on/off | Feature visibility | | String | Multi-variant | A/B testing copy | | Number | Numeric value | Rate limits, thresholds | | JSON | Structured config | Complex configurations |
Architecture
``
SDK → Edge Evaluation → Flag Store → Rules Engine
↓
Local Cache (TTL: 30s)
↓
Event Stream (flag evaluations)
`
Targeting Rules
Targeting rules are evaluated in priority order. Each rule contains:
Example Rule (YAML)
`yaml
rules:
- attribute: plan
operator: equals
value: enterprise
variation: enabled
- attribute: email
operator: contains
value: "@acme.com"
variation: enabled
`
Rollout Strategy
Gradual rollouts use deterministic hashing on userId + flagKey to ensure:
See ⟦ Rollout Strategy ⟧ for the mathematical model.
SDK Integration
The SDK fetches flag states at initialization and subscribes to a streaming endpoint for real-time updates. See ⟦ SDK Integration Guide ⟧ for language-specific implementations.
`agent-context
``Context: Feature Flag System
This system controls feature visibility across all product surfaces.
Agents working on feature development should check flag states before
assuming feature availability in production.