One flag service, every request’s user, then prerequisites
A feature-flag service stores each flag’s targeting rule as an expression tree, as the lesson’s help desk stores a saved view, and interprets it for every request against that request’s user: their plan, whether they joined the beta, and the country the geo lookup found, which can be unknown. Each level starts from the previous level’s finished code, so you can begin at any of them.
Product now builds flags on top of other flags: the new checkout should be on only where the new navigation is on, whatever the navigation’s rule says this week. The dashboard saves this as Requires("new-nav"), and the service passes every flag’s saved rule into each evaluation as flags, by name. The dashboard already rejects a flag that requires itself, directly or through others. Requires was added to the language, but its meaning was never written.
Every flag with a prerequisite is off for everyone, including the beta users who were meant to test it. A typo in a prerequisite’s name goes unnoticed, because it looks the same as off.
Reproduce With new-nav saved as Beta, the rule Requires('new-nav') AND PlanIs('pro') decides off for Ada, who is on pro and in the beta. Requires('new-nab'), a typo, decides off rather than an error.
Acceptance criteria Requires(name) answers what that flag’s saved rule answers for the same user, looked up in the evaluation’s flags. A name with no saved rule returns the error unknown-flag (decided as off (unknown-flag)), not false. An error inside the required flag’s rule, such as missing-country, comes back unchanged; prerequisites can require other flags in turn. INTERPRETER-101’s rules still hold: CountryIn’s own codes, an unknown country as an error, And and Or reading their left side first. Notes Each case gives the flags as saved, then decides one rule for each user in turn; the lines print joined by “ | ”. Keep the names and constructors of the expression types and the signature of decide. The checker never saves a flag that requires itself.