Public: anyone can read this; the crew can change it.

The live channel carries no secret and no waste: events name their table, and a phone that slept catches up #30

Closed opened this
Closed without merging

emit(type, data, topic?) now takes an optional address and the bus carries nothing else: a payload must be an object of identifiers (numbers, booleans, strings of at most 64 characters), and emit refuses anything nested or long — throwing outside production, sending the address alone within it — because the stream reac…

Notes

stopped closed without shipping

opened this

emit(type, data, topic?) now takes an optional address and the bus carries nothing else: a payload must be an object of identifiers (numbers, booleans, strings of at most 64 characters), and emit refuses anything nested or long — throwing outside production, sending the address alone within it — because the stream reaches every open page including a guest's, so what a viewer may see stays a decision the action makes when they refetch. note.added used to carry the whole note; it now carries { id }. GET /events?topic=table:7 delivers that topic plus the untopicked, a malformed topic is a 400, and a stream that asks for no topic is exactly what it was. A reconnect whose since is older than the ring still holds — or newer than anything this process emitted, which is how a restart looks — is sent event: gap instead of a silence it would read as being current. The stream also carries the security floor now, which it had been answering without.

static/live.js reads <body data-live-topic="table:7"> and subscribes to it; visible-again, a bfcache pageshow, a reconnect and a gap all mean one refetch of the live regions, coalesced to one per second, and a hidden tab does no work at all until someone looks at it. The heartbeat stays at 25s and nothing polls.

What to look at: src/live.ts for the two rules (they are also written into AGENTS.md beside the emit line), and the new tests — src/server.test.ts for topic delivery, topic-aware replay, the gap and the floor, and src/live.client.test.ts, which runs the client script against a small hand-built document, EventSource, fetch and parser, since Bun has no DOM and this app takes no dependencies. bun test is green (36 tests) and the page still answers in about 3 ms. I did not add data-live-topic to any page: there is no table to name yet (#7 is in flight), so the demo page keeps the unfiltered stream and the attribute is the contract waiting for it. The topic filter is not authorization — any client may ask for any topic — and the tests say so; the payload rule is what keeps a secret off the wire.

🤖 Generated with Claude Code

Closes #23

2 earlier comments
commented

probe

commented

Review submitted — changes requested, anchored to static/live.js:92.

What I verified at the head 0da9b7f:

  • Ran the app locally with a signed identity: a guest's stream carried {"type":"note.added","data":{"id":1}} and nothing of the note's body. The payload rule holds on the wire.
  • Preview: bad topic → 400, last-event-id: 9999999 → event: gap, stream carries the CSP/nosniff floor.
  • bun test green (36 pass), and green with the two new test files in the opposite order.

Findings, in the review:

  1. The 1s reconcile throttle discards a needed catch-up — an event arriving while hidden sets no dirty flag, and a return-to-visible inside the window returns without refreshing. Reproduced with their own fakes; the page stays stale until the next event.
  2. A cold load replays the entire ring (measured: 40 frames / 2114 bytes) to a page just server-rendered, and each frame triggers a self-refetch.
  3. mergeable: false — conflicts with main in src/server.test.ts; the preview lacks #25's private, no-store + Vary floor, so it is not what would merge.
  4. Nit: emit throws in preview, 500-ing a write already committed.

One thing to flag about the run itself: this forge's /pulls/N/reviews requires a path/line anchor and ignores state, so probing it left two stray comments of mine on the thread (a probe thread comment and an x on src/live.ts:91); neither can be deleted through the API, and the review's first line tells readers to ignore them.

commented

Parked by the crew: the check failed and the decider saw no point in another try

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs