standard_flags 0.2.2 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +158 -0
  3. data/README.md +566 -35
  4. data/conformance/README.md +166 -0
  5. data/conformance/bucket_vectors.json +46 -0
  6. data/conformance/guards_and_errors.json +35 -0
  7. data/conformance/legacy_env.json +38 -0
  8. data/conformance/legacy_exact.json +90 -0
  9. data/conformance/operations/write_path.json +723 -0
  10. data/conformance/permanent_flags.json +38 -0
  11. data/conformance/resolution.json +68 -0
  12. data/conformance/runtime/client.json +1431 -0
  13. data/conformance/runtime/rules.json +1305 -0
  14. data/conformance/schema/fixture.schema.json +1340 -0
  15. data/conformance/versions/legacy_ranges.json +183 -0
  16. data/conformance/versions/version_ranges.json +503 -0
  17. data/conformance/wire/client_state.json +1905 -0
  18. data/conformance/wire/delivery.json +1541 -0
  19. data/lib/standard_flags/audience.rb +49 -0
  20. data/lib/standard_flags/client.rb +157 -0
  21. data/lib/standard_flags/config.rb +21 -0
  22. data/lib/standard_flags/context.rb +70 -17
  23. data/lib/standard_flags/controller.rb +92 -10
  24. data/lib/standard_flags/definition.rb +71 -8
  25. data/lib/standard_flags/delivery.rb +195 -0
  26. data/lib/standard_flags/errors.rb +33 -0
  27. data/lib/standard_flags/job.rb +12 -1
  28. data/lib/standard_flags/mcp/flags.rb +3 -3
  29. data/lib/standard_flags/mcp/gating.rb +151 -0
  30. data/lib/standard_flags/mcp.rb +64 -5
  31. data/lib/standard_flags/notifiers/logger.rb +4 -0
  32. data/lib/standard_flags/ofrep/controller.rb +211 -0
  33. data/lib/standard_flags/ofrep.rb +115 -0
  34. data/lib/standard_flags/open_feature/provider.rb +1 -1
  35. data/lib/standard_flags/operations/rules.rb +17 -4
  36. data/lib/standard_flags/operations/validation.rb +25 -4
  37. data/lib/standard_flags/operations.rb +0 -2
  38. data/lib/standard_flags/payload.rb +8 -3
  39. data/lib/standard_flags/registry.rb +157 -12
  40. data/lib/standard_flags/runtime/cache.rb +1 -0
  41. data/lib/standard_flags/runtime/resolver.rb +26 -17
  42. data/lib/standard_flags/runtime/values.rb +8 -1
  43. data/lib/standard_flags/runtime.rb +42 -1
  44. data/lib/standard_flags/semantic_version.rb +141 -0
  45. data/lib/standard_flags/subscribers.rb +3 -0
  46. data/lib/standard_flags/testing.rb +4 -2
  47. data/lib/standard_flags/tooling.rb +25 -3
  48. data/lib/standard_flags/version.rb +1 -1
  49. data/lib/standard_flags/version_range.rb +309 -0
  50. data/lib/standard_flags.rb +38 -4
  51. metadata +24 -1
@@ -0,0 +1,166 @@
1
+ # standard_flags conformance suite
2
+
3
+ These JSON files are the cross-language contract for standard_flags. The
4
+ Ruby gem runs every one of them. Client libraries (Kotlin, TypeScript) run
5
+ the `wire` ones. The suite ships inside the gem (`conformance/` in the
6
+ installed gem's directory). It is fixture format version 1.
7
+
8
+ Every file validates against [`schema/fixture.schema.json`](schema/fixture.schema.json)
9
+ (JSON Schema 2020-12). Each file has a `description`, a `suite`, which picks
10
+ the case shape, and a `scope`:
11
+
12
+ - `server`: ENV pins, legacy variables, runtime rules, the write path,
13
+ bucketing and RubyGems-syntax ranges. Only server evaluators run these. Clients never evaluate rules.
14
+ - `wire`: what crosses the network and what a client does with it. Client
15
+ libraries run these too.
16
+
17
+ A case may carry its own `scope`, which overrides its file's. In
18
+ `runtime/client.json`, cases marked `"scope": "server"` exercise compatibility
19
+ only the Ruby server keeps (RubyGems-syntax ranges stored by 0.2.x, client
20
+ versions passed outside SemVer).
21
+
22
+ | File | Suite | Scope | In → out |
23
+ |---|---|---|---|
24
+ | `resolution.json`, `guards_and_errors.json`, `legacy_env.json`, `legacy_exact.json`, `permanent_flags.json` | `evaluation` | server | registry, environment, env vars → value, variant, reason, error code, deciding variable |
25
+ | `runtime/*.json` | `runtime` | server | stored rule, cohorts, memberships, context → evaluation and `rule_id` |
26
+ | `operations/write_path.json` | `operations` | server | operations applied in order → evaluations |
27
+ | `bucket_vectors.json` | `bucket_vectors` | server | salt, unit key, decision → bucket |
28
+ | `versions/version_ranges.json` | `version_ranges` | wire | version or build, neutral range → matched |
29
+ | `versions/legacy_ranges.json` | `legacy_ranges` | server | RubyGems range stored by 0.2.x → neutral translation; version → matched (as Gem::Requirement) |
30
+ | `wire/delivery.json` | `delivery` | wire | registry, context, client → OFREP entries and ETag |
31
+ | `wire/client_state.json` | `client_state` | wire | OFREP payloads → what client code reads |
32
+
33
+ ## delivery.json: what the server sends
34
+
35
+ A server runs each case through its delivery builder (in the gem,
36
+ `StandardFlags::Delivery.build`) and compares the result with
37
+ `{ "flags": expected.flags, "metadata": { "version": expected.etag } }`. A
38
+ client library uses each expected body as a golden OFREP payload, for example
39
+ to check that its decoder accepts every one.
40
+
41
+ The rules:
42
+
43
+ - **Entries.** One entry per wire name of every flag exposed to the audience,
44
+ aliases included. Every alias carries the same evaluation. Entries are
45
+ ordered by `key`, which is the wire name, never the flag key.
46
+ - **Success entry.** `{ "key", "value", "reason", "variant" }`. `value` is a
47
+ boolean, or a string for modes and experiments. `reason` is one of STATIC,
48
+ DEFAULT, TARGETING_MATCH, SPLIT, DISABLED, ENV_PIN or KILL_SWITCH.
49
+ KILL_SWITCH is how a client tells "temporarily unavailable" from "not
50
+ available".
51
+ - **Failure entry.** A flag whose evaluation failed is OFREP's
52
+ evaluationFailure: `{ "key", "errorCode", "errorDetails" }`. `errorCode` is
53
+ PARSE_ERROR, TARGETING_KEY_MISSING, INVALID_CONTEXT or GENERAL. There is no
54
+ value, so the client uses its code default. One bad flag never breaks the
55
+ others.
56
+ - **`min_client`.** The flag is withheld from a client whose platform is
57
+ listed and whose version is below the minimum, or unknown (missing or
58
+ unparseable). It is also withheld from a client with no platform. A
59
+ platform the declaration doesn't list is unaffected. Version precedence is
60
+ SemVer's, so `0.4.0-rc.1` is below `0.4.0`.
61
+ - **Deprecated static wires.** A tombstone's `serve` wires are sent with
62
+ reason STATIC and variant `on`/`off` (booleans) or the string itself. They
63
+ are sent through the `until` date, compared with today's date in UTC, and
64
+ stop the day after. Every `serve` has an `until`. A client on a
65
+ platform `until_clients` lists stops receiving them at that version. A
66
+ client with an unknown version, or on a platform it doesn't list, keeps
67
+ receiving them until `until`.
68
+ - **What never leaves the server.** Flag keys, rule IDs, env var names, unit
69
+ keys and flags the audience isn't exposed to. No string in `never_on_wire`
70
+ may appear anywhere in a payload.
71
+ - **ETag.** The ETag is the SHA-256, in lowercase hex, of the RFC 8785 (JCS)
72
+ canonical JSON of `{"audience": <audience>, "flags": <entries>}`, encoded
73
+ as UTF-8: object keys sorted, no whitespace. Strings may be non-ASCII
74
+ (static values, mode values and variants are free text). They are written
75
+ raw, with only the escapes JCS requires: `"` and `\`, the short forms
76
+ `\b \f \n \r \t`, and other control characters as `\u00xx` in lowercase
77
+ hex. DEL, U+2028 and `/` are left as they are. No numbers occur. A
78
+ serialiser that escapes non-ASCII (Python's default `ensure_ascii`,
79
+ Jackson's `ESCAPE_NON_ASCII`) computes a different ETag. The ETag depends only on what
80
+ the client is told, never on a config revision. Two users who are told the
81
+ same thing share an ETag, and two users told different things never do.
82
+ `etag_same_as` and `etag_differs_from` name earlier cases.
83
+
84
+ ## client_state.json: what a client reads
85
+
86
+ Each case starts with a fresh client that declares the wire keys it reads,
87
+ from the case's `declared` or else the file's:
88
+
89
+ ```json
90
+ { "type": "boolean" | "string", "default": <code default>, "values": [...]?, "ceiling": true? }
91
+ ```
92
+
93
+ The case's `steps` then run in order. A step is one of:
94
+
95
+ - `payload`: an object, which the runner serialises however it likes.
96
+ Payload cases stay well under the limits.
97
+ - `raw`: exact UTF-8 bytes, measured against `limits.max_bytes`.
98
+ - `not_modified`: a 304.
99
+
100
+ After each step, compare `accepted`, `version` and every declared key's read
101
+ `{ "state", "value", "reason" }`.
102
+
103
+ **Rejecting a payload.** A client rejects the whole payload, and keeps its
104
+ last good one and that payload's version, when any of these hold:
105
+
106
+ - it is larger than `max_bytes` (a payload of exactly `max_bytes` is
107
+ accepted), or is not JSON (a byte-order mark or trailing bytes make it not
108
+ JSON);
109
+ - the top level is not an object;
110
+ - `flags` is not an array, or has more than `max_flags` entries;
111
+ - an entry is not an object, or has no non-empty string `key`;
112
+ - two entries share a key;
113
+ - `metadata` is present and not an object.
114
+
115
+ Before any payload is accepted, every key reads `not_loaded`. Servers never
116
+ send an object with a repeated member name, so how a client reads one is not
117
+ pinned.
118
+
119
+ **Accepting a payload.** The client remembers `metadata.version` when it is
120
+ a non-empty string, else null, and sends it as If-None-Match next time. A
121
+ 304 changes nothing, even before any payload. Keys the client doesn't
122
+ declare are ignored.
123
+
124
+ **Reading a key.** An entry's value is *usable* when all of these hold:
125
+
126
+ - the entry exists;
127
+ - it has no `errorCode`, or one that is null;
128
+ - it has a `value`;
129
+ - the value has the declared type;
130
+ - for a string with `values`, the value is one of them.
131
+
132
+ The read is then:
133
+
134
+ - **Not usable:** `{ "state": "not_loaded", "value": default, "reason": null }`.
135
+ A missing entry, an entry without a value (OFREP's code-default form), an
136
+ errored entry and a value of the wrong type all mean the code default.
137
+ - **Usable boolean:** `state` is `on` or `off` and `value` is the server's
138
+ value.
139
+ - **Usable string:** `state` is `loaded` and `value` is the server's value.
140
+ - **Ceiling:** a boolean declared `ceiling: true` can only be lowered by the
141
+ server. The value is `default AND server value`. A server `true` against a
142
+ `false` default reads `off`, with value false.
143
+ - **`reason`** is the entry's reason when the value read is the server's
144
+ value and the reason is a string, else null.
145
+
146
+ When a fresh value applies, at launch or live, is the app's policy. It is not
147
+ part of this suite.
148
+
149
+ ## versions/version_ranges.json
150
+
151
+ A version and a range in the neutral syntax, `matched` out; `build_cases`
152
+ do the same for build numbers. Also lists
153
+ `invalid_ranges` and `invalid_build_ranges`, which every implementation must
154
+ refuse. Precedence is
155
+ SemVer 2.0 §11. Compare numbers by length, then digit by digit, if your
156
+ language lacks big integers. A null version means "no client version" and
157
+ never matches. Ranges in RubyGems syntax (`~>`, commas) are not part of the
158
+ client contract: `legacy_ranges.json` is server-only.
159
+
160
+ A case with `"server_matched"` records where the Ruby server reads the same
161
+ input differently: for 0.2.2 compatibility it reads a client version that
162
+ isn't SemVer (`1.4.0.1`, `01.4.0`) through RubyGems when the range is one
163
+ RubyGems can also read (`>=0.0.0`). Only versions an app passes in a
164
+ context's client Hash reach that path; client headers drop a non-SemVer
165
+ version, so clients never see it. Clients use `matched` and ignore
166
+ `server_matched`.
@@ -0,0 +1,46 @@
1
+ {
2
+ "description": "Bucket test vectors. v1 = SHA-256(\"salt:unit_key\")[0,15] hex mod 10000. v2 = SHA-256(\"v2|decision|salt|unit_key\")[0,15] hex mod 10000. A null or blank unit key has no bucket (TARGETING_KEY_MISSING), never a random one. The v2 rollout vectors are also checked against the Postgres expression from StandardFlags::Bucket.sql_v2.",
3
+ "suite": "bucket_vectors",
4
+ "scope": "server",
5
+ "vectors": [
6
+ {"version":1,"salt":"new_checkout","unit_key":"acct_42","bucket":2927},
7
+ {"version":1,"salt":"new_checkout","unit_key":"1","bucket":2424},
8
+ {"version":1,"salt":"new_checkout","unit_key":"00000000-0000-4000-8000-000000000001","bucket":8188},
9
+ {"version":1,"salt":"new_checkout","unit_key":"ünït-7","bucket":4038},
10
+ {"version":1,"salt":"9f3c2a71e4b0d856","unit_key":"acct_42","bucket":4815},
11
+ {"version":1,"salt":"9f3c2a71e4b0d856","unit_key":"1","bucket":2657},
12
+ {"version":1,"salt":"9f3c2a71e4b0d856","unit_key":"00000000-0000-4000-8000-000000000001","bucket":8928},
13
+ {"version":1,"salt":"9f3c2a71e4b0d856","unit_key":"ünït-7","bucket":892},
14
+ {"version":1,"salt":"home_hero","unit_key":"acct_42","bucket":2517},
15
+ {"version":1,"salt":"home_hero","unit_key":"1","bucket":9931},
16
+ {"version":1,"salt":"home_hero","unit_key":"00000000-0000-4000-8000-000000000001","bucket":5778},
17
+ {"version":1,"salt":"home_hero","unit_key":"ünït-7","bucket":3637},
18
+ {"version":2,"decision":"rollout","salt":"new_checkout","unit_key":"acct_42","bucket":1144},
19
+ {"version":2,"decision":"rollout","salt":"new_checkout","unit_key":"1","bucket":7533},
20
+ {"version":2,"decision":"rollout","salt":"new_checkout","unit_key":"00000000-0000-4000-8000-000000000001","bucket":956},
21
+ {"version":2,"decision":"rollout","salt":"new_checkout","unit_key":"ünït-7","bucket":1665},
22
+ {"version":2,"decision":"rollout","salt":"9f3c2a71e4b0d856","unit_key":"acct_42","bucket":2119},
23
+ {"version":2,"decision":"rollout","salt":"9f3c2a71e4b0d856","unit_key":"1","bucket":3768},
24
+ {"version":2,"decision":"rollout","salt":"9f3c2a71e4b0d856","unit_key":"00000000-0000-4000-8000-000000000001","bucket":8673},
25
+ {"version":2,"decision":"rollout","salt":"9f3c2a71e4b0d856","unit_key":"ünït-7","bucket":8448},
26
+ {"version":2,"decision":"rollout","salt":"home_hero","unit_key":"acct_42","bucket":8144},
27
+ {"version":2,"decision":"rollout","salt":"home_hero","unit_key":"1","bucket":3428},
28
+ {"version":2,"decision":"rollout","salt":"home_hero","unit_key":"00000000-0000-4000-8000-000000000001","bucket":4566},
29
+ {"version":2,"decision":"rollout","salt":"home_hero","unit_key":"ünït-7","bucket":5834},
30
+ {"version":2,"decision":"variant","salt":"new_checkout","unit_key":"acct_42","bucket":7516},
31
+ {"version":2,"decision":"variant","salt":"new_checkout","unit_key":"1","bucket":7537},
32
+ {"version":2,"decision":"variant","salt":"new_checkout","unit_key":"00000000-0000-4000-8000-000000000001","bucket":4270},
33
+ {"version":2,"decision":"variant","salt":"new_checkout","unit_key":"ünït-7","bucket":4096},
34
+ {"version":2,"decision":"variant","salt":"9f3c2a71e4b0d856","unit_key":"acct_42","bucket":609},
35
+ {"version":2,"decision":"variant","salt":"9f3c2a71e4b0d856","unit_key":"1","bucket":209},
36
+ {"version":2,"decision":"variant","salt":"9f3c2a71e4b0d856","unit_key":"00000000-0000-4000-8000-000000000001","bucket":8058},
37
+ {"version":2,"decision":"variant","salt":"9f3c2a71e4b0d856","unit_key":"ünït-7","bucket":4146},
38
+ {"version":2,"decision":"variant","salt":"home_hero","unit_key":"acct_42","bucket":7255},
39
+ {"version":2,"decision":"variant","salt":"home_hero","unit_key":"1","bucket":6212},
40
+ {"version":2,"decision":"variant","salt":"home_hero","unit_key":"00000000-0000-4000-8000-000000000001","bucket":8851},
41
+ {"version":2,"decision":"variant","salt":"home_hero","unit_key":"ünït-7","bucket":7292},
42
+ {"version":1,"salt":"new_checkout","unit_key":null,"bucket":null},
43
+ {"version":2,"decision":"rollout","salt":"new_checkout","unit_key":null,"bucket":null},
44
+ {"version":2,"decision":"rollout","salt":"new_checkout","unit_key":" ","bucket":null}
45
+ ]
46
+ }
@@ -0,0 +1,35 @@
1
+ {
2
+ "description": "forbidden_in guards, which run before ENV pins, and fail-safe results for unknown and removed keys outside strict mode.",
3
+ "suite": "evaluation",
4
+ "scope": "server",
5
+ "registry": {
6
+ "flags": [
7
+ { "kind": "flag", "key": "demo_data", "owner": "platform", "remove_by": "2027-01-01", "final": false,
8
+ "default": { "staging": true }, "forbidden_in": "production" },
9
+ { "kind": "mode", "key": "debug_tools", "owner": "platform", "values": ["off", "read_only", "full"],
10
+ "forbidden_in": ["production", "sandbox"] }
11
+ ],
12
+ "tombstones": [
13
+ { "key": "manual_entry", "removed": "2026-12-01" }
14
+ ]
15
+ },
16
+ "cases": [
17
+ { "name": "forbidden flag is off in the forbidden environment", "flag": "demo_data", "environment": "production",
18
+ "expected": { "value": false, "variant": "off", "reason": "DISABLED" } },
19
+ { "name": "forbidden flag ignores a pin in the forbidden environment", "flag": "demo_data", "environment": "production",
20
+ "env_vars": { "STANDARD_FLAGS_DEMO_DATA": "on" },
21
+ "expected": { "value": false, "variant": "off", "reason": "DISABLED" } },
22
+ { "name": "forbidden flag uses its default elsewhere", "flag": "demo_data", "environment": "staging",
23
+ "expected": { "value": true, "variant": "on", "reason": "DEFAULT" } },
24
+ { "name": "forbidden flag can be pinned elsewhere", "flag": "demo_data", "environment": "staging",
25
+ "env_vars": { "STANDARD_FLAGS_DEMO_DATA": "off" },
26
+ "expected": { "value": false, "variant": "off", "reason": "ENV_PIN", "source_env_var": "STANDARD_FLAGS_DEMO_DATA" } },
27
+ { "name": "forbidden mode is forced to its first value", "flag": "debug_tools", "environment": "sandbox",
28
+ "env_vars": { "STANDARD_FLAGS_DEBUG_TOOLS": "full" },
29
+ "expected": { "value": "off", "variant": "off", "reason": "DISABLED" } },
30
+ { "name": "unknown key fails safe outside strict mode", "flag": "never_declared", "environment": "production", "strict": false,
31
+ "expected": { "value": null, "variant": null, "reason": "ERROR", "error_code": "FLAG_NOT_FOUND" } },
32
+ { "name": "tombstoned key fails safe outside strict mode", "flag": "manual_entry", "environment": "production", "strict": false,
33
+ "expected": { "value": null, "variant": null, "reason": "ERROR", "error_code": "FLAG_NOT_FOUND" } }
34
+ ]
35
+ }
@@ -0,0 +1,38 @@
1
+ {
2
+ "description": "Legacy env names declared with env:, inversion of *_DISABLED names, and precedence of the canonical name.",
3
+ "suite": "evaluation",
4
+ "scope": "server",
5
+ "registry": {
6
+ "flags": [
7
+ { "kind": "kill_switch", "key": "ai_assistant", "owner": "assistant", "env": "ACME_LEGACY_DISABLED", "inverted": true },
8
+ { "kind": "flag", "key": "new_reports", "owner": "reporting", "remove_by": "2027-01-01", "final": true,
9
+ "env": ["ACME_REPORTS_ENABLED", "ACME_REPORTS_V2"] }
10
+ ]
11
+ },
12
+ "cases": [
13
+ { "name": "inverted legacy true turns the kill switch off", "flag": "ai_assistant", "environment": "production",
14
+ "env_vars": { "ACME_LEGACY_DISABLED": "true" },
15
+ "expected": { "value": false, "variant": "off", "reason": "KILL_SWITCH", "source_env_var": "ACME_LEGACY_DISABLED" } },
16
+ { "name": "inverted legacy false keeps the kill switch on", "flag": "ai_assistant", "environment": "production",
17
+ "env_vars": { "ACME_LEGACY_DISABLED": "false" },
18
+ "expected": { "value": true, "variant": "on", "reason": "ENV_PIN", "source_env_var": "ACME_LEGACY_DISABLED" } },
19
+ { "name": "canonical name is never inverted", "flag": "ai_assistant", "environment": "production",
20
+ "env_vars": { "STANDARD_FLAGS_AI_ASSISTANT": "true" },
21
+ "expected": { "value": true, "variant": "on", "reason": "ENV_PIN", "source_env_var": "STANDARD_FLAGS_AI_ASSISTANT" } },
22
+ { "name": "canonical wins over legacy", "flag": "ai_assistant", "environment": "production",
23
+ "env_vars": { "STANDARD_FLAGS_AI_ASSISTANT": "on", "ACME_LEGACY_DISABLED": "true" },
24
+ "expected": { "value": true, "variant": "on", "reason": "ENV_PIN", "source_env_var": "STANDARD_FLAGS_AI_ASSISTANT" } },
25
+ { "name": "unparseable canonical falls through to legacy", "flag": "ai_assistant", "environment": "production",
26
+ "env_vars": { "STANDARD_FLAGS_AI_ASSISTANT": "maybe", "ACME_LEGACY_DISABLED": "1" },
27
+ "expected": { "value": false, "variant": "off", "reason": "KILL_SWITCH", "source_env_var": "ACME_LEGACY_DISABLED" } },
28
+ { "name": "unparseable legacy value is ignored", "flag": "ai_assistant", "environment": "production",
29
+ "env_vars": { "ACME_LEGACY_DISABLED": "disabled" },
30
+ "expected": { "value": true, "variant": "on", "reason": "DEFAULT" } },
31
+ { "name": "first parseable legacy name wins in declared order", "flag": "new_reports", "environment": "production",
32
+ "env_vars": { "ACME_REPORTS_ENABLED": "yes", "ACME_REPORTS_V2": "no" },
33
+ "expected": { "value": true, "variant": "on", "reason": "ENV_PIN", "source_env_var": "ACME_REPORTS_ENABLED" } },
34
+ { "name": "later legacy name is read when earlier ones are unset", "flag": "new_reports", "environment": "production",
35
+ "env_vars": { "ACME_REPORTS_V2": "on" },
36
+ "expected": { "value": true, "variant": "on", "reason": "ENV_PIN", "source_env_var": "ACME_REPORTS_V2" } }
37
+ ]
38
+ }
@@ -0,0 +1,90 @@
1
+ {
2
+ "description": "legacy_parser: exact reads legacy env: names the way a hand-written ENV[\"X\"] == \"on\" reader did: no trimming or case folding, on only for a legacy_true value, any other value (including a set-but-blank one, unless inverted) pins off, and modes match a value exactly (blank is unset). The canonical STANDARD_FLAGS_<KEY> pin is always strict.",
3
+ "suite": "evaluation",
4
+ "scope": "server",
5
+ "registry": {
6
+ "flags": [
7
+ { "kind": "flag", "key": "purge_inactive", "owner": "platform", "permanent": true,
8
+ "env": "ACME_PURGE_INACTIVE", "legacy_parser": "exact" },
9
+ { "kind": "flag", "key": "bulk_export", "owner": "reporting", "permanent": true,
10
+ "env": "ACME_BULK_EXPORT", "legacy_parser": "exact", "legacy_true": ["on", "enabled"] },
11
+ { "kind": "kill_switch", "key": "ai_assistant", "owner": "assistant",
12
+ "env": "ACME_ASSISTANT_DISABLED", "inverted": true, "legacy_parser": "exact" },
13
+ { "kind": "mode", "key": "strict_gates", "owner": "platform", "preset": "sensor",
14
+ "env": "ACME_STRICT_GATES", "legacy_parser": "exact" },
15
+ { "kind": "flag", "key": "new_reports", "owner": "reporting", "remove_by": "2027-01-01", "final": true,
16
+ "env": "ACME_REPORTS_ENABLED" }
17
+ ]
18
+ },
19
+ "cases": [
20
+ { "name": "exact legacy on turns the flag on", "flag": "purge_inactive", "environment": "production",
21
+ "env_vars": { "ACME_PURGE_INACTIVE": "on" },
22
+ "expected": { "value": true, "variant": "on", "reason": "ENV_PIN", "source_env_var": "ACME_PURGE_INACTIVE" } },
23
+ { "name": "exact legacy true is not on: it pins the flag off", "flag": "purge_inactive", "environment": "production",
24
+ "env_vars": { "ACME_PURGE_INACTIVE": "true" },
25
+ "expected": { "value": false, "variant": "off", "reason": "ENV_PIN", "source_env_var": "ACME_PURGE_INACTIVE" } },
26
+ { "name": "exact legacy matching is case-sensitive", "flag": "purge_inactive", "environment": "production",
27
+ "env_vars": { "ACME_PURGE_INACTIVE": "ON" },
28
+ "expected": { "value": false, "variant": "off", "reason": "ENV_PIN", "source_env_var": "ACME_PURGE_INACTIVE" } },
29
+ { "name": "exact legacy matching does not strip whitespace", "flag": "purge_inactive", "environment": "production",
30
+ "env_vars": { "ACME_PURGE_INACTIVE": " on" },
31
+ "expected": { "value": false, "variant": "off", "reason": "ENV_PIN", "source_env_var": "ACME_PURGE_INACTIVE" } },
32
+ { "name": "an unrecognised exact legacy value pins off instead of being ignored", "flag": "purge_inactive", "environment": "production",
33
+ "env_vars": { "ACME_PURGE_INACTIVE": "maybe" },
34
+ "expected": { "value": false, "variant": "off", "reason": "ENV_PIN", "source_env_var": "ACME_PURGE_INACTIVE" } },
35
+ { "name": "a set-but-blank exact legacy value pins the flag off", "flag": "purge_inactive", "environment": "production",
36
+ "env_vars": { "ACME_PURGE_INACTIVE": " " },
37
+ "expected": { "value": false, "variant": "off", "reason": "ENV_PIN", "source_env_var": "ACME_PURGE_INACTIVE" } },
38
+ { "name": "an empty exact legacy value pins the flag off", "flag": "purge_inactive", "environment": "production",
39
+ "env_vars": { "ACME_PURGE_INACTIVE": "" },
40
+ "expected": { "value": false, "variant": "off", "reason": "ENV_PIN", "source_env_var": "ACME_PURGE_INACTIVE" } },
41
+ { "name": "an unset exact legacy name falls through to the default", "flag": "purge_inactive", "environment": "production",
42
+ "env_vars": {},
43
+ "expected": { "value": false, "variant": "off", "reason": "DEFAULT" } },
44
+ { "name": "a blank canonical pin is unset, so the exact legacy name decides", "flag": "purge_inactive", "environment": "production",
45
+ "env_vars": { "STANDARD_FLAGS_PURGE_INACTIVE": " ", "ACME_PURGE_INACTIVE": "on" },
46
+ "expected": { "value": true, "variant": "on", "reason": "ENV_PIN", "source_env_var": "ACME_PURGE_INACTIVE" } },
47
+ { "name": "the canonical pin stays strict and case-insensitive", "flag": "purge_inactive", "environment": "production",
48
+ "env_vars": { "STANDARD_FLAGS_PURGE_INACTIVE": " TRUE " },
49
+ "expected": { "value": true, "variant": "on", "reason": "ENV_PIN", "source_env_var": "STANDARD_FLAGS_PURGE_INACTIVE" } },
50
+ { "name": "the canonical pin wins over an exact legacy name", "flag": "purge_inactive", "environment": "production",
51
+ "env_vars": { "STANDARD_FLAGS_PURGE_INACTIVE": "off", "ACME_PURGE_INACTIVE": "on" },
52
+ "expected": { "value": false, "variant": "off", "reason": "ENV_PIN", "source_env_var": "STANDARD_FLAGS_PURGE_INACTIVE" } },
53
+ { "name": "an unparseable canonical pin falls through to the exact legacy name", "flag": "purge_inactive", "environment": "production",
54
+ "env_vars": { "STANDARD_FLAGS_PURGE_INACTIVE": "maybe", "ACME_PURGE_INACTIVE": "on" },
55
+ "expected": { "value": true, "variant": "on", "reason": "ENV_PIN", "source_env_var": "ACME_PURGE_INACTIVE" } },
56
+ { "name": "legacy_true lists every value that means on", "flag": "bulk_export", "environment": "production",
57
+ "env_vars": { "ACME_BULK_EXPORT": "enabled" },
58
+ "expected": { "value": true, "variant": "on", "reason": "ENV_PIN", "source_env_var": "ACME_BULK_EXPORT" } },
59
+ { "name": "legacy_true replaces the default on", "flag": "bulk_export", "environment": "production",
60
+ "env_vars": { "ACME_BULK_EXPORT": "yes" },
61
+ "expected": { "value": false, "variant": "off", "reason": "ENV_PIN", "source_env_var": "ACME_BULK_EXPORT" } },
62
+ { "name": "inverted exact legacy on turns the kill switch off", "flag": "ai_assistant", "environment": "production",
63
+ "env_vars": { "ACME_ASSISTANT_DISABLED": "on" },
64
+ "expected": { "value": false, "variant": "off", "reason": "KILL_SWITCH", "source_env_var": "ACME_ASSISTANT_DISABLED" } },
65
+ { "name": "inverted exact legacy true keeps the kill switch on", "flag": "ai_assistant", "environment": "production",
66
+ "env_vars": { "ACME_ASSISTANT_DISABLED": "true" },
67
+ "expected": { "value": true, "variant": "on", "reason": "ENV_PIN", "source_env_var": "ACME_ASSISTANT_DISABLED" } },
68
+ { "name": "a blank inverted exact legacy value is unset", "flag": "ai_assistant", "environment": "production",
69
+ "env_vars": { "ACME_ASSISTANT_DISABLED": "" },
70
+ "expected": { "value": true, "variant": "on", "reason": "DEFAULT" } },
71
+ { "name": "a blank exact legacy mode value is unset", "flag": "strict_gates", "environment": "production",
72
+ "env_vars": { "ACME_STRICT_GATES": " " },
73
+ "expected": { "value": "off", "variant": "off", "reason": "DEFAULT" } },
74
+ { "name": "an exact legacy mode value must equal a mode name", "flag": "strict_gates", "environment": "production",
75
+ "env_vars": { "ACME_STRICT_GATES": "sensor" },
76
+ "expected": { "value": "sensor", "variant": "sensor", "reason": "ENV_PIN", "source_env_var": "ACME_STRICT_GATES" } },
77
+ { "name": "an exact legacy mode value in another case is rejected", "flag": "strict_gates", "environment": "production",
78
+ "env_vars": { "ACME_STRICT_GATES": "Sensor" },
79
+ "expected": { "value": "off", "variant": "off", "reason": "DEFAULT" } },
80
+ { "name": "an exact legacy mode value with whitespace is rejected", "flag": "strict_gates", "environment": "production",
81
+ "env_vars": { "ACME_STRICT_GATES": "on " },
82
+ "expected": { "value": "off", "variant": "off", "reason": "DEFAULT" } },
83
+ { "name": "the canonical mode pin stays case-insensitive", "flag": "strict_gates", "environment": "production",
84
+ "env_vars": { "STANDARD_FLAGS_STRICT_GATES": "Sensor" },
85
+ "expected": { "value": "sensor", "variant": "sensor", "reason": "ENV_PIN", "source_env_var": "STANDARD_FLAGS_STRICT_GATES" } },
86
+ { "name": "a legacy name without legacy_parser stays strict", "flag": "new_reports", "environment": "production",
87
+ "env_vars": { "ACME_REPORTS_ENABLED": " Yes " },
88
+ "expected": { "value": true, "variant": "on", "reason": "ENV_PIN", "source_env_var": "ACME_REPORTS_ENABLED" } }
89
+ ]
90
+ }