Flag Evaluation
Responsibility
internal/eval/eval.go implements Evaluate(flag, userKey) bool, the single
function that decides whether a flag is on for a given user. It runs in the
data plane (client), never on the server.
Algorithm
- If
KillSwitchis true → false (overrides everything). - If
!Enabled→ false. - If
RolloutPercent >= 100→ true. - If
RolloutPercent <= 0→ false. - Hash
name:userKeywith FNV-32a, takebucket = hash % 100. - Return
bucket < RolloutPercent.
Properties
- Deterministic: same flag + user key → same result across processes.
- Kill switch wins: overrides enabled and rollout.
- Gradual rollout: increasing
RolloutPercentonly adds users (monotonic in percentage for a fixed hash). - No server state: evaluation is pure and side-effect free.
Tests
internal/eval/eval_test.go covers kill switch, disabled, 0/100 percent, and
determinism. See openwiki/testing/test-strategy.md.
Related
openwiki/domain/flag-model.mdopenwiki/client/data-plane-client.md