Skip to content

Engine tests: the failed-enablement test reads its own clock, so the window's edge is exact (#408) - #447

Merged
SSFSKIM merged 1 commit into
mainfrom
fix/408-background-pointer
Nov 20, 2026
Merged

SSFSKIM merged 1 commit into
mainfrom
fix/408-background-pointer

Conversation

@SSFSKIM

@SSFSKIM SSFSKIM commented Nov 20, 2026

Copy link
Copy Markdown
Owner

Closes #408. Test-only; no shipped behaviour changes, so no version bump.

BackgroundPointerTests.testAFailedEnablementWriteStillOpensTheFreshWindowAndIsReported failed on hosted macOS six times (11-15..11-20, #444), always at line 546 alone with XCTAssertFalse failed. The cause was floating-point rounding, not timing. The test read freshSince from the real clock (CLOCK_UPTIME_RAW in fractional ms) and checked that the window had closed at since + 10_000. When that sum crosses a power of two, the Double loses a low bit, now - since comes out as 9999.99999999994, and the window reads as still fresh. Sampling real uptimes put this at about 0.9% under one hour of uptime, which is where a freshly booted hosted runner sits. No user can meet it: the difference is under a nanosecond, at the exact 10 s edge.

Fix: the test passes its own clock through WebAccessibility(now:), as the other tests in the file already do. It asserts freshSince == 5_000 exactly (it used to check >= before), and both edge checks are exact.

Repro before the fix: pinning the clock at 520_000.123456789, whose sum with 10 000 crosses 2^19, failed the unchanged test every time, at line 546 only. That matches the hosted logs.

Checks:

The hosted 200-run loop that #408 asked for wasn't run. The test no longer reads the real clock, so its result doesn't depend on the runner.

Sminos-Session: cursor235#b93055dd (cua on macbook)

…its own, so the window's edge is exact (refs #408)

The test took freshSince from the real CLOCK_UPTIME_RAW and asserted not-fresh at since + 10 000 ms. When
that sum crosses a power of two, Double drops a low bit and can round it down, so now - since came out a
hair under the window and read fresh: about 1% of readings under an hour of uptime, the hosted runner's
line-546 "XCTAssertFalse failed". Forcing the clock to 520 000.123456789 ms reproduces it every time.
The product is unaffected (sub-nanosecond at the edge); the test now injects its clock and asserts the
observation's time exactly.

Sminos-Session: cursor235#b93055dd (cua on macbook)
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 20, 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-20T17:25:18.540266Z cdd3bbb 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.

@SSFSKIM
SSFSKIM enabled auto-merge (squash) November 20, 2026 17:24
@SSFSKIM
SSFSKIM merged commit be35c41 into main Nov 20, 2026
6 checks passed
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.

Engine tests: BackgroundPointerTests' failed-enablement test is timing-flaky on hosted engine-swift (two gate reruns)

1 participant