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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +158 -0
- data/README.md +566 -35
- data/conformance/README.md +166 -0
- data/conformance/bucket_vectors.json +46 -0
- data/conformance/guards_and_errors.json +35 -0
- data/conformance/legacy_env.json +38 -0
- data/conformance/legacy_exact.json +90 -0
- data/conformance/operations/write_path.json +723 -0
- data/conformance/permanent_flags.json +38 -0
- data/conformance/resolution.json +68 -0
- data/conformance/runtime/client.json +1431 -0
- data/conformance/runtime/rules.json +1305 -0
- data/conformance/schema/fixture.schema.json +1340 -0
- data/conformance/versions/legacy_ranges.json +183 -0
- data/conformance/versions/version_ranges.json +503 -0
- data/conformance/wire/client_state.json +1905 -0
- data/conformance/wire/delivery.json +1541 -0
- data/lib/standard_flags/audience.rb +49 -0
- data/lib/standard_flags/client.rb +157 -0
- data/lib/standard_flags/config.rb +21 -0
- data/lib/standard_flags/context.rb +70 -17
- data/lib/standard_flags/controller.rb +92 -10
- data/lib/standard_flags/definition.rb +71 -8
- data/lib/standard_flags/delivery.rb +195 -0
- data/lib/standard_flags/errors.rb +33 -0
- data/lib/standard_flags/job.rb +12 -1
- data/lib/standard_flags/mcp/flags.rb +3 -3
- data/lib/standard_flags/mcp/gating.rb +151 -0
- data/lib/standard_flags/mcp.rb +64 -5
- data/lib/standard_flags/notifiers/logger.rb +4 -0
- data/lib/standard_flags/ofrep/controller.rb +211 -0
- data/lib/standard_flags/ofrep.rb +115 -0
- data/lib/standard_flags/open_feature/provider.rb +1 -1
- data/lib/standard_flags/operations/rules.rb +17 -4
- data/lib/standard_flags/operations/validation.rb +25 -4
- data/lib/standard_flags/operations.rb +0 -2
- data/lib/standard_flags/payload.rb +8 -3
- data/lib/standard_flags/registry.rb +157 -12
- data/lib/standard_flags/runtime/cache.rb +1 -0
- data/lib/standard_flags/runtime/resolver.rb +26 -17
- data/lib/standard_flags/runtime/values.rb +8 -1
- data/lib/standard_flags/runtime.rb +42 -1
- data/lib/standard_flags/semantic_version.rb +141 -0
- data/lib/standard_flags/subscribers.rb +3 -0
- data/lib/standard_flags/testing.rb +4 -2
- data/lib/standard_flags/tooling.rb +25 -3
- data/lib/standard_flags/version.rb +1 -1
- data/lib/standard_flags/version_range.rb +309 -0
- data/lib/standard_flags.rb +38 -4
- metadata +24 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: '08b69b20300f0808f08a4039cb115e00086d4330b0545a606937a06b8aa7b48f'
|
|
4
|
+
data.tar.gz: a2d5bc16126c737aeda9b5dd1e39d56f2abd9be360a2cd331b0d5ff2c58d9357
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4dbbc29fe5f72f4ff21e70853ecb8a40512fc7526b6420f11f8be4eb5f1d2d6642541dfc9ccaa7c7a371698238010fe15252dccbcb88ec4409264415b7340071
|
|
7
|
+
data.tar.gz: a21474b41ec44d4a074b49d7bd38b45feaba73c2ab206d2d6b1fe7d973060a055039ec6336df9439a2c467720e0ddce41605f8736aa5b5ceaa3c77f825b34758
|
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,164 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.3.0] - 2026-11-25
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- **Client context.** `StandardFlags::Client` (platform, version, build), a
|
|
15
|
+
frozen Hash subclass, so `context.client` keeps 0.2.2's Hash reads, with
|
|
16
|
+
typed readers. `Client.from_headers(headers)` reads `X-Client-Platform`,
|
|
17
|
+
`X-Client-Version` and `X-Client-Build` (`config.client_headers`); the
|
|
18
|
+
platform is downcased and must be in `config.client_platforms` (default
|
|
19
|
+
android, ios, web, desktop), the version must parse and the build must be
|
|
20
|
+
1 to 18 digits. A bad version or build is dropped; a bad platform becomes
|
|
21
|
+
`"unknown"`, which fails every platform-scoped rule condition. Each emits
|
|
22
|
+
`client_invalid.standard_flags`; nothing raises (invalid UTF-8 included)
|
|
23
|
+
or reports. No headers gives an empty client, which rules read as 0.2.2
|
|
24
|
+
read an empty client.
|
|
25
|
+
- `StandardFlags::Controller` reads the headers once per request
|
|
26
|
+
(`standard_flags_client`; empty when there is no request) and evaluates
|
|
27
|
+
guards and payloads for `standard_flags_context` plus that client, unless
|
|
28
|
+
the context already names one. `standard_flags_request_context` and
|
|
29
|
+
`standard_flags_reader` give actions the same context.
|
|
30
|
+
`config.read_client_headers = false` opts out.
|
|
31
|
+
- `Context.wrap(value, client:)` and `Context#with_client`, so `for:` can
|
|
32
|
+
carry a client. Jobs' `requires_flag` takes `client:` (a value or a lambda
|
|
33
|
+
run in the job), and the MCP tools take `client:`
|
|
34
|
+
(`StandardFlags::MCP.tools(client:)`).
|
|
35
|
+
- **Versions and portable ranges.** `StandardFlags::Version` (SemVer 2.0 with
|
|
36
|
+
`MAJOR.MINOR` and `MAJOR` shorthands, SemVer precedence, build metadata
|
|
37
|
+
ignored) and `StandardFlags::VersionRange`: space-separated comparators
|
|
38
|
+
(`>=`, `>`, `<=`, `<`, `=`), all of which must hold, with `||`
|
|
39
|
+
alternatives, e.g. `>=1.4.0 <2.0.0 || =0.9.5-beta.1`. Kotlin and
|
|
40
|
+
TypeScript clients can implement the same syntax.
|
|
41
|
+
- **Build conditions.** Runtime rules take `conditions.builds`
|
|
42
|
+
(`{ platform => range }` over integers, e.g. `>=120 <200`, as
|
|
43
|
+
`StandardFlags::BuildRange`), checked with version ranges; both must hold.
|
|
44
|
+
`SetConditions` and `Testing.rule` take `builds:`.
|
|
45
|
+
- **`StandardFlags::FeatureDisabled`**, a raisable `feature_disabled` with
|
|
46
|
+
the flag's `key`, wire name (`feature`) and `status` (403), and
|
|
47
|
+
`StandardFlags.require!(key, for:)`, which raises it.
|
|
48
|
+
`StandardFlags::Controller` renders it exactly like a `requires_flag`
|
|
49
|
+
denial, through `config.controller_responder` when set, even when the app
|
|
50
|
+
declares `rescue_from StandardError` after the include; a 404 one answers
|
|
51
|
+
like `error: :not_found`.
|
|
52
|
+
- **Gated MCP tools.** `StandardFlags::MCP::Gated` gives an app's own tools
|
|
53
|
+
`requires_flag :key` (with optional `for:` and `client:`), in every
|
|
54
|
+
subclass. A call while a flag is off returns
|
|
55
|
+
`{"error":{"code":"feature_disabled",...}}` without running the tool.
|
|
56
|
+
`StandardFlags::MCP.visible(tools, actor:, context:, client:)` leaves such
|
|
57
|
+
tools out of `tools/list`, and `StandardFlags::MCP.call(tool, arguments,
|
|
58
|
+
actor:, context:, client:)` calls with the same evaluation. The gate is
|
|
59
|
+
evaluated once per call, however deep the subclasses. A `FeatureDisabled`
|
|
60
|
+
raised inside any tool becomes that error. The gem's own tools are not
|
|
61
|
+
gated.
|
|
62
|
+
- Conformance: `runtime/client.json` (neutral ranges, prerelease ordering,
|
|
63
|
+
shorthand versions, build ranges, no-platform and unknown-platform
|
|
64
|
+
clients; RubyGems cases marked `"scope": "server"`),
|
|
65
|
+
`versions/version_ranges.json` (versions and builds, for non-Ruby
|
|
66
|
+
clients; also run through the server's read path, with the five cases
|
|
67
|
+
where the server's RubyGems fallback differs marked `server_matched`) and
|
|
68
|
+
the server-only `versions/legacy_ranges.json`. Every existing
|
|
69
|
+
runtime case with a version range also runs with the range in canonical
|
|
70
|
+
neutral form.
|
|
71
|
+
- **Client delivery.** `StandardFlags::Delivery.build(audience, context)`
|
|
72
|
+
returns OFREP evaluation entries (`key` = wire name, `value`, `variant`,
|
|
73
|
+
`reason`; OFREP's `errorCode`/`errorDetails` for a flag whose evaluation
|
|
74
|
+
failed) for every wire the audience is told about, plus tombstones'
|
|
75
|
+
static wires, and an ETag: the SHA-256 of the audience and the canonical
|
|
76
|
+
JSON of the entries, never the config revision. No flag keys, rule IDs,
|
|
77
|
+
env var names, unit keys or unexposed flags.
|
|
78
|
+
- **OFREP endpoint mixin.** `StandardFlags::OFREP::Controller`
|
|
79
|
+
(`ActionController::API`, or `::Base` with an explicit
|
|
80
|
+
`csrf: :skip | :protect`; leaving it out raises
|
|
81
|
+
`StandardFlags::ConfigurationError`) with `standard_flags_ofrep audience:`
|
|
82
|
+
serves `ofrep_evaluate_flags` (bulk, with ETag, 304 on If-None-Match,
|
|
83
|
+
`Cache-Control: no-cache, private` and a Vary on Authorization and the
|
|
84
|
+
client headers) and `ofrep_evaluate_flag` (one wire, with a strong ETag;
|
|
85
|
+
404 FLAG_NOT_FOUND for anything the audience isn't told). The app draws
|
|
86
|
+
the routes and authenticates. Units come from `standard_flags_context`,
|
|
87
|
+
never the body's `targetingKey`; the body only adds client attributes,
|
|
88
|
+
headers win, and with `read_client_headers` off neither counts. Before
|
|
89
|
+
Rails parses anything, the mixin answers a non-JSON Content-Type 415 and
|
|
90
|
+
an oversized (64 KiB, bounded read), non-UTF-8 or malformed body 400
|
|
91
|
+
INVALID_CONTEXT, outside the rescue chain. Validated against the OFREP
|
|
92
|
+
OpenAPI document 0.4.0.
|
|
93
|
+
- **Embeds.** `StandardFlags.payload(audience, for:, client:, format: :ofrep)`
|
|
94
|
+
and `standard_flags_payload(audience, format: :ofrep)` return the bulk
|
|
95
|
+
body (`{ "flags", "metadata" => { "version" => etag } }`) for bootstrap
|
|
96
|
+
responses, device check-ins and MCP whoami. The flat format stays the
|
|
97
|
+
default.
|
|
98
|
+
- **`expose:` aliases.** An audience may list several wire names for one
|
|
99
|
+
flag (`expose: { mobile: %i[chat_enabled insights_enabled] }`), each
|
|
100
|
+
serving the same evaluation. `Definition#wire_names`, `Registry#wires`.
|
|
101
|
+
The manifest keeps `audiences` (first wire, as in version 1) and adds
|
|
102
|
+
`wires` for flags with aliases; the TypeScript interfaces list every alias.
|
|
103
|
+
- **`min_client:`** (`{ platform => "version" }`) leaves a flag out of
|
|
104
|
+
OFREP payloads for clients on a listed platform below the minimum, of
|
|
105
|
+
unknown version, or with no (or an unrecognised) platform. Refused on a
|
|
106
|
+
kill switch, which must reach every client.
|
|
107
|
+
- **Deprecated wires.** `tombstone ..., serve: { audience => { wire =>
|
|
108
|
+
value } }, until: "YYYY-MM-DD", until_clients: { platform => "version" }`
|
|
109
|
+
keeps a removed flag's client wires answering a static value (reason
|
|
110
|
+
STATIC) through `until:` (required; a UTC date), and only for clients
|
|
111
|
+
below `until_clients:`. `flags:stale` lists a `serve:` block past
|
|
112
|
+
`until:` as removable. The manifest doesn't list tombstones' static wires
|
|
113
|
+
or `min_client:` yet: the version 2 manifest (next release) adds both.
|
|
114
|
+
- **`config.audiences`**: the audiences an app serves (an Array, or a Hash
|
|
115
|
+
with `public:` and `unit:`). When set, undeclared `expose:`/`serve:`
|
|
116
|
+
audiences fail boot. A `public: true` audience is the only kind an
|
|
117
|
+
`anonymous: true` OFREP controller serves, evaluated with no actors
|
|
118
|
+
(`StandardFlags::AnonymousContext`; runtime rules skip segments for it),
|
|
119
|
+
the audience's `unit:` keyed by the body's `targetingKey` (use random,
|
|
120
|
+
unguessable install IDs: pre-auth answers are public). A public flag whose
|
|
121
|
+
rule has members or cohorts logs `public_targeting.standard_flags` when
|
|
122
|
+
rules load and shows in the diagnostics.
|
|
123
|
+
- `Client.from_context(fields)` checks OpenFeature context fields like
|
|
124
|
+
headers; the OpenFeature provider and the OFREP body share
|
|
125
|
+
`Client::CONTEXT_FIELDS`.
|
|
126
|
+
|
|
127
|
+
### Changed
|
|
128
|
+
|
|
129
|
+
- **The conformance suite moved to a top-level `conformance/` folder and
|
|
130
|
+
ships in the gem**, with a JSON Schema (`conformance/schema/fixture.schema.json`)
|
|
131
|
+
every fixture validates against and a README. Each file is tagged `suite`
|
|
132
|
+
and `scope` (`server` or `wire`). New wire suites: `wire/delivery.json`
|
|
133
|
+
(context in, OFREP entries and ETag out) and `wire/client_state.json`
|
|
134
|
+
(payloads in, client reads out), which Kotlin and TypeScript clients can
|
|
135
|
+
run without Ruby.
|
|
136
|
+
|
|
137
|
+
- Client conditions in runtime rules compare with `StandardFlags::Version`
|
|
138
|
+
and `VersionRange`. Ranges stored by 0.2.x that only RubyGems can read
|
|
139
|
+
evaluate exactly as `Gem::Requirement` did: translated where the neutral
|
|
140
|
+
syntax can hold them (`~> 1.4` reads as `>=1.4.0 <2.0.0-0`, so
|
|
141
|
+
`2.0.0-beta.1` still misses it), and evaluated by RubyGems otherwise
|
|
142
|
+
(`>= 1.4.0.1`, and any prerelease operand such as `= 1.4.0.beta`, which
|
|
143
|
+
RubyGems orders differently). A string valid in both syntaxes
|
|
144
|
+
(`>= 1.4.0`, `>= 1.0.0-alpha`) is read as neutral, so SemVer client
|
|
145
|
+
versions compare by SemVer. A client version outside SemVer (`1.4.0.1`,
|
|
146
|
+
`1.4.0.beta`, a `Gem::Version`, a Float) is still read by RubyGems against
|
|
147
|
+
any range RubyGems can read. Ranges only the neutral syntax can read
|
|
148
|
+
compare SemVer only.
|
|
149
|
+
- Deliberate: build metadata in a client version passed in a context's
|
|
150
|
+
client Hash is ignored, as SemVer says, so `version: "1.4.0+381"` now
|
|
151
|
+
meets `~> 1.4` and `>= 1.4`; 0.2.2 refused it. The header path accepts it
|
|
152
|
+
too.
|
|
153
|
+
- `SetConditions` stores version ranges in the neutral syntax where it can:
|
|
154
|
+
a neutral range as given, a RubyGems one translated (`">= 1.4, < 2"` is
|
|
155
|
+
stored as `">=1.4.0 <2.0.0"`), and one the neutral syntax can't hold as
|
|
156
|
+
given.
|
|
157
|
+
- `Context.wrap(value, client: {})` leaves the context's client as it is,
|
|
158
|
+
as `client: nil` does.
|
|
159
|
+
- `requires_flag` denials' `feature` is always a String.
|
|
160
|
+
- README: the header, results, roadmap and health-check notes describe
|
|
161
|
+
0.2.2 rather than 0.1.0.
|
|
162
|
+
|
|
163
|
+
### Removed
|
|
164
|
+
|
|
165
|
+
- `StandardFlags::Operations::SCOPES`, an unused constant. The scopes are
|
|
166
|
+
the strings `config.authorize` receives.
|
|
167
|
+
|
|
10
168
|
## [0.2.2] - 2026-11-23
|
|
11
169
|
|
|
12
170
|
### Changed
|