:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(flags): parse closed v2 configs without enabling evaluation (#102189)
Andersc2d491932ee5
diff --git a/docs/internal/feature-flags/flag-evaluation-engine.md b/docs/internal/feature-flags/flag-evaluation-engine.mdindex 35fc66e26f9e..c7c00b84f6ba 100644--- a/docs/internal/feature-flags/flag-evaluation-engine.md+++ b/docs/internal/feature-flags/flag-evaluation-engine.md@@ -5,17 +5,46 @@ The Rust feature flags service evaluates flags using a deterministic, hash-based## Architecture overviewStored configuration dispatch reads `filters.version`; the row's `FeatureFlag.version` remains a concurrency counter.-An absent discriminator or numeric 1 (including 1.0) selects v1; every other value, 2 included, is a format this service does not evaluate.-The classification matches Python's `detect_config_format` (`products/feature_flags/backend/facade/config.py`).+An absent discriminator or numeric 1 (including 1.0) selects v1.+Numeric 2 (including 2.0) selects the closed v2 parser; other discriminator values are unsupported.+The service does not evaluate any non-v1 format, including a successfully parsed v2 configuration.+The classification converts the discriminator to correctly rounded binary64, matching Python's `detect_config_format` (`products/feature_flags/backend/facade/config.py`) and its cache producer's normalization.Cache and PostgreSQL ingress classify the original document before decoding v1 fields.-Non-v1 objects stay opaque in the filters passthrough map so cache round trips retain them and the cache byte budget includes them.+Non-v1 objects retain their original JSON in `FlagFilters.non_v1`, alongside the v2 parse result when applicable.+PostgreSQL decodes filters as raw JSON through the same reader used by service-cache records.+V2 validation checks the retained tokens for duplicate object keys, nonzero numeric underflow, and excess percentage precision before admitting the typed configuration.+These checks share one token pass with the compact document-size limit; original tokens survive cache round trips.+Validation cannot recover precision or duplicate keys already lost by an upstream producer, so writers must enforce these constraints before ordinary JSON decoding.+The prepared cache retains this data through an `Arc`; requests reuse the parse result, and its byte estimate includes raw JSON, typed rules, property values, and seeds.+Manually constructed opaque filters still use the passthrough-map serialization fallback.++The parser accepts person-assigned boolean configurations with ordered targeted-release and percentage-rollout rules.+It validates required fields, closed semantic objects, unique UUID rule IDs, boolean values, canonical person-property operators, rollout policies, assignment literals, and seeds.+Missing defaults and miss policies are errors; explicit null defaults and empty rule/targeting arrays are valid.+Experiment and holdout semantics, group assignment, non-boolean outputs, and cohort/group/flag predicates remain unsupported.+One unsupported predicate or rule rejects the whole flag's configuration.+Parser diagnostics and debug output omit raw configuration values.++The reader enforces 100 rules, 100 predicates per rule, 1–400 character percentage-rule seeds, and finite percentages in [0, 100] with at most two decimal places.+Its compact UTF-8 document ceiling reads `MAX_FEATURE_FLAG_FILTER_SIZE_BYTES` once per process, with the same 512 KiB default as the writer; the reader counts stored token bytes, excluding whitespace outside strings.+Writers must also enforce their deployment-specific document limit and explicit metadata limit; the parser adds no separate metadata-size policy.+Set `MAX_FEATURE_FLAG_FILTER_SIZE_BYTES` to the same value on the reader and writer deployments before admitting stored v2 data.+Presentation metadata stays in the original JSON and does not enter typed targeting.++The service-cache envelope remains separate from the canonical definitions-entry envelope, where team identity can be omitted.+Parser tests adapt canonical definition filters to service records without adding a definitions-v2 route or allowing the legacy definitions endpoint to publish v2.+Parser fixtures from harness release 1.6.0 are pinned under contract version 2.1.0, separately from the unchanged v1 corpus pin.+The Rust suite checks parser field sets, limits, and literals against the released schema and registry.+Definitions-feed artifacts belong to the future definitions route and are not part of this parser pin.The evaluator classifies them once per request, next to `filtered_out_flag_ids`, rather than failing per flag inside `get_match`: an eligible non-v1 flag gets a `flag_data_parsing_error` response entry, is skipped by regex, cohort, dependency, and property preparation, and is pre-seeded false like any other skipped flag, so a dependent's `flag_evaluates_to: false` condition still resolves.Detailed responses mark them failed.The legacy `/flags` map and `/decide?v=3` retain false entries with `errorsWhileComputingFlags=true`; older `/decide` formats omit them.Healthy siblings still evaluate, and request eligibility remains unchanged.Malformed v1 documents retain the existing ingress error behavior.+Each recognized v2 ingress increments `flags_v2_config_parse_total` with a fixed `outcome` label: `success`, `malformed`, `unsupported`, or `limit_exceeded`.+These outcomes cover cache and PostgreSQL reads and contain no configuration values.The internal batch evaluation endpoint rejects a non-v1 target with HTTP 400 and `unsupported_config_format` before it pages the team, so cohort generation treats the failure as permanent.The Rust cache builder fails a team's rebuild on an evaluable non-v1 document, the way Python does.@@ -24,6 +53,8 @@ Inactive and deleted non-v1 flags do not fail the team's rebuild.`/remote_config` stays outside this boundary: it reads `filters.payloads["true"]` raw, as Django's shadow-compared view does.This boundary does not make legacy definitions producers or older cache writers safe for persisted v2 rows.Those paths need independent exclusion and deployment-floor protection before such rows can exist.+To roll back parsing, remove its reader consumer first while retaining opaque non-v1 reads and evaluator/producer rejection.+Never restore a reader that interprets v2 data as v1.The production `v1_bucketing` functions accept prescribed hashes for contract tests.Rollout returns included at 100% before identifier resolution or hashing; other percentages use `hash <= percentage / 100.0`.diff --git a/rust/feature-flags/Cargo.toml b/rust/feature-flags/Cargo.tomlindex 4e4d5563c8a8..44f64c6576f9 100644--- a/rust/feature-flags/Cargo.toml+++ b/rust/feature-flags/Cargo.toml@@ -36,7 +36,7 @@ url = "2.5"once_cell = { workspace = true }rand = { workspace = true }serde = { workspace = true }-serde_json = { workspace = true }+serde_json = { workspace = true, features = ["raw_value"] }json5 = "1.3"thiserror = { workspace = true }sha1 = "0.10.6"@@ -117,7 +117,7 @@ workspace = true[dev-dependencies]rstest = "0.26"assert-json-diff = { workspace = true }-common-s3 = { path = "../common/s3" }+common-s3 = { path = "../common/s3", features = ["mock-client"] }reqwest = { workspace = true }futures = "0.3.30"test-case = "3.3.1"diff --git a/rust/feature-flags/src/flags/config_format.rs b/rust/feature-flags/src/flags/config_format.rsindex b40b63332dce..c15e617bf577 100644--- a/rust/feature-flags/src/flags/config_format.rs+++ b/rust/feature-flags/src/flags/config_format.rs@@ -1,22 +1,92 @@use serde::{Deserialize, Deserializer, Serialize, Serializer};-use serde_json::Value;+use serde_json::value::RawValue;+use serde_json::{Map, Value};+use std::sync::Arc;use crate::api::errors::FlagError;+use crate::flags::config_v2;use crate::flags::flag_models::FlagFilters;+use crate::metrics::consts::FLAG_V2_PARSE_COUNTER;-/// Mirrors Python's `detect_config_format` (products/feature_flags/backend/facade/config.py).-fn is_v1_version(version: Option<&Value>) -> bool {- match version {- None => true,- // JSON booleans are not `Value::Number`, so `true` cannot read as 1 here.- Some(Value::Number(number)) => number.as_f64() == Some(1.0),- Some(_) => false,+#[derive(Debug, Clone, Copy, PartialEq, Eq)]+enum ConfigFormat {+ V1,+ V2,+ Unsupported,+}++impl ConfigFormat {+ fn from_number(number: Option<f64>) -> Self {+ match number {+ Some(1.0) => Self::V1,+ Some(2.0) => Self::V2,+ _ => Self::Unsupported,+ }+ }+}++fn config_format(version: Option<&Value>) -> ConfigFormat {+ version.map_or(ConfigFormat::V1, |value| {+ ConfigFormat::from_number(value.as_f64())+ })+}++struct FilterDocument<const BUILD_DOCUMENT: bool> {+ format: ConfigFormat,+ document: Map<String, Value>,+}++impl<'de, const BUILD_DOCUMENT: bool> Deserialize<'de> for FilterDocument<BUILD_DOCUMENT> {+ fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {+ struct DocumentVisitor<const BUILD_DOCUMENT: bool>;+ impl<'de, const BUILD_DOCUMENT: bool> serde::de::Visitor<'de> for DocumentVisitor<BUILD_DOCUMENT> {+ type Value = FilterDocument<BUILD_DOCUMENT>;++ fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {+ formatter.write_str("a filters object")+ }++ fn visit_map<A: serde::de::MapAccess<'de>>(+ self,+ mut map: A,+ ) -> Result<Self::Value, A::Error> {+ let mut format = ConfigFormat::V1;+ let mut document = Map::new();+ while let Some(key) = map.next_key::<String>()? {+ if key == "version" {+ let raw: &RawValue = map.next_value()?;+ // Python rounds JSON numbers correctly; serde's default Value+ // parser can round a nearby non-1 discriminator to 1 instead.+ format = ConfigFormat::from_number(raw.get().parse::<f64>().ok());+ if BUILD_DOCUMENT {+ let mut version =+ serde_json::from_str(raw.get()).unwrap_or(Value::Null);+ // Keep is_v1's Value-based check consistent with raw-token+ // dispatch. serialize_filters also writes this normalized+ // discriminator back to the cache.+ if format == ConfigFormat::V1 && version.as_f64() != Some(1.0) {+ version = serde_json::json!(1.0);+ }+ document.insert(key, version);+ }+ } else if BUILD_DOCUMENT {+ document.insert(key, map.next_value()?);+ } else {+ map.next_value::<serde::de::IgnoredAny>()?;+ }+ }+ Ok(FilterDocument { format, document })+ }+ }+ // Require an object: derived Deserialize also accepts positional arrays+ // and would interpret [2] as a non-v1 document with version 2.+ deserializer.deserialize_map(DocumentVisitor::<BUILD_DOCUMENT>)}}impl FlagFilters {pub(crate) fn is_v1(&self) -> bool {- is_v1_version(self.extra.get("version"))+ self.non_v1.is_none() && config_format(self.extra.get("version")) == ConfigFormat::V1}pub(crate) fn require_v1(&self) -> Result<(), FlagError> {@@ -30,18 +100,43 @@ impl FlagFilters {}}+#[cfg(test)]pub(crate) fn decode_filters(value: Value) -> Result<FlagFilters, serde_json::Error> {- // An object is required even when the discriminator is absent.- let Value::Object(document) = value else {- return Err(serde::de::Error::custom("expected a filters object"));+ decode_raw_filters(serde_json::value::to_raw_value(&value)?)+}++pub(crate) fn decode_raw_filters(raw: Box<RawValue>) -> Result<FlagFilters, serde_json::Error> {+ let (format, document) = match serde_json::from_str::<FilterDocument<true>>(raw.get()) {+ Ok(decoded) => (decoded.format, Ok(decoded.document)),+ Err(error) => {+ // An unrepresentable number must stay a per-flag v2 failure. Only+ // failed Value reads need another scan to recover the discriminator.+ let probe = serde_json::from_str::<FilterDocument<false>>(raw.get())?;+ (probe.format, Err(error))+ }};- if is_v1_version(document.get("version")) {- serde_json::from_value(Value::Object(document))+ if format == ConfigFormat::V1 {+ serde_json::from_value(Value::Object(document?))} else {+ let parsed_v2 = (format == ConfigFormat::V2).then(|| {+ config_v2::validate_raw_document(&raw)?;+ let document = document.map_err(|_| config_v2::ParseError::Malformed("filters"))?;+ config_v2::Config::parse(&document)+ });+ if let Some(parsed) = &parsed_v2 {+ let outcome = match parsed {+ Ok(_) => "success",+ Err(config_v2::ParseError::Malformed(_)) => "malformed",+ Err(config_v2::ParseError::Unsupported(_)) => "unsupported",+ Err(config_v2::ParseError::LimitExceeded(_)) => "limit_exceeded",+ };+ metrics::counter!(FLAG_V2_PARSE_COUNTER, "outcome" => outcome).increment(1);+ }Ok(FlagFilters {- // Keep the document opaque: v1-looking fields may have unrelated types.- // The passthrough map also accounts for these bytes in the prepared cache.- extra: document,+ non_v1: Some(Arc::new(config_v2::NonV1Config {+ parsed_v2,+ document: raw,+ })),..Default::default()})}@@ -51,17 +146,19 @@ pub(crate) fn deserialize_filters<'de, D>(deserializer: D) -> Result<FlagFilterswhereD: Deserializer<'de>,{- decode_filters(Value::deserialize(deserializer)?).map_err(serde::de::Error::custom)+ decode_raw_filters(Box::<RawValue>::deserialize(deserializer)?)+ .map_err(serde::de::Error::custom)}-/// The single place a `FlagFilters` turns back into stored JSON: the derived `Serialize`-/// impl flattens `extra`, which for an opaque non-v1 document would emit the typed fields-/// twice.+/// Derived serialization adds v1 fields to opaque documents. Stored JSON must use+/// the retained raw document, or the passthrough map for manually constructed filters.pub(crate) fn serialize_filters<S>(filters: &FlagFilters, serializer: S) -> Result<S::Ok, S::Error>whereS: Serializer,{- if filters.is_v1() {+ if let Some(config) = &filters.non_v1 {+ config.document.serialize(serializer)+ } else if filters.is_v1() {filters.serialize(serializer)} else {filters.extra.serialize(serializer)diff --git a/rust/feature-flags/src/flags/config_format/tests.rs b/rust/feature-flags/src/flags/config_format/tests.rsindex 00402ae3f7fd..909894e86d0d 100644--- a/rust/feature-flags/src/flags/config_format/tests.rs+++ b/rust/feature-flags/src/flags/config_format/tests.rs@@ -84,6 +84,8 @@ fn invalid_v1_filter_documents_keep_ingress_errors() {json!(1),json!("filters"),json!([]),+ json!([2]),+ json!([1]),json!({"groups": null}),json!({"groups": [{"properties": [{"key": "missing-type"}]}]}),] {@@ -96,3 +98,50 @@ fn invalid_v1_filter_documents_keep_ingress_errors() {let empty: FeatureFlag = serde_json::from_value(flag(json!({}))).unwrap();assert!(empty.filters.groups.is_empty());}++#[test]+fn v2_ingress_counts_parse_outcomes_without_configuration_labels() {+ use metrics_util::debugging::{DebugValue, DebuggingRecorder};+ let recorder = DebuggingRecorder::new();+ let valid =+ json!({"version": 2, "return_type": "boolean", "default_value": false, "rules": []});+ let mut malformed = valid.clone();+ malformed["default_value"] = json!("invalid");+ let mut unsupported = valid.clone();+ unsupported["return_type"] = json!("string");+ let mut oversized = valid.clone();+ oversized["extra"] = json!("x".repeat(*config_v2::MAX_CONFIG_BYTES));+ metrics::with_local_recorder(&recorder, || {+ for document in [+ valid,+ malformed,+ unsupported,+ oversized,+ json!({}),+ json!({"version": 3}),+ ] {+ decode_filters(document).unwrap();+ }+ });+ let outcomes: std::collections::BTreeSet<_> = recorder+ .snapshotter()+ .snapshot()+ .into_vec()+ .into_iter()+ .filter(|(key, _, _, _)| key.key().name() == FLAG_V2_PARSE_COUNTER)+ .map(|(key, _, _, value)| {+ assert_eq!(value, DebugValue::Counter(1));+ let labels: Vec<_> = key.key().labels().collect();+ assert_eq!(labels.len(), 1);+ assert_eq!(labels[0].key(), "outcome");+ labels[0].value().to_owned()+ })+ .collect();+ assert_eq!(+ outcomes,+ ["success", "malformed", "unsupported", "limit_exceeded"]+ .into_iter()+ .map(str::to_owned)+ .collect()+ );+}diff --git a/rust/feature-flags/src/flags/config_v2.rs b/rust/feature-flags/src/flags/config_v2.rsnew file mode 100644index 000000000000..3e8ff18d6b9b--- /dev/null+++ b/rust/feature-flags/src/flags/config_v2.rs@@ -0,0 +1,330 @@+use std::collections::HashSet;+use std::fmt;++use once_cell::sync::Lazy;+use serde_json::value::RawValue;+use serde_json::{Map, Value};+use uuid::Uuid;++mod properties;+mod raw;+pub use properties::PersonPredicate;+pub(crate) use raw::validate_raw_document;++pub static MAX_CONFIG_BYTES: Lazy<usize> = Lazy::new(|| {+ std::env::var("MAX_FEATURE_FLAG_FILTER_SIZE_BYTES")+ .map(|value| {+ value+ .parse()+ .expect("MAX_FEATURE_FLAG_FILTER_SIZE_BYTES must be a nonnegative integer")+ })+ .unwrap_or(512 * 1024)+});+pub const MAX_RULES: usize = 100;+pub const MAX_PREDICATES: usize = 100;+pub const MAX_SEED_LENGTH: usize = 400;+pub const CONFIG_FIELDS: &[&str] = &[+ "version",+ "return_type",+ "default_value",+ "rules",+ "aggregation_group_type_index",+];+pub const TARGETED_RELEASE_FIELDS: &[&str] = &[+ "id",+ "rule_type",+ "targeting",+ "description",+ "metadata",+ "value",+];+pub const PERCENTAGE_ROLLOUT_FIELDS: &[&str] = &[+ "id",+ "rule_type",+ "targeting",+ "description",+ "metadata",+ "value",+ "rollout_percentage",+ "on_rollout_miss",+ "assignment_algorithm",+ "seed",+ "assign_by",+];+pub const TARGETING_FIELDS: &[&str] = &["properties"];+pub const PROPERTY_FIELDS: &[&str] = &[+ "key",+ "type",+ "value",+ "operator",+ "negation",+ "group_type_index",+ "cohort_name",+ "group_key_names",+ "label",+];++#[derive(Clone, Copy, Debug, PartialEq, Eq)]+pub enum ParseError {+ Malformed(&'static str),+ Unsupported(&'static str),+ LimitExceeded(&'static str),+}++#[derive(Clone)]+pub struct NonV1Config {+ pub parsed_v2: Option<Result<Config, ParseError>>,+ pub(crate) document: Box<RawValue>,+}++impl fmt::Debug for NonV1Config {+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {+ f.debug_struct("NonV1Config")+ .field("parsed_v2", &self.parsed_v2)+ .finish_non_exhaustive()+ }+}++impl NonV1Config {+ pub(crate) fn estimated_heap_bytes(&self) -> usize {+ std::mem::size_of::<Self>()+ + 2 * std::mem::size_of::<usize>()+ + self.document.get().len()+ + self+ .parsed_v2+ .as_ref()+ .and_then(|parsed| parsed.as_ref().ok())+ .map_or(0, Config::estimated_heap_bytes)+ }+}++#[derive(Clone)]+pub struct Config {+ pub default_value: Option<bool>,+ pub rules: Vec<Rule>,+}++#[derive(Clone)]+pub struct Rule {+ pub id: Uuid,+ pub targeting: Vec<PersonPredicate>,+ pub outcome: Outcome,+}++#[derive(Clone)]+pub enum Outcome {+ TargetedRelease {+ value: bool,+ },+ PercentageRollout {+ value: bool,+ rollout_percentage: f64,+ on_rollout_miss: RolloutMiss,+ seed: String,+ },+}++#[derive(Clone, Copy, Debug, PartialEq, Eq)]+pub enum RolloutMiss {+ Continue,+ ReturnDefault,+}++impl fmt::Debug for Config {+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {+ f.debug_struct("V2Config")+ .field("rule_count", &self.rules.len())+ .finish_non_exhaustive()+ }+}++impl fmt::Debug for Rule {+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {+ f.debug_struct("V2Rule")+ .field("predicate_count", &self.targeting.len())+ .field("outcome", &self.outcome)+ .finish_non_exhaustive()+ }+}++impl fmt::Debug for Outcome {+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {+ f.write_str(match self {+ Self::TargetedRelease { .. } => "TargetedRelease { .. }",+ Self::PercentageRollout { .. } => "PercentageRollout { .. }",+ })+ }+}++impl Config {+ pub(super) fn parse(document: &Map<String, Value>) -> Result<Self, ParseError> {+ closed(document, CONFIG_FIELDS, "filters")?;+ match string(document, "return_type")? {+ "boolean" => {}+ "string" | "number" | "object" => {+ return Err(ParseError::Unsupported("return_type"));+ }+ _ => return Err(ParseError::Malformed("return_type")),+ }+ if let Some(group) = document.get("aggregation_group_type_index") {+ if !group+ .as_f64()+ .is_some_and(|n| n.is_finite() && n.fract() == 0.0)+ {+ return Err(ParseError::Malformed("aggregation_group_type_index"));+ }+ return Err(ParseError::Unsupported("aggregation_group_type_index"));+ }+ let default_value = match required(document, "default_value")? {+ Value::Null => None,+ Value::Bool(value) => Some(*value),+ _ => return Err(ParseError::Malformed("default_value")),+ };+ let rules = required(document, "rules")?+ .as_array()+ .ok_or(ParseError::Malformed("rules"))?;+ if rules.len() > MAX_RULES {+ return Err(ParseError::LimitExceeded("rules"));+ }+ let mut seen = HashSet::with_capacity(rules.len());+ let rules = rules+ .iter()+ .map(|value| {+ let rule = Rule::parse(value)?;+ if !seen.insert(rule.id) {+ return Err(ParseError::Malformed("rule.id"));+ }+ Ok(rule)+ })+ .collect::<Result<_, _>>()?;+ Ok(Self {+ default_value,+ rules,+ })+ }++ pub(crate) fn estimated_heap_bytes(&self) -> usize {+ self.rules.capacity() * std::mem::size_of::<Rule>()+ + self+ .rules+ .iter()+ .map(Rule::estimated_heap_bytes)+ .sum::<usize>()+ }+}++impl Rule {+ fn parse(value: &Value) -> Result<Self, ParseError> {+ let rule = object(value, "rule")?;+ let rule_type = string(rule, "rule_type")?;+ let fields: &[&str] = match rule_type {+ "targeted_release" => TARGETED_RELEASE_FIELDS,+ "percentage_rollout" => PERCENTAGE_ROLLOUT_FIELDS,+ "experiment" => return Err(ParseError::Unsupported("rule_type")),+ _ => return Err(ParseError::Malformed("rule_type")),+ };+ closed(rule, fields, "rule")?;+ let id = string(rule, "id")?;+ // UUID's general parser also accepts compact and URN forms; the wire does not.+ if id.len() != 36 || [8, 13, 18, 23].iter().any(|&i| id.as_bytes()[i] != b'-') {+ return Err(ParseError::Malformed("rule.id"));+ }+ let id = Uuid::parse_str(id).map_err(|_| ParseError::Malformed("rule.id"))?;+ if rule.get("description").is_some_and(|v| !v.is_string()) {+ return Err(ParseError::Malformed("description"));+ }+ if rule.get("metadata").is_some_and(|v| !v.is_object()) {+ return Err(ParseError::Malformed("metadata"));+ }+ let targeting = properties::parse_targeting(required(rule, "targeting")?)?;+ let value = required(rule, "value")?+ .as_bool()+ .ok_or(ParseError::Malformed("value"))?;+ let outcome = if rule_type == "targeted_release" {+ Outcome::TargetedRelease { value }+ } else {+ if string(rule, "assignment_algorithm")? != "sha1_60_v1" {+ return Err(ParseError::Malformed("assignment_algorithm"));+ }+ if rule+ .get("assign_by")+ .is_some_and(|v| v.as_str() != Some("person"))+ {+ return Err(ParseError::Malformed("assign_by"));+ }+ let seed = string(rule, "seed")?;+ if !(1..=MAX_SEED_LENGTH).contains(&seed.chars().count()) {+ return Err(ParseError::Malformed("seed"));+ }+ let on_rollout_miss = match string(rule, "on_rollout_miss")? {+ "continue" => RolloutMiss::Continue,+ "return_default" => RolloutMiss::ReturnDefault,+ _ => return Err(ParseError::Malformed("on_rollout_miss")),+ };+ Outcome::PercentageRollout {+ value,+ rollout_percentage: percentage(required(rule, "rollout_percentage")?)?,+ on_rollout_miss,+ seed: seed.to_owned(),+ }+ };+ Ok(Self {+ id,+ targeting,+ outcome,+ })+ }++ fn estimated_heap_bytes(&self) -> usize {+ self.targeting.capacity() * std::mem::size_of::<PersonPredicate>()+ + self+ .targeting+ .iter()+ .map(PersonPredicate::estimated_heap_bytes)+ .sum::<usize>()+ + match &self.outcome {+ Outcome::PercentageRollout { seed, .. } => seed.capacity(),+ Outcome::TargetedRelease { .. } => 0,+ }+ }+}++fn percentage(value: &Value) -> Result<f64, ParseError> {+ let error = ParseError::Malformed("rollout_percentage");+ let Value::Number(number) = value else {+ return Err(error);+ };+ let numeric = number.as_f64().ok_or(error)?;+ if !numeric.is_finite() || !(0.0..=100.0).contains(&numeric) {+ return Err(error);+ }+ Ok(numeric)+}++fn object<'a>(value: &'a Value, field: &'static str) -> Result<&'a Map<String, Value>, ParseError> {+ value.as_object().ok_or(ParseError::Malformed(field))+}++fn required<'a>(+ object: &'a Map<String, Value>,+ field: &'static str,+) -> Result<&'a Value, ParseError> {+ object.get(field).ok_or(ParseError::Malformed(field))+}++fn string<'a>(object: &'a Map<String, Value>, field: &'static str) -> Result<&'a str, ParseError> {+ required(object, field)?+ .as_str()+ .ok_or(ParseError::Malformed(field))+}++fn closed(+ object: &Map<String, Value>,+ fields: &[&str],+ field: &'static str,+) -> Result<(), ParseError> {+ if object.keys().any(|key| !fields.contains(&key.as_str())) {+ return Err(ParseError::Malformed(field));+ }+ Ok(())+}diff --git a/rust/feature-flags/src/flags/config_v2/properties.rs b/rust/feature-flags/src/flags/config_v2/properties.rsnew file mode 100644index 000000000000..a84703106773--- /dev/null+++ b/rust/feature-flags/src/flags/config_v2/properties.rs@@ -0,0 +1,162 @@+use std::fmt;++use serde_json::Value;++use super::{+ closed, object, required, string, ParseError, MAX_PREDICATES, PROPERTY_FIELDS, TARGETING_FIELDS,+};+use crate::properties::property_matching::to_semver_representation;+use crate::properties::property_models::OperatorType;+use crate::properties::relative_date::parse_relative_date_parts;+use crate::utils::json_size::estimate_json_heap_size;++#[derive(Clone)]+pub struct PersonPredicate {+ pub key: String,+ pub value: Option<Value>,+ pub operator: OperatorType,+ pub negation: bool,+}++impl fmt::Debug for PersonPredicate {+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {+ f.debug_struct("PersonPredicate")+ .field("operator", &self.operator)+ .finish_non_exhaustive()+ }+}++pub(super) fn parse_targeting(value: &Value) -> Result<Vec<PersonPredicate>, ParseError> {+ let targeting = object(value, "targeting")?;+ closed(targeting, TARGETING_FIELDS, "targeting")?;+ let properties = required(targeting, "properties")?+ .as_array()+ .ok_or(ParseError::Malformed("properties"))?;+ if properties.len() > MAX_PREDICATES {+ return Err(ParseError::LimitExceeded("properties"));+ }+ properties.iter().map(PersonPredicate::parse).collect()+}++impl PersonPredicate {+ fn parse(value: &Value) -> Result<Self, ParseError> {+ let property = object(value, "property")?;+ closed(property, PROPERTY_FIELDS, "property")?;+ match string(property, "type")? {+ "person" => {}+ "cohort" | "group" | "flag" => return Err(ParseError::Unsupported("property.type")),+ _ => return Err(ParseError::Malformed("property.type")),+ }+ let key = string(property, "key")?;+ if key.is_empty() {+ return Err(ParseError::Malformed("property.key"));+ }+ let operator = match property.get("operator") {+ None | Some(Value::Null) => OperatorType::Exact,+ Some(value) => {+ let operator: OperatorType = serde_json::from_value(value.clone())+ .map_err(|_| ParseError::Malformed("property.operator"))?;+ // The legacy enum accepts aliases and cohort-only operators.+ if serde_json::to_value(operator).ok().as_ref() != Some(value)+ || matches!(+ operator,+ OperatorType::Between+ | OperatorType::NotBetween+ | OperatorType::In+ | OperatorType::NotIn+ | OperatorType::FlagEvaluatesTo+ )+ {+ return Err(ParseError::Malformed("property.operator"));+ }+ operator+ }+ };+ if property+ .get("group_type_index")+ .is_some_and(|v| !v.is_null())+ {+ return Err(ParseError::Malformed("property.group_type_index"));+ }+ let negation = match property.get("negation") {+ None | Some(Value::Null) => false,+ Some(Value::Bool(value)) => *value,+ _ => return Err(ParseError::Malformed("property.negation")),+ };+ for field in ["cohort_name", "label"] {+ if property+ .get(field)+ .is_some_and(|v| !v.is_null() && !v.is_string())+ {+ return Err(ParseError::Malformed("property.presentation"));+ }+ }+ if let Some(names) = property.get("group_key_names").filter(|v| !v.is_null()) {+ if !names+ .as_object()+ .is_some_and(|names| names.values().all(Value::is_string))+ {+ return Err(ParseError::Malformed("property.group_key_names"));+ }+ }+ let value = property.get("value").filter(|value| !value.is_null());+ validate_value(operator, value)?;+ Ok(Self {+ key: key.to_owned(),+ value: value.cloned(),+ operator,+ negation,+ })+ }++ pub(super) fn estimated_heap_bytes(&self) -> usize {+ self.key.capacity() + self.value.as_ref().map_or(0, estimate_json_heap_size)+ }+}++fn validate_value(operator: OperatorType, value: Option<&Value>) -> Result<(), ParseError> {+ use OperatorType::{+ Between, EndsWith, Exact, FlagEvaluatesTo, Gt, Gte, Icontains, IcontainsMulti, In,+ IsDateAfter, IsDateBefore, IsDateExact, IsNot, IsNotSet, IsSet, Lt, Lte, NotBetween,+ NotEndsWith, NotIcontains, NotIcontainsMulti, NotIn, NotRegex, NotStartsWith, Regex,+ SemverCaret, SemverEq, SemverGt, SemverGte, SemverLt, SemverLte, SemverNeq, SemverTilde,+ SemverWildcard, StartsWith,+ };+ let valid = match operator {+ Regex | NotRegex | Icontains | NotIcontains | StartsWith | NotStartsWith | EndsWith+ | NotEndsWith => value.is_some_and(Value::is_string),+ Gt | Gte | Lt | Lte => {+ value.is_some_and(|v| v.is_string() || v.as_f64().is_some_and(f64::is_finite))+ }+ IcontainsMulti | NotIcontainsMulti => value.is_some_and(Value::is_array),+ SemverGt | SemverGte | SemverLt | SemverLte | SemverEq | SemverNeq | SemverTilde+ | SemverCaret | SemverWildcard => value.and_then(Value::as_str).is_some_and(|s| {+ // The writer requires numeric components before the prerelease suffix;+ // the evaluator's broader version normalization cannot replace that check.+ let s = if operator == SemverWildcard {+ s.trim_end_matches(['.', '*'])+ } else {+ s+ };+ s.split('-')+ .next()+ .unwrap_or_default()+ .split('.')+ .take(3)+ .all(|part| part.trim().parse::<u64>().is_ok())+ && to_semver_representation(&Value::String(s.to_owned())).is_some()+ }),+ IsDateExact | IsDateAfter | IsDateBefore => {+ value.and_then(Value::as_str).is_some_and(|s| {+ dateparser::parse(s).is_ok() || parse_relative_date_parts(s).is_some()+ })+ }+ Exact | IsNot | IsSet | IsNotSet => true,+ Between | NotBetween | In | NotIn | FlagEvaluatesTo => false,+ };+ if valid {+ Ok(())+ } else {+ Err(ParseError::Malformed("property.value"))+ }+}diff --git a/rust/feature-flags/src/flags/config_v2/raw.rs b/rust/feature-flags/src/flags/config_v2/raw.rsnew file mode 100644index 000000000000..50205a6e8b1f--- /dev/null+++ b/rust/feature-flags/src/flags/config_v2/raw.rs@@ -0,0 +1,147 @@+use serde_json::value::RawValue;+use std::collections::HashSet;++use super::{ParseError, MAX_CONFIG_BYTES};++// Raw tokens prevent binary64 rounding from making an overprecise value valid.+pub(super) fn decimal_places_at_most(number: &str, places: i64) -> bool {+ let (mantissa, exponent) = number.split_once(['e', 'E']).unwrap_or((number, "0"));+ let mantissa = mantissa.strip_prefix('-').unwrap_or(mantissa);+ let mut digits = mantissa.bytes().filter(|&b| b != b'.');+ let digit_count = digits.clone().count();+ if digit_count == 0 || digits.any(|b| !b.is_ascii_digit()) {+ return false;+ }+ let trailing_zeros = mantissa+ .bytes()+ .rev()+ .filter(|&b| b != b'.')+ .take_while(|&b| b == b'0')+ .count();+ if trailing_zeros == digit_count {+ return true;+ }+ let Ok(exponent) = exponent.parse::<i64>() else {+ return false;+ };+ let fraction = mantissa.split_once('.').map_or(0, |(_, f)| f.len()) as i64;+ fraction+ .saturating_sub(trailing_zeros as i64)+ .saturating_sub(exponent)+ <= places+}++enum Container {+ Object {+ keys: HashSet<String>,+ key: String,+ expects_key: bool,+ is_rule: bool,+ },+ Array {+ is_rule_list: bool,+ },+}++pub(crate) fn validate_raw_document(document: &RawValue) -> Result<(), ParseError> {+ // RawValue already checked JSON syntax. Inspect tokens before Value loses+ // duplicate keys or rounds nonzero numbers to zero.+ let max_config_bytes = *MAX_CONFIG_BYTES;+ let text = document.get();+ let bytes = text.as_bytes();+ let mut containers = Vec::new();+ let mut compact_bytes = 0;+ let mut index = 0;+ while index < bytes.len() {+ let start = index;+ match bytes[index] {+ b' ' | b'\t' | b'\n' | b'\r' => {+ index += 1;+ continue;+ }+ b'"' => {+ index += 1;+ while bytes[index] != b'"' {+ if bytes[index] == b'\\' {+ index += 1;+ }+ index += 1;+ }+ index += 1;+ if let Some(Container::Object {+ keys,+ key,+ expects_key,+ ..+ }) = containers.last_mut()+ {+ if *expects_key {+ *key = serde_json::from_str(&text[start..index])+ .map_err(|_| ParseError::Malformed("filters"))?;+ if !keys.insert(key.clone()) {+ return Err(ParseError::Malformed("json_keys_unique"));+ }+ *expects_key = false;+ }+ }+ }+ b'{' => {+ let is_rule = matches!(+ containers.last(),+ Some(Container::Array { is_rule_list: true })+ );+ containers.push(Container::Object {+ keys: HashSet::new(),+ key: String::new(),+ expects_key: true,+ is_rule,+ });+ index += 1;+ }+ b'[' => {+ let is_rule_list = containers.len() == 1+ && matches!(containers.last(), Some(Container::Object { key, .. }) if key == "rules");+ containers.push(Container::Array { is_rule_list });+ index += 1;+ }+ b'}' | b']' => {+ containers.pop();+ index += 1;+ }+ b',' => {+ if let Some(Container::Object { expects_key, .. }) = containers.last_mut() {+ *expects_key = true;+ }+ index += 1;+ }+ b'-' | b'0'..=b'9' => {+ while index < bytes.len()+ && matches!(bytes[index], b'-' | b'+' | b'.' | b'e' | b'E' | b'0'..=b'9')+ {+ index += 1;+ }+ let token = &text[start..index];+ let number = token+ .parse::<f64>()+ .map_err(|_| ParseError::Malformed("number_is_binary64"))?;+ let mantissa = token.split(['e', 'E']).next().unwrap();+ if !number.is_finite()+ || (number == 0.0 && mantissa.bytes().any(|b| matches!(b, b'1'..=b'9')))+ {+ return Err(ParseError::Malformed("number_is_binary64"));+ }+ if matches!(containers.last(), Some(Container::Object { key, is_rule: true, .. }) if key == "rollout_percentage")+ && !decimal_places_at_most(token, 2)+ {+ return Err(ParseError::Malformed("rollout_percentage"));+ }+ }+ _ => index += 1,+ }+ compact_bytes += index - start;+ if compact_bytes > max_config_bytes {+ return Err(ParseError::LimitExceeded("filters"));+ }+ }+ Ok(())+}diff --git a/rust/feature-flags/src/flags/feature_flag_list.rs b/rust/feature-flags/src/flags/feature_flag_list.rsindex 3bf10e30867a..e15d1f544281 100644--- a/rust/feature-flags/src/flags/feature_flag_list.rs+++ b/rust/feature-flags/src/flags/feature_flag_list.rs@@ -180,25 +180,28 @@ impl FeatureFlagList {GROUP BY f.id, f.team_id, f.name, f.key, f.filters, f.deleted, f.active,f.ensure_experience_continuity, f.version, f.evaluation_runtime"#;- let flags_row = sqlx::query_as::<_, FeatureFlagRow>(query)- .bind(team_id)- .fetch_all(&mut *conn)- .await- .map_err(|e| {- tracing::error!(- "Failed to fetch feature flags from database for team {}: {}",- team_id,- e- );- let message = format!("Database query error: {e}");- FlagError::internal(anyhow::Error::new(e).context(message))- })?;+ let flags_row = sqlx::query_as::<+ _,+ FeatureFlagRow<sqlx::types::Json<Box<serde_json::value::RawValue>>>,+ >(query)+ .bind(team_id)+ .fetch_all(&mut *conn)+ .await+ .map_err(|e| {+ tracing::error!(+ "Failed to fetch feature flags from database for team {}: {}",+ team_id,+ e+ );+ let message = format!("Database query error: {e}");+ FlagError::internal(anyhow::Error::new(e).context(message))+ })?;let mut malformed_filter_flags: u64 = 0;let flags: Vec<FeatureFlag> = flags_row.into_iter().filter_map(|row| {- match crate::flags::config_format::decode_filters(row.filters) {+ match crate::flags::config_format::decode_raw_filters(row.filters.0) {Ok(filters) => Some(FeatureFlag {id: row.id,team_id: row.team_id,@@ -1404,6 +1407,7 @@ mod tests {key: "test_flag".to_string(),has_experiment: false,filters: FlagFilters {+ non_v1: None,groups: vec![FlagPropertyGroup {properties: Some(vec![PropertyFilter {diff --git a/rust/feature-flags/src/flags/flag_models.rs b/rust/feature-flags/src/flags/flag_models.rsindex 414dcc5f6679..7b77a7b0669f 100644--- a/rust/feature-flags/src/flags/flag_models.rs+++ b/rust/feature-flags/src/flags/flag_models.rs@@ -194,11 +194,13 @@ pub struct MultivariateFlagOptions {// Runtime Python mirror: products/feature_flags/backend/api/filters_schema.py validates// filters against these shapes at write time — keep field shapes in sync (issue #50084).//-// `filters` is customer-writable JSONB that Django stores unvalidated, so every struct-// reachable from here must carry `#[serde(flatten)] extra` and be weighed in+// V1 `filters` is customer-writable JSONB that Django stores unvalidated, so each v1+// struct reachable from here must carry `#[serde(flatten)] extra` and be weighed in// `estimate_filters_size`. Skipping either drops customer keys, or hides their bytes.-#[derive(Debug, Clone, Deserialize, Serialize, Default)]+#[derive(Clone, Deserialize, Serialize, Default)]pub struct FlagFilters {+ #[serde(skip)]+ pub non_v1: Option<Arc<super::config_v2::NonV1Config>>,#[serde(default)]pub groups: Vec<FlagPropertyGroup>,#[serde(default, skip_serializing_if = "Option::is_none")]@@ -252,6 +254,39 @@ pub struct FlagFilters {pub extra: serde_json::Map<String, serde_json::Value>,}+impl std::fmt::Debug for FlagFilters {+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {+ let Self {+ non_v1,+ groups,+ multivariate,+ aggregation_group_type_index,+ payloads,+ feature_enrollment,+ holdout,+ early_exit,+ extra,+ } = self;+ if !self.is_v1() {+ return f+ .debug_struct("FlagFilters")+ .field("non_v1", non_v1)+ .finish_non_exhaustive();+ }+ f.debug_struct("FlagFilters")+ .field("non_v1", non_v1)+ .field("groups", groups)+ .field("multivariate", multivariate)+ .field("aggregation_group_type_index", aggregation_group_type_index)+ .field("payloads", payloads)+ .field("feature_enrollment", feature_enrollment)+ .field("holdout", holdout)+ .field("early_exit", early_exit)+ .field("extra", extra)+ .finish()+ }+}+pub type FeatureFlagId = i32;/// Defines which identifier is used for bucketing users into rollout and variants@@ -279,7 +314,7 @@ pub struct FeatureFlag {#[serde(skip_serializing_if = "Option::is_none")]pub name: Option<String>,pub key: String,- // Non-v1 documents stay opaque in `extra`; check the format before reading v1 fields.+ // Check the format before reading v1 fields; non-v1 documents retain their raw JSON.#[serde(deserialize_with = "crate::flags::config_format::deserialize_filters",serialize_with = "crate::flags::config_format::serialize_filters"@@ -338,13 +373,13 @@ impl FeatureFlag {/// Row struct for PostgreSQL queries via sqlx. The `evaluation_tags` column is/// always named `evaluation_tags` in the SQL query, so no alias is needed.-#[derive(Debug, Default, Serialize, sqlx::FromRow)]-pub struct FeatureFlagRow {+#[derive(Default, Serialize, sqlx::FromRow)]+pub struct FeatureFlagRow<F = serde_json::Value> {pub id: i32,pub team_id: i32,pub name: Option<String>,pub key: String,- pub filters: serde_json::Value,+ pub filters: F,pub deleted: bool,pub active: bool,pub ensure_experience_continuity: Option<bool>,@@ -360,6 +395,41 @@ pub struct FeatureFlagRow {pub has_experiment: bool,}+impl<F> std::fmt::Debug for FeatureFlagRow<F> {+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {+ let Self {+ id,+ team_id,+ name,+ key,+ filters: _,+ deleted,+ active,+ ensure_experience_continuity,+ version,+ evaluation_runtime,+ evaluation_tags,+ bucketing_identifier,+ has_experiment,+ } = self;+ f.debug_struct("FeatureFlagRow")+ .field("id", id)+ .field("team_id", team_id)+ .field("name", name)+ .field("key", key)+ .field("filters", &"<redacted>")+ .field("deleted", deleted)+ .field("active", active)+ .field("ensure_experience_continuity", ensure_experience_continuity)+ .field("version", version)+ .field("evaluation_runtime", evaluation_runtime)+ .field("evaluation_tags", evaluation_tags)+ .field("bucketing_identifier", bucketing_identifier)+ .field("has_experiment", has_experiment)+ .finish()+ }+}+/// Request-scoped view of flag definitions plus the per-request filter set./// All shared fields are `Arc`-backed so `clone()` is a refcount bump rather/// than a deep copy.@@ -438,6 +508,10 @@ fn estimate_filters_size(filters: &FlagFilters) -> usize {.map_or(0, |h| estimate_json_map_size(&h.extra));groups_size+ + filters+ .non_v1+ .as_ref()+ .map_or(0, |config| config.estimated_heap_bytes())+ estimate_json_map_size(&filters.extra)+ multivariate_size+ holdout_sizediff --git a/rust/feature-flags/src/flags/flag_service.rs b/rust/feature-flags/src/flags/flag_service.rsindex ff166dd41277..cdd6ebed8d4b 100644--- a/rust/feature-flags/src/flags/flag_service.rs+++ b/rust/feature-flags/src/flags/flag_service.rs@@ -433,6 +433,7 @@ mod tests {key: "beta_feature".to_string(),has_experiment: false,filters: FlagFilters {+ non_v1: None,groups: vec![FlagPropertyGroup {properties: Some(vec![PropertyFilter {key: "country".to_string(),@@ -471,6 +472,7 @@ mod tests {key: "new_ui".to_string(),has_experiment: false,filters: FlagFilters {+ non_v1: None,groups: vec![],multivariate: None,aggregation_group_type_index: None,@@ -495,6 +497,7 @@ mod tests {key: "premium_feature".to_string(),has_experiment: false,filters: FlagFilters {+ non_v1: None,groups: vec![FlagPropertyGroup {properties: Some(vec![PropertyFilter {key: "is_premium".to_string(),@@ -629,6 +632,7 @@ mod tests {deleted: false,active: i % 2 == 0,filters: FlagFilters {+ non_v1: None,groups: vec![FlagPropertyGroup {properties: Some(vec![PropertyFilter {key: format!("property_key_{i}"),diff --git a/rust/feature-flags/src/flags/mod.rs b/rust/feature-flags/src/flags/mod.rsindex 0535a4bfb4dc..f3c7db1f2680 100644--- a/rust/feature-flags/src/flags/mod.rs+++ b/rust/feature-flags/src/flags/mod.rs@@ -3,6 +3,7 @@ pub mod cache_invalidation;pub mod cache_shadow;pub mod cache_writer;pub(crate) mod config_format;+pub mod config_v2;pub mod feature_flag_list;pub mod flag_analytics;pub mod flag_definitions_cache;diff --git a/rust/feature-flags/src/flags/test_flag_matching.rs b/rust/feature-flags/src/flags/test_flag_matching.rsindex 35254af79567..4e3d821fce88 100644--- a/rust/feature-flags/src/flags/test_flag_matching.rs+++ b/rust/feature-flags/src/flags/test_flag_matching.rs@@ -348,6 +348,7 @@ mod tests {team_id: team.id,key: "group_flag".mock_into(),filters: FlagFilters {+ non_v1: None,groups: vec![FlagPropertyGroup {properties: Some(vec![PropertyFilter {key: "name".to_string(),@@ -434,6 +435,7 @@ mod tests {let flag = mock!(FeatureFlag,team_id: team.id,filters: FlagFilters {+ non_v1: None,groups: vec![FlagPropertyGroup {properties: Some(vec![PropertyFilter {key: "industry".to_string(),@@ -522,6 +524,7 @@ mod tests {let flag = mock!(FeatureFlag,team_id: team.id,filters: FlagFilters {+ non_v1: None,groups: vec![FlagPropertyGroup {properties: Some(vec![mock!(PropertyFilter,@@ -758,6 +761,7 @@ mod tests {team_id: team.id,key: "leaf_flag".mock_into(),filters: FlagFilters {+ non_v1: None,groups: vec![FlagPropertyGroup {properties: Some(vec![PropertyFilter {@@ -1212,6 +1216,7 @@ mod tests {team_id: team.id,key: "leaf_flag".mock_into(),filters: FlagFilters {+ non_v1: None,groups: vec![FlagPropertyGroup {properties: Some(vec![PropertyFilter {@@ -2815,6 +2820,7 @@ mod tests {name: "Complex Flag".mock_into(),key: "complex_flag".mock_into(),filters: FlagFilters {+ non_v1: None,groups: vec![FlagPropertyGroup {properties: Some(vec![PropertyFilter {@@ -3064,6 +3070,7 @@ mod tests {let flag = mock!(FeatureFlag,team_id: team.id,filters: FlagFilters {+ non_v1: None,groups: vec![FlagPropertyGroup {properties: Some(vec![PropertyFilter {key: "id".to_string(),@@ -3176,6 +3183,7 @@ mod tests {let flag = mock!(FeatureFlag,team_id: team.id,filters: FlagFilters {+ non_v1: None,groups: vec![FlagPropertyGroup {properties: Some(vec![PropertyFilter {key: "id".to_string(),@@ -3273,6 +3281,7 @@ mod tests {let flag = mock!(FeatureFlag,team_id: team.id,filters: FlagFilters {+ non_v1: None,groups: vec![FlagPropertyGroup {properties: Some(vec![PropertyFilter {key: "id".to_string(),@@ -3370,6 +3379,7 @@ mod tests {let flag = mock!(FeatureFlag,team_id: team.id,filters: FlagFilters {+ non_v1: None,groups: vec![FlagPropertyGroup {properties: Some(vec![PropertyFilter {key: "id".to_string(),@@ -3488,6 +3498,7 @@ mod tests {let flag = mock!(FeatureFlag,team_id: team.id,filters: FlagFilters {+ non_v1: None,groups: vec![FlagPropertyGroup {properties: Some(vec![PropertyFilter {key: "id".to_string(),@@ -3585,6 +3596,7 @@ mod tests {let flag = mock!(FeatureFlag,team_id: team.id,filters: FlagFilters {+ non_v1: None,groups: vec![FlagPropertyGroup {properties: Some(vec![PropertyFilter {key: "id".to_string(),@@ -3682,6 +3694,7 @@ mod tests {let flag = mock!(FeatureFlag,team_id: team.id,filters: FlagFilters {+ non_v1: None,groups: vec![FlagPropertyGroup {properties: Some(vec![PropertyFilter {key: "id".to_string(),@@ -3742,6 +3755,7 @@ mod tests {team_id: team_id,key: "freeze-flag".mock_into(),filters: FlagFilters {+ non_v1: None,groups: vec![group],multivariate: Some(multivariate),aggregation_group_type_index: None,@@ -3930,6 +3944,7 @@ mod tests {let flag = mock!(FeatureFlag,team_id: team.id,filters: FlagFilters {+ non_v1: None,groups: vec![FlagPropertyGroup {properties: Some(vec![PropertyFilter {key: "id".to_string(),@@ -4014,6 +4029,7 @@ mod tests {let flag = mock!(FeatureFlag,team_id: team.id,filters: FlagFilters {+ non_v1: None,groups: vec![FlagPropertyGroup {properties: Some(vec![PropertyFilter {key: "id".to_string(),@@ -4113,6 +4129,7 @@ mod tests {let flag = mock!(FeatureFlag,team_id: team.id,filters: FlagFilters {+ non_v1: None,groups: vec![FlagPropertyGroup {properties: Some(vec![PropertyFilter {key: "id".to_string(),@@ -4242,6 +4259,7 @@ mod tests {mock!(FeatureFlag,team_id: team_id,filters: FlagFilters {+ non_v1: None,groups: vec![FlagPropertyGroup {properties: Some(vec![PropertyFilter {key: "id".to_string(),@@ -4761,6 +4779,7 @@ mod tests {team_id: team.id,key: "flag_continuity".mock_into(),filters: FlagFilters {+ non_v1: None,groups: vec![FlagPropertyGroup {properties: Some(vec![PropertyFilter {key: "email".to_string(),@@ -4867,6 +4886,7 @@ mod tests {team_id: team.id,key: "flag_continuity_missing".mock_into(),filters: FlagFilters {+ non_v1: None,groups: vec![FlagPropertyGroup {properties: Some(vec![PropertyFilter {key: "email".to_string(),@@ -4956,6 +4976,7 @@ mod tests {team_id: team.id,key: "flag_continuity_mix".mock_into(),filters: FlagFilters {+ non_v1: None,groups: vec![FlagPropertyGroup {properties: Some(vec![PropertyFilter {key: "email".to_string(),@@ -4990,6 +5011,7 @@ mod tests {team_id: team.id,key: "flag_no_continuity_mix".mock_into(),filters: FlagFilters {+ non_v1: None,groups: vec![FlagPropertyGroup {properties: Some(vec![PropertyFilter {key: "age".to_string(),@@ -5096,6 +5118,7 @@ mod tests {team_id: team.id,key: "test_flag".mock_into(),filters: FlagFilters {+ non_v1: None,groups: vec![FlagPropertyGroup {properties: Some(vec![PropertyFilter {key: "email".to_string(),@@ -5173,6 +5196,7 @@ mod tests {team_id: team.id,key: "test_flag_invalid".mock_into(),filters: FlagFilters {+ non_v1: None,groups: vec![FlagPropertyGroup {properties: Some(vec![PropertyFilter {key: "email".to_string(),@@ -5290,6 +5314,7 @@ mod tests {name: "Flag with holdout".mock_into(),key: "flag-with-gt-filter".mock_into(),filters: FlagFilters {+ non_v1: None,groups: vec![FlagPropertyGroup {properties: Some(vec![PropertyFilter {key: "$some_prop".to_string(),@@ -5326,6 +5351,7 @@ mod tests {name: "Other flag with holdout".mock_into(),key: "other-flag-with-gt-filter".mock_into(),filters: FlagFilters {+ non_v1: None,groups: vec![FlagPropertyGroup {properties: Some(vec![PropertyFilter {key: "$some_prop".to_string(),@@ -5362,6 +5388,7 @@ mod tests {name: "Flag".mock_into(),key: "other-flag-without-holdout-with-gt-filter".mock_into(),filters: FlagFilters {+ non_v1: None,groups: vec![FlagPropertyGroup {properties: Some(vec![PropertyFilter {key: "$some_prop".to_string(),@@ -5536,6 +5563,7 @@ mod tests {name: "Flag with new holdout".mock_into(),key: "flag-with-gt-filter".mock_into(),filters: FlagFilters {+ non_v1: None,groups: vec![FlagPropertyGroup {properties: Some(vec![PropertyFilter {key: "$some_prop".to_string(),@@ -5661,6 +5689,7 @@ mod tests {team_id: team.id,key: "flag-both-formats".mock_into(),filters: FlagFilters {+ non_v1: None,groups: vec![FlagPropertyGroup {properties: Some(vec![PropertyFilter {key: "$some_prop".to_string(),@@ -5736,6 +5765,7 @@ mod tests {team_id: team.id,key: "flag-zero-holdout".mock_into(),filters: FlagFilters {+ non_v1: None,groups: vec![FlagPropertyGroup {properties: Some(vec![PropertyFilter {key: "$some_prop".to_string(),@@ -5843,6 +5873,7 @@ mod tests {team_id: team.id,key: "flag-full-holdout".mock_into(),filters: FlagFilters {+ non_v1: None,groups: vec![FlagPropertyGroup {properties: Some(vec![PropertyFilter {key: "$some_prop".to_string(),@@ -5933,6 +5964,7 @@ mod tests {key: "beta-feature".to_string(),has_experiment: false,filters: FlagFilters {+ non_v1: None,groups: vec![FlagPropertyGroup {properties: None,rollout_percentage: None,@@ -6096,6 +6128,7 @@ mod tests {let flag = mock!(FeatureFlag,team_id: team.id,filters: FlagFilters {+ non_v1: None,groups: vec![FlagPropertyGroup {properties: Some(vec![PropertyFilter {key: "id".to_string(),@@ -6160,6 +6193,7 @@ mod tests {let flag = mock!(FeatureFlag,team_id: team.id,filters: FlagFilters {+ non_v1: None,groups: vec![FlagPropertyGroup {properties: Some(vec![PropertyFilter {key: "email".to_string(),@@ -6233,6 +6267,7 @@ mod tests {let flag = mock!(FeatureFlag,team_id: team.id,filters: FlagFilters {+ non_v1: None,groups: vec![FlagPropertyGroup {properties: Some(vec![]),rollout_percentage: Some(100.0),@@ -6682,6 +6717,7 @@ mod tests {let flag = mock!(FeatureFlag,team_id: team.id,filters: FlagFilters {+ non_v1: None,groups: vec![// Condition 1: Requires app_version, focus, osFlagPropertyGroup {@@ -6944,6 +6980,7 @@ mod tests {let flag = mock!(FeatureFlag,team_id: team.id,filters: FlagFilters {+ non_v1: None,groups: vec![// Condition 1: Requires plan, region, feature_access (group properties)FlagPropertyGroup {@@ -7257,6 +7294,7 @@ mod tests {key: "test_order_flag".to_string(),has_experiment: false,filters: FlagFilters {+ non_v1: None,groups: vec![FlagPropertyGroup {variant: None, // No variant override@@ -8248,6 +8286,7 @@ mod tests {team_id: team.id,key: "opt_multivariate".mock_into(),filters: FlagFilters {+ non_v1: None,groups: vec![FlagPropertyGroup {properties: None,rollout_percentage: Some(100.0),@@ -8359,6 +8398,7 @@ mod tests {team_id: team.id,key: "opt_multivariate_100".mock_into(),filters: FlagFilters {+ non_v1: None,groups: vec![FlagPropertyGroup {properties: None,rollout_percentage: Some(100.0),@@ -8535,6 +8575,7 @@ mod tests {team_id: team.id,key: "flag_optimizable".mock_into(),filters: FlagFilters {+ non_v1: None,groups: vec![FlagPropertyGroup {properties: None,rollout_percentage: Some(100.0),@@ -8560,6 +8601,7 @@ mod tests {team_id: team.id,key: "flag_needs_lookup".mock_into(),filters: FlagFilters {+ non_v1: None,groups: vec![FlagPropertyGroup {properties: None,rollout_percentage: Some(50.0),@@ -8585,6 +8627,7 @@ mod tests {team_id: team.id,key: "flag_no_continuity".mock_into(),filters: FlagFilters {+ non_v1: None,groups: vec![FlagPropertyGroup {properties: None,rollout_percentage: Some(100.0),@@ -8701,6 +8744,7 @@ mod tests {team_id: team.id,key: "flag_optimizable".mock_into(),filters: FlagFilters {+ non_v1: None,groups: vec![FlagPropertyGroup {properties: None,rollout_percentage: Some(100.0),@@ -8726,6 +8770,7 @@ mod tests {team_id: team.id,key: "flag_needs_lookup".mock_into(),filters: FlagFilters {+ non_v1: None,groups: vec![FlagPropertyGroup {properties: None,rollout_percentage: Some(50.0),@@ -8933,6 +8978,7 @@ mod tests {name: "Feature Enrollment Flag".mock_into(),key: "my-feature".mock_into(),filters: FlagFilters {+ non_v1: None,groups: vec![FlagPropertyGroup {properties: None,rollout_percentage: Some(0.0),@@ -8997,6 +9043,7 @@ mod tests {name: "Feature Enrollment Flag".mock_into(),key: "my-feature".mock_into(),filters: FlagFilters {+ non_v1: None,groups: vec![FlagPropertyGroup {properties: None,rollout_percentage: Some(0.0),@@ -9058,6 +9105,7 @@ mod tests {let project_flag = mock!(FeatureFlag,team_id: team.id,filters: FlagFilters {+ non_v1: None,groups: vec![FlagPropertyGroup {properties: Some(vec![PropertyFilter {key: "name".to_string(),@@ -9091,6 +9139,7 @@ mod tests {team_id: team.id,name: "org_flag".mock_into(),filters: FlagFilters {+ non_v1: None,groups: vec![FlagPropertyGroup {properties: Some(vec![PropertyFilter {key: "tier".to_string(),@@ -9396,6 +9445,7 @@ mod tests {let flag = mock!(FeatureFlag,team_id: team.id,filters: FlagFilters {+ non_v1: None,groups: vec![FlagPropertyGroup {properties: Some(vec![PropertyFilter {key: "industry".to_string(),@@ -9490,6 +9540,7 @@ mod tests {team_id: team.id,key: "mixed-flag".mock_into(),filters: FlagFilters {+ non_v1: None,groups: vec![FlagPropertyGroup {properties: Some(vec![PropertyFilter {key: "industry".to_string(),@@ -9568,6 +9619,7 @@ mod tests {team_id: team.id,key: "person-flag".mock_into(),filters: FlagFilters {+ non_v1: None,groups: vec![FlagPropertyGroup {properties: Some(vec![PropertyFilter {key: "email".to_string(),@@ -9636,6 +9688,7 @@ mod tests {team_id: team.id,key: "mixed-flag".mock_into(),filters: FlagFilters {+ non_v1: None,groups: vec![// Condition 0: group-aggregated (organization)FlagPropertyGroup {@@ -9821,6 +9874,7 @@ mod tests {team_id: team.id,key: "mixed-flag".mock_into(),filters: FlagFilters {+ non_v1: None,groups,multivariate: None,aggregation_group_type_index: None,@@ -9880,6 +9934,7 @@ mod tests {team_id: team.id,key: "mixed-flag".mock_into(),filters: FlagFilters {+ non_v1: None,groups: vec![// Condition 0: group-aggregatedFlagPropertyGroup {@@ -9984,6 +10039,7 @@ mod tests {team_id: team.id,key: "legacy-group-flag".mock_into(),filters: FlagFilters {+ non_v1: None,groups: vec![FlagPropertyGroup {properties: Some(vec![PropertyFilter {key: "industry".to_string(),@@ -10064,6 +10120,7 @@ mod tests {team_id: team.id,key: "override-flag".mock_into(),filters: FlagFilters {+ non_v1: None,groups: vec![FlagPropertyGroup {properties: Some(vec![PropertyFilter {key: "industry".to_string(),@@ -10142,6 +10199,7 @@ mod tests {team_id: team.id,key: "variant-flag".mock_into(),filters: FlagFilters {+ non_v1: None,groups: vec![// Condition 0: group-aggregated — won't match (group not provided)FlagPropertyGroup {@@ -10247,6 +10305,7 @@ mod tests {team_id: team.id,key: "no-match-flag".mock_into(),filters: FlagFilters {+ non_v1: None,groups: vec![// Condition 0: group-aggregated — no group providedFlagPropertyGroup {@@ -10339,6 +10398,7 @@ mod tests {team_id: team.id,key: "rollout-mixed".mock_into(),filters: FlagFilters {+ non_v1: None,groups: vec![// Condition 0: group-aggregated, 100% rollout, no propertiesFlagPropertyGroup {@@ -10729,6 +10789,7 @@ mod tests {key: "early-exit-test-flag".mock_into(),active: true,filters: FlagFilters {+ non_v1: None,groups: vec![FlagPropertyGroup {properties: Some(vec![PropertyFilter {@@ -10814,6 +10875,7 @@ mod tests {key: "no-early-exit-test-flag".mock_into(),active: true,filters: FlagFilters {+ non_v1: None,groups: vec![FlagPropertyGroup {properties: Some(vec![PropertyFilter {@@ -10898,6 +10960,7 @@ mod tests {key: "early-exit-non-first".mock_into(),active: true,filters: FlagFilters {+ non_v1: None,groups: vec![// Condition 0: property does not match — NoConditionMatch, no early exitFlagPropertyGroup {@@ -11004,6 +11067,7 @@ mod tests {key: "early-exit-no-condition-match".mock_into(),active: true,filters: FlagFilters {+ non_v1: None,groups: vec![// Condition 0: property does not match — NoConditionMatch, must not early exitFlagPropertyGroup {@@ -11091,6 +11155,7 @@ mod tests {key: "early-exit-multivariate".mock_into(),active: true,filters: FlagFilters {+ non_v1: None,groups: vec![FlagPropertyGroup {properties: Some(vec![PropertyFilter {@@ -11192,6 +11257,7 @@ mod tests {key: "early-exit-group".mock_into(),active: true,filters: FlagFilters {+ non_v1: None,groups: vec![FlagPropertyGroup {properties: Some(vec![PropertyFilter {@@ -11322,6 +11388,7 @@ mod tests {key: "early-exit-cohort-no-match".mock_into(),active: true,filters: FlagFilters {+ non_v1: None,groups: vec![// Condition 0: NOT in cohort → NoConditionMatch, must NOT trigger early_exitFlagPropertyGroup {@@ -11404,6 +11471,7 @@ mod tests {key: flag_key.mock_into(),active: true,filters: FlagFilters {+ non_v1: None,groups: vec![// Condition 0: would trigger early exit if the enrollment check didn't win firstFlagPropertyGroup {@@ -11490,6 +11558,7 @@ mod tests {key: "early-exit-holdout".mock_into(),active: true,filters: FlagFilters {+ non_v1: None,groups: vec![// Condition 0: would trigger early exit if holdout didn't win firstFlagPropertyGroup {diff --git a/rust/feature-flags/src/metrics/consts.rs b/rust/feature-flags/src/metrics/consts.rsindex 831a52c42967..fe6ef097db83 100644--- a/rust/feature-flags/src/metrics/consts.rs+++ b/rust/feature-flags/src/metrics/consts.rs@@ -431,6 +431,9 @@ pub const FLAG_QUOTA_LIMITED_COUNTER: &str = "flags_quota_limited_total";// Labels: reason (missing_device_id, missing_group_type)pub const FLAG_CONDITION_SKIPPED_COUNTER: &str = "flags_condition_skipped_total";+// V2 ingress outcomes use fixed labels and never include configuration values.+pub const FLAG_V2_PARSE_COUNTER: &str = "flags_v2_config_parse_total";+// Incremented once per flag left out of a team's payload because its `filters` JSON// does not deserialize into FlagFilters. A property filter with no `"type"` key is// one such blob, because PropertyFilter requires prop_type, and serde fails thediff --git a/rust/feature-flags/src/properties/relative_date.rs b/rust/feature-flags/src/properties/relative_date.rsindex 10cdc38f5b0c..6c3acb48321c 100644--- a/rust/feature-flags/src/properties/relative_date.rs+++ b/rust/feature-flags/src/properties/relative_date.rs@@ -69,21 +69,19 @@ pub(crate) fn naive_to_utc_in_tz(naive: NaiveDateTime, tz: Tz) -> Option<DateTim}}+pub(crate) fn parse_relative_date_parts(date_str: &str) -> Option<(i64, &str)> {+ let captures = RELATIVE_DATE_REGEX.captures(date_str)?;+ let number = captures.name("number")?.as_str().parse::<i64>().ok()?;+ (number < 10_000).then_some((number, captures.name("interval")?.as_str()))+}+/// Apply the relativedelta-style subtraction purely on a naive wall clock.////// All arithmetic is timezone-agnostic here; callers decide how to anchor `now`/// and how to interpret the result. Time-of-day (including sub-second precision)/// is preserved across calendar month/year shifts.fn parse_relative_date_naive(date_str: &str, now: NaiveDateTime) -> Option<NaiveDateTime> {- let captures = RELATIVE_DATE_REGEX.captures(date_str)?;-- let number: i64 = captures.name("number")?.as_str().parse().ok()?;- if number >= 10_000 {- // Guard against overflow, disallow numbers greater than 10_000- return None;- }-- let interval = captures.name("interval")?.as_str();+ let (number, interval) = parse_relative_date_parts(date_str)?;match interval {"h" => Some(now - Duration::hours(number)),diff --git a/rust/feature-flags/src/utils/json_size.rs b/rust/feature-flags/src/utils/json_size.rsindex 27a4e4eb57e7..1459acef8127 100644--- a/rust/feature-flags/src/utils/json_size.rs+++ b/rust/feature-flags/src/utils/json_size.rs@@ -1,3 +1,5 @@+use serde_json::Value;+/// Estimates the serialized size of a JSON value with minimal allocation.////// Walks the JSON tree and approximates the byte length of the serialized@@ -44,6 +46,30 @@ pub fn estimate_json_size(value: &serde_json::Value) -> usize {}}+/// Estimates heap allocations, rather than serialized bytes, for retained v2 predicate values.+pub fn estimate_json_heap_size(value: &Value) -> usize {+ match value {+ Value::Null | Value::Bool(_) | Value::Number(_) => 0,+ Value::String(value) => value.capacity(),+ Value::Array(values) => {+ values.capacity() * std::mem::size_of::<Value>()+ + values.iter().map(estimate_json_heap_size).sum::<usize>()+ }+ Value::Object(values) => {+ // BTreeMap exposes no allocation capacity. Budget a root node and+ // spare entry/child slots conservatively instead of weighing JSON text.+ let entries = values.len()+ * (3 * std::mem::size_of::<(String, Value)>() + 4 * std::mem::size_of::<usize>());+ let root = if values.is_empty() { 0 } else { 1024 };+ root + entries+ + values+ .iter()+ .map(|(key, value)| key.capacity() + estimate_json_heap_size(value))+ .sum::<usize>()+ }+ }+}+/// Estimates the serialized size of a `serde_json::Map` as if it were flattened/// into a parent object (no surrounding `{}`). Used to weigh `#[serde(flatten)]/// extra` passthrough maps that capture unknown JSONB keys on flag-filter structs:diff --git a/rust/feature-flags/src/utils/mock.rs b/rust/feature-flags/src/utils/mock.rsindex aeb31e68e4ba..4bec0d90914c 100644--- a/rust/feature-flags/src/utils/mock.rs+++ b/rust/feature-flags/src/utils/mock.rs@@ -324,6 +324,7 @@ mod tests {deleted: false,team_id: 99,filters: FlagFilters {+ non_v1: None,groups: vec![FlagPropertyGroup {properties: Some(vec![crate::properties::property_models::PropertyFilter {key: "country".to_string(),diff --git a/rust/feature-flags/src/utils/test_utils.rs b/rust/feature-flags/src/utils/test_utils.rsindex 4d978e13ca41..555c4c11e34d 100644--- a/rust/feature-flags/src/utils/test_utils.rs+++ b/rust/feature-flags/src/utils/test_utils.rs@@ -176,8 +176,17 @@ pub async fn insert_flags_with_metadata_for_team_in_redis("evaluation_metadata": evaluation_metadata}).to_string();+ write_flags_wire_json_to_redis(client, team_id, json_string).await+}++/// Preserves raw numeric tokens that Value-based test setup would round away.+pub async fn write_flags_wire_json_to_redis(+ client: Arc<dyn RedisClientTrait + Send + Sync>,+ team_id: i32,+ wire_json: String,+) -> Result<(), Error> {let pickled_bytes =- serde_pickle::to_vec(&json_string, Default::default()).expect("Failed to pickle flags");+ serde_pickle::to_vec(&wire_json, Default::default()).expect("Failed to pickle flags");let cache_key = format!("posthog:1:cache/teams/{team_id}/feature_flags/flags.json");client.set_bytes(cache_key, pickled_bytes, None).await?;diff --git a/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/README.md b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/README.mdnew file mode 100644index 000000000000..dbfe6569a055--- /dev/null+++ b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/README.md@@ -0,0 +1,163 @@+# Feature Flag Rules v2 contract++This package defines Feature Flag Rules v2 configuration, definitions, response, management diagnostic and event contracts, plus the canonical evaluation corpus.+Contract package 2.1.0 contains config schema 1.0.0, registry 2.0.0, corpus 1.1.0, and wire schemas/fixtures 1.0.0.+The contract version is independent of the test harness package version.++The package does not enable config writes or runtime evaluation.+It reserves number and object values for later writer support.++## Terminology and OpenFeature translation++These are PostHog configuration names compatible with OpenFeature's evaluation and provider interfaces.+OpenFeature does not prescribe this configuration schema; person assignment, experiments, rule types, and variant weights are PostHog vocabulary choices.++default_value is the flag default; the caller default is supplied to the SDK accessor.+On a normal no-match result, a configured flag default of false wins over a caller default of true.+A null flag default delegates to the caller default.+On abnormal execution, OpenFeature returns the caller default regardless of the configured flag default.++Each variants[].weight is a percentage of subjects enrolled by the rule, and the weights sum to exactly 100.+The separate rollout_percentage controls enrollment into the rule.++Person flags may explicitly set assign_by to person or omit it.+Group flags declare aggregation_group_type_index (including index 0) and must omit assign_by on every rule; the schema enforces this so assignment uses the flag aggregation key.++Experiment rules require an integer experiment_id linking an Experiment row.+An experiment_id of null is invalid in this contract.+Non-experiment variant splits are reserved for a possible future extension; their evaluation reason and exposure semantics are not defined here.++rollout_miss means a terminal miss under on_rollout_miss: return_default.+A continuing miss moves evaluation to the next rule and contributes neither a reason code nor metadata from the missed rule (including rule_id and condition_index) to the final result. The final result uses the terminating rule's reason and metadata, or no_rule_match if no rule terminates.+no_rule_match means no rule produced a terminal result, including when targeting matched but rollout missed with continue.+dependency_error covers unknown, cyclic, and otherwise unresolvable dependencies.++The OpenFeature mapping also depends on the provider's evaluation-context binding.+missing_group_key maps to INVALID_CONTEXT when required group membership is missing from additional context fields, even if a person targetingKey is present.+Only a provider that binds the group key to OpenFeature targetingKey uses TARGETING_KEY_MISSING when that field is missing.+Percentage rollout inclusion maps to TARGETING_MATCH by contract choice; OpenFeature also describes pseudorandom assignment with SPLIT and permits custom reasons.++## Package contents++- schemas/config.schema.json contains the JSON Schema 2020-12 config contract.+- registries/literals.json owns shared protocol literals, semantic constraints, and the OpenFeature reason mapping.+- fixtures/config/valid contains configs that the schema must accept.+- fixtures/config/invalid contains configs that the schema must reject.+- corpus/hash_sha1_60_v1.json contains exact sha1_60_v1 vectors, white-box threshold and variant boundary vectors, and v1-to-v2 seed parity inputs.+- corpus/v1_evaluation.json contains lock-down fixtures for the frozen version 1 evaluation arm.+- corpus/legacy_projection.json records how a version 1 outcome projects into each response protocol version.+- schemas/hash_sha1_60_v1.schema.json, schemas/v1_evaluation.schema.json, and schemas/legacy_projection.schema.json are the companion schemas for the corpus files.+- manifest.json assigns stable fixture and case IDs and declares the compatibility policy.+- SHA256SUMS records the SHA-256 digest for each package file except itself.++In the config and corpus schemas, objects marked with x-posthog-open-object accept arbitrary keys by design; every other object is closed.+The marker documents this choice for the contract tests; additionalProperties defines how those keys are validated.++The config schema enforces all constraints that the standard can express, including the 20-level object-value depth limit.+Depth counts object and array containers, with the returned object at level 1; scalar leaves add no level.+The registry also identifies constraints that need a semantic or parser-level validator, such as unique rule IDs and variant keys, and exact variant weight totals.++Docker releases include contracts/ directly. MANIFEST.in also includes this contract in Python source distributions for source-artifact verification.+It does not install the contract as wheel package data; consumers should pin the repository files or use the source distribution or Docker image.++## Component versions++Each artifact carries its own component version in manifest.json.+The config schema stays at 1.0.0 because contract 2.0.0 does not change its published bytes or accepted configs.+The literal registry is 2.0.0: it removes the four unused management warning codes (`EXPERIMENT_VALUE_COLLISION`, `SDK_REMOTE_FALLBACK_REQUIRED`, `SDK_EXPERIMENT_CONTEXT_MISSING`, `LEGACY_PROJECTION_LIMITED`) from the `warning_codes` published in registry 1.0.0 (contract 1.2.0), which the compatibility policy classifies as a major change; the five remaining codes are unchanged.+The corpus files and their companion schemas are corpus version 1.1.0.+Contract package 2.1.0 adds config fixtures for the targeted-release and percentage-rollout family; it changes no published schema, registry, corpus or fixture bytes.++## Corpus rules++Every corpus case has a stable ID that manifest.json declares under its file.+Adding, removing, or renaming a case requires a manifest change.++Expected values are hand-derived from the algorithm definition and the frozen version 1 evaluator.+Hash expectations were calculated with an independent SHA-1 implementation, never generated from a production evaluator.+The meta-tests recompute every hash vector, so an expectation cannot change silently.++A published corpus version is immutable.+Changing any expected value, including a hash vector, a version 1 outcome, or a projection cell, requires a new corpus version and a review explanation of why the previous expectation was wrong or superseded.+Additive cases may join a new minor corpus version; a changed expectation is a major corpus change.++Hash arithmetic is defined in corpus/hash_sha1_60_v1.json.+The contract value of hash01 converts both the 60-bit integer and the scale to binary64 before one division.+Consumers must parse decimal hash01 literals with correctly rounded binary64 conversion, including 17-digit literals.+Check the accompanying hash01_binary64_hex before consuming the corpus; a best-effort JSON float parser can otherwise move a boundary case.+Thresholds are rollout_percentage / 100 computed in binary64, and variant boundaries accumulate left to right in binary64 in stored order.++## Empty identifiers in the frozen version 1 arm++The Rust `/flags` service is the server-side version 1 reference; there is no remaining Python server-side v1 evaluator.+The frozen arm pins its behavior as verified on 2026-09-10 at [PostHog/posthog f57417de1c412fe55187540f392def4e2aef48b3](https://github.com/PostHog/posthog/blob/f57417de1c412fe55187540f392def4e2aef48b3/rust/feature-flags/src/flags/flag_matching.rs#L2160).+A deliberate change to that behavior requires a new corpus version.++Version 1 accepts an empty `distinct_id`; a missing field is invalid.+Its rollout and variant hash accessor returns 0.0 without calling SHA-1 for the empty identifier.+The inclusive rollout comparison therefore matches even at 0 percent, and a 50/50 variant split selects the first stored variant.+Holdouts do call SHA-1: the empty identifier hashes `holdout-` to 0.9268829483920294, outside a 92 percent holdout and inside a 93 percent holdout.+Version 2 never enters rollout, holdout, or variant assignment with an empty identifier.++`hash_evidence` always records SHA-1 arithmetic.+For the empty-identifier rollout and variant cases it shows the counterfactual arithmetic result; `expected` records the reference's 0.0-path outcome, and each note explains the difference.+For holdouts the recorded arithmetic is the hash the reference actually uses.++`local_evaluation` describes the local evaluator contract: `conclusive` requires the expected value, `inconclusive` requires fallback without a local value, and `remote_only` pins reference behavior that local evaluators do not yet implement; an evaluator implementing it must match.+The empty-identifier cases are `remote_only` because [posthog-python a1002c577e7c69e3f321f8f0832ee037316135a3](https://github.com/PostHog/posthog-python/blob/a1002c577e7c69e3f321f8f0832ee037316135a3/posthog/feature_flags.py#L116) hashes the prefix (plus the variant salt) locally and ignores holdouts.+Its public local-only flag API returns false at 0 and 62 percent, test for the stored control/test 50/50 split, and true for both holdout fixtures.+These are known SDK divergences, not inconclusive results or evidence of automatic fallback; the 92 percent holdout result happens to agree.++## Version and integrity policy++A published contract version is immutable.+Publish a new contract version to correct or extend a published contract.+Do not change a published version in place.++SHA256SUMS uses raw file bytes.+It has one lowercase SHA-256 digest, two spaces, a relative POSIX path, and one line feed per entry.+Entries use bytewise path order.++To pin this contract, record the source revision, the contract version, the corpus version, and the SHA-256 digest of SHA256SUMS.+Verify each file against SHA256SUMS before use.++After editing rules/response_presence.json, regenerate the derived terminal-reason branches of the presence and called-context schemas:++```sh+python3 <repo>/bin/update-feature-flag-rules-v2-presence-schemas.py+```++After editing contract files and updating manifest.json, regenerate the checksum index from any working directory:++```sh+python3 <repo>/bin/update-feature-flag-rules-v2-checksums.py+```++Run `python -m pytest tests/test_feature_flag_rules_v2_contract.py tests/test_feature_flag_rules_v2_corpus.py tests/test_feature_flag_rules_v2_wire.py` from the repository root to verify the manifest, fixtures, corpus, and checksums.+++## Wire artifacts and validation boundaries++- `schemas/definitions_entry.schema.json` selects v1 for absent/1 `filters.version`, or references the frozen config schema for v2. The entry's row `version` is independent. Row `version` and `ensure_experience_continuity` retain their existing nullable types. Existing v1 filters are opaque in this schema; this package does not redefine legacy evaluation semantics.+- `schemas/definitions_v2.schema.json` describes the mixed-version definitions feed, including its required cohort map and optional boolean `minimal_flag_called_events`. Unsupported config versions or v2 semantic fields require per-flag remote fallback in auto mode and an unsupported result in strict local mode.+- `schemas/flags_response_v3.schema.json` is the exact producer schema. Its raw-byte digest is pinned in the manifest and tests. `schemas/flags_response_v3_presence.schema.json` adds the terminal-reason presence matrix from `rules/response_presence.json`. The companion also requires the failure envelope flag whenever a record failed and rejects an `experiment_id` alongside `has_experiment: false` in any record; `has_experiment: true` alone does not imply an unambiguous experiment ID. Validate against both, then check map-key equality and recursive seed absence. A schema-only success does not establish a valid producer response.+- `schemas/management_warning.schema.json` describes a diagnostic with a required warning code from the registry's five `warning_codes` and optional presentation `detail` and field `attr`. `schemas/management_error.schema.json` preserves the management validation-error envelope (`type`, `code`, `detail`, `attr`); error codes remain endpoint-owned. These artifacts do not install a warning response envelope or an acknowledgement protocol.+- `schemas/feature_flag_called_context.schema.json` and `schemas/experiment_exposure_properties.schema.json` describe **closed property projections**, not entire capture envelopes. The generic call supports v1 diagnostics and v2 terminal context. A malformed-split diagnostic may retain config version 2 and the split reason while omitting the whole rule/experiment attribution tuple; a partly populated tuple is rejected. Direct exposure requires the complete v2 experiment-split tuple, SDK origin and `locally_evaluated`, and forbids holdout and forced-variant context. Scan the full event for assignment seeds before extracting the projection; normal capture identity, library, group and optional transport properties remain outside it.+- `fixtures/wire/` contains producer fixtures, separate tolerant-reader expectations, and full-event transport examples. A case deep-copies a named template, removes existing members by JSON Pointer, and then sets members by JSON Pointer (the parent must exist). Invalid cases declare the validation layer, keyword and instance path; reader cases separately declare producer validity; optional message fragments disambiguate required fields. `schema`, `presence`, `semantic` and `seed` are fixture validation layers, not new wire error codes.++Definitions retain canonical rule and holdout assignment seeds because local evaluation needs them. Evaluation responses and events prohibit assignment seeds recursively, including inside arrays, diagnostic conditions and opaque transport objects. The response's `flags` map keys are user-defined flag names, so names such as `seed` are allowed; every record and the rest of the envelope are still scanned. Likewise, the immediate keys of an event's `$groups`, `$set` and `$set_once` maps are customer-chosen group type and person property names; their values are still scanned.++Producer and reader contracts serve different purposes. Missing split context is invalid producer output, but a reader preserves a usable value and emits no experiment exposure. Known fields with wrong JSON types produce a per-record parse error and leave siblings usable. Unknown fields are ignored. A record without `value` uses the old-server `variant ?? enabled` interpretation, config version 1, and no carried-over v2 context. Reader expectations never loosen producer validation. Reader and event fixtures are contract data; they do not run SDK execution or activate capabilities.++The first event release permits only booleans and non-empty strings in the response property. Reserved number/object response-schema cases do not enable writers or event emission. Equal-valued arms remain separate analytical identities through their variant keys. A holdout, pause, rollout miss, default, missing or failed result cannot produce a direct exposure.++Future accepted/rejected wire-contract changes require a new major wire component version and a new major package version; additive fixture cases require a new minor fixture version and a new minor package version. Wire schema `$id`s are stable URLs without embedded versions, matching the exact producer schema; the component version is carried by `manifest.json` and the checksum index, so load one package version per schema registry. A future major wire revision publishes new schema files under new paths and `$id`s rather than reusing these.++The source distribution includes every indexed artifact and the checksum utility. Verify a build against the checkout with:++```sh+uv build --sdist+python3 bin/update-feature-flag-rules-v2-checksums.py --verify-sdist dist/posthog_sdk_test_harness-<harness-version>.tar.gz+```++The verifier reads the archive without extraction, requires its checksum index to match the checkout, and checks exact file coverage and every digest against that index.diff --git a/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/SHA256SUMS b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/SHA256SUMSnew file mode 100644index 000000000000..f60e71085715--- /dev/null+++ b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/SHA256SUMS@@ -0,0 +1,69 @@+e95b63c14f4af2abce2f9906aaaf28c5174759ce657eaa27ea8374f1d966fa54 README.md+e9bea9cff58bac0c6c1021e9c8842c53594055b6874a2c58bc4350d0c28a93ca corpus/hash_sha1_60_v1.json+536c8386eefa75721d113bd8718ddeb7fb1aad3b4f2cce1fbcf516a346a16e26 corpus/legacy_projection.json+752ff88dcb943ab1e21f9552b0c4ec606029393fca2b565b01a497da89cd8675 corpus/v1_evaluation.json+52d356d2bcdcbf705b0fe2673eb147ac352bda13c9b1bc3d53c4bbb1cb01a5aa fixtures/config/invalid/assign_by_not_person.json+516e72b6bd9f761de62166457528242723694f86e417b1aee6eb37b924acc4b5 fixtures/config/invalid/default_value_type_mismatch.json+f5aa796ba2abf17ab6b2f4706c872f2b15bfa77310cdf0400a3a460db22eda41 fixtures/config/invalid/empty_seed.json+6fac810e014d81b938f66909808e2a2fc1b7cf4db5462fe6522fde1e045cbdda fixtures/config/invalid/empty_string_value.json+cbe5d7e00f3abadd490a72055e6197d511fa59f6b3f7062dbacffea426cc5360 fixtures/config/invalid/group_experiment_with_assign_by.json+82189b24744270ac2e4ad93b97efddbede530e6990d597fe80890cbd2820f70e fixtures/config/invalid/group_percentage_rollout_with_assign_by.json+f3902f40a82f5f80c88a463768b24922bb787b774cb7cd3c4e77fe0e8748e487 fixtures/config/invalid/missing_experiment_paused.json+88541b7eb14532becb477a9d62797960d8cfdc38bc101b79c5294c1e611e26ec fixtures/config/invalid/missing_on_rollout_miss.json+bfc87e05621e30ec19647c8b4dc129b02433c7f2f2e17a9c52f8bf71ad3711ea fixtures/config/invalid/missing_rollout_seed.json+3e35c5e211d8ba159824009be3ed26c4ac6f12c1426109fa1b53b49ff63fc770 fixtures/config/invalid/non_uuid_rule_id.json+de6c7a55d67adce2042d16db287dfcbe49f502d1e5e2f8e71532d0817e28e169 fixtures/config/invalid/null_experiment_id.json+ac6f0c04ffbe348a75be7249a7cce80a2ec0411954c46c142eaa3609d2842bd7 fixtures/config/invalid/null_rule_value.json+8809275942a5fb5ed548d70d819baffa84ee4ccfec7414cc93903cc79f39c550 fixtures/config/invalid/object_value_too_deep.json+b48ead6599cbb40a2a9eea606544b0ee083bb13ce768d57fc225f2da4924633a fixtures/config/invalid/return_value_type_mismatch.json+9aeefb4ab1eb4140afb213554a91a2c1c085e54cdbe47734442e65ba9a17f99c fixtures/config/invalid/rollout_percentage_above_maximum.json+dc4102374a3e075c9501f915ead07e8061d46f07293d7b71c0eaa53d4e06fbcf fixtures/config/invalid/rollout_percentage_below_minimum.json+2ca76285c4f9724603eecb980080bf7ddf0ff8dea4458eb60a2699dfad020941 fixtures/config/invalid/seed_too_long.json+7080ad218d8a04b26884aeca4828ada72a21ea8b85453a4f2ae6fafc567223be fixtures/config/invalid/targeted_release_with_rollout_fields.json+22b5201619d80be17bfb21c9a0bf93472e2231ad4a5f1c6bb8136275e64bb8a4 fixtures/config/invalid/too_few_variants.json+aacabb57255580136b8e6a984c57cea7367e59ddeffed3d4a40137b804cf4c31 fixtures/config/invalid/too_many_variants.json+a2cc3d33443fb50ca284ec0a053c1e29b5b752729808aca7f1a5d5009c3cc5cb fixtures/config/invalid/unknown_assignment_algorithm.json+68c83e9c074a0a70e7753a6e52daa414aeb18977abdd9b702ec4c5c61d82c3a4 fixtures/config/invalid/unknown_config_field.json+f5bba7fa0ea88e43834ac3b5e03ed4f7297ad0bf4ab2f09d962241521dd06787 fixtures/config/invalid/unknown_config_version.json+f13c58cc326561ee558ffd5d2e60ec26c8ba8bc5410c7310f1f820c3ff08eb25 fixtures/config/invalid/unknown_property_field.json+621727ab45d910f6c47d88da7e68ab619c38aaee6aff2abeccf1b5f413b60b75 fixtures/config/invalid/unknown_property_operator.json+06f5c1dafff26761dfe321765072161a1230e591e1e80a353e5093a8eca041bd fixtures/config/invalid/unknown_property_type.json+e1ed66e2d00c56c217af240b2cb5af3cc10d2f7f2d26299ecf998bcb73246c22 fixtures/config/invalid/unknown_rollout_miss_policy.json+8bcc957c38bb2b6a33e244ad1cfe76612cf6f4918c8f0b0cc22f86bd01cd1932 fixtures/config/invalid/unknown_rule_field.json+f5d71ea6a2ad839fb5f540c8a7f894438fe7c99f152d7469b86af83e938288db fixtures/config/invalid/variant_key_invalid_characters.json+aecfc8a8f49f1fa5586082fc4b70284a5212e14998984fc3a7bde1520b933095 fixtures/config/invalid/variant_value_type_mismatch.json+49587173259e8b379c8f473e60af7bce7a52ad8f17088068dec021c2a3f9242d fixtures/config/invalid/version_boolean.json+4835228c5a390aa2497d4df5bd62a41d775c5ff75363d2f7dca0a5eee9e77649 fixtures/config/invalid/version_string.json+bd56e3422fee0adf18ee9a4ad13ea96fe9bb4e4d11b3e9e0499e6be985b628e8 fixtures/config/valid/boolean_all_rule_types.json+ff39ff54ecdc16a52fe963b3d0e7f08b8e417567a147c7730fc932fc366944e8 fixtures/config/valid/boolean_targeted_and_percentage_rollout.json+bd163291f26d8a851d91ed8c76e4979e9af40608fe0c8a80eefa27c3cdd0f2ad fixtures/config/valid/group_all_rule_types.json+fb09e42911934248ff767dbcfe61be60fd39483972f3bb8b1f4b1a4e9e46d944 fixtures/config/valid/object_value_max_depth.json+6a3ce5d6c5522c71969f9141c5da06e0222f797a321de2c5a90c391bcb937947 fixtures/config/valid/reserved_number_value.json+316ca827654b1a5585d25c534a889e963e5c603d293e605b3902357117802d27 fixtures/config/valid/reserved_object_value.json+414987b3d374fc5fc2d912616cadce8241be9b346d66d6cf4945ca69c169354d fixtures/config/valid/string_group_assignment.json+a848ae2e3e0dd2119600bb90ebbcba59040b3bb788586ba127a57eab1848a403 fixtures/config/valid/version_float_literal.json+f18d0bdb0ae65fc6dfa5150731633fd44ca43b752257b18bf81ab876a38ea0e8 fixtures/wire/call_transport.json+e3f09c4d8b076ceae55e742de90a42ce05bc4655140e971c63d407f519efe56b fixtures/wire/calls.json+b6398336370d8807b0874229e8dc94ed1f6e686736764d56666fc48021dabf31 fixtures/wire/definitions.json+0d267173a7d9d9260d94040ff07d14e0e1c90ccad0928c1de174d37ef135bb04 fixtures/wire/definitions_feed.json+6c402eae3da68c26e1fb72c0ed5a6c12ec0fd8aa84935f319a75deeee83bdd3c fixtures/wire/errors.json+06f8b3bb27231abac4cfa65c29078f5a68afe4d4c9443dafc0b338f447838dd3 fixtures/wire/exposure_transport.json+072119b41ccfa922fc9dc96921f022ff06f2c24c2b7540de673142f11da0b084 fixtures/wire/exposures.json+07499c5a7ca7467968156ee16fa95bdeb9018c0b841c4ec8f5bffc61d72de4fa fixtures/wire/readers.json+e34659b62facbc594bdc1ce6c0f127ff25d94672da332670b383d729f45e5960 fixtures/wire/responses.json+caac24e4c78b7086e13eb15768b5fa0eca65992d0cb0b926da5aa5d167d9878b fixtures/wire/warnings.json+cfca35316b4333f0eb1bf462eb8afa7110eb3391081c43447351acebc50f3485 manifest.json+afd25df141b5e05dfa5c8848e1685a4e8b81f3c80fbafc4769c944b815356069 registries/literals.json+c62900e74546b28a29b0883f4863536846d34b19159f3a8ca8bc0914218dfaa3 rules/response_presence.json+74e43ed13dbfd578bcb8eedc5a247917788b320829b888eab84ce1126841d63b schemas/config.schema.json+6d920c77fb7f20c2031dc188d495ed28c3789b3f362334517a2e86021a226e85 schemas/definitions_entry.schema.json+f361158f8a5572feee09fd03ce8d41f31e077f6003b90f776ea2d9ed9e38dcd8 schemas/definitions_v2.schema.json+524a2a0cc43e7907598ca49c98209c116ac65ba8ba5c16a54e1c8a4629fd3a2c schemas/experiment_exposure_properties.schema.json+b26db1aaf9e03764124286e3d9bc0cb263f4521de47e42793560558750c99f3b schemas/feature_flag_called_context.schema.json+1dd97730c746bc4534c4f47eebd82dac0cc67ceb1e4c53e7540960e7f74b00d9 schemas/flags_response_v3.schema.json+3b3fb0be1ac89524f1a65bfcde92ba34b3cdc789ebce716c3ef2ad5938d0ce62 schemas/flags_response_v3_presence.schema.json+9dbf9d76982408badc2409f390311f7150ebee4109ad11528907c55a114a1f9c schemas/hash_sha1_60_v1.schema.json+37f8f88e7ecc2337bee24972a28dbd5ff11893936732bbb34728fce143f128fc schemas/legacy_projection.schema.json+a0ec9be52e5ff9b83751283efd10ff071dc62ac90062d34b71594b37261dba8b schemas/management_error.schema.json+9aafe3c28785298bbc143e170881df43866d1b6f1070f685cbdf3d6e4418f361 schemas/management_warning.schema.json+3e51e0fad046fd9cd829d76d83b26bb6cd0b26be7a26ba223946ec92dcd7c6ce schemas/v1_evaluation.schema.jsondiff --git a/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/SOURCE.json b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/SOURCE.jsonnew file mode 100644index 000000000000..052f5dcb666b--- /dev/null+++ b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/SOURCE.json@@ -0,0 +1,58 @@+{+ "source_revision": "c32f4959240967f1ee89e58490fc9d3beaa1401f",+ "contract_version": "2.1.0",+ "registry_version": "2.0.0",+ "config_schema_version": "1.0.0",+ "definitions_schema_version": "1.0.0",+ "files": [+ "README.md",+ "fixtures/config/invalid/assign_by_not_person.json",+ "fixtures/config/invalid/default_value_type_mismatch.json",+ "fixtures/config/invalid/empty_seed.json",+ "fixtures/config/invalid/empty_string_value.json",+ "fixtures/config/invalid/group_experiment_with_assign_by.json",+ "fixtures/config/invalid/group_percentage_rollout_with_assign_by.json",+ "fixtures/config/invalid/missing_experiment_paused.json",+ "fixtures/config/invalid/missing_on_rollout_miss.json",+ "fixtures/config/invalid/missing_rollout_seed.json",+ "fixtures/config/invalid/non_uuid_rule_id.json",+ "fixtures/config/invalid/null_experiment_id.json",+ "fixtures/config/invalid/null_rule_value.json",+ "fixtures/config/invalid/object_value_too_deep.json",+ "fixtures/config/invalid/return_value_type_mismatch.json",+ "fixtures/config/invalid/rollout_percentage_above_maximum.json",+ "fixtures/config/invalid/rollout_percentage_below_minimum.json",+ "fixtures/config/invalid/seed_too_long.json",+ "fixtures/config/invalid/targeted_release_with_rollout_fields.json",+ "fixtures/config/invalid/too_few_variants.json",+ "fixtures/config/invalid/too_many_variants.json",+ "fixtures/config/invalid/unknown_assignment_algorithm.json",+ "fixtures/config/invalid/unknown_config_field.json",+ "fixtures/config/invalid/unknown_config_version.json",+ "fixtures/config/invalid/unknown_property_field.json",+ "fixtures/config/invalid/unknown_property_operator.json",+ "fixtures/config/invalid/unknown_property_type.json",+ "fixtures/config/invalid/unknown_rollout_miss_policy.json",+ "fixtures/config/invalid/unknown_rule_field.json",+ "fixtures/config/invalid/variant_key_invalid_characters.json",+ "fixtures/config/invalid/variant_value_type_mismatch.json",+ "fixtures/config/invalid/version_boolean.json",+ "fixtures/config/invalid/version_string.json",+ "fixtures/config/valid/boolean_all_rule_types.json",+ "fixtures/config/valid/boolean_targeted_and_percentage_rollout.json",+ "fixtures/config/valid/group_all_rule_types.json",+ "fixtures/config/valid/object_value_max_depth.json",+ "fixtures/config/valid/reserved_number_value.json",+ "fixtures/config/valid/reserved_object_value.json",+ "fixtures/config/valid/string_group_assignment.json",+ "fixtures/config/valid/version_float_literal.json",+ "fixtures/wire/definitions.json",+ "manifest.json",+ "registries/literals.json",+ "schemas/config.schema.json",+ "schemas/definitions_entry.schema.json"+ ],+ "source_repository": "https://github.com/PostHog/posthog-sdk-test-harness",+ "source_release": "1.6.0",+ "source_sha256sums_digest": "b8488174e76feb8a83907ee723c8609cf3fd1a1063fdeb90df2228991a01e1a0"+}diff --git a/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/assign_by_not_person.json b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/assign_by_not_person.jsonnew file mode 100644index 000000000000..b58dd6c2147c--- /dev/null+++ b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/assign_by_not_person.json@@ -0,0 +1,20 @@+{+ "version": 2,+ "return_type": "boolean",+ "default_value": false,+ "rules": [+ {+ "id": "b2b2b2b2-b2b2-4b2b-8b2b-b2b2b2b2b2b2",+ "rule_type": "percentage_rollout",+ "targeting": {+ "properties": []+ },+ "value": true,+ "rollout_percentage": 33.33,+ "on_rollout_miss": "continue",+ "assignment_algorithm": "sha1_60_v1",+ "seed": "release-preview",+ "assign_by": "group"+ }+ ]+}diff --git a/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/default_value_type_mismatch.json b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/default_value_type_mismatch.jsonnew file mode 100644index 000000000000..09e2e774d2ff--- /dev/null+++ b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/default_value_type_mismatch.json@@ -0,0 +1,22 @@+{+ "version": 2,+ "return_type": "boolean",+ "default_value": "false",+ "rules": [+ {+ "id": "a1a1a1a1-a1a1-4a1a-8a1a-a1a1a1a1a1a1",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": [+ {+ "key": "account_tier",+ "type": "person",+ "operator": "exact",+ "value": "preview"+ }+ ]+ },+ "value": true+ }+ ]+}diff --git a/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/empty_seed.json b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/empty_seed.jsonnew file mode 100644index 000000000000..808246f16b53--- /dev/null+++ b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/empty_seed.json@@ -0,0 +1,19 @@+{+ "version": 2,+ "return_type": "boolean",+ "default_value": false,+ "rules": [+ {+ "id": "dddddddd-dddd-4ddd-8ddd-dddddddddddd",+ "rule_type": "percentage_rollout",+ "targeting": {+ "properties": []+ },+ "value": true,+ "rollout_percentage": 25,+ "on_rollout_miss": "continue",+ "assignment_algorithm": "sha1_60_v1",+ "seed": ""+ }+ ]+}diff --git a/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/empty_string_value.json b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/empty_string_value.jsonnew file mode 100644index 000000000000..9377203d8d43--- /dev/null+++ b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/empty_string_value.json@@ -0,0 +1,15 @@+{+ "version": 2,+ "return_type": "string",+ "default_value": "standard",+ "rules": [+ {+ "id": "bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbbb",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": []+ },+ "value": ""+ }+ ]+}diff --git a/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/group_experiment_with_assign_by.json b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/group_experiment_with_assign_by.jsonnew file mode 100644index 000000000000..6da55c0ad12a--- /dev/null+++ b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/group_experiment_with_assign_by.json@@ -0,0 +1,39 @@+{+ "version": 2,+ "return_type": "boolean",+ "default_value": false,+ "rules": [+ {+ "id": "44444444-4444-4444-8444-444444444444",+ "rule_type": "experiment",+ "targeting": {+ "properties": []+ },+ "experiment_id": 42,+ "paused": false,+ "rollout_percentage": 100,+ "on_rollout_miss": "continue",+ "assignment_algorithm": "sha1_60_v1",+ "seed": "experiment-preview",+ "assign_by": "person",+ "variants": [+ {+ "key": "control",+ "weight": 50,+ "value": true+ },+ {+ "key": "test",+ "weight": 50,+ "value": true+ }+ ],+ "holdout": {+ "id": 7,+ "seed": "holdout-",+ "exclusion_percentage": 5+ }+ }+ ],+ "aggregation_group_type_index": 0+}diff --git a/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/group_percentage_rollout_with_assign_by.json b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/group_percentage_rollout_with_assign_by.jsonnew file mode 100644index 000000000000..38d0f23415e9--- /dev/null+++ b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/group_percentage_rollout_with_assign_by.json@@ -0,0 +1,21 @@+{+ "version": 2,+ "return_type": "boolean",+ "default_value": false,+ "rules": [+ {+ "id": "22222222-2222-4222-8222-222222222222",+ "rule_type": "percentage_rollout",+ "targeting": {+ "properties": []+ },+ "value": true,+ "rollout_percentage": 25.5,+ "on_rollout_miss": "continue",+ "assignment_algorithm": "sha1_60_v1",+ "seed": "release-preview",+ "assign_by": "person"+ }+ ],+ "aggregation_group_type_index": 0+}diff --git a/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/missing_experiment_paused.json b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/missing_experiment_paused.jsonnew file mode 100644index 000000000000..7dabb0282af8--- /dev/null+++ b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/missing_experiment_paused.json@@ -0,0 +1,31 @@+{+ "version": 2,+ "return_type": "boolean",+ "default_value": false,+ "rules": [+ {+ "id": "aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa",+ "rule_type": "experiment",+ "targeting": {+ "properties": []+ },+ "experiment_id": 21,+ "rollout_percentage": 100,+ "on_rollout_miss": "continue",+ "assignment_algorithm": "sha1_60_v1",+ "seed": "missing-pause",+ "variants": [+ {+ "key": "control",+ "weight": 50,+ "value": false+ },+ {+ "key": "test",+ "weight": 50,+ "value": true+ }+ ]+ }+ ]+}diff --git a/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/missing_on_rollout_miss.json b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/missing_on_rollout_miss.jsonnew file mode 100644index 000000000000..87d9f6500f65--- /dev/null+++ b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/missing_on_rollout_miss.json@@ -0,0 +1,18 @@+{+ "version": 2,+ "return_type": "boolean",+ "default_value": false,+ "rules": [+ {+ "id": "99999999-9999-4999-8999-999999999999",+ "rule_type": "percentage_rollout",+ "targeting": {+ "properties": []+ },+ "value": true,+ "rollout_percentage": 25,+ "assignment_algorithm": "sha1_60_v1",+ "seed": "missing-policy"+ }+ ]+}diff --git a/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/missing_rollout_seed.json b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/missing_rollout_seed.jsonnew file mode 100644index 000000000000..b9aebe13c213--- /dev/null+++ b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/missing_rollout_seed.json@@ -0,0 +1,18 @@+{+ "version": 2,+ "return_type": "boolean",+ "default_value": false,+ "rules": [+ {+ "id": "88888888-8888-4888-8888-888888888888",+ "rule_type": "percentage_rollout",+ "targeting": {+ "properties": []+ },+ "value": true,+ "rollout_percentage": 25,+ "on_rollout_miss": "continue",+ "assignment_algorithm": "sha1_60_v1"+ }+ ]+}diff --git a/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/non_uuid_rule_id.json b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/non_uuid_rule_id.jsonnew file mode 100644index 000000000000..550fe30cb462--- /dev/null+++ b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/non_uuid_rule_id.json@@ -0,0 +1,15 @@+{+ "version": 2,+ "return_type": "boolean",+ "default_value": false,+ "rules": [+ {+ "id": "rule-1",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": []+ },+ "value": true+ }+ ]+}diff --git a/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/null_experiment_id.json b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/null_experiment_id.jsonnew file mode 100644index 000000000000..7e6c8231080d--- /dev/null+++ b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/null_experiment_id.json@@ -0,0 +1,32 @@+{+ "version": 2,+ "return_type": "boolean",+ "default_value": false,+ "rules": [+ {+ "id": "aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa",+ "rule_type": "experiment",+ "targeting": {+ "properties": []+ },+ "experiment_id": null,+ "rollout_percentage": 100,+ "on_rollout_miss": "continue",+ "assignment_algorithm": "sha1_60_v1",+ "seed": "null-experiment-id",+ "variants": [+ {+ "key": "control",+ "weight": 50,+ "value": false+ },+ {+ "key": "test",+ "weight": 50,+ "value": true+ }+ ],+ "paused": false+ }+ ]+}diff --git a/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/null_rule_value.json b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/null_rule_value.jsonnew file mode 100644index 000000000000..86b0fd4ce629--- /dev/null+++ b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/null_rule_value.json@@ -0,0 +1,22 @@+{+ "version": 2,+ "return_type": "boolean",+ "default_value": false,+ "rules": [+ {+ "id": "a1a1a1a1-a1a1-4a1a-8a1a-a1a1a1a1a1a1",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": [+ {+ "key": "account_tier",+ "type": "person",+ "operator": "exact",+ "value": "preview"+ }+ ]+ },+ "value": null+ }+ ]+}diff --git a/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/object_value_too_deep.json b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/object_value_too_deep.jsonnew file mode 100644index 000000000000..fbba36171147--- /dev/null+++ b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/object_value_too_deep.json@@ -0,0 +1,57 @@+{+ "version": 2,+ "return_type": "object",+ "default_value": null,+ "rules": [+ {+ "id": "aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": []+ },+ "value": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": false+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ ]+}diff --git a/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/return_value_type_mismatch.json b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/return_value_type_mismatch.jsonnew file mode 100644index 000000000000..0a974d59fb93--- /dev/null+++ b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/return_value_type_mismatch.json@@ -0,0 +1,15 @@+{+ "version": 2,+ "return_type": "boolean",+ "default_value": false,+ "rules": [+ {+ "id": "cccccccc-cccc-4ccc-8ccc-cccccccccccc",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": []+ },+ "value": "enabled"+ }+ ]+}diff --git a/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/rollout_percentage_above_maximum.json b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/rollout_percentage_above_maximum.jsonnew file mode 100644index 000000000000..a80e13b76daf--- /dev/null+++ b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/rollout_percentage_above_maximum.json@@ -0,0 +1,20 @@+{+ "version": 2,+ "return_type": "boolean",+ "default_value": false,+ "rules": [+ {+ "id": "22222222-2222-4222-8222-222222222222",+ "rule_type": "percentage_rollout",+ "targeting": {+ "properties": []+ },+ "value": true,+ "rollout_percentage": 150,+ "on_rollout_miss": "continue",+ "assignment_algorithm": "sha1_60_v1",+ "seed": "release-preview",+ "assign_by": "person"+ }+ ]+}diff --git a/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/rollout_percentage_below_minimum.json b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/rollout_percentage_below_minimum.jsonnew file mode 100644index 000000000000..ae1178323d9c--- /dev/null+++ b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/rollout_percentage_below_minimum.json@@ -0,0 +1,19 @@+{+ "version": 2,+ "return_type": "boolean",+ "default_value": false,+ "rules": [+ {+ "id": "b2b2b2b2-b2b2-4b2b-8b2b-b2b2b2b2b2b2",+ "rule_type": "percentage_rollout",+ "targeting": {+ "properties": []+ },+ "value": true,+ "rollout_percentage": -1,+ "on_rollout_miss": "continue",+ "assignment_algorithm": "sha1_60_v1",+ "seed": "release-preview"+ }+ ]+}diff --git a/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/seed_too_long.json b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/seed_too_long.jsonnew file mode 100644index 000000000000..6e706d2fdc66--- /dev/null+++ b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/seed_too_long.json@@ -0,0 +1,38 @@+{+ "version": 2,+ "return_type": "boolean",+ "default_value": false,+ "rules": [+ {+ "id": "44444444-4444-4444-8444-444444444444",+ "rule_type": "experiment",+ "targeting": {+ "properties": []+ },+ "experiment_id": 42,+ "paused": false,+ "rollout_percentage": 100,+ "on_rollout_miss": "continue",+ "assignment_algorithm": "sha1_60_v1",+ "seed": "sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss",+ "assign_by": "person",+ "variants": [+ {+ "key": "control",+ "weight": 50,+ "value": true+ },+ {+ "key": "test",+ "weight": 50,+ "value": true+ }+ ],+ "holdout": {+ "id": 7,+ "seed": "holdout-",+ "exclusion_percentage": 5+ }+ }+ ]+}diff --git a/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/targeted_release_with_rollout_fields.json b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/targeted_release_with_rollout_fields.jsonnew file mode 100644index 000000000000..ada5d13a0c72--- /dev/null+++ b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/targeted_release_with_rollout_fields.json@@ -0,0 +1,27 @@+{+ "version": 2,+ "return_type": "boolean",+ "default_value": false,+ "rules": [+ {+ "id": "a1a1a1a1-a1a1-4a1a-8a1a-a1a1a1a1a1a1",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": [+ {+ "key": "account_tier",+ "type": "person",+ "operator": "exact",+ "value": "preview"+ }+ ]+ },+ "value": true,+ "rollout_percentage": 25,+ "on_rollout_miss": "continue",+ "assignment_algorithm": "sha1_60_v1",+ "seed": "release-preview",+ "assign_by": "person"+ }+ ]+}diff --git a/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/too_few_variants.json b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/too_few_variants.jsonnew file mode 100644index 000000000000..eac34c695e3a--- /dev/null+++ b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/too_few_variants.json@@ -0,0 +1,33 @@+{+ "version": 2,+ "return_type": "boolean",+ "default_value": false,+ "rules": [+ {+ "id": "44444444-4444-4444-8444-444444444444",+ "rule_type": "experiment",+ "targeting": {+ "properties": []+ },+ "experiment_id": 42,+ "paused": false,+ "rollout_percentage": 100,+ "on_rollout_miss": "continue",+ "assignment_algorithm": "sha1_60_v1",+ "seed": "experiment-preview",+ "assign_by": "person",+ "variants": [+ {+ "key": "only",+ "weight": 100,+ "value": true+ }+ ],+ "holdout": {+ "id": 7,+ "seed": "holdout-",+ "exclusion_percentage": 5+ }+ }+ ]+}diff --git a/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/too_many_variants.json b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/too_many_variants.jsonnew file mode 100644index 000000000000..60de1041556c--- /dev/null+++ b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/too_many_variants.json@@ -0,0 +1,133 @@+{+ "version": 2,+ "return_type": "boolean",+ "default_value": false,+ "rules": [+ {+ "id": "44444444-4444-4444-8444-444444444444",+ "rule_type": "experiment",+ "targeting": {+ "properties": []+ },+ "experiment_id": 42,+ "paused": false,+ "rollout_percentage": 100,+ "on_rollout_miss": "continue",+ "assignment_algorithm": "sha1_60_v1",+ "seed": "experiment-preview",+ "assign_by": "person",+ "variants": [+ {+ "key": "variant_0",+ "weight": 5,+ "value": true+ },+ {+ "key": "variant_1",+ "weight": 5,+ "value": true+ },+ {+ "key": "variant_2",+ "weight": 5,+ "value": true+ },+ {+ "key": "variant_3",+ "weight": 5,+ "value": true+ },+ {+ "key": "variant_4",+ "weight": 5,+ "value": true+ },+ {+ "key": "variant_5",+ "weight": 5,+ "value": true+ },+ {+ "key": "variant_6",+ "weight": 5,+ "value": true+ },+ {+ "key": "variant_7",+ "weight": 5,+ "value": true+ },+ {+ "key": "variant_8",+ "weight": 5,+ "value": true+ },+ {+ "key": "variant_9",+ "weight": 5,+ "value": true+ },+ {+ "key": "variant_10",+ "weight": 5,+ "value": true+ },+ {+ "key": "variant_11",+ "weight": 5,+ "value": true+ },+ {+ "key": "variant_12",+ "weight": 5,+ "value": true+ },+ {+ "key": "variant_13",+ "weight": 5,+ "value": true+ },+ {+ "key": "variant_14",+ "weight": 5,+ "value": true+ },+ {+ "key": "variant_15",+ "weight": 5,+ "value": true+ },+ {+ "key": "variant_16",+ "weight": 5,+ "value": true+ },+ {+ "key": "variant_17",+ "weight": 5,+ "value": true+ },+ {+ "key": "variant_18",+ "weight": 5,+ "value": true+ },+ {+ "key": "variant_19",+ "weight": 5,+ "value": true+ },+ {+ "key": "variant_20",+ "weight": 0,+ "value": true+ }+ ],+ "holdout": {+ "id": 7,+ "seed": "holdout-",+ "exclusion_percentage": 5+ }+ }+ ]+}diff --git a/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/unknown_assignment_algorithm.json b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/unknown_assignment_algorithm.jsonnew file mode 100644index 000000000000..316e736db644--- /dev/null+++ b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/unknown_assignment_algorithm.json@@ -0,0 +1,19 @@+{+ "version": 2,+ "return_type": "boolean",+ "default_value": false,+ "rules": [+ {+ "id": "b2b2b2b2-b2b2-4b2b-8b2b-b2b2b2b2b2b2",+ "rule_type": "percentage_rollout",+ "targeting": {+ "properties": []+ },+ "value": true,+ "rollout_percentage": 33.33,+ "on_rollout_miss": "continue",+ "assignment_algorithm": "md5_v1",+ "seed": "release-preview"+ }+ ]+}diff --git a/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/unknown_config_field.json b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/unknown_config_field.jsonnew file mode 100644index 000000000000..a0903f45bb82--- /dev/null+++ b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/unknown_config_field.json@@ -0,0 +1,7 @@+{+ "version": 2,+ "return_type": "boolean",+ "default_value": false,+ "rules": [],+ "groups": []+}diff --git a/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/unknown_config_version.json b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/unknown_config_version.jsonnew file mode 100644index 000000000000..3be6d836b204--- /dev/null+++ b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/unknown_config_version.json@@ -0,0 +1,6 @@+{+ "version": 3,+ "return_type": "boolean",+ "default_value": false,+ "rules": []+}diff --git a/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/unknown_property_field.json b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/unknown_property_field.jsonnew file mode 100644index 000000000000..6dfddd6c5978--- /dev/null+++ b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/unknown_property_field.json@@ -0,0 +1,23 @@+{+ "version": 2,+ "return_type": "boolean",+ "default_value": false,+ "rules": [+ {+ "id": "a1a1a1a1-a1a1-4a1a-8a1a-a1a1a1a1a1a1",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": [+ {+ "key": "account_tier",+ "type": "person",+ "operator": "exact",+ "value": "preview",+ "implicit_default": false+ }+ ]+ },+ "value": true+ }+ ]+}diff --git a/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/unknown_property_operator.json b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/unknown_property_operator.jsonnew file mode 100644index 000000000000..2c64cb68a044--- /dev/null+++ b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/unknown_property_operator.json@@ -0,0 +1,22 @@+{+ "version": 2,+ "return_type": "boolean",+ "default_value": false,+ "rules": [+ {+ "id": "a1a1a1a1-a1a1-4a1a-8a1a-a1a1a1a1a1a1",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": [+ {+ "key": "account_tier",+ "type": "person",+ "operator": "contains",+ "value": "preview"+ }+ ]+ },+ "value": true+ }+ ]+}diff --git a/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/unknown_property_type.json b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/unknown_property_type.jsonnew file mode 100644index 000000000000..ad308a4210c4--- /dev/null+++ b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/unknown_property_type.json@@ -0,0 +1,22 @@+{+ "version": 2,+ "return_type": "boolean",+ "default_value": false,+ "rules": [+ {+ "id": "a1a1a1a1-a1a1-4a1a-8a1a-a1a1a1a1a1a1",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": [+ {+ "key": "account_tier",+ "type": "event",+ "operator": "exact",+ "value": "preview"+ }+ ]+ },+ "value": true+ }+ ]+}diff --git a/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/unknown_rollout_miss_policy.json b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/unknown_rollout_miss_policy.jsonnew file mode 100644index 000000000000..0992b220aaee--- /dev/null+++ b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/unknown_rollout_miss_policy.json@@ -0,0 +1,19 @@+{+ "version": 2,+ "return_type": "boolean",+ "default_value": false,+ "rules": [+ {+ "id": "b2b2b2b2-b2b2-4b2b-8b2b-b2b2b2b2b2b2",+ "rule_type": "percentage_rollout",+ "targeting": {+ "properties": []+ },+ "value": true,+ "rollout_percentage": 33.33,+ "on_rollout_miss": "stop",+ "assignment_algorithm": "sha1_60_v1",+ "seed": "release-preview"+ }+ ]+}diff --git a/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/unknown_rule_field.json b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/unknown_rule_field.jsonnew file mode 100644index 000000000000..75b2e7295bfa--- /dev/null+++ b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/unknown_rule_field.json@@ -0,0 +1,16 @@+{+ "version": 2,+ "return_type": "boolean",+ "default_value": false,+ "rules": [+ {+ "id": "88888888-8888-4888-8888-888888888888",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": []+ },+ "value": true,+ "implicit_default": false+ }+ ]+}diff --git a/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/variant_key_invalid_characters.json b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/variant_key_invalid_characters.jsonnew file mode 100644index 000000000000..292ba97aa4f2--- /dev/null+++ b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/variant_key_invalid_characters.json@@ -0,0 +1,38 @@+{+ "version": 2,+ "return_type": "boolean",+ "default_value": false,+ "rules": [+ {+ "id": "44444444-4444-4444-8444-444444444444",+ "rule_type": "experiment",+ "targeting": {+ "properties": []+ },+ "experiment_id": 42,+ "paused": false,+ "rollout_percentage": 100,+ "on_rollout_miss": "continue",+ "assignment_algorithm": "sha1_60_v1",+ "seed": "experiment-preview",+ "assign_by": "person",+ "variants": [+ {+ "key": "invalid key",+ "weight": 50,+ "value": true+ },+ {+ "key": "test",+ "weight": 50,+ "value": true+ }+ ],+ "holdout": {+ "id": 7,+ "seed": "holdout-",+ "exclusion_percentage": 5+ }+ }+ ]+}diff --git a/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/variant_value_type_mismatch.json b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/variant_value_type_mismatch.jsonnew file mode 100644index 000000000000..6c777d1eef6e--- /dev/null+++ b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/variant_value_type_mismatch.json@@ -0,0 +1,32 @@+{+ "version": 2,+ "return_type": "boolean",+ "default_value": false,+ "rules": [+ {+ "id": "aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa",+ "rule_type": "experiment",+ "targeting": {+ "properties": []+ },+ "experiment_id": 21,+ "rollout_percentage": 100,+ "on_rollout_miss": "continue",+ "assignment_algorithm": "sha1_60_v1",+ "seed": "variant-value-type-mismatch",+ "variants": [+ {+ "key": "control",+ "weight": 50,+ "value": "false"+ },+ {+ "key": "test",+ "weight": 50,+ "value": true+ }+ ],+ "paused": false+ }+ ]+}diff --git a/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/version_boolean.json b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/version_boolean.jsonnew file mode 100644index 000000000000..44177f13c571--- /dev/null+++ b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/version_boolean.json@@ -0,0 +1,6 @@+{+ "version": true,+ "return_type": "boolean",+ "default_value": false,+ "rules": []+}diff --git a/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/version_string.json b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/version_string.jsonnew file mode 100644index 000000000000..cd2153b082c4--- /dev/null+++ b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/invalid/version_string.json@@ -0,0 +1,6 @@+{+ "version": "2",+ "return_type": "boolean",+ "default_value": false,+ "rules": []+}diff --git a/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/valid/boolean_all_rule_types.json b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/valid/boolean_all_rule_types.jsonnew file mode 100644index 000000000000..ef901e2a6986--- /dev/null+++ b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/valid/boolean_all_rule_types.json@@ -0,0 +1,71 @@+{+ "version": 2,+ "return_type": "boolean",+ "default_value": false,+ "rules": [+ {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": [+ {+ "key": "account_tier",+ "type": "person",+ "operator": "exact",+ "value": "preview",+ "label": "Account tier"+ }+ ]+ },+ "description": "Enable the preview for selected accounts.",+ "metadata": {+ "display_color": "blue"+ },+ "value": true+ },+ {+ "id": "22222222-2222-4222-8222-222222222222",+ "rule_type": "percentage_rollout",+ "targeting": {+ "properties": []+ },+ "value": true,+ "rollout_percentage": 25.5,+ "on_rollout_miss": "continue",+ "assignment_algorithm": "sha1_60_v1",+ "seed": "release-preview",+ "assign_by": "person"+ },+ {+ "id": "44444444-4444-4444-8444-444444444444",+ "rule_type": "experiment",+ "targeting": {+ "properties": []+ },+ "experiment_id": 42,+ "paused": false,+ "rollout_percentage": 100,+ "on_rollout_miss": "continue",+ "assignment_algorithm": "sha1_60_v1",+ "seed": "experiment-preview",+ "assign_by": "person",+ "variants": [+ {+ "key": "control",+ "weight": 50,+ "value": true+ },+ {+ "key": "test",+ "weight": 50,+ "value": true+ }+ ],+ "holdout": {+ "id": 7,+ "seed": "holdout-",+ "exclusion_percentage": 5+ }+ }+ ]+}diff --git a/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/valid/boolean_targeted_and_percentage_rollout.json b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/valid/boolean_targeted_and_percentage_rollout.jsonnew file mode 100644index 000000000000..0150a3672ed4--- /dev/null+++ b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/valid/boolean_targeted_and_percentage_rollout.json@@ -0,0 +1,59 @@+{+ "version": 2,+ "return_type": "boolean",+ "default_value": null,+ "rules": [+ {+ "id": "a1a1a1a1-a1a1-4a1a-8a1a-a1a1a1a1a1a1",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": [+ {+ "key": "account_tier",+ "type": "person",+ "operator": "exact",+ "value": "preview"+ }+ ]+ },+ "value": true+ },+ {+ "id": "b2b2b2b2-b2b2-4b2b-8b2b-b2b2b2b2b2b2",+ "rule_type": "percentage_rollout",+ "targeting": {+ "properties": []+ },+ "value": true,+ "rollout_percentage": 33.33,+ "on_rollout_miss": "continue",+ "assignment_algorithm": "sha1_60_v1",+ "seed": "release-preview"+ },+ {+ "id": "c3c3c3c3-c3c3-4c3c-8c3c-c3c3c3c3c3c3",+ "rule_type": "percentage_rollout",+ "targeting": {+ "properties": []+ },+ "value": false,+ "rollout_percentage": 100,+ "on_rollout_miss": "return_default",+ "assignment_algorithm": "sha1_60_v1",+ "seed": "release-fallback",+ "assign_by": "person"+ },+ {+ "id": "d4d4d4d4-d4d4-4d4d-8d4d-d4d4d4d4d4d4",+ "rule_type": "percentage_rollout",+ "targeting": {+ "properties": []+ },+ "value": true,+ "rollout_percentage": 0,+ "on_rollout_miss": "continue",+ "assignment_algorithm": "sha1_60_v1",+ "seed": "release-disabled"+ }+ ]+}diff --git a/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/valid/group_all_rule_types.json b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/valid/group_all_rule_types.jsonnew file mode 100644index 000000000000..4d6a091e86ee--- /dev/null+++ b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/valid/group_all_rule_types.json@@ -0,0 +1,70 @@+{+ "version": 2,+ "return_type": "boolean",+ "default_value": false,+ "rules": [+ {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": [+ {+ "key": "account_tier",+ "type": "person",+ "operator": "exact",+ "value": "preview",+ "label": "Account tier"+ }+ ]+ },+ "description": "Enable the preview for selected accounts.",+ "metadata": {+ "display_color": "blue"+ },+ "value": true+ },+ {+ "id": "22222222-2222-4222-8222-222222222222",+ "rule_type": "percentage_rollout",+ "targeting": {+ "properties": []+ },+ "value": true,+ "rollout_percentage": 25.5,+ "on_rollout_miss": "continue",+ "assignment_algorithm": "sha1_60_v1",+ "seed": "release-preview"+ },+ {+ "id": "44444444-4444-4444-8444-444444444444",+ "rule_type": "experiment",+ "targeting": {+ "properties": []+ },+ "experiment_id": 42,+ "paused": false,+ "rollout_percentage": 100,+ "on_rollout_miss": "continue",+ "assignment_algorithm": "sha1_60_v1",+ "seed": "experiment-preview",+ "variants": [+ {+ "key": "control",+ "weight": 50,+ "value": true+ },+ {+ "key": "test",+ "weight": 50,+ "value": true+ }+ ],+ "holdout": {+ "id": 7,+ "seed": "holdout-",+ "exclusion_percentage": 5+ }+ }+ ],+ "aggregation_group_type_index": 0+}diff --git a/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/valid/object_value_max_depth.json b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/valid/object_value_max_depth.jsonnew file mode 100644index 000000000000..908497db3cb3--- /dev/null+++ b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/valid/object_value_max_depth.json@@ -0,0 +1,55 @@+{+ "version": 2,+ "return_type": "object",+ "default_value": null,+ "rules": [+ {+ "id": "aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": []+ },+ "value": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": false+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ ]+}diff --git a/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/valid/reserved_number_value.json b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/valid/reserved_number_value.jsonnew file mode 100644index 000000000000..7f933519173a--- /dev/null+++ b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/valid/reserved_number_value.json@@ -0,0 +1,15 @@+{+ "version": 2,+ "return_type": "number",+ "default_value": 0,+ "rules": [+ {+ "id": "66666666-6666-4666-8666-666666666666",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": []+ },+ "value": 1.25+ }+ ]+}diff --git a/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/valid/reserved_object_value.json b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/valid/reserved_object_value.jsonnew file mode 100644index 000000000000..7284f9543b14--- /dev/null+++ b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/valid/reserved_object_value.json@@ -0,0 +1,24 @@+{+ "version": 2,+ "return_type": "object",+ "default_value": {+ "layout": "standard"+ },+ "rules": [+ {+ "id": "77777777-7777-4777-8777-777777777777",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": []+ },+ "value": {+ "layout": "compact",+ "options": [+ 1,+ true,+ null+ ]+ }+ }+ ]+}diff --git a/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/valid/string_group_assignment.json b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/valid/string_group_assignment.jsonnew file mode 100644index 000000000000..aebdedb2f441--- /dev/null+++ b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/valid/string_group_assignment.json@@ -0,0 +1,31 @@+{+ "version": 2,+ "return_type": "string",+ "default_value": "standard",+ "aggregation_group_type_index": 0,+ "rules": [+ {+ "id": "55555555-5555-4555-8555-555555555555",+ "rule_type": "percentage_rollout",+ "targeting": {+ "properties": [+ {+ "key": "region",+ "type": "group",+ "operator": "exact",+ "value": "north",+ "group_type_index": 0,+ "group_key_names": {+ "organization": "Organization"+ }+ }+ ]+ },+ "value": "compact",+ "rollout_percentage": 50,+ "on_rollout_miss": "continue",+ "assignment_algorithm": "sha1_60_v1",+ "seed": "group-release"+ }+ ]+}diff --git a/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/valid/version_float_literal.json b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/valid/version_float_literal.jsonnew file mode 100644index 000000000000..70b2c313344e--- /dev/null+++ b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/config/valid/version_float_literal.json@@ -0,0 +1,6 @@+{+ "version": 2.0,+ "return_type": "boolean",+ "default_value": false,+ "rules": []+}diff --git a/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/wire/definitions.json b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/wire/definitions.jsonnew file mode 100644index 000000000000..764a8c3bf01c--- /dev/null+++ b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/fixtures/wire/definitions.json@@ -0,0 +1,388 @@+{+ "fixture_version": "1.0.0",+ "schema": "schemas/definitions_entry.schema.json",+ "templates": {+ "v2": {+ "id": 201,+ "key": "garden-layout",+ "active": true,+ "version": 7,+ "filters": {+ "version": 2,+ "return_type": "boolean",+ "default_value": false,+ "rules": [+ {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": [+ {+ "key": "account_tier",+ "type": "person",+ "operator": "exact",+ "value": "preview",+ "label": "Account tier"+ }+ ]+ },+ "description": "Enable the preview for selected accounts.",+ "metadata": {+ "display_color": "blue"+ },+ "value": true+ },+ {+ "id": "22222222-2222-4222-8222-222222222222",+ "rule_type": "percentage_rollout",+ "targeting": {+ "properties": []+ },+ "value": true,+ "rollout_percentage": 25.5,+ "on_rollout_miss": "continue",+ "assignment_algorithm": "sha1_60_v1",+ "seed": "release-preview",+ "assign_by": "person"+ },+ {+ "id": "44444444-4444-4444-8444-444444444444",+ "rule_type": "experiment",+ "targeting": {+ "properties": []+ },+ "experiment_id": 42,+ "paused": false,+ "rollout_percentage": 100,+ "on_rollout_miss": "continue",+ "assignment_algorithm": "sha1_60_v1",+ "seed": "experiment-preview",+ "assign_by": "person",+ "variants": [+ {+ "key": "control",+ "weight": 50,+ "value": true+ },+ {+ "key": "test",+ "weight": 50,+ "value": true+ }+ ],+ "holdout": {+ "id": 7,+ "seed": "holdout-",+ "exclusion_percentage": 5+ }+ }+ ]+ }+ },+ "v1": {+ "id": 202,+ "key": "legacy-garden",+ "active": true,+ "version": 9,+ "filters": {+ "groups": [+ {+ "properties": [],+ "rollout_percentage": 100+ }+ ]+ }+ }+ },+ "cases": [+ {+ "id": "definitions.v2_canonical",+ "template": "v2",+ "expected": "valid"+ },+ {+ "id": "definitions.v1_implicit",+ "template": "v1",+ "expected": "valid"+ },+ {+ "id": "definitions.v1_explicit",+ "template": "v1",+ "set": {+ "/filters/version": 1+ },+ "expected": "valid"+ },+ {+ "id": "definitions.v2_numeric_version",+ "template": "v2",+ "set": {+ "/filters/version": 2.0+ },+ "expected": "valid"+ },+ {+ "id": "definitions.inactive",+ "template": "v2",+ "set": {+ "/active": false+ },+ "expected": "valid"+ },+ {+ "id": "definitions.unsupported_version_future",+ "template": "v2",+ "set": {+ "/filters/version": 3+ },+ "expected": "invalid",+ "expected_failure": {+ "layer": "schema",+ "keyword": "const",+ "instance_path": "/filters/version"+ },+ "reader": {+ "auto": "remote_fallback",+ "local_only": "unsupported"+ }+ },+ {+ "id": "definitions.unsupported_version_string",+ "template": "v2",+ "set": {+ "/filters/version": "2"+ },+ "expected": "invalid",+ "expected_failure": {+ "layer": "schema",+ "keyword": "const",+ "instance_path": "/filters/version"+ },+ "reader": {+ "auto": "remote_fallback",+ "local_only": "unsupported"+ }+ },+ {+ "id": "definitions.unsupported_version_boolean",+ "template": "v2",+ "set": {+ "/filters/version": true+ },+ "expected": "invalid",+ "expected_failure": {+ "layer": "schema",+ "keyword": "const",+ "instance_path": "/filters/version"+ },+ "reader": {+ "auto": "remote_fallback",+ "local_only": "unsupported"+ }+ },+ {+ "id": "definitions.unsupported_version_null",+ "template": "v2",+ "set": {+ "/filters/version": null+ },+ "expected": "invalid",+ "expected_failure": {+ "layer": "schema",+ "keyword": "const",+ "instance_path": "/filters/version"+ },+ "reader": {+ "auto": "remote_fallback",+ "local_only": "unsupported"+ }+ },+ {+ "id": "definitions.unknown_semantic_field",+ "template": "v2",+ "set": {+ "/filters/future_assignment": true+ },+ "expected": "invalid",+ "expected_failure": {+ "layer": "schema",+ "keyword": "additionalProperties",+ "instance_path": "/filters"+ },+ "reader": {+ "auto": "remote_fallback",+ "local_only": "unsupported"+ }+ },+ {+ "id": "definitions.unknown_rule_field",+ "template": "v2",+ "set": {+ "/filters/rules/0/future_targeting": true+ },+ "expected": "invalid",+ "expected_failure": {+ "layer": "schema",+ "keyword": "additionalProperties",+ "instance_path": "/filters/rules/0"+ },+ "reader": {+ "auto": "remote_fallback",+ "local_only": "unsupported"+ }+ },+ {+ "id": "definitions.unsupported_rule_type",+ "template": "v2",+ "set": {+ "/filters/rules/0/rule_type": "future_rule"+ },+ "expected": "invalid",+ "expected_failure": {+ "layer": "schema",+ "keyword": "const",+ "instance_path": "/filters/rules/0/rule_type"+ },+ "reader": {+ "auto": "remote_fallback",+ "local_only": "unsupported"+ }+ },+ {+ "id": "definitions.missing_assignment_seed",+ "template": "v2",+ "remove": [+ "/filters/rules/1/seed"+ ],+ "expected": "invalid",+ "expected_failure": {+ "layer": "schema",+ "keyword": "required",+ "instance_path": "/filters/rules/1",+ "message_contains": "seed"+ }+ },+ {+ "id": "definitions.v1_null_version",+ "template": "v1",+ "set": {+ "/version": null+ },+ "expected": "valid"+ },+ {+ "id": "definitions.v1_wrong_type_version",+ "template": "v1",+ "set": {+ "/version": "invalid"+ },+ "expected": "invalid",+ "expected_failure": {+ "layer": "schema",+ "keyword": "type",+ "instance_path": "/version"+ }+ },+ {+ "id": "definitions.v1_null_ensure_experience_continuity",+ "template": "v1",+ "set": {+ "/ensure_experience_continuity": null+ },+ "expected": "valid"+ },+ {+ "id": "definitions.v1_wrong_type_ensure_experience_continuity",+ "template": "v1",+ "set": {+ "/ensure_experience_continuity": "invalid"+ },+ "expected": "invalid",+ "expected_failure": {+ "layer": "schema",+ "keyword": "type",+ "instance_path": "/ensure_experience_continuity"+ }+ },+ {+ "id": "definitions.v1_explicit_null_row_fields",+ "template": "v1",+ "set": {+ "/filters/version": 1,+ "/version": null,+ "/ensure_experience_continuity": null+ },+ "expected": "valid"+ },+ {+ "id": "definitions.missing_id",+ "template": "v2",+ "remove": [+ "/id"+ ],+ "expected": "invalid",+ "expected_failure": {+ "layer": "schema",+ "keyword": "required",+ "instance_path": "",+ "message_contains": "id"+ }+ },+ {+ "id": "definitions.missing_key",+ "template": "v2",+ "remove": [+ "/key"+ ],+ "expected": "invalid",+ "expected_failure": {+ "layer": "schema",+ "keyword": "required",+ "instance_path": "",+ "message_contains": "key"+ }+ },+ {+ "id": "definitions.missing_active",+ "template": "v2",+ "remove": [+ "/active"+ ],+ "expected": "invalid",+ "expected_failure": {+ "layer": "schema",+ "keyword": "required",+ "instance_path": "",+ "message_contains": "active"+ }+ },+ {+ "id": "definitions.missing_filters",+ "template": "v2",+ "remove": [+ "/filters"+ ],+ "expected": "invalid",+ "expected_failure": {+ "layer": "schema",+ "keyword": "required",+ "instance_path": "",+ "message_contains": "filters"+ }+ },+ {+ "id": "definitions.unknown_field",+ "template": "v2",+ "set": {+ "/future_row_field": 1+ },+ "expected": "invalid",+ "expected_failure": {+ "layer": "schema",+ "keyword": "additionalProperties",+ "instance_path": "",+ "message_contains": "future_row_field"+ }+ }+ ]+}diff --git a/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/manifest.json b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/manifest.jsonnew file mode 100644index 000000000000..440c1d2677bb--- /dev/null+++ b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/manifest.json@@ -0,0 +1,1041 @@+{+ "manifest_version": 1,+ "contract": {+ "name": "feature_flag_rules_v2",+ "version": "2.1.0",+ "config_version": 2+ },+ "corpus": {+ "version": "1.1.0",+ "config_version_locked": 1,+ "case_id_pattern": "^[a-z][a-z0-9_]*(\\.[a-z0-9_]+)+$",+ "published_versions_are_immutable": true,+ "expectation_change": "Any changed expected value requires a new corpus version and a review explanation."+ },+ "schema_dialect": "https://json-schema.org/draft/2020-12/schema",+ "compatibility": {+ "published_versions_are_immutable": true,+ "patch": "Documentation or integrity-tool changes that do not change accepted configs, wire payloads, frozen literals, or fixture expectations.",+ "minor": "Additive fixtures or artifacts that do not change accepted configs, accepted or rejected wire payloads, frozen literals, or published fixture expectations.",+ "major": "Any change to accepted or rejected configs, accepted or rejected wire payloads (responses, definitions, events, diagnostics), frozen literals, or published fixture expectations."+ },+ "integrity": {+ "algorithm": "sha256",+ "index": "SHA256SUMS",+ "content": "raw_file_bytes",+ "entry_format": "<lowercase_hex_digest><two_spaces><relative_posix_path><line_feed>",+ "entry_order": "bytewise_path",+ "excluded_from_index": [+ "SHA256SUMS"+ ]+ },+ "artifacts": [+ {+ "path": "README.md",+ "kind": "documentation"+ },+ {+ "path": "registries/literals.json",+ "kind": "registry",+ "version": "2.0.0"+ },+ {+ "path": "schemas/config.schema.json",+ "kind": "schema",+ "version": "1.0.0"+ },+ {+ "path": "fixtures/config/valid/boolean_all_rule_types.json",+ "kind": "fixture",+ "fixture_id": "config.valid.boolean_all_rule_types",+ "expected": "valid"+ },+ {+ "path": "fixtures/config/valid/string_group_assignment.json",+ "kind": "fixture",+ "fixture_id": "config.valid.string_group_assignment",+ "expected": "valid"+ },+ {+ "path": "fixtures/config/valid/reserved_number_value.json",+ "kind": "fixture",+ "fixture_id": "config.valid.reserved_number_value",+ "expected": "valid"+ },+ {+ "path": "fixtures/config/valid/reserved_object_value.json",+ "kind": "fixture",+ "fixture_id": "config.valid.reserved_object_value",+ "expected": "valid"+ },+ {+ "path": "fixtures/config/valid/version_float_literal.json",+ "kind": "fixture",+ "fixture_id": "config.valid.version_float_literal",+ "expected": "valid"+ },+ {+ "path": "fixtures/config/invalid/unknown_config_version.json",+ "kind": "fixture",+ "fixture_id": "config.invalid.unknown_config_version",+ "expected": "invalid",+ "expected_failure": {+ "keyword": "const",+ "instance_path": "/version",+ "message_contains": "2 was expected"+ }+ },+ {+ "path": "fixtures/config/invalid/version_string.json",+ "kind": "fixture",+ "fixture_id": "config.invalid.version_string",+ "expected": "invalid",+ "expected_failure": {+ "keyword": "const",+ "instance_path": "/version"+ }+ },+ {+ "path": "fixtures/config/invalid/version_boolean.json",+ "kind": "fixture",+ "fixture_id": "config.invalid.version_boolean",+ "expected": "invalid",+ "expected_failure": {+ "keyword": "const",+ "instance_path": "/version"+ }+ },+ {+ "path": "fixtures/config/invalid/unknown_config_field.json",+ "kind": "fixture",+ "fixture_id": "config.invalid.unknown_config_field",+ "expected": "invalid",+ "expected_failure": {+ "keyword": "additionalProperties",+ "instance_path": "",+ "message_contains": "groups"+ }+ },+ {+ "path": "fixtures/config/invalid/unknown_rule_field.json",+ "kind": "fixture",+ "fixture_id": "config.invalid.unknown_rule_field",+ "expected": "invalid",+ "expected_failure": {+ "keyword": "additionalProperties",+ "instance_path": "/rules/0",+ "message_contains": "implicit_default"+ }+ },+ {+ "path": "fixtures/config/invalid/missing_on_rollout_miss.json",+ "kind": "fixture",+ "fixture_id": "config.invalid.missing_on_rollout_miss",+ "expected": "invalid",+ "expected_failure": {+ "keyword": "required",+ "instance_path": "/rules/0",+ "message_contains": "on_rollout_miss"+ }+ },+ {+ "path": "fixtures/config/invalid/missing_rollout_seed.json",+ "kind": "fixture",+ "fixture_id": "config.invalid.missing_rollout_seed",+ "expected": "invalid",+ "expected_failure": {+ "keyword": "required",+ "instance_path": "/rules/0",+ "message_contains": "seed"+ }+ },+ {+ "path": "fixtures/config/invalid/missing_experiment_paused.json",+ "kind": "fixture",+ "fixture_id": "config.invalid.missing_experiment_paused",+ "expected": "invalid",+ "expected_failure": {+ "keyword": "required",+ "instance_path": "/rules/0",+ "message_contains": "paused"+ }+ },+ {+ "path": "fixtures/config/invalid/non_uuid_rule_id.json",+ "kind": "fixture",+ "fixture_id": "config.invalid.non_uuid_rule_id",+ "expected": "invalid",+ "expected_failure": {+ "keyword": "pattern",+ "instance_path": "/rules/0/id"+ }+ },+ {+ "path": "fixtures/config/invalid/empty_seed.json",+ "kind": "fixture",+ "fixture_id": "config.invalid.empty_seed",+ "expected": "invalid",+ "expected_failure": {+ "keyword": "minLength",+ "instance_path": "/rules/0/seed"+ }+ },+ {+ "path": "fixtures/config/invalid/empty_string_value.json",+ "kind": "fixture",+ "fixture_id": "config.invalid.empty_string_value",+ "expected": "invalid",+ "expected_failure": {+ "keyword": "minLength",+ "instance_path": "/rules/0/value"+ }+ },+ {+ "path": "fixtures/config/invalid/return_value_type_mismatch.json",+ "kind": "fixture",+ "fixture_id": "config.invalid.return_value_type_mismatch",+ "expected": "invalid",+ "expected_failure": {+ "keyword": "type",+ "instance_path": "/rules/0/value"+ }+ },+ {+ "path": "fixtures/config/invalid/variant_value_type_mismatch.json",+ "kind": "fixture",+ "fixture_id": "config.invalid.variant_value_type_mismatch",+ "expected": "invalid",+ "expected_failure": {+ "keyword": "type",+ "instance_path": "/rules/0/variants/0/value"+ }+ },+ {+ "path": "fixtures/config/invalid/null_experiment_id.json",+ "kind": "fixture",+ "fixture_id": "config.invalid.null_experiment_id",+ "expected": "invalid",+ "expected_failure": {+ "keyword": "type",+ "instance_path": "/rules/0/experiment_id",+ "message_contains": "integer"+ }+ },+ {+ "path": "fixtures/config/valid/object_value_max_depth.json",+ "kind": "fixture",+ "fixture_id": "config.valid.object_value_max_depth",+ "expected": "valid"+ },+ {+ "path": "fixtures/config/invalid/object_value_too_deep.json",+ "kind": "fixture",+ "fixture_id": "config.invalid.object_value_too_deep",+ "expected": "invalid",+ "expected_failure": {+ "keyword": "oneOf",+ "instance_path": "/rules/0/value/child/child/child/child/child/child/child/child/child/child/child/child/child/child/child/child/child/child/child/child"+ }+ },+ {+ "path": "fixtures/config/invalid/rollout_percentage_above_maximum.json",+ "kind": "fixture",+ "fixture_id": "config.invalid.rollout_percentage_above_maximum",+ "expected": "invalid",+ "expected_failure": {+ "keyword": "maximum",+ "instance_path": "/rules/0/rollout_percentage"+ }+ },+ {+ "path": "fixtures/config/invalid/variant_key_invalid_characters.json",+ "kind": "fixture",+ "fixture_id": "config.invalid.variant_key_invalid_characters",+ "expected": "invalid",+ "expected_failure": {+ "keyword": "pattern",+ "instance_path": "/rules/0/variants/0/key"+ }+ },+ {+ "path": "fixtures/config/invalid/too_few_variants.json",+ "kind": "fixture",+ "fixture_id": "config.invalid.too_few_variants",+ "expected": "invalid",+ "expected_failure": {+ "keyword": "minItems",+ "instance_path": "/rules/0/variants"+ }+ },+ {+ "path": "fixtures/config/invalid/too_many_variants.json",+ "kind": "fixture",+ "fixture_id": "config.invalid.too_many_variants",+ "expected": "invalid",+ "expected_failure": {+ "keyword": "maxItems",+ "instance_path": "/rules/0/variants"+ }+ },+ {+ "path": "fixtures/config/invalid/seed_too_long.json",+ "kind": "fixture",+ "fixture_id": "config.invalid.seed_too_long",+ "expected": "invalid",+ "expected_failure": {+ "keyword": "maxLength",+ "instance_path": "/rules/0/seed"+ }+ },+ {+ "path": "fixtures/config/invalid/group_percentage_rollout_with_assign_by.json",+ "kind": "fixture",+ "fixture_id": "config.invalid.group_percentage_rollout_with_assign_by",+ "expected": "invalid",+ "expected_failure": {+ "keyword": "not",+ "instance_path": "/rules/0"+ }+ },+ {+ "path": "fixtures/config/invalid/group_experiment_with_assign_by.json",+ "kind": "fixture",+ "fixture_id": "config.invalid.group_experiment_with_assign_by",+ "expected": "invalid",+ "expected_failure": {+ "keyword": "not",+ "instance_path": "/rules/0"+ }+ },+ {+ "path": "fixtures/config/valid/group_all_rule_types.json",+ "kind": "fixture",+ "fixture_id": "config.valid.group_all_rule_types",+ "expected": "valid"+ },+ {+ "path": "fixtures/config/valid/boolean_targeted_and_percentage_rollout.json",+ "kind": "fixture",+ "fixture_id": "config.valid.boolean_targeted_and_percentage_rollout",+ "expected": "valid"+ },+ {+ "path": "fixtures/config/invalid/targeted_release_with_rollout_fields.json",+ "kind": "fixture",+ "fixture_id": "config.invalid.targeted_release_with_rollout_fields",+ "expected": "invalid",+ "expected_failure": {+ "keyword": "additionalProperties",+ "instance_path": "/rules/0",+ "message_contains": "rollout_percentage"+ }+ },+ {+ "path": "fixtures/config/invalid/rollout_percentage_below_minimum.json",+ "kind": "fixture",+ "fixture_id": "config.invalid.rollout_percentage_below_minimum",+ "expected": "invalid",+ "expected_failure": {+ "keyword": "minimum",+ "instance_path": "/rules/0/rollout_percentage"+ }+ },+ {+ "path": "fixtures/config/invalid/unknown_rollout_miss_policy.json",+ "kind": "fixture",+ "fixture_id": "config.invalid.unknown_rollout_miss_policy",+ "expected": "invalid",+ "expected_failure": {+ "keyword": "enum",+ "instance_path": "/rules/0/on_rollout_miss"+ }+ },+ {+ "path": "fixtures/config/invalid/unknown_assignment_algorithm.json",+ "kind": "fixture",+ "fixture_id": "config.invalid.unknown_assignment_algorithm",+ "expected": "invalid",+ "expected_failure": {+ "keyword": "const",+ "instance_path": "/rules/0/assignment_algorithm"+ }+ },+ {+ "path": "fixtures/config/invalid/assign_by_not_person.json",+ "kind": "fixture",+ "fixture_id": "config.invalid.assign_by_not_person",+ "expected": "invalid",+ "expected_failure": {+ "keyword": "const",+ "instance_path": "/rules/0/assign_by"+ }+ },+ {+ "path": "fixtures/config/invalid/null_rule_value.json",+ "kind": "fixture",+ "fixture_id": "config.invalid.null_rule_value",+ "expected": "invalid",+ "expected_failure": {+ "keyword": "type",+ "instance_path": "/rules/0/value",+ "message_contains": "boolean"+ }+ },+ {+ "path": "fixtures/config/invalid/default_value_type_mismatch.json",+ "kind": "fixture",+ "fixture_id": "config.invalid.default_value_type_mismatch",+ "expected": "invalid",+ "expected_failure": {+ "keyword": "type",+ "instance_path": "/default_value"+ }+ },+ {+ "path": "fixtures/config/invalid/unknown_property_field.json",+ "kind": "fixture",+ "fixture_id": "config.invalid.unknown_property_field",+ "expected": "invalid",+ "expected_failure": {+ "keyword": "additionalProperties",+ "instance_path": "/rules/0/targeting/properties/0",+ "message_contains": "implicit_default"+ }+ },+ {+ "path": "fixtures/config/invalid/unknown_property_operator.json",+ "kind": "fixture",+ "fixture_id": "config.invalid.unknown_property_operator",+ "expected": "invalid",+ "expected_failure": {+ "keyword": "enum",+ "instance_path": "/rules/0/targeting/properties/0/operator"+ }+ },+ {+ "path": "fixtures/config/invalid/unknown_property_type.json",+ "kind": "fixture",+ "fixture_id": "config.invalid.unknown_property_type",+ "expected": "invalid",+ "expected_failure": {+ "keyword": "enum",+ "instance_path": "/rules/0/targeting/properties/0/type"+ }+ },+ {+ "path": "schemas/hash_sha1_60_v1.schema.json",+ "kind": "schema",+ "version": "1.1.0"+ },+ {+ "path": "schemas/v1_evaluation.schema.json",+ "kind": "schema",+ "version": "1.1.0"+ },+ {+ "path": "schemas/legacy_projection.schema.json",+ "kind": "schema",+ "version": "1.1.0"+ },+ {+ "path": "corpus/hash_sha1_60_v1.json",+ "kind": "corpus",+ "version": "1.1.0",+ "schema": "schemas/hash_sha1_60_v1.schema.json",+ "case_ids": [+ "hash.rollout.ascii_division_edge",+ "hash.rollout.ascii_excluded",+ "hash.variant.ascii",+ "hash.holdout.literal_prefix",+ "hash.concatenation.no_separator_escaping",+ "hash.identifier.empty",+ "hash.identifier.unicode_utf8",+ "hash.identifier.truncated_ascii",+ "hash.identifier.truncated_scalar_values",+ "hash.identifier.exactly_200_multibyte",+ "hash.identifier.integer_group_key",+ "threshold.equal_is_included",+ "threshold.next_binary64_above_is_excluded",+ "threshold.zero_percent_zero_hash",+ "threshold.zero_percent_smallest_hash",+ "threshold.hundred_percent_short_circuit",+ "threshold.two_decimal_division_equal",+ "threshold.two_decimal_division_excluded",+ "threshold.two_decimal_division_included_below_quotient",+ "variant.zero_hash_first_variant",+ "variant.boundary_is_exclusive",+ "variant.just_below_boundary",+ "variant.accumulated_boundary_left_to_right",+ "variant.accumulated_boundary_third",+ "variant.two_decimal_weights_boundary",+ "variant.hash_one_off_the_end",+ "variant.sum_below_one_off_the_end",+ "parity.rollout_identical_bytes",+ "parity.variant_identical_bytes",+ "parity.holdout_identical_bytes",+ "parity.empty_identifier_divergent",+ "parity.final_variant_fallback_divergent"+ ]+ },+ {+ "path": "corpus/v1_evaluation.json",+ "kind": "corpus",+ "version": "1.1.0",+ "schema": "schemas/v1_evaluation.schema.json",+ "case_ids": [+ "v1.boolean.targeted_match_with_payload",+ "v1.boolean.targeting_miss",+ "v1.boolean.rollout_included",+ "v1.boolean.rollout_excluded",+ "v1.boolean.rollout_miss_continues_to_lower_condition",+ "v1.boolean.rollout_miss_early_exit",+ "v1.boolean.reason_priority_keeps_earlier_rollout_miss",+ "v1.boolean.reason_priority_prefers_later_rollout_miss",+ "v1.boolean.null_rollout_is_100",+ "v1.boolean.empty_distinct_id_included_at_zero_percent",+ "v1.boolean.empty_distinct_id_included_below_prefix_hash",+ "v1.multivariate.variant_from_hash_with_payload",+ "v1.multivariate.variant_from_hash_control",+ "v1.multivariate.variant_override",+ "v1.multivariate.invalid_variant_override_uses_hash",+ "v1.multivariate.partial_rollout_included",+ "v1.multivariate.partial_rollout_excluded",+ "v1.multivariate.empty_distinct_id_first_variant",+ "v1.group.included_by_group_key",+ "v1.group.excluded_by_group_key",+ "v1.group.integer_group_key_normalized",+ "v1.group.missing_group_key",+ "v1.dependency.satisfied",+ "v1.dependency.unsatisfied",+ "v1.dependency.variant_match",+ "v1.dependency.variant_mismatch",+ "v1.dependency.missing_target",+ "v1.holdout.member",+ "v1.holdout.not_member",+ "v1.holdout.empty_distinct_id_hashes_prefix",+ "v1.omission.inactive_flag"+ ]+ },+ {+ "path": "corpus/legacy_projection.json",+ "kind": "corpus",+ "version": "1.1.0",+ "schema": "schemas/legacy_projection.schema.json",+ "case_ids": [+ "projection.boolean_true",+ "projection.boolean_true_with_payload",+ "projection.boolean_false_targeting_miss",+ "projection.boolean_false_out_of_rollout",+ "projection.variant",+ "projection.variant_with_payload",+ "projection.holdout_variant",+ "projection.no_group_type",+ "projection.missing_dependency",+ "projection.failed_evaluation",+ "projection.inactive_omitted"+ ]+ },+ {+ "path": "schemas/definitions_entry.schema.json",+ "kind": "schema",+ "version": "1.0.0"+ },+ {+ "path": "schemas/definitions_v2.schema.json",+ "kind": "schema",+ "version": "1.0.0"+ },+ {+ "path": "schemas/flags_response_v3.schema.json",+ "kind": "schema",+ "version": "1.0.0"+ },+ {+ "path": "schemas/flags_response_v3_presence.schema.json",+ "kind": "schema",+ "version": "1.0.0"+ },+ {+ "path": "schemas/management_warning.schema.json",+ "kind": "schema",+ "version": "1.0.0"+ },+ {+ "path": "schemas/management_error.schema.json",+ "kind": "schema",+ "version": "1.0.0"+ },+ {+ "path": "schemas/feature_flag_called_context.schema.json",+ "kind": "schema",+ "version": "1.0.0"+ },+ {+ "path": "schemas/experiment_exposure_properties.schema.json",+ "kind": "schema",+ "version": "1.0.0"+ },+ {+ "path": "rules/response_presence.json",+ "kind": "presence_matrix",+ "version": "1.0.0"+ },+ {+ "path": "fixtures/wire/definitions.json",+ "kind": "fixture_set",+ "version": "1.0.0",+ "schema": "schemas/definitions_entry.schema.json",+ "case_ids": [+ "definitions.v2_canonical",+ "definitions.v1_implicit",+ "definitions.v1_explicit",+ "definitions.v2_numeric_version",+ "definitions.inactive",+ "definitions.unsupported_version_future",+ "definitions.unsupported_version_string",+ "definitions.unsupported_version_boolean",+ "definitions.unsupported_version_null",+ "definitions.unknown_semantic_field",+ "definitions.unknown_rule_field",+ "definitions.unsupported_rule_type",+ "definitions.missing_assignment_seed",+ "definitions.v1_null_version",+ "definitions.v1_wrong_type_version",+ "definitions.v1_null_ensure_experience_continuity",+ "definitions.v1_wrong_type_ensure_experience_continuity",+ "definitions.v1_explicit_null_row_fields",+ "definitions.missing_id",+ "definitions.missing_key",+ "definitions.missing_active",+ "definitions.missing_filters",+ "definitions.unknown_field"+ ]+ },+ {+ "path": "fixtures/wire/definitions_feed.json",+ "kind": "fixture_set",+ "version": "1.0.0",+ "schema": "schemas/definitions_v2.schema.json",+ "case_ids": [+ "definitions_feed.mixed_versions",+ "definitions_feed.missing_cohorts",+ "definitions_feed.minimal_events_false",+ "definitions_feed.minimal_events_true",+ "definitions_feed.minimal_events_wrong_type",+ "definitions_feed.null_legacy_row_fields",+ "definitions_feed.missing_flags",+ "definitions_feed.missing_group_type_mapping",+ "definitions_feed.unknown_field"+ ]+ },+ {+ "path": "fixtures/wire/responses.json",+ "kind": "fixture_set",+ "version": "1.0.0",+ "schema": "schemas/flags_response_v3.schema.json",+ "case_ids": [+ "responses.targeting_match_targeted_release",+ "responses.missing_id",+ "responses.missing_version",+ "responses.missing_config_version",+ "responses.targeting_match_targeted_release_missing_has_experiment",+ "responses.targeting_match_targeted_release_missing_rule_type",+ "responses.targeting_match_targeted_release_missing_rule_id",+ "responses.targeting_match_targeted_release_forbidden_experiment_id",+ "responses.targeting_match_targeted_release_forbidden_variant_key",+ "responses.targeting_match_targeted_release_forbidden_holdout_id",+ "responses.targeting_match_targeted_release_wrong_condition_index",+ "responses.targeting_match_targeted_release_forbidden_failed",+ "responses.targeting_match_targeted_release_flag_with_experiment",+ "responses.targeting_match_percentage_rollout",+ "responses.targeting_match_percentage_rollout_missing_has_experiment",+ "responses.targeting_match_percentage_rollout_missing_rule_type",+ "responses.targeting_match_percentage_rollout_missing_rule_id",+ "responses.targeting_match_percentage_rollout_forbidden_experiment_id",+ "responses.targeting_match_percentage_rollout_forbidden_variant_key",+ "responses.targeting_match_percentage_rollout_forbidden_holdout_id",+ "responses.targeting_match_percentage_rollout_wrong_condition_index",+ "responses.targeting_match_percentage_rollout_forbidden_failed",+ "responses.experiment_split",+ "responses.experiment_split_missing_has_experiment",+ "responses.experiment_split_missing_rule_type",+ "responses.experiment_split_missing_rule_id",+ "responses.experiment_split_missing_experiment_id",+ "responses.experiment_split_missing_variant_key",+ "responses.experiment_split_forbidden_holdout_id",+ "responses.experiment_split_wrong_condition_index",+ "responses.experiment_split_forbidden_failed",+ "responses.experiment_split_contradicted_has_experiment",+ "responses.rollout_miss_percentage_rollout",+ "responses.rollout_miss_percentage_rollout_missing_has_experiment",+ "responses.rollout_miss_percentage_rollout_missing_rule_type",+ "responses.rollout_miss_percentage_rollout_missing_rule_id",+ "responses.rollout_miss_percentage_rollout_forbidden_experiment_id",+ "responses.rollout_miss_percentage_rollout_forbidden_variant_key",+ "responses.rollout_miss_percentage_rollout_forbidden_holdout_id",+ "responses.rollout_miss_percentage_rollout_wrong_condition_index",+ "responses.rollout_miss_percentage_rollout_forbidden_failed",+ "responses.rollout_miss_experiment",+ "responses.rollout_miss_experiment_missing_has_experiment",+ "responses.rollout_miss_experiment_missing_rule_type",+ "responses.rollout_miss_experiment_missing_rule_id",+ "responses.rollout_miss_experiment_missing_experiment_id",+ "responses.rollout_miss_experiment_forbidden_variant_key",+ "responses.rollout_miss_experiment_forbidden_holdout_id",+ "responses.rollout_miss_experiment_wrong_condition_index",+ "responses.rollout_miss_experiment_forbidden_failed",+ "responses.experiment_paused",+ "responses.experiment_paused_missing_has_experiment",+ "responses.experiment_paused_missing_rule_type",+ "responses.experiment_paused_missing_rule_id",+ "responses.experiment_paused_missing_experiment_id",+ "responses.experiment_paused_forbidden_variant_key",+ "responses.experiment_paused_forbidden_holdout_id",+ "responses.experiment_paused_wrong_condition_index",+ "responses.experiment_paused_forbidden_failed",+ "responses.holdout",+ "responses.holdout_missing_has_experiment",+ "responses.holdout_missing_rule_type",+ "responses.holdout_missing_rule_id",+ "responses.holdout_missing_experiment_id",+ "responses.holdout_missing_holdout_id",+ "responses.holdout_forbidden_variant_key",+ "responses.holdout_wrong_condition_index",+ "responses.holdout_forbidden_failed",+ "responses.no_rule_match",+ "responses.no_rule_match_missing_has_experiment",+ "responses.no_rule_match_forbidden_rule_type",+ "responses.no_rule_match_forbidden_rule_id",+ "responses.no_rule_match_forbidden_experiment_id",+ "responses.no_rule_match_forbidden_variant_key",+ "responses.no_rule_match_forbidden_holdout_id",+ "responses.no_rule_match_wrong_condition_index",+ "responses.no_rule_match_forbidden_failed",+ "responses.missing_group_key",+ "responses.missing_group_key_missing_has_experiment",+ "responses.missing_group_key_forbidden_rule_type",+ "responses.missing_group_key_forbidden_rule_id",+ "responses.missing_group_key_forbidden_experiment_id",+ "responses.missing_group_key_forbidden_variant_key",+ "responses.missing_group_key_forbidden_holdout_id",+ "responses.missing_group_key_wrong_condition_index",+ "responses.missing_group_key_forbidden_failed",+ "responses.dependency_error",+ "responses.dependency_error_missing_has_experiment",+ "responses.dependency_error_forbidden_rule_type",+ "responses.dependency_error_forbidden_rule_id",+ "responses.dependency_error_forbidden_experiment_id",+ "responses.dependency_error_forbidden_variant_key",+ "responses.dependency_error_forbidden_holdout_id",+ "responses.dependency_error_wrong_condition_index",+ "responses.dependency_error_missing_failed",+ "responses.dependency_error_nonnull_value",+ "responses.error",+ "responses.error_missing_has_experiment",+ "responses.error_forbidden_rule_type",+ "responses.error_forbidden_rule_id",+ "responses.error_forbidden_experiment_id",+ "responses.error_forbidden_variant_key",+ "responses.error_forbidden_holdout_id",+ "responses.error_wrong_condition_index",+ "responses.error_missing_failed",+ "responses.error_nonnull_value",+ "responses.v1",+ "responses.omitted",+ "responses.split_wrong_type_config_version",+ "responses.split_wrong_type_rule_type",+ "responses.split_wrong_type_rule_id",+ "responses.split_wrong_type_experiment_id",+ "responses.split_wrong_type_variant_key",+ "responses.forbidden_legacy_enabled",+ "responses.forbidden_legacy_variant",+ "responses.split_arm_b_equal_value",+ "responses.split_string_value",+ "responses.null_default",+ "responses.request_failure_omission",+ "responses.missing_group_nonnull_value",+ "responses.v1_failed",+ "responses.v1_quick_win",+ "responses.v2_forced_variant",+ "responses.key_mismatch",+ "responses.failure_envelope",+ "responses.local_only_reason",+ "responses.nested_seed",+ "responses.passthrough_seed",+ "responses.reserved_number_wire_value",+ "responses.reserved_object_wire_value",+ "responses.targeting_match_targeted_release_wrong_rule_type",+ "responses.experiment_split_wrong_rule_type",+ "responses.rollout_miss_percentage_rollout_wrong_rule_type",+ "responses.rollout_miss_experiment_wrong_rule_type",+ "responses.experiment_paused_wrong_rule_type",+ "responses.holdout_wrong_rule_type",+ "responses.targeting_match_targeted_release_null_value",+ "responses.targeting_match_percentage_rollout_null_value",+ "responses.experiment_split_null_value",+ "responses.empty_v2_string",+ "responses.v1_experiment_without_linkage",+ "responses.v1_ambiguous_experiment",+ "responses.flag_key_seed",+ "responses.seed_named_flag_nested_seed",+ "responses.flag_key_assignment_seed",+ "responses.v1_forbidden_rule_id",+ "responses.v1_forbidden_rule_type",+ "responses.v1_forbidden_holdout_id",+ "responses.v1_object_payload",+ "responses.v1_null_value_not_failed"+ ]+ },+ {+ "path": "fixtures/wire/warnings.json",+ "kind": "fixture_set",+ "version": "1.0.0",+ "schema": "schemas/management_warning.schema.json",+ "case_ids": [+ "warnings.rule_order_changes_traffic",+ "warnings.unreachable_lower_rule",+ "warnings.rollout_miss_can_enter_lower_rule",+ "warnings.assignment_reset_changes_traffic",+ "warnings.conclusion_expands_population",+ "warnings.detail_and_attr",+ "warnings.unknown_code",+ "warnings.missing_code",+ "warnings.wrong_detail_type",+ "warnings.unknown_field"+ ]+ },+ {+ "path": "fixtures/wire/errors.json",+ "kind": "fixture_set",+ "version": "1.0.0",+ "schema": "schemas/management_error.schema.json",+ "case_ids": [+ "errors.validation",+ "errors.nonfield",+ "errors.missing_type",+ "errors.missing_code",+ "errors.missing_detail",+ "errors.missing_attr",+ "errors.wrong_detail_type",+ "errors.unknown_field"+ ]+ },+ {+ "path": "fixtures/wire/calls.json",+ "kind": "fixture_set",+ "version": "1.0.0",+ "schema": "schemas/feature_flag_called_context.schema.json",+ "case_ids": [+ "calls.targeting_match_targeted_release",+ "calls.targeting_match_targeted_release_missing_rule_type",+ "calls.targeting_match_targeted_release_missing_rule_id",+ "calls.targeting_match_targeted_release_forbidden_experiment_id",+ "calls.targeting_match_targeted_release_forbidden_variant_key",+ "calls.targeting_match_targeted_release_forbidden_holdout_id",+ "calls.targeting_match_percentage_rollout",+ "calls.targeting_match_percentage_rollout_missing_rule_type",+ "calls.targeting_match_percentage_rollout_missing_rule_id",+ "calls.targeting_match_percentage_rollout_forbidden_experiment_id",+ "calls.targeting_match_percentage_rollout_forbidden_variant_key",+ "calls.targeting_match_percentage_rollout_forbidden_holdout_id",+ "calls.experiment_split",+ "calls.experiment_split_missing_rule_type",+ "calls.experiment_split_missing_rule_id",+ "calls.experiment_split_missing_experiment_id",+ "calls.experiment_split_missing_variant_key",+ "calls.experiment_split_forbidden_holdout_id",+ "calls.rollout_miss_percentage_rollout",+ "calls.rollout_miss_percentage_rollout_missing_rule_type",+ "calls.rollout_miss_percentage_rollout_missing_rule_id",+ "calls.rollout_miss_percentage_rollout_forbidden_experiment_id",+ "calls.rollout_miss_percentage_rollout_forbidden_variant_key",+ "calls.rollout_miss_percentage_rollout_forbidden_holdout_id",+ "calls.rollout_miss_experiment",+ "calls.rollout_miss_experiment_missing_rule_type",+ "calls.rollout_miss_experiment_missing_rule_id",+ "calls.rollout_miss_experiment_missing_experiment_id",+ "calls.rollout_miss_experiment_forbidden_variant_key",+ "calls.rollout_miss_experiment_forbidden_holdout_id",+ "calls.experiment_paused",+ "calls.experiment_paused_missing_rule_type",+ "calls.experiment_paused_missing_rule_id",+ "calls.experiment_paused_missing_experiment_id",+ "calls.experiment_paused_forbidden_variant_key",+ "calls.experiment_paused_forbidden_holdout_id",+ "calls.holdout",+ "calls.holdout_missing_rule_type",+ "calls.holdout_missing_rule_id",+ "calls.holdout_missing_experiment_id",+ "calls.holdout_missing_holdout_id",+ "calls.holdout_forbidden_variant_key",+ "calls.no_rule_match",+ "calls.no_rule_match_forbidden_rule_type",+ "calls.no_rule_match_forbidden_rule_id",+ "calls.no_rule_match_forbidden_experiment_id",+ "calls.no_rule_match_forbidden_variant_key",+ "calls.no_rule_match_forbidden_holdout_id",+ "calls.missing_group_key",+ "calls.missing_group_key_forbidden_rule_type",+ "calls.missing_group_key_forbidden_rule_id",+ "calls.missing_group_key_forbidden_experiment_id",+ "calls.missing_group_key_forbidden_variant_key",+ "calls.missing_group_key_forbidden_holdout_id",+ "calls.dependency_error",+ "calls.dependency_error_forbidden_rule_type",+ "calls.dependency_error_forbidden_rule_id",+ "calls.dependency_error_forbidden_experiment_id",+ "calls.dependency_error_forbidden_variant_key",+ "calls.dependency_error_forbidden_holdout_id",+ "calls.error",+ "calls.error_forbidden_rule_type",+ "calls.error_forbidden_rule_id",+ "calls.error_forbidden_experiment_id",+ "calls.error_forbidden_variant_key",+ "calls.error_forbidden_holdout_id",+ "calls.v1",+ "calls.missing",+ "calls.inactive",+ "calls.v1_quick_win",+ "calls.arm_b_equal_value",+ "calls.string",+ "calls.v2_forced_variant",+ "calls.forbidden_value_number",+ "calls.forbidden_value_object",+ "calls.forbidden_value_array",+ "calls.forbidden_value_null",+ "calls.forbidden_value_empty_string",+ "calls.partial_split_diagnostic",+ "calls.inactive_forbidden_experiment_id",+ "calls.missing_feature_flag",+ "calls.missing_feature_flag_response",+ "calls.unknown_field"+ ]+ },+ {+ "path": "fixtures/wire/exposures.json",+ "kind": "fixture_set",+ "version": "1.0.0",+ "schema": "schemas/experiment_exposure_properties.schema.json",+ "case_ids": [+ "exposures.remote_split",+ "exposures.local_split",+ "exposures.arm_b_equal_value",+ "exposures.successor_experiment",+ "exposures.string",+ "exposures.missing_feature_flag",+ "exposures.wrong_type_feature_flag",+ "exposures.missing_feature_flag_response",+ "exposures.wrong_type_feature_flag_response",+ "exposures.missing_feature_flag_config_version",+ "exposures.wrong_type_feature_flag_config_version",+ "exposures.missing_feature_flag_reason_code",+ "exposures.wrong_type_feature_flag_reason_code",+ "exposures.missing_feature_flag_variant",+ "exposures.wrong_type_feature_flag_variant",+ "exposures.missing_feature_flag_rule_id",+ "exposures.wrong_type_feature_flag_rule_id",+ "exposures.missing_feature_flag_rule_type",+ "exposures.wrong_type_feature_flag_rule_type",+ "exposures.missing_feature_flag_experiment_id",+ "exposures.wrong_type_feature_flag_experiment_id",+ "exposures.missing_experiment_exposure_source",+ "exposures.wrong_type_experiment_exposure_source",+ "exposures.missing_locally_evaluated",+ "exposures.wrong_type_locally_evaluated",+ "exposures.forbidden_outcome_holdout",+ "exposures.forbidden_outcome_pause",+ "exposures.forbidden_outcome_rollout_miss",+ "exposures.forbidden_outcome_no_rule",+ "exposures.forbidden_outcome_failed",+ "exposures.forbidden_value_object",+ "exposures.forbidden_value_array",+ "exposures.forbidden_value_null",+ "exposures.forbidden_value_empty_string",+ "exposures.holdout_context",+ "exposures.ingestion_source",+ "exposures.v1_config",+ "exposures.forced_variant_context",+ "exposures.unknown_field"+ ]+ },+ {+ "path": "fixtures/wire/readers.json",+ "kind": "fixture_set",+ "version": "1.0.0",+ "schema": "schemas/flags_response_v3.schema.json",+ "case_ids": [+ "readers.complete_split",+ "readers.partial_split_missing_config_version",+ "readers.partial_split_missing_rule_type",+ "readers.partial_split_missing_rule_id",+ "readers.partial_split_missing_experiment_id",+ "readers.partial_split_missing_variant_key",+ "readers.split_wrong_type_config_version",+ "readers.split_wrong_type_rule_type",+ "readers.split_wrong_type_rule_id",+ "readers.split_wrong_type_experiment_id",+ "readers.split_wrong_type_variant_key",+ "readers.wrong_rule_type_literal",+ "readers.unknown_fields",+ "readers.old_server_variant",+ "readers.old_server_boolean",+ "readers.old_server_null_variant",+ "readers.old_server_false",+ "readers.v3_value_takes_precedence",+ "readers.missing_flag",+ "readers.targeting_match_targeted_release",+ "readers.targeting_match_percentage_rollout",+ "readers.rollout_miss_percentage_rollout",+ "readers.rollout_miss_experiment",+ "readers.experiment_paused",+ "readers.holdout",+ "readers.holdout_variant_key",+ "readers.no_rule_match",+ "readers.missing_group_key",+ "readers.dependency_error",+ "readers.error",+ "readers.error_with_value",+ "readers.malformed_sibling_isolation",+ "readers.partial_split_string_value",+ "readers.v1_at_v3",+ "readers.v1_failed",+ "readers.integral_json_number_context",+ "readers.flag_key_seed"+ ]+ },+ {+ "path": "fixtures/wire/exposure_transport.json",+ "kind": "fixture_set",+ "version": "1.0.0",+ "schema": "schemas/experiment_exposure_properties.schema.json",+ "case_ids": [+ "exposure_transport.exposure_with_transport",+ "exposure_transport.nested_seed",+ "exposure_transport.nested_holdout_seed",+ "exposure_transport.holdout_context",+ "exposure_transport.forced_variant_context",+ "exposure_transport.group_type_named_seed"+ ]+ },+ {+ "path": "fixtures/wire/call_transport.json",+ "kind": "fixture_set",+ "version": "1.0.0",+ "schema": "schemas/feature_flag_called_context.schema.json",+ "case_ids": [+ "call_transport.call_with_transport",+ "call_transport.nested_assignment_seed",+ "call_transport.prefixed_seed",+ "call_transport.person_property_named_seed"+ ]+ }+ ],+ "wire_contract": {+ "version": "1.0.0",+ "fixture_version": "1.0.0",+ "published_versions_are_immutable": true,+ "producer_schema_sha256": "1dd97730c746bc4534c4f47eebd82dac0cc67ceb1e4c53e7540960e7f74b00d9",+ "fixture_encoding": "Each case deep-copies its named template, removes the listed existing JSON Pointer members, then sets members by JSON Pointer. Set requires an existing parent. Templates and expectations are JSON, not executable SDK suites.",+ "compatibility": "New artifacts are additive to contract 1.2.0. Published schema bytes and fixture expectations are immutable. Accepted/rejected wire-contract changes require a new major wire component version; additive cases require a new minor fixture version. Reader expectations never relax producer validation."+ }+}diff --git a/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/registries/literals.json b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/registries/literals.jsonnew file mode 100644index 000000000000..ed8065689791--- /dev/null+++ b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/registries/literals.json@@ -0,0 +1,297 @@+{+ "registry_version": "2.0.0",+ "config_versions": {+ "v1": 1,+ "v2": 2,+ "absent_version_selects": "v1",+ "unknown_version_result": "unsupported",+ "version_comparison": "A JSON number selects the version it equals mathematically, so 2.0 selects v2. A JSON string or boolean never selects a version."+ },+ "fields": [+ "aggregation_group_type_index",+ "assign_by",+ "assignment_algorithm",+ "cohort_name",+ "default_value",+ "description",+ "exclusion_percentage",+ "experiment_id",+ "group_key_names",+ "group_type_index",+ "holdout",+ "id",+ "key",+ "label",+ "metadata",+ "negation",+ "on_rollout_miss",+ "operator",+ "paused",+ "properties",+ "return_type",+ "rollout_percentage",+ "rule_type",+ "rules",+ "seed",+ "targeting",+ "type",+ "value",+ "variants",+ "version",+ "weight"+ ],+ "rule_types": [+ {+ "value": "targeted_release",+ "writer_status": "enabled"+ },+ {+ "value": "percentage_rollout",+ "writer_status": "enabled"+ },+ {+ "value": "experiment",+ "writer_status": "enabled"+ }+ ],+ "return_types": [+ {+ "value": "boolean",+ "writer_status": "enabled"+ },+ {+ "value": "string",+ "writer_status": "enabled"+ },+ {+ "value": "number",+ "writer_status": "reserved"+ },+ {+ "value": "object",+ "writer_status": "reserved"+ }+ ],+ "rollout_miss_policies": [+ "continue",+ "return_default"+ ],+ "assignment_targets": [+ "person"+ ],+ "assignment_algorithms": [+ "sha1_60_v1"+ ],+ "property_types": [+ "person",+ "cohort",+ "group",+ "flag"+ ],+ "property_operators": [+ "exact",+ "is_not",+ "icontains",+ "not_icontains",+ "icontains_multi",+ "not_icontains_multi",+ "starts_with",+ "not_starts_with",+ "ends_with",+ "not_ends_with",+ "regex",+ "not_regex",+ "gt",+ "gte",+ "lt",+ "lte",+ "semver_gt",+ "semver_gte",+ "semver_lt",+ "semver_lte",+ "semver_eq",+ "semver_neq",+ "semver_tilde",+ "semver_caret",+ "semver_wildcard",+ "is_set",+ "is_not_set",+ "is_date_exact",+ "is_date_after",+ "is_date_before",+ "in",+ "not_in",+ "flag_evaluates_to"+ ],+ "reason_codes": [+ "targeting_match",+ "experiment_split",+ "rollout_miss",+ "experiment_paused",+ "holdout",+ "no_rule_match",+ "flag_disabled",+ "missing_group_key",+ "dependency_error",+ "error"+ ],+ "openfeature_mapping": {+ "specification": "https://openfeature.dev/specification/",+ "reason_codes": {+ "targeting_match": {+ "reason": "TARGETING_MATCH",+ "error_code": null,+ "note": "Targeted release, or percentage rollout inclusion. TARGETING_MATCH is this contract's choice for rollout inclusion; OpenFeature also describes pseudorandom assignment with SPLIT and permits custom reasons."+ },+ "experiment_split": {+ "reason": "SPLIT",+ "error_code": null,+ "note": "Experiment identity is in flag metadata."+ },+ "rollout_miss": {+ "reason": "DEFAULT",+ "error_code": null,+ "note": "A terminal rollout miss under return_default. Value is default_value, or the caller default when null. A continuing miss moves evaluation to the next rule and contributes neither a reason code nor metadata from the missed rule (including rule_id and condition_index) to the final result. The final result uses the terminating rule's reason and metadata, or no_rule_match if no rule terminates."+ },+ "experiment_paused": {+ "reason": "DEFAULT",+ "error_code": null,+ "note": "Value is default_value, or the caller default when null."+ },+ "holdout": {+ "reason": "DEFAULT",+ "error_code": null,+ "note": "Value is default_value, or the caller default when null."+ },+ "no_rule_match": {+ "reason": "DEFAULT",+ "error_code": null,+ "note": "No rule produced a terminal result, including when targeting matched but rollout missed with continue. Value is default_value, or the caller default when null."+ },+ "flag_disabled": {+ "reason": "DISABLED",+ "error_code": null,+ "note": "Local definitions only. Remote responses omit an inactive flag."+ },+ "missing_group_key": {+ "reason": "ERROR",+ "error_code": "INVALID_CONTEXT",+ "note": "The required group key is missing from additional evaluation-context fields. If a provider binds the group key to OpenFeature targetingKey and that field is missing, use TARGETING_KEY_MISSING instead."+ },+ "dependency_error": {+ "reason": "ERROR",+ "error_code": "GENERAL",+ "note": "A dependency is unknown, cyclic, or otherwise unresolvable. reason.description becomes the error message."+ },+ "error": {+ "reason": "ERROR",+ "error_code": "GENERAL",+ "note": "reason.description becomes the error message."+ }+ },+ "outcomes_without_reason_code": [+ {+ "situation": "Flag absent from the remote response",+ "reason": "ERROR",+ "error_code": "FLAG_NOT_FOUND",+ "note": "Typed accessor returns the caller default."+ },+ {+ "situation": "Unsupported config version or unknown semantic field in definitions, strict local mode",+ "reason": "ERROR",+ "error_code": "PARSE_ERROR",+ "note": "Auto mode falls back remotely before this."+ },+ {+ "situation": "Typed accessor asked for a type the flag does not return",+ "reason": "ERROR",+ "error_code": "TYPE_MISMATCH",+ "note": "No coercion."+ },+ {+ "situation": "Bootstrap value used",+ "reason": "CACHED",+ "error_code": null,+ "note": "STALE when the SDK knows definitions are outdated. No experiment context, no exposure."+ },+ {+ "situation": "Client-side override",+ "reason": "override",+ "error_code": null,+ "note": "Custom reason string. Never TARGETING_MATCH; suppresses $experiment_exposure."+ },+ {+ "situation": "Provider not initialised",+ "reason": "ERROR",+ "error_code": "PROVIDER_NOT_READY",+ "note": "Provider concern."+ }+ ],+ "flag_metadata_keys": [+ "config_version",+ "rule_type",+ "rule_id",+ "experiment_id",+ "variant_key",+ "holdout_id",+ "id",+ "version",+ "reason_code",+ "condition_index"+ ]+ },+ "warning_codes": [+ "RULE_ORDER_CHANGES_TRAFFIC",+ "UNREACHABLE_LOWER_RULE",+ "ROLLOUT_MISS_CAN_ENTER_LOWER_RULE",+ "ASSIGNMENT_RESET_CHANGES_TRAFFIC",+ "CONCLUSION_EXPANDS_POPULATION"+ ],+ "semantic_constraints": [+ {+ "id": "rule_ids_unique",+ "scope": "rules",+ "requirement": "Each rule id is unique in one config. For example, two rules in one config with id aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa are invalid even if their rule_type differs; the same id may appear in separate configs."+ },+ {+ "id": "variant_keys_unique",+ "scope": "rules[].variants",+ "requirement": "Each variant key is unique in one variant list. For example, [control, test] is valid and [control, control] is invalid within one rule. Separate rules may each use control and test."+ },+ {+ "id": "variant_weights_sum_100",+ "scope": "rules[].variants",+ "requirement": "Each variant weight is a percentage of subjects enrolled by the rule. Weights sum to exactly 100 in stored order; rollout_percentage separately controls enrollment into the rule. For example, [33.33, 33.33, 33.34] is valid, while [33.33, 33.33, 33.33] totals 99.99 and is invalid. Validate the stored decimal percentages exactly (for example, as integer hundredths totaling 10000); do not round an invalid sum to 100. This validation is separate from binary64 accumulation during assignment."+ },+ {+ "id": "percentage_two_decimals",+ "scope": "all rollout_percentage, weight, and exclusion_percentage values",+ "requirement": "Percentages have at most two decimal places. JSON Schema multipleOf is not used because binary64 division is inexact for values such as 33.33."+ },+ {+ "id": "number_is_binary64",+ "scope": "all number and object values",+ "requirement": "Numbers are finite IEEE-754 binary64 values. Negative zero normalizes to zero. Nonzero underflow to zero is invalid."+ },+ {+ "id": "json_keys_unique",+ "scope": "all object values",+ "requirement": "JSON object keys are unique at every depth before ordinary deserialization."+ },+ {+ "id": "json_depth_limit",+ "scope": "all object values",+ "requirement": "Object values contain at most 20 object/array levels, counting the root object as level 1. Scalar leaves do not add a level. The config schema enforces this bound with numbered definitions."+ },+ {+ "id": "assignment_target_context",+ "scope": "randomized rules",+ "requirement": "Explicit person assignment is valid only for person flags. Group flags use the flag aggregation key and omit assign_by. The config schema enforces omission of assign_by whenever aggregation_group_type_index is present, including index 0."+ },+ {+ "id": "contextual_size_limits",+ "scope": "config and metadata",+ "requirement": "The deployment config byte limit and the metadata size limit apply outside JSON Schema validation."+ }+ ]+}diff --git a/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/schemas/config.schema.json b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/schemas/config.schema.jsonnew file mode 100644index 000000000000..f44d12f0c44a--- /dev/null+++ b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/schemas/config.schema.json@@ -0,0 +1,1005 @@+{+ "$schema": "https://json-schema.org/draft/2020-12/schema",+ "$id": "urn:posthog:feature-flag-rules-v2:config:1.0.0",+ "title": "Feature Flag Rules v2 config",+ "description": "Canonical stored configuration for Feature Flag Rules config version 2.",+ "type": "object",+ "required": [+ "version",+ "return_type",+ "default_value",+ "rules"+ ],+ "properties": {+ "version": {+ "const": 2+ },+ "return_type": {+ "enum": [+ "boolean",+ "string",+ "number",+ "object"+ ]+ },+ "default_value": {+ "description": "Flag default for a normal result with no assigned value. Null delegates to the caller default. OpenFeature uses the caller default on abnormal execution regardless of this setting."+ },+ "rules": {+ "type": "array",+ "maxItems": 100,+ "items": {+ "$ref": "#/$defs/rule"+ }+ },+ "aggregation_group_type_index": {+ "type": "integer"+ }+ },+ "additionalProperties": false,+ "allOf": [+ {+ "if": {+ "properties": {+ "return_type": {+ "const": "boolean"+ }+ },+ "required": [+ "return_type"+ ]+ },+ "then": {+ "properties": {+ "default_value": {+ "type": [+ "boolean",+ "null"+ ]+ },+ "rules": {+ "items": {+ "$ref": "#/$defs/booleanRuleValues"+ }+ }+ }+ }+ },+ {+ "if": {+ "properties": {+ "return_type": {+ "const": "string"+ }+ },+ "required": [+ "return_type"+ ]+ },+ "then": {+ "properties": {+ "default_value": {+ "anyOf": [+ {+ "$ref": "#/$defs/stringValue"+ },+ {+ "type": "null"+ }+ ]+ },+ "rules": {+ "items": {+ "$ref": "#/$defs/stringRuleValues"+ }+ }+ }+ }+ },+ {+ "if": {+ "properties": {+ "return_type": {+ "const": "number"+ }+ },+ "required": [+ "return_type"+ ]+ },+ "then": {+ "properties": {+ "default_value": {+ "anyOf": [+ {+ "$ref": "#/$defs/safeNumber"+ },+ {+ "type": "null"+ }+ ]+ },+ "rules": {+ "items": {+ "$ref": "#/$defs/numberRuleValues"+ }+ }+ }+ }+ },+ {+ "if": {+ "properties": {+ "return_type": {+ "const": "object"+ }+ },+ "required": [+ "return_type"+ ]+ },+ "then": {+ "properties": {+ "default_value": {+ "anyOf": [+ {+ "$ref": "#/$defs/jsonObjectValue"+ },+ {+ "type": "null"+ }+ ]+ },+ "rules": {+ "items": {+ "$ref": "#/$defs/objectRuleValues"+ }+ }+ }+ }+ },+ {+ "if": {+ "required": [+ "aggregation_group_type_index"+ ]+ },+ "then": {+ "properties": {+ "rules": {+ "items": {+ "not": {+ "required": [+ "assign_by"+ ]+ }+ }+ }+ }+ }+ }+ ],+ "$defs": {+ "uuid": {+ "type": "string",+ "format": "uuid",+ "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"+ },+ "percentage": {+ "type": "number",+ "minimum": 0,+ "maximum": 100+ },+ "seed": {+ "type": "string",+ "minLength": 1,+ "maxLength": 400+ },+ "stringValue": {+ "type": "string",+ "minLength": 1+ },+ "safeNumber": {+ "type": "number",+ "minimum": -9007199254740991,+ "maximum": 9007199254740991+ },+ "jsonObjectValue": {+ "type": "object",+ "additionalProperties": {+ "$ref": "#/$defs/jsonValueDepth2"+ },+ "x-posthog-open-object": "application_json_value",+ "description": "At most 20 object/array levels, counting this root object as level 1. Scalar leaves do not add a level. Numbered definitions bound validation recursion."+ },+ "metadata": {+ "type": "object",+ "additionalProperties": true,+ "x-posthog-open-object": "opaque_metadata"+ },+ "groupKeyNames": {+ "anyOf": [+ {+ "type": "null"+ },+ {+ "type": "object",+ "additionalProperties": {+ "type": "string"+ },+ "x-posthog-open-object": "display_group_key_names"+ }+ ]+ },+ "propertyFilter": {+ "type": "object",+ "required": [+ "key",+ "type"+ ],+ "properties": {+ "key": {+ "type": "string",+ "minLength": 1+ },+ "value": {},+ "type": {+ "enum": [+ "person",+ "cohort",+ "group",+ "flag"+ ]+ },+ "operator": {+ "anyOf": [+ {+ "enum": [+ "exact",+ "is_not",+ "icontains",+ "not_icontains",+ "icontains_multi",+ "not_icontains_multi",+ "starts_with",+ "not_starts_with",+ "ends_with",+ "not_ends_with",+ "regex",+ "not_regex",+ "gt",+ "gte",+ "lt",+ "lte",+ "semver_gt",+ "semver_gte",+ "semver_lt",+ "semver_lte",+ "semver_eq",+ "semver_neq",+ "semver_tilde",+ "semver_caret",+ "semver_wildcard",+ "is_set",+ "is_not_set",+ "is_date_exact",+ "is_date_after",+ "is_date_before",+ "in",+ "not_in",+ "flag_evaluates_to"+ ]+ },+ {+ "type": "null"+ }+ ]+ },+ "group_type_index": {+ "type": [+ "integer",+ "null"+ ]+ },+ "negation": {+ "type": [+ "boolean",+ "null"+ ]+ },+ "cohort_name": {+ "type": [+ "string",+ "null"+ ]+ },+ "group_key_names": {+ "$ref": "#/$defs/groupKeyNames"+ },+ "label": {+ "type": [+ "string",+ "null"+ ]+ }+ },+ "additionalProperties": false+ },+ "targeting": {+ "type": "object",+ "required": [+ "properties"+ ],+ "properties": {+ "properties": {+ "type": "array",+ "maxItems": 100,+ "items": {+ "$ref": "#/$defs/propertyFilter"+ }+ }+ },+ "additionalProperties": false+ },+ "variant": {+ "type": "object",+ "required": [+ "key",+ "weight",+ "value"+ ],+ "properties": {+ "key": {+ "type": "string",+ "minLength": 1,+ "pattern": "^[a-zA-Z0-9_-]+$"+ },+ "weight": {+ "description": "Percentage of subjects enrolled by the rule assigned to this variant. Variant weights sum to exactly 100; the rule's rollout_percentage separately controls enrollment.",+ "$ref": "#/$defs/percentage"+ },+ "value": {}+ },+ "additionalProperties": false+ },+ "holdout": {+ "type": "object",+ "required": [+ "id",+ "seed",+ "exclusion_percentage"+ ],+ "properties": {+ "id": {+ "type": "integer"+ },+ "seed": {+ "$ref": "#/$defs/seed"+ },+ "exclusion_percentage": {+ "$ref": "#/$defs/percentage"+ }+ },+ "additionalProperties": false+ },+ "targetedReleaseRule": {+ "type": "object",+ "required": [+ "id",+ "rule_type",+ "targeting",+ "value"+ ],+ "properties": {+ "id": {+ "$ref": "#/$defs/uuid"+ },+ "rule_type": {+ "const": "targeted_release"+ },+ "targeting": {+ "$ref": "#/$defs/targeting"+ },+ "description": {+ "type": "string"+ },+ "metadata": {+ "$ref": "#/$defs/metadata"+ },+ "value": {}+ },+ "additionalProperties": false+ },+ "percentageRolloutRule": {+ "type": "object",+ "required": [+ "id",+ "rule_type",+ "targeting",+ "value",+ "rollout_percentage",+ "on_rollout_miss",+ "assignment_algorithm",+ "seed"+ ],+ "properties": {+ "id": {+ "$ref": "#/$defs/uuid"+ },+ "rule_type": {+ "const": "percentage_rollout"+ },+ "targeting": {+ "$ref": "#/$defs/targeting"+ },+ "description": {+ "type": "string"+ },+ "metadata": {+ "$ref": "#/$defs/metadata"+ },+ "value": {},+ "rollout_percentage": {+ "$ref": "#/$defs/percentage"+ },+ "on_rollout_miss": {+ "enum": [+ "continue",+ "return_default"+ ]+ },+ "assignment_algorithm": {+ "const": "sha1_60_v1"+ },+ "seed": {+ "$ref": "#/$defs/seed"+ },+ "assign_by": {+ "const": "person"+ }+ },+ "additionalProperties": false+ },+ "experimentRule": {+ "type": "object",+ "required": [+ "id",+ "rule_type",+ "targeting",+ "experiment_id",+ "paused",+ "rollout_percentage",+ "on_rollout_miss",+ "assignment_algorithm",+ "seed",+ "variants"+ ],+ "properties": {+ "id": {+ "$ref": "#/$defs/uuid"+ },+ "rule_type": {+ "const": "experiment"+ },+ "targeting": {+ "$ref": "#/$defs/targeting"+ },+ "description": {+ "type": "string"+ },+ "metadata": {+ "$ref": "#/$defs/metadata"+ },+ "experiment_id": {+ "type": "integer"+ },+ "paused": {+ "type": "boolean"+ },+ "rollout_percentage": {+ "$ref": "#/$defs/percentage"+ },+ "on_rollout_miss": {+ "enum": [+ "continue",+ "return_default"+ ]+ },+ "assignment_algorithm": {+ "const": "sha1_60_v1"+ },+ "seed": {+ "$ref": "#/$defs/seed"+ },+ "assign_by": {+ "const": "person"+ },+ "variants": {+ "type": "array",+ "minItems": 2,+ "maxItems": 20,+ "items": {+ "$ref": "#/$defs/variant"+ }+ },+ "holdout": {+ "$ref": "#/$defs/holdout"+ }+ },+ "additionalProperties": false+ },+ "rule": {+ "oneOf": [+ {+ "$ref": "#/$defs/targetedReleaseRule"+ },+ {+ "$ref": "#/$defs/percentageRolloutRule"+ },+ {+ "$ref": "#/$defs/experimentRule"+ }+ ]+ },+ "booleanRuleValues": {+ "properties": {+ "value": {+ "type": "boolean"+ },+ "variants": {+ "items": {+ "properties": {+ "value": {+ "type": "boolean"+ }+ }+ }+ }+ }+ },+ "stringRuleValues": {+ "properties": {+ "value": {+ "$ref": "#/$defs/stringValue"+ },+ "variants": {+ "items": {+ "properties": {+ "value": {+ "$ref": "#/$defs/stringValue"+ }+ }+ }+ }+ }+ },+ "numberRuleValues": {+ "properties": {+ "value": {+ "$ref": "#/$defs/safeNumber"+ },+ "variants": {+ "items": {+ "properties": {+ "value": {+ "$ref": "#/$defs/safeNumber"+ }+ }+ }+ }+ }+ },+ "objectRuleValues": {+ "properties": {+ "value": {+ "$ref": "#/$defs/jsonObjectValue"+ },+ "variants": {+ "items": {+ "properties": {+ "value": {+ "$ref": "#/$defs/jsonObjectValue"+ }+ }+ }+ }+ }+ },+ "jsonScalarValue": {+ "oneOf": [+ {+ "type": "null"+ },+ {+ "type": "boolean"+ },+ {+ "$ref": "#/$defs/safeNumber"+ },+ {+ "type": "string"+ }+ ]+ },+ "jsonValueDepth2": {+ "oneOf": [+ {+ "$ref": "#/$defs/jsonScalarValue"+ },+ {+ "type": "array",+ "items": {+ "$ref": "#/$defs/jsonValueDepth3"+ }+ },+ {+ "type": "object",+ "additionalProperties": {+ "$ref": "#/$defs/jsonValueDepth3"+ },+ "x-posthog-open-object": "application_json_value"+ }+ ]+ },+ "jsonValueDepth3": {+ "oneOf": [+ {+ "$ref": "#/$defs/jsonScalarValue"+ },+ {+ "type": "array",+ "items": {+ "$ref": "#/$defs/jsonValueDepth4"+ }+ },+ {+ "type": "object",+ "additionalProperties": {+ "$ref": "#/$defs/jsonValueDepth4"+ },+ "x-posthog-open-object": "application_json_value"+ }+ ]+ },+ "jsonValueDepth4": {+ "oneOf": [+ {+ "$ref": "#/$defs/jsonScalarValue"+ },+ {+ "type": "array",+ "items": {+ "$ref": "#/$defs/jsonValueDepth5"+ }+ },+ {+ "type": "object",+ "additionalProperties": {+ "$ref": "#/$defs/jsonValueDepth5"+ },+ "x-posthog-open-object": "application_json_value"+ }+ ]+ },+ "jsonValueDepth5": {+ "oneOf": [+ {+ "$ref": "#/$defs/jsonScalarValue"+ },+ {+ "type": "array",+ "items": {+ "$ref": "#/$defs/jsonValueDepth6"+ }+ },+ {+ "type": "object",+ "additionalProperties": {+ "$ref": "#/$defs/jsonValueDepth6"+ },+ "x-posthog-open-object": "application_json_value"+ }+ ]+ },+ "jsonValueDepth6": {+ "oneOf": [+ {+ "$ref": "#/$defs/jsonScalarValue"+ },+ {+ "type": "array",+ "items": {+ "$ref": "#/$defs/jsonValueDepth7"+ }+ },+ {+ "type": "object",+ "additionalProperties": {+ "$ref": "#/$defs/jsonValueDepth7"+ },+ "x-posthog-open-object": "application_json_value"+ }+ ]+ },+ "jsonValueDepth7": {+ "oneOf": [+ {+ "$ref": "#/$defs/jsonScalarValue"+ },+ {+ "type": "array",+ "items": {+ "$ref": "#/$defs/jsonValueDepth8"+ }+ },+ {+ "type": "object",+ "additionalProperties": {+ "$ref": "#/$defs/jsonValueDepth8"+ },+ "x-posthog-open-object": "application_json_value"+ }+ ]+ },+ "jsonValueDepth8": {+ "oneOf": [+ {+ "$ref": "#/$defs/jsonScalarValue"+ },+ {+ "type": "array",+ "items": {+ "$ref": "#/$defs/jsonValueDepth9"+ }+ },+ {+ "type": "object",+ "additionalProperties": {+ "$ref": "#/$defs/jsonValueDepth9"+ },+ "x-posthog-open-object": "application_json_value"+ }+ ]+ },+ "jsonValueDepth9": {+ "oneOf": [+ {+ "$ref": "#/$defs/jsonScalarValue"+ },+ {+ "type": "array",+ "items": {+ "$ref": "#/$defs/jsonValueDepth10"+ }+ },+ {+ "type": "object",+ "additionalProperties": {+ "$ref": "#/$defs/jsonValueDepth10"+ },+ "x-posthog-open-object": "application_json_value"+ }+ ]+ },+ "jsonValueDepth10": {+ "oneOf": [+ {+ "$ref": "#/$defs/jsonScalarValue"+ },+ {+ "type": "array",+ "items": {+ "$ref": "#/$defs/jsonValueDepth11"+ }+ },+ {+ "type": "object",+ "additionalProperties": {+ "$ref": "#/$defs/jsonValueDepth11"+ },+ "x-posthog-open-object": "application_json_value"+ }+ ]+ },+ "jsonValueDepth11": {+ "oneOf": [+ {+ "$ref": "#/$defs/jsonScalarValue"+ },+ {+ "type": "array",+ "items": {+ "$ref": "#/$defs/jsonValueDepth12"+ }+ },+ {+ "type": "object",+ "additionalProperties": {+ "$ref": "#/$defs/jsonValueDepth12"+ },+ "x-posthog-open-object": "application_json_value"+ }+ ]+ },+ "jsonValueDepth12": {+ "oneOf": [+ {+ "$ref": "#/$defs/jsonScalarValue"+ },+ {+ "type": "array",+ "items": {+ "$ref": "#/$defs/jsonValueDepth13"+ }+ },+ {+ "type": "object",+ "additionalProperties": {+ "$ref": "#/$defs/jsonValueDepth13"+ },+ "x-posthog-open-object": "application_json_value"+ }+ ]+ },+ "jsonValueDepth13": {+ "oneOf": [+ {+ "$ref": "#/$defs/jsonScalarValue"+ },+ {+ "type": "array",+ "items": {+ "$ref": "#/$defs/jsonValueDepth14"+ }+ },+ {+ "type": "object",+ "additionalProperties": {+ "$ref": "#/$defs/jsonValueDepth14"+ },+ "x-posthog-open-object": "application_json_value"+ }+ ]+ },+ "jsonValueDepth14": {+ "oneOf": [+ {+ "$ref": "#/$defs/jsonScalarValue"+ },+ {+ "type": "array",+ "items": {+ "$ref": "#/$defs/jsonValueDepth15"+ }+ },+ {+ "type": "object",+ "additionalProperties": {+ "$ref": "#/$defs/jsonValueDepth15"+ },+ "x-posthog-open-object": "application_json_value"+ }+ ]+ },+ "jsonValueDepth15": {+ "oneOf": [+ {+ "$ref": "#/$defs/jsonScalarValue"+ },+ {+ "type": "array",+ "items": {+ "$ref": "#/$defs/jsonValueDepth16"+ }+ },+ {+ "type": "object",+ "additionalProperties": {+ "$ref": "#/$defs/jsonValueDepth16"+ },+ "x-posthog-open-object": "application_json_value"+ }+ ]+ },+ "jsonValueDepth16": {+ "oneOf": [+ {+ "$ref": "#/$defs/jsonScalarValue"+ },+ {+ "type": "array",+ "items": {+ "$ref": "#/$defs/jsonValueDepth17"+ }+ },+ {+ "type": "object",+ "additionalProperties": {+ "$ref": "#/$defs/jsonValueDepth17"+ },+ "x-posthog-open-object": "application_json_value"+ }+ ]+ },+ "jsonValueDepth17": {+ "oneOf": [+ {+ "$ref": "#/$defs/jsonScalarValue"+ },+ {+ "type": "array",+ "items": {+ "$ref": "#/$defs/jsonValueDepth18"+ }+ },+ {+ "type": "object",+ "additionalProperties": {+ "$ref": "#/$defs/jsonValueDepth18"+ },+ "x-posthog-open-object": "application_json_value"+ }+ ]+ },+ "jsonValueDepth18": {+ "oneOf": [+ {+ "$ref": "#/$defs/jsonScalarValue"+ },+ {+ "type": "array",+ "items": {+ "$ref": "#/$defs/jsonValueDepth19"+ }+ },+ {+ "type": "object",+ "additionalProperties": {+ "$ref": "#/$defs/jsonValueDepth19"+ },+ "x-posthog-open-object": "application_json_value"+ }+ ]+ },+ "jsonValueDepth19": {+ "oneOf": [+ {+ "$ref": "#/$defs/jsonScalarValue"+ },+ {+ "type": "array",+ "items": {+ "$ref": "#/$defs/jsonValueDepth20"+ }+ },+ {+ "type": "object",+ "additionalProperties": {+ "$ref": "#/$defs/jsonValueDepth20"+ },+ "x-posthog-open-object": "application_json_value"+ }+ ]+ },+ "jsonValueDepth20": {+ "oneOf": [+ {+ "$ref": "#/$defs/jsonScalarValue"+ },+ {+ "type": "array",+ "items": {+ "$ref": "#/$defs/jsonScalarValue"+ }+ },+ {+ "type": "object",+ "additionalProperties": {+ "$ref": "#/$defs/jsonScalarValue"+ },+ "x-posthog-open-object": "application_json_value"+ }+ ]+ }+ }+}diff --git a/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/schemas/definitions_entry.schema.json b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/schemas/definitions_entry.schema.jsonnew file mode 100644index 000000000000..8be58d048b0d--- /dev/null+++ b/rust/feature-flags/tests/fixtures/rules_v2_parser/2.1.0/schemas/definitions_entry.schema.json@@ -0,0 +1,86 @@+{+ "$schema": "https://json-schema.org/draft/2020-12/schema",+ "$id": "https://posthog.com/contracts/feature_flag_rules_v2/definitions_entry.schema.json",+ "title": "Versioned definitions entry",+ "type": "object",+ "additionalProperties": false,+ "required": [+ "id",+ "key",+ "active",+ "filters"+ ],+ "properties": {+ "id": {+ "type": "integer"+ },+ "key": {+ "type": "string",+ "minLength": 1+ },+ "active": {+ "type": "boolean"+ },+ "filters": {+ "oneOf": [+ {+ "type": "object",+ "properties": {+ "version": {+ "const": 1+ }+ },+ "additionalProperties": true,+ "x-posthog-open-object": "Existing v1 filters remain opaque here; this schema only selects the version."+ },+ {+ "$ref": "urn:posthog:feature-flag-rules-v2:config:1.0.0"+ }+ ]+ },+ "version": {+ "type": [+ "integer",+ "null"+ ],+ "minimum": 0+ },+ "deleted": {+ "type": "boolean"+ },+ "name": {+ "type": "string"+ },+ "team_id": {+ "type": "integer"+ },+ "ensure_experience_continuity": {+ "type": [+ "boolean",+ "null"+ ]+ },+ "evaluation_runtime": {+ "type": [+ "string",+ "null"+ ]+ },+ "bucketing_identifier": {+ "type": [+ "string",+ "null"+ ]+ },+ "evaluation_contexts": {+ "type": "array",+ "items": {+ "type": "string"+ }+ },+ "has_experiment": {+ "type": "boolean"+ }+ },+ "description": "The config discriminator is filters.version, independent of the optional row version. Canonical v2 filters include assignment seeds. V1 filter semantics remain owned by the legacy evaluator."+}diff --git a/rust/feature-flags/tests/test_config_format.rs b/rust/feature-flags/tests/test_config_format.rsindex 3a5548769148..125535f73663 100644--- a/rust/feature-flags/tests/test_config_format.rs+++ b/rust/feature-flags/tests/test_config_format.rs@@ -2,17 +2,19 @@ use std::collections::HashMap;use std::sync::Arc;use anyhow::Result;+use common_hypercache::{HyperCacheConfig, HyperCacheReader, KeyType};+use common_s3::MockS3Client;use feature_flags::cohorts::cohort_cache_manager::CohortCacheManager;use feature_flags::config::DEFAULT_TEST_CONFIG;use feature_flags::flags::cache_builder::build_flags_cache;use feature_flags::flags::feature_flag_list::PreparedFlags;use feature_flags::flags::flag_matching::FeatureFlagMatcher;use feature_flags::flags::flag_models::{- EvaluationMetadata, FeatureFlag, FeatureFlagList, FeatureFlagRow,+ EvaluationMetadata, FeatureFlag, FeatureFlagList, FeatureFlagRow, HypercacheFlagsWrapper,};use feature_flags::utils::test_utils::{- insert_flags_for_team_in_redis, mock_group_type_cache, setup_redis_client,- update_team_in_hypercache, TestContext,+ mock_group_type_cache, setup_redis_client, update_team_in_hypercache,+ write_flags_wire_json_to_redis, TestContext,};use rstest::rstest;use serde_json::{json, Value};@@ -22,10 +24,52 @@ pub mod common;fn documents() -> Vec<(String, Value, bool, bool)> {let mut cases = Vec::new();+ let supported: Value = serde_json::from_str(include_str!(+ "fixtures/rules_v2_parser/2.1.0/fixtures/config/valid/boolean_targeted_and_percentage_rollout.json"+ )).unwrap();+ cases.push((+ "rejected-valid-v2".to_string(),+ supported.clone(),+ true,+ false,+ ));+ let mut rounded = supported.clone();+ rounded["version"] = json!("__rounds_to_two__");+ cases.push(("rejected-rounded-v2".to_string(), rounded, true, false));+ let mut near_one = supported.clone();+ near_one["version"] = json!("__below_one__");+ cases.push(("rejected-below-one".to_string(), near_one, true, false));+ let mut unsupported = supported.clone();+ unsupported["rules"]+ .as_array_mut()+ .unwrap()+ .push(json!({"rule_type": "experiment"}));+ cases.push((+ "rejected-unsupported-v2".to_string(),+ unsupported,+ true,+ false,+ ));+ let mut overprecise = supported.clone();+ overprecise["rules"][1]["rollout_percentage"] = json!("__overprecise__");+ cases.push((+ "rejected-overprecise-v2".to_string(),+ overprecise,+ true,+ false,+ ));+ cases.push((+ "inactive-valid-v2".to_string(),+ supported.clone(),+ false,+ false,+ ));+ cases.push(("deleted-valid-v2".to_string(), supported, true, true));for (key, version) in [("absent", None),("one", Some(json!(1))),("one-float", Some(json!(1.0))),+ ("one-rounded", Some(json!("__rounds_to_one__"))),] {let mut filters = json!({"groups": [{"rollout_percentage": 100}], "payloads": {"true": "example-payload"}});if let Some(version) = version {@@ -80,6 +124,21 @@ fn documents() -> Vec<(String, Value, bool, bool)> {cases}+const RAW_NUMBERS: &[(&str, &str, &str)] = &[+ (+ "rejected-overprecise-v2",+ "__overprecise__",+ "33.330000000000000001",+ ),+ ("one-rounded", "__rounds_to_one__", "1.0000000000000001"),+ ("rejected-below-one", "__below_one__", "0.9999999999999999"),+ (+ "rejected-rounded-v2",+ "__rounds_to_two__",+ "2.0000000000000001",+ ),+];+#[rstest]#[case::redis(true)]#[case::postgres_fallback(false)]@@ -115,12 +174,75 @@ async fn config_dispatch_preserves_siblings_and_wire_errors(#[case] cached: bool}}if cached {- insert_flags_for_team_in_redis(redis, team.id, Some(json!(flags).to_string())).await?;+ let ids: Vec<_> = flags+ .iter()+ .map(|flag| flag["id"].as_i64().unwrap())+ .collect();+ let dependencies: serde_json::Map<_, _> =+ ids.iter().map(|id| (id.to_string(), json!([]))).collect();+ // Value-based cache helpers would round the discriminator under test.+ let mut encoded = json!({"flags": flags, "evaluation_metadata": {+ "dependency_stages": [ids], "flags_with_missing_deps": [], "transitive_deps": dependencies+ }}).to_string();+ for (_, placeholder, number) in RAW_NUMBERS {+ encoded = encoded.replace(&format!("\"{placeholder}\""), number);+ }+ write_flags_wire_json_to_redis(redis.clone(), team.id, encoded).await?;} else {+ let mut connection = db.non_persons_writer.get_connection().await?;+ for &(key, placeholder, number) in RAW_NUMBERS {+ let raw = docs+ .iter()+ .find(|(name, ..)| name == key)+ .unwrap()+ .1+ .to_string()+ .replace(&format!("\"{placeholder}\""), number);+ sqlx::query("UPDATE posthog_featureflag SET filters = $1::jsonb WHERE team_id = $2 AND key = $3")+ .bind(raw).bind(team.id).bind(key).execute(&mut *connection).await?;+ }+ drop(connection);assert!(build_flags_cache(db.non_persons_reader.clone(), team.id).await.is_err());}+ let stored = if cached {+ let reader = HyperCacheReader::new_with_s3_client(+ redis.clone(),+ Arc::new(MockS3Client::new()),+ HyperCacheConfig::new(+ "feature_flags".to_owned(),+ "flags.json".to_owned(),+ "us-east-1".to_owned(),+ "test-bucket".to_owned(),+ ),+ );+ reader+ .get_typed_from_redis::<HypercacheFlagsWrapper>(&KeyType::Int(team.id))+ .await?+ .expect("written flags must be present in Redis")+ .flags+ } else {+ FeatureFlagList::from_pg(db.non_persons_reader.clone(), team.id).await?+ };+ for (key, valid) in [+ ("rejected-valid-v2", true),+ ("rejected-rounded-v2", true),+ ("rejected-overprecise-v2", false),+ ] {+ let flag = stored.iter().find(|flag| flag.key == key).unwrap();+ assert_eq!(+ flag.filters+ .non_v1+ .as_ref()+ .unwrap()+ .parsed_v2+ .as_ref()+ .unwrap()+ .is_ok(),+ valid+ );+ }let server = common::ServerHandle::for_config(DEFAULT_TEST_CONFIG.clone()).await;let client = reqwest::Client::new();let payload = json!({"token": team.api_token, "distinct_id": "example-person"});@@ -173,7 +295,7 @@ async fn config_dispatch_preserves_siblings_and_wire_errors(#[case] cached: bool}match shape {Shape::Detailed => {- for key in ["absent", "one", "one-float"] {+ for key in ["absent", "one", "one-float", "one-rounded"] {assert_eq!(body["flags"][key]["enabled"], true, "{body}");assert_eq!(body["flags"][key]["metadata"]["version"], 2, "{body}");}@@ -199,13 +321,19 @@ async fn config_dispatch_preserves_siblings_and_wire_errors(#[case] cached: boolkeys.sort_by(|a, b| a.as_str().cmp(&b.as_str()));assert_eq!(keys,- vec![json!("absent"), json!("one"), json!("one-float")]+ vec![+ json!("absent"),+ json!("one"),+ json!("one-float"),+ json!("one-rounded")+ ]);}Shape::Map {keeps_rejected_as_false,} => {- let mut expected = json!({"absent": true, "one": true, "one-float": true});+ let mut expected =+ json!({"absent": true, "one": true, "one-float": true, "one-rounded": true});if keeps_rejected_as_false {for (key, _, _, _) in &docs {if key.starts_with("rejected-") {diff --git a/rust/feature-flags/tests/test_config_v2.rs b/rust/feature-flags/tests/test_config_v2.rsnew file mode 100644index 000000000000..c2093ede83dc--- /dev/null+++ b/rust/feature-flags/tests/test_config_v2.rs@@ -0,0 +1,646 @@+use std::sync::Arc;++use feature_flags::flags::config_v2::{Config, Outcome, ParseError, RolloutMiss, MAX_CONFIG_BYTES};+use feature_flags::flags::feature_flag_list::PreparedFlags;+use feature_flags::flags::flag_models::{+ EvaluationMetadata, FeatureFlag, FeatureFlagRow, HypercacheFlagsWrapper,+ PreparedFlagDefinitions,+};+use feature_flags::properties::property_models::OperatorType;+use serde_json::{json, Value};++#[path = "test_config_v2/fixtures.rs"]+mod fixtures;++fn config() -> Value {+ json!({+ "version": 2, "return_type": "boolean", "default_value": false,+ "rules": [{+ "id": "11111111-1111-4111-8111-111111111111", "rule_type": "percentage_rollout",+ "targeting": {"properties": []}, "value": true, "rollout_percentage": 33.33,+ "on_rollout_miss": "continue", "assignment_algorithm": "sha1_60_v1", "seed": "example-seed"+ }]+ })+}++fn read(filters: Value) -> FeatureFlag {+ serde_json::from_value(json!({+ "id": 1, "team_id": 1, "key": "example", "active": true, "version": 42, "filters": filters+ }))+ .unwrap()+}++fn read_raw(document: &str) -> FeatureFlag {+ serde_json::from_str(&format!(+ r#"{{"id":1,"team_id":1,"key":"example","active":true,"filters":{document}}}"#+ ))+ .unwrap()+}++fn result(flag: &FeatureFlag) -> &Result<Config, ParseError> {+ flag.filters+ .non_v1+ .as_deref()+ .and_then(|config| config.parsed_v2.as_ref())+ .expect("recognized v2 must retain its parse result")+}++#[test]+fn original_numeric_tokens_control_precision_and_survive_cache_round_trips() {+ for hundredths in 0..=10_000 {+ for number in [+ format!("{}.{:02}", hundredths / 100, hundredths % 100),+ format!("{hundredths}e-2"),+ if hundredths == 0 {+ "0e-27".to_owned()+ } else {+ format!("{hundredths}0000000000000000000000000e-27")+ },+ ] {+ let document = config().to_string().replace("33.33", &number);+ let flag = read_raw(&document);+ let parsed = result(&flag)+ .as_ref()+ .unwrap_or_else(|error| panic!("{number}: {error:?}"));+ match parsed.rules[0].outcome {+ Outcome::PercentageRollout {+ rollout_percentage, ..+ } => assert_eq!(+ rollout_percentage,+ number.parse::<f64>().unwrap(),+ "{number}"+ ),+ _ => unreachable!(),+ }+ }+ }+ for (number, accepted) in [+ ("33.33", true),+ ("3333e-2", true),+ ("0.0001e2", true),+ ("33.330000000000000000000000000000000000000", true),+ ("33.330000000000000001", false),+ ("100.000000000000000001", false),+ ("1e-400", false),+ ("1e400", false),+ ] {+ let document = config().to_string().replace("33.33", number);+ let flag = read_raw(&document);+ assert_eq!(result(&flag).is_ok(), accepted, "{number}");+ let round_trip = serde_json::to_string(&flag).unwrap();+ assert!(round_trip.contains(number), "{number}");+ let decoded: FeatureFlag = serde_json::from_str(&round_trip).unwrap();+ assert_eq!(result(&decoded).is_ok(), accepted, "{number}");+ }+}++#[test]+fn version_discriminator_rounds_to_binary64() {+ for digits in 15..=80 {+ for number in [+ format!("0.{}", "9".repeat(digits)),+ format!("1.{}1", "0".repeat(digits)),+ format!("1.{}", "9".repeat(digits)),+ format!("2.{}1", "0".repeat(digits)),+ ] {+ let document = config()+ .to_string()+ .replace("\"version\":2", &format!("\"version\":{number}"));+ let flag = read_raw(&document);+ let expected = number.parse::<f64>().unwrap();+ assert_eq!(flag.filters.non_v1.is_none(), expected == 1.0, "{number}");+ if let Some(non_v1) = &flag.filters.non_v1 {+ assert_eq!(non_v1.parsed_v2.is_some(), expected == 2.0, "{number}");+ }+ }+ }+ for (number, recognized_v2) in [+ ("2.0", true),+ ("20e-1", true),+ ("2.0000000000000001", true),+ ("1.0000000000000001", false),+ ] {+ let document = config()+ .to_string()+ .replace("\"version\":2", &format!("\"version\":{number}"));+ let flag = read_raw(&document);+ assert_eq!(flag.filters.non_v1.is_some(), recognized_v2, "{number}");+ if recognized_v2 {+ assert!(result(&flag).is_ok());+ assert!(serde_json::to_string(&flag).unwrap().contains(number));+ }+ }+}++#[test]+fn raw_v2_constraints_reject_duplicates_and_underflow_only_in_the_affected_flag() {+ for (raw, field) in [+ (r#"{"version":2,"version":2,"return_type":"boolean","default_value":null,"rules":[]}"#.to_owned(), "json_keys_unique"),+ (config().to_string().replace("\"value\":true", "\"value\":false,\"value\":true"), "json_keys_unique"),+ (config().to_string().replace("\"properties\":[]", r#""properties":[{"key":"example","key":"other","type":"person"}]"#), "json_keys_unique"),+ (config().to_string().replace("\"properties\":[]", r#""properties":[{"key":"example","type":"person","value":{"items":[{"x":1,"\u0078":2}]}}]"#), "json_keys_unique"),+ (config().to_string().replace("\"seed\":", r#""metadata":{"nested":{"x":1,"x":2}},"seed":"#), "json_keys_unique"),+ ] {+ let flag = read_raw(&raw);+ assert_eq!(result(&flag).as_ref().unwrap_err(), &ParseError::Malformed(field), "{raw}");+ let encoded = serde_json::to_string(&flag).unwrap();+ assert!(encoded.contains(&raw));+ let wrapper = format!(r#"{{"flags":[{encoded},{{"id":2,"team_id":1,"key":"healthy","filters":{{"groups":[{{"rollout_percentage":100}}]}}}}],"evaluation_metadata":{{"dependency_stages":[[1,2]],"flags_with_missing_deps":[],"transitive_deps":{{}}}}}}"#);+ let wrapper: HypercacheFlagsWrapper = serde_json::from_str(&wrapper).unwrap();+ assert!(result(&wrapper.flags[0]).is_err());+ assert_eq!(wrapper.flags[1].filters.groups.len(), 1);+ }+ for (number, valid) in [+ ("1e-400", false),+ ("-1e-400", false),+ ("1e400", false),+ ("-1e400", false),+ ("5e-324", true),+ ("-5e-324", true),+ ("0e-400", true),+ ("-0.0", true),+ ] {+ for property in [+ format!(r#"{{"key":"example","type":"person","operator":"gt","value":{number}}}"#),+ format!(r#"{{"key":"example","type":"person","value":{{"nested":[{number}]}}}}"#),+ ] {+ let raw = config()+ .to_string()+ .replace("\"properties\":[]", &format!("\"properties\":[{property}]"));+ let flag = read_raw(&raw);+ assert_eq!(result(&flag).is_ok(), valid, "{number}");+ if !valid {+ assert_eq!(+ result(&flag).as_ref().unwrap_err(),+ &ParseError::Malformed("number_is_binary64")+ );+ }+ }+ }+ let mut document = config();+ document["rules"][0]["metadata"] = json!({"rollout_percentage": 0.001, "text": "\"duplicate\":1,\"duplicate\":1e-400 \\ braces{}[]", "distinct": [{"same":1},{"same":2}]});+ assert!(result(&read(document)).is_ok());+ let legacy = read_raw(r#"{"groups":[],"extra":{"key":1,"key":2,"tiny":1e-400}}"#);+ assert!(legacy.filters.non_v1.is_none());+ assert_eq!(legacy.filters.extra["extra"]["key"], 2);+ assert_eq!(legacy.filters.extra["extra"]["tiny"].as_f64(), Some(0.0));+}++#[test]+fn supported_values_and_order_survive_the_reader() {+ for default in [json!(true), json!(false), Value::Null] {+ for percentage in [0.0, 0.01, 1.01, 33.33, 99.99, 100.0] {+ for policy in ["continue", "return_default"] {+ let mut document = config();+ document["default_value"] = default.clone();+ document["rules"][0]["rollout_percentage"] = json!(percentage);+ document["rules"][0]["on_rollout_miss"] = json!(policy);+ document["rules"].as_array_mut().unwrap().push(json!({+ "id": "22222222-2222-4222-8222-222222222222", "rule_type": "targeted_release",+ "targeting": {"properties": []}, "value": false,+ "description": "Example display text", "metadata": {"opaque": [null, {"anything": true}]}+ }));+ let flag = read(document.clone());+ let parsed = result(&flag).as_ref().unwrap();+ assert_eq!(parsed.default_value, default.as_bool());+ assert_eq!(parsed.rules.len(), 2);+ assert_eq!(parsed.rules[0].id.to_string(), document["rules"][0]["id"]);+ match &parsed.rules[0].outcome {+ Outcome::PercentageRollout {+ value,+ rollout_percentage,+ on_rollout_miss,+ seed,+ } => {+ assert!(*value);+ assert_eq!(*rollout_percentage, percentage);+ assert_eq!(+ *on_rollout_miss,+ if policy == "continue" {+ RolloutMiss::Continue+ } else {+ RolloutMiss::ReturnDefault+ }+ );+ assert_eq!(seed, "example-seed");+ }+ other => panic!("unexpected outcome {other:?}"),+ }+ assert!(matches!(+ parsed.rules[1].outcome,+ Outcome::TargetedRelease { value: false }+ ));+ assert_eq!(serde_json::to_value(&flag).unwrap()["filters"], document);+ }+ }+ let flag = read(+ json!({"version": 2.0, "return_type": "boolean", "default_value": default, "rules": []}),+ );+ assert!(result(&flag).as_ref().unwrap().rules.is_empty());+ assert_eq!(flag.version, Some(42));+ }+}++#[test]+fn required_and_closed_fields_fail_without_losing_the_original_document() {+ for pointer in [+ "/return_type",+ "/default_value",+ "/rules",+ "/rules/0/id",+ "/rules/0/rule_type",+ "/rules/0/targeting",+ "/rules/0/targeting/properties",+ "/rules/0/value",+ "/rules/0/rollout_percentage",+ "/rules/0/on_rollout_miss",+ "/rules/0/assignment_algorithm",+ "/rules/0/seed",+ ] {+ let mut document = config();+ let (parent, key) = pointer.rsplit_once('/').unwrap();+ document+ .pointer_mut(parent)+ .unwrap()+ .as_object_mut()+ .unwrap()+ .remove(key);+ let flag = read(document.clone());+ assert!(+ matches!(result(&flag), Err(ParseError::Malformed(_))),+ "{pointer}"+ );+ assert!(serde_json::to_string(&flag)+ .unwrap()+ .contains(&format!("\"filters\":{document}")));+ }+ for (pointer, value) in [+ ("/groups", json!(false)),+ ("/multivariate", json!("bad-v1")),+ ("/unknown", json!(true)),+ ("/rules/0/unknown", json!(true)),+ ("/rules/0/targeting/unknown", json!(true)),+ ("/default_value", json!(0)),+ ("/default_value", json!("false")),+ ("/rules", Value::Null),+ ("/rules", json!({})),+ ("/rules/0", Value::Null),+ ("/rules/0/targeting", json!([])),+ ("/rules/0/targeting/properties", Value::Null),+ ("/rules/0/value", Value::Null),+ ("/rules/0/value", json!(1)),+ ("/rules/0/id", json!("11111111111141118111111111111111")),+ (+ "/rules/0/id",+ json!("urn:uuid:11111111-1111-4111-8111-111111111111"),+ ),+ ("/rules/0/id", json!("zzzzzzzz-1111-4111-8111-111111111111")),+ ("/rules/0/seed", json!("")),+ ("/rules/0/seed", json!("é".repeat(401))),+ ("/rules/0/seed", Value::Null),+ ("/rules/0/description", Value::Null),+ ("/rules/0/metadata", json!([])),+ ("/rules/0/assign_by", json!("device_id")),+ ("/rules/0/assign_by", Value::Null),+ ("/rules/0/assignment_algorithm", json!("future")),+ ("/rules/0/on_rollout_miss", json!("ignore")),+ ("/rules/0/on_rollout_miss", Value::Null),+ ("/rules/0/rule_type", json!("variant_rollout")),+ ("/aggregation_group_type_index", Value::Null),+ ("/rules/0/rollout_percentage", json!(-0.01)),+ ("/rules/0/rollout_percentage", json!(100.01)),+ ("/rules/0/rollout_percentage", json!(33.333)),+ ("/rules/0/rollout_percentage", json!(33.33000000000001)),+ ("/rules/0/rollout_percentage", json!(1e-30)),+ ("/rules/0/rollout_percentage", json!(true)),+ ("/rules/0/rollout_percentage", json!("33.33")),+ ] {+ let mut document = config();+ let (parent, key) = pointer.rsplit_once('/').unwrap();+ if let Some(map) = document.pointer_mut(parent).unwrap().as_object_mut() {+ map.insert(key.to_owned(), value);+ } else {+ *document.pointer_mut(pointer).unwrap() = value;+ }+ let flag = read(document.clone());+ assert!(+ matches!(result(&flag), Err(ParseError::Malformed(_))),+ "{pointer}"+ );+ assert!(serde_json::to_string(&flag)+ .unwrap()+ .contains(&format!("\"filters\":{document}")));+ }+}++#[test]+fn semantic_limits_and_duplicate_ids_are_enforced() {+ let mut document = config();+ document["rules"][0]["seed"] = json!("é".repeat(400));+ assert!(result(&read(document.clone())).is_ok());+ let repeated = document["rules"][0].clone();+ document["rules"].as_array_mut().unwrap().push(repeated);+ assert_eq!(+ result(&read(document.clone())).as_ref().unwrap_err(),+ &ParseError::Malformed("rule.id")+ );+ let mut document = config();+ document["rules"] = Value::Array(+ (0..100)+ .map(|n| {+ let mut rule = config()["rules"][0].clone();+ rule["id"] = json!(format!("{n:08x}-1111-4111-8111-111111111111"));+ rule+ })+ .collect(),+ );+ assert!(result(&read(document.clone())).is_ok());+ let rule = document["rules"][0].clone();+ document["rules"].as_array_mut().unwrap().push(rule);+ assert_eq!(+ result(&read(document)).as_ref().unwrap_err(),+ &ParseError::LimitExceeded("rules")+ );+ let mut document = config();+ document["rules"][0]["targeting"]["properties"] = Value::Array(+ (0..100)+ .map(|n| json!({"key": format!("tier-{n}"), "type": "person"}))+ .collect(),+ );+ let flag = read(document.clone());+ let predicates = &result(&flag).as_ref().unwrap().rules[0].targeting;+ assert_eq!(predicates.len(), 100);+ for (n, predicate) in predicates.iter().enumerate() {+ assert_eq!(predicate.key, format!("tier-{n}"));+ }+ document["rules"][0]["targeting"]["properties"]+ .as_array_mut()+ .unwrap()+ .push(json!({"key": "tier", "type": "person"}));+ assert_eq!(+ result(&read(document)).as_ref().unwrap_err(),+ &ParseError::LimitExceeded("properties")+ );+ let mut document = config();+ document["rules"][0]["metadata"] = json!({"display": "x".repeat(*MAX_CONFIG_BYTES)});+ let flag = read(document.clone());+ assert_eq!(+ result(&flag).as_ref().unwrap_err(),+ &ParseError::LimitExceeded("filters")+ );+ assert_eq!(serde_json::to_value(flag).unwrap()["filters"], document);++ let mut document = config();+ document["rules"][0]["metadata"] = json!({"display": ""});+ let padding = *MAX_CONFIG_BYTES - document.to_string().len();+ document["rules"][0]["metadata"]["display"] = json!("x".repeat(padding));+ let raw = serde_json::to_string_pretty(&document).unwrap();+ let encoded = format!(r#"{{"id":1,"team_id":1,"key":"example","filters":{raw}}}"#);+ let flag: FeatureFlag = serde_json::from_str(&encoded).unwrap();+ assert!(result(&flag).is_ok());+ document["rules"][0]["metadata"]["display"] = json!("x".repeat(padding + 1));+ assert_eq!(+ result(&read(document)).as_ref().unwrap_err(),+ &ParseError::LimitExceeded("filters")+ );+}++fn person_property_cases() -> Vec<(&'static str, Value)> {+ vec![+ ("exact", json!(["preview"])),+ ("is_not", json!(false)),+ ("is_set", Value::Null),+ ("is_not_set", Value::Null),+ ("regex", json!("^preview$")),+ ("not_regex", json!("[")),+ ("icontains", json!("view")),+ ("not_icontains", json!("view")),+ ("starts_with", json!("pre")),+ ("not_starts_with", json!("pre")),+ ("ends_with", json!("view")),+ ("not_ends_with", json!("view")),+ ("icontains_multi", json!(["a", "b"])),+ ("not_icontains_multi", json!([])),+ ("gt", json!(2)),+ ("gte", json!("2")),+ ("lt", json!(3.5)),+ ("lte", json!("3.5")),+ ("is_date_exact", json!("2024-01-01")),+ ("is_date_after", json!("-7d")),+ ("is_date_before", json!("2024-01-01T00:00:00Z")),+ ("semver_gt", json!("1.2.3")),+ ("semver_eq", json!(" 1.2.3 ")),+ ("semver_gte", json!("1.2.3")),+ ("semver_lt", json!("1.2.3")),+ ("semver_lte", json!("1.2.3")),+ ("semver_eq", json!("1.2.3")),+ ("semver_neq", json!("1.2.3")),+ ("semver_tilde", json!("1.2")),+ ("semver_caret", json!("1.2.3")),+ ("semver_wildcard", json!("1.2.*")),+ ]+}++#[test]+fn person_properties_are_closed_before_reusing_operator_types() {+ for (operator, value) in person_property_cases() {+ let mut document = config();+ document["rules"][0]["targeting"]["properties"] = json!([{+ "key": "example", "type": "person", "operator": operator, "value": value,+ "negation": true, "group_type_index": null, "label": "Display", "cohort_name": null,+ "group_key_names": {"0": "Display only"}+ }]);+ let flag = read(document);+ let parsed = result(&flag)+ .as_ref()+ .unwrap_or_else(|error| panic!("{operator}: {error:?}"));+ let property = &parsed.rules[0].targeting[0];+ assert_eq!(property.key, "example");+ assert_eq!(serde_json::to_value(property.operator).unwrap(), operator);+ assert!(property.negation);+ assert_eq!(+ property.value,+ if value.is_null() { None } else { Some(value) }+ );+ }+ for property in [+ json!({"key": "tier", "type": "person"}),+ json!({"key": "tier", "type": "person", "operator": null, "value": null, "negation": null}),+ ] {+ let mut document = config();+ document["rules"][0]["targeting"]["properties"] = json!([property]);+ let flag = read(document);+ let predicate = &result(&flag).as_ref().unwrap().rules[0].targeting[0];+ assert_eq!(predicate.operator, OperatorType::Exact);+ assert!(!predicate.negation);+ }+ for (field, value) in [+ ("key", json!(42)),+ ("key", json!("")),+ ("type", json!("person_metadata")),+ ("operator", json!("min")),+ ("operator", json!("max")),+ ("operator", json!("between")),+ ("operator", json!("in")),+ ("operator", json!("not_in")),+ ("operator", json!("flag_evaluates_to")),+ ("operator", json!("unknown")),+ ("operator", json!(true)),+ ("negation", json!("false")),+ ("group_type_index", json!(0)),+ ("label", json!(false)),+ ("cohort_name", json!([])),+ ("group_key_names", json!({"0": false})),+ ("extra", json!(true)),+ ] {+ let mut document = config();+ let mut property = json!({"key": "tier", "type": "person", "value": "preview"});+ property[field] = value;+ document["rules"][0]["targeting"]["properties"] = json!([property]);+ assert!(+ matches!(result(&read(document)), Err(ParseError::Malformed(_))),+ "{field}"+ );+ }+ for (operator, value) in [+ ("regex", json!(1)),+ ("icontains_multi", json!("x")),+ ("gt", json!(false)),+ ("is_date_exact", json!("not-a-date")),+ ("is_date_exact", json!("-10000d")),+ ("semver_gt", json!("not-a-version")),+ ("semver_gt", json!(123)),+ ("semver_eq", json!("1.2.3+meta")),+ ("semver_eq", json!("v1.2.3")),+ ("semver_eq", json!("+1.2.3")),+ ("semver_eq", json!("1. 2.3")),+ ("semver_eq", json!("1.+2.3")),+ ] {+ let mut document = config();+ document["rules"][0]["targeting"]["properties"] =+ json!([{"key": "example", "type": "person", "operator": operator, "value": value}]);+ assert_eq!(+ result(&read(document)).as_ref().unwrap_err(),+ &ParseError::Malformed("property.value")+ );+ }+}++#[test]+fn unsupported_members_reject_the_whole_flag_and_debug_redacts_config() {+ for property_type in ["cohort", "group", "flag"] {+ let mut document = config();+ document["rules"][0]["targeting"]["properties"] = json!([+ {"key": "tier", "type": "person", "value": "preview"},+ {"key": "id", "type": property_type, "value": "private-property-value"}+ ]);+ assert_eq!(+ result(&read(document)).as_ref().unwrap_err(),+ &ParseError::Unsupported("property.type")+ );+ }+ for (field, value) in [+ ("return_type", json!("string")),+ ("return_type", json!("number")),+ ("return_type", json!("object")),+ ("aggregation_group_type_index", json!(0)),+ ] {+ let mut document = config();+ document[field] = value;+ assert!(matches!(+ result(&read(document)),+ Err(ParseError::Unsupported(_))+ ));+ }+ let mut document = config();+ document["rules"]+ .as_array_mut()+ .unwrap()+ .push(json!({"rule_type": "experiment", "holdout": {"seed": "private-holdout"}}));+ assert_eq!(+ result(&read(document)).as_ref().unwrap_err(),+ &ParseError::Unsupported("rule_type")+ );+ for version in [json!(2), json!(3), json!("private-version")] {+ let mut document = config();+ document["version"] = version;+ document["rules"][0]["seed"] = json!("private-seed");+ document["rules"][0]["metadata"] = json!({"private-metadata": "private-metadata-value"});+ document["rules"][0]["targeting"]["properties"] =+ json!([{"key": "private-key", "type": "person", "value": "private-property-value"}]);+ let row = FeatureFlagRow {+ id: 1,+ team_id: 2,+ key: "example".to_owned(),+ active: true,+ version: Some(42),+ filters: document.clone(),+ ..Default::default()+ };+ let debug = format!("{row:?}");+ assert!(debug.contains("key: \"example\""));+ assert!(debug.contains("active: true"));+ assert!(debug.contains("version: Some(42)"));+ assert!(!debug.contains("private-"), "{debug}");+ let flag = read(document);+ let debug = format!("{flag:?}");+ assert!(!debug.contains("private-"), "{debug}");+ if let Some(Ok(parsed)) = flag+ .filters+ .non_v1+ .as_deref()+ .and_then(|config| config.parsed_v2.as_ref())+ {+ assert!(!format!("{:?}", parsed.rules).contains("private-"));+ assert!(!format!("{:?}", parsed.rules[0].targeting).contains("private-"));+ }+ }+}++#[test]+fn preparation_reuses_parsing_and_accounts_for_raw_and_typed_data() {+ let mut document = config();+ document["rules"][0]["metadata"] = json!({"display": "x".repeat(8192)});+ document["rules"][0]["targeting"]["properties"] =+ json!([{"key": "tier", "type": "person", "value": "preview"}]);+ let flag = read(document.clone());+ let parsed = Arc::clone(flag.filters.non_v1.as_ref().unwrap());+ let mut raw_only = flag.clone();+ Arc::make_mut(raw_only.filters.non_v1.as_mut().unwrap()).parsed_v2 = None;+ let prepared = |flag| PreparedFlagDefinitions {+ flags: PreparedFlags::seal(vec![flag]),+ evaluation_metadata: Arc::new(EvaluationMetadata::default()),+ cohorts: None,+ };+ let parsed_flags = prepared(flag);+ let raw_flags = prepared(raw_only);+ assert!(parsed_flags.estimated_size_bytes() > raw_flags.estimated_size_bytes());+ assert!(raw_flags.estimated_size_bytes() > 8192);+ assert!(Arc::ptr_eq(+ &parsed,+ parsed_flags.flags[0].filters.non_v1.as_ref().unwrap()+ ));+ assert!(parsed_flags.flags[0].filters.groups.is_empty());+ assert_eq!(+ serde_json::to_value(&parsed_flags.flags[0]).unwrap()["filters"],+ document+ );+ let wrapper: HypercacheFlagsWrapper = serde_json::from_value(json!({+ "flags": [serde_json::to_value(&parsed_flags.flags[0]).unwrap(), {+ "id": 2, "team_id": 1, "key": "healthy", "active": true,+ "filters": {"groups": [{"rollout_percentage": 100}]}+ }], "evaluation_metadata": {"dependency_stages": [[1, 2]], "flags_with_missing_deps": [], "transitive_deps": {"1": [], "2": []}}+ })).unwrap();+ assert!(result(&wrapper.flags[0]).is_ok());+ assert!(wrapper.flags[1].filters.non_v1.is_none());+ assert_eq!(wrapper.flags[1].filters.groups.len(), 1);++ let values = vec![json!({"items": vec![Value::Null; 1000]}); 50];+ let mut document = config();+ document["rules"][0]["targeting"]["properties"] =+ json!([{"key": "example", "type": "person", "value": values}]);+ let flag = read(document.clone());+ assert!(result(&flag).is_ok());+ let weighted = prepared(flag).estimated_size_bytes();+ assert!(weighted > document.to_string().len() + 50_000 * std::mem::size_of::<Value>());+}diff --git a/rust/feature-flags/tests/test_config_v2/fixtures.rs b/rust/feature-flags/tests/test_config_v2/fixtures.rsnew file mode 100644index 000000000000..d47065385395--- /dev/null+++ b/rust/feature-flags/tests/test_config_v2/fixtures.rs@@ -0,0 +1,489 @@+use std::collections::{BTreeMap, BTreeSet};+use std::path::PathBuf;++use serde_json::{json, Value};+use sha2::{Digest, Sha256};++use super::{config, person_property_cases, read, result};+use feature_flags::flags::config_v2::{+ ParseError, CONFIG_FIELDS, MAX_PREDICATES, MAX_RULES, MAX_SEED_LENGTH,+ PERCENTAGE_ROLLOUT_FIELDS, PROPERTY_FIELDS, TARGETED_RELEASE_FIELDS, TARGETING_FIELDS,+};+use feature_flags::flags::flag_models::FeatureFlag;++fn root() -> PathBuf {+ PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("tests/fixtures/rules_v2_parser/2.1.0")+}++fn load(path: &str) -> Value {+ serde_json::from_slice(&std::fs::read(root().join(path)).unwrap()).unwrap()+}++#[test]+fn released_parser_artifacts_are_intact() {+ let source = load("SOURCE.json");+ assert_eq!(+ source["source_revision"],+ "c32f4959240967f1ee89e58490fc9d3beaa1401f"+ );+ let index = std::fs::read(root().join("SHA256SUMS")).unwrap();+ assert_eq!(+ hex::encode(Sha256::digest(&index)),+ source["source_sha256sums_digest"]+ );+ let text = std::str::from_utf8(&index).unwrap();+ let digests: BTreeMap<_, _> = text+ .lines()+ .map(|line| {+ let (digest, path) = line.split_once(" ").unwrap();+ (path, digest)+ })+ .collect();+ let files: BTreeSet<_> = source["files"]+ .as_array()+ .unwrap()+ .iter()+ .map(|p| p.as_str().unwrap())+ .collect();+ assert_eq!(files.len(), source["files"].as_array().unwrap().len());+ for path in files {+ let bytes = std::fs::read(root().join(path)).unwrap();+ assert_eq!(hex::encode(Sha256::digest(bytes)), digests[path], "{path}");+ }+ let manifest = load("manifest.json");+ assert_eq!(manifest["contract"]["version"], source["contract_version"]);+ assert_eq!(manifest["corpus"]["version"], "1.1.0");+}++#[test]+fn released_config_cases_distinguish_schema_expectations_from_supported_families() {+ let manifest = load("manifest.json");+ #[derive(Default, Debug, PartialEq)]+ struct Totals {+ supported: usize,+ valid_but_unsupported: usize,+ malformed: usize,+ unsupported: usize,+ rejected_before_parsing: usize,+ }+ let mut totals = Totals::default();+ for fixture in manifest["artifacts"].as_array().unwrap() {+ let path = fixture["path"].as_str().unwrap();+ if !path.starts_with("fixtures/config/") {+ continue;+ }+ let document = load(path);+ let flag = read(document.clone());+ let parsed = flag.filters.non_v1.as_ref().unwrap().parsed_v2.as_ref();+ if fixture["expected"] == "valid" {+ if path.ends_with("version_float_literal.json")+ || path.ends_with("boolean_targeted_and_percentage_rollout.json")+ {+ assert!(parsed.unwrap().is_ok(), "{path}: {parsed:?}");+ totals.supported += 1;+ } else {+ assert!(+ matches!(parsed, Some(Err(ParseError::Unsupported(_)))),+ "{path}: {parsed:?}"+ );+ totals.valid_but_unsupported += 1;+ }+ } else {+ let name = PathBuf::from(path)+ .file_stem()+ .unwrap()+ .to_str()+ .unwrap()+ .to_owned();+ let expected = invalid_fixture_error(&name);+ assert_eq!(+ parsed.map(|result| *result.as_ref().unwrap_err()),+ expected,+ "{path}"+ );+ match expected {+ Some(ParseError::Malformed(_)) => {+ totals.malformed += 1;+ let repaired = repair_supported_fixture(&name, document.clone());+ assert!(+ result(&read(repaired)).is_ok(),+ "repair must make {path} supported"+ );+ }+ Some(ParseError::Unsupported(_)) => totals.unsupported += 1,+ None => totals.rejected_before_parsing += 1,+ other => panic!("unexpected fixture classification: {other:?}"),+ }+ }+ assert_eq!(+ serde_json::to_value(flag).unwrap()["filters"],+ document,+ "{path}"+ );+ }+ assert_eq!(+ totals,+ Totals {+ supported: 2,+ valid_but_unsupported: 6,+ malformed: 18,+ unsupported: 11,+ rejected_before_parsing: 3,+ }+ );+}++fn invalid_fixture_error(name: &str) -> Option<ParseError> {+ use ParseError::{Malformed, Unsupported};+ Some(match name {+ "assign_by_not_person" => Malformed("assign_by"),+ "default_value_type_mismatch" => Malformed("default_value"),+ "empty_seed" | "missing_rollout_seed" => Malformed("seed"),+ "missing_on_rollout_miss" => Malformed("on_rollout_miss"),+ "non_uuid_rule_id" => Malformed("rule.id"),+ "null_rule_value" | "return_value_type_mismatch" => Malformed("value"),+ "rollout_percentage_above_maximum" | "rollout_percentage_below_minimum" => {+ Malformed("rollout_percentage")+ }+ "targeted_release_with_rollout_fields" | "unknown_rule_field" => Malformed("rule"),+ "unknown_assignment_algorithm" => Malformed("assignment_algorithm"),+ "unknown_config_field" => Malformed("filters"),+ "unknown_property_field" => Malformed("property"),+ "unknown_property_operator" => Malformed("property.operator"),+ "unknown_property_type" => Malformed("property.type"),+ "unknown_rollout_miss_policy" => Malformed("on_rollout_miss"),+ "empty_string_value" | "object_value_too_deep" => Unsupported("return_type"),+ "group_experiment_with_assign_by" | "group_percentage_rollout_with_assign_by" => {+ Unsupported("aggregation_group_type_index")+ }+ "missing_experiment_paused"+ | "null_experiment_id"+ | "seed_too_long"+ | "too_few_variants"+ | "too_many_variants"+ | "variant_key_invalid_characters"+ | "variant_value_type_mismatch" => Unsupported("rule_type"),+ "unknown_config_version" | "version_boolean" | "version_string" => return None,+ _ => panic!("unclassified released fixture: {name}"),+ })+}++fn repair_supported_fixture(name: &str, mut document: Value) -> Value {+ match name {+ "assign_by_not_person" => document["rules"][0]["assign_by"] = json!("person"),+ "default_value_type_mismatch" => document["default_value"] = json!(false),+ "empty_seed" | "missing_rollout_seed" => {+ document["rules"][0]["seed"] = json!("example-seed")+ }+ "missing_on_rollout_miss" | "unknown_rollout_miss_policy" => {+ document["rules"][0]["on_rollout_miss"] = json!("continue")+ }+ "non_uuid_rule_id" => {+ document["rules"][0]["id"] = json!("11111111-1111-4111-8111-111111111111")+ }+ "null_rule_value" | "return_value_type_mismatch" => {+ document["rules"][0]["value"] = json!(false)+ }+ "rollout_percentage_above_maximum" | "rollout_percentage_below_minimum" => {+ document["rules"][0]["rollout_percentage"] = json!(33.33)+ }+ "targeted_release_with_rollout_fields" => {+ for field in [+ "assign_by",+ "assignment_algorithm",+ "on_rollout_miss",+ "rollout_percentage",+ "seed",+ ] {+ document["rules"][0].as_object_mut().unwrap().remove(field);+ }+ }+ "unknown_rule_field" => {+ document["rules"][0]+ .as_object_mut()+ .unwrap()+ .remove("implicit_default");+ }+ "unknown_assignment_algorithm" => {+ document["rules"][0]["assignment_algorithm"] = json!("sha1_60_v1")+ }+ "unknown_config_field" => {+ document.as_object_mut().unwrap().remove("groups");+ }+ "unknown_property_field" => document["rules"][0]["targeting"]["properties"][0]+ .as_object_mut()+ .unwrap()+ .retain(|key, _| ["key", "type", "operator", "value"].contains(&key.as_str())),+ "unknown_property_operator" => {+ document["rules"][0]["targeting"]["properties"][0]["operator"] = json!("exact")+ }+ "unknown_property_type" => {+ document["rules"][0]["targeting"]["properties"][0]["type"] = json!("person")+ }+ _ => panic!("no focused repair for {name}"),+ }+ document+}++#[test]+fn definitions_filters_use_the_same_parser_without_replacing_the_service_envelope() {+ let fixtures = load("fixtures/wire/definitions.json");+ let mut exercised = BTreeSet::new();+ for case in fixtures["cases"].as_array().unwrap() {+ let mut entry = fixtures["templates"][case["template"].as_str().unwrap()].clone();+ for path in case["remove"].as_array().into_iter().flatten() {+ let (parent, key) = path.as_str().unwrap().rsplit_once('/').unwrap();+ entry+ .pointer_mut(parent)+ .unwrap()+ .as_object_mut()+ .unwrap()+ .remove(key);+ }+ for (path, value) in case["set"].as_object().into_iter().flatten() {+ let (parent, key) = path.rsplit_once('/').unwrap();+ entry+ .pointer_mut(parent)+ .unwrap()+ .as_object_mut()+ .unwrap()+ .insert(key.to_owned(), value.clone());+ }+ // The service reader gets its team identity from the service cache/PG row;+ // the canonical definitions entry can omit it. This is only a test adapter.+ entry["team_id"] = json!(1);+ let decoded = serde_json::from_value::<FeatureFlag>(entry.clone());+ if case["expected"] == "valid" {+ let flag = decoded.unwrap();+ if case["template"] == "v2" {+ assert!(matches!(+ result(&flag),+ Err(ParseError::Unsupported("rule_type"))+ ))+ } else {+ assert!(flag.filters.non_v1.is_none());+ }+ assert_eq!(+ flag.version,+ entry+ .get("version")+ .and_then(Value::as_i64)+ .map(|n| n as i32)+ );+ } else if case["expected_failure"]["instance_path"]+ .as_str()+ .unwrap()+ .starts_with("/filters")+ {+ let flag = decoded.unwrap();+ let expected = match case["id"].as_str().unwrap() {+ "definitions.unknown_semantic_field" => Some(ParseError::Malformed("filters")),+ "definitions.unknown_rule_field" => Some(ParseError::Malformed("rule")),+ "definitions.unsupported_rule_type" => Some(ParseError::Malformed("rule_type")),+ "definitions.missing_assignment_seed" => Some(ParseError::Malformed("seed")),+ "definitions.unsupported_version_future"+ | "definitions.unsupported_version_string"+ | "definitions.unsupported_version_boolean"+ | "definitions.unsupported_version_null" => None,+ other => panic!("unclassified definitions defect: {other}"),+ };+ let parsed = flag.filters.non_v1.as_deref().unwrap().parsed_v2.as_ref();+ assert_eq!(+ parsed.map(|r| *r.as_ref().unwrap_err()),+ expected,+ "{}",+ case["id"]+ );+ } else {+ match case["id"].as_str().unwrap() {+ // Service rows default active and allow additional row fields;+ // the canonical definitions schema is stricter at this boundary.+ "definitions.missing_active" => assert!(!decoded.unwrap().active),+ "definitions.unknown_field" => {+ decoded.unwrap();+ }+ "definitions.v1_wrong_type_version"+ | "definitions.v1_wrong_type_ensure_experience_continuity"+ | "definitions.missing_id"+ | "definitions.missing_key"+ | "definitions.missing_filters" => assert!(decoded.is_err(), "{}", case["id"]),+ other => panic!("unclassified definitions row defect: {other}"),+ }+ }+ assert!(exercised.insert(case["id"].as_str().unwrap()));+ }+ let manifest = load("manifest.json");+ let artifact = manifest["artifacts"]+ .as_array()+ .unwrap()+ .iter()+ .find(|artifact| artifact["path"] == "fixtures/wire/definitions.json")+ .unwrap();+ let expected: BTreeSet<_> = artifact["case_ids"]+ .as_array()+ .unwrap()+ .iter()+ .map(|id| id.as_str().unwrap())+ .collect();+ assert_eq!(exercised, expected);+ let mut entry = fixtures["templates"]["v2"].clone();+ entry["filters"] = load("fixtures/config/valid/boolean_targeted_and_percentage_rollout.json");+ entry["team_id"] = json!(1);+ let flag: FeatureFlag = serde_json::from_value(entry.clone()).unwrap();+ assert!(result(&flag).is_ok());+ assert_eq!(+ serde_json::to_value(flag).unwrap()["filters"],+ entry["filters"]+ );+}++#[test]+fn released_schema_and_registry_match_the_parser_contract() {+ let schema = load("schemas/config.schema.json");+ let registry = load("registries/literals.json");+ assert_eq!(+ registry["registry_version"],+ load("SOURCE.json")["registry_version"]+ );+ for (pointer, fields) in [+ ("/properties", CONFIG_FIELDS),+ (+ "/$defs/targetedReleaseRule/properties",+ TARGETED_RELEASE_FIELDS,+ ),+ (+ "/$defs/percentageRolloutRule/properties",+ PERCENTAGE_ROLLOUT_FIELDS,+ ),+ ("/$defs/targeting/properties", TARGETING_FIELDS),+ ("/$defs/propertyFilter/properties", PROPERTY_FIELDS),+ ] {+ let expected: BTreeSet<_> = schema+ .pointer(pointer)+ .unwrap()+ .as_object()+ .unwrap()+ .keys()+ .map(String::as_str)+ .collect();+ assert_eq!(+ fields.iter().copied().collect::<BTreeSet<_>>(),+ expected,+ "{pointer}"+ );+ }+ assert_eq!(+ MAX_RULES,+ schema["properties"]["rules"]["maxItems"].as_u64().unwrap() as usize+ );+ assert_eq!(+ MAX_PREDICATES,+ schema["$defs"]["targeting"]["properties"]["properties"]["maxItems"]+ .as_u64()+ .unwrap() as usize+ );+ assert_eq!(+ MAX_SEED_LENGTH,+ schema["$defs"]["seed"]["maxLength"].as_u64().unwrap() as usize+ );++ let entries = load("schemas/definitions_entry.schema.json");+ assert_eq!(+ entries["properties"]["filters"]["oneOf"][0]["properties"]["version"]["const"],+ registry["config_versions"]["v1"]+ );+ assert_eq!(+ entries["properties"]["filters"]["oneOf"][1]["$ref"],+ schema["$id"]+ );+ for version in ["v1", "v2"] {+ let mut document = config();+ document["version"] = registry["config_versions"][version].clone();+ let flag = read(document);+ assert_eq!(flag.filters.non_v1.is_none(), version == "v1");+ if version == "v2" {+ assert!(result(&flag).is_ok());+ }+ }+ for entry in registry["return_types"].as_array().unwrap() {+ let mut document = config();+ document["return_type"] = entry["value"].clone();+ let flag = read(document);+ if entry["value"] == "boolean" {+ assert!(result(&flag).is_ok());+ } else {+ assert_eq!(+ result(&flag).as_ref().unwrap_err(),+ &ParseError::Unsupported("return_type")+ );+ }+ }+ for entry in registry["rule_types"].as_array().unwrap() {+ let mut document = config();+ document["rules"][0]["rule_type"] = entry["value"].clone();+ if entry["value"] == "targeted_release" {+ document["rules"][0]+ .as_object_mut()+ .unwrap()+ .retain(|key, _| TARGETED_RELEASE_FIELDS.contains(&key.as_str()));+ }+ let flag = read(document);+ match entry["value"].as_str().unwrap() {+ "targeted_release" | "percentage_rollout" => assert!(result(&flag).is_ok()),+ _ => assert_eq!(+ result(&flag).as_ref().unwrap_err(),+ &ParseError::Unsupported("rule_type")+ ),+ }+ }+ for (registry_field, rule_field) in [+ ("assignment_algorithms", "assignment_algorithm"),+ ("assignment_targets", "assign_by"),+ ("rollout_miss_policies", "on_rollout_miss"),+ ] {+ for literal in registry[registry_field].as_array().unwrap() {+ let mut document = config();+ document["rules"][0][rule_field] = literal.clone();+ assert!(+ result(&read(document)).is_ok(),+ "{registry_field}: {literal}"+ );+ }+ }+ for prop_type in registry["property_types"].as_array().unwrap() {+ let mut document = config();+ document["rules"][0]["targeting"]["properties"] =+ json!([{"key": "example", "type": prop_type}]);+ let flag = read(document);+ if prop_type == "person" {+ assert!(result(&flag).is_ok());+ } else {+ assert_eq!(+ result(&flag).as_ref().unwrap_err(),+ &ParseError::Unsupported("property.type")+ );+ }+ }+ let operators = person_property_cases();+ let tested: BTreeSet<_> = operators+ .iter()+ .map(|(operator, _)| *operator)+ .chain(["in", "not_in", "flag_evaluates_to"])+ .collect();+ let released: BTreeSet<_> = registry["property_operators"]+ .as_array()+ .unwrap()+ .iter()+ .map(|operator| operator.as_str().unwrap())+ .collect();+ assert_eq!(tested, released);+ for operator in ["in", "not_in", "flag_evaluates_to"] {+ let mut document = config();+ document["rules"][0]["targeting"]["properties"] =+ json!([{"key": "example", "type": "person", "operator": operator}]);+ assert_eq!(+ result(&read(document)).as_ref().unwrap_err(),+ &ParseError::Malformed("property.operator")+ );+ }+}