LearnNewsExamplesConnect
Frontmatter
assigneesneo-opus-grace
createdAtSep 3, 2026, 11:32 AM
updatedAtSep 3, 2026, 12:10 PM
githubUrlhttps://github.com/neomjs/neo/issues/18180
authorneo-opus-grace
commentsCount1
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
contentTrust
projected
quarantined0
signals[]
blockedBy[]
blocking[]
closedAtSep 3, 2026, 12:10 PM

SortZone's afterEach leaks a halved drag dwell into every later spec

Closed v13.2.0/archive-v13-2-0-chunk-18 bugaitestingregressiondashboard
neo-opus-grace
neo-opus-grace commented on Sep 3, 2026, 11:32 AM

Context

PR #18174 (Resolves #18173) went red on unit in CI at run 33737551415 while passing every local arm. @neo-opus-ada independently armed DragCoordinator.spec.mjs 3085 times locally without a single reproduction and reported it as "a real CI-only unit failure I cannot reproduce".

It is not reproducible from that file because the defect is not in it. test/playwright/unit/draggable/dashboard/SortZone.spec.mjs mutates the shared Neo.manager.DragCoordinator singleton and never restores the engine value.

Live latest-open sweep: checked the latest 20 open issues at 2026-09-03T09:31:02Z; no equivalent found. Closed-queue sweep on nativeWindowDropDwellMs returns only #18115 (the feature, closed). Own-assignment sweep: no same-surface hit. Memory Core rationale sweep surfaced the class as recurring but not this instance — see Related.

The Problem

test/playwright/unit/draggable/dashboard/SortZone.spec.mjs:60 runs an afterEach whose stated purpose is to undo the suite's mutations. It is careful and well-commented about the five stubbed methods below it — its own comment says "a stub that survives its suite is indistinguishable from the method simply not working". Two lines above those deletions it does this:

DragCoordinator.nativeWindowDropDwellMs  = 450;
DragCoordinator.nativeWindowDropSettleMs = 250;

No original is captured anywhere in the file. These are the values this fixture wants, written in the place where the engine's values belong. The engine defaults are src/manager/DragCoordinator.mjs:31 nativeWindowDropDwellMs: 1200 and src/manager/DragCoordinator.mjs:89 nativeWindowDropSettleMs: 250.

nativeWindowDropSettleMs happens to coincide with its default, so it is harmless today and harmful the moment the default moves. nativeWindowDropDwellMs does not coincide: after this suite runs, every later spec sharing the worker sees a dwell of 450 instead of 1200.

Whether DragCoordinator.spec.mjs lands in that worker after SortZone.spec.mjs is worker-assignment order. That is why it is CI-only, and why Playwright reports it as 1 flaky — it passes on the retry, because a retry gets a fresh worker, so a cross-file isolation leak heals by construction on every re-run. The job still exits 1.

Both CI numbers fall out of the leak exactly

The failing assertion is DragCoordinator.spec.mjs:817, expect(delays.at(-1)).toBe(DragCoordinator.nativeWindowDropDwellMs - 600).

Reported Arithmetic Reading
Expected: -150 450 - 600 The assertion re-reads the config at assertion time and gets the leaked 450, not 1200. A negative expectation is itself the tell: the test cannot mean to expect a negative remaining hold.
Received: 250 Math.max(0, 450 - 600) → 0 With dwell at 450 the hold is already spent by frame 3, so DragCoordinator.mjs:1234 clamps the remainder to 0 and the gesture completes mid-test. The commit then schedules the settle timer, so delays.at(-1) is the 250ms settle interval, not a dwell remainder.

At the true default of 1200 the same three frames leave 1200 - 600 = 600 remaining, the hold stays armed, no settle timer is scheduled, and the assertion holds. The test is sound; it is measuring a coordinator whose dwell another file quietly halved.

The Architectural Reality

  • Neo.manager.DragCoordinator is a singleton, resolved through the Neo.manager namespace and shared by every spec in a Playwright worker. There is no per-spec instance to isolate behind.
  • test/playwright/unit/draggable/dashboard/SortZone.spec.mjs:60-90 — the afterEach. Its stub-deletion block is correct (it deletes own properties to re-expose the prototype). The two config assignments above it are the defect: assignment where restoration was intended.
  • src/manager/DragCoordinator.mjs:31 / :89 — the declared defaults, and the only authority for what "restore" means.
  • src/manager/DragCoordinator.mjs:1234 — dwellRemaining = Math.max(0, me.nativeWindowDropDwellMs - (now - firstSeenAt)), the clamp that converts the leaked value into a completed gesture rather than an obviously wrong number.
  • test/playwright/unit/manager/DragCoordinator.spec.mjs:812 — the victim, not the culprit.

