Repository navigation
fix(provider): wait for launchd service removal before replacement - #1315
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Threat model review — advisoryReviewed head Review not completed for this head. Previous findings are superseded, not confirmed resolved. Models: budgeted Sonnet / selective Opus / selective Sol 6.1. Findings require human validation; this review never requests changes or blocks merging. Coverage: 0/0 source units; cross-file integration pending. 0 selected depth batch(es) pending. All threat definitions indexed; relevant full definitions selected. Unchanged callers are not scanned. Cost this run: $0.0000 reported, $0.0000 reserved with unknown cost; 0 paid request(s), 0 reused batch(es), 0 provider cache-hit tokens. Saved findings and earlier report · Historical findings are not confirmed resolved. |
Only CHANGELOG.md conflicted. Both entries are kept: this branch's launchd removal note and the entries master added since. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CHANGELOG.md conflicted again at the top of the file. Both sides are kept; master's new entries go first so later entries there do not collide with this branch's section. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CHANGELOG.md conflicted at the top of the file again, this time with the entry master gained when #1336 merged. Every entry is kept. This branch's entry now sits after the verification-concurrency section, away from the spot where other open changes insert theirs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Gajesh2007
left a comment
There was a problem hiding this comment.
Reviewed exact head b07fac6 against 34f0e6d, with the target delta through current master f9f2b41 inspected. No actionable introduced defect found. Exact-label absence confirmation closes #1102's bootout/replacement race; timeout/unknown/permission/spawn errors prevent replacement, preserve the plist and avoid false bootstrap success on error 37. Relevant CLI/drain/restart/update/stop/uninstall/watchdog callers were traced.
Local isolated validation: the exact production lifecycle component harness passed 63 expanded cases, including independent boundary/command-duration controls. The base algorithm reproduced 14 expected new-lifecycle failures plus passing controls: install bootstraps at 0.5s and drained restart at 0s before a 3s label release; head waits until removal. The ten-second timeout performs no bootstrap/kickstart and preserves original plist bytes.
Exact-head native Swift build passed (395.61s), with input paths, new removal-wait object symbols and source provenance verified against independent copied artifacts. Native focused lifecycle tests passed 52 executed functions/56 expanded cases; one real-launchd opt-in test was disabled. Broader native ProviderCore service selection passed (235 tests declared in 34 suites). The CLI selection (308 declared tests/46 suites) had one unchanged cache-path test fail under our fixed Foundation-home override; that exact test passes alone without the override, while all other private state/keychain settings remain. The broader combined selection remains exit 1 and is not claimed as an aggregate pass. No tracked source/test assertion changed.
Limits: no real user service was replaced/stopped, no reporter-OS/live launchd reproduction, and no full native provider/GPU aggregate or full-model qualification for this PR. Native execution used local Swift 6.4/Xcode 27 and verified source-matched cached Metal resources; CI uses its pinned toolchain. An individually hung existing launchctl process can still exceed the polling budget, as documented. Fresh head unchanged; current-head CI, Integration Tests and Contribution Policy pass, docs/link/impact checks pass. Protected benchmarks remain waiting; advisory threat reports are incomplete, and fresh hosted Mermaid rendering remained behind SAML. Approval is for this exact head and stated lifecycle scope.
Layr-Labs#1315 landed the launchd removal wait; keep only the watchdog re-arm on a failed relaunch.
Summary
When launchd returns from bootout before removing its service label, provider replacement can bootstrap too early and fail with an operation-in-progress error. Wait for confirmed removal of the exact label before replacement, preserve errors and the existing plist when confirmation fails, and stop treating numeric error 37 as successful bootstrap.
Linked issue
Related to #1102. This draft does not request issue closure.
Before
flowchart TD A["Caller requests install or drained restart"] --> B["LaunchAgent.unloadService: bootout returns"] B --> C["installAndStart sleeps 0.5s; restartAfterDrain proceeds"] C --> D["loadService calls bootstrap"] D --> E{"Old label still registered?"} E -->|"Yes"| F["Replacement fails; error 37 may be ignored"] E -->|"No"| G["kickstart starts provider"] classDef step fill:#dbeafe,stroke:#1d4ed8,color:#172554 classDef bad fill:#fee2e2,stroke:#b91c1c,color:#450a0a classDef good fill:#dcfce7,stroke:#15803d,color:#052e16 class A,B,C,D,E step class F bad class G goodAfter
flowchart TD A["Caller requests install or drained restart"] --> B["unloadService: bootout returns"] B --> C["waitForServiceRemoval polls exact label"] C --> D{"Confirmed absent?"} D -->|"Still loaded; budget remains"| C D -->|"Error or budget exhausted"| E["Throw; preserve plist; no replacement"] D -->|"Yes"| F["loadService bootstraps then kickstarts"] F --> G["Provider replacement completes"] F -->|"Operation-in-progress error"| H["Throw before kickstart"] classDef step fill:#dbeafe,stroke:#1d4ed8,color:#172554 classDef bad fill:#fee2e2,stroke:#b91c1c,color:#450a0a classDef good fill:#dcfce7,stroke:#15803d,color:#052e16 class A,B,C,D,F step class E,H bad class G goodBlue nodes show the lifecycle calls and decisions, green the successful observable result, and red explicit failure outcomes. Shared unload behavior also makes stop wait without reloading and uninstall preserve its plist if removal fails.
Current target and integration status
Integrated current master
34f0e6dd(after #1324, #1338, #1340 and the merge of #1336) with signed merge commitsdfa6bdcb,dc6e955fandb07fac6a; the resolved source tree isbdb93f35. OnlyCHANGELOG.mdconflicted, each time where new entries are inserted, and every entry is kept. This branch's entry now sits after the verification-concurrency section, away from that insertion point. Master changed none of this pull request's Swift files since the previous integration, so the provider change is exactly what was validated before.On the merged head, docs lint (330 files) and docs impact pass. The Swift lifecycle suites were not re-run locally on this head; CI runs them. This pull request does not touch the coordinator, so the reorganization in #1324 required no code movement here.
Previous integration (2026-10-02)
Integrated current master
c56b98e8638f1895b80e22c00122880bed9b11b9with a signed merge commit1431f4f1ef6cd776665077454cc28d6e8a7aee0c; the resolved source tree isb382a615dd2a55222c2f78b4cb4f05f988ff8e6d. The merge preserves the focused fix and incoming master behavior. The consumed SDK is1ee8675a035d0d842d5df663938d66cfedf88a8e.Fresh local validation: 27 lifecycle cases and 34 adjacent plist/config/watchdog cases passed, with zero skips. The current-master control had 14 expected failures and 13 passing controls. Docs lint (330 files) and docs impact (five paths) passed. This is an offline Foundation component harness using scripted launchctl and virtual time, exact SDK defaults and explicitly declared configuration fixtures; full native provider/SDK, real launchd and GPU execution remain unrun.
Ready for maintainer review after reproducing the deterministic lifecycle failure on current master and verifying candidate success in the scoped scripted-launchctl harness. Latest-head CI remains pending; real launchd/native qualification is not claimed. Local component results do not establish production deployment or full native qualification.
Earlier qualification
The original candidate
e58ae161c2c3a8d2c3e408897ecbc29b78e9e971was qualified against base27a165e831e23dd9276f0b279068abe948982902. Those results remain historical; the current-base results and outstanding gates are stated above.Components touched
Protocol / interface changes
Documentation impact
Notes for reviewers
The ten-second monotonic polling budget allows at most 101 post-bootout probes at a 100 ms cadence. It is not a hard subprocess wall timeout: an individual launchctl invocation still uses the existing Process runner without a deadline. Unknown print errors, permission errors, another label's missing-service diagnostic and spawn failures propagate. Explicit already-loaded bootstrap wording remains compatible.
Runner/home test seam design follows the existing coverage proposal in #1296; its unchanged lifecycle algorithm does not implement removal confirmation. No dependency on that unmerged PR is introduced. The test fixture also injects time without sleeping in real time. Current CLI process-drain logic and the reporter's provider 0.9.4 environment are outside the bounded fixture; this draft does not claim live OS reproduction or full qualification.
Hosted checks on the current target composition remain pending. No runner or setting change is part of this PR. The unchanged figures were checked in actual GitHub rendering; that check does not constitute a full theme/accessibility or unobstructed-label audit.
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.