Repository navigation
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs real behavior proof before merge. Reviewed September 20, 2026, 12:34 PM ET / 16:34 UTC (Revision 5). ClawSweeper reviewWhat this changesDoctor waits for a stopped Gateway to release lifecycle ownership, rechecks update admission, and completes macOS restart after successfully restoring an unloaded LaunchAgent. Merge readiness⛔ Blocked before merge - 6 items remain Keep this useful fallback open: current main still has the reported failure paths, and the related replacement remains unmerged and conflicted. The earlier authority finding is resolved; no new blocking patch defect was established. Priority: P1 Review scores
Verification
How this fits togetherDoctor coordinates repairs with the service manager so the Gateway stops before maintenance and returns afterward. On macOS, LaunchAgent recovery determines whether launchd can run the Gateway again. flowchart TD
A[Doctor repair request] --> B[Verify service and update ownership]
B --> C[Stop managed Gateway]
C --> D[Wait for lifecycle ownership]
D --> E[Recheck repair admission]
E --> F[Repair or refuse safely]
F --> G[Restore LaunchAgent under current authority]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +32, Tests +566. Total +598 across 6 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Use one shared stop-and-drain deadline, preserve current restoration authority, and demonstrate automatic Gateway recovery when a published updater invokes the candidate. Do we have a high-confidence way to reproduce the issue? Yes, source and the supplied macOS timing report identify the stop-to-lifecycle-release race and false failure after bootstrap recovery. This review did not execute a current-main reproduction. Is this the best way to solve the issue? Partly: the patch repairs the existing owners without a parallel implementation, but the independent drain timer should follow the shared-budget direction already recorded in discussion. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 9f5048ae9963. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (4 earlier review cycles)
|
|
Thank you for the source review in #153173 and this draft — it identified two invariants our in-flight fix for the same defect (#153167, opened a few minutes earlier for #153155) did not yet hold, and both are now in #153167 by independent implementation with credit to you in its body:
One part was deliberately not adopted: the separate 20 s drain timer. #153167 keeps Doctor's existing shared 330 s stop deadline as the single budget (the drain wait starts before the native stop and compensation shares the remainder), so no new timer or constant is introduced. Regressions for admission loss during drain and for the absent-job recovery were added on our side with synthetic ticks. #153167 is review-clean and queued to land tonight; once it is on |
Revalidate repair admission with both coordinators held and retain native stop custody through pre-repair compensation, including captured Windows recovery assertions and handle settlement. Probe ambiguous launchd kickstart failures so verified absent-job recovery completes while loaded-job errors retain their original detail. Thanks to @sasan1200 for the source review in #153173 and #153172 identifying these cases. Implemented independently with deterministic boundary regressions.
|
Reopening as draft. Keeping as fallback until #153167 merges. |
Revalidate repair admission with both coordinators held and retain native stop custody through pre-repair compensation, including captured Windows recovery assertions and handle settlement. Probe ambiguous launchd kickstart failures so verified absent-job recovery completes while loaded-job errors retain their original detail. Thanks to @sasan1200 for the source review in #153173 and #153172 identifying these cases. Implemented independently with deterministic boundary regressions.
Revalidate repair admission with both coordinators held and retain native stop custody through pre-repair compensation, including captured Windows recovery assertions and handle settlement. Probe ambiguous launchd kickstart failures so verified absent-job recovery completes while loaded-job errors retain their original detail. Thanks to @sasan1200 for the source review in #153173 and #153172 identifying these cases. Implemented independently with deterministic boundary regressions.
Revalidate repair admission with both coordinators held and retain native stop custody through pre-repair compensation, including captured Windows recovery assertions and handle settlement. Probe ambiguous launchd kickstart failures so verified absent-job recovery completes while loaded-job errors retain their original detail. Thanks to @sasan1200 for the source review in #153173 and #153172 identifying these cases. Implemented independently with deterministic boundary regressions.
Revalidate repair admission with both coordinators held and retain native stop custody through pre-repair compensation, including captured Windows recovery assertions and handle settlement. Probe ambiguous launchd kickstart failures so verified absent-job recovery completes while loaded-job errors retain their original detail. Thanks to @sasan1200 for the source review in #153173 and #153172 identifying these cases. Implemented independently with deterministic boundary regressions.
* fix(doctor): restore Gateways after shutdown contention Wait for the stopped Gateway to release lifecycle ownership within the shared stop budget before state repair or recovery. Preserve partial-acquisition cleanup and route launchd activation failures through bootstrap recovery with explicit loaded-state diagnostics and live authority checks. Thanks @sagebhardt for the shutdown timing table. Fixes #153155. * fix(doctor): complete recovery after admission and kickstart failures Revalidate repair admission with both coordinators held and retain native stop custody through pre-repair compensation, including captured Windows recovery assertions and handle settlement. Probe ambiguous launchd kickstart failures so verified absent-job recovery completes while loaded-job errors retain their original detail. Thanks to @sasan1200 for the source review in #153173 and #153172 identifying these cases. Implemented independently with deterministic boundary regressions. * test(launchd): preserve policy through activation recovery * refactor(doctor): extract maintenance restoration owner * test(doctor): isolate launchd maintenance fixtures Complete the standalone repair-policy mock used by the native scratch-job proof after main added the deferred-repair predicate. Reserve a suite-owned free port for the mocked Gateway so a listener on port 18789 cannot trigger host-dependent owner-lease reads against the legacy fixture database. Retain the native job protections and database artifact assertions. Validation: both native scratch cases and all 50 maintenance revalidation cases pass independently; the complete requested selection passes 544 tests across 22 files. Production is unchanged from the previous PR patch replayed onto main. * style(doctor): order imports after maintenance rebase * fix(doctor): preserve restoration custody and shared stop deadline --------- Co-authored-by: Jason (Json) <[email protected]>
…w#153167) * fix(doctor): restore Gateways after shutdown contention Wait for the stopped Gateway to release lifecycle ownership within the shared stop budget before state repair or recovery. Preserve partial-acquisition cleanup and route launchd activation failures through bootstrap recovery with explicit loaded-state diagnostics and live authority checks. Thanks @sagebhardt for the shutdown timing table. Fixes openclaw#153155. * fix(doctor): complete recovery after admission and kickstart failures Revalidate repair admission with both coordinators held and retain native stop custody through pre-repair compensation, including captured Windows recovery assertions and handle settlement. Probe ambiguous launchd kickstart failures so verified absent-job recovery completes while loaded-job errors retain their original detail. Thanks to @sasan1200 for the source review in openclaw#153173 and openclaw#153172 identifying these cases. Implemented independently with deterministic boundary regressions. * test(launchd): preserve policy through activation recovery * refactor(doctor): extract maintenance restoration owner * test(doctor): isolate launchd maintenance fixtures Complete the standalone repair-policy mock used by the native scratch-job proof after main added the deferred-repair predicate. Reserve a suite-owned free port for the mocked Gateway so a listener on port 18789 cannot trigger host-dependent owner-lease reads against the legacy fixture database. Retain the native job protections and database artifact assertions. Validation: both native scratch cases and all 50 maintenance revalidation cases pass independently; the complete requested selection passes 544 tests across 22 files. Production is unchanged from the previous PR patch replayed onto main. * style(doctor): order imports after maintenance rebase * fix(doctor): preserve restoration custody and shared stop deadline --------- Co-authored-by: Jason (Json) <[email protected]>
|
Superseded by #153167 (merged as 18a0b30). Rebased onto current main: no production lines remain. The post-stop gateway-lifecycle drain wait, the admission recheck after drain, and the absent-job restart completion are all on main. |
Closes #153173
What Problem This Solves
Fixes:
openclaw doctor --fixcan leave a managed macOS Gateway stopped when LaunchAgent shutdown is still draining lifecycle ownership, restart must recover an unloaded job, or Doctor loses update authority before rollback restoration.User Impact
User impact: Doctor waits for the stopped Gateway's bounded lifecycle drain, rejects a competing update before repair or restoration, and restores the LaunchAgent only while it still owns update authority.
Why This Change Was Made
LaunchAgent stop can observe the listener released before the exiting Gateway releases
gateway-lifecycle. Doctor now waits for that already-stopped owner to drain and revalidates update admission while both maintenance coordinators are held.Rollback restoration previously bypassed update-admission revalidation. That allowed a displaced Doctor owner to perform one native restart after a competing updater became active. Native restoration now revalidates both Doctor custody and update authority inside the service-operation lock; loss of authority rejects without a Doctor-originated restart, while a still-current owner retains the normal restoration path.
During restoration,
launchctl kickstartcan fail without a reliable not-loaded diagnostic even though a follow-up probe shows the job is absent. After a successful bootstrap, restart now completes; if the job remains loaded, the original kickstart failure remains visible.Evidence
e243a9d2522a59fccd8de627abdb4c1775123225and integrated its signed patch as6baa78ccbe402c1dbdb16d14a9df696dfc73b4a8on upstreammain24a03acf58c48d0e6b72e120aa1eabec219be429; final signed head:c3ac1d77ed728d9e5209861927b4fd6f8a5f56bc.node scripts/run-vitest.mjs src/commands/doctor-maintenance.finish-revalidation.test.ts src/commands/doctor-maintenance.plugin-preflight.test.ts src/daemon/launchd-lifecycle.restart-restore.test.ts src/daemon/launchd.test.ts: 227/227 passed in 61.92s on the integrated pre-review head.node scripts/run-vitest.mjs src/commands/doctor-maintenance.finish-revalidation.test.ts: 39/39 passed in 46.41s after the authority-boundary repair, including competing-update rejection with zero restart and still-current-owner restoration.node scripts/run-vitest.mjs run --config test/vitest/vitest.e2e.config.ts src/daemon/launchd.integration.e2e.test.ts: 8/8 native macOS launchd tests passed in 315.31s, including the busy-port, retained-supervision, stop/start, stop/restart, and missing-bootstrap paths.node scripts/run-vitest.mjs run --config test/vitest/vitest.e2e.config.ts src/commands/doctor-maintenance.launchd.integration.e2e.test.ts: 2/2 real macOS Doctor × LaunchAgent authority-chain tests passed in 264.59s on the final code. Using unique profile-derived scratch LaunchAgents, they proved delayed lifecycle release followed by healthy native restoration, plus displaced-owner rejection with no native activation before the original owner restored during cleanup. Post-run inspection confirmed no test jobs, state directories, live plists, or new Trash plists remained; the defaultai.openclaw.gatewayjob was never targeted.oxfmt,oxlint,git diff --check, native compilation, and both native tests passed.+3/-17lines and tests by+371/-2lines.git diff --checkpassed; the final worktree was clean and commitc3ac1d77ed728d9e5209861927b4fd6f8a5f56bchas a valid ED25519 signature.findings: []; the patch was assessed correct with 0.96 confidence.