Repository navigation
feat: Add the override store, overlay, and data system wiring #2051
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
kinyoklion
merged 9 commits into
feat/overrides
from
rlamb/overrides-node-override-layer
Oct 12, 2026
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
381a623
feat: Add the override store, overlay, and data system wiring
kinyoklion abf2561
test: Model value-only overrides as flags served by fallthrough
kinyoklion 3743980
fix: Keep the client shutdown and the all flags state correct around …
kinyoklion bf64955
fix: Treat a null override source option as no override source
kinyoklion dd27afb
fix: Never make an evaluation wait for the override source's initial …
kinyoklion dc6c2f8
fix: Reject an override definition that does not have the shape evalu…
kinyoklion 7933b13
fix: Compare override entries by deep equality and copy them with the…
kinyoklion 7942c7f
refactor: Reuse existing helpers in the override layer, sink, and cli…
kinyoklion 27aa6a8
fix: Read the override layer before the store on an uninitialized cli…
kinyoklion File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
108 changes: 108 additions & 0 deletions
108
packages/shared/sdk-server/__tests__/LDClientImpl.overrideVectors.test.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| import * as fs from 'fs'; | ||
| import * as path from 'path'; | ||
|
|
||
| import { | ||
| fdv2FullPayload, | ||
| makeFDv2Client, | ||
| makeFDv2Platform, | ||
| singleValueFlag, | ||
| } from './overrides/overridesTestSupport'; | ||
| import TestOverrideSource from './overrides/TestOverrideSource'; | ||
|
|
||
| // These vectors come from the OVERRIDE specification. Each vector sets up LaunchDarkly data, an | ||
| // override layer, and an initialization state. The test evaluates one flag through the full | ||
| // client stack and checks the value, the variation index, and the reason. | ||
| const vectorsPath = path.join(__dirname, 'overrides', 'override-vectors', 'vectors.json'); | ||
|
|
||
| // The vectors' semantics are versioned. A schema change means this runner needs review. | ||
| const supportedVectorSchema = '0.4.0'; | ||
|
|
||
| interface OverrideVector { | ||
| description: string; | ||
| group: string; | ||
| launchDarklyData: { | ||
| initialized: boolean; | ||
| flags: Record<string, any>; | ||
| segments: Record<string, any>; | ||
| }; | ||
| overrides: { | ||
| flags?: Record<string, any>; | ||
| flagValues?: Record<string, any>; | ||
| segments?: Record<string, any>; | ||
| }; | ||
| evaluate: { | ||
| flagKey: string; | ||
| context: any; | ||
| defaultValue: any; | ||
| }; | ||
| expect: { | ||
| value: any; | ||
| variationIndex: number | null; | ||
| reason: Record<string, any>; | ||
| summaryOverrideAffected?: boolean; | ||
| }; | ||
| } | ||
|
|
||
| const file: { schemaVersion: string; vectors: OverrideVector[] } = JSON.parse( | ||
| fs.readFileSync(vectorsPath, 'utf8'), | ||
| ); | ||
|
|
||
| it('uses the supported vector schema', () => { | ||
| expect(file.schemaVersion).toEqual(supportedVectorSchema); | ||
| expect(file.vectors.length).toBeGreaterThan(0); | ||
| }); | ||
|
|
||
| describe.each( | ||
| file.vectors.map((vector) => [`${vector.group}: ${vector.description}`, vector] as const), | ||
| )('%s', (_name, vector) => { | ||
| it('evaluates as the vector expects', async () => { | ||
| // The override layer is the same document shape the file-based source accepts. A flag value | ||
| // entry expands into a full flag that is on and serves the value by fallthrough. | ||
| const source = new TestOverrideSource({ | ||
| flags: [ | ||
| ...Object.values(vector.overrides.flags ?? {}), | ||
| ...Object.entries(vector.overrides.flagValues ?? {}).map(([key, value]) => | ||
| singleValueFlag(key, value), | ||
| ), | ||
| ], | ||
| segments: Object.values(vector.overrides.segments ?? {}), | ||
| }); | ||
| const platform = vector.launchDarklyData.initialized | ||
| ? makeFDv2Platform( | ||
| fdv2FullPayload(vector.launchDarklyData.flags, vector.launchDarklyData.segments), | ||
| ) | ||
| : makeFDv2Platform(); | ||
| const client = makeFDv2Client(platform, { dataSystem: { overrides: source } }); | ||
| try { | ||
| if (vector.launchDarklyData.initialized) { | ||
| await client.waitForInitialization({ timeout: 5 }); | ||
| } | ||
|
|
||
| const detail = await client.variationDetail( | ||
| vector.evaluate.flagKey, | ||
| vector.evaluate.context, | ||
| vector.evaluate.defaultValue, | ||
| ); | ||
|
|
||
| expect(detail.value).toEqual(vector.expect.value); | ||
| if (vector.expect.variationIndex === null) { | ||
| expect(detail.variationIndex ?? null).toBeNull(); | ||
| } else { | ||
| expect(detail.variationIndex).toEqual(vector.expect.variationIndex); | ||
| } | ||
|
|
||
| // The reason is compared only on the fields the vector lists. The override indicator | ||
| // collapses tri-state: an expected reason that omits it requires the actual reason to | ||
| // report false or to omit it. | ||
| const actualReason = detail.reason as Record<string, any>; | ||
| Object.entries(vector.expect.reason).forEach(([field, expected]) => { | ||
| expect(actualReason[field]).toEqual(expected); | ||
| }); | ||
| if (!('overrideAffected' in vector.expect.reason)) { | ||
| expect(actualReason.overrideAffected ?? false).toBe(false); | ||
| } | ||
| } finally { | ||
| client.close(); | ||
| } | ||
| }); | ||
| }); | ||
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.