Skip to content

fix(android): share the boot error shape and pin the offline boot-probe retry - #4812

Merged
thymikee merged 6 commits into
mainfrom
fix/android-boot-poller-followups
Nov 20, 2026
Merged

thymikee merged 6 commits into
mainfrom
fix/android-boot-poller-followups

Conversation

@thymikee

@thymikee thymikee commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Summary

Follow-ups to #4717, which merged at c277c86 before these landed.

  1. Offline then booted. New case through ensureAndroidReady: the probe returns { stdout: '', stderr: 'error: device offline', exitCode: 1 }, then the booted probe. It resolves, with run called twice. Without it, a change that makes every nonzero exit terminal would pass.
  2. Shared error shape. The readiness poller reuses buildAndroidBootError, now exported from emulator-lifecycle.ts. For one typed observation, both boot pollers report the same code, message and cause.

Rule for the message: the builder says "Android device did not finish booting in time" only when the caller's boot budget is spent. Each caller decides that from the deadline it holds. A failure inside the budget keeps the message of the layer that failed.

Behavior changes:

  • Both pollers keep the original cause on a terminal boot failure.
  • A TOOL_MISSING failure, or a terminal adb transport failure such as an unauthorized device, keeps its own message even when the budget is also spent.
  • Lifecycle poller: one adb probe timeout inside the boot budget now reports the probe's own message. Before, it reported the budget wording because the reason was ANDROID_BOOT_TIMEOUT. A spent budget, or retries that ended on a still-booting observation, still report the budget wording.
  • Readiness poller: a probe failure that lands on or after the readiness deadline now reports the budget wording. A probe that throws a non-AppError reports COMMAND_FAILED, as it did before fix(android): use typed evidence in the readiness boot poller #4717, not UNKNOWN.

Details use a named, module-local AndroidBootFailureDetails type. 4 files changed.

Validation

Base c94e11046c. Head 0d94142006.

  • New or tightened tests: the cause on a terminal TOOL_MISSING failure; the in-budget probe timeout message at both pollers (the lifecycle row now asserts the message); the budget wording when the readiness deadline passes during the probe; COMMAND_FAILED for a plain Error; the offline-then-booted retry.
  • The readiness and emulator-lifecycle suites pass. Typecheck and lint are clean.
  • The full platform-android run under host load (about 34) failed one unrelated test on the slow-test gate, snapshot-helper-exit-result.test.ts. It passes when run with the two changed suites (64 of 64).
  • No local check:affected receipt: the host is under load from other validation runs. Hosted CI validates this head.
  • No device run. The retry and terminal decisions are unchanged from the base. Only a run that hits an in-budget adb probe timeout would show the lifecycle message on a real device.

@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 -1 B
Package (unpacked) 6.45 MB 6.45 MB -1 B
Package (download) 1.97 MB 1.97 MB -13 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 30.0 ms 29.2 ms -0.7 ms
CLI --help 70.7 ms 59.9 ms -10.8 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 7e59a4c. The verdict and the full list are in the summary comment.

@apex-sentinel-staging

This comment has been minimized.

@thymikee

Copy link
Copy Markdown
Member Author

No wrong behavior in dbb8c7b compared with the merge base, and all 18 checks pass on this head. The retry and terminal decisions are unchanged from base, so no new device run is needed, but only a run that hits an in-budget adb probe timeout would show the lifecycle message below on a real device. No conflicts. Before merge, the one open design ask is to let the caller's deadline decide when the boot message says the budget ran out.

The builder is meant to give one message for one boot observation at both pollers, but it does not yet. The lifecycle call at https://github.com/callstack/agent-device/blob/dbb8c7b/packages/platform-android/src/emulator-lifecycle.ts#L141 treats the budget as spent when params.timedOut || reason === ANDROID_BOOT_TIMEOUT. A single adb probe killed by its 10s timeout inside a 60s or 120s budget therefore reports "Android device did not finish booting in time", while the readiness poller (https://github.com/callstack/agent-device/blob/dbb8c7b/packages/platform-android/src/readiness/runtime.ts#L207) reports "adb timed out after 10000ms" for the same evidence. The rule should be that the budget wording appears only when the deadline has expired, and that code, message and cause are equal at both pollers for one typed observation. Could buildAndroidBootError(appError, reason, { deadline, details }) take the deadline both call sites already hold and check deadline.isExpired()? That would remove the timedOut || reason condition and fix the budget edge at https://github.com/callstack/agent-device/blob/dbb8c7b/packages/platform-android/src/readiness/runtime.ts#L157, where a probe cut short by the last seconds of the budget currently reports a plain adb timeout. Nothing needs to change first, since the function is package-private with two call sites. If the in-budget lifecycle message is deliberate, a named reason or ADR should say so, and the PR body claim that both pollers report the same message should go.

Not blocking, and you can take or leave these: the lifecycle probe-timeout row in https://github.com/callstack/agent-device/blob/dbb8c7b/packages/platform-android/src/__tests__/emulator-lifecycle.test.ts#L168 asserts the reason and call count but not the message, so nothing fails if the two pollers drift apart. asAppError at runtime.ts:164 gives a non-AppError the code UNKNOWN, where base always threw TOOL_MISSING or COMMAND_FAILED, so either normalise at the readiness call site or document the wider code set in the builder. The details parameter at emulator-lifecycle.ts:181 became Record<string, unknown>, so a named shared detail type would keep both pollers type-checked. The Validation section of the PR body still names head 7e59a4c and +53/-10, while this head is dbb8c7b with +60/-13.

