Repository navigation
feat: Count override-affected evaluations separately and send no individual events for them - #299
Conversation
…vidual events for them An override-affected evaluation appears in summary events only: it produces no individual feature event and no debug event, whatever the flag's configuration requests. It is counted in a separate summary counter that carries an overrideAffected marker, so override-affected and ordinary evaluations of the same flag, variation, and version are never counted together. - Event.FeatureRequest carries the marking as a boolean that the SDK sets from its evaluation result. The existing constructors keep working and leave it false; toDebugEvent() keeps the value. - DefaultEventProcessor keys individual feature event and debug event emission on the marking. Index events and summaries are unchanged. - EventSummarizer keeps a second set of counters per flag for marked evaluations, created on first use so unmarked flags pay nothing. EventOutputFormatter writes overrideAffected: true only on those counters, the same way the unknown marker is written. - EventSummarizerInterface gains a summarizeEvent overload with the marker. Flag overrides are currently experimental and subject to change.
EventSummarizerInterface keeps summarizeEvent without the override marker abstract, as before, and the overload with the marker becomes a default method that calls it. A summarizer that implements only the method without the marker, such as the one in the Android SDK, compiles against this version unchanged, and counts every evaluation as one that no override affected. AggregatedEventSummarizer and PerContextEventSummarizer implement both methods, so the event processor's summarizers count the marker.
|
bugbot review |
…s, and restore Adds tests for behavior that no test checked: - The per-context summarizer passes the marker on, so one context gets separate counters for evaluations with and without it. - The library summarizers count a call to the method without the marker as one that no override affected. - The feature event constructors without the marker make events that no override affected. - A restored summary keeps its override-affected counts, also when a flag has only override-affected counters. The interface documentation now says that an implementation whose method without the marker calls the overload must also override the overload.
|
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 b997e7a. Configure here.
<!-- TERMAG_PR_BODY_BEGIN --> ## 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 - One PR per library, so each gets its own changelog entry and release. This one merges and releases first; the internal library (#299) then moves its common dependency to this release. The server SDK moves to the released versions in a later PR. <details><summary>Details</summary> - 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 </details> <!-- TERMAG_PR_BODY_END --> <!-- termag: box=i-0575d1c54853058d7 project=java-core task=feature --> <sub>Opened from termag</sub> <!-- CURSOR_SUMMARY --> --- > [!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. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit da5d8fa. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
Moves the common dependency from 2.4.0 to 2.6.0, the release that adds the overrideAffected indicator to EvaluationReason. This library does not use the indicator; it keeps its own marker on the feature event.
There was a problem hiding this comment.
Risk: medium. Not approved (risk threshold: low only): this changes how override-affected evaluations are counted and whether individual events are sent, which is a medium-risk SDK analytics behavior change. Human review is needed and no reviewers were assigned.
Sent by Cursor Approval Agent: SDK - Pull Request Router and Approver
There was a problem hiding this comment.
Risk: medium.
Automated risk review (dry run): Medium
This PR would not be automatically approved. Human approval required.
Why: It changes DefaultEventProcessor, EventSummarizer, EventOutputFormatter, and Event.FeatureRequest so override-affected evaluations skip individual and debug events and use separate summary counters, and it bumps java-sdk-common to 2.6.0. That is a bounded but non-trivial analytics event-pipeline change, so it is not Low. 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.
Sent by Cursor Approval Agent: Dry-Run PR Approver
The comments now say why the marker has its own overload with a default: a new parameter on the existing method would break implementations outside this library.
kinyoklion
left a comment
There was a problem hiding this comment.
This comment was written by an AI agent (Claude Code) working on behalf of @kinyoklion.
Notes on the compatibility change, which was not part of the #219 review.
| // The override marker is a new parameter, so it is in a separate overload with a default. | ||
| // A new parameter on this method would break implementations outside this library. |
There was a problem hiding this comment.
This comment was written by an AI agent (Claude Code) working on behalf of @kinyoklion.
Compatibility change, not part of the #219 review. In #219, the method without the override marker became a default that called a new abstract method with the marker. A class outside this library that implements only the method without the marker then no longer compiles, because it does not implement the new abstract method. The Android SDK has such a class, SameContextPerContextEventSummarizer (android-client-sdk main 8d997308).
Here the method without the marker stays abstract, as on main, and the overload with the marker is the default. Because of this, AggregatedEventSummarizer and PerContextEventSummarizer now implement the method without the marker themselves. Android's class compiles unchanged against this branch, and its tests pass against the branch jar.
| * @param context the evaluation context | ||
| * @param overrideAffected true if an override affected the evaluation | ||
| */ | ||
| default void summarizeEvent( |
There was a problem hiding this comment.
This comment was written by an AI agent (Claude Code) working on behalf of @kinyoklion.
This is the other half of the compatibility change that the comment above explains: the overload with the marker is the default, and the method without the marker is abstract.
The default drops the marker: an implementation that does not override this method counts every evaluation as one that no override affected. That is safe for Android, which never marks an evaluation. This library's event processor uses only AggregatedEventSummarizer and PerContextEventSummarizer, and both override this method, so the marker reaches the counters.
An implementation that later handles override-affected evaluations must override this method. The Javadoc says so, and it also warns that the two methods call each other without end if the method without the marker calls this one and this one is not overridden.
| // The interface keeps this method so that existing implementations do not break. This class | ||
| // counts the evaluation as one that no override affected. | ||
| @Override | ||
| public void summarizeEvent( |
There was a problem hiding this comment.
This comment was written by an AI agent (Claude Code) working on behalf of @kinyoklion.
This method is part of a compatibility change that was not in the #219 review; the comment on EventSummarizerInterface explains it. In #219, this class implemented only the overload with the override marker, and the interface gave the method without the marker a default. Here the interface keeps the method without the marker abstract, so that classes outside this library that implement only that method still compile. This class therefore implements it, and passes false for the marker. EventSummarizerInterfaceTest.aggregatedSummarizerCountsTheMethodWithoutTheMarkerAsUnaffected checks it.
| // The interface keeps this method so that existing implementations do not break. This class | ||
| // counts the evaluation as one that no override affected. | ||
| @Override | ||
| public void summarizeEvent( |
There was a problem hiding this comment.
This comment was written by an AI agent (Claude Code) working on behalf of @kinyoklion.
This method is part of the compatibility change that the comment on EventSummarizerInterface explains. As in AggregatedEventSummarizer, the interface keeps the method without the override marker abstract, so this class implements it and passes false for the marker. In #219 the interface default did this. EventSummarizerInterfaceTest.perContextSummarizerCountsTheMethodWithoutTheMarkerAsUnaffected checks it.
| // Implements only the method without the override marker, as a summarizer outside this library can. | ||
| private static final class SummarizerWithoutMarker implements EventSummarizerInterface { |
There was a problem hiding this comment.
This comment was written by an AI agent (Claude Code) working on behalf of @kinyoklion.
This test covers the compatibility change that the comment on EventSummarizerInterface explains. SummarizerWithoutMarker stands in for the Android SDK's summarizer: it implements only the method without the override marker. This file does not compile against #219 as reviewed, and passes here.
There was a problem hiding this comment.
Risk: medium. Not approved (Risk Classification: threshold is low only; SDK rules 1–3 pass). This changes SDK analytics event emission and summary counters for override-affected evaluations, so human review is needed and no reviewers were assigned.
Sent by Cursor Approval Agent: SDK - Pull Request Router and Approver
🤖 I have created a release *beep* *boop* --- ## [1.15.0](launchdarkly-java-sdk-internal-1.14.1...launchdarkly-java-sdk-internal-1.15.0) (2026-12-03) ### Features * Count override-affected evaluations separately and send no individual events for them ([#299](#299)) ([b1c9655](b1c9655)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…ide-affected evaluations (#223) <!-- TERMAG_PR_BODY_BEGIN --> ## Update, 2026-12-03 - `launchdarkly-java-sdk-internal` 1.15.0 is released from `main` (#299), and the pin is unchanged. The release has the event changes from #219 that this PR uses. It also keeps the existing `EventSummarizerInterface` method abstract and makes the overload with the override marker the default, so that summarizers outside the library still compile. The server SDK does not use that interface. - Verified against the Maven Central artifacts of common 2.6.0 and internal 1.15.0: 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. - The pin moves from `java-sdk-internal` 1.13.0 to 1.15.0. Versions 1.13.0 to 1.14.1 were released from `main` without the override changes, so 1.15.0 is the version that a release of internal from `feat/overrides` gets. CI for this PR stays red until that release exists. - The `@since` tag of the new `EventProcessor` method now says 7.20.0, in the existing commit "docs: Give the flag override API the version that will ship 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. - New commit: the `@since` tag of the new `EventProcessor` method now says 7.19.0, because 7.18.0 shipped from `main` without flag overrides. - Rebase conflict in `build.gradle` with `main`'s internal 1.12.2 pin, resolved to this PR's 1.13.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 This connects the override-affected marking of an evaluation to analytics events, as the OVERRIDE specification requires. An evaluation that read a definition from the override store, directly or through a prerequisite or a segment, produces no individual feature event and no debug event, whatever the flag's configuration requests. It is still counted in summary events, in a separate counter that carries `overrideAffected: true`, so LaunchDarkly can tell override-affected counts from ordinary counts of the same flag, variation, and version. A prerequisite record carries the prerequisite's own marking: an unaffected prerequisite evaluated inside a marked evaluation still produces its individual event. - `EventProcessor` gains an overload of `recordEvaluationEvent` with the marking. It is a default method that ignores the marking and delegates to the existing method, so a custom implementation keeps compiling and behaving as before. The SDK's implementations override it. - The evaluator's event recorder passes the evaluation result's marking for top-level, prerequisite, and requested-type-mismatch records. An evaluation that throws records its error event with the evaluated flag's own marking, because that definition was read before the failure. Event generation keys on that value alone and does not read the evaluation reason. - The server SDK now depends on launchdarkly-java-sdk-internal 1.15.0, whose event processor suppresses individual events for marked evaluations and splits the summary counters by the marker. - The OVERRIDE specification's vector runner now also asserts the per-evaluation summary marking. Flag overrides are currently experimental and subject to change. This PR depends on the override layer change (rlamb/overrides-java-override-layer) and is based on that branch; 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](https://launchdarkly.atlassian.net/browse/SDK-3246) [SDK-3246]: https://launchdarkly.atlassian.net/browse/SDK-3246?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Overview** > Evaluations that read from the override store now pass an **`overrideAffected`** marker from the evaluator into **`EventProcessor.recordEvaluationEvent`**, including a new default overload on the public interface so existing custom processors keep compiling. > > **`InputValidatingEvaluator`** forwards each result’s marking for successful evals, prerequisites, type-mismatch errors, and exception paths (from the flag definition read before failure). **`DefaultEventProcessorWrapper`** passes it into **`Event.FeatureRequest`**. The dependency **`launchdarkly-java-sdk-internal`** moves to **1.15.0**, which is expected to suppress individual feature/debug events for marked evals and emit summary counters tagged with **`overrideAffected`**. > > New integration tests (**`LDClientOverrideEventsTest`**) cover marking for flags, prerequisites, segments, and flushed analytics payloads; OVERRIDE vector tests and **`TestEventProcessor`** assert **`summaryOverrideAffected`** end-to-end. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit ef3bc21. 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>
…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
<!-- 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 -->


Summary
Brings the override-affected event handling from
feat/overridestomain, solaunchdarkly-java-sdk-internalcan 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
summarizeEventwithout 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 feat: Count override-affected evaluations separately and send no individual events for them #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.Needs your attention
Details
SameContextPerContextEventSummarizerfrom android-client-sdkmain(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.main, built against this change and the common change, passes its unit tests and the v3.2.0-alpha.21 contract tests.Opened from termag
Note
Overview
Adds override-affected handling to the internal event pipeline ahead of experimental flag overrides in the server SDK.
Event.FeatureRequestgains anoverrideAffectedflag. 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 newsummarizeEventoverload with a default interface method so external summarizers like the Android SDK keep compiling). Summary JSON emits anoverrideAffected: truemarker on the relevant counter entries through refactoredwriteCountersin EventOutputFormatter.Bumps
launchdarklyJavaSdkCommonfrom 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.Reviewed by Cursor Bugbot for commit bb5ced7. Bugbot is set up for automated code reviews on this repo. Configure here.