Skip to content

fix: memoize v2 flag and segment dependencies - #803

Open
roncohen wants to merge 17 commits into
mainfrom
fix/node-v2-dependency-memoization
Open

roncohen wants to merge 17 commits into
mainfrom
fix/node-v2-dependency-memoization

Conversation

@roncohen

Copy link
Copy Markdown
Contributor

Summary

Stacked on Node SDK v2 adoption #790; this PR targets feature/node-sdk-v2, not main.

  • Memoize full flag results and segment matches/errors/diagnostics in the shared evaluator's existing per-evaluation state. evaluateAll shares results across roots; separate calls and contexts never share cached results.
  • Re-propagate cached errors into every referencing rule, preserving diagnostic provenance/deduplication, fail-closed negation, variant-key matching and rule traces. Keep returned diagnostic/source objects independent between roots.
  • Add regressions for shared flag diamonds, the 17-segment repeated-reference graph, cached failures/unresolved flags, context isolation and equal/falsy variant payloads. Update the existing uncached-behavior assertions/descriptions and add an evaluator patch Changeset.

The 17-segment/two-root regression drops from 131,072 leaf comparisons to one per evaluation. Seven regression cases failed before the fix.

Validation

  • 970 workspace tests pass across ten packages, including 307 evaluator tests and 271 Node SDK tests.
  • 33,280 complete per-flag wire results still match published evaluator 2.0.0 across 80 deterministic mixed acyclic graphs; batch/single-flag results agree.
  • A separate probe with the freshly built Node client confirms one leaf comparison per getFlag or two-root bootstrap call across alternating contexts, using mocked transport with no real network or telemetry.
  • Evaluator/Node builds, both Node compiler programs, strict evaluator/test TypeScript checks, scoped zero-warning lint, formatting, whitespace checks and Changesets release-plan validation pass.
  • Normal commit hooks passed without changing the verified tree.

Scope and release boundary

  • No SDK depth guard: excessive combined graph depth is a separate authoring/publication validation task, per the agreed scope.
  • No refresh scheduling, fallback validation or .NET changes.
  • The Changeset plans @reflag/flag-evaluation@2.0.1; nothing is published by this PR. The separate Node prerelease workflow currently pins evaluator 2.0.0 and must deliberately adopt the published fixed evaluator before a prerelease can ship this fix. Workspace validation alone is not packed-release evidence.

Copilot AI balanced review requested due to automatic review settings November 15, 2026 10:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

Base automatically changed from feature/node-sdk-v2 to main November 18, 2026 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants