Spec review — Claude Fable (model id claude-fable-5-2), read-only against origin/spec/live-push 4ce1a1b
Verdict: APPROVE AFTER FIXES
The direction is right and I would not change it: bytes on the existing SSE stream read from the committed log, send-when-idle with a floor, warm handle, no WebSocket. I checked the load-bearing claims against the code: commit precedes broadcast (ApplyUpdate returns after the transaction, updatesPost broadcasts after), seq is MAX+1 in the single-writer transaction so a reader sees a gapless prefix, the Yjs/yrs wire is untouched, and the raw results match the tables I spot-checked (lat-rtt50, q-p20-rtt50). Findings 1–4 must be fixed in the spec before it becomes a plan; 5–10 should be; the rest are small.
Blocking
1. §3.3 — a warm handle reaches MaxRetainedUpdates and the web then drops the save. (High) core.Handle.Apply appends every accepted update to h.applied and refuses with ErrUpdateLogFull at 4096 (core.go:555). Today that is unreachable because each POST replays into a fresh handle from snapshot + ≤255 rows. A warm handle never resets: at ~6 uploads/s one typist gets there in ~11 minutes of typing, five in ~2. That POST answers 400, which save-queue.mjs treats as a final refusal and drops the batch. "Evict on any error" comes too late for that batch. It also means the handle's memory grows by every update it has seen. The spec must say: re-seed the warm handle (from its own snapshot, as reseedForReplay does) at each snapshot cadence, well under the cap; and a warm-path ErrUpdateLogFull, trap or recovered error falls back to a cold replay inside the same POST instead of failing it. Test: >4096 POSTs to one warm document, none refused.
2. §3.3 — an update applied to the warm handle but not committed poisons it. (High) Apply happens outside the transaction. If the transaction then fails (the in-transaction checkPermission for a writer revoked mid-request, a cancelled request context, a DB error, the team guard), the handle holds bytes that are not in the log, while its seq still equals MAX(seq), so the validity check passes on the next POST. The next cadence snapshot is then written from it, and D5 verifies the candidate against that same handle, so a refused write becomes durable content. "A rejected update leaves the handle usable" is true only for a core rejection. State the rule: any failure after a successful Apply drops the handle; the handle's seq advances only after commit. Test: revoke between apply and commit, then check the next snapshot equals a cold replay.
3. §3.4 / §6 — own is an unverified "you already have this", and adopting it wrongly is silent divergence. (High) A client adopts own N at cursor + 1 without bytes. §6 says a wrong Docs-Stream "starves the forger, the client fetches on the resulting gap", but there is no gap: seq N is exactly next, so the stream that receives own skips the update for good, and later updates that depend on it park invisibly. The risk is ordinary bugs more than forgery (a stale id after a reconnect, the native drainer's "model holds every entry" check being wrong once, two tabs). Make the client able to check it: the header carries <stream id>.<client counter>, own echoes the counter, and the client adopts only for a counter it sent on this stream; anything else is treated as update (fetch). The server should also record the session with the stream id and ignore a header from a different session. Also say which wins on a push stream, own or the POST's Docs-Seq (both are safe under exactly-next, but only one should be specified). Related: the (seq → stream id) entry is recorded after ApplyUpdate commits, so a stream woken by someone else's POST can read row N before the entry exists and send the poster its own bytes. That is harmless for correctness, but on native it costs a fresh-source presentation (25–45 ms at 20 pages) on the typist's main thread during shared editing. Record the entry inside the transaction, before commit.
4. §3.5 / §1.3 cause 7 / question 2 — bye does not fix what Paul will see. (High for the goal, needs Paul) live-updates.mjs closes a visible tab's stream after IDLE_MS = 2 minutes with no local activity and no stream event, and reopens only on activity. So: Paul stops typing for two minutes, types again, and the untouched copy stays stale until he moves the mouse over it. bye across the 5-minute TTL only helps while updates keep arriving. The same holds after any deploy or restart: hub.drain closes every stream and the web reopens only on activity. Question 2 should be put to Paul as the real trade: how long a visible, untouched tab may hold its instance awake (2 minutes today; the Friday-to-Monday hibernation rule is the reason). Options: a longer visible-idle window (say 15–30 minutes), or keep 2 minutes and accept it. Whichever he picks, send bye on drain as well, with a jittered reopen, so a deploy does not strand watchers.
Should fix
5. §3.1 — fetch fallback and frames interleave without a stated rule. (Medium) After update 43 (oversized) the server will send push 44 straight behind it while the client's ?since=42 fetch is in flight. Specify: one fetch in flight; frames that arrive meanwhile queue and are re-checked against the cursor when it lands (drop ≤ cursor, apply cursor + 1, otherwise one more fetch). Specify the server side too: after an update fallback its sent moves to that seq. Without this, both clients will invent their own rule and one will double-fetch or stall.
6. §3.1 — a cursor ahead of the log is undetectable. (Medium) If the log is ever behind the client (database restored from a backup, a team re-provisioned, version restore later), since=N with N > MAX(seq) sends nothing and the client drops new rows as "≤ cursor". Put the server's current seq in hello; a client whose cursor is greater resyncs from 0. Also state that Last-Event-ID beats since when both arrive, and do not put id: on update frames (the bytes were not delivered).
7. §7 — new client, old server is not "only more POSTs". (Medium) It is the "send at once, fetch" row of §4: ~1.8× server CPU, more GETs per watcher, and the web's own-echo fetches. That combination is real, not just a rollback case: one native build talks to every team's instance, including lagged ones. Rule: the client uses the 50 ms floor only on a stream that said hello; otherwise it keeps 250 ms. State also that hello and bye are sent only on push=1 streams.
8. §3.3 / §5 — warm-handle memory is not measured or bounded in bytes. (Medium) "64 handles, LRU" bounds a count. Each handle is a WASM instance whose linear memory grows and does not shrink, plus applied. The quoted 64–127 MB heap is from runs without warm handles. Measure resident size per warm handle at 1 and 20 pages and cap by bytes. Also: drop the handle on delete, restore, team or seal change (a sealed document's plaintext otherwise stays resident for 60 s after access changes); and say how the 60 s eviction works with hibernation (stream.go deliberately has no timer outside a live connection; evict lazily on the next POST plus one sweep, and let shutdown close them).
9. §4 — the two central cost claims are projections, and the worst case was not run. (Medium) No run includes a warm handle or a push frame. "About today's CPU" is arithmetic (and comes out ~15% over today, inside the ±20%). "Key → announced" stands in for push but leaves out what push adds per watcher per notification: the session re-check, a log read, opening sealed rows, base64. Every load run puts each typist in their own document with one watcher; the case that stresses this design is several typists and several watchers in one document (N streams each re-reading and re-opening the same rows). Each cell is one run of 200 keys, so p95 is ten samples, on a machine at load 10–970 (load-p1 rtt0 shows POST p50 at 37–43 ms against 7 ms in the quiet run). The numbers are good enough to choose the design; they are not evidence that the targets are met. Make slice 1 re-run load-p1/load-p20 plus a 5-typists-5-watchers-one-document case with the real implementation, and make question 4 (a stream and a POST through the real edge) a condition of calling slice 2 done, since edge buffering is still unverified.
10. §8 — the latency gate as written will flake or go false green. (Medium) Absolute thresholds (p50 ≤ 50 ms, p95 ≤ 100 ms) on a shared CI runner cannot hold, and a gate that is retried or skipped under load is the false-green pattern we have had before. The gate test does not exist yet (the probes are multi-process, env-gated, and use Node-built updates). Split it:
- CI, deterministic: fake-clock tests that a key after idle is sent with zero wait and coalesces while in flight (JS and Swift); a Go test that one POST yields exactly one flushed
pushframe per watcher with no GET, andownfor the poster; uploads ≤ 1.2 × keys. - CI, timing: server-added time only (measured minus injected RTT), compared with a baseline measured in the same process, best of three; it fails, never skips.
- Release step:
run-clients.shagainst the §2 targets with real web and native clients, result file committed beside the release, and it refuses to record a run above a stated load average.
11. §5 — late answers need bounds. (Medium-low) Safe against the clients' timeouts only if stated: delay before taking the document lock or the writer (never while holding either), capped at ~1 s, ended by request cancel and hub.draining(), and with a limit on how many answers one session may have waiting (beyond it, 503 with Retry-After, which the web queue retries; never a 4xx). Without the last, the rail turns a hostile client into held goroutines.
12. §9 — split slice 1 and add switches. (Medium-low) Slice 1 puts a change to the durable write path (warm handle) in the same deploy as the stream. Ship the warm handle first on its own, with the warm-equals-cold property test and findings 1–2, behind an environment switch; then the stream. A server switch that ignores push=1 is free given §7's matrix and turns every client back to today's path without a release. The web's leading-edge send arrives with the server's deploy, so order the commits so it cannot go live before the push stream has been checked on production.
Minor
- §3.1: with W watchers each notification does W identical reads and W unseals. Measure under finding 9 before adding a cache.
- §5 storage: rows are sealed in production, so a row costs well over 30 bytes; the rate roughly doubles and compaction is still deferred. Give the real per-row figure.
- §3.7: treat
isConstrained(Low Data Mode) likeisExpensive. - §3.3: two processes on one database (a deploy overlap) stay correct because validity is checked in the transaction; say so, and note that a stream on the old process hears nothing until drained.
- §8: add tests for a reader's stream (receives frames, cannot post), for access revoked between two frames, and for an old native parser against a
push=1-less stream on the new server. - Restore
RealtimeAuditE2ETests.testEndToEndRemoteUpdates(n=0 since S1a) before native work starts; it is the existing end-to-end check.
For Paul
Questions 1 and 3 are fine as recommended. Question 2 needs rewording per finding 4. Question 4 should be a yes: two minutes on the real edge is the one measurement nobody else can take.