Skip to content

refactor: drop the hash caching the LRU-cache design needed - #389

Merged
abelonogov-ld merged 5 commits into
mainfrom
andrey/exposure-simplify
Aug 18, 2026
Merged

refactor: drop the hash caching the LRU-cache design needed#389
abelonogov-ld merged 5 commits into
mainfrom
andrey/exposure-simplify

Conversation

@abelonogov-ld

@abelonogov-ld abelonogov-ld commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

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.

  • EvaluationExposureKey no 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.
  • TrackedFlag no longer caches its hash code either. A query TrackedFlag is built fresh per evaluation, so the field was computed eagerly in the constructor and read exactly once, while HashMap already remembers the hashes of the entries it stores. Its equals no longer compares hashes as a fast reject.
  • Experimental notices added to EvaluationExposureKey, EvaluationExposureDeduper, and EvaluationExposureKeySupplier, 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/hashCode themselves stay — the deduper compares whole keys to decide whether a result changed, and TrackedFlag is a map key.

Test plan

  • EvaluationExposureDeduperTest (15 tests) and DedupingHookTest (16 tests) pass
  • Existing coverage already asserts the hashCode contract (equal keys hash alike), which is what the caching removal must preserve
  • CI green

Note

Overview
Removes lazy hash caching on EvaluationExposureKey and TrackedFlag that dated from an LRU-based deduper layout. hashCode() now computes on each call; TrackedFlag.equals no longer uses a cached hash as a fast reject. Deduplication behavior is unchangedequals/hashCode contracts stay the same.

Adds experimental / not semver-stable documentation to the public hook dedupe surface: EvaluationExposureKey, EvaluationExposureDeduper, and EvaluationExposureKeySupplier, 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.

abelonogov-ld and others added 3 commits August 14, 2026 12:52
* 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
abelonogov-ld requested a review from a team as a code owner August 17, 2026 19:37
@abelonogov-ld
abelonogov-ld merged commit c262eee into main Aug 18, 2026
6 checks passed
@abelonogov-ld
abelonogov-ld deleted the andrey/exposure-simplify branch August 18, 2026 17:50
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