Skip to content

fix: memoize v2 flag and segment dependencies - #803

Merged
roncohen merged 2 commits into
mainfrom
fix/node-v2-dependency-memoization
Nov 28, 2026
Merged

roncohen merged 2 commits into
mainfrom
fix/node-v2-dependency-memoization

Conversation

@roncohen

@roncohen roncohen commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Memoize flag and segment results within each evaluation in @reflag/flag-evaluation. Without memoization, segments and flags that are referenced more than once are evaluated again at every reference. In a chain of 17 segments where each one references the previous segment twice, a single flag read performs 65,536 leaf comparisons.

  • Batch evaluation (evaluateAll) shares cached results across roots. Separate calls and contexts never share them, and there is no process-wide cache.
  • Cached errors still propagate to every rule that references them, and fail closed. Variant-key matching and rule traces are unchanged.
  • A flag-evaluation patch changeset releases this as 2.0.1. Changesets updates @reflag/node-sdk@2.0.0 to depend on it.

Rebased onto current main as this single commit. The earlier Node SDK v2 history on this branch was already squash-merged into main.

Validation

  • @reflag/flag-evaluation: 307 tests pass. @reflag/node-sdk: 288 tests pass.
  • Release-script tests pass (25). changeset status plans flag-evaluation 2.0.1 alongside the six 2.0.0 packages.

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
@roncohen
roncohen force-pushed the fix/node-v2-dependency-memoization branch from 012fe9a to a4504fa Compare November 28, 2026 11:48
@roncohen
roncohen enabled auto-merge November 28, 2026 11:48

@reflag-review reflag-review 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

no actionable findings

@roncohen
roncohen added this pull request to the merge queue Nov 28, 2026
Merged via the queue into main with commit a1bd963 Nov 28, 2026
9 checks passed
@roncohen
roncohen deleted the fix/node-v2-dependency-memoization branch November 28, 2026 12:38
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