feat: a shared store with no durable medium - #180
Open
sea-snake wants to merge 10 commits into
Open
Conversation
`shared` and `durable` are declared by every credential store and only one of them was ever read, because nothing shipped with `shared: true, durable: false`. The pair read as one axis. `SharedMemoryCredentialStorage` is that store: a `Map`, replicated to the other tabs of this origin over a `BroadcastChannel`. Every write is broadcast and every instance applies what it receives, so a steady-state read stays local — the channel keeps the copies agreeing rather than being asked at the moment of use. A `CryptoKeyPair` crosses as a handle that signs and cannot be exported. For an environment with no durable medium at all, where every tab minting for itself is still worth avoiding. **The cold start has no deadline in it**, which is the part worth reading. A starting instance holds nothing and its peers hold everything, and waiting on silence would mean picking a number that is either too short to save the mint or long enough to be paid by a tab that had no peer at all. So each instance holds a lock under a name only it uses: presence becomes something a starting instance can enumerate rather than infer, and it waits for whichever comes first — an answer, or the grant of a peer's lock, which the browser hands over when that peer is gone rather than slow. An instance with no peers waits for nothing. Where there are no Web Locks every instance starts alone, which costs mints and never correctness. It is its own layer because nothing else in the stack depends on it, and at ~310 implementation lines it was 40% of the storage layer and the reason that layer sat past the size bar. The redirect rule that first distinguishes the two booleans stays with the storage layer, where the case it refuses is reachable. Only the case it allows needs a store like this one, so that test travels here.
sea-snake
marked this pull request as ready for review
August 31, 2026 23:14
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.
No description provided.