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,723 @@
1
+ {
2
+ "description": "The write path: operations applied in order to an empty store, then evaluations. Each step names an operation (snake_case: ramp, set_value, add_members, ...), its target (a flag key, or cohort:<key>), its arguments as stored strings, an optional expected_revision, and the failure code it must return when it is refused (\"fails\"). A set_value with a value on a draft rule (including the one it creates) starts it in the same write; every other operation leaves a draft a draft. Steps run as a system actor that the policy allows. Rules created by a step take the flag's bucketing:, so bucket numbers in case names are the v2 rollout bucket (see bucket_vectors.json).",
3
+ "suite": "operations",
4
+ "scope": "server",
5
+ "registry": {
6
+ "units": [
7
+ "account"
8
+ ],
9
+ "flags": [
10
+ {
11
+ "kind": "flag",
12
+ "key": "new_checkout",
13
+ "owner": "payments",
14
+ "remove_by": "2027-01-01",
15
+ "final": true,
16
+ "unit": "account",
17
+ "bucketing": {
18
+ "version": 2,
19
+ "salt": "conformance"
20
+ }
21
+ },
22
+ {
23
+ "kind": "flag",
24
+ "key": "global_banner",
25
+ "owner": "web",
26
+ "remove_by": "2027-01-01",
27
+ "final": true
28
+ },
29
+ {
30
+ "kind": "kill_switch",
31
+ "key": "ai_assistant",
32
+ "owner": "assistant",
33
+ "unit": "account"
34
+ },
35
+ {
36
+ "kind": "mode",
37
+ "key": "strict_gates",
38
+ "owner": "platform",
39
+ "preset": "sensor",
40
+ "unit": "account"
41
+ }
42
+ ]
43
+ },
44
+ "cases": [
45
+ {
46
+ "name": "a draft rule serves the code default until it starts (acct_8 is bucket 2290)",
47
+ "steps": [
48
+ {
49
+ "op": "ramp",
50
+ "target": "new_checkout",
51
+ "args": {
52
+ "bps": 2500
53
+ }
54
+ }
55
+ ],
56
+ "checks": [
57
+ {
58
+ "flag": "new_checkout",
59
+ "environment": "production",
60
+ "context": {
61
+ "units": {
62
+ "account": "acct_8"
63
+ }
64
+ },
65
+ "expected": {
66
+ "value": false,
67
+ "variant": "off",
68
+ "reason": "DEFAULT",
69
+ "rule_id": null,
70
+ "error_code": null
71
+ }
72
+ }
73
+ ]
74
+ },
75
+ {
76
+ "name": "set_value on a draft starts it, so the value serves at once",
77
+ "steps": [
78
+ {
79
+ "op": "set_value",
80
+ "target": "global_banner",
81
+ "args": {
82
+ "value": "on"
83
+ }
84
+ }
85
+ ],
86
+ "checks": [
87
+ {
88
+ "flag": "global_banner",
89
+ "environment": "production",
90
+ "context": {},
91
+ "expected": {
92
+ "value": true,
93
+ "variant": "on",
94
+ "reason": "TARGETING_MATCH",
95
+ "rule_id": "fallthrough",
96
+ "error_code": null
97
+ }
98
+ }
99
+ ]
100
+ },
101
+ {
102
+ "name": "start refuses a rule set_value already started",
103
+ "steps": [
104
+ {
105
+ "op": "set_value",
106
+ "target": "global_banner",
107
+ "args": {
108
+ "value": "on"
109
+ }
110
+ },
111
+ {
112
+ "op": "start",
113
+ "target": "global_banner",
114
+ "fails": "invalid"
115
+ }
116
+ ],
117
+ "checks": [
118
+ {
119
+ "flag": "global_banner",
120
+ "environment": "production",
121
+ "context": {},
122
+ "expected": {
123
+ "value": true,
124
+ "variant": "on",
125
+ "reason": "TARGETING_MATCH",
126
+ "rule_id": "fallthrough",
127
+ "error_code": null
128
+ }
129
+ }
130
+ ]
131
+ },
132
+ {
133
+ "name": "set_value starts a draft with what was staged on it (acct_8 is bucket 2290, acct_1 is 8584)",
134
+ "steps": [
135
+ {
136
+ "op": "ramp",
137
+ "target": "new_checkout",
138
+ "args": {
139
+ "bps": 2500
140
+ }
141
+ },
142
+ {
143
+ "op": "set_value",
144
+ "target": "new_checkout",
145
+ "args": {
146
+ "value": "off"
147
+ }
148
+ }
149
+ ],
150
+ "checks": [
151
+ {
152
+ "flag": "new_checkout",
153
+ "environment": "production",
154
+ "context": {
155
+ "units": {
156
+ "account": "acct_8"
157
+ }
158
+ },
159
+ "expected": {
160
+ "value": true,
161
+ "variant": "on",
162
+ "reason": "SPLIT",
163
+ "rule_id": "percentage",
164
+ "error_code": null
165
+ }
166
+ },
167
+ {
168
+ "flag": "new_checkout",
169
+ "environment": "production",
170
+ "context": {
171
+ "units": {
172
+ "account": "acct_1"
173
+ }
174
+ },
175
+ "expected": {
176
+ "value": false,
177
+ "variant": "off",
178
+ "reason": "TARGETING_MATCH",
179
+ "rule_id": "fallthrough",
180
+ "error_code": null
181
+ }
182
+ }
183
+ ]
184
+ },
185
+ {
186
+ "name": "set_value on a paused rule stores the value and leaves it paused",
187
+ "steps": [
188
+ {
189
+ "op": "set_value",
190
+ "target": "strict_gates",
191
+ "args": {
192
+ "value": "sensor"
193
+ }
194
+ },
195
+ {
196
+ "op": "pause",
197
+ "target": "strict_gates"
198
+ },
199
+ {
200
+ "op": "set_value",
201
+ "target": "strict_gates",
202
+ "args": {
203
+ "value": "on"
204
+ }
205
+ }
206
+ ],
207
+ "checks": [
208
+ {
209
+ "flag": "strict_gates",
210
+ "environment": "production",
211
+ "context": {
212
+ "units": {
213
+ "account": "acct_1"
214
+ }
215
+ },
216
+ "expected": {
217
+ "value": "off",
218
+ "variant": "off",
219
+ "reason": "DEFAULT",
220
+ "rule_id": null,
221
+ "error_code": null
222
+ }
223
+ }
224
+ ]
225
+ },
226
+ {
227
+ "name": "clearing the value of a new rule leaves it a draft",
228
+ "steps": [
229
+ {
230
+ "op": "set_value",
231
+ "target": "global_banner",
232
+ "args": {
233
+ "value": null
234
+ }
235
+ },
236
+ {
237
+ "op": "start",
238
+ "target": "global_banner"
239
+ }
240
+ ],
241
+ "checks": [
242
+ {
243
+ "flag": "global_banner",
244
+ "environment": "production",
245
+ "context": {},
246
+ "expected": {
247
+ "value": false,
248
+ "variant": "off",
249
+ "reason": "DEFAULT",
250
+ "rule_id": null,
251
+ "error_code": null
252
+ }
253
+ }
254
+ ]
255
+ },
256
+ {
257
+ "name": "a ramp serves units below the percentage (acct_8 is bucket 2290, acct_1 is 8584)",
258
+ "steps": [
259
+ {
260
+ "op": "ramp",
261
+ "target": "new_checkout",
262
+ "args": {
263
+ "bps": 2500
264
+ }
265
+ },
266
+ {
267
+ "op": "start",
268
+ "target": "new_checkout"
269
+ }
270
+ ],
271
+ "checks": [
272
+ {
273
+ "flag": "new_checkout",
274
+ "environment": "production",
275
+ "context": {
276
+ "units": {
277
+ "account": "acct_8"
278
+ }
279
+ },
280
+ "expected": {
281
+ "value": true,
282
+ "variant": "on",
283
+ "reason": "SPLIT",
284
+ "rule_id": "percentage",
285
+ "error_code": null
286
+ }
287
+ },
288
+ {
289
+ "flag": "new_checkout",
290
+ "environment": "production",
291
+ "context": {
292
+ "units": {
293
+ "account": "acct_1"
294
+ }
295
+ },
296
+ "expected": {
297
+ "value": false,
298
+ "variant": "off",
299
+ "reason": "DEFAULT",
300
+ "rule_id": null,
301
+ "error_code": null
302
+ }
303
+ }
304
+ ]
305
+ },
306
+ {
307
+ "name": "pausing serves the code default and keeps the settings for start",
308
+ "steps": [
309
+ {
310
+ "op": "set_value",
311
+ "target": "strict_gates",
312
+ "args": {
313
+ "value": "on"
314
+ }
315
+ },
316
+ {
317
+ "op": "pause",
318
+ "target": "strict_gates"
319
+ }
320
+ ],
321
+ "checks": [
322
+ {
323
+ "flag": "strict_gates",
324
+ "environment": "production",
325
+ "context": {
326
+ "units": {
327
+ "account": "acct_1"
328
+ }
329
+ },
330
+ "expected": {
331
+ "value": "off",
332
+ "variant": "off",
333
+ "reason": "DEFAULT",
334
+ "rule_id": null,
335
+ "error_code": null
336
+ }
337
+ }
338
+ ]
339
+ },
340
+ {
341
+ "name": "start resumes a paused rule as it was",
342
+ "steps": [
343
+ {
344
+ "op": "set_value",
345
+ "target": "strict_gates",
346
+ "args": {
347
+ "value": "sensor"
348
+ }
349
+ },
350
+ {
351
+ "op": "pause",
352
+ "target": "strict_gates"
353
+ },
354
+ {
355
+ "op": "start",
356
+ "target": "strict_gates"
357
+ }
358
+ ],
359
+ "checks": [
360
+ {
361
+ "flag": "strict_gates",
362
+ "environment": "production",
363
+ "context": {
364
+ "units": {
365
+ "account": "acct_1"
366
+ }
367
+ },
368
+ "expected": {
369
+ "value": "sensor",
370
+ "variant": "sensor",
371
+ "reason": "TARGETING_MATCH",
372
+ "rule_id": "fallthrough",
373
+ "error_code": null
374
+ }
375
+ }
376
+ ]
377
+ },
378
+ {
379
+ "name": "set_value throws a kill switch from the database, starting the rule it creates",
380
+ "steps": [
381
+ {
382
+ "op": "set_value",
383
+ "target": "ai_assistant",
384
+ "args": {
385
+ "value": "off"
386
+ }
387
+ }
388
+ ],
389
+ "checks": [
390
+ {
391
+ "flag": "ai_assistant",
392
+ "environment": "production",
393
+ "context": {
394
+ "units": {
395
+ "account": "acct_1"
396
+ }
397
+ },
398
+ "expected": {
399
+ "value": false,
400
+ "variant": "off",
401
+ "reason": "KILL_SWITCH",
402
+ "rule_id": "fallthrough",
403
+ "error_code": null
404
+ }
405
+ }
406
+ ]
407
+ },
408
+ {
409
+ "name": "a member's value wins over the fallthrough, and deny wins over a cohort",
410
+ "steps": [
411
+ {
412
+ "op": "create_cohort",
413
+ "target": "cohort:staff",
414
+ "args": {
415
+ "unit": "account"
416
+ }
417
+ },
418
+ {
419
+ "op": "add_members",
420
+ "target": "cohort:staff",
421
+ "args": {
422
+ "keys": [
423
+ "acct_1",
424
+ "acct_2"
425
+ ]
426
+ }
427
+ },
428
+ {
429
+ "op": "attach_cohort",
430
+ "target": "strict_gates",
431
+ "args": {
432
+ "cohort": "staff",
433
+ "value": "on"
434
+ }
435
+ },
436
+ {
437
+ "op": "add_members",
438
+ "target": "strict_gates",
439
+ "args": {
440
+ "keys": [
441
+ "acct_2"
442
+ ],
443
+ "value": "off"
444
+ }
445
+ },
446
+ {
447
+ "op": "set_value",
448
+ "target": "strict_gates",
449
+ "args": {
450
+ "value": "sensor"
451
+ }
452
+ }
453
+ ],
454
+ "checks": [
455
+ {
456
+ "flag": "strict_gates",
457
+ "environment": "production",
458
+ "context": {
459
+ "units": {
460
+ "account": "acct_1"
461
+ }
462
+ },
463
+ "expected": {
464
+ "value": "on",
465
+ "variant": "on",
466
+ "reason": "TARGETING_MATCH",
467
+ "rule_id": "cohort:staff",
468
+ "error_code": null
469
+ }
470
+ },
471
+ {
472
+ "flag": "strict_gates",
473
+ "environment": "production",
474
+ "context": {
475
+ "units": {
476
+ "account": "acct_2"
477
+ }
478
+ },
479
+ "expected": {
480
+ "value": "off",
481
+ "variant": "off",
482
+ "reason": "TARGETING_MATCH",
483
+ "rule_id": "deny",
484
+ "error_code": null
485
+ }
486
+ },
487
+ {
488
+ "flag": "strict_gates",
489
+ "environment": "production",
490
+ "context": {
491
+ "units": {
492
+ "account": "acct_3"
493
+ }
494
+ },
495
+ "expected": {
496
+ "value": "sensor",
497
+ "variant": "sensor",
498
+ "reason": "TARGETING_MATCH",
499
+ "rule_id": "fallthrough",
500
+ "error_code": null
501
+ }
502
+ }
503
+ ]
504
+ },
505
+ {
506
+ "name": "a removed member no longer matches",
507
+ "steps": [
508
+ {
509
+ "op": "add_members",
510
+ "target": "new_checkout",
511
+ "args": {
512
+ "keys": [
513
+ "acct_1"
514
+ ]
515
+ }
516
+ },
517
+ {
518
+ "op": "start",
519
+ "target": "new_checkout"
520
+ },
521
+ {
522
+ "op": "remove_members",
523
+ "target": "new_checkout",
524
+ "args": {
525
+ "keys": [
526
+ "acct_1"
527
+ ]
528
+ }
529
+ }
530
+ ],
531
+ "checks": [
532
+ {
533
+ "flag": "new_checkout",
534
+ "environment": "production",
535
+ "context": {
536
+ "units": {
537
+ "account": "acct_1"
538
+ }
539
+ },
540
+ "expected": {
541
+ "value": false,
542
+ "variant": "off",
543
+ "reason": "DEFAULT",
544
+ "rule_id": null,
545
+ "error_code": null
546
+ }
547
+ }
548
+ ]
549
+ },
550
+ {
551
+ "name": "a stopped rule serves its stop value to everyone",
552
+ "steps": [
553
+ {
554
+ "op": "add_members",
555
+ "target": "new_checkout",
556
+ "args": {
557
+ "keys": [
558
+ "acct_1"
559
+ ],
560
+ "value": "off"
561
+ }
562
+ },
563
+ {
564
+ "op": "stop",
565
+ "target": "new_checkout",
566
+ "args": {
567
+ "serve": "on"
568
+ }
569
+ }
570
+ ],
571
+ "checks": [
572
+ {
573
+ "flag": "new_checkout",
574
+ "environment": "production",
575
+ "context": {
576
+ "units": {
577
+ "account": "acct_1"
578
+ }
579
+ },
580
+ "expected": {
581
+ "value": true,
582
+ "variant": "on",
583
+ "reason": "STATIC",
584
+ "rule_id": "stopped",
585
+ "error_code": null
586
+ }
587
+ },
588
+ {
589
+ "flag": "new_checkout",
590
+ "environment": "production",
591
+ "context": {},
592
+ "expected": {
593
+ "value": true,
594
+ "variant": "on",
595
+ "reason": "STATIC",
596
+ "rule_id": "stopped",
597
+ "error_code": null
598
+ }
599
+ }
600
+ ]
601
+ },
602
+ {
603
+ "name": "expected_revision is the rule's revision: a stale one is refused, the current one applies",
604
+ "steps": [
605
+ {
606
+ "op": "ramp",
607
+ "target": "new_checkout",
608
+ "args": {
609
+ "bps": 2500
610
+ }
611
+ },
612
+ {
613
+ "op": "start",
614
+ "target": "new_checkout",
615
+ "expected_revision": 0,
616
+ "fails": "stale_revision"
617
+ },
618
+ {
619
+ "op": "start",
620
+ "target": "new_checkout",
621
+ "expected_revision": 1
622
+ }
623
+ ],
624
+ "checks": [
625
+ {
626
+ "flag": "new_checkout",
627
+ "environment": "production",
628
+ "context": {
629
+ "units": {
630
+ "account": "acct_8"
631
+ }
632
+ },
633
+ "expected": {
634
+ "value": true,
635
+ "variant": "on",
636
+ "reason": "SPLIT",
637
+ "rule_id": "percentage",
638
+ "error_code": null
639
+ }
640
+ }
641
+ ]
642
+ },
643
+ {
644
+ "name": "a pinned flag is refused and the pin still decides",
645
+ "env_vars": {
646
+ "STANDARD_FLAGS_GLOBAL_BANNER": "true"
647
+ },
648
+ "steps": [
649
+ {
650
+ "op": "set_value",
651
+ "target": "global_banner",
652
+ "args": {
653
+ "value": "off"
654
+ },
655
+ "fails": "pinned_by_env"
656
+ }
657
+ ],
658
+ "checks": [
659
+ {
660
+ "flag": "global_banner",
661
+ "environment": "production",
662
+ "context": {},
663
+ "expected": {
664
+ "value": true,
665
+ "variant": "on",
666
+ "reason": "ENV_PIN",
667
+ "rule_id": null,
668
+ "error_code": null
669
+ }
670
+ }
671
+ ]
672
+ },
673
+ {
674
+ "name": "a value the flag can't take is refused on write",
675
+ "steps": [
676
+ {
677
+ "op": "set_value",
678
+ "target": "strict_gates",
679
+ "args": {
680
+ "value": "loud"
681
+ },
682
+ "fails": "invalid"
683
+ },
684
+ {
685
+ "op": "ramp",
686
+ "target": "new_checkout",
687
+ "args": {
688
+ "bps": 10001
689
+ },
690
+ "fails": "invalid"
691
+ },
692
+ {
693
+ "op": "set_variants",
694
+ "target": "strict_gates",
695
+ "args": {
696
+ "weights": {
697
+ "off": 5000
698
+ }
699
+ },
700
+ "fails": "invalid"
701
+ }
702
+ ],
703
+ "checks": [
704
+ {
705
+ "flag": "strict_gates",
706
+ "environment": "production",
707
+ "context": {
708
+ "units": {
709
+ "account": "acct_1"
710
+ }
711
+ },
712
+ "expected": {
713
+ "value": "off",
714
+ "variant": "off",
715
+ "reason": "DEFAULT",
716
+ "rule_id": null,
717
+ "error_code": null
718
+ }
719
+ }
720
+ ]
721
+ }
722
+ ]
723
+ }