Skip to content

test: remove five timing races from CI - #4800

Merged
thymikee merged 4 commits into
mainfrom
test/deflake-ci-2026-11-20
Nov 20, 2026
Merged

thymikee merged 4 commits into
mainfrom
test/deflake-ci-2026-11-20

Conversation

@thymikee

@thymikee thymikee commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Summary

Five tests failed on unrelated heads. Every race is in test code; production is unchanged. 12 files.

  1. Android Back diff. diff snapshot ran before Settings rendered. The lane reads chained diffs until the transition is reported, or fails at 10 s.
  2. Android Home pixels. One launcher capture took 6.7 s against a 5 s per-attempt cap. Budget raised for a real device: 15 s cap, 30 s wait.
  3. Upload deadline guard. It counted event-loop turns, so slow finalize IO ended the count unanswered. It now settles on socket data under the 3 s guard.
  4. webOS cancelled inspect. An empty pid file read as pid 0, which signal 0 always reaches. A missing pid now means not running.
  5. Limrun runner. The fixture server did not handle a client cancelling mid-upload. It now returns on an incomplete body.

Mutation harness

Scope expansion. The mutation config left out the global setup that names the run's checkout-local directory, so a test that requires it failed every kernel-errors dry run. Both configs now share one list.

Validation

Head 4409098: CI passes, including Android smoke and all mutation jobs (failed at 602a4aa). Lint, typecheck, format clean.

Same injection on base 74771e1 (fails) and head (passes):

  • Upload: finalize read delayed 300 ms ([]).
  • webOS: pid written 1 s late (true !== false).
  • Limrun: 96 MB body (Error: aborted).
  • Home: scripted 6.7 s captures.
  • Harness: overlay.test.ts under the mutation config with CI=1, 13 fail, then 13 pass.

Back diff: new scripted test only.

Head fails on a real defect: expiry answer removed (3 s), tunnel left running (3 s), cache retry removed, surface or diff never changing (deadline).

Loop under CPU load: upload 50/50, webOS 50/50, Limrun 50/50.

Risks: one Android smoke pass does not prove the two smoke races gone. No independent reviewer.

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Size Report

Metric Base Current Diff
Installed (including dependencies) 6.45 MB 6.45 MB -2.0 kB
Package (unpacked) 6.45 MB 6.45 MB -2.0 kB
Package (download) 1.96 MB 1.96 MB -561 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 33.2 ms 35.3 ms +2.1 ms
CLI --help 69.7 ms 86.7 ms +17.0 ms

@apex-sentinel-staging

This comment has been minimized.

@apex-sentinel-staging apex-sentinel-staging Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apex Sentinel: 1 new finding on 7011edd. The verdict and the full list are in the summary comment.

