Repository navigation
feat: let each Doctor repair say whether it has work before the Gateway stops - #206247
Conversation
Declare diagnostic-only contributions, derive health-check contributions' pending work from their repairs, and add read-only checks at each owner for the boot lifecycle, external config, migration-backup completion, retained runtimes and a first group of repairing contributions. A test runs every diagnostic-only contribution under --fix and fails when one changes a store.
…ion-pending-checks
…ion-pending-checks
|
🦞👀 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: passed. What this changesThis PR adds read-only pending-work checks to Doctor contributions and late maintenance steps while preserving existing repair execution. Example: Run openclaw doctor --fix --non-interactive --yes on the supplied healthy Linux npm installation with startup tracing enabled.
Review scores
ProductKind: Refactor · Worth it: Yes · Fix scope: Partial Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR provides a useful prerequisite for avoiding unnecessary Gateway stops, and current main lacks these checks. No blocking implementation defect was established. Reviewed head: Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherDoctor coordinates configuration, database, workspace, and service repairs; contribution-owned checks now describe pending work to the existing startup trace without controlling repair execution. flowchart TD
A[Doctor CLI] --> B[Maintenance orchestration]
B --> C[Contribution owner checks]
C --> D[Pending trace]
B --> E[Existing repair owners]
E --> F[Gateway restoration]
Technical reviewBest possible solution: Land the owner-based pending checks as this preparatory stage once the applicable proof and exact-head CI gates are satisfied. Do we have a high-confidence way to reproduce the issue? Current-main source defaults contributions without predicates to work, and the supplied base CLI logs demonstrate that behavior on a healthy installation; no target code was executed during this review. Is this the best way to solve the issue? Reusing repair-owner predicates and the existing trace is a coherent, minimal mechanism; retaining unconditional execution makes this a safe preparatory stage rather than a completed downtime fix. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 9fd0b7de19b7. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +479, Tests +703, Other +3. Total +1185 across 45 files. Added test files: 3. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. 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:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
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 Reviewed November 26, 2026, 7:45 PM ET / November 27, 2026, 00:45 UTC. |
|
Merged via squash.
|
…ay stops (openclaw#206247) * feat(doctor): give contributions and late steps real pending checks Declare diagnostic-only contributions, derive health-check contributions' pending work from their repairs, and add read-only checks at each owner for the boot lifecycle, external config, migration-backup completion, retained runtimes and a first group of repairing contributions. A test runs every diagnostic-only contribution under --fix and fails when one changes a store. * test(doctor): satisfy mock, worker and test-line ratchets for pending checks
Related: #204775
What Problem This Solves
Every
openclaw doctor --fixstops a healthy Gateway before it knows whether any step has work. To make that stop conditional (step 6 of the plan in #204775), each step must answer "is there work?" truthfully and without writing. Onmain, 90 of the 94 decisions on a healthy install still answer "work" only because they have no check.This is step 5: real read-only checks for the Doctor contributions and the late steps.
User Impact
None visible.
doctor --fixstill stops the Gateway and runs every step exactly as before. WithOPENCLAW_GATEWAY_STARTUP_TRACE=1, a healthy install now traces 64 decisions aspending=none check=ownerinstead of 3. The 29 decisions that still saywork check=defaultare listed below with the reason each one has no check yet; that list is the input for step 6.Why This Change Was Made
pendingis either the declared constant"diagnostic-only"or a function at its owner."diagnostic-only"(36 contributions) meansrunnever writes under--fix. A new test runs every declared contribution in repair mode under maintenance on an install with a state database, an agent database, a config and a workspace, and fails when any file changes. A contribution that later starts writing fails that test (shown below).runDoctorHealthRepairsrepairs a check only after its detect reports a finding, so there is work exactly when a check with a real repair has one. A check without a repair, alegacyOwnedRepairthat only describes another owner's work, or a dry run cannot write. A throwing detect counts as undecidable. Core-check contributions (stale-runtime-build,telegram-general-topic-conversations) use the same rule.gateway-daemon,retained-update-runtimes).boot-lifecyclecounts the rows its repair would change through a new read operation that shares the repair'swhereclause.external-configreads the persisted snapshot with observation off, the same read its validation uses.maintenance-readychecks the migration-backup manifests its completion would record (the readiness assertions only read).retained-runtimesturns its report-only pass into a decision through anonRecognizedcallback; it counts what the cleanup would try to remove.-walfile; the tests treat that as unchanged because any write leaves frames in it or changes the database.maybeRepairGatewayServiceConfigand the daemon runtime pin migration writes during it; that needs a read-only plan from the daemon side. The startup steps belong to the step 4 PR.doctor-health-contributions.tswas over its line cap after the change, so the systemd linger helpers moved unchanged intodoctor-systemd-linger.tsand the final contributions import them directly instead of taking them as parameters.gatewayBootReadOperationsin the state read worker, so it is added to that kernel's existing W-tier entry inscripts/database-worker-inventory.mjsbeside its sibling readers. The tests exceed the 400-line test budget by 303 lines;config/test-lines-allocations/206247-doctor-contribution-pending-checks.txtrecords that, because each new check needs a case with real work and the diagnostic-only declarations need their store test.Classification of all 81 contributions
"diagnostic-only"; enforced by the store testWhat still says
workorundecidableon a healthy install, and whyopenclaw.json,config.lastTouchedAt, cron rows, Codex routesctx.cfgagainstcfgForPersistence, order-sensitive JSON), not the file; a check needs the config-flow result, which is step 4's laneobserve: falseis a behavior change for its own PRrunGatewayAuthHealth; needs a split that also covers--generate-gateway-tokenrepairObsoleteGeneratedExecApprovalsdecides inside a write transaction on every runlastTouchedVersionmaybeRepairGatewayServiceConfig(about 450 lines) andwithDaemonRuntimePinMigrationwrites; needs a read-only plan from the daemon sideundecidableon btrfs withoutlsattr(existing check)Update behavior
There is no update-path change. A published updater that runs Doctor on this build runs the same repairs in the same order; the only difference is the trace lines when the trace variable is set. Nothing here changes what any step does or when the Gateway stops.
Evidence
Cells: Linux, systemd user Gateway, npm install of a packed build under an unpublished version, 64 MiB agent database,
/readyzprobed every 250 ms. Base ismainatfcc9a0648c2(packed as 2026.11.23). Head is this PR's first commit,241d268c280(packed as 2026.11.24). One count cell per build runsdoctor --fix --non-interactive --yesthree times on a healthy install. One guard cell per build seeds real work while the Gateway serves (state database mode 0644, a maintenancestartup_failedboot row, a plugin record removed, aTOOLS.md, an abandoned updater runtime and a look-alike folder as a negative control), then runs Doctor twice.fcc9a0648c2241d268c280pending=none check=ownerpending=work check=defaultpending=undecidable check=ownersqlite-nocow, nolsattron btrfs)workon a healthy runretained-runtimes, before the stop), then 46 ms (plugin registry)/readyzoutage, runs 1 / 2 / 3Guard cells, the seeded sites:
work default→work defaultwork owner→none ownerstartup_failure_repairedwork default→work defaultwork owner→none ownerwork owner→none ownerwork owner→none ownerwork default→work defaultwork owner→work owner/readyzoutage, settle / work / cleanHead's outage is within noise of base; the checks cost milliseconds and the stop is unchanged.
Recordings replay the raw cell logs: the decision counts, the remaining
worklist, the outages and the guard cell.RED/BASE,
fcc9a0648c2:red-base.mp4
GREEN/HEAD,
241d268c280:green-head.mp4
Enforcement test failing on a deliberate local edit, then passing after the revert:
enforcement.mp4
Raw evidence, base (home paths shortened)
Raw evidence, head (home paths shortened)
Enforcement test, red then green
Tests (every non-constant check has a case with real pending work that it reports as
work, then the contribution does the work and the check reportsnone)src/flows/doctor-health-contributions.diagnostic-only.test.ts: runs all 36 declared contributions under--fixand maintenance and asserts no file under the install changed, the config is unchanged and no change panel was queued. Red: a deliberatewriteConfigMachineStateindoctor:disk-spacefails it namingstate/openclaw.sqlite.src/flows/doctor-health-contribution.pending.test.ts: the derived check (a repairable finding is work and the run repairs it; detect-only, legacy-owned and dry runs are none; a failing detect tracesundecidable);gateway-daemon,gateway-servicesandretained-update-runtimeshave work only outside maintenance; systemd linger has work only for an interactive run with lingering off, and the run then enables it.src/flows/doctor-external-config.test.ts: a read-only config that would refuse startup is work, a valid one and a Doctor-writable one are none.241d268c280and again on the merged head: the 17 touched test files plus the Doctor contribution, maintenance, plugin registry, retained-runtime settlement, temp-artifact cleanup, migration backup and state read registry suites: 436 passed, 14 skipped (existing platform skips), 0 failed. Also green:pnpm tsgo:core,pnpm tsgo:core:test, oxlint on every touched file (line caps included), the session identity ratchet andgit diff --check.doctor-hosted-gateway.test.tslost the three linger parameters it passed only to satisfy the old signature. Nothing else was removed; the remaining skips are existing platform skips (Linux-only/proc, no Windows ACLs,setAuthorizeravailability).$autoreview(Codex route, branch mode againstorigin/main, P0 to P2) returned scoped-clean.Not proven
maintenance-ready,external-config, agent memory schema and project clones with real work in a cell; their work cases are unit tests on real stores.241d268c280. The branch then mergedmain(no change undersrc/flows,src/commands/doctor*or the touched infra files); the focused suites ran again on the merged head.