refactor: read the flag once per evaluation, in one place - #381
Open
abelonogov-ld wants to merge 2 commits into
Open
refactor: read the flag once per evaluation, in one place#381abelonogov-ld wants to merge 2 commits into
abelonogov-ld wants to merge 2 commits into
Conversation
The ten variation methods each spelled out the same call to the hook runner around the same evaluation, and left the flag read to the evaluation itself. They now collapse onto a helper that does the read, so one place expresses the order of the read, the hooks and the evaluation, and what an evaluation is about to return can be described without reading the store a second time. Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 7efd98c. Configure here.
evaluateWithHooks snapshotted the flag before hooks ran, but variationDetailInternal still re-read the evaluation context when recording events. An identify landing in between left the returned value from the prior context's flag attributed to the new context. Both are now read together and threaded through the evaluation so the series, the result and the events all describe one pair. Co-authored-by: Cursor <cursoragent@cursor.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

The ten variation methods each spelled out the same call to the hook runner around the same evaluation, and left the flag read to the evaluation itself. They now collapse onto a helper that does the read, so one place expresses the order of the read, the hooks and the evaluation, and what an evaluation is about to return can be described without reading the store a second time.
Requirements
Related issues
Provide links to any issues in this repository or elsewhere relating to this pull request.
Describe the solution you've provided
Provide a clear and concise description of what you expect to happen.
Describe alternatives you've considered
Provide a clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context about the pull request here.
Note
Overview
Refactors flag evaluation so all typed
*VariationAPIs go through a newevaluateWithHookshelper instead of duplicatinghookRunner.withEvaluationcalls.Evaluation now snapshots the evaluation context and flag (
getNonDeletedFlag) once before hooks run, then passes those intovariationDetailInternal. Prerequisite walks reuse the same context and fetch each prereq flag at that layer instead of re-reading context inside the evaluator.Intent: one ordered pipeline (read → hooks → evaluate) so a concurrent
identify()cannot swap context mid-call and attribute the wrong context on evaluation events.Reviewed by Cursor Bugbot for commit 6a7de48. Bugbot is set up for automated code reviews on this repo. Configure here.