Private doorbell client: row-bearing dings on gated channels + live layer re-land - #20
Merged
Merged
Conversation
…ayer re-land The SDK half of the platform's private realtime doorbell (codehs/bool#570). realtime.ts owns the wristband lifecycle with injected deps (fully unit-tested, no sockets): mint from the gateway's /_bool/v1/realtime/token (which re-runs liveAccess/session on every mint — THE access decision), setAuth, join the private app room + personal user room (audiences are disjoint by trigger construction, so no dedupe), re-mint at 75% TTL, and degrade to the legacy public row-data-free ping whenever the private path is unavailable: no desk (older platform), refused mint (revoked access — the TTL is the revocation window), or refused join. A generation counter orphans in-flight async work on teardown so a late mint can never resurrect channels. Re-lands the live layer from preserve/live-entities exactly as reverted in next.23, now on the architecture it was built for: private dings carry `row`, so LiveEntityStore applies them with zero fetches; id-only dings keep the keyed-fetch path through the gateway (RLS answers per viewer). Plus the fix the revert postponed: leading-edge coalescing, so a lone change reconciles immediately instead of eating the 50ms burst window. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
The SDK half of codehs/bool#570. Live updates arrive with the row on a private channel — one socket hop, ~0–3ms after commit (measured in #570's e2e).
What's here
realtime.ts— the wristband lifecycle, all deps injected (10 tests, zero sockets): mint →setAuth→ join private app + user rooms → re-mint at 75% TTL. Every unavailable/refused state degrades to the legacy public row-free ping: no mint desk (older platform), refused re-mint (revoked access — the TTL is the revocation window), refused join. A generation counter orphans in-flight async work on teardown. One doorbell shared by all subscribers.preserve/live-entities(useEntity,LiveEntityStore,matchesFilter,compareBySort, registry fix) — unchanged from the next.23 revert, now on the architecture it was built for:row-bearing dings apply with zero fetches; id-only dings keep the gateway keyed-fetch (RLS answers per viewer).Compatibility
latest(0.1.1) untouched; ships to thenextcanary as 0.2.0-next.24.Testing
150 pass / 0 fail,
tsc --noEmitclean. New: 10 doorbell lifecycle tests, 2 leading-edge coalescing tests, 1 wiring test (mint URL + credentials + orphaned teardown), 26 live-layer tests re-landed.🤖 Generated with Claude Code