Repository navigation
fix: interactive doctor repairs race a managed gateway - #166948
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 maintainer review before merge. What this changesInteractive Doctor asks permission to pause the managed Gateway before repairs, keeps individual repair approvals, and restores the service’s previous running or stopped state. Example: The user runs openclaw doctor and approves repairs while the managed Gateway is running.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Partial Merge readiness✅ Ready for maintainer review This remains a useful, maintainer-sponsored fix that current main does not provide. No actionable patch defects remain. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherDoctor checks and repairs OpenClaw configuration and SQLite state. Its maintenance owner coordinates those repairs with the native service manager so the Gateway and Doctor do not write the same state concurrently. flowchart TD
A[Interactive Doctor] --> B[Schema checks and update offer]
B --> C{Maintenance consent}
C -->|Decline| D[Cancel and show read-only diagnosis command]
C -->|Accept| E[Existing maintenance owner]
E --> F[Pause owned Gateway and review repairs]
F --> G[Settle database work and verify readiness]
G --> H[Restore previous service state]
Technical reviewBest possible solution: Land the approved maintenance-custody repair while retaining the related issue for diagnostic continuation after declined consent. Do we have a high-confidence way to reproduce the issue? Yes, from source: current main bypasses maintenance for ordinary interactive Doctor while allowing approved state repairs. The report identifies the macOS startup-overlap scenario, and the PR records a failing pre-fix flow regression; no target code was executed during this review. Is this the best way to solve the issue? Yes for the approved maintenance-custody scope: it extends the existing owner and preserves update admission, repair consent, and native ownership checks. It intentionally leaves same-invocation diagnostic continuation after decline to the related issue. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 7b627f476aef. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +75, Tests +81, Docs +9. Total +165 across 11 files. Added test files: 0. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (7 earlier review cycles)
Reviewed October 9, 2026, 6:31 PM ET / 22:31 UTC (Revision 8). |
|
The final exact head 0d8ecef now has green hosted CI and a complete passing published 2026.9.8 → candidate compatibility cell. Its body records the exact package/build, actual successful update, serving identity/readiness and durable state/session assertions, cleanup, and the synthetic-service/interactive-proof limits. Both accepted findings and the CI ordering regression are repaired with focused regressions and clean P2 review. No stored format, schema or migration transform changes are introduced; completed upgrade proof supports compatibility sufficiency. @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Completed the previously missing actual terminal/native-service proof at exact head Actual macOS interactive Doctor proofCandidate: The previously absent, task-owned profile Commands used the absolute candidate built CLI, abbreviated here as openclaw --profile proof166948 gateway install --port 19648
/usr/bin/script -q <case-transcript> /usr/bin/env -i HOME=/Users/dallin USER=dallin LOGNAME=dallin PATH=/Users/dallin/.nvm/versions/node/v24.16.0/bin:/usr/bin:/bin:/usr/sbin:/sbin TERM=xterm-256color node <candidate>/dist/entry.js --profile proof166948 doctor
openclaw --profile proof166948 gateway stop --force
The durable sentinel was created and injected through actual Gateway RPC ( Raw bytes of the serving SQLite/WAL/SHM files can change while the unchanged Gateway remains running. This proof therefore does not claim byte equality for that active database; it uses the logical session/message oracle, alongside unchanged native PID/plist/config and absence of Doctor custody/repair. Raw fingerprints remain recorded for transparency. Unrelated skill disabling, shell completion, and service-definition replacement were declined. The initial shared-dependency build fixture failed workspace resolution, then passed after an isolated frozen install; source was not altered. A stop without Evidence: Cleanup passed: canonical profile-specific uninstall exited 0; real launchctl label remains absent and port 19648 is free. Only the owned profile, its two recorded captures and marker, matching trashed plist, and newly created profile-specific log were removed. Evidence and the clean exact-head source worktree remain for publication. @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Maintainer-requested product scope clarification: the restart/Doctor incident was deliberately split into five independent PRs (#166942, #166946, #166947, #166948, #166950). This PR completes ordinary interactive Doctor maintenance custody: obtain consent before writable admission/repairs, cancel safely on decline, settle SQLite writers before restoring the selected managed service, and preserve initially stopped activation state. The operator explicitly requested independently reviewable fixes; this PR does not claim to implement all of related #144845, change restart authority, or repair every reported warning. Revision 5 accepts the exact-head actual PTY/native launchd consent, decline, repair/restore and initially stopped proof, plus existing upgrade compatibility. It reports diamond proof confidence with no findings or before-merge items. Please assess product completeness against this intended maintenance-custody scope. No proof exemption or rating override is requested. @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Conflict integration pushed at Fresh focused proof passed 18/18 (readiness 5, update 5, settlement 8), plus the post-cleanup update replay 5/5. Previously sandbox-refused ancestry cases now pass under normal inspection with unchanged guards. Official scoped lint/format/diff and independent P0–P2 autoreview pass. The broad local changed checker stops at its borrowed-dependency type boundary, accurately recorded in the body. Current integration evidence is separated from historical native PTY/launchd and published-updater proof. No merge or operator Gateway/state change. The prior review is older than 12 hours; please assess this exact integration with the updated evidence. @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
* fix: coordinate interactive doctor repairs with gateway maintenance * fix: preserve stopped gateway during interactive doctor maintenance * fix: preserve doctor update admission before interactive custody
Current conflict integration — October 9, 2026
Current candidate:
e76d777ffde3631e3a2b6f7cda68669cb0888e5e, incorporating mainbfe4592a7e8195d277ef14f3a458cf7396bc125e. Preserves upstream repair-preview documentation, deletion of obsolete upload tests/mocks, readiness warning behavior, and deletion of the obsolete stopped-activation test file. The PR's stopped-service preservation regression now uses the canonical readiness suite. Removed stale assertions for an update outcome upstream had deleted; successful/pending update handoff remains asserted before consent and custody.Fresh integration proof:
node scripts/run-vitest.mjs src/commands/doctor-maintenance.readiness.test.ts src/flows/doctor-health.update.test.ts src/flows/doctor-health.managed-settlement.test.ts: 18/18 passed (readiness 5, update 5, managed settlement 8), runner wall 167.99 s.node scripts/run-vitest.mjs src/flows/doctor-health.update.test.ts: 5/5 passed, runner wall 94.04 s.node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.jsonon all nine changed TypeScript files: passed. Fresh independent autoreview of the complete staged PR delta against incorporated main: scoped-clean through P2.git merge-tree --write-tree HEAD origin/mainwas conflict-free against fetched mainc75ff3cbf56ea8d00d1f33599482901999098f8d.Conflict repair adds no production behavior beyond the previously proved scope. Against incorporated main, the complete PR is production +81/-6 (net +75), tests/support +88/-7, docs +13/-4. Production growth provides consent admission into the existing maintenance owner and preserves update-before-custody ordering; it does not introduce a competing lifecycle, store, or config option.
Native macOS PTY/launchd and published-driver proofs below remain historical original-head evidence at
0d8ecefc028a0c004ad519da40bd014c103d9928; they were not rerun on this integration and are not current-head CI. This refresh reuses those proofs only for unchanged behavior. Exact-head hosted CI run 37998267536 completed successfully; GitHub reports no pending or failed checks, including the final CI/security gate. The fresh exact-head ClawSweeper assessment is diamond lobster for readiness, proof and patch quality, with no findings or before-merge items. The PR is open, non-draft, conflict-free and ready for review. No merge, deployment, or operator Gateway/state change.Related: #166927
Related: #144845
What Problem This Solves
Fixes interactive Doctor repairs racing a managed Gateway's startup and state writers while checking or migrating SQLite state.
User Impact
Interactive Doctor asks for maintenance custody before reviewing repairs. Individual repair approvals remain separate. Declining ends the repair flow without touching the service or state and points to
doctor --lintfor read-only diagnosis. Explicit repair and non-TTY behavior remain unchanged.Why This Change Was Made
Reuse the existing offline maintenance owner rather than temporarily enabling automatic repair mode. The admitted scope excludes other writers, preserves original state, backs up migration inputs, drains reopened handles, validates startup readiness, and restores the service's prior state. Service ownership and refusal guards are retained. Ordinary interactive Doctor keeps its schema preflight and optional update handoff before custody. If an update handles the run, no custody prompt occurs. Remaining repairs take custody only after schema compatibility is established, then refresh discovery under maintenance ownership.
Evidence
runDoctorHealthFlowregression failed before the fix because interactive repairs had no maintenance custody.check:changed: passed, including core production types, all 27 test-type graphs, three dead-export scans, changed lint and the remaining repository guards. Exact-head hosted CI is green. Earlier primary regression proof also passed; a broader optional sibling invocation was interrupted during import and is not counted as passed.No live operator Gateway, configuration, or database was changed for proof. The tests do not exercise an actual launchd crash loop or filesystem contention.
Follow-up review
Accepted ClawSweeper’s P1 finding: maintenance consent must not activate an owned service that was already stopped. Ordinary interactive custody now restores only a service it actually stopped; explicit
--fix/--yeskeeps its existing owned-offline activation policy. Documentation distinguishes those cases. The broader issue remains Related because declining custody cancels repairs and directs the operator todoctor --lint, rather than continuing read-only diagnosis in that same invocation.The stopped-service regression failed on the prior PR head at the unexpected restart call while all seven explicit-repair controls passed. The repaired eight-case file passed (46.02 s repository-runner wall, 39.35 s Vitest; new case 3 ms). It uses the existing service-boundary fixture and adds no process boots, timers, sleeps, or polling. The prior full-flow proof still covers running-service restoration and failure cleanup. Fresh independent P2 review of the follow-up production change and regression: scoped-clean.
No stored schema, data format, migration transform, updater markers, or authority contract is introduced. The change admits interactive repairs to the existing maintenance owner and narrows activation consent; path-based migration/backfill flags do not identify a new migration here.
Final follow-up
check:changedfor the three changed paths completed with exit 0: core production types, all 27 test-type graphs, three Knip scans, changed formatting/lint and the schema/store/media/sidecar/import/webhook/pairing guards. These final-source checks are separate from the still-valid original flow evidence. The published-driver compatibility cell passed with published 2026.9.8 against final committed head0d8ecefc028a0c004ad519da40bd014c103d9928, using isolated real SQLite and a synthetic native-service adapter; completed results follow.Preserve ordinary Doctor update admission
Hosted CI on
5949b499b7bfd2a4bd1b852bc8e7e08858414915exposed a related ordering regression: entering maintenance before the existing update offer suppressed the update escape hatch for newer agent schemas and changed refusal-before-prompt behavior for newer shared schemas. The follow-up restores state-only schema preflight and the existing update handoff before custody, refuses incompatible agent schemas if the update does not handle the run, and keeps fresh discovery under maintenance ownership. Existing schema-refusal tests are unchanged. The canonical update outcomes retain success, skipped, failed and pending behavior; handled outcomes do not prompt for custody. Guided-mode documentation now describes consent and update ordering consistently.Final ordering follow-up
0d8ecefc028a0c004ad519da40bd014c103d9928validation: full selected source check exit 0 (core production types, all 27 test-type graphs, three Knip scans, lint and repository guards); canonical update outcomes 14/14 passed in 17.19 s runner wall / 13.40 s Vitest with the existing maintenance boundary stub; unchanged schema E2E 4/4 passed (6.697 s case time / 37.16 s Vitest / 1142.13 s wrapper including its cold four-part runtime build and artifact/type-lock wait); interactive full-flow 2 selected passed, 6 filtered (consent 23.572 s, decline 1.706 s; 75.93 s Vitest / 96.84 s runner). The full-flow fixture retains real isolated SQLite and synthetic managed-service edges. No tests add sleeps, polling, process boots or production test seams.The final test-only stub narrows the canonical update-owner fixture’s maintenance work; full custody and resource settlement remain covered by the separate flow regressions. Its final affected test-type graph, lint and fresh scoped P2 review passed. The ordering change also has a fresh scoped-clean P2 review. A failed preparation attempt due to concurrent lint temporary-file removal ran no tests; the serialized unchanged fixture passed. Guided-mode documentation and diff checks pass. A Git merge-tree check verifies this final head combines cleanly with the Tailscale preflight head
69ee5e1dc9282829bce36eb175f4fda9b127a262.Published-driver × exact final candidate — passed
Published OpenClaw 2026.9.8 successfully updated to exact head 0d8ecef (candidate package SHA-256
4c844a0e60c914a4216a7bfd7a680180ba5e46b95a172ff54056d51bd4a348a4; build ID2026.9.8-0d8ecefc028a-2026-10-08T05-02-12.338Z). Canonical Docker harness exit 0: durable update ledger finished/succeeded, exact installed and serving candidate identity, readiness HTTP 200, managed PID replacement, durable session/history preservation, incognito content removal and byte-preserved orphan OAuth sidecar. The update phase took 487.391 s, using the canonical CI’s verified published-driver cache seed, with the unchanged 1125 s total budget and final assertions. Owned service/container/volume cleanup completed. Official final-head build passed in 4m19.6s; canonical package integrity/import-graph verification passed.This cell executes the real published CLI/updater, candidate runtime and SQLite in disposable state with a synthetic Linux native-service manager. It does not reproduce a live macOS launchd crash loop or filesystem contention and does not exercise interactive TTY consent; those decisions and settlement are covered by the separate production-flow regressions above. No operator installation, configuration, connectivity or database was changed. Reproduction:
bash scripts/e2e/published-driver-update-docker.sh /absolute/candidate.tgz /absolute/proof-dir 2026.9.8, with the supported CI cache seed.Compatibility proof is sufficient for the complete introduced delta: no stored format, schema or migration-transform change is added, and the completed published-driver replay verifies actual Doctor/update restoration and durable state continuity. This evidence addresses the path-based migration/backfill flags without an authorship exemption or waiver. Exact final-head hosted CI is green and the PR is out of draft.
Actual macOS interactive Doctor proof
Candidate:
0d8ecefc028a0c004ad519da40bd014c103d9928, version2026.9.8, official build ID2026.9.8-0d8ecefc028a-2026-10-08T05-30-37.011Z. An independent frozen dependency installation and the officialpnpm buildowner passed (7m12.6s). The actual built CLI and native LaunchAgent were used; no Vitest flow, native adapter mock, supervisor shim, or Docker service was involved.The previously absent, task-owned profile
proof166948selected canonical state~/.openclaw-proof166948, native labelgui/501/ai.openclaw.proof166948, and free loopback port19648. Default profile/port were not used. All CLI children receivedenv -iwith actual account HOME, USER/LOGNAME, normal Node/system PATH, and TERM only. The profile used a synthetic local authentication token, no channels, no inference, disabled plugins/browser/cron, and its own workspace. The real service installer generated its profile-specific environment and plist. Launchd retained its normal OS SSH socket environment; this proof did not use SSH or any API/service credential.Commands used the absolute candidate built CLI, abbreviated here as
node /Users/dallin/openclaw-native-maintenance/dist/entry.js:scriptprovided a real PTY. Consent was entered at the displayed prompts. An independent read-only observer sampled actuallaunchctl print, plist/config/SQLite fingerprints and modes, and the profile-local ownership locks every 200ms.Stopped the managed Gateway for Doctor repair.PID 59975 disappeared; real launchctl reported the label absent and the port refused connections. Offline ownership showed Doctor PID 84895, rolesqlite-maintenance. The first config write at 2026-10-08T05:42:00.105787Z occurred with native label absent and PID null; config mode became 0600. Plist stayed identical. CLI subsequently printedGateway restarted and verified after Doctor repair.Actual restored PID 98301, readiness 200, exit 0. Durable session ID/messages survived.integrity_check.The durable sentinel was created and injected through actual Gateway RPC (
sessions.create,chat.inject), withrunStarted=falseand deliverynone. Its session ID was8614ba95-cf87-4539-8420-4cb1d1661a4e; markernative-proof166948-durable-marker-0d8ecefc. Before/afterchat.historymessages were exactly equal; only the expected responsesnapshotAttimestamp changed. After the stopped case, a read-only SQLite query confirmed the same transcript marker without starting the service.Raw bytes of the serving SQLite/WAL/SHM files can change while the unchanged Gateway remains running. This proof therefore does not claim byte equality for that active database; it uses the logical session/message oracle, alongside unchanged native PID/plist/config and absence of Doctor custody/repair. Raw fingerprints remain recorded for transparency.
Unrelated skill disabling, shell completion, and service-definition replacement were declined. The initial shared-dependency build fixture failed workspace resolution, then passed after an isolated frozen install; source was not altered. A stop without
--forcewas safely refused, and the authorized task-owned stop used the canonical--forceoption.Evidence:
maintenance-native-summary.json, official build log and build-info, raw/clean PTY transcripts for all cases, independent timeline JSONL, actual native plist/Gateway log, before/after sentinel RPC results, stopped sentinel query, and canonical uninstall log.Cleanup passed: canonical profile-specific uninstall exited 0; real launchctl label remains absent and port 19648 is free. Only the owned profile, its two recorded captures and marker, matching trashed plist, and newly created profile-specific log were removed. Evidence and the clean exact-head source worktree remain for publication.
maintenance-cleanup.jsonrecords the removed paths; the parent owns final worktree removal.