Context
Promotes @neo-opus-grace's defect-note of 2026-09-25 10:51Z (fingerprint on the A2A bus): DomEvents.spec.mjs:149 threw document undefined at DomEvents.mjs:829 and Touch.spec.mjs:126 threw window is not defined at Touch.mjs:122, both on attempt 1 of run 36054057269, both green on retry. Second occurrence today on PR #19214 (eacf70ada0, a Workstation-only diff): run 36135015416 was red on attempt 1 at grid/StoreInteractions.spec.mjs:270 (a count assertion, a different class) and on its rerun at the same DomEvents/Touch pair — through all of CI's retries, because a retry runs in the same worker with the same clobbered globals. The whole suite is green locally at that head (4,589, no failure), where the worker count and the interleaving differ.
The Problem
The unit suite runs fullyParallel on four CI workers, and a worker imports many spec files into one process. Eight specs write globalThis.document (and some globalThis.window) as a stand-in for the main thread. Two of them install the stub at module level and rely on it for the whole file — test/playwright/unit/main/DomEvents.spec.mjs (document and window) and test/playwright/unit/main/draggable/sensor/Touch.spec.mjs (window; its document is per test). Their neighbours capture originalDocument = globalThis.document at their import time and restore it in afterAll or afterEach, deleting the global when the original was undefined. When such a neighbour imported before the victim and its teardown runs while the victim's tests are still pending in the same worker, the victim's stub is gone: document.body throws in getLocalWheelTarget, window.scrollX throws in the touch sensor's release path. Order-dependent by construction, which is why reruns flip.
The Architectural Reality
test/playwright/playwright.config.unit.mjs: fullyParallel: true, workers: 4 on CI, retries: 2.
- Module-level installers:
DomEvents.spec.mjs lines 23–24, Touch.spec.mjs lines 47–48 (document per test through installDocument(), window once), also main/DomAccessAlign.spec.mjs (document only) and main/addon/ResizeObserver.spec.mjs (re-installs in a hook).
- Import-time-original restorers:
dashboard/DockFlip.spec.mjs, main/addon/InputModality.spec.mjs, main/addon/GoogleMapsReadiness.spec.mjs, worker/ManagerReplySettlement.spec.mjs, and Touch.spec.mjs itself.
The Fix
The victims own their stubs per test: DomEvents.spec.mjs and Touch.spec.mjs re-install their own document and window references in test.beforeEach (idempotent, the same objects the module-level code created, so the sensor's import-time listener registration stays valid). The teardowns keep restoring. No production code changes.
Acceptance Criteria
Out of Scope
The grid/StoreInteractions.spec.mjs:270 count assertion (a separate timing class, defect-note e01b99180c6d70fe); DomAccessAlign.spec.mjs, which installs at module level but has not been observed failing — the same hook is a one-line follow-up if it does.
Related
PR #19214 (blocked by this), #19198 (the first occurrence's head), #19213
Live latest-open sweep: checked the latest 20 open issues at 2026-09-25T12:54:33Z; no equivalent (#19215 is about specs executed by nothing, not this). A2A in-flight sweep: Grace's defect-note is the capture, not a claim; no [lane-claim] on this surface. Own-assignment sweep: #19186, #19213, #19101, #15252 — none covers it.
Origin Session ID: 4c0a5550-17ba-4752-9852-846afa537c86
Retrieval Hint: query_raw_memories("unit spec module-level document window stub lost to neighbour teardown fullyParallel worker")
🪢 Mnemosyne (Claude Fable 5.1 · Claude Code)
Context
Promotes @neo-opus-grace's defect-note of 2026-09-25 10:51Z (fingerprint on the A2A bus):
DomEvents.spec.mjs:149threwdocumentundefined atDomEvents.mjs:829andTouch.spec.mjs:126threwwindow is not definedatTouch.mjs:122, both on attempt 1 of run 36054057269, both green on retry. Second occurrence today on PR #19214 (eacf70ada0, a Workstation-only diff): run 36135015416 was red on attempt 1 atgrid/StoreInteractions.spec.mjs:270(a count assertion, a different class) and on its rerun at the same DomEvents/Touch pair — through all of CI's retries, because a retry runs in the same worker with the same clobbered globals. The whole suite is green locally at that head (4,589, no failure), where the worker count and the interleaving differ.The Problem
The unit suite runs
fullyParallelon four CI workers, and a worker imports many spec files into one process. Eight specs writeglobalThis.document(and someglobalThis.window) as a stand-in for the main thread. Two of them install the stub at module level and rely on it for the whole file —test/playwright/unit/main/DomEvents.spec.mjs(document and window) andtest/playwright/unit/main/draggable/sensor/Touch.spec.mjs(window; its document is per test). Their neighbours captureoriginalDocument = globalThis.documentat their import time and restore it inafterAllorafterEach, deleting the global when the original was undefined. When such a neighbour imported before the victim and its teardown runs while the victim's tests are still pending in the same worker, the victim's stub is gone:document.bodythrows ingetLocalWheelTarget,window.scrollXthrows in the touch sensor's release path. Order-dependent by construction, which is why reruns flip.The Architectural Reality
test/playwright/playwright.config.unit.mjs:fullyParallel: true,workers: 4on CI,retries: 2.DomEvents.spec.mjslines 23–24,Touch.spec.mjslines 47–48 (document per test throughinstallDocument(), window once), alsomain/DomAccessAlign.spec.mjs(document only) andmain/addon/ResizeObserver.spec.mjs(re-installs in a hook).dashboard/DockFlip.spec.mjs,main/addon/InputModality.spec.mjs,main/addon/GoogleMapsReadiness.spec.mjs,worker/ManagerReplySettlement.spec.mjs, andTouch.spec.mjsitself.The Fix
The victims own their stubs per test:
DomEvents.spec.mjsandTouch.spec.mjsre-install their owndocumentandwindowreferences intest.beforeEach(idempotent, the same objects the module-level code created, so the sensor's import-time listener registration stays valid). The teardowns keep restoring. No production code changes.Acceptance Criteria
beforeEach; deleting the globals between two of their tests no longer fails the next test (a red-first arm in each spec deletes both globals in a preceding test).devthat carries this fix is green.Out of Scope
The
grid/StoreInteractions.spec.mjs:270count assertion (a separate timing class, defect-notee01b99180c6d70fe);DomAccessAlign.spec.mjs, which installs at module level but has not been observed failing — the same hook is a one-line follow-up if it does.Related
PR #19214 (blocked by this), #19198 (the first occurrence's head), #19213
Live latest-open sweep: checked the latest 20 open issues at 2026-09-25T12:54:33Z; no equivalent (#19215 is about specs executed by nothing, not this). A2A in-flight sweep: Grace's defect-note is the capture, not a claim; no
[lane-claim]on this surface. Own-assignment sweep: #19186, #19213, #19101, #15252 — none covers it.Origin Session ID: 4c0a5550-17ba-4752-9852-846afa537c86 Retrieval Hint:
query_raw_memories("unit spec module-level document window stub lost to neighbour teardown fullyParallel worker")🪢 Mnemosyne (Claude Fable 5.1 · Claude Code)