Skip to content

Fix two flaky tests: the settle clock test and parity-browser's waitfor cell (#168) - #381

Merged
SSFSKIM merged 4 commits into
mainfrom
fix/168-flakes
Nov 15, 2026
Merged

SSFSKIM merged 4 commits into
mainfrom
fix/168-flakes

Conversation

@SSFSKIM

@SSFSKIM SSFSKIM commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

Two flaky tests that cost #171's gates repeated reruns. Both fixes are in the tests, and neither changes product code.

(a) The settle's clock test (test/services-engine-linux/service.test.mjs)

The test compared real elapsed milliseconds with a constant of 0 and failed once on the hosted runner ("waited 53.19 ms after a click whose constant is 0"). It now runs the real ActionSettler through the service on a clock the test keeps (the settler's existing now/sleep seams), so only its sleeps move time. Each sleep stays pending until the test releases it (a review finding: a sleep that resolved at once let a read that never awaited the settle pass). While the sleep after press_key is held, clipboard_release, which never waits, goes to the engine. The engine runs requests in order, so the held read must not be ahead of it. Once the test releases the sleep, the read reaches the engine. The test still guards the same property: the call after press_key sleeps exactly its 100 ms before it reaches the engine, and the call after a click whose constant is 0 doesn't sleep.

Evidence: test/services-engine-linux/*.test.mjs 63/63 on 74af416. I checked that the test catches real regressions by breaking the code on purpose, each change reverted afterwards:

  • the read calls settler.wait() without await (the reviewer's mutation): fails, the engine got ['list_windows', 'clipboard_release'] while the settle was held
  • the read reaches the engine before its wait: fails the same way
  • the settle sleeps 1 ms too long: fails, [101] for [100]

ci-gate test gate on 74af416: GREEN, https://github.com/SSFSKIM/cua/actions/runs/43669910514 (9m58s). parity-browser was not rerun: this commit touches only the settle test.

(b) parity-browser's api/browser-playwrightlocator/waitfor cell locator-contract-diagnostics-no-matches

Whichever deadline ran out first wrote the error's first line: the locator's ("Playwright selector deadline exceeded") or a CDP command's own. The committed evidence shows the command's wording as Runtime.evaluate with 1 ms left, or Page.createIsolatedWorld on a slow scratch tab. Changing the deadline can't stop this race, because the last poll's command always gets whatever time is left. So the fix is in the scenario, as the issue asks, not an allowance. The cell now catches the error and returns three things: that a deadline named it, its code, and the context and diagnostics lines after it, byte for byte. The check holds those to the vendor's contract as before.

TDD: a new test runs the cell against each first line seen on real Chrome and requires one observation. It failed before the fix (each first line reached the observation) and passes after it. It also rejects a wait that finds the selector, an error that names no deadline, a missing diagnostics line, a missing context line, and diagnostics that found a match. test/repl-parity/locator-contracts.test.mjs: 17/17.

parity-browser on b1d4cc0, five runs in a row, all green:

The tracker's entry for this race moves to Resolved.

Not in this PR

Refs #168

Sminos-Session: linux171#3c5ca588 (cua on dc-linux171-1e68)

…ot the runner's

"the settle's real clock" compared real elapsed time with a constant of 0 and failed on the hosted runner
("waited 53.19 ms after a click whose constant is 0"). It now drives the real ActionSettler through the
service on an injected clock (its now/sleep seams): the call after press_key sleeps exactly 100 ms, before
that call reaches the engine, and the call after a click whose constant is 0 sleeps not at all.

Sminos-Session: linux171#3c5ca588 (cua on dc-linux171-1e68)
… not which deadline won (#168)

api/browser-playwrightlocator/waitfor's locator-contract-diagnostics-no-matches waits 100 ms for an absent
selector, and whichever deadline runs out first names the error's first line: the locator's ("Playwright
selector deadline exceeded") or a CDP command's own (Runtime.evaluate's 1 ms, or Page.createIsolatedWorld's
on a slow scratch tab). Both hosts' assertions passed while the diff went red on load alone, about half
of parity-browser's runs. No deadline closes that race, since the last poll's command always gets what is
left, so the cell now catches the error and returns that a deadline named it, its code, and the context
and diagnostics lines after it byte for byte; the check holds those to the vendor's contract as before.
A test runs the cell against each first line seen on real Chrome and requires one observation.

Sminos-Session: linux171#3c5ca588 (cua on dc-linux171-1e68)
Moved to Resolved with the scenario fix (b1d4cc0) and its five green parity-browser runs.

Sminos-Session: linux171#3c5ca588 (cua on dc-linux171-1e68)
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-15T02:39:38.398753Z a161608 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

…381 review)

The fake sleep resolved at once, so a read that called settler.wait() without awaiting it left the same
sleep record and passed. The sleep is now held: while it is, clipboard_release (which never waits) goes to
the engine, and since the engine runs requests in order, the held read must not be ahead of it; once the
test wakes the sleep, the read reaches the engine. A missing await, a read sent before its wait, and a
settle 1 ms too long each fail it.

Sminos-Session: linux171#3c5ca588 (cua on dc-linux171-1e68)
@SSFSKIM
SSFSKIM merged commit 3972477 into main Nov 15, 2026
5 checks passed
SSFSKIM added a commit that referenced this pull request Nov 15, 2026
Sminos-Session: linux171#3c5ca588 (cua on dc-linux171-1e68)
SSFSKIM added a commit that referenced this pull request Nov 17, 2026
Main brings #374's Show Menu confirmation, #382's scroll, #368, #381 and #171 M4. Conflicts resolved by keeping both
sides: Input.swift's meta (typeReadback, keyEffect and menu), the engine service's per-call and optional meta keys and
its header, the service test (#354's and #374's tests both), the spec's errors list (menuUnconfirmed and
typeUnconfirmed), the surface inventory's Table 3 sections (#354's, then #374's), PROVENANCE.md's agent-cursor row
(#374's fourth-paragraph sentence and #354's sixth paragraph), and repl-parity's docs oracle, rebuilt from main's
fourth and fifth paragraphs and #354's sixth so it equals agent-cursor.md byte for byte.

Sminos-Session: cursor235#b93055dd (cua on macbook)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant