Repository navigation
fix(android): check ownership before a failed boot stops its emulator - #4991
Conversation
#4863 stops the emulator a cold boot launched when that boot fails, and the stop is gated only by the `device-shutdown` policy. A second `open` that binds to the booting `emulator-NNNN` becomes that emulator's owner, and the first open's later failure stopped it out from under that owner. The daemon's failed-open cleanup (#4842) already refuses to stop a launch somebody else holds; the readiness stop had no such answer. Readiness now asks whoever owns the boot before its stop signals the launched pid. The daemon answers from the same session and claim state its cleanup reads, under that device's claim lock, so a claim being written right now answers as ownership too. A held device is never signaled, whichever reason failed the boot, and an answer that cannot be reached keeps the launch. A route that opens no session, such as `boot`, has no ownership to ask about and keeps following the boot's own rule. Keeping a launch after its own failure is now the boot wait's own knowledge rather than an undocumented `bootBudgetSpent` field on the error's details. Taking the optional notes from #4863's final review: ADR 0029's amendment now says the emulator host gates its own `terminate` and the launched-process stop uses the request-level flag, and a composition test pins the shutdown gate into the composed emulator host's `terminate`.
Size Report
Startup median (7 runs, lower is better):
|
The readiness stop already keeps a launch when nobody can say who owns the emulator, but it swallows the reason. It now emits android_emulator_launch_ownership_unanswered, in the same style as the terminate refusal beside it, and the open's help, the command docs and ADR 0029 say that an unreachable answer stops nothing. The failed-open cleanup asks the session half of the same question through holdsDeviceInAnotherSession, so both stops read ownership one way.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Apex Sentinel: 1 new finding on a403ceb. The verdict and the full list are in the summary comment.
|
The ownership check in a403ceb covers only boots that start from Only The new sentence in commands.md:256 sits in a paragraph that ends with " This change alters whether a launched emulator process is terminated after a failed or canceled cold boot, which is a device-facing path, and the PR lists device-free validation only. Live evidence is required before merge. Run Could the check live where the #4863 policy gate already lives? The daemon-composed emulator host's terminate could take the device beside the pid and ask, under that device's claim lock, whether another session or a foreign claim holds it. It could reuse Not blocking, and these can be taken or left: the answer is read and the claim lock released before One lower-priority open inline thread, on the AVD-keyed question before discovery returns, still applies. The code needs the changes above. The 5 non-passing checks are cancelled Body rules runs that look superseded by PR-body edits, and the other 17 checks pass. Not verified here: that the latest Body rules run succeeded, that any tests were run, that the six base-failing tests fail at base, and that the finding above reproduces live. There are no conflicts. Before merge, cover every daemon route that can terminate a failed boot's launch (or rescope #4867 and fix the |
Sessions and device claims are keyed under the emulator's serial, so an AVD name is not an address anything can be held under. Asking ownership about a boot that never resolved a serial could therefore only answer "not held", which is a guess at somebody else's emulator: the guard was vacuous exactly when the boot failed before discovery named the serial, and the stop killed the emulator a concurrent open had already taken. Readiness now treats that answer as unknown and keeps the launch, the same way it treats an unreachable one, and records android_emulator_launch_ownership_unanswered with the reason. No re-resolution is added: whoever resolves the serial is the open that binds to it. The daemon test pinned the vacuous false answer for an AVD; it asks about a serial nobody holds instead, which is the other real answer.
…boot Only `open` reads the session and claim state that answers ownership, and only an `open` publishes the session a held device would belong to. `boot`, app deployment, `apps`, `appstate`, `push` and `doctor` keep the boot's own rule and stop their launch; covering every route from the daemon's readiness composition is filed as a follow-up (#4867 comment r4660185881 finding). The commands doc sentence and ADR 0029 said the whole boot-time rule, including `boot` and deployment, stops nothing when the device is held. They now state the scope: only `open` asks who holds the emulator.
This comment has been minimized.
This comment has been minimized.
|
The pre-serial pick is fixed at 793a34b, but the new keep path orphans an emulator on an early-canceled runtime.ts:134 now answers "held" whenever The PR changes whether a launched emulator process is terminated after a failed or canceled cold boot. That is a device-facing lifecycle path, and the PR body still lists only device-free validation at a403ceb. Required before merge: on an isolated The thread at #4991 (comment) (pre-serial AVD stop) is fixed at this head, in runtime.ts rather than the cited file, and its cost is the first finding. Not blocking, and fine to take or leave: ADR 0029 line 31 has a stray "—." and says twice that boot and app deployment stop their launch, and it names a follow-up for the other routes without an issue, so dropping the duplicate clause and filing and citing that issue would tidy it. Not verified here: tests were not run locally, the length of the pre-serial window on a real host was not measured, and the "6 fail at base / 73 pass" count refers to a403ceb and was not re-checked for this head. The earlier findings are at #4991 (comment). |
Ownership is recorded under the emulator's serial, so a boot that failed before discovery named one has nothing to ask about. Settling that address would take one more inventory pass, and every inventory probe runs under the request's own signal, which a canceled request has already aborted: the pass could only fail. Ask ownership only of a boot that resolved a serial, and let the earlier window stop its launch as base did, so no emulator is left running with no session to own it (#4863). Issue #4993 tracks giving that window, and every other daemon route that can stop a failed boot's launch, an ownership answer from state that needs no inventory. Co-authored-by: Apex powered by GPT-5.6 <noreply@callstack.com>
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Apex Sentinel: 1 new finding on 7f2da86. The verdict and the full list are in the summary comment.
|
Fixed at I did not take the bounded discover. Every inventory probe runs its command under the request's own scope signal, which a canceled request has already aborted, and ADR 0029 line 31: duplicate clause dropped, the stray Live evidence at this head is in the PR body: three |
android_emulator_launch_ownership_unanswered recorded the ownership caller's error message as its `reason`. Report the typed reason code `ownership-query-failed` there and carry the message as `error`, so a reader of the diagnostic log groups unanswered ownership questions by why, not by the text each caller happened to throw. Co-authored-by: Apex powered by GPT-5.6 <noreply@callstack.com>
Apex Sentinel · ✅ Approve · review of
|
| 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.
|
Both problems from the earlier review (793a34b, #4991 (comment)) are fixed at ebce477, and the code looks good. A launch that has no serial yet now stops as on base, with a cancel-before-discovery test that asserts the terminate. The PR also adds live stop, keep and pre-serial evidence. The ownership-query failure now reports reason 'ownership-query-failed' with the thrown message, and runtime.test.ts asserts the full payload, so the thread at #4991 (comment) can be resolved. The thread at #4991 (comment) does not apply any more: the pre-serial window is accepted as meeting #4867 and tracked in #4993, so it can be resolved too. All 17 checks pass at this commit, and no conflicts were reported. Not verified here: the tests were not run locally, and the '3 of 35 fail at base' count was not reproduced. The live runs were made at 7f2da86, and only the diagnostic payload changed since. The PR body summarizes those runs, so the full command lines and device status output were not reproduced. No further change is needed before merge. |
…#4991) * fix(android): check ownership before a failed boot stops its emulator stop is gated only by the `device-shutdown` policy. A second `open` that binds to the booting `emulator-NNNN` becomes that emulator's owner, and the first open's later failure stopped it out from under that owner. The daemon's failed-open cleanup (#4842) already refuses to stop a launch somebody else holds; the readiness stop had no such answer. Readiness now asks whoever owns the boot before its stop signals the launched pid. The daemon answers from the same session and claim state its cleanup reads, under that device's claim lock, so a claim being written right now answers as ownership too. A held device is never signaled, whichever reason failed the boot, and an answer that cannot be reached keeps the launch. A route that opens no session, such as `boot`, has no ownership to ask about and keeps following the boot's own rule. Keeping a launch after its own failure is now the boot wait's own knowledge rather than an undocumented `bootBudgetSpent` field on the error's details. Taking the optional notes from #4863's final review: ADR 0029's amendment now says the emulator host gates its own `terminate` and the launched-process stop uses the request-level flag, and a composition test pins the shutdown gate into the composed emulator host's `terminate`. * fix(android): record an unanswered ownership question The readiness stop already keeps a launch when nobody can say who owns the emulator, but it swallows the reason. It now emits android_emulator_launch_ownership_unanswered, in the same style as the terminate refusal beside it, and the open's help, the command docs and ADR 0029 say that an unreachable answer stops nothing. The failed-open cleanup asks the session half of the same question through holdsDeviceInAnotherSession, so both stops read ownership one way. * fix(android): keep a launch whose boot never resolved a serial Sessions and device claims are keyed under the emulator's serial, so an AVD name is not an address anything can be held under. Asking ownership about a boot that never resolved a serial could therefore only answer "not held", which is a guess at somebody else's emulator: the guard was vacuous exactly when the boot failed before discovery named the serial, and the stop killed the emulator a concurrent open had already taken. Readiness now treats that answer as unknown and keeps the launch, the same way it treats an unreachable one, and records android_emulator_launch_ownership_unanswered with the reason. No re-resolution is added: whoever resolves the serial is the open that binds to it. The daemon test pinned the vacuous false answer for an AVD; it asks about a serial nobody holds instead, which is the other real answer. * docs(4867): scope the ownership answer to the open that launched the boot Only `open` reads the session and claim state that answers ownership, and only an `open` publishes the session a held device would belong to. `boot`, app deployment, `apps`, `appstate`, `push` and `doctor` keep the boot's own rule and stop their launch; covering every route from the daemon's readiness composition is filed as a follow-up (#4867 comment r4660185881 finding). The commands doc sentence and ADR 0029 said the whole boot-time rule, including `boot` and deployment, stops nothing when the device is held. They now state the scope: only `open` asks who holds the emulator. * fix(android): stop a launch whose boot failed before a serial exists Ownership is recorded under the emulator's serial, so a boot that failed before discovery named one has nothing to ask about. Settling that address would take one more inventory pass, and every inventory probe runs under the request's own signal, which a canceled request has already aborted: the pass could only fail. Ask ownership only of a boot that resolved a serial, and let the earlier window stop its launch as base did, so no emulator is left running with no session to own it (#4863). Issue #4993 tracks giving that window, and every other daemon route that can stop a failed boot's launch, an ownership answer from state that needs no inventory. Co-authored-by: Apex powered by GPT-5.6 <noreply@callstack.com> * fix(android): keep the ownership diagnostic's reason a code android_emulator_launch_ownership_unanswered recorded the ownership caller's error message as its `reason`. Report the typed reason code `ownership-query-failed` there and carry the message as `error`, so a reader of the diagnostic log groups unanswered ownership questions by why, not by the text each caller happened to throw. Co-authored-by: Apex powered by GPT-5.6 <noreply@callstack.com> --------- Co-authored-by: Apex powered by GPT-5.6 <noreply@callstack.com>
…callstack#4991) * fix(android): check ownership before a failed boot stops its emulator stop is gated only by the `device-shutdown` policy. A second `open` that binds to the booting `emulator-NNNN` becomes that emulator's owner, and the first open's later failure stopped it out from under that owner. The daemon's failed-open cleanup (callstack#4842) already refuses to stop a launch somebody else holds; the readiness stop had no such answer. Readiness now asks whoever owns the boot before its stop signals the launched pid. The daemon answers from the same session and claim state its cleanup reads, under that device's claim lock, so a claim being written right now answers as ownership too. A held device is never signaled, whichever reason failed the boot, and an answer that cannot be reached keeps the launch. A route that opens no session, such as `boot`, has no ownership to ask about and keeps following the boot's own rule. Keeping a launch after its own failure is now the boot wait's own knowledge rather than an undocumented `bootBudgetSpent` field on the error's details. Taking the optional notes from callstack#4863's final review: ADR 0029's amendment now says the emulator host gates its own `terminate` and the launched-process stop uses the request-level flag, and a composition test pins the shutdown gate into the composed emulator host's `terminate`. * fix(android): record an unanswered ownership question The readiness stop already keeps a launch when nobody can say who owns the emulator, but it swallows the reason. It now emits android_emulator_launch_ownership_unanswered, in the same style as the terminate refusal beside it, and the open's help, the command docs and ADR 0029 say that an unreachable answer stops nothing. The failed-open cleanup asks the session half of the same question through holdsDeviceInAnotherSession, so both stops read ownership one way. * fix(android): keep a launch whose boot never resolved a serial Sessions and device claims are keyed under the emulator's serial, so an AVD name is not an address anything can be held under. Asking ownership about a boot that never resolved a serial could therefore only answer "not held", which is a guess at somebody else's emulator: the guard was vacuous exactly when the boot failed before discovery named the serial, and the stop killed the emulator a concurrent open had already taken. Readiness now treats that answer as unknown and keeps the launch, the same way it treats an unreachable one, and records android_emulator_launch_ownership_unanswered with the reason. No re-resolution is added: whoever resolves the serial is the open that binds to it. The daemon test pinned the vacuous false answer for an AVD; it asks about a serial nobody holds instead, which is the other real answer. * docs(4867): scope the ownership answer to the open that launched the boot Only `open` reads the session and claim state that answers ownership, and only an `open` publishes the session a held device would belong to. `boot`, app deployment, `apps`, `appstate`, `push` and `doctor` keep the boot's own rule and stop their launch; covering every route from the daemon's readiness composition is filed as a follow-up (callstack#4867 comment r4660185881 finding). The commands doc sentence and ADR 0029 said the whole boot-time rule, including `boot` and deployment, stops nothing when the device is held. They now state the scope: only `open` asks who holds the emulator. * fix(android): stop a launch whose boot failed before a serial exists Ownership is recorded under the emulator's serial, so a boot that failed before discovery named one has nothing to ask about. Settling that address would take one more inventory pass, and every inventory probe runs under the request's own signal, which a canceled request has already aborted: the pass could only fail. Ask ownership only of a boot that resolved a serial, and let the earlier window stop its launch as base did, so no emulator is left running with no session to own it (callstack#4863). Issue callstack#4993 tracks giving that window, and every other daemon route that can stop a failed boot's launch, an ownership answer from state that needs no inventory. Co-authored-by: Apex powered by GPT-5.6 <noreply@callstack.com> * fix(android): keep the ownership diagnostic's reason a code android_emulator_launch_ownership_unanswered recorded the ownership caller's error message as its `reason`. Report the typed reason code `ownership-query-failed` there and carry the message as `error`, so a reader of the diagnostic log groups unanswered ownership questions by why, not by the text each caller happened to throw. Co-authored-by: Apex powered by GPT-5.6 <noreply@callstack.com> --------- Co-authored-by: Apex powered by GPT-5.6 <noreply@callstack.com>
…#4991) * fix(android): check ownership before a failed boot stops its emulator stop is gated only by the `device-shutdown` policy. A second `open` that binds to the booting `emulator-NNNN` becomes that emulator's owner, and the first open's later failure stopped it out from under that owner. The daemon's failed-open cleanup (#4842) already refuses to stop a launch somebody else holds; the readiness stop had no such answer. Readiness now asks whoever owns the boot before its stop signals the launched pid. The daemon answers from the same session and claim state its cleanup reads, under that device's claim lock, so a claim being written right now answers as ownership too. A held device is never signaled, whichever reason failed the boot, and an answer that cannot be reached keeps the launch. A route that opens no session, such as `boot`, has no ownership to ask about and keeps following the boot's own rule. Keeping a launch after its own failure is now the boot wait's own knowledge rather than an undocumented `bootBudgetSpent` field on the error's details. Taking the optional notes from #4863's final review: ADR 0029's amendment now says the emulator host gates its own `terminate` and the launched-process stop uses the request-level flag, and a composition test pins the shutdown gate into the composed emulator host's `terminate`. * fix(android): record an unanswered ownership question The readiness stop already keeps a launch when nobody can say who owns the emulator, but it swallows the reason. It now emits android_emulator_launch_ownership_unanswered, in the same style as the terminate refusal beside it, and the open's help, the command docs and ADR 0029 say that an unreachable answer stops nothing. The failed-open cleanup asks the session half of the same question through holdsDeviceInAnotherSession, so both stops read ownership one way. * fix(android): keep a launch whose boot never resolved a serial Sessions and device claims are keyed under the emulator's serial, so an AVD name is not an address anything can be held under. Asking ownership about a boot that never resolved a serial could therefore only answer "not held", which is a guess at somebody else's emulator: the guard was vacuous exactly when the boot failed before discovery named the serial, and the stop killed the emulator a concurrent open had already taken. Readiness now treats that answer as unknown and keeps the launch, the same way it treats an unreachable one, and records android_emulator_launch_ownership_unanswered with the reason. No re-resolution is added: whoever resolves the serial is the open that binds to it. The daemon test pinned the vacuous false answer for an AVD; it asks about a serial nobody holds instead, which is the other real answer. * docs(4867): scope the ownership answer to the open that launched the boot Only `open` reads the session and claim state that answers ownership, and only an `open` publishes the session a held device would belong to. `boot`, app deployment, `apps`, `appstate`, `push` and `doctor` keep the boot's own rule and stop their launch; covering every route from the daemon's readiness composition is filed as a follow-up (#4867 comment r4660185881 finding). The commands doc sentence and ADR 0029 said the whole boot-time rule, including `boot` and deployment, stops nothing when the device is held. They now state the scope: only `open` asks who holds the emulator. * fix(android): stop a launch whose boot failed before a serial exists Ownership is recorded under the emulator's serial, so a boot that failed before discovery named one has nothing to ask about. Settling that address would take one more inventory pass, and every inventory probe runs under the request's own signal, which a canceled request has already aborted: the pass could only fail. Ask ownership only of a boot that resolved a serial, and let the earlier window stop its launch as base did, so no emulator is left running with no session to own it (#4863). Issue #4993 tracks giving that window, and every other daemon route that can stop a failed boot's launch, an ownership answer from state that needs no inventory. Co-authored-by: Apex powered by GPT-5.6 <noreply@callstack.com> * fix(android): keep the ownership diagnostic's reason a code android_emulator_launch_ownership_unanswered recorded the ownership caller's error message as its `reason`. Report the typed reason code `ownership-query-failed` there and carry the message as `error`, so a reader of the diagnostic log groups unanswered ownership questions by why, not by the text each caller happened to throw. Co-authored-by: Apex powered by GPT-5.6 <noreply@callstack.com> --------- Co-authored-by: Apex powered by GPT-5.6 <noreply@callstack.com>
Summary
Readiness stops the emulator a failed cold boot launched (#4863), gated only by
device-shutdownpolicy. A secondopenthat binds to the bootingemulator-NNNNbecomes its owner; the first open's later failure stopped it from under that owner. The failed-open cleanup (#4842) already refuses that; readiness had no such answer. Fixes #4867.EnsureReadyInputgainsisAndroidEmulatorHeldByOther, answered from the session and claim state the cleanup reads, under the device's claim lock, so a claim in flight counts too. A held device is never signaled; an unreachable answer also stops nothing, recorded byandroid_emulator_launch_ownership_unanswered. Ownership is recorded under the serial, so only a boot that resolved one asks; an earlier failure stops its launch as base did. Other routes keep asking nothing (#4993). Keeping a launch is now the boot wait's own knowledge; ADR 0029 reworded; a test pins the policy gate.Before / after
Validation
Evidence at
7f2da869bc; headebce477210adds only a typed diagnostic reason. Reverting readiness sources to base fails 3 of that suite's 35 tests; all 35 pass at head. Green:typecheck,format, daemon, readiness, host, doc-guard suites.Live,
node bin/agent-device.mjsat this head, isolated--state-dir, AVDfocus-order-probe-api37,device statusbefore: no claims:Cleanup: sessions closed, scratch claims and state dirs removed, nothing left running.
🤖 Generated with Claude Code