refactor: drop the hash caching the LRU-cache design needed - #389
Merged
Conversation
* main: feat: add HookDecorator so a hook wrapper forwards the stages it does not override
Left from when the deduper held exposure keys in an LRU cache. A query TrackedFlag is built fresh per evaluation, so the field was computed eagerly in the constructor and read once, while HashMap already remembers the hash of the entries it stores. Its equals no longer compares hashes as a fast reject. Co-authored-by: Cursor <cursoragent@cursor.com>
abelonogov-ld
enabled auto-merge
August 18, 2026 17:14
tanderson-ld
approved these changes
Aug 18, 2026
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.
Summary
Cleans up two micro-optimizations left over from when the deduper held exposure keys in an LRU cache, and marks the remaining public surface of the feature experimental.
EvaluationExposureKeyno longer caches its hash code. The SDK's deduper recognizes a repeat by the flag a key belongs to and the result it describes, so it never hashes a whole key. The lazily-cached field, its benign-race comment, and the "hash is computed once" doc claim are gone;hashCode()now just computes.TrackedFlagno longer caches its hash code either. A queryTrackedFlagis built fresh per evaluation, so the field was computed eagerly in the constructor and read exactly once, whileHashMapalready remembers the hashes of the entries it stores. Itsequalsno longer compares hashes as a fast reject.EvaluationExposureKey,EvaluationExposureDeduper, andEvaluationExposureKeySupplier, so every public API in this feature carries one. The two on the key and the deduper say why it matters: which components make up the identity of an evaluation is the likeliest thing to be revised, and a deduper subclass reasoning about them may have to change with it.equals/hashCodethemselves stay — the deduper compares whole keys to decide whether a result changed, andTrackedFlagis a map key.Test plan
EvaluationExposureDeduperTest(15 tests) andDedupingHookTest(16 tests) passhashCodecontract (equal keys hash alike), which is what the caching removal must preserveNote
Overview
Removes lazy hash caching on
EvaluationExposureKeyandTrackedFlagthat dated from an LRU-based deduper layout.hashCode()now computes on each call;TrackedFlag.equalsno longer uses a cached hash as a fast reject. Deduplication behavior is unchanged—equals/hashCodecontracts stay the same.Adds experimental / not semver-stable documentation to the public hook dedupe surface:
EvaluationExposureKey,EvaluationExposureDeduper, andEvaluationExposureKeySupplier, including notes that evaluation identity fields and subclassing may change.Reviewed by Cursor Bugbot for commit 256e625. Bugbot is set up for automated code reviews on this repo. Configure here.