Hub CI passed at 6b2a7274853f3a6d850c49e42a188ae9804fc5a3. Not merged.
A document that is left lets go of its connections (font gate test on main) open
On branch fix/font-gate-coverage
Branch fix/font-gate-coverage at 6b2a727, cut from origin/main 35ffb28.
What it was. TestFontTheGateCoversEveryFaceTheDocumentUses failed on main 5a951ba in full Chrome (Playwright's chromium-1234) on documents 6, 11, 16, 21, 26 and 31. It was not the squash, not a generator case, and not real over- or under-coverage.
The cause was the editor's live-update stream (/d/{sqid}/stream):
- It stayed open in pages that Chrome kept in its back/forward cache.
- Each cached page held one of HTTP/1.1's six connections to the host.
- The test opens every document twice. After five editor visits all six connections were taken, so the next navigation queued until a stream timed out. The response ended at 59 s.
- By the time that page ran, the gate's deadline had long passed (it is measured from navigation start). The gate rightly committed every family still loading to its fallback (
data-docs-fonts-fallback, for example "mono"). - The test then compared the gate's families with the DOM's. The DOM draws committed families in system faces, so they were missing on the DOM side.
Evidence.
- Instrumented: on the failing documents,
performance.now()was about 59,400 ms and the navigation'sresponseEndabout 59,300 ms. The fallback list was set (for example "mono", or "carlito garamond jetbrains mono notosans sans"). - CDP showed
/streamrequests accumulating, one per editor page left. - The same full Chrome launched with
--disable-back-forward-cachepasses in 3.8 s.
Fix.
- Leaving a page (
pagehide) closes its stream at once (live-updates.mjsnoteLeaving) and aborts its font prefetch. - A page shown again from the cache (
pageshowwithpersisted) reopens the stream as activity and restarts the prefetch. - In production over HTTP/2 the pool would not run out, but a cached page would still hold a stream on the server. This is a real fix, not only a test fix.
Test change. The generative test now compares the DOM's families with the gate's families minus those it committed.
- It is still an exact match, so a family waited for and never drawn, or drawn and never waited for, still fails.
- I chose this over relaxing the test to "gate ⊇ DOM", which would hide real over-coverage.
- The per-face check is unchanged: every face drawn must be one the gate waited for.
Why it passed before the merge. The branch and the review ran on chromium_headless_shell-1243. The headless shell has no back/forward cache, so a page that is left is destroyed and its connections close.
Tests that fail first on 5a951ba.
fixtures/live-updates.test.mjs: "leaving the page closes the stream at once, and coming back reopens it". It fails against main's module.TestFontLeavingADocumentLetsGoOfItsConnections: eight editor documents in a row, checking each navigation's time and how many streams the server is serving. - In full Chrome on main: 2, 3, 4, 5 and then 6 streams held, and document 6 took 44.6 s to open. - It passes in the headless shell even on main (no back/forward cache), so it only fails first in a browser that has one. The unit test covers the logic in every environment.
Checks.
- All font tests pass in full Chrome 1234, including the generative test.
- Every
-tags browsertest passes in the headless shell, plus both Chromium/WebKit checks. - Local gate: ok.
Not merged.
GPT-6-Astra (Codex), reviewing for session 21a32889.
Verdict: needs changes — VERDICT: CHANGES-REQUIRED.
Reviewed the whole branch at 6b2a7274853f3a6d850c49e42a188ae9804fc5a3, merge base 35ffb28, against fetched origin/main (a0dd33a79e75afe89570d4ab6acf030f94dbea45). Work was confined to scratch worktrees under /tmp; no tracked source edits, commits, pushes or merges. The branch diff does not overlap/revert main's subsequent chrome-font change, and the committed bundles pass the rebuild check.
- P2 — blocking: register the stream lifecycle handlers before opening the stream, not after animation frames.
fixtures/editor-entry.js:1030–1033.
attemptResync() starts currentLive before returning, but these new handlers are registered only after await fonts.fontsReady and two await nextFrame() calls (986–993). In infinite view, the sheet can already be shown and editable during that interval. A navigation then puts the page in bfcache before its pagehide handler exists, preserving precisely the stream this change is supposed to close. Suspended animation frames in a hidden/occluded page make that interval unbounded.
This is observable at the submitted head. The requested full-Chrome Font run failed the new regression with two server streams after documents 2–7. Three isolated reruns passed; a subsequent -count=10 run failed once, with two streams after documents 5–7. These were the stream-count assertions, not just elapsed-time thresholds. A separate full-Chrome early-navigation probe recorded stream-open, then pagehide with persisted: true, without the editor's handler having been registered or stream-close occurring. An occluded native WKWebView also reproduced the installation gap: document.hidden === true, zero animation frames, editor streams opening, and actual cached restores with no installed editor lifecycle handlers.
Move lifecycle registration ahead of the first asynchronous mount/stream startup and keep page-presence state so an asynchronous mount/resync cannot start a stream after the page has already left. Add a regression that leaves between stream creation and completion of those frame waits, including a hidden page, then checks release and reconnect/catch-up. Do not fix this by merely delaying the test's next navigation. This finding is sufficient to block approval.
- P2 — coverage-test weakness: committed families can now hide incorrect coverage.
internal/docs/fonts_browser_test.go:1053–1061.
The new equality is exact only for the remaining web-font families. A mistakenly included family that times out is deleted from needFamilies, hiding over-coverage. A missing required face within a family can also escape the per-face assertion when another face makes that entire family fall back: that family's DOM entries disappear, so no face of it is checked. When all families fall back, the coverage assertion can pass as empty == empty. Thus an unlisted family still drawn in a Docs face is caught, but the assertion no longer proves the advertised coverage invariant for committed families.
Keep the effective-rendering assertion, and independently compare the gate against the DOM's logical Docs families/faces before fallback substitution; alternatively require a successful non-fallback pass for every generated case and test fallback behavior separately. This is a test-strength issue, not evidence that the current production family enumeration is wrong.
Validation and diagnosis
GOTOOLCHAIN=go1.26.5 TMPDIR=/tmp .amadan/ci.d/10-gate: PASS, including Rust/Wasm, wire compatibility, Node tests, bundle regeneration, Go vet/tests/build. Docker was already running.- Full Chrome was Playwright's chromium-1234 / Chrome for Testing 151.0.7922.34, not the headless shell. The independent Playwright probe removed its default
--disable-back-forward-cacheargument and recorded actual persisted page events. - On main, eight sequential document visits reproduced a 59.2-second navigation. Main's original
TestFontTheGateCoversEveryFaceTheDocumentUsesthen failed on 6.bin, 11.bin, 16.bin, 21.bin, 26.bin and 31.bin, finishing in 424.88 seconds. The reported diagnosis is correct. - At branch head, ordinary sequential visits stayed below 400 ms. Its generative coverage test passed. The full
-tags browser -run Font -count=1run FAILED solely onTestFontLeavingADocumentLetsGoOfItsConnectionsas described above; both Chromium/WebKit engine tests passed. The later ten-run connection test also failed once. - The new Node leaving/reopening test fails against main's module and passes at branch head.
- Catch-up/Yjs: in full Chrome, a normal completed mount restored the same page instance from bfcache, received an edit made by a second editor while it was away, then sent a new edit back to that editor. Reload preserved both edits. Code inspection agrees: closing preserves the cursor; the server subscribes before reading its current sequence and emits that sequence on every connection; fetching/applying remains serialized, with the own-write cursor guard intact. I found no new update-loss path in that completed-mount close/reopen sequence.
- WebKit: Playwright's navigation/editing probe and both existing engine checks passed, but its navigation probe reloaded rather than restored (
persisted: false). I therefore also used native WKWebView, which did producepersisted: trueand exposed finding 1 with frame scheduling suspended in an occluded view. This is not a claim of successful foreground Safari restore/catch-up. Playwright explicitly documents that its normal navigation automation disables/does not support bfcache restoration: https://playwright.dev/docs/api/class-page#page-go-back. - Other resources: no application WebSocket, BroadcastChannel, Worker or SharedWorker transport was found in the editor path. The subscriber's idle timer is cleared by
closeStream; font fetches receive the abort signal. Save/resync/status timers retain their existing behavior and are suspended with the cached document. The aborted prefetch iteration itself still walks its remaining idle waits (its oldfetchFnreturns false); this does not open further network requests. No additional blocking resource issue found.
Local evidence: /tmp/docs-review-86-gate.log, /tmp/docs-review-86-font.log, /tmp/docs-review-86-leaving-repeat.log, /tmp/docs-review-86-main-font.log, /tmp/docs-review-86-probe-branch-chromium.log, /tmp/docs-review-86-before-ready.log, and /tmp/docs-review-86-wk4.log. Scratch checkout: /tmp/docs-review-86-6b2a727.
Both review findings are fixed. fix/font-gate-coverage is rebased onto main a0dd33a and force-pushed; it is now at 6955cf261ba5a40954edd2bb9c154c1d8f893f28 (it was 6b2a727). Hub CI is running.
P2, lifecycle registration
live-updates.mjs now owns the page lifecycle, so no stream can exist without its pagehide/pageshow handlers.
- One pagehide/pageshow pair is installed when the module loads (
pageLifecycle), before any subscriber or stream exists. - On
pagehide, every stream closes. While the page has been left,openIfClosedrefuses to open one, including for a mount or resync that finishes late. - On
pageshowfrom the back/forward cache, the stream reopens and catches up from the cursor. - The reopen waits for the next task instead of running inside
pageshow. In a WKWebView, a stream opened insidepageshowerrored at once; the module then closed it, but WebKit reconnected it anyway. That left a connection the module no longer held, and the page didn't catch up until the reconnect, 3 s later. - The editor's own handlers, registered after its frame waits, are removed.
New test: TestLeavingADocumentEarlyLetsGoOfItsStream.
- Chromium (
fixtures/engines/leaving.mjs): full Chromium with its back/forward cache turned on (Playwright normally turns it off). - WebKit (
fixtures/engines/leaving-webkit.swift): a WKWebView in a window that is never shown, so the page is hidden. The test builds it with swiftc on macOS. - Each page runs no animation frames and leaves the moment the editor opens its stream. A collaborator edits while it's away, then the page goes back.
- It checks: - the server has 0 streams after leaving - the page really came back from the back/forward cache (otherwise the check would be blind) - it caught up with the collaborator's edit - it has 1 stream again
- Fails first on both 6b2a727 and main a0dd33a: - Chromium: "the document was left and 1 live streams are still open", and then it never caught up. - WebKit: its back/forward cache drops the connection itself, so the leak doesn't show there. Instead, the restored page "never caught up" and had 0 streams, because the handlers were never installed.
- Passes 10 of 10 in both engines. Your full-Chrome connection regression (
TestFontLeavingADocumentLetsGoOfItsConnections) passes 20 of 20 in chromium-1234. live-updates.test.mjsadds two unit tests: - leaving closes the stream, and coming back reopens it and catches up - a page left before its subscriber starts opens nothing
P2, coverage test
The test no longer subtracts committed families. Each element and text node gets a logical family from its markup: its font mark's class, code/pre, or the default. The checks run on that, before any fallback:
- The gate's families are exactly the DOM's logical families.
- Every logical face (family, weight and style, as
Faceresolves them) is one the gate waited for. - Every committed family is one the gate waited for, and its text is drawn only in that family's declared fallback (the first family in its stack). Every other family's text is drawn in its own Docs face.
- What is drawn (the Docs families computed) is exactly the gate's families less those committed.
There is now a second pass in which every face is late past the deadline (6 documents, both renderings), so committed families are actually exercised.
Failing first: under that late pass, two gate mutations get past 6b2a727's subtraction but fail now:
- an extra Caveat added to every need list ("the gate waited for [… Docs Caveat …], the DOM asks for […]")
- italic faces left out ("CODE asks for Docs Liberation Mono 400 italic, which the gate did not wait for")
Checks
- Local gate: ok.
- Every
-tags browsertest passes in the headless shell, including both engines checks. - The full Font suite plus the new test pass in full Chrome 1234.
Not merged.
Hub CI passed at 6955cf261ba5a40954edd2bb9c154c1d8f893f28. Not merged.
GPT-6-Astra (Codex), reviewing for session 21a32889.
Verdict: ready to merge — VERDICT: APPROVE.
Reviewed the whole branch at 6955cf261ba5a40954edd2bb9c154c1d8f893f28 against fetched origin/main, a0dd33a79e75afe89570d4ab6acf030f94dbea45, which is also its merge base.
- No remaining P0, P1 or P2 findings. Both previous P2s are fixed.
Lifecycle and catch-up. live-updates.mjs registers the page lifecycle at module evaluation, before any stream can exist. The shared left state prevents activity, late mounts and replacement subscribers from opening while away. Restore schedules a reopen after pageshow; stopping a replaced subscriber unsubscribes it. The cursor survives leaving. Reconnecting receives the server's current sequence, with the server subscribed before reading it; fetch/apply serialization, byte-derived Docs-Seq, the own-write gap guard, and the editor's subscriber-identity check preserve catch-up across in-flight work and resync. I found no new missed-update path across bfcache.
I reproduced the original failure at 6b2a727 using the new early-leaving test through a Go overlay: Chromium retained one server stream while away; native WKWebView restored but never caught up and had zero streams. At the new head, the test passed 10/10 in each engine, and the eight-document connection regression passed 10/10 in full Chrome.
Native harness. The Swift harness uses a real WKWebView and a nonpersistent data store in a window that is never shown. Suppressed animation frames keep the editor before its old late-handler registration point. Navigation waits for stream construction; the Go side checks zero server streams before posting the collaborator's update. A pass requires pageshow.persisted, that update in the restored DOM, and exactly one server stream. A reload or WebKit merely closing the old connection cannot make this test pass. The old-head failure confirms that it detects the original defect.
Coverage. Requested families now come from markup independently of fallback substitution. Logical family equality and requested-face inclusion remain checked even when all text falls back; effective rendering is checked separately. Using Go overlays without changing tracked source, an extra Caveat family failed the logical-family equality, and omitted italics failed requested-face inclusion in the late pass. These failed on the intended assertions, not on navigation or setup errors.
Validation
GOTOOLCHAIN=go1.26.5 TMPDIR=/tmp .amadan/ci.d/10-gate: passed, including bundle reproducibility, Rust/Wasm, wire compatibility, Node tests and Go vet/tests/build.- Full Chrome for Testing 151.0.7922.34,
chromium-1234:go test -tags browser ./internal/docs -run 'Font|LeavingADocumentEarly' -count=1, including the normal/late generative passes and Chromium/WebKit engine checks: passed. - Both lifecycle regressions repeated ten times: passed.
- Five independent Node interleaving probes: passed, covering an in-flight response across restore, a font-delayed apply, interrupted-fetch retry, resync replacement while away, and another departure before the deferred reopen.
- Hub CI: passed at the reviewed SHA. Scratch worktree clean; no commits, pushes or merges.
Scratch checkout: /tmp/docs-review-86-6955cf2. Evidence: /tmp/docs-review-86-6955cf2-{gate,browser,repeat,old-repro,extra-canonical,italic,interleavings}.log. Review probes and overlays are outside the tracked tree.