The earlier thread on the readiness message (#4812 (comment)) is fixed at this head for the readiness route, so you can resolve it. The same claim still applies on the lifecycle route, as described above.

@thymikee

Copy link
Copy Markdown
Member Author

Pushed cb8a55e5f0. This answers the review at dbb8c7b.

  • Design ask: done. The builder words a failure as a spent budget only when the caller's boot budget is spent. The lifecycle poller decides that from its Deadline (timedOut, deadline.isExpired(), or retries that ended on a still-booting observation). The readiness poller decides it from host.clock.now() >= deadline. The reason === ANDROID_BOOT_TIMEOUT condition is gone, so one adb probe timeout inside the budget reports the probe's message at both pollers. I kept a boolean parameter instead of passing the deadline object, because the two pollers hold different deadline types (a Deadline and an absolute time on the host clock).
  • Budget edge at readiness: a probe failure that lands on or after the deadline now reports the budget wording. A new test covers it.
  • Lifecycle test: the probe-timeout row now asserts the message.
  • Non-AppError code: the readiness call site normalizes it to COMMAND_FAILED, as before fix(android): use typed evidence in the readiness boot poller #4717. A new test covers it. The builder's doc states that it keeps the failure's own code.
  • Detail type: AndroidBootFailureDetails replaces Record<string, unknown>.
  • PR body: rewritten for this head, with the behavior changes listed.

No local check:affected receipt for this head; the host is under load. Hosted CI validates it.

@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 cb8a55e. The verdict and the full list are in the summary comment.

@thymikee

Copy link
Copy Markdown
Member Author

Coverage failed at 8514e672c5 on packages/daemon-client/src/__tests__/daemon-client-ensure-explicit-lifecycle.test.ts ("a quiesce the daemon never hears is judged again, not reported as a transport failure"), which timed out at 5000 ms. This PR changes only Android boot-poller code and does not touch daemon-client. An earlier run on another PR listed the same test over its slow-test budget (3.74 s against 2.5 s). I reran the failed job: https://github.com/callstack/agent-device/actions/runs/44754485493/job/136350519957

@apex-sentinel-staging

This comment has been minimized.

@thymikee

Copy link
Copy Markdown
Member Author

Coverage failed a second time at 8514e672c5 on the same test, daemon-client-ensure-explicit-lifecycle.test.ts ("a quiesce the daemon never hears is judged again, not reported as a transport failure", timed out at 5000 ms). Main's Coverage passed at bfc09800b, which contains the recent daemon-client changes (#4801, #4803, #4806). So this looks like a timing-sensitive test in those changes, not a result of this PR, which changes only Android boot-poller files. I have not confirmed the cause. I reran the job once more.

@thymikee

Copy link
Copy Markdown
Member Author

This PR is ready at 8514e67. Both points from the earlier review are fixed: an in-budget probe timeout now keeps the adb message at both pollers, and the TOOL_MISSING branch now comes before the budget-spent branch. CI is green on this commit and there are no conflicts.

Not blocking, take or leave:

  • A transport failure with reason ADB_TRANSPORT_UNAVAILABLE (for example device_unauthorized) that lands at or after the deadline still reports "did not finish booting in time" (emulator-lifecycle.ts#L196). Checking that reason before the budget-spent branch, instead of keying only on TOOL_MISSING, would cover it.
  • AndroidBootFailureDetails is exported at emulator-lifecycle.ts#L175 but nothing imports it. Drop the export or annotate the readiness details literal with it.

The two inline threads fixed at this commit can be resolved: in-budget probe timeout and TOOL_MISSING order.

Not verified here: the tests were not run locally and there was no device run. Retry and terminal decisions are unchanged, so only the error shape needed checking. Whether retryWithPolicy or runAndroidHostAdb can throw a non-AppError into the lifecycle poller was not checked; that behavior is unchanged from the base.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 20, 2026
@thymikee

Copy link
Copy Markdown
Member Author

Pushed 0d94142006 with both optional notes from the review at 8514e67. Both hold.

  • Transport failure before the budget wording: the builder now checks ADB_TRANSPORT_UNAVAILABLE before the budget-spent branch. A late device unauthorized keeps its own message and is not reported as a boot timeout. A transient offline observation never reaches this branch: the lifecycle poller normalizes it to ANDROID_BOOT_TIMEOUT, and the readiness poller retries it. New test: "an unauthorized device keeps its own message when the probe also spent the budget".
  • Unused export: AndroidBootFailureDetails is now module-local.

Both inline threads were already resolved. The readiness and lifecycle suites pass (34 tests); typecheck and lint are clean. Hosted CI validates this head.

@thymikee

Copy link
Copy Markdown
Member Author

Coverage failed at 0d94142006 on test/integration/provider-scenarios/ios-wait-selector.test.ts ("Apple wait text ignores a text field's typed value but matches its label"). That is the wait verdict flake from #4794, which #4814 fixes. This PR does not touch that path. I reran the failed job.

@apex-sentinel-staging

Copy link
Copy Markdown

Apex Sentinel · ✅ Approve · review of 0d94142

Since the review of 8514e67: 0 new · 0 still open · 0 no longer raised

No open findings.

1 finding below minor hidden (user_settings.min_severity).

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

💬 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
thymikee merged commit 2cde6a0 into main Nov 20, 2026
22 of 23 checks passed
@thymikee
thymikee deleted the fix/android-boot-poller-followups branch November 20, 2026 15:26
thymikee added a commit that referenced this pull request Nov 20, 2026
…nts-main

* origin/main:
  docs(commands): generate the keyboard, scroll, and clipboard API blocks (#4809)
  refactor(host-kit): move settleWithin to a dependency-free leaf module (#4816)
  fix(android): share the boot error shape and pin the offline boot-probe retry (#4812)
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