Comment on lines +26 to +30
const deadline = Date.now() + SNAPSHOT_TRANSITION_TIMEOUT_MS;
let missing = [...expected];
let lastDiff: unknown;
for (let attempt = 1; Date.now() < deadline; attempt += 1) {
const diff = await runStep(context, `${step} (attempt ${attempt})`, ['diff', 'snapshot', '-i']);

@apex-sentinel-staging apex-sentinel-staging Bot Nov 20, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer raised on 4409098.

🟡 Minor · waitForSnapshotDiffLines aborts the scenario on one failed diff step

One diff snapshot -i returning non-zero kills the scenario instead of retrying under the 10 s deadline the wait exists to honour. The call passes no step options, so assertStepOutcome takes its unexpectedFailure path and throws an AssertionError rather than continuing the loop.

⚠️ Check this patch before you commit it: the review doubted it would be right as written.

Suggested change
const deadline = Date.now() + SNAPSHOT_TRANSITION_TIMEOUT_MS;
let missing = [...expected];
let lastDiff: unknown;
for (let attempt = 1; Date.now() < deadline; attempt += 1) {
const diff = await runStep(context, `${step} (attempt ${attempt})`, ['diff', 'snapshot', '-i']);
const diff = await runStep(context, `${step} (attempt ${attempt})`, ['diff', 'snapshot', '-i'], {
allowFailure: true,
});
Details

Also raised here

Also raised at this location by persona maintainability: New diff wait retries only wrong lines; a failing diff command aborts the wait at once — A diff snapshot step that fails outright (daemon hiccup, non-zero run, rejected runStep) rejects waitForSnapshotDiffLines on the first attempt, failing the CI lane on a single transient error instead of polling on. Only a well-formed diff that has not caught up is retried; there is no catch around the awaited runStep. The sibling pixel wait the design mirrors keeps observing until the deadline when its captures keep failing (live-surface-transition.test.ts asserts that case reports the last capture error at the deadline), so the new helper is less resilient than the one it was copied from, and it is there the same flake class will reappear.

persona: senior-developer, maintainability

Useful? Reply @apex-sentinel-staging like, or @apex-sentinel-staging dislike <why> if it is not.

Reply @apex-sentinel-staging note ... to add context, or @apex-sentinel-staging pivot ... if it is wrong — I will re-check the cited code.

thymikee and others added 3 commits November 20, 2026 12:36
The upload deadline guard counted event-loop turns for two socket
answers, so slow finalize IO ended the count with no answer read. It now
settles on the socket data, under the existing 3 s guard.

The webOS tunnel probe read an empty pid file as pid 0, and signal 0 to
pid 0 always succeeds. A cancel that landed before the shell wrote its
pid left the probe reporting a running tunnel forever.

The Limrun fixture server read each request body without handling a
client that cancels mid-upload, which surfaced as an unhandled rejection
after every test had passed.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…or slow captures

A diff read right after Back could still describe the automation route.
The lane now reads chained diffs until the transition is reported, and
fails at a 10 s deadline when it never is.

One launcher capture took 6.7 s on a hosted emulator, above the 5 s
per-attempt cap, so no attempt of the 10 s surface wait could finish.
The cap is now 15 s and the wait holds two capped attempts.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The inline cancel handling took the fixture server handler over the
complexity threshold of the code health audit.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@blacksmith-sh

blacksmith-sh Bot commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

Found 1 test failure on Blacksmith runners:

Failure

Test View Logs
smoke:automation-input/smoke:automation-input View Logs

Fix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

The mutation config left out the global setup that names the run's
checkout-local directory. A test that requires that directory fails on
CI without it, so the dry run of any kernel that owns such a test
stopped every shard before a report. Both configs now share one list.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@thymikee
thymikee force-pushed the test/deflake-ci-2026-11-20 branch from 602a4aa to 4409098 Compare November 20, 2026 11:37
@apex-sentinel-staging

Copy link
Copy Markdown

Apex Sentinel · ✅ Approve · review of 4409098

Since the review of 7011edd: 0 new · 0 still open · 1 no longer raised

No open findings.

2 findings below minor hidden (user_settings.min_severity).

Reviewed with this repository's own Sentinel configuration (ef1198e37698).

💬 Talking to Sentinel

In a finding's thread, reply with:

Command What it does
@apex-sentinel-staging note <context> Adds context; Sentinel re-checks the cited code
@apex-sentinel-staging pivot <why> Says the finding is wrong; Sentinel re-checks the cited code
@apex-sentinel-staging like Marks the finding as useful
@apex-sentinel-staging dislike <why> Marks it as not useful, so it is not raised again

On this conversation, comment @apex-sentinel-staging review to run a full review once again.

@thymikee

Copy link
Copy Markdown
Member Author

This PR is ready at 4409098. It changes tests, fixtures and test config only, and all checks pass, including Android smoke and every mutation shard.

  • Back diff: the smoke scenario now reads chained diffs until both lines are reported and fails at 10 s with the last diff. The new scripted test covers the early read, the immediate case, the deadline and a diff without lines.
  • Home and Recents: the per-capture cap is 15 s and the wait is two caps, so one 6.7 s launcher capture can no longer use up the wait. A real defect now fails at 30 s.
  • Upload deadline test: it waits on socket data under the existing guard instead of counting event-loop turns.
  • webOS tunnel test: an empty pid file no longer reads as pid 0.
  • Limrun fixture: a client that cancels mid-upload is handled.
  • Mutation lane: the mutation config now shares the unit lane's global setup, which is why its shards stopped on tests that need the per-run directory.

Not blocking: the Back-diff wait has not run against the old failure on an emulator, and one green Android smoke run does not prove the two smoke races are gone, so watch the next few runs on main.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 20, 2026
@thymikee
thymikee merged commit de36d03 into main Nov 20, 2026
27 checks passed
@thymikee
thymikee deleted the test/deflake-ci-2026-11-20 branch November 20, 2026 12:12
thymikee added a commit to pcbeingused333/agent-device that referenced this pull request Nov 20, 2026
* origin/main:
  test: remove five timing races from CI (callstack#4800)
  refactor(remote): save a remote script from memory with the local publisher (callstack#4802)
thymikee added a commit that referenced this pull request Nov 20, 2026
* origin/main:
  feat(gesture): hold before the move with gesture pan --hold-ms (#4767)
  docs: clarify device verification and security proposals (#4805)
  fix(daemon-client): say that a hung daemon is stopped before ensureDaemon starts a new one (#4803)
  test: remove five timing races from CI (#4800)
  refactor(remote): save a remote script from memory with the local publisher (#4802)
  refactor(apple-runner): one RUNNER_ERROR_CODES row per runner error code with parity/docs gates (#4774)
  fix(android): require acknowledgements for test IME typing (#4722)
  feat(scroll): add scroll refresh for pull-to-refresh (#4770)
  refactor(host-kit): add request Scope and use it for the wait capture deadline (#4794)
  fix(android): let permission all change nothing on an app that declares no permissions (#4796)
  fix(cli): replace the CLI session and generated remote config instead of rewriting them in place (#4797)
  fix(host-kit): accept a group-writable script directory the user owns (#4799)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant