Lesson 0005 · ~12 minutes · synthesis

Ship the decision, not the buzzword

One skill: given a feature brief, write a complete transport choice — protocol, client API, resume policy, and one risk you own.

Mission payoff

This is the durable skill from MISSION.md: defend a realtime choice in a design review without hand-waving.

1. The playbook (four gates)

Run in order. Earlier gates reject more options than later ones.

Gate A · Direction

Poll if rare/stale OK. SSE-family if server→client text. WebSocket if continuous duplex or binary on the pipe. (Lesson 1)

Gate B · Client API

Native EventSource if GET + cookies/no custom headers. Else fetch stream (same wire possible). (Lessons 2, 4)

Gate C · Resume

Gaps OK → reconnect (+ snapshots). Gapless → id + Last-Event-ID + server log. (Lesson 3)

Gate D · Ops

Proxy flush, heartbeats, h1 vs h2 connection budget, multi-tab, close() on unmount. (Lesson 4; Lawrence)

Sentence you should be able to say

“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.

2. Practice — full briefs

Pick the best default package (transport + client + resume). Equal-length options.

Brief A · Ops dashboard

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.

Brief B · AI assistant

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.

Brief C · Support chat

Agents and customers exchange messages live. Typing indicators both ways. Presence “online”. Mobile clients stay on flaky networks.

Brief D · Compliance feed

Regulated UI must show every status transition in order. Cookie auth, same origin, one-way. After reconnect, no silent gaps allowed.

Brief E · Marketing badge

Homepage shows “N signups today.” Backend updates hourly. Slightly stale is fine. Public CDN, no auth.

Brief F · Incident (Lawrence)

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?

3. Self-check (retrieval)

Without scrolling up, answer mentally — then expand.

What does the browser guarantee on reconnect?

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 is native EventSource the wrong client?

When you need custom headers, POST body, or non-GET to start the stream — use fetch streaming (wire can still be text/event-stream).

Name one h1 multi-tab failure mode.

~6 connections per origin; each SSE holds one; other requests stall (Lawrence / WHATWG authoring notes).

4. What you can do now

Ask your teacher Paste a real feature from work (or an interview prompt). We will run the four gates on it together — that is how this becomes wisdom, not only fluency.

Primary source (course spine)

Re-skim the WHATWG SSE introduction + authoring notes as the normative spine. Your print companion is decision-playbook.html.