Dependent flags let a segment condition read another flag's result via a $.flags.<feature name>.<enabled|value|variant> property, so that flag has to be resolved before the condition is evaluated. Behaviour is defined by the shared cases in Flagsmith/engine-test-data#59; schema in Flagsmith/flagsmith#8396; reference implementation in Flagsmith/flagsmith-engine#343.
The reference implementation resolves a flag lazily, on first read, rather than scanning every condition up front to discover dependencies. Three things in this engine currently prevent that:
get_value_from_jsonpath calls serde_json::to_value(ec) on every lookup, serialising the whole context (~268 µs on a 263-feature environment, of which the query itself is 389 ns). A lazily resolved flags map has nothing to be inserted into, and lookups already dominate evaluation.
JsonPath::parse also runs on every lookup (~1.5 µs), uncached.
serde_json::Value exposes no lookup hook, so resolution must be triggered by inspecting the parsed path. serde_json_path::JsonPath keeps its Query private, though the AST is public in serde_json_path_core::spec.
Acceptance criteria
engine-test-data is bumped from v3.7.0 to the tag containing the flag dependency cases, and they pass.
- An environment with no
$.flags conditions gains no per-evaluation cost.
- Dependency detection uses the parser's AST, not a bespoke matcher, so all pinned spellings of a query agree.
Dependent flags let a segment condition read another flag's result via a
$.flags.<feature name>.<enabled|value|variant>property, so that flag has to be resolved before the condition is evaluated. Behaviour is defined by the shared cases in Flagsmith/engine-test-data#59; schema in Flagsmith/flagsmith#8396; reference implementation in Flagsmith/flagsmith-engine#343.The reference implementation resolves a flag lazily, on first read, rather than scanning every condition up front to discover dependencies. Three things in this engine currently prevent that:
get_value_from_jsonpathcallsserde_json::to_value(ec)on every lookup, serialising the whole context (~268 µs on a 263-feature environment, of which the query itself is 389 ns). A lazily resolvedflagsmap has nothing to be inserted into, and lookups already dominate evaluation.JsonPath::parsealso runs on every lookup (~1.5 µs), uncached.serde_json::Valueexposes no lookup hook, so resolution must be triggered by inspecting the parsed path.serde_json_path::JsonPathkeeps itsQueryprivate, though the AST is public inserde_json_path_core::spec.Acceptance criteria
engine-test-datais bumped fromv3.7.0to the tag containing the flag dependency cases, and they pass.$.flagsconditions gains no per-evaluation cost.