Skip to content

feat: a shared store with no durable medium - #180

Open
sea-snake wants to merge 10 commits into
feat/auth-shared-session-docs-v2from
feat/auth-shared-memory-storage
Open

feat: a shared store with no durable medium#180
sea-snake wants to merge 10 commits into
feat/auth-shared-session-docs-v2from
feat/auth-shared-memory-storage

Conversation

@sea-snake

Copy link
Copy Markdown
Contributor

No description provided.

`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
sea-snake marked this pull request as ready for review August 31, 2026 23:14
@sea-snake
sea-snake requested a review from a team as a code owner August 31, 2026 23:14
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.

1 participant