Repository navigation
feat: Add the override marker to the model, evaluator, and reason - #450
Merged
Merged
Conversation
kinyoklion
force-pushed
the
rlamb/overrides-ruby-model-evaluator
branch
from
September 25, 2026 22:51
0f89736 to
4810ac9
Compare
kinyoklion
force-pushed
the
rlamb/overrides-ruby-filedata
branch
from
September 28, 2026 20:36
eb26dd7 to
72d5776
Compare
kinyoklion
force-pushed
the
rlamb/overrides-ruby-model-evaluator
branch
3 times, most recently
from
October 3, 2026 00:46
8072ee4 to
ed8fccf
Compare
Member
Author
|
bugbot review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit ed8fccf. Configure here.
kinyoklion
force-pushed
the
rlamb/overrides-ruby-model-evaluator
branch
2 times, most recently
from
October 8, 2026 16:54
bb04f10 to
6ad2419
Compare
kinyoklion
force-pushed
the
rlamb/overrides-ruby-model-evaluator
branch
from
October 13, 2026 22:12
6ad2419 to
7579ddb
Compare
kinyoklion
marked this pull request as ready for review
November 2, 2026 23:13
keelerm84
approved these changes
Nov 3, 2026
kinyoklion
force-pushed
the
rlamb/overrides-ruby-model-evaluator
branch
from
November 3, 2026 23:58
7579ddb to
fae4a5c
Compare
kinyoklion
force-pushed
the
rlamb/overrides-ruby-model-evaluator
branch
from
November 4, 2026 19:20
fae4a5c to
16d5b70
Compare
kinyoklion
force-pushed
the
rlamb/overrides-ruby-filedata
branch
from
November 4, 2026 19:48
809c4e7 to
a43c443
Compare
kinyoklion
force-pushed
the
rlamb/overrides-ruby-model-evaluator
branch
from
November 4, 2026 19:48
16d5b70 to
156dc66
Compare
Base automatically changed from
rlamb/overrides-ruby-filedata
to
feat/overrides
November 4, 2026 20:46
Flag overrides, as defined by the OVERRIDE specification, need three pieces below the store: a marker on the flag and segment model that says a definition came from the override store, evaluator marking that follows every definition an evaluation reads, and an indicator on the evaluation reason that reports the marking to callers. The model classes carry the marker as an attribute that is never serialized. `as_override` returns a marked shallow copy and leaves the original unchanged. Only the SDK components that manage override entries set it. The evaluator marks an evaluation as override-affected when the evaluated flag, a prerequisite flag at any depth, or a segment read during clause matching carries the marker. A segment counts when it is read, so a segment that does not match, or that is read through a negated clause, still marks the evaluation. The marking propagates upward only: a prerequisite's own record reflects the definitions its own subtree read, and a plain prerequisite inside a marked evaluation is not marked. An error result is marked when a marked definition was read before the failure, including when the failure was raised while a prerequisite was being evaluated. An evaluation that reads no marked definition keeps the shared precomputed detail instances. `EvaluationReason#override_affected` carries the indicator. It is written to JSON as `overrideAffected` only when true, so the wire format of ordinary evaluations is unchanged. `with_override_affected` follows the `with_big_segments_status` precedent and returns the same instance when nothing changes. Flag overrides are currently experimental and subject to change.
kinyoklion
force-pushed
the
rlamb/overrides-ruby-model-evaluator
branch
from
November 4, 2026 20:47
156dc66 to
d677d6c
Compare
Ruby 3.1 through 3.3 report file modification times in whole seconds on Windows, so a truncation 20 ms after another one does not look like a new write. The reloader specs that need a rewrite to look new now stamp the file's modification time themselves. The listen gem polls on Windows CI and compares the lstat of a symbolic link, so it cannot see a link replaced within the second of its creation. The watcher spec that replaces a link waits for the next second first on a platform with whole-second file times.
kinyoklion
added a commit
that referenced
this pull request
Nov 6, 2026
<!-- TERMAG_PR_BODY_BEGIN --> ## Summary This PR is stacked on #450 because it uses the override marker, the evaluator marking, and the reason indicator that PR adds. This change adds the override layer that the OVERRIDE specification describes: a runtime-mutable collection of flag and segment definitions that takes precedence over LaunchDarkly data at the store read boundary, populated by an override source through a sink. With no override source configured the SDK behaves exactly as before. The file-based source, the events changes, and the contract test service follow in later PRs. `LaunchDarkly::Interfaces::Overrides::OverrideSource` and `OverrideSink` define how a source supplies complete snapshots to the SDK. The sink accepts data model objects or hashes in the flag and segment data model. The SDK marks the entries itself. `Impl::Overrides::Layer` holds marked entries in an immutable hash that is swapped on update, so the layer holds exactly one snapshot at any instant and reads are lock-free. `Impl::Overrides::Overlay` sits at the store read boundary: a read for a key returns the override entry when one exists and the LaunchDarkly entry otherwise, an enumeration is the union with the override entry winning, and initialization status is the base store's alone. `Impl::Overrides::Sink` applies snapshots and notifies flag change listeners of every flag whose merged-view evaluation may have changed, including flags that depend on an overridden prerequisite or segment. It computes dependency edges over both the old and the new merged view, as the Go reference does. `DataSystem::ConfigBuilder#overrides` accepts one override source builder, the same `build(sdk_key, config)` protocol as the data source builders. The FDv2 data system builds the source at construction, so an invalid configuration raises from `LDClient.new` like other invalid component configuration. It starts the source before its run loop, so the initial load is in effect before the constructor returns. An exception from the source's `start` does not prevent the client from starting: the SDK logs it, stops the source, removes any snapshot the source supplied, and the client runs without overrides (the SDK's own file source does not raise from `start`; a custom source could). It serves reads through the overlay. When the client closes, the sink stops accepting snapshots before the source is stopped, and an exception from `stop` is logged. An offline client builds no source and logs a warning that the configured source is not started. The client consults the override store before the not-initialized short-circuit. An overridden flag is served before LaunchDarkly data arrives, read from the override store itself, and a flag that is not overridden still returns the client-not-ready default, even when a store without an init marker holds LaunchDarkly data for it. `all_flags_state` reads through the overlay. Before initialization, when the store is not initialized and the override store holds flags, it returns a state of those flags alone, read from the override store, with a once-per-client warning; with no override flags the state is invalid, as it is without a source. Without a source this state is empty, because the SDK reports no flags before the store is initialized, so the override flags only add to what it reports; overrides never remove a flag from the state. A failure of the base store to list its flags propagates through the overlay, and `all_flags_state` logs it as without a source. Without a source the state is then invalid and empty; with override flags it holds those flags and stays invalid, so the overrides only add to it. A client-side SDK bootstrapped from the state uses its flags whatever `$valid` says (js-client-sdk 3.x and the 4.x browser SDK only log a warning), so the overridden values still reach it. A wrong-type migration result keeps the marking of the evaluation it replaces. When the evaluator raises for a flag that came from the override store, `variation_detail` and `all_flags_state` report the `EXCEPTION` error reason with `override_affected` set, from the flag's own marker. This also fixes a pre-existing crash: `all_flags_state` raised `NoMethodError` when an evaluation raised, because the failed flag has no evaluation state; it now reports that flag with no prerequisites. The marker is read only from the SDK's model objects: a custom store can return a flag as a plain hash, as the `FeatureStore` interface documents, and such a flag never came from the override store, so its failed evaluation still returns the unmarked `EXCEPTION` result instead of raising. A value-only override expands, through the file loading code from #449, into a flag that is on and serves its single value by fallthrough, which reports the FALLTHROUGH reason kind as the specification describes. The OVERRIDE specification's test vectors (`spec/fixtures/override-vectors/vectors.json`) run as a spec through the full client stack, checking value, variation index, and reason under the vectors' comparison rules. The vectors' per-evaluation summary marker is asserted once the event processor carries the marking, in the events PR. LaunchDarkly changes reach override dependents. `Layer` keeps a dependency graph of its entries in each snapshot, and `Store` expands every changed LaunchDarkly item through both its own graph and the layer's, to a fixpoint. A change to a prerequisite flag or a segment that an override entry references therefore notifies that entry's flag, the same way dependent flags are notified for LaunchDarkly data, and a chain may cross between LaunchDarkly data and overrides any number of times. The FDv2 store's defect that seeded its dependency fan-out with symbol keys, while `Impl::DependencyTracker` indexes dependents under string keys, is fixed on `main` by #470, which the stack's base now includes. The fan-out helper here also compares keys as strings, which the fixpoint needs in any case, and the store spec keeps the #470 specs beside this PR's specs for the override layer. Verification: specs for the layer (marking, replacement, snapshot atomicity under concurrent writers), the overlay (precedence, union, deleted base items, base failure, initialization), the sink (added, removed, changed, and unchanged entries, dependency fan-out through prerequisites and nested segments, both merged views, no-listener path, base failure, serialized updates), the FDv2 wiring (construction, start order, overlay reads, stop, offline, availability unaffected), the client (not-ready gate, all-flags state, change notifications through the flag tracker, migration marker, lifecycle), and the specification vectors. Full suite and RuboCop are clean, and the full suite passes on JRuby 9.4 (the specs wait on queues without `Queue#pop`'s timeout, which Ruby 3.1 and JRuby 9.4 lack). Each new spec was checked against a deliberate defect in the code it covers. The existing FDv1 and FDv2 file data sources keep their current behavior. This series does not change them; the override feature is additive. [SDK-3249](https://launchdarkly.atlassian.net/browse/SDK-3249) [SDK-3249]: https://launchdarkly.atlassian.net/browse/SDK-3249?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Overview** > **feat: Add the override store, overlay, and data system wiring** > > Adds experimental, runtime flag/segment overrides: `DataSystem::ConfigBuilder#overrides` accepts an `OverrideSource` builder, FDv2 builds `Layer` + `Overlay` + `Sink`, wires `Store` to cross-graph dependency notifications, and extends evaluator/reason plumbing so prerequisites, segments, and client APIs respect override markers while still documenting that the surface is experimental. > > **Highlights** > > - New override layer modules (`Impl::Overrides::{Layer,Overlay,Sink}`) plus `Interfaces::Overrides` contracts mark model objects, merge overrides ahead of LD data, and fan-out flag-change listeners using merged dependency graphs. > - `EvaluationReason`, evaluator state, prerequisite records, migrations, and `LDClient` paths (`variation_detail`, `all_flags_state`) now propagate `overrideAffected`, handle uninitialized stores by consulting pure override snapshots, and keep JSON compatibility by emitting the bit only when true. > - FDv2 data system starts/stops override sources safely (offline skip, resilient `start`/`stop`), exposes `override_items`, and coordinates with `Store` via external dependency graphs; specs/vectors cover layer semantics, notifier behavior, client flows, and file-data reloader timing fixes on coarse clocks. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 1005ed0. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> The all-flags report keeps an override-affected flag's `trackEvents`, `trackReason`, and `debugEventsUntilDate` in this PR; #452 turns them off (OVERRIDE Requirement 1.4.1.1) together with the rest of the event policy for override-affected evaluations. <!-- TERMAG_PR_BODY_END --> <!-- termag: box=i-0575d1c54853058d7 project=Overrides --> <sub>Opened from termag</sub>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR is stacked on #449 so that the flag overrides series applies in order. It does not use that PR's code.
Flag overrides, as defined by the OVERRIDE specification, need three pieces below the store: a marker on the flag and segment model that says a definition came from the override store, evaluator marking that follows every definition an evaluation reads, and an indicator on the evaluation reason that reports the marking to callers. This change adds those three pieces. Nothing sets the marker yet, so the SDK behaves exactly as before. The override store, the overlay, and the data system wiring follow in the next PR.
The model classes
FeatureFlagandSegmentcarry the marker as an attribute that is never serialized, becauseas_jsonreturns the flag data hash.as_overridereturns a marked shallow copy and leaves the original unchanged. Only the SDK components that manage override entries will set it.The evaluator marks an evaluation as override-affected when the evaluated flag, a prerequisite flag at any depth, or a segment read during clause matching carries the marker. A segment counts when it is read, so a segment that does not match, or one read through a negated clause, still marks the evaluation. The marking propagates upward only. A prerequisite's own record reflects the definitions its own subtree read, so a plain prerequisite inside a marked evaluation is recorded as usual, and a prerequisite of an overridden flag is not marked by its parent. An error result is marked when a marked definition was read before the failure, including a failure raised while a prerequisite was being evaluated. An evaluation that reads no marked definition keeps the shared precomputed detail instances.
EvaluationReason#override_affectedcarries the indicator, following theinExperimentandbigSegmentsStatusprecedents. It is written to JSON asoverrideAffectedonly when true, so the wire format of ordinary evaluations is unchanged.with_override_affectedreturns the same instance when nothing changes, andwith_big_segments_statuskeeps the indicator.Verification: specs for the model marker (default, copy, original unchanged, not serialized), the reason indicator (default, JSON when true and when false,
[], equality, interaction with the big segments status), and the evaluator marking rules (direct, prerequisite at any depth, upward-only propagation, unaffected prerequisite record, segment read with and without a match, negated clause, nested segment, unresolved definition, prerequisite failure, malformed override, error raised during a prerequisite evaluation, big segments status kept). Full suite and RuboCop are clean. Each new spec was checked against a deliberate defect in the code it covers.The existing FDv1 and FDv2 file data sources keep their current behavior. This series does not change them; the override feature is additive.
This PR also carries a spec-only fix for the Windows job, which failed or passed depending on the random example order. Ruby 3.1 through 3.3 report file modification times in whole seconds on Windows, so a truncation 20 ms after another one does not look like a new write. The reloader specs that need a rewrite to look new now set the file's modification time themselves, and the watcher spec that replaces a symbolic link waits for the next second first on such a platform. No code under
lib/changes, and the specs came in with #449, so the fix sits at the bottom of the stack.SDK-3249
Opened from termag