Skip to content

fix(android): propagate typed boot readiness and request cancellation - #4610

Merged
thymikee merged 13 commits into
mainfrom
t3/android-main-rebase-validation
Nov 17, 2026
Merged

thymikee merged 13 commits into
mainfrom
t3/android-main-rebase-validation

Conversation

@thymikee

@thymikee thymikee commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Summary

Use typed Android boot observations and effective request cancellation/cutoffs for readiness. Refuse expired dispatch/cache publication and preserve recording recovery's own scope. Construct ordinary scopes in daemon core; retain explicit lower/resource/recovery scopes and the replay relay. Preserve typed abort reasons; remove unused Android classifier branches.

This coherent change touches 46 files. Unclassified error: closed stays terminal; typed offline retains its retry exception. Refs #4426. #4512 is closed under the readiness Decision; this PR is ready for review.

Validation

Head 7a3c272df8fb785c7155c427ee30c87757f0fb72: exact check:affected --run --base fdf595127a756647dd211dcdd19deeaa9968a468 --head 7a3c272df8fb785c7155c427ee30c87757f0fb72 --json passed; exactCommit=true, checkoutChanged=false. Full selection (failOpen=true): 42 checks passed/25 skipped, 415 related, 20,197 unit passed/10 skipped; #4050 retained. Skips receive no pass credit.

Independent source/smaller-design and live-child evidence reviews accepted production at 7f380954, byte-identical here. Settings-write controls:20passed; isolated write-only mutant:1failed/19passed; restore:20passed. Eleven earlier mutants retain7f attribution.

API35 actual daemon-route readiness/SIGINT proof and replay deadline response ran with candidate0.21.38-dev/client0.21.36. The latter returned REPLAY_DIVERGENCE, reason=daemon_request_timeout, causeReason=request_canceled, timeoutMs=2500, and killed an unpaused live adb child. No dispatched field was emitted. Fresh polling was observed; after-abort cache-guard proof remains deterministic tests.

Evidence and limits. CI:13success/5draftskips; Sentinel approves7a3c. Ready CI:18success/5historicalskips/1Cubicneutral(quota),no failures. Historical causes stay unproven. Do not merge.

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Size Report

Metric Base Current Diff
Installed (including dependencies) 6.33 MB 6.33 MB +1.5 kB
Package (unpacked) 6.33 MB 6.33 MB +1.5 kB
Package (download) 1.92 MB 1.92 MB +488 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 31.7 ms 35.7 ms +4.0 ms
CLI --help 70.8 ms 66.5 ms -4.4 ms

@thymikee

Copy link
Copy Markdown
Member Author

Validation receipt at 3c1cb569742bc4e158ff0cd6703ab26f40a07193 (base 83a8e530997f31ec57b815b58bef1f050d09dae5):

  • Pinned pnpm 11.17.0 frozen install/build and full repository format passed.121 focused and56 interaction tests passed.
  • One exact affected gate,18:15:32–18:23:03UTC: passed/exit0; exactCommit=true, checkoutChanged=false, identical initial/final fingerprints, failOpen=false. Format/lint/typecheck/layering/Fallow/build/related/unit passed. Related: 415; unit: 20,192 passed / 10 skipped, zero failed/unhandled. investigate(gates): model source-reading test dependencies before narrowing selection #4050 full-unit fallback retained.
  • Eight skips retain GitHub/manual owners: coverage, web-smoke, iOS replay, iOS-device replay, macOS replay, Linux replay, Linux command evidence, Android replay. Provider integration is deduplicated against related tests. None receives an independent pass claim. Draft platform CI skips also remain skips.
  • Independent review accepted 5721; coordinator rebase review compared every changed path and all nine patch IDs.105 of 106 files match; the sole type addition exactly matches upstream. Source tree 6e9dc13fa446aedc41489a01709227eec5d6da05. Later main release metadata is disjoint.

Native evidence remains at 57217458 / API 35: actual candidate polling observed9 offline failures and15 not-ready reads, then success in 24.98 s with 60 s / 10 s / 1 s limits unchanged. A separate later candidate HTTP Settings snapshot used matching helper 0.21.38-dev. Full HTTP cold-boot/native cancellation remains unproven. Native owner source is unchanged by the rebase. Owned resources were stopped; evidence and stopped AVD metadata retained.

