Skip to content

feat: Add the overrideAffected indicator to EvaluationReason - #298

Merged
kinyoklion merged 1 commit into
mainfrom
rlamb/sdk-3246/java-common-override-reason
Dec 2, 2026
Merged

kinyoklion merged 1 commit into
mainfrom
rlamb/sdk-3246/java-common-override-reason

Conversation

@kinyoklion

@kinyoklion kinyoklion commented Dec 2, 2026 •

Copy link
Copy Markdown
Member

Summary

Brings the overrideAffected indicator on EvaluationReason from feat/overrides to main, so launchdarkly-java-sdk-common can be released before the server SDK's flag override support needs it. The change is the one reviewed in #218, unchanged: isOverrideAffected() and withOverrideAffected(boolean), and JSON that has overrideAffected only when it is true. Flag overrides are currently experimental and subject to change.

Follow-up to #218 ("feat: Add the overrideAffected indicator to EvaluationReason")

Technical design decisions

Details
  • Compatibility: the change only adds. A comparison of the public API with main shows the two new methods and nothing removed or changed. Nothing on main sets the indicator, so serialized reasons and equality are unchanged.
  • Tested: the library's CI build (tests, checks, Javadoc). The server SDK from main, built against this change and the internal change, passes its unit tests and the v3.2.0-alpha.21 contract tests.
  • SDK-3246

Opened from termag


Note

Overview
Adds an overrideAffected flag to EvaluationReason so evaluations can record when a flag, prerequisite, or segment came from the experimental override store.

The model gains isOverrideAffected() and withOverrideAffected(boolean) (default false, same-instance optimization when unchanged). equals/hashCode and withBigSegmentsStatus preserve the new field. JSON via EvaluationReasonTypeAdapter reads overrideAffected and writes it only when true (same pattern as inExperiment).

Unit and serialization tests cover defaults, immutability, equality, and round-trip JSON.

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

An evaluation is override-affected when any definition it read came from
the SDK's override store: the flag itself, a prerequisite at any depth,
or a segment read during matching. The evaluation reason carries that
marking as a boolean named overrideAffected, alongside inExperiment.

EvaluationReason gains isOverrideAffected() and
withOverrideAffected(boolean). The latter returns the same instance when
the value is unchanged, so the shared static instances stay shared. The
indicator takes part in equality and hashing. The JSON representation
writes overrideAffected only when it is true, and parsing accepts the
property. The string representation is unchanged.

Flag overrides are currently experimental and subject to change.
@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.

✅ 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 da5d8fa. Configure here.

@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: low. Approved: not a release PR (rule 1), allowed SDK-team author (rule 2), and no GitHub Actions workflow changes (rule 3). Cursor Bugbot completed with no issues.

Open in Web View Automation 

Sent by Cursor Approval Agent: SDK - Pull Request Router and Approver

@cursor cursor Bot added the risk:low label Dec 2, 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.

Automated risk review (dry run): Low

This PR would be automatically approved.

Why: Additive overrideAffected on EvaluationReason plus JSON adapter and tests; defaults keep existing equality and JSON unchanged when the indicator is false.

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

@kinyoklion
kinyoklion merged commit cd28eb7 into main Dec 2, 2026
9 checks passed
@kinyoklion
kinyoklion deleted the rlamb/sdk-3246/java-common-override-reason branch December 2, 2026 21:51
kinyoklion pushed a commit that referenced this pull request Dec 2, 2026
🤖 I have created a release *beep* *boop*
---


##
[2.6.0](launchdarkly-java-sdk-common-2.5.0...launchdarkly-java-sdk-common-2.6.0)
(2026-12-02)


### Features

* Add the overrideAffected indicator to EvaluationReason
([#298](#298))
([cd28eb7](cd28eb7))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Overview**
> **Release Please** bumps `lib/shared/common` from **2.5.0** to
**2.6.0** by updating `.release-please-manifest.json`,
`gradle.properties`, and `CHANGELOG.md`. There is **no application
code** in this diff.
> 
> The published **2.6.0** release documents the feature already merged
in [#298](#298):
**`EvaluationReason`** now exposes an **`overrideAffected`** indicator
(via `isOverrideAffected()` / `withOverrideAffected()`), signaling when
an evaluation was influenced by the SDK override store—including
prerequisite flags or segments at any depth.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
74d59b7. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
kinyoklion added a commit that referenced this pull request Dec 3, 2026
…vidual events for them (#299)

<!-- TERMAG_PR_BODY_BEGIN -->
## Summary

Brings the override-affected event handling from `feat/overrides` to
`main`, so `launchdarkly-java-sdk-internal` can be released before the
server SDK's flag override support needs it. A marked evaluation
produces no individual or debug event and is counted in a separate
summary counter. Nothing sets the marker until the server SDK's support
ships. Flag overrides are currently experimental and subject to change.

Follow-up to #219 ("feat: Count override-affected evaluations separately
and send no individual events for them")

## Technical design decisions

- The first commit is the change reviewed in #219. The second keeps
summarizers outside this library compiling: `summarizeEvent` without the
marker stays abstract, and the new overload with the marker is a default
method that calls it. The Android SDK has such a summarizer,
`SameContextPerContextEventSummarizer`, which does not compile against
#219 as it was. The third adds tests for marker paths that no test
checked. The fourth moves the common dependency to 2.6.0.
- One PR per library, so each gets its own changelog entry and release.
Common (#298) was merged and released first as 2.6.0, and this library
moves its common dependency from 2.4.0 to 2.6.0, although this change
does not need it. The server SDK moves to the released versions in a
later PR.

## Needs your attention

- The compatibility and test commits were not part of the #219 review.
Review comments on the diff mark the compatibility change.

<details><summary>Details</summary>

- Android: `SameContextPerContextEventSummarizer` from
android-client-sdk `main` (8d997308) compiles unchanged against this
branch. Internal's event processor creates its own summarizers, so it
never calls the overload with the marker on a summarizer from outside.
- Java and Android levels: a default interface method is a Java 8
language feature. The library already targets Java 8, and #219 used one
too. Android build tools convert default methods for API levels below
24; no Java 8 library API is used.
- Tested: the library's CI build (tests, checks, Javadoc) against common
2.6.0 from Maven Central, with new tests for a summarizer that
implements only the method without the marker, the marker in the
per-context summarizer, the feature event constructors without the
marker, and restored summaries with override-affected counts. The server
SDK from `main`, built against this change and the common change, passes
its unit tests and the v3.2.0-alpha.21 contract tests.
- SDK-3246

</details>
<!-- TERMAG_PR_BODY_END -->

<!-- termag: box=i-0575d1c54853058d7 project=java-core task=feature -->
<sub>Opened from termag</sub>

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Overview**
> Adds **override-affected** handling to the internal event pipeline
ahead of experimental flag overrides in the server SDK.
> 
> `Event.FeatureRequest` gains an `overrideAffected` flag. When set,
**DefaultEventProcessor** still records the evaluation in summaries but
**suppresses** individual feature and debug events regardless of flag
tracking/debug settings. Summarizers route those evaluations into
**separate counters** (via a new `summarizeEvent` overload with a
**default interface method** so external summarizers like the Android
SDK keep compiling). Summary JSON emits an **`overrideAffected: true`**
marker on the relevant counter entries through refactored
`writeCounters` in **EventOutputFormatter**.
> 
> Bumps **`launchdarklyJavaSdkCommon`** from 2.4.0 to 2.6.0 in
**Dependencies.kt**. Nothing in this library sets the marker yet—that
will come when override support lands upstream.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
bb5ced7. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
kinyoklion added a commit that referenced this pull request Dec 3, 2026
… evaluations (#221)

<!-- TERMAG_PR_BODY_BEGIN -->
## Update, 2026-12-03

- `launchdarkly-java-sdk-common` 2.6.0 is released from `main` (#298).
Its source is the same as on `feat/overrides`, and the pin is unchanged.
- Verified against the Maven Central artifact: this head builds, with
the contract test service, and CI passes.

## Update, 2026-12-01

- Rebased onto `feat/overrides`, which has `main` merged into it again.
From `main` it gets the 7.19.0 to 7.19.2 releases, `java-sdk-internal`
1.14.0, and the FDv2 fix that leaves out an empty selector (#261). The
v3.2.0-alpha.21 contract tests check that fix, so CI failed three FDv2
streaming tests without it.
- Rebase conflict in `build.gradle`: `main`'s internal 1.14.0, with this
PR's common 2.6.0.
- `main` added a `clientSideAvailability` argument to the `FeatureFlag`
constructor (#275). The marked copy of a flag now passes it on, so an
override keeps the flag's client-side availability. The change is in the
first commit, and its test checks it.
- Verified with the v3.2.0-alpha.21 harness that CI runs, with `common`
2.6.0 and `internal` 1.15.0 published locally from `feat/overrides`:
  - every PR in the stack compiles, with Javadoc, at its own head;
- the server unit tests pass at the top (2348, with the 72 existing
skips);
- the full v3 contract tests pass at the top (6457 tests ran). That
includes the flag overrides suite and both flag listener suites.

## Update, 2026-11-13

- Rebased onto `feat/overrides`, which now includes #218 and #219 and
has `main` merged into it. From `main` it gets the 7.18.0 release, CI on
the latest v3 contract tests, flag change listener support in the
contract test service, and the `java-sdk-internal` 1.12.1 and 1.12.2
fixes. A common 2.6.0 and internal 1.13.0 release from this branch needs
those fixes.
- Rebase conflicts with `main`, both resolved by keeping both sides:
- `Evaluator.java`: `main`'s #258 keeps the big segments status on an
error reason, and this PR marks that result as override-affected.
- `build.gradle`: `main`'s `jsr305` and internal 1.12.2, with this PR's
common 2.6.0.
- Verified at the top of the stack, with `common` and `internal`
published locally from `feat/overrides`:
  - every PR in the stack compiles, with Javadoc, at its own head;
  - the server unit tests pass (2285, with the 72 existing skips);
- the full v3 contract tests pass (6321 tests). That includes the flag
overrides suite, with the deleted-entry tests of
launchdarkly/sdk-test-harness#599, and both flag listener suites.

## 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).

Flag overrides are currently experimental and subject to change.

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

[SDK-3246](https://launchdarkly.atlassian.net/browse/SDK-3246)


[SDK-3246]:
https://launchdarkly.atlassian.net/browse/SDK-3246?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Overview**
> Adds **experimental flag-override tracking** so evaluations can report
when they were influenced by local override definitions rather than
LaunchDarkly data.
> 
> **FeatureFlag** and **Segment** gain a transient `isOverride` marker
(never serialized) and `markedAsOverride()` shallow copies for the
override layer to use. The **Evaluator** tracks whether the current
scope read any marked flag, prerequisite subtree, or segment (match or
not), propagating upward while keeping each prerequisite record scoped
to its own subtree. **`EvalResult`** exposes `isOverrideAffected()` and
`withOverrideAffected()` via `EvaluationReason` so shared precomputed
results stay immutable.
> 
> **InputValidatingEvaluator**, **MigrationStageEnforcingEvaluator**,
and `allFlagsState` preserve override marking across type errors,
exceptions, and malformed evaluations. Dependency
**`launchdarkly-java-sdk-common`** is bumped to **2.6.0** for
`EvaluationReason.isOverrideAffected()`.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
a2a5c8e. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
<!-- TERMAG_PR_BODY_END -->

<!-- termag: box=i-0575d1c54853058d7 project=java-core -->
<sub>Opened from termag</sub>
kinyoklion added a commit that referenced this pull request Dec 3, 2026
…y it is listed under (#259)

<!-- TERMAG_PR_BODY_BEGIN -->
## Update, 2026-12-03

- `launchdarkly-java-sdk-common` 2.6.0 and
`launchdarkly-java-sdk-internal` 1.15.0 are released from `main` (#298,
#299), and the pins are unchanged.
- Verified against the Maven Central artifacts: every PR in the stack
builds at its own head, with the contract test service, the server unit
tests pass at the top (2348, with the 72 existing skips), and CI passes.

## Update, 2026-12-01

- Rebased onto `feat/overrides`, which has `main` merged into it again.
From `main` it gets the 7.19.0 to 7.19.2 releases, `java-sdk-internal`
1.14.0, and the FDv2 fix that leaves out an empty selector (#261). The
v3.2.0-alpha.21 contract tests check that fix, so CI failed three FDv2
streaming tests without it.
- No changes of its own. It keeps #260, which merged into this branch:
the file synchronizer pin tests wait for the failure status, so they
hold on Windows.
- Verified with the v3.2.0-alpha.21 harness that CI runs, with `common`
2.6.0 and `internal` 1.15.0 published locally from `feat/overrides`:
  - every PR in the stack compiles, with Javadoc, at its own head;
- the server unit tests pass at the top (2348, with the 72 existing
skips);
- the full v3 contract tests pass at the top (6457 tests ran). That
includes the flag overrides suite and both flag listener suites.

## Update, 2026-11-13

- Rebased onto `feat/overrides`, which now includes #218 and #219 and
has `main` merged into it. From `main` it gets the 7.18.0 release, CI on
the latest v3 contract tests, flag change listener support in the
contract test service, and the `java-sdk-internal` 1.12.1 and 1.12.2
fixes. A common 2.6.0 and internal 1.13.0 release from this branch needs
those fixes.
- New commit, "fix: Key each override by the key it is listed under, and
reject one listed under another key":
- Evaluation reads an override entry by the key it is listed under, but
the all-flags state and events report the definition's own key. The file
source deserialized each `flags` and `segments` entry as it was, so an
entry with no `key` property made `allFlagsState()` throw a
`NullPointerException` to the application, and an entry pasted under a
new key with its old `key` property was served under one key and
reported under the other. I confirmed both with a probe against the
stack.
- Each entry now takes the key it's listed under, as the Node, Go and
Python sources key it. A `key` property is optional, and
`FileOverrides.source()` says so.
- The override layer also rejects a snapshot that lists a flag or
segment under a key other than its own, the same way as one with a
deleted item: the sink logs it and the overrides in effect stay. Only a
custom source can produce such a snapshot now. Python added the same
check after keelerm84's review of its port (python-server-sdk#527). Go,
Node, .NET and Ruby don't have it yet.
- Tests: `OverrideFileLoaderTest.entryIsKeyedByTheKeyItIsListedUnder`
(JSON and YAML, flags and segments),
`LDClientOverridesTest.fileEntryIsServedAndReportedUnderTheKeyItIsListedUnder`,
`OverrideLayerTest.replacementThatListsAnItemUnderAnotherKeyIsRejectedAndTheLayerIsUnchanged`
(including a definition with no key), and
`OverrideSinkImplTest.snapshotThatListsAFlagUnderAnotherKeyIsRejected`.
Removing the keying fails the first two, and removing the layer check
fails the other two.
- Verified at the top of the stack, with `common` and `internal`
published locally from `feat/overrides`:
  - every PR in the stack compiles, with Javadoc, at its own head;
  - the server unit tests pass (2285, with the 72 existing skips);
- the full v3 contract tests pass (6321 tests). That includes the flag
overrides suite, with the deleted-entry tests of
launchdarkly/sdk-test-harness#599, and both flag listener suites.

**Requirements**

- [x] I have added test coverage for new or changed functionality
- [x] I have followed the repository's [pull request submission
guidelines](../blob/main/CONTRIBUTING.md#submitting-pull-requests)
- [ ] I have validated my changes against all supported platform
versions

**Related issues**

Implements the "reject deleted entries" rule of the flag overrides spec,
launchdarkly/sdk-specs#288 (Requirements 1.1.1.1, 1.2.8.1 and 1.3.6.2).

This PR is stacked on #225 (`rlamb/overrides-java-contract-tests`) so
that the PRs below it do not change. Retarget it when the stack merges.

**Describe the solution you've provided**

Before: a flag or segment entry with `"deleted": true` became a deleted
placeholder. That was true both in an override file and in a snapshot
from a custom source. The override layer stored it and the overlay
served it, so the key looked absent: the LaunchDarkly definition was
hidden from evaluation, from prerequisites and segment reads, and from
the all-flags state, and the evaluation was not marked as
override-affected.

After:

- **Sink (every source, including a custom one through
`OverrideSink`).** The override layer never holds a deleted item. If a
snapshot contains one, the SDK rejects the whole snapshot. The layer
stays unchanged, no flag change listener is notified, and the SDK logs
an Error naming the kind and the key, for example `Rejected an override
snapshot because flag "f" is marked as deleted; the overrides in effect
are unchanged`. A deleted item is either the placeholder that
`DataKind.deserialize` produces or a model object marked as deleted. The
check runs in `OverrideLayer.setAll` before the contents are swapped,
and `OverrideSinkImpl` logs the rejection. The `OverrideSink` signature
is unchanged and nothing is thrown to the source.
- **File override source.** `OverrideFileLoader` fails the load when a
file has a flag or segment entry marked as deleted, the same way it
fails for a file that cannot be parsed. The overrides in effect stay,
and the existing retry applies. The failure is logged like other load
failures and names the file and the key: `Unable to load flags: file
/path/overrides.json: flag "f" is marked as deleted; remove the entry to
remove its override`. The check also fires when the duplicate keys
handling would drop the entry, because the file still needs correcting.
The source detects this while loading, before it calls the sink.
- `"deleted": false` is an ordinary definition and still loads.
- **Public docs.** `FileOverrides.source()` gains one sentence saying
that a file with an entry marked as deleted fails to load and that an
override is removed by removing its entry or deleting the file.
`OverrideSink.setOverrides` gains one sentence saying that a snapshot
with a deleted flag or segment is rejected. The experimental notice is
unchanged on both.

**The ordinary file data source is unchanged on purpose.**
`FileDataSourceBase` and `FileDataSourceParsing` are not modified.
Rejecting deleted entries there would be a breaking change, which is
planned for a later major version. The check lives only in the override
path (`OverrideFileLoader` and the override layer). A new test,
`DataLoaderTest.entriesMarkedAsDeletedStillLoadAsDeletedItems`, pins the
data source's current behavior: it still loads such entries as deleted
items.

**Tests**

- `OverrideLayerTest`:
`replacementThatContainsADeletedItemIsRejectedAndTheLayerIsUnchanged`
replaces `deletedPlaceholderIsStoredAsIs`, which pinned the old
behavior. It covers the deserialized placeholder and a model object
marked as deleted, for both flags and segments.
`definitionWithDeletedFalseIsStored` is new.
- `OverrideSinkImplTest`: `snapshotWithADeletedFlagIsRejected`,
`snapshotWithADeletedSegmentIsRejected` and
`snapshotWithADeletedItemIsRejectedWhenNothingIsListening`. Each checks
that the layer is unchanged, that no notification is sent, and that the
Error is logged.
- `OverrideFileLoaderTest`: `flagMarkedAsDeletedFailsTheLoad` and
`segmentMarkedAsDeletedFailsTheLoad` cover JSON and YAML, with the exact
message naming the file and the key. Also
`entryMarkedAsDeletedFailsTheLoadEvenWhenItIsADroppedDuplicate` and
`entriesWithDeletedFalseAreOrdinaryDefinitions`.
- `FileOverrideSourceTest`:
`flagMarkedAsDeletedFailsTheReloadAndKeepsTheOverrides` and
`segmentMarkedAsDeletedFailsTheReloadAndKeepsTheOverrides`. In each, an
in-place edit adds the deleted entry and changes another override.
Nothing is supplied, the logged Error names the file and the key, and
removing the entry recovers. `entriesWithDeletedFalseLoad` is also new.
- `DataLoaderTest.entriesMarkedAsDeletedStillLoadAsDeletedItems`: the
ordinary file data source behavior is pinned as unchanged.

How I ran them, on JDK 17 (arm64):

1. Published the unreleased shared libraries locally from the monorepo.
Common came from the #218 head (`b5deba0`) with `./gradlew
publishToMavenLocal -Pversion=2.6.0 -PskipSigning=true` in
`lib/shared/common`. Internal came from the #219 head (`0e7744f`) with
`-Pversion=1.13.0` in `lib/shared/internal`.
2. In `lib/sdk/server`, ran the override and file data source classes
with `./gradlew --max-workers=2 --no-daemon -Dorg.gradle.jvmargs=-Xmx2g
test --tests '*Override*' --tests '*.integrations.File*' --tests
'*.integrations.DataLoaderTest' --tests '*.integrations.FlagFileParser*'
--tests '*.integrations.ClientWithFileDataSourceTest'`. Result: 343
tests in 29 classes, 0 failures.
3. Ran the full server `test` task (same Gradle options). Result: 2275
tests in 129 classes, 0 failures. The 72 skipped tests are the existing
skips in `PersistentDataStoreWrapperTest`.
4. Ran `checkstyleMain checkstyleTest javadoc`: passed, with no new
Javadoc warnings.
5. Checked that the new tests fail without the change. With the layer
check and the loader check disabled, all 9 rejection tests fail, and the
`deleted: false` tests and the data source pin still pass. With the
sink's catch removed, the 3 sink tests fail.

**Describe alternatives you've considered**

- Checking only in the sink, with a separate pass over the snapshot.
That pass would iterate the source's `Iterable` twice. Checking in
`OverrideLayer.setAll` keeps it to one pass and makes the layer enforce
its own invariant.
- Dropping only the deleted entry. The spec requires rejecting the whole
snapshot, so the layer is always exactly a snapshot that the source
supplied.
<!-- TERMAG_PR_BODY_END -->

<!-- termag: box=i-0575d1c54853058d7 project=java-core -->
<sub>Opened from termag</sub>

[SDK-3578](https://launchdarkly.atlassian.net/browse/SDK-3578)

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Overview**
> Strengthens **flag/segment override** handling so invalid snapshots
are rejected instead of partially applied.
> 
> **Override layer** (`OverrideLayer.setAll`) now refuses any
replacement that includes a **deleted** flag/segment (placeholder or
`deleted: true`) or a definition **listed under a different key** than
its own `key`. The prior snapshot stays in place; new
`DeletedItemException` / `MismatchedKeyException` types carry clear
messages.
> 
> **Override sink** catches those failures, logs an error, and **does
not** notify flag-change listeners.
> 
> **File override source** (`OverrideFileLoader`) treats `"deleted":
true` entries as a **load failure** (like a parse error), forces each
`flags`/`segments` entry’s `key` to match the map key it’s listed under
via `keyedBy`, and updates public docs on `FileOverrides` and
`OverrideSink`. Removing an override is done by deleting the entry or
file—not by marking deleted.
> 
> The **ordinary file data source** is intentionally unchanged; a new
test pins that deleted entries still load there.
> 
> Extensive unit/integration tests cover rejection, logging, key
consistency in evaluation vs `allFlagsState`, and file reload behavior.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
7b2ebcf. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->



[SDK-3578]:
https://launchdarkly.atlassian.net/browse/SDK-3578?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
kinyoklion added a commit that referenced this pull request Dec 3, 2026
<!-- TERMAG_PR_BODY_BEGIN -->
BEGIN_COMMIT_OVERRIDE
feat: Add experimental support for file-based flag overrides
fix: Keep flag file content out of the file data source's parse error
messages
fix: Prevent YAML flag files that are parsed at the same time from
returning each other's data
fix: Report a YAML flag file value that does not match its explicit tag
as invalid data instead of an unexpected exception
END_COMMIT_OVERRIDE

## Summary

Brings `feat/overrides` into `main`: experimental flag overrides for the
server SDK on the FDv2 data system, with a file-based override source.
The branch is `feat/overrides` with `main` merged into it;
`feat/overrides` itself is unchanged. Every change was reviewed and
merged through its own PR against `feat/overrides`: #220, #221, #222,
#223, #224, #225 and #259. The shared library changes were released from
`main` as `launchdarkly-java-sdk-common` 2.6.0 (#298) and
`launchdarkly-java-sdk-internal` 1.15.0 (#299), and the server pins
those versions. This PR adds nothing of its own; its diff against `main`
is the server SDK only.

## Technical design decisions

- The merge of `main` takes `main`'s `lib/shared`, which is the released
code. Git merged `EventSummarizerInterface` without a conflict, but into
the shape of #219, which breaks summarizers outside the library; the
merge keeps the shape of #299.
- The changelog entries come from the override block above: the feature,
and three fixes to the existing file data source that came with the
reload infrastructure in #220.

## Needs your attention

- Release Please takes the entries from the override block, not from the
title. Edit the block to change them.
- The new public APIs say `@since 7.20.0`. The open release PR #296
(7.19.3) becomes 7.20.0 once this merges.

<details><summary>Details</summary>

- Tested: the server tree is identical to the last #259 head. That head
builds against the Maven Central artifacts of common 2.6.0 and internal
1.15.0, its server unit tests pass (2348, with the 72 existing skips),
and its CI passed, including the v3.2.0-alpha.21 contract tests. CI on
`feat/overrides` after the stack merged passed too.
- Merge conflicts: `AggregatedEventSummarizer`,
`PerContextEventSummarizer`, `DefaultEventProcessorOutputTest` and
`EventSummarizerTest` in `lib/shared/internal`, all resolved to `main`'s
version.
- The fixes to the existing file data source: parse failures no longer
quote file lines or values in the log or the data source status; each
YAML parse has its own SnakeYAML instance instead of a shared static
one; and a value that SnakeYAML cannot convert to its explicit tag is a
parse failure, where it escaped the loader before.

[SDK-3246](https://launchdarkly.atlassian.net/browse/SDK-3246)

</details>
<!-- TERMAG_PR_BODY_END -->

<!-- termag: box=i-0575d1c54853058d7 project=java-core task=feature -->
<sub>Opened from termag</sub>


[SDK-3246]:
https://launchdarkly.atlassian.net/browse/SDK-3246?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Overview**
> Adds **experimental file-based flag overrides** on the FDv2 data
system: operators can configure
`DataSystemBuilder.overrides(FileOverrides.source()...)` so local
JSON/YAML files supply flag and segment definitions that **take
precedence** over LaunchDarkly data at read time, without affecting
client initialization or data-source status.
> 
> The implementation introduces an **override layer** (`OverrideLayer`,
`OverrideOverlayStore`, `OverrideSinkImpl`) wired from `FDv2DataSystem`,
a pluggable **`OverrideSource` / `OverrideSink`** API, and a **file
override source** with polling or filesystem watching, debounced
reloads, duplicate-key handling, and safer JSON/YAML parsing
(extension-based format choice, improved error messages, per-parse YAML,
tag-mismatch handling).
> 
> **Evaluation and analytics behavior** changes: flags/segments from
overrides carry a transient marker; the evaluator propagates
**override-affected** through prerequisites and segment reads;
`EvalResult` / `EvaluationReason` expose the marker; **individual
evaluation events are suppressed** for override-affected results (while
summaries can still account for them via the new `EventProcessor`
parameter); `allFlagsState` and `isFlagKnown` can use overrides **before
the store is initialized**. **Dependency tracking** now merges
LaunchDarkly and override-layer edges so flag-change listeners fire when
LD updates affect overridden definitions.
> 
> Contract tests register the **`flag-overrides`** capability and map
override config in `SdkClientEntity`. Build pins bump
`launchdarklyJavaSdkCommon` / `Internal` versions.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
763827f. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant