Open
Conversation
commit: |
👁️ Cyclops Security Review🧭 Auditing · mode=
⚙️ Controls
📜 7 events🔍 |
ab1aca9 to
347da37
Compare
👁️ Cyclops Security Review🧭 Auditing · mode=
⚙️ Controls
|
Collaborator
Author
|
Refactored Store/AtomicStore to use Viem-style generic slot pattern per @tmm suggestion. Before (structural patching): type Store<itemMap> = { get; put; delete; update?: Update }
type AtomicStore<itemMap> = Omit<Store, "update"> & { update: Update }After (compositional via 2nd generic slot): type StoreActions<itemMap> = { get; put; delete }
type AtomicActions<itemMap> = { update: Update }
type Store<itemMap, extended> = StoreActions<itemMap> & extended
type AtomicStore<itemMap> = Store<itemMap, AtomicActions<itemMap>> |
- Replace ChannelStore symbol hack with optional method on the type - Extract wrapJsonUpdate helper to DRY cloudflare/redis update adapters - Remove dead assertHashUnused (markHashUsed handles atomically) - Simplify releaseHashUse to plain store.delete
…ypes
Instead of AtomicStore = Omit<Store, 'update'> & { update }, use a 2nd
generic slot on Store inspired by Viem's Client<..., extended> pattern:
- Store<itemMap, extended> — base type with compositional extended slot
- AtomicStore<itemMap> = Store<itemMap, AtomicActions<itemMap>>
- StoreActions — base get/put/delete interface
- AtomicActions — update capability, provided via the extended slot
This makes Store extensible for future capabilities (batch, watch, etc.)
without structural patching via Omit.
223db13 to
59bc4e1
Compare
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
Add an atomic
Store.update()primitive and a newAtomicStoretype, then use them to eliminate race conditions in Tempo replay protection and channel state updates.Why
The previous check-then-mark flow for replay protection and channel state mutation could race under concurrent requests or multi-instance deployments. This was an intentional choice at the time, but we now see a larger need for multi-instance deployments so want to add this primitive.
AtomicStoregives store backends a typed atomic primitive and moves all sensitive Tempo paths onto it.Notes
Store.update()is optional at theStoreinterface level but required for Tempo charge/session viaAtomicStore.Store.memory()always returnsAtomicStore.updatemust be synchronous, pure, and retry-safe.