Historical helper/guard/WebOS/API36 causes remain unproven. Old failed/inconclusive receipts are retained. Earlier mutation experiments used the implementation checkout under a mistaken coordinator constraint; this was not a user override. Verified restorations and the later exact gate remain evidence with that process limitation. The original co-stamped timeout-arm-only mutant survivor is disclosed. Unclassified error: closed remains terminal by the adopted policy.

This PR remains blocked draft under #4512, with CI pending and no merge authorization. Publication does not close #4426 or #4512. See the linked issue's Current state for the full evidence and limits.

@apex-sentinel-staging

apex-sentinel-staging Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Apex Sentinel · ✅ Approve

Since the last review: 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 (27a4e409dae6).

💬 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.

Earlier reviews

Review of 3c1cb569 · 16.11.2026 18:41 UTC

Apex Sentinel · ✅ Approve

No open findings.

1 finding below minor hidden (user_settings.min_severity).

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

@thymikee

Copy link
Copy Markdown
Member Author

I reviewed 3c1cb56. The code looks sound from the diff, but the daemon readiness route has no live run yet, so it needs one before merge. CI is green (18 checks, 0 failing), but the draft platform replay lanes are skipped, so the Android replay route has no CI pass credit. No conflicts.

This change is device-facing: device-ready.ts:29 now hands the request signal to the live adb getprop child and kills it on client cancel or deadline. It also changes which real adb outcomes retry. The only native run (57217458) polled waitForAndroidBoot directly and took a snapshot on an already-booted device. Nothing has reached the daemon readiness route on a booting device or cancelled it mid-poll, so cancellation and no-cache-publication are proven only with a mocked runCmd. A real adb child that ignores the abort, or a getprop that returns after the kill, would go unseen. Please run two checks at head on a booting Android emulator (sys.boot_completed=0, adb state device or offline) with no session, using agent-device snapshot --platform android --serial <s> --json or clipboard read. First, let it go offline, then not-ready, then booted. Record success and the getprop poll count from --verbose. Second, repeat from a fresh boot with a short --timeout or a Ctrl-C mid-poll. Record a daemon_request_timeout or request_canceled response with dispatched:no, no leftover adb shell getprop in ps, and a next request that polls again instead of hitting the TTL cache.

Not blocking, so take or leave these: (1) emulator-lifecycle.ts:88 dropped allowFailure, so any non-zero getprop exit now throws and only adb-failure.ts-stamped retriable failures retry. adbd restarts during boot often print error: closed (exit 1), which no matcher covers, so on base it retried as still booting but now ends with BOOT_COMMAND_FAILED. If that is a transient drop, add it to the connection_dropped matcher in adb-failure.ts so every adb caller gets one outcome; otherwise record the decision on #4426. (2) Every EnsureLocalDeviceReady implementation should forward the signal it receives. platform-runtime-device-ready.ts:15 calls ensureBootedSimulator(device) without {signal}, and the physical-device path gets none. app-lifecycle.ts:207 and :614 still call waitForAndroidBoot without runnerContext.signal. Pass it, or list those as out of scope. (3) readiness/runtime.ts:114 is a second Android boot poller, used on the open/install cold-boot route. It still polls with allowFailure:true and retries every outcome, including device_unauthorized, until the deadline. One module should own Android boot retry: route it through the same typed predicate or through waitForAndroidBoot, or name it as remaining scope on #4426. (4) No production caller passes platform 'android' to classifyBootFailure now. The remaining callers are apple-runner runner-startup-transport.ts:512/554 and simulator.ts:94, all 'ios'. The android branches in boot-diagnostics.ts:94 are dead and kept alive only by their tests, so delete them and import type BootFailureReason in emulator-lifecycle.ts:8. (5) request-cancel.ts:191 aborts children from the parent chain, and replay test-command.ts:88 relayReplayTestAbortFromParent already does the same for the same child controller. Keep one owner for parent-to-child cancellation. (6) emulator-lifecycle.ts:55 and :83 throw a fresh createRequestCanceledError() on abort and drop signal.reason, which carries the owner's details such as {timeoutMs, requestId}. signal.throwIfAborted() keeps them. (7) About 60 call sites in interaction-touch-routing.test.ts:46 and similar paste requestScope: platformRequestScopeFixture() next to req. session-command-harness.ts defaults it, but the other route harnesses do not, so default it in each harness or drop the required field.

