standard_flags 0.3.0 → 0.4.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 (45) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +188 -0
  3. data/README.md +531 -59
  4. data/conformance/README.md +152 -3
  5. data/conformance/legacy_env.json +7 -1
  6. data/conformance/schema/fixture.schema.json +390 -21
  7. data/conformance/schema/manifest.schema.json +347 -0
  8. data/conformance/upgrade/client_status_server.json +297 -0
  9. data/conformance/wire/client_state.json +2115 -2
  10. data/conformance/wire/client_status.json +359 -0
  11. data/conformance/wire/manifest_check.json +5713 -0
  12. data/lib/generators/standard_flags/install/templates/initializer.rb.tt +4 -1
  13. data/lib/generators/standard_flags/migrations/migrations_generator.rb +37 -9
  14. data/lib/generators/standard_flags/migrations/templates/create_standard_flags_compat_stats.rb.tt +17 -0
  15. data/lib/standard_flags/client_app.rb +229 -0
  16. data/lib/standard_flags/client_status/controller.rb +59 -0
  17. data/lib/standard_flags/client_status.rb +110 -0
  18. data/lib/standard_flags/config.rb +18 -1
  19. data/lib/standard_flags/controller.rb +110 -5
  20. data/lib/standard_flags/definition.rb +37 -35
  21. data/lib/standard_flags/diagnostics.rb +61 -3
  22. data/lib/standard_flags/env_pin.rb +5 -15
  23. data/lib/standard_flags/errors.rb +31 -0
  24. data/lib/standard_flags/evaluator.rb +1 -0
  25. data/lib/standard_flags/mcp/flags.rb +12 -1
  26. data/lib/standard_flags/open_feature/provider.rb +2 -1
  27. data/lib/standard_flags/parser.rb +0 -16
  28. data/lib/standard_flags/registry.rb +46 -4
  29. data/lib/standard_flags/runtime/active_record_store.rb +64 -0
  30. data/lib/standard_flags/runtime/compat_tracker.rb +228 -0
  31. data/lib/standard_flags/runtime/memory_store.rb +20 -0
  32. data/lib/standard_flags/runtime/models.rb +6 -0
  33. data/lib/standard_flags/runtime/store.rb +18 -0
  34. data/lib/standard_flags/runtime.rb +33 -3
  35. data/lib/standard_flags/stores/app_store.rb +172 -0
  36. data/lib/standard_flags/stores.rb +37 -0
  37. data/lib/standard_flags/tooling/kotlin.rb +319 -0
  38. data/lib/standard_flags/tooling/manifest.rb +401 -0
  39. data/lib/standard_flags/tooling/manifest_check.rb +355 -0
  40. data/lib/standard_flags/tooling.rb +150 -55
  41. data/lib/standard_flags/version.rb +1 -1
  42. data/lib/standard_flags.rb +3 -0
  43. data/lib/tasks/standard_flags.rake +47 -0
  44. metadata +15 -2
  45. data/conformance/legacy_exact.json +0 -90
