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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +188 -0
- data/README.md +531 -59
- data/conformance/README.md +152 -3
- data/conformance/legacy_env.json +7 -1
- data/conformance/schema/fixture.schema.json +390 -21
- data/conformance/schema/manifest.schema.json +347 -0
- data/conformance/upgrade/client_status_server.json +297 -0
- data/conformance/wire/client_state.json +2115 -2
- data/conformance/wire/client_status.json +359 -0
- data/conformance/wire/manifest_check.json +5713 -0
- data/lib/generators/standard_flags/install/templates/initializer.rb.tt +4 -1
- data/lib/generators/standard_flags/migrations/migrations_generator.rb +37 -9
- data/lib/generators/standard_flags/migrations/templates/create_standard_flags_compat_stats.rb.tt +17 -0
- data/lib/standard_flags/client_app.rb +229 -0
- data/lib/standard_flags/client_status/controller.rb +59 -0
- data/lib/standard_flags/client_status.rb +110 -0
- data/lib/standard_flags/config.rb +18 -1
- data/lib/standard_flags/controller.rb +110 -5
- data/lib/standard_flags/definition.rb +37 -35
- data/lib/standard_flags/diagnostics.rb +61 -3
- data/lib/standard_flags/env_pin.rb +5 -15
- data/lib/standard_flags/errors.rb +31 -0
- data/lib/standard_flags/evaluator.rb +1 -0
- data/lib/standard_flags/mcp/flags.rb +12 -1
- data/lib/standard_flags/open_feature/provider.rb +2 -1
- data/lib/standard_flags/parser.rb +0 -16
- data/lib/standard_flags/registry.rb +46 -4
- data/lib/standard_flags/runtime/active_record_store.rb +64 -0
- data/lib/standard_flags/runtime/compat_tracker.rb +228 -0
- data/lib/standard_flags/runtime/memory_store.rb +20 -0
- data/lib/standard_flags/runtime/models.rb +6 -0
- data/lib/standard_flags/runtime/store.rb +18 -0
- data/lib/standard_flags/runtime.rb +33 -3
- data/lib/standard_flags/stores/app_store.rb +172 -0
- data/lib/standard_flags/stores.rb +37 -0
- data/lib/standard_flags/tooling/kotlin.rb +319 -0
- data/lib/standard_flags/tooling/manifest.rb +401 -0
- data/lib/standard_flags/tooling/manifest_check.rb +355 -0
- data/lib/standard_flags/tooling.rb +150 -55
- data/lib/standard_flags/version.rb +1 -1
- data/lib/standard_flags.rb +3 -0
- data/lib/tasks/standard_flags.rake +47 -0
- metadata +15 -2
- data/conformance/legacy_exact.json +0 -90
data/README.md
CHANGED
|
@@ -8,16 +8,19 @@ guards, environment pins, then per-environment code defaults. Results have
|
|
|
8
8
|
the [OpenFeature](https://openfeature.dev) shape (value, variant, reason,
|
|
9
9
|
error code), so "why is this on?" is always a one-line answer.
|
|
10
10
|
|
|
11
|
-
This is version 0.
|
|
11
|
+
This is version 0.3.0: the registry, ENV layer and evaluation API (which
|
|
12
12
|
need no database tables), plus opt-in [runtime rules](#runtime-rules) stored
|
|
13
13
|
in the app's own database, the audited operations that change them,
|
|
14
|
-
[operator tools](#operator-tools-mcp), an admin page generator
|
|
15
|
-
[OpenFeature](#openfeature) provider
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
[operator tools](#operator-tools-mcp), an admin page generator, an
|
|
15
|
+
[OpenFeature](#openfeature) provider, [client context](#client-context) (who
|
|
16
|
+
is calling, from request headers), portable version ranges, build-number
|
|
17
|
+
conditions, a raisable `FeatureDisabled`, flag-gated MCP tools and
|
|
18
|
+
[client delivery](#client-delivery) (an OFREP endpoint mixin, bootstrap
|
|
19
|
+
embeds, minimum client versions and deprecated wires). Unreleased on `main`:
|
|
20
|
+
[client upgrades](#client-upgrades) (a client registry, `GET /client/status`,
|
|
21
|
+
a 426 guard and measured compatibility windows) and the
|
|
22
|
+
[client contract](#client-contract) (manifest version 2, a CI check, Kotlin
|
|
23
|
+
and TypeScript generators). See [Roadmap](#roadmap).
|
|
21
24
|
|
|
22
25
|
- [Install](#install)
|
|
23
26
|
- [Declaring flags](#declaring-flags)
|
|
@@ -30,6 +33,8 @@ deprecated wires). See [Roadmap](#roadmap).
|
|
|
30
33
|
- [Client context](#client-context)
|
|
31
34
|
- [Client payload](#client-payload)
|
|
32
35
|
- [Client delivery](#client-delivery)
|
|
36
|
+
- [Client upgrades](#client-upgrades)
|
|
37
|
+
- [Client contract](#client-contract)
|
|
33
38
|
- [Rake tasks](#rake-tasks)
|
|
34
39
|
- [Observability](#observability)
|
|
35
40
|
- [Health check and diagnostics](#health-check-and-diagnostics)
|
|
@@ -109,7 +114,7 @@ end
|
|
|
109
114
|
| `kill_switch` | on / off | on, fails open | Permanent switches that turn a feature off in an emergency. |
|
|
110
115
|
| `mode` | declared values | first value | Staged rollouts. Presets: `:sensor` (off/sensor/on), `:cutover` (off/allowlist/all), `:shadow` (off/shadow/enforce); or `values:`. May declare `remove_by:` with `final:`, or `permanent: true`. |
|
|
111
116
|
| `experiment` | declared variants | first variant | Experiments. Resolves to its first variant (list `control` first) unless pinned by ENV or split by a runtime rule's variant weights. |
|
|
112
|
-
| `compat` | on / off | on | Compatibility shims that stay on until they are removed. |
|
|
117
|
+
| `compat` | on / off | on | Compatibility shims that stay on until they are removed. `until_clients:` declares the client versions that still need it, and makes it a [measured window](#compatibility-windows). |
|
|
113
118
|
| `tombstone` | — | — | A removed key. It can never be declared again. `serve:` keeps its client wires answering a static value for a while ([Deprecated wires](#deprecated-wires)). |
|
|
114
119
|
|
|
115
120
|
### Attributes
|
|
@@ -121,8 +126,6 @@ end
|
|
|
121
126
|
| `default:` | A value, or `{ env_name => value }`. Environments not listed get the kind's default. |
|
|
122
127
|
| `env:` | Legacy environment variable name(s) still honoured. See [Environment variables](#environment-variables). |
|
|
123
128
|
| `inverted:` | The legacy name is a `*_DISABLED` variable: legacy on means flag off. |
|
|
124
|
-
| `legacy_parser:` | `:strict` (default) or `:exact`: how legacy `env:` values are read. See [Exact legacy readers](#exact-legacy-readers). |
|
|
125
|
-
| `legacy_true:` | With `legacy_parser: :exact` on an on/off kind, the exact values that mean on. Default `%w[on]`. |
|
|
126
129
|
| `forbidden_in:` | Environment name(s) where the flag is forced off. A pin that tries to turn it on is reported once per process. |
|
|
127
130
|
| `fail:` | The value returned if evaluation raises. Kill switches default to on. |
|
|
128
131
|
| `expose:` | `{ audience => wire_name }`, or a list of audiences to use the key. A Hash value may list several wire names (aliases), each serving the same evaluation: `expose: { mobile: %i[chat_enabled insights_enabled], web: :chat }`. Default: not exposed. |
|
|
@@ -131,14 +134,16 @@ end
|
|
|
131
134
|
| `bucketing:` | On `flag`, `mode` and `experiment`: `{ version: 1 \| 2, salt: "..." }`, for a flag migrated from another system that must keep its old buckets. Needs `unit:`. |
|
|
132
135
|
| `remove_by:`, `final:` | On `flag` (required) and `mode` (optional, together): the date it should be gone, and the value it settles on. A mode's `final:` must be one of its values. |
|
|
133
136
|
| `permanent:` | On `flag` and `mode`: `true` for a standing switch with no `remove_by:`/`final:`. |
|
|
137
|
+
| `until_clients:` | On `compat`: `{ platform => "version" }`, the first client version per platform that no longer needs the shim. See [Compatibility windows](#compatibility-windows). |
|
|
134
138
|
|
|
135
139
|
The registry is validated when it loads. `StandardFlags::DefinitionError` is
|
|
136
140
|
raised for a reused tombstoned key, a missing owner, a `flag` without
|
|
137
141
|
`remove_by:`/`final:` (or a `permanent: true` flag or mode with either), a mode with only one of
|
|
138
|
-
`remove_by:`/`final:` or a `final:` outside its values, a
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
+
`remove_by:`/`final:` or a `final:` outside its values, a default outside a
|
|
143
|
+
mode's values, the same wire name used twice for one audience, an undeclared
|
|
144
|
+
unit, a malformed `bucketing:` or unit `key:`, or any unknown attribute.
|
|
145
|
+
`legacy_parser:` and `legacy_true:` were removed in 0.4.0; declaring either
|
|
146
|
+
raises `ArgumentError` (see [Exact legacy readers](#exact-legacy-readers)).
|
|
142
147
|
|
|
143
148
|
### Units
|
|
144
149
|
|
|
@@ -285,10 +290,17 @@ app's own admin and tools.
|
|
|
285
290
|
|
|
286
291
|
```bash
|
|
287
292
|
bin/rails g standard_flags:migrations # existing installs
|
|
288
|
-
bin/rails g standard_flags:install --runtime # new installs: also writes the
|
|
293
|
+
bin/rails g standard_flags:install --runtime # new installs: also writes the migrations
|
|
289
294
|
bin/rails db:migrate
|
|
290
295
|
```
|
|
291
296
|
|
|
297
|
+
The generator writes two migrations: the runtime-rule tables, and
|
|
298
|
+
`standard_flags_compat_stats` for [compatibility windows](#compatibility-windows).
|
|
299
|
+
Each is skipped when its migration file already exists, or when its table
|
|
300
|
+
already exists in the database (an app that squashed or deleted the first
|
|
301
|
+
migration), so running it again after upgrading the gem adds only the new,
|
|
302
|
+
additive one. `--no-check-tables` skips the database check.
|
|
303
|
+
|
|
292
304
|
```ruby
|
|
293
305
|
# config/initializers/standard_flags.rb
|
|
294
306
|
StandardFlags.configure do |config|
|
|
@@ -934,16 +946,15 @@ restyle the pages freely.
|
|
|
934
946
|
Every flag can be pinned with its canonical variable, `STANDARD_FLAGS_<KEY>`
|
|
935
947
|
(the key upcased): `STANDARD_FLAGS_NEW_CHECKOUT=on`.
|
|
936
948
|
|
|
937
|
-
One strict parser reads every value,
|
|
938
|
-
|
|
949
|
+
One strict parser reads every value, canonical and legacy, trimmed and
|
|
950
|
+
case-insensitive:
|
|
939
951
|
|
|
940
952
|
- on/off kinds: `on`/`off`, `true`/`false`, `1`/`0`, `yes`/`no`;
|
|
941
953
|
- modes: a declared value; experiments: a declared variant.
|
|
942
954
|
|
|
943
955
|
Anything else is ignored and reported once per process per variable, through
|
|
944
956
|
`Rails.error.report(handled: true)` and a `pin_rejected.standard_flags`
|
|
945
|
-
notification. A blank value counts as unset
|
|
946
|
-
[exact reading](#exact-legacy-readers), where a blank legacy on/off value pins off).
|
|
957
|
+
notification. A blank value counts as unset.
|
|
947
958
|
|
|
948
959
|
### Legacy names
|
|
949
960
|
|
|
@@ -968,34 +979,15 @@ means enabled. Call that out when migrating a flag.
|
|
|
968
979
|
|
|
969
980
|
### Exact legacy readers
|
|
970
981
|
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
982
|
+
Versions before 0.4.0 offered `legacy_parser: :exact` (and `legacy_true:`)
|
|
983
|
+
to read a legacy name the way a hand-written `ENV["X"] == "on"` reader did.
|
|
984
|
+
Both are gone: declaring either raises `ArgumentError`. Set the canonical
|
|
985
|
+
`STANDARD_FLAGS_<KEY>` variable instead, which the strict parser reads.
|
|
974
986
|
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
env: "ACME_BULK_EXPORT", legacy_parser: :exact, legacy_true: %w[on enabled]
|
|
980
|
-
mode :strict_gates, owner: "platform", preset: :sensor,
|
|
981
|
-
env: "ACME_STRICT_GATES", legacy_parser: :exact
|
|
982
|
-
```
|
|
983
|
-
|
|
984
|
-
- It applies to legacy `env:` names only. The canonical
|
|
985
|
-
`STANDARD_FLAGS_<KEY>` pin is always read by the strict parser.
|
|
986
|
-
- On/off kinds: a value in `legacy_true:` (default `%w[on]`) means on; any
|
|
987
|
-
other non-blank value pins off, as the old reader did, and is never
|
|
988
|
-
reported as rejected. `inverted: true` still flips the result.
|
|
989
|
-
- Modes and experiments: a value matches only if it equals a declared value
|
|
990
|
-
exactly (case-sensitive, no trimming); anything else is rejected and
|
|
991
|
-
reported like any unparseable pin.
|
|
992
|
-
- Matching does no trimming or case folding.
|
|
993
|
-
- A legacy variable that is set but blank (`X=""`, `X=" "`) pins an on/off
|
|
994
|
-
flag off, as `ENV["X"] == "on"` did, so blanking the variable disarms the
|
|
995
|
-
flag even when a runtime rule or default would serve on. Only an unset
|
|
996
|
-
variable falls through. Two exceptions keep blank as unset: an `inverted:`
|
|
997
|
-
name (pinning it would turn the flag on) and modes and experiments, where
|
|
998
|
-
no value is "off". The canonical pin always treats blank as unset.
|
|
987
|
+
Moving off an exact reader widens what turns the flag on (`true`, `ON`,
|
|
988
|
+
` on ` now all mean on) and makes a set-but-blank value unset rather than
|
|
989
|
+
off, so it falls through to a runtime rule or the default. For a flag that
|
|
990
|
+
guards destructive work, check every environment's value before upgrading.
|
|
999
991
|
|
|
1000
992
|
## Sensor rollouts
|
|
1001
993
|
|
|
@@ -1075,6 +1067,11 @@ The denial carries `key`, `error`, `status` (from `error:`/`status:`),
|
|
|
1075
1067
|
`feature` and `body` (the default JSON:API document). The responder must
|
|
1076
1068
|
render or redirect so the action doesn't run.
|
|
1077
1069
|
|
|
1070
|
+
`requires_client_version` answers 426 to builds below their enforced
|
|
1071
|
+
minimum through the same responder chain; see [Answering 426](#answering-426).
|
|
1072
|
+
A global responder receives both kinds of denial and can tell them apart by
|
|
1073
|
+
`denial.error`.
|
|
1074
|
+
|
|
1078
1075
|
### Raising FeatureDisabled
|
|
1079
1076
|
|
|
1080
1077
|
Code deeper than a `before_action` can raise the same denial:
|
|
@@ -1517,7 +1514,10 @@ Neither is one whose version is missing or unparseable, nor one that sends
|
|
|
1517
1514
|
no platform: an unknown build never receives a `min_client` flag. Platforms
|
|
1518
1515
|
the declaration doesn't list are unaffected. Platforms come from
|
|
1519
1516
|
`config.client_platforms`, and precedence is SemVer's (`0.4.0-rc.1` is below
|
|
1520
|
-
`0.4.0`).
|
|
1517
|
+
`0.4.0`). That is stricter than the [client registry](#client-upgrades)'s
|
|
1518
|
+
minimum, where a prerelease of exactly the minimum release meets it: a
|
|
1519
|
+
`0.4.0-beta` build passes a client minimum of `0.4.0` but not
|
|
1520
|
+
`min_client: { android: "0.4.0" }`.
|
|
1521
1521
|
|
|
1522
1522
|
A kill switch can't declare `min_client:` (the registry refuses it): a
|
|
1523
1523
|
withheld entry means the client's code default, which for a kill switch is
|
|
@@ -1540,7 +1540,9 @@ date in UTC, so every host switches the wire off at the same moment. With
|
|
|
1540
1540
|
receiving it sooner. A client of unknown version keeps receiving it until
|
|
1541
1541
|
`until:`; `until_clients:` never extends it. A static wire can't reuse a
|
|
1542
1542
|
live wire name. Once `until:` has passed, `flags:stale` lists
|
|
1543
|
-
the `serve:` block as removable.
|
|
1543
|
+
the `serve:` block as removable. `standard_flags:manifest:check` fails CI
|
|
1544
|
+
when a client wire disappears without such a tombstone
|
|
1545
|
+
([Client contract](#client-contract)).
|
|
1544
1546
|
|
|
1545
1547
|
### Before sign-in
|
|
1546
1548
|
|
|
@@ -1574,18 +1576,471 @@ flags. Client attributes (headers or body) only shape what a client is told
|
|
|
1574
1576
|
version can at most withhold a flag or show a value meant for another build.
|
|
1575
1577
|
Never gate authorisation on a client-reported version.
|
|
1576
1578
|
|
|
1579
|
+
## Client upgrades
|
|
1580
|
+
|
|
1581
|
+
Tell old builds to upgrade, and refuse the ones that must. The policy lives
|
|
1582
|
+
in code, with ENV break-glass pins; nothing is stored.
|
|
1583
|
+
|
|
1584
|
+
### The client registry
|
|
1585
|
+
|
|
1586
|
+
```ruby
|
|
1587
|
+
# config/flags.rb
|
|
1588
|
+
StandardFlags.define do
|
|
1589
|
+
client :android_app, platform: :android, min_version: "0.4.0", since: "2026-12-01",
|
|
1590
|
+
recommended: "0.5.0", available: "0.5.0", grace: 7.days,
|
|
1591
|
+
store_url: "https://play.google.com/store/apps/details?id=com.example.app"
|
|
1592
|
+
client :ios_app, platform: :ios, min_version: "2.0.0", since: "2026-12-01", available: "1.9.0",
|
|
1593
|
+
store_url: "https://apps.apple.com/app/id000000000",
|
|
1594
|
+
store_lookup: StandardFlags::Stores::AppStore.new(bundle_id: "com.example.app", country: "us")
|
|
1595
|
+
end
|
|
1596
|
+
```
|
|
1597
|
+
|
|
1598
|
+
| Attribute | Meaning |
|
|
1599
|
+
|-----------|---------|
|
|
1600
|
+
| `platform:` | Required. One of `config.client_platforms`. |
|
|
1601
|
+
| `min_version:` | The oldest build allowed to keep working. Needs `since:`. |
|
|
1602
|
+
| `since:` | The date (`YYYY-MM-DD`, UTC) the minimum was raised; a Time or DateTime counts as its UTC date. Enforcement starts at `since + grace`. **When you raise `min_version:`, move `since:` to that day**, or the old date enforces the new minimum at once. |
|
|
1603
|
+
| `grace:` | Whole days before a raised minimum is enforced: `7.days` (the default), `14` or `0`. |
|
|
1604
|
+
| `recommended:` | Builds below it are nudged, never blocked. Must not be below `min_version:`. |
|
|
1605
|
+
| `available:` | The newest version known to be in the store (set it when review passes). The store ceiling, below. |
|
|
1606
|
+
| `store_lookup:` | This client's live source for `available` (see below). It only ever caps this client. |
|
|
1607
|
+
| `store_url:` | Where the client sends the user (an http(s) URL). |
|
|
1608
|
+
| `group:` | Lets a second app share a platform. Clients are unique per platform within a group; the status endpoint and the guard pick a group (none by default). |
|
|
1609
|
+
|
|
1610
|
+
The registry is checked when it loads: a platform outside
|
|
1611
|
+
`config.client_platforms`, a version or date that doesn't parse, a minimum
|
|
1612
|
+
without `since:` (or `since:` alone), `recommended:` below `min_version:`, a
|
|
1613
|
+
part-day `grace:`, a `store_url:` that isn't http(s), a `store_lookup:` that
|
|
1614
|
+
can't be called, two clients on one platform in one group, or a flag whose
|
|
1615
|
+
pin collides with a client's pin all raise `StandardFlags::DefinitionError`.
|
|
1616
|
+
|
|
1617
|
+
**Break-glass pins.** `STANDARD_FLAGS_CLIENT_<NAME>_MIN_VERSION`, `_SINCE`,
|
|
1618
|
+
`_RECOMMENDED` and `_AVAILABLE` beat the code and any store lookup, as a
|
|
1619
|
+
flag's pin beats its default (for `:android_app`,
|
|
1620
|
+
`STANDARD_FLAGS_CLIENT_ANDROID_APP_MIN_VERSION`). Lower a minimum that went
|
|
1621
|
+
out too high with `_MIN_VERSION` alone. To raise one, pin `_SINCE` with it:
|
|
1622
|
+
a raised `_MIN_VERSION` without `_SINCE` is ignored, so a break-glass raise
|
|
1623
|
+
always gets its own grace window. A pin lowers the minimum only when every
|
|
1624
|
+
version that meets the code's minimum also meets the pin, so a prerelease of
|
|
1625
|
+
the code's minimum (`0.4.0-rc.1` against `0.4.0`) is a raise: it stops
|
|
1626
|
+
`0.4.0-beta.1`, which `0.4.0` lets through. A value that doesn't parse is
|
|
1627
|
+
ignored too.
|
|
1628
|
+
Pins in force are listed in the diagnostics (`clients:`), as flags' pins
|
|
1629
|
+
are, and never warn; ignored pins are health check warnings, by name only.
|
|
1630
|
+
|
|
1631
|
+
### Grace and the store ceiling
|
|
1632
|
+
|
|
1633
|
+
A raised minimum is enforced from `since + grace`, compared with today's UTC
|
|
1634
|
+
date, so every host flips on the same day. Until then, builds below it are
|
|
1635
|
+
told `upgrade_recommended` with the date (`enforce_at`).
|
|
1636
|
+
|
|
1637
|
+
The enforced minimum is never above the newest version known to be in the
|
|
1638
|
+
store, so raising the minimum before a release passes review locks nobody
|
|
1639
|
+
out. `recommended` is capped the same way, since nudging toward a build
|
|
1640
|
+
nobody can install helps no one. The newest version is a pinned
|
|
1641
|
+
`_AVAILABLE` if there is one, else the client's `store_lookup:` answer if
|
|
1642
|
+
it has one, else `available:`.
|
|
1643
|
+
|
|
1644
|
+
A store lookup belongs to the one client that declares it. It is any object
|
|
1645
|
+
whose `call(client_app)` answers its last known version (or nil) at once:
|
|
1646
|
+
it is asked on request threads, so it must never wait on the network.
|
|
1647
|
+
`StandardFlags::Stores::AppStore.new(bundle_id:, country:)` asks Apple's
|
|
1648
|
+
public iTunes lookup API in the background: the first call answers nil (so
|
|
1649
|
+
`available:` applies) and starts a refresh on a thread, and later calls
|
|
1650
|
+
answer the last good version. It refreshes at most once an hour per process.
|
|
1651
|
+
After a failure, or when its runner can't start the refresh, it keeps the
|
|
1652
|
+
last good answer and waits 5 minutes, doubling with each further failure up
|
|
1653
|
+
to an hour. Each fetch has one overall 5-second deadline (connect, TLS,
|
|
1654
|
+
request and body), with each phase's own timeout a little shorter so a
|
|
1655
|
+
stalled connection is closed by net/http, and a 256 KiB body cap; the
|
|
1656
|
+
connection is closed on every path. `refresh!` fetches on the calling
|
|
1657
|
+
thread, for a warm-up at boot. Failures emit
|
|
1658
|
+
`store_lookup_failed.standard_flags` (`store`, `client`, `reason`) once the
|
|
1659
|
+
fetch has ended; nothing raises. Google Play has
|
|
1660
|
+
no public API for this (it needs a service account), so Android clients use
|
|
1661
|
+
`available:` alone: set it when a release reaches production. A store
|
|
1662
|
+
version that isn't SemVer (`2.1.0.4`) reads as unknown.
|
|
1663
|
+
|
|
1664
|
+
### The status endpoint
|
|
1665
|
+
|
|
1666
|
+
```ruby
|
|
1667
|
+
# config/routes.rb
|
|
1668
|
+
get "client/status", to: "client_status#client_status"
|
|
1669
|
+
|
|
1670
|
+
class ClientStatusController < ActionController::API # ActionController::Base works too
|
|
1671
|
+
include StandardFlags::ClientStatus::Controller
|
|
1672
|
+
standard_flags_client_status # group: :kiosk, max_age: 60
|
|
1673
|
+
end
|
|
1674
|
+
```
|
|
1675
|
+
|
|
1676
|
+
Route it outside authentication; it reveals nothing about the caller. It is
|
|
1677
|
+
a GET, so forgery protection never applies. It reads the client exactly as
|
|
1678
|
+
the [426 guard](#answering-426) and the flag guards do
|
|
1679
|
+
(`standard_flags_upgrade_client`): the client your `standard_flags_context`
|
|
1680
|
+
names, whole, when it names one (the app chose it, from a trusted device
|
|
1681
|
+
record, say), else the X-Client-* headers' client, whole. Fields from the
|
|
1682
|
+
two are never mixed. So a build the guard refuses is always told why here.
|
|
1683
|
+
Keep that context safe to call before sign-in (nil, the default, is). It
|
|
1684
|
+
answers 200 with:
|
|
1685
|
+
|
|
1686
|
+
```json
|
|
1687
|
+
{ "status": "upgrade_recommended", "platform": "android", "version": "0.3.9",
|
|
1688
|
+
"min_version": "0.4.0", "recommended": "0.5.0", "enforce_at": "2026-12-08",
|
|
1689
|
+
"store_url": "https://play.google.com/store/apps/details?id=com.example.app" }
|
|
1690
|
+
```
|
|
1691
|
+
|
|
1692
|
+
| `status` | When |
|
|
1693
|
+
|----------|------|
|
|
1694
|
+
| `unknown` | No platform, one the app doesn't recognise, or no usable version. An unknown build is never told to upgrade. |
|
|
1695
|
+
| `upgrade_required` | Below the enforced minimum, on or after `enforce_at`. |
|
|
1696
|
+
| `upgrade_recommended` | Below the minimum during its grace window (with `enforce_at`), or below `recommended`. |
|
|
1697
|
+
| `ok` | Anything else, including a recognised platform with no client declared. |
|
|
1698
|
+
|
|
1699
|
+
Every key is always present (null when absent). Versions are canonical
|
|
1700
|
+
SemVer (`0.4` is sent as `0.4.0`) and compare by SemVer precedence, with one
|
|
1701
|
+
exception: a prerelease of exactly the minimum or recommended version meets
|
|
1702
|
+
it, so a beta or TestFlight build of the required release (`1.5.0-beta.2`
|
|
1703
|
+
against `1.5.0`) isn't locked out. A prerelease of an older version
|
|
1704
|
+
(`1.4.9-rc.1`) is still below it. `min_version` and `recommended` are the
|
|
1705
|
+
values after the store ceiling. `enforce_at` is set whenever the version is
|
|
1706
|
+
below the minimum. The response carries `Cache-Control: max-age=60,
|
|
1707
|
+
private` and a Vary on the client headers. With `config.read_client_headers`
|
|
1708
|
+
off it can't see the headers. A client that receives a status it doesn't
|
|
1709
|
+
know should treat it as `unknown` and never block on it.
|
|
1710
|
+
`StandardFlags::ClientStatus.for(client)` gives the same answer in Ruby, for
|
|
1711
|
+
a bootstrap response or a device check-in.
|
|
1712
|
+
|
|
1713
|
+
### Answering 426
|
|
1714
|
+
|
|
1715
|
+
```ruby
|
|
1716
|
+
class Api::OrdersController < Api::BaseController
|
|
1717
|
+
requires_client_version # only:/except:, group:, with:
|
|
1718
|
+
end
|
|
1719
|
+
|
|
1720
|
+
class Api::StatusController < Api::OrdersController
|
|
1721
|
+
skip_client_version_check # only:/except:
|
|
1722
|
+
end
|
|
1723
|
+
```
|
|
1724
|
+
|
|
1725
|
+
A request whose client is `upgrade_required` gets **426**
|
|
1726
|
+
`client_upgrade_required` through the same responder chain as
|
|
1727
|
+
`requires_flag`: the guard's `with:`, then `config.controller_responder`,
|
|
1728
|
+
then a JSON:API body, sent whatever the request's Accept header says (the
|
|
1729
|
+
client needs `min_version` and `store_url` to act on it):
|
|
1730
|
+
|
|
1731
|
+
```json
|
|
1732
|
+
{"errors":[{"status":"426","code":"client_upgrade_required","meta":{"min_version":"0.4.0","store_url":"https://…"}}]}
|
|
1733
|
+
```
|
|
1734
|
+
|
|
1735
|
+
The responder receives a `StandardFlags::Controller::UpgradeDenial` (`key`
|
|
1736
|
+
is the client's name, `error` is `:client_upgrade_required`, `status` 426,
|
|
1737
|
+
`feature` nil, plus `platform`, `version`, `min_version` and `store_url`),
|
|
1738
|
+
so one responder can tell it from a feature denial by `error`. A build in
|
|
1739
|
+
its grace window, or below `recommended` only, passes. So does one whose
|
|
1740
|
+
platform or version is unknown, unless `config.require_client_version =
|
|
1741
|
+
true`. The guard reads the same client as the status endpoint and the flag
|
|
1742
|
+
guards.
|
|
1743
|
+
|
|
1744
|
+
There is one guard per controller hierarchy. Declaring it again, in the same
|
|
1745
|
+
class or in a subclass of a guarded class, raises
|
|
1746
|
+
`StandardFlags::ConfigurationError`, because the new declaration would
|
|
1747
|
+
silently replace the earlier one (its actions, group and responder). Pass
|
|
1748
|
+
`override: true` to replace it on purpose. To narrow an inherited guard, use
|
|
1749
|
+
`skip_client_version_check only:/except:` in the subclass. Client-facing denials stay 4xx (403 and 426):
|
|
1750
|
+
some edges replace an app's 5xx body with their own page. HTTP defines 426
|
|
1751
|
+
for protocol upgrades and expects an `Upgrade` header; here it means "upgrade
|
|
1752
|
+
the app", with no `Upgrade` header.
|
|
1753
|
+
|
|
1754
|
+
App code can raise `StandardFlags::ClientUpgradeRequired.new(status)` (a
|
|
1755
|
+
`ClientStatus` result, or keywords). The controller answers it like the
|
|
1756
|
+
guard, even when the app declares `rescue_from StandardError` after including
|
|
1757
|
+
`StandardFlags::Controller`; only an app's own `rescue_from
|
|
1758
|
+
StandardFlags::ClientUpgradeRequired` takes it over.
|
|
1759
|
+
|
|
1760
|
+
### Compatibility windows
|
|
1761
|
+
|
|
1762
|
+
A compat flag with `until_clients:` is a shim you mean to delete once every
|
|
1763
|
+
build that needs it is gone:
|
|
1764
|
+
|
|
1765
|
+
```ruby
|
|
1766
|
+
compat :legacy_form_auth, owner: "identity", until_clients: { android: "0.1.12", ios: "1.3.0" }
|
|
1767
|
+
```
|
|
1768
|
+
|
|
1769
|
+
With `config.track_compat = true` (off by default; it needs runtime rules and
|
|
1770
|
+
the `standard_flags_compat_stats` migration), each evaluation of such a flag
|
|
1771
|
+
counts a hit per platform (`unknown` for a platform the app doesn't
|
|
1772
|
+
recognise, `none` when the evaluation carried no client). The oldest client
|
|
1773
|
+
version seen is recorded only for platforms in `config.client_platforms`.
|
|
1774
|
+
Versions come from client headers, which anyone can send, so treat it as a
|
|
1775
|
+
hint, not proof; it starts over once a platform has gone unused for 14 days.
|
|
1776
|
+
|
|
1777
|
+
Counts are held in memory and written behind like `last_evaluated_at`:
|
|
1778
|
+
never during an evaluation, and at most once per
|
|
1779
|
+
`config.evaluation_tracking_interval` per process when a unit of work ends,
|
|
1780
|
+
failed writes included. A failed write is reported once per process, emits
|
|
1781
|
+
`compat_tracking_failed.standard_flags` once per interval, and keeps the
|
|
1782
|
+
counts for the next try. A write skipped inside a transaction is tried again
|
|
1783
|
+
at the next unit of work. Every write that succeeds also refreshes each
|
|
1784
|
+
window's tracking marker: when tracking began, and when a write last
|
|
1785
|
+
succeeded. A tracking process writes once per interval even without hits,
|
|
1786
|
+
so a quiet window still shows tracking is healthy.
|
|
1787
|
+
A forked child starts with no pending counts. Operator reads (MCP tools,
|
|
1788
|
+
diagnostics) don't count. Every evaluation counts, so a shim checked on
|
|
1789
|
+
every request (or in a `StandardFlags.snapshot`) never looks idle; evaluate
|
|
1790
|
+
it only on the legacy path.
|
|
1791
|
+
|
|
1792
|
+
`flags:stale` says a window "can be removed" only when tracking has run for
|
|
1793
|
+
at least 14 days, a write has succeeded in the last 2 days, no hit has
|
|
1794
|
+
landed in the last 14 days, and the window has passed on every listed
|
|
1795
|
+
platform. While writes are failing it says "tracking unhealthy since"
|
|
1796
|
+
the last successful write, since missing hits then prove nothing. A platform's window has passed when every
|
|
1797
|
+
client declared for it enforces a minimum at or above the listed version
|
|
1798
|
+
today (UTC), or when no build below it has used the flag (no hits from that
|
|
1799
|
+
platform, or its oldest version seen is at or above it). Until tracking is
|
|
1800
|
+
14 days old it says "not enough data" with the date tracking began. The
|
|
1801
|
+
diagnostics (`compat:`, with `tracking_since` and `last_flushed_at`) and the MCP `get_flag` tool
|
|
1802
|
+
show the window and the stored counts.
|
|
1803
|
+
## Client contract
|
|
1804
|
+
|
|
1805
|
+
The committed manifest is the contract between the server and the clients
|
|
1806
|
+
built against it. `standard_flags:manifest` writes it, `standard_flags:manifest:check`
|
|
1807
|
+
keeps server CI honest about it, and the Kotlin and TypeScript generators
|
|
1808
|
+
turn it into client types.
|
|
1809
|
+
|
|
1810
|
+
### The manifest (version 2)
|
|
1811
|
+
|
|
1812
|
+
`bin/rails standard_flags:manifest` writes `config.manifest_path` (default
|
|
1813
|
+
`config/flags.manifest.json`). Commit it.
|
|
1814
|
+
|
|
1815
|
+
```json
|
|
1816
|
+
{
|
|
1817
|
+
"version": 2,
|
|
1818
|
+
"audiences": { "mobile": { "public": false }, "pre_auth": { "public": true } },
|
|
1819
|
+
"flags": [
|
|
1820
|
+
{ "key": "ai_assistant", "kind": "kill_switch", "type": "boolean", "values": [true, false],
|
|
1821
|
+
"default": true, "audiences": { "mobile": ["chat", "chatEnabled"] }, "min_client": {} },
|
|
1822
|
+
{ "key": "new_checkout", "kind": "flag", "type": "boolean", "values": [true, false],
|
|
1823
|
+
"default": { "*": false, "staging": true }, "audiences": { "mobile": ["newCheckout"] },
|
|
1824
|
+
"min_client": { "android": "0.4.0" }, "permanent": false, "remove_by": "2027-03-01", "final": true }
|
|
1825
|
+
],
|
|
1826
|
+
"tombstones": [
|
|
1827
|
+
{ "key": "chat_v1", "removed": "2026-12-01", "serve": { "mobile": { "chat_v1": false } },
|
|
1828
|
+
"until": "2027-03-01", "until_clients": { "android": "0.6.0" } }
|
|
1829
|
+
],
|
|
1830
|
+
"clients": {
|
|
1831
|
+
"android_app": { "platform": "android", "group": null, "min_version": "0.4.0", "since": "2026-12-01",
|
|
1832
|
+
"grace": 7, "recommended": "0.5.0", "available": "0.5.0",
|
|
1833
|
+
"store_url": "https://example.com/app", "store_lookup": false }
|
|
1834
|
+
}
|
|
1835
|
+
}
|
|
1836
|
+
```
|
|
1837
|
+
|
|
1838
|
+
- `audiences` lists every audience a flag or tombstone serves, plus any
|
|
1839
|
+
`config.audiences` declares, and whether each is served before sign-in.
|
|
1840
|
+
- A flag's `audiences` gives every wire name per audience, aliases included,
|
|
1841
|
+
in declared order. `type` is the wire's JSON type: `boolean`, or `string`
|
|
1842
|
+
for modes and experiments. `default` is a value, or per environment with
|
|
1843
|
+
`"*"` for the rest.
|
|
1844
|
+
- `min_client` is always present (`{}` without one). `permanent` is on
|
|
1845
|
+
entries of kind `flag` and `mode`; `remove_by` and `final` only when
|
|
1846
|
+
declared.
|
|
1847
|
+
- A tombstone with deprecated wires carries `serve`, `until` and
|
|
1848
|
+
`until_clients` (`{}` when not given).
|
|
1849
|
+
- `clients` is the [client registry](#the-client-registry) as declared in
|
|
1850
|
+
code, keyed by name. Every attribute is present (null when not declared),
|
|
1851
|
+
`grace` is in whole days, and `store_lookup` only says whether one is
|
|
1852
|
+
configured. ENV break-glass pins and store lookup answers are runtime
|
|
1853
|
+
state and never appear. Client changes only make the manifest stale.
|
|
1854
|
+
- `owner:` and `description:` are left out on purpose. Client repositories
|
|
1855
|
+
copy this file, so it holds only what a client can already learn from the
|
|
1856
|
+
wire, plus lifecycle dates. Operators read owners through `flags:list`,
|
|
1857
|
+
`flags:show` and the MCP tools.
|
|
1858
|
+
|
|
1859
|
+
The JSON Schema is `conformance/schema/manifest.schema.json`. The reader
|
|
1860
|
+
refuses anything the schema rejects, plus what a schema can't say: a
|
|
1861
|
+
`version` that isn't the integer 2, dates that aren't calendar dates, and a
|
|
1862
|
+
wire listed twice for one audience. Version 1 files (0.3.0 and earlier) are
|
|
1863
|
+
still read, so the check can compare an old committed file and report what
|
|
1864
|
+
upgrading changes. Regenerate after upgrading the gem.
|
|
1865
|
+
|
|
1866
|
+
The file is generated text: keep formatters and line-ending conversion away
|
|
1867
|
+
from it. Put `config/flags.manifest.json -text` in `.gitattributes` and the
|
|
1868
|
+
path in `.prettierignore`. The check tolerates CRLF line endings and
|
|
1869
|
+
trailing newlines; other reformatting makes it stale.
|
|
1870
|
+
|
|
1871
|
+
### Checking it in server CI
|
|
1872
|
+
|
|
1873
|
+
`bin/rails standard_flags:manifest:check` compares the committed manifest
|
|
1874
|
+
with the registry. It exits with:
|
|
1875
|
+
|
|
1876
|
+
| Exit | Meaning | Fix |
|
|
1877
|
+
|------|---------|-----|
|
|
1878
|
+
| 0 | The committed file matches what `standard_flags:manifest` writes (CRLF line endings and trailing newlines aside). | — |
|
|
1879
|
+
| 1 | Stale (or missing): the registry changed. The output lists what changed per flag and tombstone. | Run `standard_flags:manifest` and commit. |
|
|
1880
|
+
| 2 | The client contract is broken. Either a wire the baseline told an audience is gone without a tombstone serving it, or a wire changed type, or a public audience serving wires became private (clients before sign-in lose them all). | Keep the wire (or the audience public), or tombstone the wire with `serve:` and `until:`, or use a new wire name. |
|
|
1881
|
+
| 2 | The baseline given as `BASE=` is missing or unreadable, or a manifest can't be read. | Fix the CI step; see below. |
|
|
1882
|
+
|
|
1883
|
+
A wire counts as served by a tombstone only while its `until:` is today or
|
|
1884
|
+
later (UTC). A deprecated wire whose `until:` has passed in the baseline may
|
|
1885
|
+
be deleted: its window is over. Moving a wire to another flag of the same
|
|
1886
|
+
type is fine. Moving it to another audience removes it from the first.
|
|
1887
|
+
Two things print a warning without failing:
|
|
1888
|
+
- moving a deprecated wire's `until:` earlier, since shipped clients were
|
|
1889
|
+
promised the later date;
|
|
1890
|
+
- adding a wire whose generated Kotlin name is an existing wire's in the
|
|
1891
|
+
same audience (`new_checkout` beside a shipped `newCheckout`). See
|
|
1892
|
+
[Kotlin](#kotlin) for how constants stay put.
|
|
1893
|
+
|
|
1894
|
+
The baseline is `BASE=`, the base branch's manifest, so a PR that
|
|
1895
|
+
regenerates the file in the same commit still can't drop a wire. Without
|
|
1896
|
+
`BASE=` the committed file stands in, and the check prints a warning that a
|
|
1897
|
+
regenerated file hides removals. A `BASE` file that is missing, a directory
|
|
1898
|
+
or unreadable fails with exit 2, and a stale committed file is still
|
|
1899
|
+
reported. `BASE_OPTIONAL=1` forgives only a file that doesn't exist: set it
|
|
1900
|
+
for first adoption, when the base branch has no manifest yet. The contract
|
|
1901
|
+
checks are then skipped, with a warning.
|
|
1902
|
+
|
|
1903
|
+
```yaml
|
|
1904
|
+
# .github/workflows/ci.yml, in a job with the app's Ruby and database set up.
|
|
1905
|
+
- uses: actions/checkout@v4
|
|
1906
|
+
- name: Flag manifest
|
|
1907
|
+
env:
|
|
1908
|
+
BASE_REF: ${{ github.base_ref || 'main' }}
|
|
1909
|
+
run: |
|
|
1910
|
+
MANIFEST="$(bin/rails runner 'print StandardFlags.config.manifest_path')"
|
|
1911
|
+
test -n "$MANIFEST" || { echo "could not read config.manifest_path" >&2; exit 1; }
|
|
1912
|
+
git fetch --no-tags --depth=1 origin "$BASE_REF"
|
|
1913
|
+
mkdir -p tmp
|
|
1914
|
+
if git cat-file -e "FETCH_HEAD:$MANIFEST" 2>/dev/null; then
|
|
1915
|
+
git show "FETCH_HEAD:$MANIFEST" > tmp/base.manifest.json
|
|
1916
|
+
bin/rails standard_flags:manifest:check BASE=tmp/base.manifest.json
|
|
1917
|
+
else
|
|
1918
|
+
# First adoption: the base branch has no manifest yet.
|
|
1919
|
+
bin/rails standard_flags:manifest:check BASE=tmp/base.manifest.json BASE_OPTIONAL=1
|
|
1920
|
+
fi
|
|
1921
|
+
```
|
|
1922
|
+
|
|
1923
|
+
The path comes from `config.manifest_path`, so the step can't look in the
|
|
1924
|
+
wrong place. A failed fetch fails the step (the default shell exits on
|
|
1925
|
+
error), and `git show` runs only when the file exists at the base, so no
|
|
1926
|
+
error turns into a skipped check. In the one PR that moves the manifest,
|
|
1927
|
+
pass `BASE=` the old path's contents yourself.
|
|
1928
|
+
|
|
1929
|
+
`StandardFlags::Tooling::ManifestCheck` is the same check as a class, for
|
|
1930
|
+
apps with their own CI scripts.
|
|
1931
|
+
|
|
1932
|
+
### Kotlin
|
|
1933
|
+
|
|
1934
|
+
`bin/rails standard_flags:kotlin` writes plain Kotlin (no dependencies) to
|
|
1935
|
+
`config.kotlin_path` (default `config/StandardFlags.kt`) in
|
|
1936
|
+
`config.kotlin_package` (nil writes no package line):
|
|
1937
|
+
|
|
1938
|
+
```kotlin
|
|
1939
|
+
// Generated by `bin/rails standard_flags:kotlin`. Do not edit by hand.
|
|
1940
|
+
// Manifest version 2, sha256 9c1f….
|
|
1941
|
+
|
|
1942
|
+
package com.example.flags
|
|
1943
|
+
|
|
1944
|
+
object StandardFlagsManifest {
|
|
1945
|
+
const val VERSION: Int = 2
|
|
1946
|
+
const val SHA256: String = "9c1f…"
|
|
1947
|
+
}
|
|
1948
|
+
|
|
1949
|
+
enum class FeatureType { BOOLEAN, STRING }
|
|
1950
|
+
|
|
1951
|
+
enum class MobileFeature(val wire: String, val type: FeatureType) {
|
|
1952
|
+
CHAT("chat", FeatureType.BOOLEAN),
|
|
1953
|
+
CHAT_ENABLED("chatEnabled", FeatureType.BOOLEAN),
|
|
1954
|
+
@Deprecated("No longer declared; served as a static value through 2027-03-01")
|
|
1955
|
+
CHAT_V1("chat_v1", FeatureType.BOOLEAN),
|
|
1956
|
+
/** Values: [HomeHeroValue]. */
|
|
1957
|
+
HOME_HERO("homeHero", FeatureType.STRING),
|
|
1958
|
+
;
|
|
1959
|
+
|
|
1960
|
+
companion object {
|
|
1961
|
+
fun fromWire(wire: String): MobileFeature? = values().firstOrNull { it.wire == wire }
|
|
1962
|
+
}
|
|
1963
|
+
}
|
|
1964
|
+
|
|
1965
|
+
enum class HomeHeroValue(val value: String) {
|
|
1966
|
+
CONTROL("control"),
|
|
1967
|
+
SAVINGS("savings"),
|
|
1968
|
+
;
|
|
1969
|
+
|
|
1970
|
+
companion object {
|
|
1971
|
+
fun fromValue(value: String?): HomeHeroValue? = values().firstOrNull { it.value == value }
|
|
1972
|
+
}
|
|
1973
|
+
}
|
|
1974
|
+
```
|
|
1975
|
+
|
|
1976
|
+
- There is one `<Audience>Feature` enum per manifest audience, with one
|
|
1977
|
+
entry per wire, ordered by wire name. Deprecated static wires are included
|
|
1978
|
+
and marked `@Deprecated`.
|
|
1979
|
+
- There is one `<Key>Value` enum per mode or experiment exposed to any
|
|
1980
|
+
audience, in declared order.
|
|
1981
|
+
- Entry names are SCREAMING_SNAKE_CASE (`homeHero` becomes `HOME_HERO`).
|
|
1982
|
+
Values that can't start an identifier get `V_` (`2fa` becomes `V_2FA`).
|
|
1983
|
+
- Names are stable across regenerations. The task reads the file it wrote
|
|
1984
|
+
last time (`config.kotlin_path`), and every wire and value keeps the name
|
|
1985
|
+
it had there; only new ones are named. A `new_checkout` alias added after
|
|
1986
|
+
a shipped `newCheckout` gets a suffixed name and never takes
|
|
1987
|
+
`NEW_CHECKOUT`. Delete the file to name everything afresh. Commit it, or
|
|
1988
|
+
restore it in CI before regenerating, so names survive a clean checkout.
|
|
1989
|
+
- A new name never fails on a clash:
|
|
1990
|
+
- When two wires of one audience map to the same name (`new_checkout` and
|
|
1991
|
+
`newCheckout`, the alias pair a rename leaves), the spelling that already
|
|
1992
|
+
is the name in some case (`new_checkout`, else `NEW_CHECKOUT`) keeps it,
|
|
1993
|
+
unless an existing wire holds it. Every other spelling gets `_` plus 8
|
|
1994
|
+
hex digits of the SHA-256 of its exact spelling
|
|
1995
|
+
(`NEW_CHECKOUT_1F0A2B3C`), and its KDoc says why.
|
|
1996
|
+
- When two values of one flag map to the same name, later ones in
|
|
1997
|
+
declared order get the first free `_2`, `_3`, and so on.
|
|
1998
|
+
- The source is ASCII: every other character is escaped.
|
|
1999
|
+
- `SHA256` is `Tooling::Manifest#digest`, the SHA-256 of the canonical
|
|
2000
|
+
manifest: exactly what `standard_flags:manifest` writes, with LF line
|
|
2001
|
+
endings. It equals the committed file's hash when the file is current and
|
|
2002
|
+
untouched by line-ending conversion. A client build can compare it with
|
|
2003
|
+
the server's manifest to tell whether its copy is current.
|
|
2004
|
+
|
|
2005
|
+
### TypeScript
|
|
2006
|
+
|
|
2007
|
+
`bin/rails standard_flags:typescript` keeps the `<Audience>Features`
|
|
2008
|
+
interfaces, `FlagKey` and `FlagValues` as before. It adds, from the
|
|
2009
|
+
manifest:
|
|
2010
|
+
|
|
2011
|
+
- one `<Audience>Wire` union per audience (deprecated static wires
|
|
2012
|
+
included), and `WiresByAudience`;
|
|
2013
|
+
- the OFREP shapes: `OfrepEvaluationRequest` (with `appVersion` or
|
|
2014
|
+
`app_version`), `OfrepEvaluationSuccess<W>`,
|
|
2015
|
+
`OfrepEvaluationFailure<W>`, `OfrepBulkResponse<W>`, `OfrepFlagNotFound`,
|
|
2016
|
+
`OfrepInvalidContext`, `OfrepReason`, `OfrepErrorCode`, and
|
|
2017
|
+
`OfrepBulkResponseByAudience`.
|
|
2018
|
+
|
|
2019
|
+
### In client CI
|
|
2020
|
+
|
|
2021
|
+
A client copies (or fetches) the server's manifest. The client library's
|
|
2022
|
+
contract check compares the wires its generated enums were built from with
|
|
2023
|
+
the server's current manifest. It fails on a wire the audience no longer
|
|
2024
|
+
exposes or serves, or on a changed type, exactly as server CI does.
|
|
2025
|
+
`conformance/wire/manifest_check.json` pins those semantics: committed and
|
|
2026
|
+
current manifests and today's date in; ok, stale, removed wires and type
|
|
2027
|
+
changes out. The Kotlin library's Gradle task runs it. The server and client
|
|
2028
|
+
checks therefore agree on what breaks a shipped build.
|
|
2029
|
+
|
|
1577
2030
|
## Rake tasks
|
|
1578
2031
|
|
|
1579
2032
|
| Task | What it does |
|
|
1580
2033
|
|------|--------------|
|
|
1581
2034
|
| `bin/rails flags:list` | Every flag with its value, reason, deciding env var and remove_by (`permanent` for permanent flags). |
|
|
1582
|
-
| `bin/rails flags:stale` | Flags and modes past `remove_by`, with the `final:` value to keep. Permanent ones never appear. Tombstones whose `serve:` block is past `until:`. With runtime rules on, also stale rules and memberships due for purge ([Stale rules](#stale-rules)). |
|
|
2035
|
+
| `bin/rails flags:stale` | Flags and modes past `remove_by`, with the `final:` value to keep. Permanent ones never appear. Tombstones whose `serve:` block is past `until:`. With runtime rules on, also stale rules and memberships due for purge ([Stale rules](#stale-rules)), and with `config.track_compat`, compat windows ready to remove ([Compatibility windows](#compatibility-windows)). |
|
|
1583
2036
|
| `bin/rails flags:show KEY=` | One flag's declaration, value here, ENV pin and stored rule; `KEY=cohort:<key>` for a cohort. |
|
|
1584
2037
|
| `bin/rails flags:set` / `ramp` / `start` / `pause` / `stop` / `members:add` / `members:remove` / `purge` | Break-glass changes through the audited operations ([Rake tasks for break-glass changes](#rake-tasks-for-break-glass-changes)). |
|
|
1585
2038
|
| `bin/rails flags:restore AT=` | Rules and memberships as they were at `AT`, from the audit log; a dry run unless `APPLY=1` ([Restore](#restore)). |
|
|
1586
2039
|
| `bin/rails flags:refs` | Scans `config.refs_paths` (default `app lib config`) for `on?(:k`, `off?(:k`, `mode(:k`, `variant(:k`, `evaluate(:k`, `requires_flag :k` and string keys. Exits non-zero for undeclared or tombstoned keys; warns for declared flags nothing reads. Run it in CI. |
|
|
1587
|
-
| `bin/rails standard_flags:manifest` | Writes `config/flags.manifest.json
|
|
1588
|
-
| `bin/rails standard_flags:
|
|
2040
|
+
| `bin/rails standard_flags:manifest` | Writes `config/flags.manifest.json` (version 2): audiences, and per flag its wire names per audience, kind, type, values, defaults, `min_client` and lifecycle; tombstones with their deprecated wires. Deterministic. Commit it ([The manifest](#the-manifest-version-2)). |
|
|
2041
|
+
| `bin/rails standard_flags:manifest:check BASE= [BASE_OPTIONAL=1]` | Exits 1 when the committed manifest is stale or missing. Exits 2 when a wire the baseline told a client is gone without a tombstone, a wire changed type, a public audience went private, `BASE` is unavailable, or a manifest can't be read ([Checking it in server CI](#checking-it-in-server-ci)). |
|
|
2042
|
+
| `bin/rails standard_flags:kotlin` | Writes `config.kotlin_path`: a `<Audience>Feature` enum per audience, a `<Key>Value` enum per mode and experiment, `FeatureType`, and the manifest's version and digest ([Kotlin](#kotlin)). |
|
|
2043
|
+
| `bin/rails standard_flags:typescript` | Writes a `.d.ts` with a `Features` interface per audience (`WebFeatures`, `MobileFeatures`, …) keyed by wire name, a `<Audience>Wire` union per audience, `FlagKey` and `FlagValues` (every key and its stored values), the OFREP request and response types, and the shapes of the MCP tools' results that the [admin page](#admin-page) uses. |
|
|
1589
2044
|
|
|
1590
2045
|
## Observability
|
|
1591
2046
|
|
|
@@ -1650,8 +2105,10 @@ legacy names in use, flags past `remove_by`, `STANDARD_FLAGS_*` variables that
|
|
|
1650
2105
|
match no flag, a runtime store that can't be reached (flags keep serving
|
|
1651
2106
|
through a database blip, so this isn't a failure), a stale runtime snapshot,
|
|
1652
2107
|
prepared statements being off (see [Privacy](#privacy)), a missing
|
|
1653
|
-
`standard_flags_state` row,
|
|
1654
|
-
undeclared or tombstoned keys
|
|
2108
|
+
`standard_flags_state` row, runtime rules for
|
|
2109
|
+
undeclared or tombstoned keys, client registry pins that were ignored
|
|
2110
|
+
(pins in force are listed, not warned about), and compat stats that can't
|
|
2111
|
+
be read (or `config.track_compat` without runtime rules). standard_health has no
|
|
1655
2112
|
warning status, so warnings ride on the row (`warnings:`) and the check stays
|
|
1656
2113
|
`:ok`; pass `warn_as: :fail` to let them degrade the tier. It is non-critical
|
|
1657
2114
|
by default. There is no dependency on standard_health unless you reference
|
|
@@ -1665,7 +2122,11 @@ rules on it adds each flag's `rule_status` and a `runtime:` section (store,
|
|
|
1665
2122
|
readiness, any unreachable error class, store warnings, revision, snapshot
|
|
1666
2123
|
age, staleness and each rule's status), and
|
|
1667
2124
|
`flags:list` gains a `rule` column and a header line with the revision and
|
|
1668
|
-
age.
|
|
2125
|
+
age. With a client registry it adds `clients:` (each client's values in
|
|
2126
|
+
force, `enforce_on`, the pins that applied and those ignored; a store lookup
|
|
2127
|
+
is never asked here), and with compat windows `compat:` (each window, when
|
|
2128
|
+
its tracking began and, when tracking, its stored counts). It contains variable names only, never
|
|
2129
|
+
raw environment values.
|
|
1669
2130
|
|
|
1670
2131
|
## OpenFeature
|
|
1671
2132
|
|
|
@@ -1870,8 +2331,16 @@ client in, OFREP entries and ETag out (aliases, `min_client:` with known,
|
|
|
1870
2331
|
unknown and older versions, deprecated wires, errored flags, ETag equality
|
|
1871
2332
|
across users and clients). `wire/client_state.json` pins what a client does
|
|
1872
2333
|
with a payload: on, off and not loaded, a missing value meaning the code
|
|
1873
|
-
default, ceilings, and payloads refused by size or shape.
|
|
1874
|
-
|
|
2334
|
+
default, ceilings, and payloads refused by size or shape.
|
|
2335
|
+
`wire/client_status.json` pins `GET /client/status`: the recognised
|
|
2336
|
+
platforms, the client registry, header values and today's date in, the
|
|
2337
|
+
status payload out (unknown builds, grace, enforcement, prereleases, the
|
|
2338
|
+
store ceiling, groups). `upgrade/client_status_server.json` (`"scope":
|
|
2339
|
+
"server"`) adds ENV pins and store lookups. None of them needs Ruby to run.
|
|
2340
|
+
`wire/manifest_check.json` pins the [client contract](#client-contract)
|
|
2341
|
+
check: committed and current manifests in; stale, removed wires and type
|
|
2342
|
+
changes out. Its manifests validate against
|
|
2343
|
+
`conformance/schema/manifest.schema.json`. None of them needs Ruby to run.
|
|
1875
2344
|
|
|
1876
2345
|
## Bucketing
|
|
1877
2346
|
|
|
@@ -1904,8 +2373,11 @@ Phase 3 is client delivery. On `main` now: client context from request
|
|
|
1904
2373
|
headers, portable version ranges, build conditions, `FeatureDisabled` and
|
|
1905
2374
|
gated MCP tools, an OFREP endpoint mixin and an embeddable payload with
|
|
1906
2375
|
ETags, minimum client versions and deprecated wires, and the portable
|
|
1907
|
-
conformance suite
|
|
1908
|
-
|
|
2376
|
+
conformance suite, a client registry with `GET /client/status`, a 426 guard,
|
|
2377
|
+
grace windows and a store ceiling, measured compatibility windows, and the
|
|
2378
|
+
client contract (manifest version 2, `standard_flags:manifest:check`, Kotlin
|
|
2379
|
+
and TypeScript generators). Next: the Kotlin client library, with the
|
|
2380
|
+
manifest check in client CI. Phase 4 adds
|
|
1909
2381
|
experiment exposure tracking and staged rollout plans with automatic
|
|
1910
2382
|
halts.
|
|
1911
2383
|
|