Could the design be smaller? Carry only the AbortSignal to readiness: ensureDeviceReady(device, services, signal) calls signal.throwIfAborted() before the cache read and after the wait, and EnsureLocalDeviceReady forwards it to waitForAndroidBoot and ensureBootedSimulator. That would drop PlatformRequestScope.checkDeadline, throwIfRequestExecutionDeadlineExceeded, the recovery-authority checkDeadline wrapper and the parent-chain and same-request deadline-set rework in request-cancel.ts. The deadline timer already aborts the signal, and a boot_completed=1 observation cached in the same tick as the cutoff is still true. The signal could come from the readiness owner (one new readinessScope field set from createPlatformRequestScope(req) where readiness: true is set) or from the per-request scope the router already installs. That would keep the production change near emulator-lifecycle.ts, device-ready.ts, platform-services.ts, platform-runtime-device-ready.ts and runtime-admission.ts, and remove most of the 73 fixture edits. It would also fit with one Android boot poller and no android branch in classifyBootFailure. What has to be decided first, on #4426, is whether "expired work must not publish cache entries" must hold within the same event-loop tick, which needs checkDeadline, or only after timer delivery, where the signal is enough. Should execution/ build the platform scope from req, or should createPlatformRequestScope move out of server/?

From the diff, the HTTP cancellation tests would fail on base, since base never passed a signal to waitForAndroidBoot, and the typed-retry tests would fail on base, since base treated offline as terminal and closed as retried. Does error: closed actually appear during getprop polling on current emulator images?

Before merge, this needs the live daemon-route run above and a maintainer answer on the checkDeadline and requestScope question, ideally before more fixture changes.

@thymikee

thymikee commented Nov 16, 2026 •

Copy link
Copy Markdown
Member Author

The correction is implemented and locally validated at 7a3c272df8fb785c7155c427ee30c87757f0fb72. Decisions6929136812 and6946057975 retain synchronous execution/recovery cutoff and adopt the core scope factory. The seven ordinary request-bearing sites construct from the router's same admitted request; lower/resource/recovery scopes and the replay relay remain explicit. The factory move has no shim. The cumulative diff is46files/1907gross. Independent source/cumulative smaller-design review found no blocking regression; root added the review's missing settings-write cancellation row and detected a write-only scope-loss mutant.

The live daemon route now has separate readiness-success and cancellation evidence at7f380954's production, which is byte-identical in 7a3c272df8fb785c7155c427ee30c87757f0fb72. On the owned API35AVD, sessionless snapshot readiness reached boot completion; the earlier follow-up snapshot succeeded through matching android-helper0.21.38-dev. Another bounded run deliberately SIGSTOPped only the verified actual readiness adb child—not the emulator, adb server or a replacement binary. The pinned client's distinct group received SIGINT at12:46:23.356Z; candidate exec recorded abort at.360Z and SIGKILL exit/abort settlement at.361Z. The stopped child had no descendants and was gone5ms afterSIGINT, before its10s timeout. The observer never sent a cleanup kill. No dispatch phase was logged for the canceled request; that is not an observed dispatched:no field. All61observed daemon children were gone at the end. A request admitted223ms afterSIGINT started a fresh readiness getprop448ms afterSIGINT, inside the5s TTL, rather than using the cache; it completed readiness on attempt7 about6.6s later. The subsequent helper capture attempt returned system-window-only with dispatched:no because the launcher was not up. This is not a successful snapshot. The canceled wait had never observed boot_completed=1, so the native follow-up does not discriminate the after-abort cache-publication guard; deterministic tests cover that guard. The induced pause is disclosed test setup, not a naturally hanging adb claim.

Native identity is stronger than the unchanged entry wrapper hash: an independent pinned rebuild of7f380954 matched all529relative-import closure modules byte-for-byte. The daemon ran from that isolated rebuild. It was candidate0.21.38-dev; the T3-pinned client was installed0.21.36. Boots/shutdown used T3; owned config restored byte-identically, daemon/session/child cleanup verified. No shared adb server/foreign device was signaled.

Limits: inventory excludes offline devices before route readiness; no route-level offline transition is claimed. The original5721direct boot-owner proof retains its own offline authority. Native request logs omit details.reason and SIGINT ends the client without a body: the structured native evidence is executor reason abort and SIGKILL, not a directly observed request_canceled response. The real-HTTP regression tests separately assert typed request_canceled; no behavior is inferred by matching message text. Delayed-timer cutoffs remain deterministic HTTP/recovery evidence. No other platform, second poller, provider or candidate-client coverage is implied. The earlier cache timeout-spawn counts are corrected to10/9/10 without changing the cache conclusion.

