Skip to content

fix(command-runtime): end a wait on its earlier captures when the last one answers late - #4814

Merged
thymikee merged 1 commit into
mainfrom
fix/wait-late-capture-verdict
Nov 20, 2026
Merged

thymikee merged 1 commit into
mainfrom
fix/wait-late-capture-verdict

Conversation

@thymikee

@thymikee thymikee commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Summary

Fixes a verdict change that #4794 introduced. Part of #4789.

Since #4794, a wait capture that answers after its cutoff is a timeout. createWaitPolling reported that poll as capture-truncated, so a wait whose earlier captures showed the target absent ended with wait_deadline_exceeded instead of wait_target_absent. Under load the last capture often straddles the cutoff, so the reason changed with host speed. The Coverage job on #4813 failed this way in ios-wait-selector.test.ts (expected wait_target_absent, received wait_deadline_exceeded): https://github.com/callstack/agent-device/actions/runs/44745114108/job/136318310016

Now a capture that answered late ends the poll with no deadline cause. Nothing was cut off mid-capture, so the wait ends on what its earlier captures established: wait_target_absent after a readable capture, wait_capture_stalled when no capture was readable in time. The late answer is still not counted as evidence. A capture that the deadline cancelled in flight keeps capture-truncated, as before. This matches the settle loop, which #4794 already treats this way.

2 files changed. No wire declaration changed.

Validation

Head 476f5f6338.

  • The refactor(host-kit): add request Scope and use it for the wait capture deadline #4794 regression "a capture that answers after the cutoff is a timeout and not a readable capture" now expects wait_target_absent with one readable capture. It fails without the change.
  • New: "a first capture that answers after the cutoff leaves the wait with no readable capture" expects wait_capture_stalled.
  • The interaction runtime suite passes (487 tests). Typecheck and lint are clean.
  • ios-wait-selector.test.ts and settle-observation.test.ts: 8 of 9 local runs passed with host load about 27. One run failed a different case, "Apple wait selector captures like is when native queries fail". It did not recur in 6 more runs, and I have not found its cause.
  • No local check:affected run: the host is under load from other validation runs. Hosted CI validates this head.

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

View guided diff Turn on auto-fix

@github-actions

Copy link
Copy Markdown
Contributor

Size Report

Metric Base Current Diff
Installed (including dependencies) 6.45 MB 6.45 MB +69 B
Package (unpacked) 6.45 MB 6.45 MB +69 B
Package (download) 1.97 MB 1.97 MB +9 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 36.0 ms 53.4 ms +17.3 ms
CLI --help 71.4 ms 132.3 ms +60.9 ms

@apex-sentinel-staging

Copy link
Copy Markdown

Apex Sentinel · ✅ Approve · review of 476f5f6

No open findings.

1 finding below minor hidden (user_settings.min_severity).

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

💬 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 476f5f6. The fix ends a wait on its earlier captures when the last one answers late, and the new injected-clock test covers that window. All checks pass on this commit, and there are no conflicts.

Not verified here: the tests were not run locally or on a device. The regression was judged by reading the merge-base code against the test assertions. A live run cannot target this timing window, so the injected-clock test is the right proof.

Not blocking, take or leave both:

  • The "first capture that answers after the cutoff" test at wait-polling.test.ts:513 would also pass on the old code except for the internal deadline field. Keep it as characterization, or assert something the fix changes.
  • The late-answer versus cancelled distinction is read as the presence of the optional error key in wait-polling.ts:153 and stable-capture.ts:578. A named field on the timed-out result in wait-deadline.ts would be clearer.

The next step is maintainer review.

@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 8b5c626 into main Nov 20, 2026
19 checks passed
@thymikee
thymikee deleted the fix/wait-late-capture-verdict branch November 20, 2026 15:12
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