Skip to content

feat: Add the override marker to the flag and segment models and mark evaluations - #221

Open
kinyoklion wants to merge 4 commits into
rlamb/overrides-java-filedata-reloaderfrom
rlamb/overrides-java-model-marker
Open

kinyoklion wants to merge 4 commits into
rlamb/overrides-java-filedata-reloaderfrom
rlamb/overrides-java-model-marker

Conversation

@kinyoklion

@kinyoklion kinyoklion commented Sep 25, 2026 •

Copy link
Copy Markdown
Member

Update, 2026-11-13

Summary

The OVERRIDE specification requires an evaluation to be marked as override-affected when any definition it read carried the override marker: the evaluated flag, a prerequisite at any depth, or a segment consulted during matching, whether or not the segment matched. The marking propagates upward only: a prerequisite's own record reflects only the definitions that its own subtree read, while the evaluation that requested it accumulates the result. An evaluation that fails is still marked when it read a marked definition, and a requested-type mismatch keeps the marking on its error reason, as does the WRONG_TYPE error that migrationVariation returns for an unrecognized stage.

  • DataModel.FeatureFlag and DataModel.Segment carry a transient isOverride marker. It is never serialized and never read from JSON. markedAsOverride() returns a shallow copy with the marker set, sharing nested collections and preprocessing with the source and never modifying it. The override layer will use it in the next change.
  • The evaluator tracks the marking per evaluation scope. The scope starts from its own flag's marker, each segment read can set it, and the value is saved, reset to the prerequisite's own marker, and restored around every prerequisite evaluation. Each result and each prerequisite record carries the marking on its reason.
  • EvalResult.isOverrideAffected() reads the reason's indicator, and withOverrideAffected(boolean) returns a copy so that the shared precomputed results are never mutated.
  • An evaluation that throws returns an EXCEPTION result marked with the evaluated flag's own marker, because that definition was read before the failure.
  • The server SDK now depends on launchdarkly-java-sdk-common 2.6.0, which adds EvaluationReason.isOverrideAffected() and the overrideAffected JSON property (written only when true). CI for this change cannot pass until that version is released.

Flag overrides are currently experimental and subject to change.

This PR is based on the file data reliability branch (rlamb/overrides-java-filedata-reloader) so the series applies in order; retarget it to feat/overrides once that branch merges.

The existing file data source keeps its current behavior; this change does not touch its code paths.

SDK-3246


Note

Overview
Introduces experimental flag-override tracking by adding a transient isOverride marker on FeatureFlag and Segment (via markedAsOverride() shallow copies that never serialize to JSON), and bumping launchdarkly-java-sdk-common to 2.6.0 so EvaluationReason can expose overrideAffected.

The evaluator now tracks per-scope whether any read definition was overridden—the evaluated flag, nested prerequisites, or segments consulted during matching (match or not)—and stamps that on the result reason with upward-only propagation (each prerequisite record keeps its own subtree marking). EvalResult gains isOverrideAffected() / withOverrideAffected() without mutating shared precomputed results.

InputValidatingEvaluator, MigrationStageEnforcingEvaluator, and allFlagsState preserve the marker on errors, type mismatches, and exceptions when an override flag was already loaded. Broad unit tests cover model serialization, propagation, and edge cases.

Reviewed by Cursor Bugbot for commit 2ac73fd. Bugbot is set up for automated code reviews on this repo. Configure here.

Opened from termag

@kinyoklion
kinyoklion force-pushed the rlamb/overrides-java-filedata-reloader branch from f0038ed to 79250a7 Compare September 28, 2026 21:03
@kinyoklion
kinyoklion force-pushed the rlamb/overrides-java-model-marker branch 3 times, most recently from 1ba722a to 996b8d3 Compare October 3, 2026 00:58
@kinyoklion

Copy link
Copy Markdown
Member Author

bugbot review

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

@kinyoklion
kinyoklion force-pushed the rlamb/overrides-java-model-marker branch from 996b8d3 to ca22bc0 Compare October 13, 2026 21:02
@kinyoklion

Copy link
Copy Markdown
Member Author

bugbot review

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

@kinyoklion

Copy link
Copy Markdown
Member Author

bugbot review

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

@kinyoklion
kinyoklion marked this pull request as ready for review November 2, 2026 23:46
@kinyoklion
kinyoklion requested a review from a team as a code owner November 2, 2026 23:46
@kinyoklion
kinyoklion force-pushed the rlamb/overrides-java-model-marker branch from 64740d7 to a4d9c28 Compare November 3, 2026 23:55

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit a4d9c28. Configure here.

… evaluations

The OVERRIDE specification requires an evaluation to be marked as
override-affected when any definition it read carried the override
marker: the evaluated flag, a prerequisite at any depth, or a segment
consulted during matching, whether or not the segment matched. The
marking propagates upward only. A prerequisite's own record reflects
only the definitions that its own subtree read. An evaluation that fails
is still marked when it read a marked definition.

DataModel.FeatureFlag and DataModel.Segment carry a transient
isOverride marker that is never serialized and never read from JSON,
with a markedAsOverride() shallow copy that the override layer will use
without modifying the source's entity.

The evaluator tracks the marking per evaluation scope: the scope starts
from its own flag's marker, each segment read can set it, and the value
is saved, reset to the prerequisite's marker, and restored around each
prerequisite evaluation. The result and every prerequisite record carry
the marking on their reason. EvalResult exposes isOverrideAffected() and
withOverrideAffected(), which copies rather than mutating the shared
precomputed results. A requested-type mismatch keeps the marking on its
error reason.

The server SDK now depends on launchdarkly-java-sdk-common 2.6.0, which
adds the overrideAffected indicator to EvaluationReason. CI for this
change cannot pass until that version is released.

Flag overrides are currently experimental and subject to change.
…gnized stage

migrationVariation replaces the result of a flag that serves an
unrecognized stage with a WRONG_TYPE error. The evaluation read the same
definitions, so the replacement keeps the override-affected marking, as
the type mismatch of an ordinary variation call already does, and the
migration tracker receives a marked reason for an overridden flag.
When the evaluation of a flag throws, the error result now carries the
override-affected marking of the flag's own definition, which was read
before the failure. The spec marks a failed evaluation when a definition
it read came from the override store.
When the evaluation of a flag throws inside allFlagsState, the state now records the error reason with the override-affected marking of the flag's own definition, as the single-flag path already does.
@kinyoklion
kinyoklion force-pushed the rlamb/overrides-java-model-marker branch from 5eee1ed to 2ac73fd Compare November 13, 2026 00:14
@kinyoklion
kinyoklion force-pushed the rlamb/overrides-java-filedata-reloader branch from 3b81e47 to 68f868e Compare November 13, 2026 00:14
@cursor cursor Bot added the risk:medium label Nov 13, 2026

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale comment

Risk: medium.

Automated risk review (dry run): Medium

This PR would not be automatically approved. Human approval required.

Why: Override-affected marking is wired through the server SDK evaluator, flag/segment data model, and error/mismatch wrappers (Evaluator.java, DataModel.java, InputValidatingEvaluator.java, MigrationStageEnforcingEvaluator.java), plus a launchdarkly-java-sdk-common 2.6.0 bump, so correctness spans several interacting evaluation paths.

Human review is needed and no reviewers were assigned.

If you disagree with this review, share this PR in #feedback-agent-approvals or submit a changes-requested review explaining why.

Open in Web View Automation 

Sent by Cursor Approval Agent: Dry-Run PR Approver

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Risk: medium.

Automated risk review (dry run): Medium

This PR would not be automatically approved. Human approval required.

Why: Override-affected marking is threaded through DataModel, Evaluator, InputValidatingEvaluator, and MigrationStageEnforcingEvaluator, plus a launchdarkly-java-sdk-common 2.6.0 bump, so evaluation behavior depends on several interacting pieces. Tests cover the new paths, but this is not a narrow change.

If you disagree with this review, share this PR in #feedback-agent-approvals or submit a changes-requested review explaining why.

Open in Web View Automation 

Sent by Cursor Approval Agent: Dry-Run PR Approver

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant