Lesson 0005 · ~12 minutes · synthesis
One skill: given a feature brief, write a complete transport choice — protocol, client API, resume policy, and one risk you own.
This is the durable skill from MISSION.md: defend a realtime choice in a design review without hand-waving.
Run in order. Earlier gates reject more options than later ones.
Poll if rare/stale OK. SSE-family if server→client text. WebSocket if continuous duplex or binary on the pipe. (Lesson 1)
Native EventSource if GET + cookies/no custom headers.
Else fetch stream (same wire possible). (Lessons
2,
4)
Gaps OK → reconnect (+ snapshots). Gapless →
id + Last-Event-ID + server log. (Lesson
3)
“We use X because direction, client EventSource|fetch because auth/method, resume gap-ok|Last-Event-ID, and we own one ops risk.”
Keep the print playbook open after this course — it is the compressed form of all five lessons.
Pick the best default package (transport + client + resume). Equal-length options.
Internal tool, same origin, cookie session. Order status updates every few seconds. Missed updates during a 3s blip are fine if the next event is current. Many agents leave tabs open all day. HTTP/2 available.
User submits a long prompt (JSON). API requires
Authorization: Bearer. Model streams tokens for ~30s
one way. After the run ends, no long-lived connection.
Agents and customers exchange messages live. Typing indicators both ways. Presence “online”. Mobile clients stay on flaky networks.
Regulated UI must show every status transition in order. Cookie auth, same origin, one-way. After reconnect, no silent gaps allowed.
Homepage shows “N signups today.” Backend updates hourly. Slightly stale is fine. Public CDN, no auth.
SPA opens one SSE per page on HTTP/1.1. With several tabs, all REST calls queue and the UI feels dead until a tab closes. Best fix class?
Without scrolling up, answer mentally — then expand.
It will try to reconnect (unless CLOSED) and may send
Last-Event-ID if it saw an id. It does
not guarantee the server replays missed events.
When you need custom headers, POST body, or non-GET to start the
stream — use fetch streaming (wire can still be
text/event-stream).
~6 connections per origin; each SSE holds one; other requests stall (Lawrence / WHATWG authoring notes).
Re-skim the WHATWG SSE introduction + authoring notes as the normative spine. Your print companion is decision-playbook.html.