Skip to content

chore: add a requirement to have an optional init option in providers…#74

Open
jsalaber wants to merge 1 commit intoopen-feature:cursor/offline-context-local-storage-4fb5from
jsalaber:cursor/offline-context-local-storage-4fb5
Open

chore: add a requirement to have an optional init option in providers…#74
jsalaber wants to merge 1 commit intoopen-feature:cursor/offline-context-local-storage-4fb5from
jsalaber:cursor/offline-context-local-storage-4fb5

Conversation

@jsalaber
Copy link
Copy Markdown

This PR

  • updated ADR to include an additional requirement for an initialization option for user's to prefix the cache key

@jsalaber jsalaber requested a review from a team as a code owner April 10, 2026 18:20
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the ADR for local storage in static-context providers to include an optional 'persisted-cache key prefix' configuration. This change aims to prevent storage key collisions when multiple provider instances share the same storage partition, such as a single web origin. The feedback focuses on improving the clarity and logical consistency of the document, specifically by refining the description of how the prefix is used during lookup and ensuring it is correctly categorized as a configuration option rather than a static-context input. Additionally, it was noted that the implementation guidelines should be updated to reflect this new requirement.

During initialization, a provider should follow a cache-first approach:

1. Attempt to load a matching persisted bulk evaluation from local storage (matching `cacheKeyHash`).
1. Attempt to load a matching persisted bulk evaluation from local storage (matching `cacheKeyHash`, and the same persisted-cache key prefix the instance was configured with, if any).
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.

medium

The phrasing "matching ... (matching ...)" is redundant. Additionally, since the prefix is used to construct the storage key (as defined in the Decision section), it is more accurate to describe it as being used for the lookup rather than being "matched" against the loaded content.

Suggested improvement:

  1. Attempt to load a persisted bulk evaluation from local storage using the configured persisted-cache key prefix (if any) and the cacheKeyHash.


Providers should only reuse a persisted evaluation when it matches the current static-context inputs.
This includes a matching `cacheKeyHash` equal to `hash(targetingKey)`.
This includes a matching `cacheKeyHash` equal to `hash(targetingKey)` and a persisted-cache key prefix provided in the initialization options.
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.

medium

The persisted-cache key prefix is a configuration option rather than a "static-context input". Grouping it under the requirement that the evaluation "matches the current static-context inputs" (line 141) is logically inconsistent.

Suggested improvement:
This includes a matching cacheKeyHash equal to hash(targetingKey). The lookup must also use the persisted-cache key prefix provided in the initialization options.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I agree I think this might be in the wrong spot.


Providers should allow applications to disable the default persistence behavior, for example with a `disableLocalCache` option, or replace the storage backend when platform requirements or policy constraints require it.

When applications configure **more than one** static-context provider against the same underlying storage (same browser origin, shared app container, and so on), providers should expose an optional **persisted-cache key prefix** (name may vary by SDK, for example `persistedCacheKeyPrefix` or `localCacheKeyPrefix`). Applications set a distinct prefix per provider instance so persisted entries are namespaced and instances do not load or overwrite each other’s bulk evaluations.
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.

medium

Since this ADR now requires providers to expose a persisted-cache key prefix option, the guideline/static-context-provider.md file should be updated to include this in its "Configuration" section to maintain consistency between the decision and the implementation guidelines.

Copy link
Copy Markdown
Member

@toddbaert toddbaert left a comment

Choose a reason for hiding this comment

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

Approved with a nit, up to you if you want to change it.

You will need to do a git commit --amend --signoff && git push -f to fix the DCO issue.

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