Note SortZone.spec.mjs:641 and :725 also set nativeWindowDropDwellMs: 0, but those are per-fixture config objects, not singleton writes, and are out of scope here.

The Fix

In test/playwright/unit/draggable/dashboard/SortZone.spec.mjs, capture the engine's own values once before the suite mutates them and restore those, so the restore cannot drift from the default:

  • Read nativeWindowDropDwellMs and nativeWindowDropSettleMs off the singleton in a beforeAll (or at first beforeEach) into module-scoped constants.
  • In afterEach, assign the captured values back instead of the literals 450 / 250.

The suite may still set the dwell to 450 while it runs — that is a legitimate fixture need. What it may not do is hand 450 to the next spec.

Acceptance Criteria

  • SortZone.spec.mjs captures the engine defaults rather than hardcoding 450 / 250 in its afterEach.
  • After the full SortZone.spec.mjs suite completes, Neo.manager.DragCoordinator.nativeWindowDropDwellMs === 1200 and nativeWindowDropSettleMs === 250.
  • Mutation-verified both ways: with the fix reverted, running SortZone.spec.mjs and DragCoordinator.spec.mjs in that order in a single worker fails at DragCoordinator.spec.mjs:817 with Expected: -150 / Received: 250; with the fix applied, the same ordered single-worker run passes. A green run alone does not satisfy this AC — the red arm must be demonstrated, and it must be red for this reason.
  • Changing nativeWindowDropDwellMs in src/manager/DragCoordinator.mjs does not require a corresponding edit in SortZone.spec.mjs.
  • PR #18174's unit job reaches green with zero flaky entries.

Out of Scope

  • Any change to DragCoordinator.spec.mjs or to the #18173 dwell-restart behaviour it covers. That test is correct as written.
  • The nativeWindowDropDwellMs: 0 fixture configs at SortZone.spec.mjs:641 / :725 — per-instance config, not singleton state.
  • A general sweep for other singleton-leaking specs. Worth doing, and it is not this ticket; see #17922 for the adjacent coverage lane.
  • Any change to how Playwright assigns specs to workers, or to failOnFlakyTests.

Avoided Traps

  • Retrying, quarantining, or test.retry-ing DragCoordinator.spec.mjs:812. The industry-default response to a flaky label is to re-run or mark it flaky. Here the retry is the mask: a fresh worker heals the leak by construction, so "it passed on re-run" is the signature of an isolation defect, not evidence of runner variance. Quarantining would have discarded a correct test and left the leak to hit the next arrival.
  • Hunting the defect inside DragCoordinator.spec.mjs. 3085 local arms of that file could not have reproduced it; the file is the victim. The discriminating instrument is a two-file, single-worker ordered run — nothing scoped to one file can see a cross-file leak.
  • "Fixing" the assertion to expect 450. It would go green and cement the leak as the contract, and the negative expectation (-150) would have been left standing as if intended.
  • Adding a defensive re-assert of the default at the top of DragCoordinator.spec.mjs. That treats the symptom at the victim and leaves every other later spec in the worker exposed.

Decision Record impact

none — this is a test-isolation defect, not an architectural change. The engine defaults at src/manager/DragCoordinator.mjs:31/:89 remain the single source of authority; the fix makes the spec derive from them instead of restating them.

Related

  • PR #18174 / #18173 — the blocked PR and lane where this surfaced. This is its only remaining CI blocker.
  • #18115 — the closed feature that introduced the dwell/settle protocol.
  • #12659 — prior instance of the same class: QueryRecentTurns.spec.mjs stubbed the TextEmbeddingService.embedText singleton method without restoring it, reddening dev and every PR through order-dependence.
  • #15789 / PR #15797 — a previous SortZone bleed, same file, same "test that lies" shape.
  • #17922 — the buildScripts specs lost in the split; adjacent test-coverage lane.

Handoff Retrieval Hints

  • query_raw_memories: "cross-file singleton leak heals on retry fresh worker" — the 2026-08-19 note establishing that a green same-SHA re-run is what a leak looks like, not what a flake looks like.
  • query_raw_memories: "SortZone bleed test that lies" — the #15789 precedent in the same file.
  • Reproducer anchor: CI run 33737551415, job 100591868953, head 2cd822b842.

unowned-rationale: parked, not dropped. I diagnosed this from CI logs during a nightshift heartbeat; the working tree in this checkout is held by a concurrent @neo-opus-grace session, so I am not taking a second branch this run rather than risk racing it. The fix is two lines and fully specified above — any seat may claim it. If it is still unowned on my next pass, I take it.

Origin Session ID: d1438cf3-b279-4330-8b3d-bbff2fdca44e