Skip to content

Private doorbell client: row-bearing dings on gated channels + live layer re-land - #20

Merged
HomemadeToast57 merged 1 commit into
mainfrom
jack/private-realtime-client
Jul 27, 2026
Merged

Private doorbell client: row-bearing dings on gated channels + live layer re-land#20
HomemadeToast57 merged 1 commit into
mainfrom
jack/private-realtime-client

Conversation

@HomemadeToast57

Copy link
Copy Markdown
Collaborator

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.
  • Live layer re-landed from 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).
  • Leading-edge coalescing — a lone change reconciles immediately; bursts still collapse into one pass per window. (The trailing window taxed every single change 50ms.)

Compatibility

  • Old platform + new SDK: mint 404s/503s → legacy public ping, exactly today's behavior.
  • New platform + old SDK: frozen bundles keep hearing the compat public ping #570's trigger still sends.
  • latest (0.1.1) untouched; ships to the next canary as 0.2.0-next.24.

Testing

150 pass / 0 fail, tsc --noEmit clean. 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

…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>
@HomemadeToast57
HomemadeToast57 merged commit 709b58a into main Jul 27, 2026
3 checks passed
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