Skip to content

feat: add internal BigSegmentStoreWrapper with caching and status polling#543

Merged
beekld merged 10 commits into
mainfrom
beeklimt/SDK-2365
Jun 5, 2026
Merged

feat: add internal BigSegmentStoreWrapper with caching and status polling#543
beekld merged 10 commits into
mainfrom
beeklimt/SDK-2365

Conversation

@beekld
Copy link
Copy Markdown
Contributor

@beekld beekld commented Jun 2, 2026

Summary

Internal layer between the evaluator and a customer-provided
IBigSegmentStore: hashes context keys, caches membership lookups, polls the
store's metadata in the background to track availability/staleness, and
broadcasts status changes. No caller yet — the evaluator and the public status
provider come later in the stack.

Design notes

  • Context keys are hashed to base64(sha256(key)) using the standard base64
    alphabet (not the existing URL-safe Base64UrlEncode), so the lookup key
    matches what the Relay Proxy writes.
  • Concurrent misses for the same key coalesce into a single store query rather
    than each hitting the store.
  • The background poll is built on async::Delay + CancellationSource.
  • A store error encountered during a membership lookup flips the store status to
    unavailable. The spec requires this; the Java and Go SDKs don't do it, so this
    is a deliberate divergence.
  • Changes StoreMetadata::last_up_to_date from a bare milliseconds to a
    system_clock::time_point, so staleness math can't mix epochs. This touches
    the Redis and DynamoDB stores (one line each) and their metadata tests.

Test plan

  • Added unit tests
  • Full server-sdk suite green (499/499)
  • DynamoDB source suite green (40/40) against DynamoDB Local
  • Redis source suite green (37/37) against a live Redis

Note

Medium Risk
Changes the public IBigSegmentStore contract (noexcept, StoreMetadata type) and adds threaded/async polling plus store-error handling that affects how staleness and availability are reported; evaluator is not wired yet, limiting immediate eval impact.

Overview
Adds BigSegmentStoreWrapper, the internal layer in front of IBigSegmentStore: hashes context keys as base64(sha256(key)) via new Base64Encode (RFC 4648, not URL-safe), uses an LRU/TTL MembershipCache, coalesces concurrent lookups for the same key, polls metadata on a timer for availability/staleness, and broadcasts status changes. Membership lookups return BigSegmentsStatus (healthy/stale/store error); a failed lookup marks the store unavailable (per spec).

StoreMetadata::last_up_to_date is now a system_clock::time_point instead of raw milliseconds; Redis and DynamoDB stores and their tests are updated accordingly. IBigSegmentStore::GetMembership / GetMetadata are noexcept, with DynamoDB wrapping AWS calls in try/catch.

Supporting pieces: big_segments_status.hpp, #include <variant> in promise.hpp, and unit tests for the wrapper, cache, and standard base64.

Reviewed by Cursor Bugbot for commit 0b492dd. Bugbot is set up for automated code reviews on this repo. Configure here.

Base automatically changed from beeklimt/SDK-2364 to main June 2, 2026 17:05
@beekld beekld force-pushed the beeklimt/SDK-2365 branch from f03dd53 to 35fb2ae Compare June 2, 2026 17:12
@beekld beekld marked this pull request as ready for review June 2, 2026 17:38
@beekld beekld requested a review from a team as a code owner June 2, 2026 17:38
@kinyoklion
Copy link
Copy Markdown
Member

A store error encountered during a membership lookup flips the store status to
unavailable. The spec requires this; the Java and Go SDKs don't do it, so this
is a deliberate divergence.

We'll want to determine if we should update the spec here or the implementations. It does sound reasonably though.

Comment thread libs/server-sdk/src/data_components/big_segments/big_segment_store_wrapper.hpp Outdated
Comment thread libs/server-sdk-dynamodb-source/src/dynamodb_big_segment_store.cpp
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

❌ 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 c13f1d8. Configure here.

@beekld
Copy link
Copy Markdown
Contributor Author

beekld commented Jun 5, 2026

A store error encountered during a membership lookup flips the store status to
unavailable. The spec requires this; the Java and Go SDKs don't do it, so this
is a deliberate divergence.

We'll want to determine if we should update the spec here or the implementations. It does sound reasonably though.

I've added it to the list of follow-ups where java and the spec aren't in alignment.

@beekld beekld merged commit 47fa5c2 into main Jun 5, 2026
47 checks passed
@beekld beekld deleted the beeklimt/SDK-2365 branch June 5, 2026 17:54
@github-actions github-actions Bot mentioned this pull request Jun 5, 2026
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