Optional items: (1)untyped closed stays terminal under6876280645; (2)Apple/physical/app-lifecycle forwarding and(3)second Android poller remain explicit residuals; (4)unused Android classifier branches are removed after private-package/consumer checks; (5)relay retained because the parent link has no immediate subscription; (6)owner AppError reason is preserved, generic/reason-less abort remains typed request_canceled with cause; (7)readiness-only fixture plumbing removed without deleting semantic assertions.

Exact check:affected --run --base fdf595127a756647dd211dcdd19deeaa9968a468 --head 7a3c272df8fb785c7155c427ee30c87757f0fb72 --json passed: exactCommit=true, checkoutChanged=false, identical clean fingerprints;42checks passed/25skipped,415related,20,197unitpassed/10skipped. plan.failOpen=true expanded to full selection for the changed layering test; #4050 retained. Skips keep their named GitHub/manual owners and receive no pass credit. Canonical and isolated controls passed20/20; the write-only mutation failed at the intended abort assertion(1failed/19passed), then restored20/20. Independent source/smaller-design and native-evidence reviews accepted their precise scopes. An additional bounded native replay→snapshot run now observes the structured daemon response. One .ad line(snapshot), ordinary --timeout2500 work budget and32500ms client envelope kept the installed client alive. Its JSON body is REPLAY_DIVERGENCE with details.reason=daemon_request_timeout,causeReason=request_canceled,timeoutMs=2500,requestId=b25fddd1e97bf913,step1/line1. The device was admitted in state device and its boot property was empty(not1). Readiness attempts1/2 were not-ready; ordinary unpaused getpropPID90380 was still in flight at the parent deadline(2502ms), then candidate exec recorded abort/SIGKILL with no later helper/capture phase. A follow-up started immediately and polled fresh0.52s later; it passed readiness, then its own2.5s deadline cut helper capture. No retry, manual process pause or signal occurred in this attempt. No dispatched field was emitted; no-dispatch evidence is phase absence and no new daemon child before the follow-up, not a fabricated field. The native after-abort publication guard is still not discriminated because the canceled wait never observed1. Client JSON was captured, not rawHTTPbytes. All54children, daemon/sessions and owned AVD were stopped; config restored exactly. Root verified the62-file manifest, response JSON and matching exec-abort/SIGKILL records. Production identity remains7f, byte-identical in published7a3c.

The maintainer has now authorized readiness and closure of the historical diagnosis. #4512 is closed as not planned under #4512 (comment); #4426 (comment) removes the current7a3c draft block. Historical causes remain unproven and old failed/inconclusive receipts remain unchanged: no fixed-defect claim or gate weakening follows. Human comment6950247930 confirms code/live-evidence readiness. #4610 is now ready for review; ready-triggeredCIisnowcomplete:18SUCCESS/5historicalSKIPPED/1NEUTRAL,MERGEABLE/CLEAN, including newAndroid/iOS/macOS/Linux smoke successes. Sentinel approval remains. CubicNEUTRAL is a monthly review-line quota,0annotations, not a finding or approval; no retry/config change is selected. The round watch was stopped for human inbox handoff; the single published-only backstop continues. Optional shared abort-helper cleanup is nonblocking/deferred without an open placeholder. Earlier mutation-isolation/shared-metadata/validation-overlap disclosures remain, without contention or historical-cause inference. No merge is authorized.

thymikee and others added 4 commits November 17, 2026 12:14
…sites

Move createPlatformRequestScope from server to core and build the
ordinary readiness scope where the admitted request is already in hand
(sessionless snapshot/diff, selector get/is, wait, clipboard,
keyboard/app-event, alert, settings). Drop the readiness-only
requestScope pass-through fields from interaction, find, generic
settle, snapshot routes, session open and the handler chain, and the
fixture plumbing they required. Request-free admission/binding seams,
SessionCommandInput's resource scope and recording recovery keep their
explicit scopes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…aborts

waitForAndroidBoot now rethrows the abort reason when the owner aborted
with a typed AppError (for example its deadline details) and wraps a
reason-less abort as request_canceled with the reason as cause. Remove
the classifyBootFailure Android branches: every caller passes ios, and
the Android boot loop classifies with its own typed predicate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…cancellation

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@thymikee