@@ -0,0 +1,347 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://raw.githubusercontent.com/rarebit-one/standard_flags/main/conformance/schema/manifest.schema.json",
4
+ "title": "standard_flags manifest, version 2",
5
+ "description": "The file `bin/rails standard_flags:manifest` writes (config.manifest_path). Client contract checks read `audiences`, each flag's `type` and `audiences`, and each tombstone's `serve` and `until`. Beyond what this schema checks, a reader also refuses: `version` written as anything but the integer 2 (`2.0`), dates that aren't calendar dates (`2026-02-30`; `format: date` says so, but not every validator asserts formats), and a wire listed twice for one audience (by two flags, or by a flag and a tombstone). Unknown top-level members may be added in later minor releases; readers ignore them.",
6
+ "type": "object",
7
+ "required": [
8
+ "version",
9
+ "audiences",
10
+ "flags",
11
+ "tombstones",
12
+ "clients"
13
+ ],
14
+ "properties": {
15
+ "version": {
16
+ "const": 2
17
+ },
18
+ "audiences": {
19
+ "type": "object",
20
+ "additionalProperties": {
21
+ "type": "object",
22
+ "required": [
23
+ "public"
24
+ ],
25
+ "properties": {
26
+ "public": {
27
+ "type": "boolean"
28
+ }
29
+ },
30
+ "additionalProperties": false
31
+ }
32
+ },
33
+ "flags": {
34
+ "type": "array",
35
+ "items": {
36
+ "$ref": "#/$defs/flag"
37
+ }
38
+ },
39
+ "tombstones": {
40
+ "type": "array",
41
+ "items": {
42
+ "$ref": "#/$defs/tombstone"
43
+ }
44
+ },
45
+ "clients": {
46
+ "type": "object",
47
+ "additionalProperties": {
48
+ "$ref": "#/$defs/client"
49
+ }
50
+ }
51
+ },
52
+ "$defs": {
53
+ "key": {
54
+ "type": "string",
55
+ "pattern": "^[a-z][a-z0-9_]*$"
56
+ },
57
+ "wire_name": {
58
+ "type": "string",
59
+ "pattern": "^[A-Za-z][A-Za-z0-9_]*$"
60
+ },
61
+ "date": {
62
+ "type": "string",
63
+ "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$",
64
+ "format": "date"
65
+ },
66
+ "value": {
67
+ "type": [
68
+ "boolean",
69
+ "string"
70
+ ]
71
+ },
72
+ "platform_versions": {
73
+ "type": "object",
74
+ "additionalProperties": {
75
+ "type": "string",
76
+ "minLength": 1
77
+ }
78
+ },
79
+ "flag": {
80
+ "type": "object",
81
+ "required": [
82
+ "key",
83
+ "kind",
84
+ "type",
85
+ "values",
86
+ "default",
87
+ "audiences",
88
+ "min_client"
89
+ ],
90
+ "properties": {
91
+ "key": {
92
+ "$ref": "#/$defs/key"
93
+ },
94
+ "kind": {
95
+ "enum": [
96
+ "flag",
97
+ "kill_switch",
98
+ "mode",
99
+ "experiment",
100
+ "compat"
101
+ ]
102
+ },
103
+ "type": {
104
+ "enum": [
105
+ "boolean",
106
+ "string"
107
+ ]
108
+ },
109
+ "values": {
110
+ "type": "array",
111
+ "minItems": 2,
112
+ "uniqueItems": true,
113
+ "items": {
114
+ "$ref": "#/$defs/value"
115
+ }
116
+ },
117
+ "default": {
118
+ "oneOf": [
119
+ {
120
+ "$ref": "#/$defs/value"
121
+ },
122
+ {
123
+ "type": "object",
124
+ "required": [
125
+ "*"
126
+ ],
127
+ "additionalProperties": {
128
+ "$ref": "#/$defs/value"
129
+ }
130
+ }
131
+ ]
132
+ },
133
+ "audiences": {
134
+ "type": "object",
135
+ "additionalProperties": {
136
+ "type": "array",
137
+ "minItems": 1,
138
+ "uniqueItems": true,
139
+ "items": {
140
+ "$ref": "#/$defs/wire_name"
141
+ }
142
+ }
143
+ },
144
+ "min_client": {
145
+ "$ref": "#/$defs/platform_versions"
146
+ },
147
+ "permanent": {
148
+ "type": "boolean"
149
+ },
150
+ "remove_by": {
151
+ "$ref": "#/$defs/date"
152
+ },
153
+ "final": {
154
+ "$ref": "#/$defs/value"
155
+ }
156
+ },
157
+ "additionalProperties": false,
158
+ "allOf": [
159
+ {
160
+ "if": {
161
+ "properties": {
162
+ "type": {
163
+ "const": "boolean"
164
+ }
165
+ }
166
+ },
167
+ "then": {
168
+ "properties": {
169
+ "values": {
170
+ "items": {
171
+ "type": "boolean"
172
+ }
173
+ },
174
+ "default": {
175
+ "oneOf": [
176
+ {
177
+ "type": "boolean"
178
+ },
179
+ {
180
+ "type": "object",
181
+ "additionalProperties": {
182
+ "type": "boolean"
183
+ }
184
+ }
185
+ ]
186
+ },
187
+ "final": {
188
+ "type": "boolean"
189
+ }
190
+ }
191
+ }
192
+ },
193
+ {
194
+ "if": {
195
+ "properties": {
196
+ "type": {
197
+ "const": "string"
198
+ }
199
+ }
200
+ },
201
+ "then": {
202
+ "properties": {
203
+ "values": {
204
+ "items": {
205
+ "type": "string"
206
+ }
207
+ },
208
+ "default": {
209
+ "oneOf": [
210
+ {
211
+ "type": "string"
212
+ },
213
+ {
214
+ "type": "object",
215
+ "additionalProperties": {
216
+ "type": "string"
217
+ }
218
+ }
219
+ ]
220
+ },
221
+ "final": {
222
+ "type": "string"
223
+ }
224
+ }
225
+ }
226
+ }
227
+ ]
228
+ },
229
+ "tombstone": {
230
+ "type": "object",
231
+ "required": [
232
+ "key",
233
+ "removed"
234
+ ],
235
+ "properties": {
236
+ "key": {
237
+ "$ref": "#/$defs/key"
238
+ },
239
+ "removed": {
240
+ "$ref": "#/$defs/date"
241
+ },
242
+ "serve": {
243
+ "type": "object",
244
+ "minProperties": 1,
245
+ "additionalProperties": {
246
+ "type": "object",
247
+ "minProperties": 1,
248
+ "propertyNames": {
249
+ "$ref": "#/$defs/wire_name"
250
+ },
251
+ "additionalProperties": {
252
+ "$ref": "#/$defs/value"
253
+ }
254
+ }
255
+ },
256
+ "until": {
257
+ "$ref": "#/$defs/date"
258
+ },
259
+ "until_clients": {
260
+ "$ref": "#/$defs/platform_versions"
261
+ }
262
+ },
263
+ "dependentRequired": {
264
+ "serve": [
265
+ "until",
266
+ "until_clients"
267
+ ],
268
+ "until": [
269
+ "serve"
270
+ ],
271
+ "until_clients": [
272
+ "serve"
273
+ ]
274
+ },
275
+ "additionalProperties": false
276
+ },
277
+ "client": {
278
+ "description": "A client registry entry as declared in code. ENV break-glass pins and store lookup answers never appear.",
279
+ "type": "object",
280
+ "required": [
281
+ "platform",
282
+ "group",
283
+ "min_version",
284
+ "since",
285
+ "grace",
286
+ "recommended",
287
+ "available",
288
+ "store_url",
289
+ "store_lookup"
290
+ ],
291
+ "properties": {
292
+ "platform": {
293
+ "type": "string",
294
+ "minLength": 1
295
+ },
296
+ "group": {
297
+ "type": [
298
+ "string",
299
+ "null"
300
+ ]
301
+ },
302
+ "min_version": {
303
+ "type": [
304
+ "string",
305
+ "null"
306
+ ]
307
+ },
308
+ "since": {
309
+ "oneOf": [
310
+ {
311
+ "$ref": "#/$defs/date"
312
+ },
313
+ {
314
+ "type": "null"
315
+ }
316
+ ]
317
+ },
318
+ "grace": {
319
+ "type": "integer",
320
+ "minimum": 0
321
+ },
322
+ "recommended": {
323
+ "type": [
324
+ "string",
325
+ "null"
326
+ ]
327
+ },
328
+ "available": {
329
+ "type": [
330
+ "string",
331
+ "null"
332
+ ]
333
+ },
334
+ "store_url": {
335
+ "type": [
336
+ "string",
337
+ "null"
338
+ ]
339
+ },
340
+ "store_lookup": {
341
+ "type": "boolean"
342
+ }
343
+ },
344
+ "additionalProperties": false
345
+ }
346
+ }
347
+ }
@@ -0,0 +1,297 @@
1
+ {
2
+ "description": "Server-only GET /client/status cases: the STANDARD_FLAGS_CLIENT_<NAME>_* break-glass ENV pins (`env_vars`) and per-client store lookups (`store_lookup`: client name => the version that client's lookup last answered; null means no answer). Same shape as wire/client_status.json.",
3
+ "suite": "client_status",
4
+ "scope": "server",
5
+ "client_platforms": [
6
+ "android",
7
+ "ios",
8
+ "web",
9
+ "desktop"
10
+ ],
11
+ "today": "2026-12-03",
12
+ "clients": [
13
+ {
14
+ "name": "android_app",
15
+ "platform": "android",
16
+ "min_version": "0.4.0",
17
+ "since": "2026-12-01",
18
+ "grace_days": 7,
19
+ "recommended": "0.5.0",
20
+ "available": "0.5.0",
21
+ "store_url": "https://example.com/store/android"
22
+ },
23
+ {
24
+ "name": "ios_app",
25
+ "platform": "ios",
26
+ "min_version": "2.0.0",
27
+ "since": "2026-11-01",
28
+ "grace_days": 7,
29
+ "recommended": "2.1.0",
30
+ "available": "1.9.0",
31
+ "store_url": "https://example.com/store/ios"
32
+ },
33
+ {
34
+ "name": "desktop_app",
35
+ "platform": "desktop",
36
+ "recommended": "3.0.0"
37
+ },
38
+ {
39
+ "name": "kiosk_android",
40
+ "platform": "android",
41
+ "group": "kiosk",
42
+ "min_version": "1.2.0",
43
+ "since": "2026-12-03",
44
+ "grace_days": 0
45
+ },
46
+ {
47
+ "name": "driver_ios",
48
+ "platform": "ios",
49
+ "group": "driver",
50
+ "min_version": "1.5.0",
51
+ "since": "2026-01-01",
52
+ "grace_days": 7,
53
+ "available": "1.4.0"
54
+ }
55
+ ],
56
+ "cases": [
57
+ {
58
+ "name": "ENV pin: a lowered minimum (break-glass) beats the code",
59
+ "client": {
60
+ "platform": "android",
61
+ "version": "0.3.9"
62
+ },
63
+ "today": "2026-12-08",
64
+ "env_vars": {
65
+ "STANDARD_FLAGS_CLIENT_ANDROID_APP_MIN_VERSION": "0.3.0"
66
+ },
67
+ "expected": {
68
+ "status": "upgrade_recommended",
69
+ "platform": "android",
70
+ "version": "0.3.9",
71
+ "min_version": "0.3.0",
72
+ "recommended": "0.5.0",
73
+ "enforce_at": null,
74
+ "store_url": "https://example.com/store/android"
75
+ }
76
+ },
77
+ {
78
+ "name": "ENV pin: a raised minimum without _SINCE is ignored, so it can't skip a grace window",
79
+ "client": {
80
+ "platform": "android",
81
+ "version": "0.4.2"
82
+ },
83
+ "today": "2026-12-08",
84
+ "env_vars": {
85
+ "STANDARD_FLAGS_CLIENT_ANDROID_APP_MIN_VERSION": "0.4.5"
86
+ },
87
+ "expected": {
88
+ "status": "upgrade_recommended",
89
+ "platform": "android",
90
+ "version": "0.4.2",
91
+ "min_version": "0.4.0",
92
+ "recommended": "0.5.0",
93
+ "enforce_at": null,
94
+ "store_url": "https://example.com/store/android"
95
+ }
96
+ },
97
+ {
98
+ "name": "ENV pin: a raised minimum with _SINCE gets its own grace window",
99
+ "client": {
100
+ "platform": "android",
101
+ "version": "0.4.2"
102
+ },
103
+ "today": "2026-12-08",
104
+ "env_vars": {
105
+ "STANDARD_FLAGS_CLIENT_ANDROID_APP_MIN_VERSION": "0.4.5",
106
+ "STANDARD_FLAGS_CLIENT_ANDROID_APP_SINCE": "2026-12-08"
107
+ },
108
+ "expected": {
109
+ "status": "upgrade_recommended",
110
+ "platform": "android",
111
+ "version": "0.4.2",
112
+ "min_version": "0.4.5",
113
+ "recommended": "0.5.0",
114
+ "enforce_at": "2026-12-15",
115
+ "store_url": "https://example.com/store/android"
116
+ }
117
+ },
118
+ {
119
+ "name": "ENV pin: a prerelease of the code's minimum is a raise (it stops that release's betas), so it needs _SINCE",
120
+ "client": {
121
+ "platform": "android",
122
+ "version": "0.4.0-beta.1"
123
+ },
124
+ "today": "2026-12-08",
125
+ "env_vars": {
126
+ "STANDARD_FLAGS_CLIENT_ANDROID_APP_MIN_VERSION": "0.4.0-rc.1"
127
+ },
128
+ "expected": {
129
+ "status": "upgrade_recommended",
130
+ "platform": "android",
131
+ "version": "0.4.0-beta.1",
132
+ "min_version": "0.4.0",
133
+ "recommended": "0.5.0",
134
+ "enforce_at": null,
135
+ "store_url": "https://example.com/store/android"
136
+ }
137
+ },
138
+ {
139
+ "name": "ENV pin: a new since restarts the grace window",
140
+ "client": {
141
+ "platform": "android",
142
+ "version": "0.3.9"
143
+ },
144
+ "today": "2026-12-08",
145
+ "env_vars": {
146
+ "STANDARD_FLAGS_CLIENT_ANDROID_APP_SINCE": "2026-12-05"
147
+ },
148
+ "expected": {
149
+ "status": "upgrade_recommended",
150
+ "platform": "android",
151
+ "version": "0.3.9",
152
+ "min_version": "0.4.0",
153
+ "recommended": "0.5.0",
154
+ "enforce_at": "2026-12-12",
155
+ "store_url": "https://example.com/store/android"
156
+ }
157
+ },
158
+ {
159
+ "name": "ENV pin: a value that doesn't parse is ignored",
160
+ "client": {
161
+ "platform": "android",
162
+ "version": "0.3.9"
163
+ },
164
+ "today": "2026-12-08",
165
+ "env_vars": {
166
+ "STANDARD_FLAGS_CLIENT_ANDROID_APP_MIN_VERSION": "latest"
167
+ },
168
+ "expected": {
169
+ "status": "upgrade_required",
170
+ "platform": "android",
171
+ "version": "0.3.9",
172
+ "min_version": "0.4.0",
173
+ "recommended": "0.5.0",
174
+ "enforce_at": "2026-12-08",
175
+ "store_url": "https://example.com/store/android"
176
+ }
177
+ },
178
+ {
179
+ "name": "ENV pin: a minimum on a client without one needs a pinned _SINCE",
180
+ "client": {
181
+ "platform": "desktop",
182
+ "version": "1.0.0"
183
+ },
184
+ "env_vars": {
185
+ "STANDARD_FLAGS_CLIENT_DESKTOP_APP_MIN_VERSION": "2.0.0"
186
+ },
187
+ "expected": {
188
+ "status": "upgrade_recommended",
189
+ "platform": "desktop",
190
+ "version": "1.0.0",
191
+ "min_version": null,
192
+ "recommended": "3.0.0",
193
+ "enforce_at": null,
194
+ "store_url": null
195
+ }
196
+ },
197
+ {
198
+ "name": "ENV pin: available raises the store ceiling",
199
+ "client": {
200
+ "platform": "ios",
201
+ "version": "1.9.0"
202
+ },
203
+ "env_vars": {
204
+ "STANDARD_FLAGS_CLIENT_IOS_APP_AVAILABLE": "2.1.0"
205
+ },
206
+ "expected": {
207
+ "status": "upgrade_required",
208
+ "platform": "ios",
209
+ "version": "1.9.0",
210
+ "min_version": "2.0.0",
211
+ "recommended": "2.1.0",
212
+ "enforce_at": "2026-11-08",
213
+ "store_url": "https://example.com/store/ios"
214
+ }
215
+ },
216
+ {
217
+ "name": "store lookup: its answer replaces the declared available",
218
+ "client": {
219
+ "platform": "ios",
220
+ "version": "1.9.5"
221
+ },
222
+ "store_lookup": {
223
+ "ios_app": "2.0.0"
224
+ },
225
+ "expected": {
226
+ "status": "upgrade_required",
227
+ "platform": "ios",
228
+ "version": "1.9.5",
229
+ "min_version": "2.0.0",
230
+ "recommended": "2.0.0",
231
+ "enforce_at": "2026-11-08",
232
+ "store_url": "https://example.com/store/ios"
233
+ }
234
+ },
235
+ {
236
+ "name": "store lookup: no answer falls back to the declared available",
237
+ "client": {
238
+ "platform": "ios",
239
+ "version": "1.9.5"
240
+ },
241
+ "store_lookup": {
242
+ "ios_app": null
243
+ },
244
+ "expected": {
245
+ "status": "ok",
246
+ "platform": "ios",
247
+ "version": "1.9.5",
248
+ "min_version": "1.9.0",
249
+ "recommended": "1.9.0",
250
+ "enforce_at": null,
251
+ "store_url": "https://example.com/store/ios"
252
+ }
253
+ },
254
+ {
255
+ "name": "ENV pin: _AVAILABLE beats a store lookup's answer",
256
+ "client": {
257
+ "platform": "ios",
258
+ "version": "1.9.5"
259
+ },
260
+ "env_vars": {
261
+ "STANDARD_FLAGS_CLIENT_IOS_APP_AVAILABLE": "1.9.0"
262
+ },
263
+ "store_lookup": {
264
+ "ios_app": "2.1.0"
265
+ },
266
+ "expected": {
267
+ "status": "ok",
268
+ "platform": "ios",
269
+ "version": "1.9.5",
270
+ "min_version": "1.9.0",
271
+ "recommended": "1.9.0",
272
+ "enforce_at": null,
273
+ "store_url": "https://example.com/store/ios"
274
+ }
275
+ },
276
+ {
277
+ "name": "store lookup: a lookup caps only the client that declares it",
278
+ "client": {
279
+ "platform": "ios",
280
+ "version": "1.4.0"
281
+ },
282
+ "group": "driver",
283
+ "store_lookup": {
284
+ "ios_app": "3.0.0"
285
+ },
286
+ "expected": {
287
+ "status": "ok",
288
+ "platform": "ios",
289
+ "version": "1.4.0",
290
+ "min_version": "1.4.0",
291
+ "recommended": null,
292
+ "enforce_at": null,
293
+ "store_url": null
294
+ }
295
+ }
296
+ ]
297
+ }