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
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: dc7ea9e788c8a7314852d436d13bf2a0c8b999d6768e55631ec1d3ded0aeae0b
|
|
4
|
+
data.tar.gz: 14a5de9ed814444a9bfe08dbbf44dc25d304f3c8a2ec3621016847440a6b8623
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 62ed9d45b8dfa73ad60d84275df9fdabd9cf5c5d4fefb3edb55adc9ec755ad9138659673f998e40502d52b9d78ac7122381e9115cce89bbed1592c30674101ba
|
|
7
|
+
data.tar.gz: 87ab264a0a713962fbcc1dbdc261b766a7a2bf60f8637531e749ab61dcc2e4f40a719182825d8754c015ba7ddbc86cc0b988ece86178524b2e16c06fb932efaa
|
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,194 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.4.0] - 2026-11-25
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- **Client registry.** `client :name, platform:, min_version:, since:,
|
|
15
|
+
recommended:, available:, store_url:, store_lookup:, grace:, group:` in
|
|
16
|
+
config/flags.rb (`StandardFlags::ClientApp`). `since:` is required with
|
|
17
|
+
`min_version:` (a Time or DateTime counts as its UTC date); a raised
|
|
18
|
+
minimum is enforced from `since + grace` (whole days, default 7, UTC
|
|
19
|
+
dates), so raising `min_version:` means moving `since:`. Clients are
|
|
20
|
+
unique per platform within a `group:`. Validated at boot, including flag
|
|
21
|
+
pins that would collide with a client's pins. `Registry#clients` and
|
|
22
|
+
`Registry#client_for(platform, group:)`.
|
|
23
|
+
- ENV break-glass pins `STANDARD_FLAGS_CLIENT_<NAME>_MIN_VERSION`, `_SINCE`,
|
|
24
|
+
`_RECOMMENDED` and `_AVAILABLE` beat the code and any store lookup. A
|
|
25
|
+
raised `_MIN_VERSION` without `_SINCE` is ignored, so a break-glass raise
|
|
26
|
+
gets its own grace window; a lowered one needs no `_SINCE`. A pin lowers
|
|
27
|
+
the minimum only when every version meeting the code's minimum also meets
|
|
28
|
+
it, so a prerelease of the code's minimum is a raise. Pins in force
|
|
29
|
+
are listed in `Diagnostics.report[:clients]` (never health warnings);
|
|
30
|
+
ignored pins are health warnings, by name only. Client pins are no longer
|
|
31
|
+
listed as unknown `STANDARD_FLAGS_*` variables.
|
|
32
|
+
- **Store ceiling.** The enforced minimum, and the recommended version, are
|
|
33
|
+
never above the newest version known to be in the store: a pinned
|
|
34
|
+
`_AVAILABLE`, else the client's `store_lookup:` answer, else `available:`.
|
|
35
|
+
A lookup belongs to one client and only caps that client; it answers its
|
|
36
|
+
last known version at once and never waits on the network.
|
|
37
|
+
`StandardFlags::Stores::AppStore.new(bundle_id:, country:)` asks Apple's
|
|
38
|
+
public iTunes lookup API in the background (a thread; one refresh at a
|
|
39
|
+
time per process, a forked child starts its own): at most hourly, backing
|
|
40
|
+
off from 5 minutes up to an hour after failures (a runner that can't
|
|
41
|
+
start counts as one), with one overall 5-second deadline per fetch,
|
|
42
|
+
shorter phase timeouts, the connection closed on every path, and a 256 KiB
|
|
43
|
+
body cap; `refresh!` fetches synchronously. Failures emit
|
|
44
|
+
`store_lookup_failed.standard_flags` (`store`, `client`, `reason`) after
|
|
45
|
+
the fetch has ended. Google Play has no public API, so Android
|
|
46
|
+
uses `available:` alone.
|
|
47
|
+
- **`StandardFlags::ClientStatus.for(client, group:)`** and the
|
|
48
|
+
`StandardFlags::ClientStatus::Controller` mixin
|
|
49
|
+
(`standard_flags_client_status group:, max_age:`; action `client_status`),
|
|
50
|
+
for `GET /client/status`, routed before sign-in. It answers `{status,
|
|
51
|
+
platform, version, min_version, recommended, enforce_at, store_url}` with
|
|
52
|
+
`status` one of `ok`, `upgrade_recommended`, `upgrade_required` or
|
|
53
|
+
`unknown` (an unknown platform or version is never told to upgrade),
|
|
54
|
+
`Cache-Control: max-age=60, private` and a Vary on the client headers.
|
|
55
|
+
A prerelease of exactly the minimum or recommended version meets it.
|
|
56
|
+
Works on API and Base controllers.
|
|
57
|
+
- **426 guard.** `requires_client_version only:, except:, group:, with:, override:` on
|
|
58
|
+
`StandardFlags::Controller` answers 426 `client_upgrade_required` through
|
|
59
|
+
`with:`, `config.controller_responder` or a JSON:API body with `meta:
|
|
60
|
+
{min_version, store_url}` (always JSON, whatever the Accept header),
|
|
61
|
+
handing responders a `StandardFlags::Controller::UpgradeDenial`.
|
|
62
|
+
One guard per controller hierarchy: a second declaration (in the class or
|
|
63
|
+
under an inherited one) raises `ConfigurationError` unless it passes
|
|
64
|
+
`override: true`; `skip_client_version_check only:, except:` narrows an
|
|
65
|
+
inherited guard. Builds in their grace window pass; unknown versions pass
|
|
66
|
+
unless `config.require_client_version = true`. The guard, the status
|
|
67
|
+
endpoint and the flag guards read the same client
|
|
68
|
+
(`standard_flags_upgrade_client`): the client the request context names,
|
|
69
|
+
whole, else the X-Client-* headers' client, whole. `StandardFlags::ClientUpgradeRequired` can be raised by app code
|
|
70
|
+
and is answered the same way, even past an app's later `rescue_from
|
|
71
|
+
StandardError`.
|
|
72
|
+
- **Compatibility windows.** `compat :k, until_clients: { platform =>
|
|
73
|
+
"version" }`. With `config.track_compat = true` (off by default; needs
|
|
74
|
+
runtime rules), each evaluation counts a hit per platform, and the oldest
|
|
75
|
+
client version for allowlisted platforms (a hint from untrusted headers;
|
|
76
|
+
it starts over after 14 idle days). Counts are written behind to the new
|
|
77
|
+
`standard_flags_compat_stats` table: never during an evaluation, at most
|
|
78
|
+
once per `evaluation_tracking_interval` per process, failed writes
|
|
79
|
+
included (one `compat_tracking_failed` event per interval, reported once
|
|
80
|
+
per process). Every successful write refreshes each window's tracking
|
|
81
|
+
marker (first seen, last flushed), at least once per interval. Operator
|
|
82
|
+
reads don't count; a forked child drops inherited counts. `flags:stale`
|
|
83
|
+
says a window can be removed only after 14 days of tracking, a successful
|
|
84
|
+
write within 2 days, 14 days without hits, and once it has passed on every
|
|
85
|
+
listed platform; it says "not enough data" or "tracking unhealthy since"
|
|
86
|
+
otherwise.
|
|
87
|
+
`Diagnostics.report[:compat]` and the MCP `get_flag` tool (for compat flags
|
|
88
|
+
with a window) show the counts, `tracking_since` and `last_flushed_at`. Stores gain
|
|
89
|
+
`record_compat` and `compat_stats` (nil from stores that don't keep them).
|
|
90
|
+
- The migrations generator writes a second, additive migration,
|
|
91
|
+
`create_standard_flags_compat_stats`. Rerunning it adds only what is
|
|
92
|
+
missing: a migration is skipped when its file exists or its table already
|
|
93
|
+
exists in the database (`--no-check-tables` skips that check). The runtime
|
|
94
|
+
store's readiness doesn't depend on the new table.
|
|
95
|
+
- `conformance/wire/client_status.json` (scope `wire`, suite
|
|
96
|
+
`client_status`): recognised platforms, registry, header values and today
|
|
97
|
+
in, the status payload out, for client libraries' upgrade-state parsing.
|
|
98
|
+
`conformance/upgrade/client_status_server.json` (scope `server`) adds ENV
|
|
99
|
+
pins and store lookups.
|
|
100
|
+
- **Manifest version 2.** `standard_flags:manifest` writes `"version": 2`:
|
|
101
|
+
a top-level `audiences` map (`{ name => { "public" => bool } }`), each
|
|
102
|
+
flag's `audiences` as `{ audience => [every wire name] }`, `min_client`
|
|
103
|
+
(always present), `permanent` (kinds `flag` and `mode`), and `remove_by`
|
|
104
|
+
and `final` when declared. Tombstones with deprecated wires carry `serve`,
|
|
105
|
+
`until` and `until_clients`. A top-level `clients` object holds the client
|
|
106
|
+
registry as declared in code (platform, group, min_version, since, grace in
|
|
107
|
+
days, recommended, available, store_url, and whether a `store_lookup` is
|
|
108
|
+
configured); ENV pins and lookup answers never appear. `owner:` and `description:` are deliberately
|
|
109
|
+
left out. The schema ships as `conformance/schema/manifest.schema.json`.
|
|
110
|
+
`StandardFlags::Tooling::Manifest.read` reads version 1 and 2 files. It
|
|
111
|
+
refuses what the schema rejects, plus a non-integer version, non-calendar
|
|
112
|
+
dates (a flag's `remove_by` included) and a wire listed twice for one
|
|
113
|
+
audience. A version 2 tombstone's `serve` needs `until_clients` as well as
|
|
114
|
+
`until`. `#digest` is the SHA-256
|
|
115
|
+
of the canonical render. The JSON layout is pinned by explicit generator
|
|
116
|
+
options.
|
|
117
|
+
- **`standard_flags:manifest:check BASE= [BASE_OPTIONAL=1]`** for server
|
|
118
|
+
CI (`StandardFlags::Tooling::ManifestCheck`).
|
|
119
|
+
- Exit 1 when the committed manifest is stale or missing (CRLF line
|
|
120
|
+
endings and trailing newlines are tolerated), with the changes listed
|
|
121
|
+
per flag and tombstone.
|
|
122
|
+
- Exit 2 when the contract breaks: a wire the baseline told an audience is
|
|
123
|
+
gone and no tombstone still serves it (`until:` today or later, UTC); a
|
|
124
|
+
wire changed type; or a public audience serving wires became private.
|
|
125
|
+
- Exit 2 too when `BASE` is missing or unreadable (a stale committed file
|
|
126
|
+
is still reported), or when a manifest can't be read. `BASE_OPTIONAL=1`
|
|
127
|
+
forgives only a `BASE` file that doesn't exist.
|
|
128
|
+
- Without `BASE` the committed file is the baseline, with a warning.
|
|
129
|
+
- A deprecated wire past its `until:` may be dropped. An earlier `until:`
|
|
130
|
+
is a warning, and so is a new wire whose Kotlin name is an existing
|
|
131
|
+
wire's.
|
|
132
|
+
- The README has a CI snippet that fetches the base ref explicitly.
|
|
133
|
+
- **`standard_flags:kotlin`** (`config.kotlin_path`, default
|
|
134
|
+
`config/StandardFlags.kt`; `config.kotlin_package`, default none) writes
|
|
135
|
+
plain Kotlin with no dependencies:
|
|
136
|
+
- `StandardFlagsManifest` (`VERSION` and `SHA256` of the manifest);
|
|
137
|
+
- `FeatureType`;
|
|
138
|
+
- per audience, `enum class <Audience>Feature(val wire: String, val type:
|
|
139
|
+
FeatureType)` in wire-name order with `fromWire`, with deprecated static
|
|
140
|
+
wires marked `@Deprecated`;
|
|
141
|
+
- per mode or experiment exposed to any audience, `enum class
|
|
142
|
+
<Key>Value(val value: String)` with `fromValue`.
|
|
143
|
+
|
|
144
|
+
The generated source is ASCII.
|
|
145
|
+
|
|
146
|
+
Names are stable across regenerations: the task keeps every entry name the
|
|
147
|
+
existing file has (`Kotlin.new(previous:)`) and names only new wires and
|
|
148
|
+
values. A new name never fails on a clash:
|
|
149
|
+
- when wires of one audience map to the same name, the spelling that
|
|
150
|
+
already is the name (snake_case, else SCREAMING_SNAKE_CASE) keeps it,
|
|
151
|
+
unless an existing wire holds it, and other spellings get a suffix from
|
|
152
|
+
the SHA-256 of their exact spelling;
|
|
153
|
+
- when values of one flag do, later ones get the first free `_2`, `_3`, …
|
|
154
|
+
|
|
155
|
+
`Tooling::Kotlin::NameClash` is left for clashing type names and
|
|
156
|
+
non-identifiers. An invalid package name raises `ConfigurationError`.
|
|
157
|
+
- **TypeScript:** `standard_flags:typescript` adds a `<Audience>Wire` union
|
|
158
|
+
per audience (deprecated static wires included), `WiresByAudience`, and
|
|
159
|
+
the OFREP types: `OfrepEvaluationRequest` (`appVersion` or `app_version`), `OfrepEvaluationSuccess`,
|
|
160
|
+
`OfrepEvaluationFailure`, `OfrepEvaluation`, `OfrepBulkResponse`,
|
|
161
|
+
`OfrepFlagNotFound`, `OfrepInvalidContext`, `OfrepReason`,
|
|
162
|
+
`OfrepErrorCode` and `OfrepBulkResponseByAudience`. The existing
|
|
163
|
+
interfaces and types are unchanged.
|
|
164
|
+
- **Conformance:**
|
|
165
|
+
- `conformance/wire/manifest_check.json` (suite `manifest_check`, scope
|
|
166
|
+
`wire`, 30 cases). Each case takes a committed and a current manifest
|
|
167
|
+
plus today's date. It expects `invalid` (naming the manifest to refuse),
|
|
168
|
+
or ok/stale/breaking with removed wires, type changes and audiences made
|
|
169
|
+
private. A client's contract check shares these semantics.
|
|
170
|
+
- `conformance/wire/client_state.json` gains strict-JSON cases: unquoted
|
|
171
|
+
literals, single quotes, unquoted keys, malformed numbers, trailing
|
|
172
|
+
commas, raw control characters, invalid escapes, and nesting beyond the
|
|
173
|
+
new `limits.max_nesting` (100), and lone or reversed surrogate escapes. It
|
|
174
|
+
also gains a version rule: a `metadata.version` is kept only when it is
|
|
175
|
+
1 to 256 characters of printable ASCII without a space or `"`, so an
|
|
176
|
+
oversized version can't wedge If-None-Match requests.
|
|
177
|
+
|
|
178
|
+
### Changed
|
|
179
|
+
|
|
180
|
+
- The committed manifest's format is version 2. Regenerate it after
|
|
181
|
+
upgrading (`bin/rails standard_flags:manifest`). A tool that read version
|
|
182
|
+
1's `audiences` (`{ audience => first wire }`) or `wires` now reads
|
|
183
|
+
`audiences` (`{ audience => [wires] }`). `standard_flags:manifest:check`
|
|
184
|
+
reads a version 1 file, reports it stale, and still checks its wires.
|
|
185
|
+
|
|
186
|
+
### Removed
|
|
187
|
+
|
|
188
|
+
- **Breaking: `legacy_parser:` and `legacy_true:`.** The exact legacy
|
|
189
|
+
reader (`legacy_parser: :exact`, which read a legacy `env:` name the way
|
|
190
|
+
`ENV["X"] == "on"` did) is gone. Declaring either option now raises
|
|
191
|
+
`ArgumentError` naming the replacement: set the canonical
|
|
192
|
+
`STANDARD_FLAGS_<KEY>` variable, which the strict parser reads. Legacy
|
|
193
|
+
`env:` names and `inverted:` are still supported, and are always read
|
|
194
|
+
strictly, so `true`/`ON` now turn such a flag on and a set-but-blank value
|
|
195
|
+
is unset instead of off. The `legacy_exact.json` conformance fixture and
|
|
196
|
+
the schema's `legacy_parser`/`legacy_true` properties are removed.
|
|
197
|
+
|
|
10
198
|
## [0.3.0] - 2026-11-25
|
|
11
199
|
|
|
12
200
|
### Added
|