Copy link
Copy Markdown
Member Author

The code at 7a3c272 is ready, and the live receipts now cover the Android boot route that the draft-skipped lanes leave unchecked. Thanks for the fixes since the earlier review.

CI shows 18 checks and none failing. The 5 draft-skipped native and replay lanes, including Android replay, give no pass credit for the device route, so the API 35 receipts carry it. The process-table cleanup, poll counts and REPLAY_DIVERGENCE body are from those receipts. The structured deadline response came through a replay step, so a plain snapshot --timeout body was not shown. The route has no dispatched field because readiness fails before capture, so the missing phase is the no-dispatch proof. The after-abort cache guard in device-ready.ts is covered only by deterministic tests. The offline transition on this route was not observed.

There are no conflicts. The PR stays a draft until the maintainer records the #4512 readiness-policy decision and marks it ready.

Not blocking, and fine to take or leave: androidBootCancellation in emulator-lifecycle.ts repeats a rule that three other places already hold (limrun-ios-files.ts, limrun-download-file.ts and the default onAbort in await-with-signal.ts). The kernel copy also maps an AbortSignal.timeout error to operation_deadline_expired, and this copy does not. One exported requestAbortError(signal) beside createRequestCanceledError, using that default mapping, could serve all four sites, and a follow-up is fine.

@thymikee

Copy link
Copy Markdown
Member Author

Now out of draft, so this is ready for maintainer review at 7a3c272: the earlier review found the code clean and the API 35 receipts cover the Android boot route. The open #4512 readiness-policy decision is the only thing left before merge.

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

Copy link
Copy Markdown
Member Author

The #4512 readiness decision is already recorded: closure of the historical diagnosis and current-head readiness. #4512 is closed and its hold on 7a3c272d is removed. Ready-triggered CI is complete: 18 successful checks, five historical skips, and one neutral Cubic quota check. No #4512 readiness blocker remains; the PR is ready for the maintainer's merge decision.

@thymikee
thymikee merged commit 945b1f0 into main Nov 17, 2026
24 checks passed
@thymikee
thymikee deleted the t3/android-main-rebase-validation branch November 17, 2026 16:04
thymikee added a commit that referenced this pull request Nov 20, 2026
…nce (#4426)

The second Android boot poller (waitForBoot in the readiness runtime behind
ensureReady/bootTarget) still made retry/stop decisions from raw probe output:
a terminal device_unauthorized or host refusal was polled until the deadline
and then misreported as boot_timeout, and a probe-level exec timeout escaped
untyped. It now stamps each observation through the existing typed evidence
owner (androidAdbResultError/attachAdbFailureHint classification) and applies
the same shared verdicts as the #4610 lifecycle poller
(isTransientAndroidBootFailure/androidBootFailureReason, now exported from
emulator-lifecycle.ts): transient not-ready/offline observations retry inside
the existing deadline budget, terminal unauthorized/host-refusal/unclassified
outcomes stay terminal with typed adbFailure/reason details, probe timeouts
report ANDROID_BOOT_TIMEOUT, cancellation keeps the abort owner's typed
reason, and deadline expiry keeps the boot_timeout typed outcome.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
thymikee added a commit that referenced this pull request Nov 20, 2026
* fix(android): route the readiness boot poller through typed adb evidence (#4426)

The second Android boot poller (waitForBoot in the readiness runtime behind
ensureReady/bootTarget) still made retry/stop decisions from raw probe output:
a terminal device_unauthorized or host refusal was polled until the deadline
and then misreported as boot_timeout, and a probe-level exec timeout escaped
untyped. It now stamps each observation through the existing typed evidence
owner (androidAdbResultError/attachAdbFailureHint classification) and applies
the same shared verdicts as the #4610 lifecycle poller
(isTransientAndroidBootFailure/androidBootFailureReason, now exported from
emulator-lifecycle.ts): transient not-ready/offline observations retry inside
the existing deadline budget, terminal unauthorized/host-refusal/unclassified
outcomes stay terminal with typed adbFailure/reason details, probe timeouts
report ANDROID_BOOT_TIMEOUT, cancellation keeps the abort owner's typed
reason, and deadline expiry keeps the boot_timeout typed outcome.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>

* test(android): pin the typed boot-probe verdict with identical failure text

* test(android): fold the typed boot-probe verdict pair into one regression

---------

Co-authored-by: Mistral Vibe <vibe@mistral.ai>
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