- packages/openfeature-railyard/src/targeting.mjs: one dependency-free
evaluator (sync SHA-1, rollout hash = parseInt(sha1("<flag>.<id>")[0:15])
/ 0xfffffffffffffff, inside when <= rollout/100; ordered rules, all
conditions of a rule must match, first match wins with its own value).
Property operators follow the reference matcher of posthog-node (MIT):
exact/is_not (lists, true/false by truthiness), icontains, regex, gt/gte/
lt/lte (numeric, else text), is_set/is_not_set. Segments are named sets of
property conditions per environment (Flagsmith segment shape, BSD-3);
cohorts are product analytics cohort ids. Byte copies with .d.mts types in
apps/console/lib/flags and apps/product-analytics/src/flags (drift test).
- Console: rules and segments live in Railyard's store for both backends
(migration 0009: railyard.flag_targeting, railyard.flag_segments, bounded
checks, cascade, RLS, no anon), so the table fallback and the Flagsmith
backend have the same rule features. setFlag validates rules and segment
references; a used segment cannot be removed; branches copy rules and
segments. The read endpoint takes ?id, ?props (JSON, 2 KB) and ?cohorts,
answers each flag for that person and ships {on, value, rules} plus the
segments used, so SDKs evaluate locally; without a person a targeted flag
reads off (old clients stay safe). Flags screen: rules per flag (everyone,
a property, a segment; cohorts only with RAILYARD_REPLAY_LIVE) with a
share, and segments. POST /api/flags/segments.
- Product analytics /flags: evaluates targeted flags with the person's
stored properties (request person_properties override) and cohort
membership (through person overrides).
- OpenFeature providers and the client: evaluation context targetingKey +
attributes (+ cohorts) resolve per person; cached starts keep rules.
- Contract fixture: flags items carry targeting (additive, version 2).
Tests
- openfeature 16/16: SHA-1 vs node crypto, rollout shares within bounds
over 10 000 ids and monotonic growth, operators, rules, validation, read
answer, client and both providers vs the evaluator, cached start, drift.
- console 142/142 incl. both backends with the same 20 rule sets, segments,
isolation, read-endpoint context, 0009 migration on a scratch PG, and
10 000 ids x 20 rule sets: provider local == read endpoint (0 mismatches).
- product analytics test/qy 10/10 incl. 10 000 ids x 20 rule sets: provider
local == /flags from stored people and cohorts (0 mismatches), and the
unmodified posthog-node local evaluation agreeing on all 18 non-cohort
sets for 10 000 ids (0 mismatches, 0 undecided); a3 experiments unchanged.
- contract 6/6; console and PA tsc clean.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Railyard MCP server's flags.list now lists the org's flags per app and
environment (key, on or off, value, description) from the new console route
GET /api/v1/flags?app= for an org's ry_ token (lib/flags/http.ts
tokenListFlags; read only, at most 100 environments). A token only ever reads
its own org: the MCP test shows org B naming org A's app lists nothing and
never sees org A's flag. Annotations stay read-only (the linter test), and
the README row says what it does.
Tests: mcp 9/9 (incl. copy lint), console 128/128, tsc clean.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A Worker's response is not edge-cached from Cache-Control alone. The client
read now uses the Workers Cache API (caches.default) for URL-keyed reads:
a hit is answered without a database read, and the stored answer expires on
its 15 s max-age, so a flip still reaches every app within 60 s. Header-keyed
reads are never cached. Absent in `next dev`, where every read goes through.
Tests: bridge 25/25 (new: a URL-keyed read served from the cache, header-keyed
reads not cached), console 109/109 with the bundle build, contracts 6/6, SDK
7/7, tsc clean.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RYP-E2 and SP-E6, dispatch 4.2 PY2.1 (Railyard side):
- lib/flags: flag environments per app environment (a Scribase environment
or branch), each with a public client key that reads that one environment.
Two backends, one surface: the unmodified Flagsmith server (one Flagsmith
organisation per Railyard org, a project per app, an environment per env;
FLAGS_API_URL + FLAGS_ADMIN_TOKEN) and, as the fallback the dispatch names
when the box 2 gate keeps Flagsmith down, the console's own tables
(migration 0005). An environment keeps the backend it was made on.
- A branch environment starts with its parent's flags (copy_from), then
changes alone.
- GET /api/v1/flags/client?key=: CORS-open, cached 15 s when keyed by URL;
the first read by an app is the slot's proof (first_flag_read).
- Bridge route flags (contract: id_format, three cases, flags_item_keys);
BRIDGE_SLOTS.flags landed.
- The Flags screen (nav item) flips with one click and adds a flag by key;
POST /api/flags writes only the signed-in org's environments.
- packages/openfeature-railyard: a zero-dependency polling client (30 s,
offline start from storage, back-off) and OpenFeature client and server
providers, with Expo and Next.js examples.
Tests: flags core 11/11 (both backends, a fake of the Flagsmith API, tenant
isolation, branch copies, a 502 that leaves nothing half made), bridge 19/19,
contract 3/3, migration 6/6 (0005 twice on a scratch cluster), console 85/85
with the bundle build, tsc clean, SDK 7/7 (a flip reaches the app within 60 s
in the worst cache timing on a fake clock; copy lint on docs and the screen).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>