Repository navigation
fix(close): keep a disproved boot on record and decide it in the daemon - #4869
Conversation
Size Report
Startup median (7 runs, lower is better):
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Verification now includes the lane the earlier report missed: full |
|
At 0001383, all 13 checks pass and no conflicts are known, but this device-facing change has no live evidence at this head yet. The change touches the Apple boot-refusal read in simctl.ts (used by Please run the Apple open/close routes once at this head on a dedicated throwaway simulator, using the branch CLI with an isolated Not verified here: this review read the code only, with no device or mutation runs. The mutation claims were checked by reading the base store logic. It is also not confirmed that CoreSimulator never emits "current device state: Booted"; the removed phrase existed only since #4864, and the pre-#4864 code matched the same two phrases as this head. Not blocking, take or leave: |
Addresses non-blocking review on #4869: - CloseBootOwnership leaves contracts. Its only consumers are in the daemon, so contracts had vocabulary no zone above it shared. R81 rejects a core -> sessions type read, and core/session-store.ts consumes the answer, so it lands in core/session-state.ts beside the flags it decides, which both consumers read downward - the iOS skill card now scopes the boot-owner-unverified warning to a simulator the open FOUND stopped, which is the case that can be disproved; the pinned contiguous paragraph is intact - session-open-execution comment names one union answer, not a pair
0001383 to
00b93ef
Compare
Live validation at head
|
| # | Command (all with --json) |
Result |
|---|---|---|
| 1 | open com.apple.Preferences --platform ios --device agent-device-4869-live (from Shutdown) → plain close |
open selection.bootOccurred: true; sim Booted; close data.shutdown.success: true, exitCode: 0; sim Shutdown |
| 2 | simctl boot first → open → plain close |
open bootOccurred: false; close ok, no shutdown key, no warnings; sim Booted |
| 3 | cold open started; second shell boots the sim at +2 s and wins → plain close |
open ok bootOccurred: true (foreign boot won the window); close ok, no shutdown, warning boot-owner-unverified; sim Booted |
| 4 | the case-3 session re-opened while Booted (open again, bootOccurred: false — proves nothing) → plain close |
close ok, no shutdown, the same boot-owner-unverified warning still present; sim Booted |
| 5 | close --shutdown on that disproved session |
data.shutdown.success: true, exitCode: 0, no warnings; sim Shutdown |
Key JSON. Case 1 close:
{ "success": true, "data": { "session": "default",
"shutdown": { "success": true, "exitCode": 0, "stdout": "", "stderr": "" },
"message": "Closed: default" } }Case 2 close (no shutdown key, warnings absent — printed from the parsed response): {"ok": true, "shutdown": null, "warnings": null}, sim stayed Booted.
Cases 3 and 4 close (identical warning, kept running):
{ "success": true, "data": { "session": "default", "message": "Closed: default",
"warnings": ["This session's open found this device stopped, but reported boot-owner-unverified: its own boot step never booted the device, so close did not request a stop. The device is still running."] } }Case 5 close: {"ok": true, "shutdown": {"success": true, "exitCode": 0}, "warnings": null}, sim Shutdown.
The race was hit for real, both times it was attempted. The script starts the cold open, then a background subshell issues xcrun simctl boot on the same UDID at +2 s; the foreign boot won on loop iteration 1 of the subshell each time (cases 3 and 4 are two independent race runs, each racing once). Selection still answered bootOccurred: true, and close on head kept the simulator with the typed warning — the exact #4791 behavior.
On the review's open question about the removed phrase: CoreSimulator's refusal for this simulator, captured directly by booting a Booted device, is exactly:
An error was encountered processing the command (domain=com.apple.CoreSimulator.SimError, code=405):
Unable to boot device in current state: Booted (exit 149)
No current device state: variant appears from this runtime (iOS 26.2 / Xcode toolchain here), consistent with the commit dropping it.
Cleanup: every session closed, each case daemon stopped with daemon stop --state-dir, simulator deleted (xcrun simctl list devices | grep -c agent-device-4869-live → 0).
The branch was also rebased onto origin/0.22 (c50f522720) and the three non-blocking review items taken in one commit: CloseBootOwnership left contracts — its only consumers are daemon-side, and R81 rejects the core→sessions read the daemon-module location would need, so it now sits in core/session-state.ts beside the flags it decides; the skill card sentence is scoped to a simulator the open found stopped (pinned paragraph intact, contract test green); the session-open-execution.ts comment says "The answer below".
This comment has been minimized.
This comment has been minimized.
|
Two of the earlier findings (#4869 (comment)) are now fixed at 00b93ef, and one remains. CI is green (14 checks, none failing), and there are no conflicts. The new workflow help at https://github.com/callstack/agent-device/blob/00b93ef/src/commands/schema/cli-help-workflows.ts#L32 (and line 347) promises a reason whenever an Apple open reports that its boot step did not perform the boot. On a fresh open of an already-running simulator, readiness reports performed:false with reason already-booted (readiness/runtime.ts:67-87), selection gives no stopped-device inference, and session-boot-ownership.ts:25-28 returns none. The store records no warning flag, so plain close returns without the token. Case 2 in the author's transcript (issue comment 7053910619) shows this outcome. Agents will expect boot-owner-unverified on an ordinary prebooted open, and a warning-free close contradicts that. Please scope both help entries to a simulator that open found stopped, whose boot step did not start it, and where the session has no earlier proof that it owns the stop. Not verified here: the device runs and tests were not re-run, and the branch CLI used in the author's transcripts was built at 00b93ef only by the author's statement. |
|
Reply to the review at 00b93ef (#4869 (comment)). Head is now Both entries now scope the Checks on this head: lint, typecheck, format, |
This comment has been minimized.
This comment has been minimized.
|
The change at 5249a56 has two remaining problems, both in the new help text and its evidence; the 13 checks are green and no conflicts are known. The earlier findings from 00b93ef are addressed in this head, and the remaining issue is the new no-warning sentence in the two workflow help entries. The new sentence says an already-running Apple simulator stays running "without a warning" after plain close (cli-help-workflows.ts:32, cli-help-workflows.ts:347). That does not hold when the simulator starts externally after the session's first open saw it stopped. That open leaves a recorded boot disproval. A later reopen in the same session finds the simulator running, adds no boot evidence, and keeps the disproval (session-store.ts:445-465). Plain close then reports boot-owner-unverified (session-close.ts:619-623). An agent following the help can read that expected warning as a close failure. In both entries, please limit the no-warning statement to a simulator that was already running when the session first opened it. Please also say that a reopen keeps any earlier boot-ownership warning until the session owns a stop. The claim that the help can promise silence for every already-running simulator rested on a source trace only. The new test at session-close-foreign-boot.test.ts:216-244 covers the reopen path and asserts the warning is kept, which contradicts the help text. Please make the help match that test, or show the route where the reopen emits no warning. Could SessionStore record one exclusive close disposition in SessionState, so close teardown and failed-open cleanup read the same stored decision? The per-open answer is exclusive, but the two optional fields in the stored state can still express both owning a stop and warning that it was withheld. Not verified here: tests were not re-run; the head delta is two help strings, checked against the head code by reading. |
|
Reply to the review at 5249a56 (#4869 (comment)). Head is now Help text. Both workflow entries now read: a device that was already running when the session first opened it keeps running, without a warning; a reopen keeps an earlier boot-ownership warning until the session owns a stop. That matches One exclusive close disposition in |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
One docs finding remains at bf7922c; the code changes from the earlier review (#4869 (comment)) are in place, and the 13 checks pass. The delta changes only help strings. The new first-open condition in cli-help-workflows.ts:32 (and the matching entry at line 347) promises that a simulator already running at the session's first open keeps running on plain close. That is false on one route. Open a prebooted local simulator, let it shut down externally while the session keeps its claim, then reopen the same session after the recent boot observation expires. Apple readiness reads Shutdown and boots it (readiness/runtime.ts:67-87). The existing-session route passes that performed:true report through (session-open.ts:318-360). The daemon then records bootedByOpen (session-boot-ownership.ts:25, session-store.ts:445-455), and plain close stops the simulator (session-close-lifecycle-teardown.ts:102-117,274-289). An agent that follows either workflow can expect close to keep a simulator that the session later booted. Please qualify the first-open sentence in both entries with "and the session has not since booted it", and refer to the boot-ownership warning there. Keep the existing sentence about retention across reopen. Not verified here: tests were not run, and the reopen route rests on reading the code and test at that commit. The packet listed no open or resolved threads. Once the two help entries are fixed, nothing else stands in the way of merge. |
|
Fixed at 15c8d56 (reply to #4869 (comment)). Both help entries (cli-help-workflows.ts:32 and :347) now read: "A device that was already running when the session first opened it, and that the session has not since booted, keeps running on plain close without a boot-ownership warning". The retention-across-reopen sentence is unchanged. Help schema tests pass locally (114/114); oxfmt is clean. |
This comment has been minimized.
This comment has been minimized.
|
The earlier findings at bf7922c are fixed, and one docs problem remains at 15c8d56. The new sentence in skills/ios-simulator/SKILL.md promises CI is green with 14 checks and none failing. Not verified here: the help schema tests were not run locally. No other threads are open, and nothing else is needed before merge once the sentence is narrowed. |
|
Fixed at 7c4145d (reply to #4869 (comment)). skills/ios-simulator/SKILL.md:24 now reads: "When the session's first open selected a stopped simulator and something else booted it before that open's own boot step, plain close leaves it running and warns with |
This comment has been minimized.
This comment has been minimized.
|
The earlier findings from 15c8d56 are fixed at 7c4145d, and one help claim still does not match the code. After a foreign-boot warning is recorded, remove the original iOS simulator and start a simulator with the same name in the same simulator set. Reopen an app in the existing session without an explicit device selector. The open refresh at session-open.ts:293 can fall back from the missing UDID to the same-name simulator in session-device-resolution.ts:144-165. That simulator is already running, so no boot is performed, and it has a different UDID. session-store.ts:445 and :463-465 then clear the old warning on the identity change without recording a stop. A plain close leaves the replacement running without boot-owner-unverified. The new help at cli-help-workflows.ts:32 and line 347 promises that a reopen keeps the earlier warning until the session owns a stop. Please qualify both sentences so the promise holds only while the session stays on the same device and has no boot of its own. The 14 checks are green, and the change since the last review is one docs sentence. Not verified here: the tests were not run, and the different-device reopen case was not checked against live behavior. No further action is needed once the two sentences match the code. |
|
Fixed at 274b3c6 (reply to #4869 (comment)). Both help entries (cli-help-workflows.ts:32 and :347) now end: "a reopen of the same device keeps an earlier boot-ownership warning until the session boots it itself, and a reopen that selects a different device clears it." Help schema tests pass locally (114/114); oxfmt is clean. |
This comment has been minimized.
This comment has been minimized.
|
This is a follow-up to the earlier review of 7c4145d (#4869 (comment)). One help-text problem remains at 274b3c6. CI is green, with 14 checks and none failing. There are no conflicts. The new help in cli-help-workflows.ts:32 says the warning clears once the session boots the simulator itself. That does not hold on one path. Start with a session that recorded an unverified boot, let the simulator shut down, and reopen the same device. If This path was traced by reading the code with a late successful |
|
Fixed at 56bf129 (reply to #4869 (comment)). cli-help-workflows.ts:32 and :347 and skills/ios-simulator/SKILL.md:24 now tie clearance to "a later open of the session records that it booted the simulator", so a reopen that ends in boot_timeout keeps the warning. Help schema and agent-guidance tests pass locally; oxfmt is clean. |
This comment has been minimized.
This comment has been minimized.
Addresses review on #4864: - a re-open that proves nothing keeps the recorded disproved boot, so a failed re-open cannot silence the warning for the same foreign boot (session-store.ts); routed and store cases pin both directions - CloseBootOwnership is a four-member union, so owning a stop and reporting one withheld cannot both be represented; the publisher no longer duplicates the store's ownership math - resolveSessionBootOwnership moves to the daemon session lifecycle per ADR 0038/R18 (contracts keeps vocabulary, not algorithms) - the boot refusal read drops the unverified third phrase, keeping only CoreSimulator's own wording, pinned at both readers - lifecycle forwarding of the boot report is pinned where it happens - docs and help name the new warning: session-state field contract, cli-help-workflows (now a guarded surface), ios-simulator skill (cherry picked from commit 96e0417)
The simulator skill contract reads the card's close paragraph as one contiguous string. Inserting the boot-owner-unverified sentence mid- paragraph broke that read, so the card now states the pinned guidance in full and names the new warning after it.
Addresses non-blocking review on #4869: - CloseBootOwnership leaves contracts. Its only consumers are in the daemon, so contracts had vocabulary no zone above it shared. R81 rejects a core -> sessions type read, and core/session-store.ts consumes the answer, so it lands in core/session-state.ts beside the flags it decides, which both consumers read downward - the iOS skill card now scopes the boot-owner-unverified warning to a simulator the open FOUND stopped, which is the case that can be disproved; the pinned contiguous paragraph is intact - session-open-execution comment names one union answer, not a pair
… open found stopped
…e session's first open
…s not since booted
56bf129 to
6472db2
Compare
This comment has been minimized.
This comment has been minimized.
|
One docs problem remains at 6472db2; the earlier findings from #4869 (comment) are fixed. The new help sentence promises a The added warning sentence in cli-help-workflows.ts:32 and at :347 covers any open that finds a stopped simulator, loses the boot to another process, and has no earlier stop proof. Take a session that starts with a prebooted simulator, then shut the simulator down externally while the daemon still holds the claim, and reopen after the recent boot observation expires. Inventory can see Shutdown in the existing-session refresh before a concurrent boot wins. The rule to satisfy: the stopped-simulator warning applies only to the session's first open, as the qualified sentence in the iOS skill already says. Please scope the sentence that way in both workflow entries. Keep the separate wording for retaining an earlier warning across a same-device reopen. The code verdict is that the findings above need a fix before this is ready. The only failing check is Body rules, which validates the PR description template and not the close route this diff changes. There are no conflicts. After the docs fix, the PR body must pass the template check before merge. Not verified here: a live device run, and a line-by-line re-read of the range-diff after the rebase; the claims above come from reading the code. |
|
Fixed at 88e564f (reply to #4869 (comment)). Both workflow entries (cli-help-workflows.ts:32 and :347) now read "...or the session's first open selected a stopped Apple simulator that something else booted before that open's own boot step (boot-owner-unverified)...", matching the iOS skill; the same-device reopen sentence is unchanged. The PR body was rewritten for scripts/check-pr-body.ts at 6472db2, and the Body rules check passes there. Help schema tests 114/114. |
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 to merge at 88e564f. The delta since the earlier review (6472db2) changes only help string text, and CI is green with all 15 checks passing. No conflicts. Nothing else needs to happen before merge. Not blocking: in cli-help-workflows.ts, any open that writes a disproved boot sets the unverified flag, not only the first open, so a reopen that selects a different stopped simulator can also report boot-owner-unverified. The help says "first open" and ends with "a reopen that selects a different device clears it", which describe only the first-open route. The sentences are not false, so these can be taken or left: say "an open" where the route applies, and add "unless that open is itself disproved" to the clearing sentence. Not verified here: the help schema tests were not run, so this relies on green CI and the author's report. |
…on (#4869) * fix(close): keep a disproved boot on record and decide it in the daemon Addresses review on #4864: - a re-open that proves nothing keeps the recorded disproved boot, so a failed re-open cannot silence the warning for the same foreign boot (session-store.ts); routed and store cases pin both directions - CloseBootOwnership is a four-member union, so owning a stop and reporting one withheld cannot both be represented; the publisher no longer duplicates the store's ownership math - resolveSessionBootOwnership moves to the daemon session lifecycle per ADR 0038/R18 (contracts keeps vocabulary, not algorithms) - the boot refusal read drops the unverified third phrase, keeping only CoreSimulator's own wording, pinned at both readers - lifecycle forwarding of the boot report is pinned where it happens - docs and help name the new warning: session-state field contract, cli-help-workflows (now a guarded surface), ios-simulator skill (cherry picked from commit 96e0417) * docs(skill): keep the pinned close guidance contiguous in the iOS card The simulator skill contract reads the card's close paragraph as one contiguous string. Inserting the boot-owner-unverified sentence mid- paragraph broke that read, so the card now states the pinned guidance in full and names the new warning after it. * refactor(daemon): declare boot ownership where its consumers read it Addresses non-blocking review on #4869: - CloseBootOwnership leaves contracts. Its only consumers are in the daemon, so contracts had vocabulary no zone above it shared. R81 rejects a core -> sessions type read, and core/session-store.ts consumes the answer, so it lands in core/session-state.ts beside the flags it decides, which both consumers read downward - the iOS skill card now scopes the boot-owner-unverified warning to a simulator the open FOUND stopped, which is the case that can be disproved; the pinned contiguous paragraph is intact - session-open-execution comment names one union answer, not a pair * docs(help): scope the boot-owner-unverified close note to a simulator open found stopped * docs(help): limit the no-warning close note to a device running at the session's first open * docs(help): keep the first-open close note to a device the session has not since booted * docs(skill): limit the iOS boot-owner warning note to the session's first open * docs(help): keep the reopen warning note to the same device * docs(help): clear the boot-owner warning only on a recorded later boot * docs(help): scope the boot-owner warning sentence to the session's first open
Summary
Follow-up to #4864 (#4791). A boot that a session disproved stays on the session record until the session owns a stop, so a later plain
closestill warnsboot-owner-unverified.CloseBootOwnershipbecomes the exclusive unionproved | inferred | disproved | none, and the ownership decision moves from contracts to the daemon session lifecycle (ADR 0038). The refusal read matches CoreSimulator's own wording only. Help and the iOS skill card state the rule.Before / after
closewarnings: [boot-owner-unverified]close --shutdownon a disproved sessionValidation
Head rebased onto
0.22at62f24be4fd. Local: build, typecheck, lint, layering, command-docs, daemon-wire-compat, fullvitest --project unit-core(20891 passed). Mutation-checked: removing the lifecycle forwarding or the store retention turns the new tests red. Live cases on #4864 still describe the running-simulator behavior. CI: hosted checks at this head.Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.