Flagsmith / Flagsmith/flagsmith-rust-flag-engine

Support `$.flags` context values in segment conditions

Aperta
#40 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Rust
Stelle
1
Fork
0
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

Dependent flags let a segment condition read another flag's result via a `$.flags..` 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.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

Inizia individuando il percorso get_value_from_jsonpath del motore e la chiamata a JsonPath::parse, quindi leggi il flusso di valutazione relativo alle condizioni dei segmenti e all'AST serde_json_path_core::spec. Usa i casi di dipendenza condivisi di engine-test-data e confronta l'implementazione di riferimento in flagsmith-engine#343. Il lavoro è completo quando i casi di dipendenza passano, i contesti senza $.flags evitano l'overhead per valutazione e il rilevamento segue l'AST del parser.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
rust
Ambito
backend
Tipo di issue
Funzionalità
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Attiva
Chiarezza
Abbastanza chiara
Idoneità per principianti
52/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.