Repository navigation
fix(android): stop the emulator a failed cold boot left unowned - #4863
Conversation
Live device evidenceRuns on this branch's CLI ( (a) Control — cold open, plain closeRe-ran both at the final head: open success with (b) Deadline expiry keeps the emulator booting (unchanged)Stopped afterwards with (c) Non-deadline failure stops the launched emulatorInjected at the host boundary, scoped to one run: That base/branch pair is the reported bug and its fix: the same failure now takes the emulator this open launched with it, and still reports its own error. Two earlier injection attempts were discarded as invalid — the fake SDK root then had no SDK payload, so the launch never reached the probe and the client hit its own 90s request timeout. |
Size Report
Startup median (7 runs, lower is better):
|
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Apex Sentinel: 4 new findings on 2278187. The verdict and the full list are in the summary comment.
|
Review of 2278187: the new readiness stop bypasses the daemon's device-shutdown policy, so this needs one fix before merge. The stop calls Required before merge: repeat the live failure case on a daemon started with Could the fix stay this small? Keep the readiness stop where the issue puts it, and give its only dependency the existing gate, which is about three lines. That makes readiness stops obey ADR 0029 with no new seam. Not blocking, and fine to take or leave: (1) the readiness stop has no check that another session or claim holds the emulator, so a second Of the open inline threads, the policy gate thread still applies and is the blocking item above, and the ownership check thread still applies as the non-blocking note. One lower-priority thread still applies. The boot-timeout thread does not apply: with the clock below the deadline and reason No conflicts. The only check that is not passing is the other automated review check, which reports the same policy bypass in code this PR changes, so it is likely related; the other 14 checks pass. After the policy gate and the policy-denied live run, nothing else stands between this PR and merge. |
An open that boots a stopped Android emulator stops that launch when the open fails (#4764). A failure inside the boot was outside that rule: readiness terminated the process it launched only when the request was canceled, so a boot that failed for another reason left an emulator running with no session to own it, and no later close ever learned to stop it (#4847). Readiness now decides per failure reason at the owner that holds the launched pid. A refusal that spent the startup budget keeps booting, which is what the --timeout contract and the existing tests promise, and a canceled request keeps terminating its launch. Every other failure after the launch returned a pid stops that process and rethrows its own error: the host could not record the launch, a boot probe failed inside the budget, or discovery went wrong. A terminate that itself throws records a diagnostic naming the boot failure it answers rather than replacing that failure. An emulator that was already running is still never stopped, and the daemon's open orchestration gains no second stop path. commands.md and the open help said a boot that failed before the emulator was ready left it as it is; both now state the final rule.
…icy (#4847) `terminate` is the one teardown a launched emulator's own host can perform, and it was the one shutdown no policy was asked about: `assertShutdownAllowed` guarded only `deviceShutdown`. A daemon that denies `device-shutdown` therefore SIGTERM'd the emulator a failed boot had launched, and a canceled boot had signaled it the same way before this. Pass that assertion to the host that owns the launch and ask it before anything else. A denied daemon now leaves its launch running and the caller keeps the failure that asked: readiness already records a diagnostic when `terminate` throws, and the open reports its own boot error. The keep-decision now reads the boot's phase rather than the clock, so a step after a finished boot cannot read as a spent budget: only a boot-wait poller that ran out that budget keeps its launch. The rule belongs to booting, not to `open`, so `commands.md` says so.
2278187 to
c58a582
Compare
|
Re-review at The gate. Taken from the non-blocking list: (2) the keep-decision reads the boot's phase — a launch is kept only when a boot-wait poller ran out its startup budget, so a step that fails after the boot is done stops it; that removed the clock clause and the redundant reason clause. (3) Live, at Denied policy — Control — same fault, same command, no policy named: The kept emulator was stopped afterwards under a daemon with no policy ( Checks at this head: |
This comment has been minimized.
This comment has been minimized.
… emulator running
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.
|
This PR is ready at 8bf0b9a. The earlier findings from #4863 (comment) are fixed: the keep-boot decision now reads the boot phase and typed evidence, the policy gate reaches the emulator host, and the Not blocking, and these can be taken or left: the All 14 checks are green. The live denied-policy and control runs in #4863 (comment) were taken as reported. Their shape matches what was asked for, and they ran at c58a582, with 8bf0b9a changing only a help string. Not verified here: the unit tests were not run, and the new host test was judged from the diff and the pre-change code. No conflicts are known, and nothing else must happen before merge. The open inline threads still need resolving. These are fixed at this commit: #4863 (comment) (help text now has the denial sentence), #4863 (comment) (policy gate and help gap covered at the emulator host and in help), #4863 (comment) (keep decision no longer compares the clock or reason strings), and #4863 (comment) (the two-constant split is gone). #4863 (comment) does not apply here: the ownership check before the readiness stop was ruled out as follow-up #4867. |
* fix(android): stop the emulator a failed cold boot left unowned An open that boots a stopped Android emulator stops that launch when the open fails (#4764). A failure inside the boot was outside that rule: readiness terminated the process it launched only when the request was canceled, so a boot that failed for another reason left an emulator running with no session to own it, and no later close ever learned to stop it (#4847). Readiness now decides per failure reason at the owner that holds the launched pid. A refusal that spent the startup budget keeps booting, which is what the --timeout contract and the existing tests promise, and a canceled request keeps terminating its launch. Every other failure after the launch returned a pid stops that process and rethrows its own error: the host could not record the launch, a boot probe failed inside the budget, or discovery went wrong. A terminate that itself throws records a diagnostic naming the boot failure it answers rather than replacing that failure. An emulator that was already running is still never stopped, and the daemon's open orchestration gains no second stop path. commands.md and the open help said a boot that failed before the emulator was ready left it as it is; both now state the final rule. * fix(android): gate the launched emulator's stop with the shutdown policy (#4847) `terminate` is the one teardown a launched emulator's own host can perform, and it was the one shutdown no policy was asked about: `assertShutdownAllowed` guarded only `deviceShutdown`. A daemon that denies `device-shutdown` therefore SIGTERM'd the emulator a failed boot had launched, and a canceled boot had signaled it the same way before this. Pass that assertion to the host that owns the launch and ask it before anything else. A denied daemon now leaves its launch running and the caller keeps the failure that asked: readiness already records a diagnostic when `terminate` throws, and the open reports its own boot error. The keep-decision now reads the boot's phase rather than the clock, so a step after a finished boot cannot read as a spent budget: only a boot-wait poller that ran out that budget keeps its launch. The rule belongs to booting, not to `open`, so `commands.md` says so. * docs(open): say a denied device-shutdown policy keeps a failed boot's emulator running
* fix(android): stop the emulator a failed cold boot left unowned An open that boots a stopped Android emulator stops that launch when the open fails (#4764). A failure inside the boot was outside that rule: readiness terminated the process it launched only when the request was canceled, so a boot that failed for another reason left an emulator running with no session to own it, and no later close ever learned to stop it (#4847). Readiness now decides per failure reason at the owner that holds the launched pid. A refusal that spent the startup budget keeps booting, which is what the --timeout contract and the existing tests promise, and a canceled request keeps terminating its launch. Every other failure after the launch returned a pid stops that process and rethrows its own error: the host could not record the launch, a boot probe failed inside the budget, or discovery went wrong. A terminate that itself throws records a diagnostic naming the boot failure it answers rather than replacing that failure. An emulator that was already running is still never stopped, and the daemon's open orchestration gains no second stop path. commands.md and the open help said a boot that failed before the emulator was ready left it as it is; both now state the final rule. * fix(android): gate the launched emulator's stop with the shutdown policy (#4847) `terminate` is the one teardown a launched emulator's own host can perform, and it was the one shutdown no policy was asked about: `assertShutdownAllowed` guarded only `deviceShutdown`. A daemon that denies `device-shutdown` therefore SIGTERM'd the emulator a failed boot had launched, and a canceled boot had signaled it the same way before this. Pass that assertion to the host that owns the launch and ask it before anything else. A denied daemon now leaves its launch running and the caller keeps the failure that asked: readiness already records a diagnostic when `terminate` throws, and the open reports its own boot error. The keep-decision now reads the boot's phase rather than the clock, so a step after a finished boot cannot read as a spent budget: only a boot-wait poller that ran out that budget keeps its launch. The rule belongs to booting, not to `open`, so `commands.md` says so. * docs(open): say a denied device-shutdown policy keeps a failed boot's emulator running
Summary
An
openthat boots a stopped Android emulator stops that launch when the open fails (#4764). A failure inside the boot was outside that rule: readiness terminated its launch only on cancellation, so a boot failing for another reason left an emulator running with no session to own it, and no latercloseever learned to stop it. Fixes #4847.Readiness keeps booting only for the boot wait itself running out its startup budget — a step failing after the boot is not "still booting" — and stops its launch for every other failure after
launchreturned a pid, rethrowing its own error unchanged.That stop tears down a launched emulator, so the launching host now asks
assertShutdownAllowedfirst: a daemon denyingdevice-shutdownleaves its launch running and the open keeps its boot error. The same call closes the existing cancellation bypass, where a canceled boot signaled its launch past the policy. An already-running emulator is never stopped.Before / after
Same injected adb transport fault, AVD
agent-device-4539-live.decae77d37c58a582203BOOT_COMMAND_FAILED, emulator left running unownedValidation
At
c58a582203: build,typecheck,lint,format,check:layering,test:unit(21845 passed),fallow audit,check:mcp-metadata, doc prose and links, command-docs. Ten new unit tests: six boot-failure stops, one post-boot phase case, three policy-gate cases; nine fail atorigin/0.22. Live: policy-denied and control runs in the comment replying to the review.Not in this PR
The readiness stop checks no other session or claim for the emulator; tracked as a follow-up issue. The daemon's post-boot stop path (#4842) and its cleanup reporting are unchanged.