advanced25 min studyLesson 385 in Engineering

Feature flags and lifecycle management

Separate deployed code from exposed behavior while managing stable cohorts, stale configuration, defaults, observability, and flag removal.

On this page

What you’ll understand

  • Specify a flag evaluation contract including stale and unavailable provider states.
  • Distinguish user-cohort assignment from independent per-request experiments.
  • Budget reachable configurations and remove temporary flags through a compatibility window.

A feature flag lets the same deployed code choose among behaviors. That creates a useful exposure control and an additional distributed configuration system. Its safety depends on which version of the rules a process sees, how evaluation context is supplied, what happens when the provider fails, and whether the old behavior still works. An emergency switch that was never tested can fail precisely when it is needed.

Specify evaluation rather than just an on/off value

A boolean flag needs an identity, owner, purpose, default, eligible population, and evaluation-context contract. Typed evaluation can report a value together with reason or error information; preserve that distinction in telemetry. A fallback default after provider failure is not evidence that the server deliberately selected the same value. OpenFeature defines evaluation and provider interfaces, but application policy still decides whether a stale or failed provider should keep a last-known value, choose a conservative alternative, or stop an operation. Different features can require different failure choices.

Assignment should often remain stable for the intended experimental unit, such as one user or organization, rather than flipping on every request. Context identity changes, missing keys, and targeting-rule edits can move cohorts unexpectedly. Consistent hashing or a managed bucketing scheme can provide deterministic allocation, but it does not make cohorts representative by magic. Include the evaluated variant, rule/configuration version where available, and a suitable privacy-preserving cohort identifier in observability. Otherwise an apparent code regression may actually be a configuration rollout or stale-cache discrepancy.

behavior=F(code revision,flag revision,context,provider state)\text{behavior}=F(\text{code revision},\text{flag revision},\text{context},\text{provider state})
This functional dependency lists inputs needed to interpret a flag-controlled behavior. It is not a promise of a pure implementation: clocks, external data, and other application inputs may also matter. Recording only the code revision cannot reproduce a mutable flag decision.↔ Scroll wide equations horizontally.

Flags create a growing compatibility surface

With k independent boolean decisions there are up to two to the k possible assignments. Not every assignment is reachable or valid, but assuming they are all tested after checking one happy path is wrong. Define mutual exclusions, dependencies, and meaningful combinations explicitly. A disabled branch can still rot as schemas and APIs change. Test the emergency-off path against current state, including new data written while the feature was on. Turning a flag off changes future selection; it does not undo prior side effects or reconstruct data a branch already deleted.

Configuration propagation can be delayed across processes. A user may hit two instances evaluating different revisions during the transition. Design cross-service contracts for that interval instead of relying on instantaneous agreement. A migration flag that changes both read and write formats needs an explicit order and compatibility matrix. Events indicating provider readiness or configuration changes can support observation, but they are not a universal guarantee that every evaluator in the fleet has converged. Specify the telemetry or acknowledgment needed to close that claim.

Nassignments=2kN_{\rm assignments}=2^k
k is the number of independent boolean flag values, so this is a dimensionless count of all assignments before constraints. Reachable combinations can be fewer. The expression is not a claim that exhaustive production exposure is required or that testing each flag individually covers every interaction.↔ Scroll wide equations horizontally.

Temporary controls need an exit plan

Record an intended expiry or review date when creating a release flag. Once one behavior is permanent, remove the unused branch only after old binaries and stale configuration clients can safely coexist with the removal. Retire targeting rules, dashboards, documentation, and tests tied solely to the temporary decision. Retain an audit record sufficient to explain historical incidents. A long-lived operational control may be intentional, but it still needs an owner and recurring validation rather than becoming an unexplained global variable nobody dares to change.

For a limited cohort model, Reset the probability lab, set both p=0.25 and n=20, predict five selected users on average, then Play or Step. Separately Reset, set both p=0.5 and n=20, predict ten, then Play or Step. The model assumes independent equal-probability assignments for twenty distinct eligible users. It does not resample actual cohorts, propagate configuration, or describe repeated requests from the same user as independent. Explain how a stale evaluator and a missing targeting key could violate the assumptions behind an advertised exposure percentage.

One-at-a-time flag tests leave interactions uncovered

An application has five independent boolean flags. A small test suite checks the all-off baseline and each flag individually on, with every other flag off. Count assignments and tested cases before considering constraints.

  1. Five independent flags have 2^5=32 assignments. This is a configuration count, not a statement that all combinations are meaningful or allowed.

  2. The described suite has one baseline plus five one-at-a-time variants, totaling six distinct assignments. It covers neither all pairs nor all multi-flag interactions.

  3. There are 32−6=26 untested assignments in the unconstrained model. Define which are reachable, prioritize meaningful interactions, and preserve the off path instead of assuming a percentage rollout substitutes for compatibility tests.

The result

A modest number of flags can produce a larger behavior space than the named features suggest. Constraints and lifecycle removal make that space manageable.

Explore the model

Interactive lab

Interactive lab · probability

Cohort percentage needs a defined assignment unit

Reset, set both p=0.25 and n=20, predict five selected users on average, then Play or Step. Separately Reset, set both p=0.5 and n=20, predict ten, then Play or Step. Exact binomial counts assume distinct independently assigned eligible users, not repeated requests, stale rules, or actual flag-provider execution.

Cohort percentage needs a defined assignment unitThese are exact binomial probabilities for independent trials with one fixed success probability. Playback tours the distribution; it does not resample outcomes. Current readings: Mean · np: 5; Variance · np(1−p): 2.5; Total probability: 1. All parameters are adjustable with the labeled controls below.03581000.070.150.220.3Successes kP(X = k)k = 0 · P = 9.77e-4
Exact probabilityHighlighted outcomeMean np
Mean · np
5
Variance · np(1−p)
2.5
Total probability
1
t = 0 s

These are exact binomial probabilities for independent trials with one fixed success probability. Playback tours the distribution; it does not resample outcomes. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.

Look forStable cohort identity and configuration version matter alongside the nominal percentage.

Check your understanding

A flag provider fails and the client returns the application's configured default. Which interpretation preserves the evaluation evidence?

Try it yourself

Six unconstrained boolean flags exist, but a test suite covers the baseline plus each flag individually. How many assignments exist and how many remain outside that suite?

Take a moment to make a prediction or work it out on paper. Open a hint when you need one.

Give me a hint

Compare 2^6 with one plus six.

Compare with the solution

There are 64 assignments, while the described suite has seven distinct cases. Fifty-seven unconstrained assignments are not covered. The count should motivate explicit valid-combination constraints and targeted interaction tests, not an assumption that every configuration must be exposed to production users or that all combinations are equally important.

Take it with you

  • Flags distribute behavior configuration and need explicit failure defaults.
  • Cohort identity and stale revisions can change actual exposure.
  • Test meaningful interactions and retire temporary branches through a compatibility window.

Read further

Original sources and deeper explanations to follow at your own pace.

Optional progress, saved in this browser when available. Revisit any lesson at any time.

Lesson not marked complete.