Skip to content

feat: let each Doctor repair say whether it has work before the Gateway stops - #206247

Merged
fuller-stack-dev merged 5 commits into
openclaw:mainfrom
fuller-stack-dev:feat/doctor-contribution-pending-checks
Nov 27, 2026
Merged

fuller-stack-dev merged 5 commits into
openclaw:mainfrom
fuller-stack-dev:feat/doctor-contribution-pending-checks

Conversation

@fuller-stack-dev

@fuller-stack-dev fuller-stack-dev commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

Related: #204775

What Problem This Solves

Every openclaw doctor --fix stops 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. On main, 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 --fix still stops the Gateway and runs every step exactly as before. With OPENCLAW_GATEWAY_STARTUP_TRACE=1, a healthy install now traces 64 decisions as pending=none check=owner instead of 3. The 29 decisions that still say work check=default are listed below with the reason each one has no check yet; that list is the input for step 6.

Why This Change Was Made

  • One small mechanism, no blanket answers. A contribution's pending is either the declared constant "diagnostic-only" or a function at its owner.
    • "diagnostic-only" (36 contributions) means run never 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).
    • Contributions that only declare health checks get their check derived from them: runDoctorHealthRepairs repairs 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, a legacyOwnedRepair that 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.
    • Every other check reuses the contribution's own gate. Where the gate sat inside the write function, it is split out at that owner and both the check and the repair call it: TOOLS.md migration, legacy plugin manifests, agent memory schema, project clones, shell completion, Screen Sharing, the model allowlist offer, channel startup maintenance hooks, stray launchd jobs, systemd linger, and the two contributions Doctor defers under maintenance (gateway-daemon, retained-update-runtimes).
  • Late steps. boot-lifecycle counts the rows its repair would change through a new read operation that shares the repair's where clause. external-config reads the persisted snapshot with observation off, the same read its validation uses. maintenance-ready checks the migration-backup manifests its completion would record (the readiness assertions only read). retained-runtimes turns its report-only pass into a decision through an onRecognized callback; it counts what the cleanup would try to remove.
  • Contract for each check: no writable open, no file creation, no database copy, no lock. The agent-memory check runs the repair's existing no-op test without the Doctor SQLite maintenance lock; its databases open read-only. A read-only open of a WAL database can leave an empty -wal file; the tests treat that as unchanged because any write leaves frames in it or changes the database.
  • Left on the default. Service-definition repair decides inside maybeRepairGatewayServiceConfig and 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.ts was over its line cap after the change, so the systemd linger helpers moved unchanged into doctor-systemd-linger.ts and the final contributions import them directly instead of taking them as parameters.
  • Ratchets: the new boot-lifecycle count runs only through gatewayBootReadOperations in the state read worker, so it is added to that kernel's existing W-tier entry in scripts/database-worker-inventory.mjs beside its sibling readers. The tests exceed the 400-line test budget by 303 lines; config/test-lines-allocations/206247-doctor-contribution-pending-checks.txt records that, because each new check needs a case with real work and the diagnostic-only declarations need their store test.
  • No schema, stored field, config option, protocol or retention change.

Classification of all 81 contributions

Class Contributions Check
(a) diagnostic only (36) node-runtime, runtime-capabilities, gateway-config, database-engine, claude-cli, command-owner, legacy-plugin-dependencies, stale-plugin-runtime-symlinks, ui-protocol-freshness, disk-space, db-bloat, channel-ingress-dead-letters, session-snapshots, codex-bwrap, security, web-fetch-proxy, bundle-lsp-env, github-projects, browser, oauth-tls, hooks-model, legacy-output-cap, model-references, acp-agent-model, provider-catalog-projection, local-audio-acceleration, runtime-tool-schemas, skill-workshop-tool-policy, workspace-status, workspace-alias, bootstrap-size, memory-provenance, gateway-health, whatsapp-responsiveness, device-pairing, workspace-suggestions declared "diagnostic-only"; enforced by the store test
(a) health checks without a repair (6) agent-database-admission, native-status, node-hosting-preconditions, update-snapshots, default-account-routing, channel-package-state-capabilities derived: no repair means no work
(a) at their gate under maintenance (2) gateway-daemon (daemon repair happens at service restoration), retained-update-runtimes (cleaned before the stop) the contribution's own gate
(b) outside the protected stores (9) gmail-gog (Homebrew upgrade), legacy-plugin-manifests (manifest files), tools-md-migration (workspace files), shell-completion (cache, shell profile), project-clone-shape (git history), gateway-services (stray launchd jobs on macOS), host-desktop (macOS Screen Sharing), systemd-linger (loginctl), stale-runtime-build (no repair; derived) owner predicate shared with the repair
(c) protected stores, with a check (5) plugin-registry (step 3), telegram-general-topic-conversations (agent database), agent-memory-schema (agent database), model-allowlist-wildcards (config), startup-channel-maintenance (plugin hooks) owner predicate shared with the repair
(c) protected stores, still default (23) see the table below none yet

What still says work or undecidable on a healthy install, and why

Contribution or step Writes Why it still defaults to work
write-config-migrations, write-config openclaw.json, config.lastTouchedAt, cron rows, Codex routes the write decision compares in-memory candidates (ctx.cfg against cfgForPersistence, order-sensitive JSON), not the file; a check needs the config-flow result, which is step 4's lane
final-config-validation state database config-health rows reads the snapshot with observation on; passing observe: false is a behavior change for its own PR
auth-profile-migration, auth-profiles auth stores, agent databases, config the resume step decides under a file lock while writing; OAuth refresh hits the network
gateway-auth secret store, state database snapshot decision is inline in runGatewayAuthHealth; needs a split that also covers --generate-gateway-token
structured-health-repairs plugin-driven config and package changes runs every plugin health check; a check would run every plugin detect a second time
legacy-state state and agent databases, exec approvals repairObsoleteGeneratedExecApprovals decides inside a write transaction on every run
session-transcripts, session-transcript-headers, session-transcript-labels agent databases, backups owners only offer a preview mode that also prints notes; no pure detect
codex-session-routes agent databases preview path prints notes and uses a tolerant scan unlike the repair's strict one
release-configured-plugin-installs plugin packages, plugin index, config its no-op plan is inline and not exported; it also rewrites lastTouchedVersion
legacy-plugin-source-captures capture folders native capture cleanup decides inline while removing
state-integrity state database (opens a write transaction on every run), file modes, agent stores the agent-path repair checks for pending rows inside its write transaction
config-audit-scrub agent databases (a DELETE on every run), audit log the usage-cost cache cleanup has no predicate
legacy-cron cron store loading the mutable store can commit repairs before any prompt
sandbox config, sandbox registry, images mixes three owners; image check spawns docker
skills config its kept-skills rule differs from the core detect; needs a shared predicate
heartbeat-cadence-migration, heartbeat-scratch-migration, heartbeat-task-cron-migration state and agent databases, workspace files their detects use artifact-preserving reads that may copy the database
memory-search plugin state store, workspace files memory plugin runtime decides inline
client-credentials, state-database-repair, database-migrations, runtime-checks, config-flow state database, config step 4 lane
service-definition systemd unit / launchd plist decision is inline in maybeRepairGatewayServiceConfig (about 450 lines) and withDaemonRuntimePinMigration writes; needs a read-only plan from the daemon side
sqlite-nocow store rewrite undecidable on btrfs without lsattr (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, /readyz probed every 250 ms. Base is main at fcc9a0648c2 (packed as 2026.11.23). Head is this PR's first commit, 241d268c280 (packed as 2026.11.24). One count cell per build runs doctor --fix --non-interactive --yes three times on a healthy install. One guard cell per build seeds real work while the Gateway serves (state database mode 0644, a maintenance startup_failed boot row, a plugin record removed, a TOOLS.md, an abandoned updater runtime and a look-alike folder as a negative control), then runs Doctor twice.

base fcc9a0648c2 head 241d268c280
decisions per healthy run 94 94
pending=none check=owner 3 64
pending=work check=default 90 29
pending=undecidable check=owner 1 (sqlite-nocow, no lsattr on btrfs) 1 (same)
any owner check answering work on a healthy run 0 0
slowest owner check 55 ms (plugin registry) 65 ms (retained-runtimes, before the stop), then 46 ms (plugin registry)
/readyz outage, runs 1 / 2 / 3 29.2 / 25.7 / 26.2 s 25.7 / 22.7 / 22.9 s

Guard cells, the seeded sites:

Site base, work run → clean run head, work run → clean run Repaired on both builds
boot lifecycle work default → work default work owner → none owner row marked startup_failure_repaired
TOOLS.md migration work default → work default work owner → none owner merged into AGENTS.md
plugin registry (step 3) work owner → none owner work owner → none owner 78 → 79 plugins
retained runtimes work default → work default work owner → work owner kept on both: inside a container the process census refuses removal by design, so the folder is still there and the check still reports it
look-alike runtime (negative control) kept kept, not counted
/readyz outage, settle / work / clean 29.4 / 23.4 / 23.2 s 26.0 / 22.9 / 23.0 s

Head'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 work list, 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)
=== RED/BASE: main fcc9a0648c2
cell count-base: Linux, systemd user Gateway, npm install of 2026.11.23 fcc9a0648c2, healthy install

---- doctor2: OPENCLAW_GATEWAY_STARTUP_TRACE=1 openclaw doctor --fix --non-interactive --yes
  decisions: 94
     3 pending=none check=owner
     1 pending=undecidable check=owner
    90 pending=work check=default
  doctor: The Gateway was stopped for 25.4 s.

---- doctor3: OPENCLAW_GATEWAY_STARTUP_TRACE=1 openclaw doctor --fix --non-interactive --yes
  decisions: 94
     3 pending=none check=owner
     1 pending=undecidable check=owner
    90 pending=work check=default
  doctor: The Gateway was stopped for 26.1 s.

---- /readyz outage (250 ms probe)
  doctor1: OUTAGE (/readyz) 29.2 s, doctor wall 45.2 s
  doctor2: OUTAGE (/readyz) 25.7 s, doctor wall 40.4 s
  doctor3: OUTAGE (/readyz) 26.2 s, doctor wall 41.4 s

---- doctor2: decisions that are not none
  doctor.pending.retained-runtimes (0.0ms) pending=work check=default
  doctor.pending.client-credentials (0.0ms) pending=work check=default
  doctor.pending.state-database-repair (0.0ms) pending=work check=default
  doctor.pending.database-migrations (0.0ms) pending=work check=default
  doctor.pending.runtime-checks (0.0ms) pending=work check=default
  doctor.pending.config-flow (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:write-config-migrations (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:agent-database-admission (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:native-status (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:node-runtime (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:runtime-capabilities (0.1ms) pending=work check=default
  doctor.pending.contribution.doctor:gateway-config (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:database-engine (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:auth-profile-migration (0.1ms) pending=work check=default
  doctor.pending.contribution.doctor:auth-profiles (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:claude-cli (0.1ms) pending=work check=default
  doctor.pending.contribution.doctor:gmail-gog (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:gateway-auth (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:node-hosting-preconditions (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:command-owner (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:structured-health-repairs (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:legacy-state (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:session-transcripts (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:agent-memory-schema (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:legacy-plugin-manifests (0.1ms) pending=work check=default
  doctor.pending.contribution.doctor:legacy-plugin-dependencies (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:stale-plugin-runtime-symlinks (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:release-configured-plugin-installs (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:legacy-plugin-source-captures (0.1ms) pending=work check=default
  doctor.pending.contribution.doctor:retained-update-runtimes (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:update-snapshots (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:ui-protocol-freshness (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:stale-runtime-build (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:disk-space (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:project-clone-shape (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:db-bloat (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:channel-ingress-dead-letters (0.1ms) pending=work check=default
  doctor.pending.contribution.doctor:state-integrity (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:codex-session-routes (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:telegram-general-topic-conversations (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:session-transcript-headers (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:session-transcript-labels (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:session-snapshots (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:config-audit-scrub (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:legacy-cron (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:sandbox (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:codex-bwrap (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:gateway-services (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:host-desktop (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:default-account-routing (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:channel-package-state-capabilities (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:startup-channel-maintenance (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:security (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:web-fetch-proxy (0.1ms) pending=work check=default
  doctor.pending.contribution.doctor:bundle-lsp-env (0.1ms) pending=work check=default
  doctor.pending.contribution.doctor:github-projects (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:browser (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:oauth-tls (0.1ms) pending=work check=default
  doctor.pending.contribution.doctor:hooks-model (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:legacy-output-cap (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:model-references (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:acp-agent-model (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:provider-catalog-projection (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:local-audio-acceleration (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:runtime-tool-schemas (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:skill-workshop-tool-policy (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:systemd-linger (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:workspace-status (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:workspace-alias (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:skills (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:model-allowlist-wildcards (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:bootstrap-size (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:memory-provenance (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:heartbeat-cadence-migration (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:heartbeat-scratch-migration (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:tools-md-migration (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:heartbeat-task-cron-migration (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:shell-completion (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:gateway-health (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:whatsapp-responsiveness (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:memory-search (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:device-pairing (0.1ms) pending=work check=default
  doctor.pending.contribution.doctor:gateway-daemon (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:write-config (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:workspace-suggestions (0.1ms) pending=work check=default
  doctor.pending.contribution.doctor:final-config-validation (0.0ms) pending=work check=default
  doctor.pending.external-config (0.0ms) pending=work check=default
  doctor.pending.maintenance-ready (0.0ms) pending=work check=default
  doctor.pending.boot-lifecycle (0.0ms) pending=work check=default
  doctor.pending.sqlite-nocow (0.0ms) pending=undecidable check=owner
  doctor.pending.service-definition (0.1ms) pending=work check=default

=== guard cell guard-base (2026.11.23 fcc9a0648c2): seed real work while the Gateway serves, then doctor --fix twice
  after: MainPID=5261 NRestarts=0 ActiveState=active SubState=running 
  seeded: mode 644, boot row seeded-startup-failure, index plugins 78 (removed xai), revision 1795736521064
  seeded: ~/.openclaw/workspace/TOOLS.md
  seeded: ~/um/tmp/openclaw-update-runtime-Step5a (596742173 bytes, owner pid 5684 exited)
  seeded negative control: ~/um/tmp/openclaw-update-runtime-Keep05
  after: MainPID=8550 NRestarts=0 ActiveState=active SubState=running 
  after: mode 600, boot row outcome startup_failure_repaired, index plugins 79, revision 1795736607307
  after: TOOLS.md migrated (AGENTS.md has notes: 1)
  after: retained runtime present
  after: negative control kept
  after: MainPID=11810 NRestarts=0 ActiveState=active SubState=running 
  after: mode 600, boot row outcome startup_failure_repaired, index plugins 79, revision 1795736607307
  after: TOOLS.md migrated (AGENTS.md has notes: 1)
  after: retained runtime present
  after: negative control kept
  -- doctorwork
     doctor.pending.retained-runtimes (0.0ms) pending=work check=default
     doctor.pending.contribution.doctor:plugin-registry (37.8ms) pending=work check=owner
     doctor.pending.contribution.doctor:tools-md-migration (0.1ms) pending=work check=default
     doctor.pending.boot-lifecycle (0.0ms) pending=work check=default
  -- doctorclean
     doctor.pending.retained-runtimes (0.0ms) pending=work check=default
     doctor.pending.contribution.doctor:plugin-registry (49.0ms) pending=none check=owner
     doctor.pending.contribution.doctor:tools-md-migration (0.0ms) pending=work check=default
     doctor.pending.boot-lifecycle (0.0ms) pending=work check=default
  doctor1: OUTAGE (/readyz) 29.4 s, doctor wall 43.0 s
  doctorwork: OUTAGE (/readyz) 23.4 s, doctor wall 36.8 s
  doctorclean: OUTAGE (/readyz) 23.2 s, doctor wall 36.8 s
Raw evidence, head (home paths shortened)
=== GREEN/HEAD: 241d268c280
cell count-head: Linux, systemd user Gateway, npm install of 2026.11.24 241d268c280, healthy install

---- doctor2: OPENCLAW_GATEWAY_STARTUP_TRACE=1 openclaw doctor --fix --non-interactive --yes
  decisions: 94
    64 pending=none check=owner
     1 pending=undecidable check=owner
    29 pending=work check=default
  doctor: The Gateway was stopped for 22.6 s.

---- doctor3: OPENCLAW_GATEWAY_STARTUP_TRACE=1 openclaw doctor --fix --non-interactive --yes
  decisions: 94
    64 pending=none check=owner
     1 pending=undecidable check=owner
    29 pending=work check=default
  doctor: The Gateway was stopped for 22.7 s.

---- /readyz outage (250 ms probe)
  doctor1: OUTAGE (/readyz) 25.7 s, doctor wall 39.2 s
  doctor2: OUTAGE (/readyz) 22.7 s, doctor wall 35.9 s
  doctor3: OUTAGE (/readyz) 22.9 s, doctor wall 36.1 s

---- doctor2: decisions that are not none
  doctor.pending.client-credentials (0.0ms) pending=work check=default
  doctor.pending.state-database-repair (0.0ms) pending=work check=default
  doctor.pending.database-migrations (0.0ms) pending=work check=default
  doctor.pending.runtime-checks (0.0ms) pending=work check=default
  doctor.pending.config-flow (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:write-config-migrations (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:auth-profile-migration (0.1ms) pending=work check=default
  doctor.pending.contribution.doctor:auth-profiles (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:gateway-auth (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:structured-health-repairs (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:legacy-state (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:session-transcripts (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:release-configured-plugin-installs (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:legacy-plugin-source-captures (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:state-integrity (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:codex-session-routes (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:session-transcript-headers (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:session-transcript-labels (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:config-audit-scrub (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:legacy-cron (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:sandbox (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:skills (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:heartbeat-cadence-migration (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:heartbeat-scratch-migration (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:heartbeat-task-cron-migration (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:memory-search (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:write-config (0.0ms) pending=work check=default
  doctor.pending.contribution.doctor:final-config-validation (0.0ms) pending=work check=default
  doctor.pending.sqlite-nocow (0.0ms) pending=undecidable check=owner
  doctor.pending.service-definition (0.0ms) pending=work check=default

=== guard cell guard-head (2026.11.24 241d268c280): seed real work while the Gateway serves, then doctor --fix twice
  after: MainPID=5247 NRestarts=0 ActiveState=active SubState=running 
  seeded: mode 644, boot row seeded-startup-failure, index plugins 78 (removed xai), revision 1795737978216
  seeded: ~/.openclaw/workspace/TOOLS.md
  seeded: ~/um/tmp/openclaw-update-runtime-Step5a (596753588 bytes, owner pid 5664 exited)
  seeded negative control: ~/um/tmp/openclaw-update-runtime-Keep05
  after: MainPID=8533 NRestarts=0 ActiveState=active SubState=running 
  after: mode 600, boot row outcome startup_failure_repaired, index plugins 79, revision 1795738060611
  after: TOOLS.md migrated (AGENTS.md has notes: 1)
  after: retained runtime present
  after: negative control kept
  after: MainPID=11796 NRestarts=0 ActiveState=active SubState=running 
  after: mode 600, boot row outcome startup_failure_repaired, index plugins 79, revision 1795738060611
  after: TOOLS.md migrated (AGENTS.md has notes: 1)
  after: retained runtime present
  after: negative control kept
  -- doctorwork
     doctor.pending.retained-runtimes (64.3ms) pending=work check=owner
     doctor.pending.contribution.doctor:plugin-registry (37.4ms) pending=work check=owner
     doctor.pending.contribution.doctor:tools-md-migration (1.8ms) pending=work check=owner
     doctor.pending.boot-lifecycle (13.3ms) pending=work check=owner
  -- doctorclean
     doctor.pending.retained-runtimes (65.5ms) pending=work check=owner
     doctor.pending.contribution.doctor:plugin-registry (48.2ms) pending=none check=owner
     doctor.pending.contribution.doctor:tools-md-migration (1.9ms) pending=none check=owner
     doctor.pending.boot-lifecycle (13.0ms) pending=none check=owner
  doctor1: OUTAGE (/readyz) 26.0 s, doctor wall 39.2 s
  doctorwork: OUTAGE (/readyz) 22.9 s, doctor wall 36.3 s
  doctorclean: OUTAGE (/readyz) 23.0 s, doctor wall 36.4 s
Enforcement test, red then green
=== ENFORCEMENT: deliberate local edit (not committed) makes doctor:disk-space write the state database
  +        // DELIBERATE RED EDIT: a "diagnostic-only" contribution starts writing the state database.
  +        writeConfigMachineState("doctor.diskSpace.lastCheckedAt", new Date().toISOString());
---- node scripts/run-vitest.mjs src/flows/doctor-health-contributions.diagnostic-only.test.ts (with the edit)
   × |unit| src/flows/doctor-health-contributions.diagnostic-only.test.ts > diagnostic-only Doctor contributions > doctor:disk-space change
  ⎯⎯⎯⎯⎯⎯⎯ Failed Tests 1 ⎯⎯⎯⎯⎯⎯⎯
  - Expected
  + Received
  +   "home/.openclaw/state/openclaw.sqlite",
        Tests  1 failed | 36 passed (37)
---- same command after reverting the edit
   Test Files  1 passed (1)
        Tests  37 passed (37)

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 reports none)

  • New src/flows/doctor-health-contributions.diagnostic-only.test.ts: runs all 36 declared contributions under --fix and maintenance and asserts no file under the install changed, the config is unchanged and no change panel was queued. Red: a deliberate writeConfigMachineState in doctor:disk-space fails it naming state/openclaw.sqlite.
  • New 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 traces undecidable); gateway-daemon, gateway-services and retained-update-runtimes have work only outside maintenance; systemd linger has work only for an interactive run with lingering off, and the run then enables it.
  • New 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.
  • Added cases to the owner suites: boot lifecycle (counts exactly the two maintenance rows, not the unrelated failure; zero after the repair), TOOLS.md, legacy plugin manifests, agent memory schema (files byte-identical after the check), project clones (shallow is work, full and partial are none, a missing clone is undecidable), shell completion, Screen Sharing, the allowlist offer, channel startup maintenance, stray launchd jobs, retained runtimes (recognized runtime is work, unmarked and look-alike folders are none, census never runs), migration-backup completion (work only under schema maintenance until recorded), Telegram General-topic rows (through the real contribution).
  • Focused suites on 241d268c280 and 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 and git diff --check.
  • Files audited in full: every touched test file. doctor-hosted-gateway.test.ts lost 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, setAuthorizer availability).
  • Review: $autoreview (Codex route, branch mode against origin/main, P0 to P2) returned scoped-clean.

Not proven

  • macOS, Windows, pnpm and Git installs. The darwin-only checks (stray launchd jobs, Screen Sharing) are covered by unit tests only.
  • Removal of a retained runtime by the pre-stop cleanup: the container census refuses it, so the guard cell shows the check and the kept folder, not a removal.
  • 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.
  • The diagnostic-only test runs on one healthy fixture, so it catches a contribution that writes on a healthy install; a write that happens only for a state the fixture lacks needs the source classification above.
  • The cells ran on 241d268c280. The branch then merged main (no change under src/flows, src/commands/doctor* or the touched infra files); the focused suites ran again on the merged head.

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.
@clawsweeper

clawsweeper Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added commands Command implementations size: XL labels Nov 27, 2026
@clawsweeper clawsweeper Bot added the P2 Normal backlog priority with limited blast radius. label Nov 27, 2026
@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Nov 27, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Nov 27, 2026
@clawsweeper

clawsweeper Bot commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Codex review: passed.

What this changes

This 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.

  • Before: The trace reports 3 owner decisions as pending=none and 90 default decisions as pending=work.
  • After: The trace reports 64 owner decisions as pending=none and 29 default decisions as pending=work; the Gateway still stops and restarts.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The implementation is coherent and has meaningful production CLI evidence, but upgrade proof remains incomplete and exact-head CI is unresolved.
Proof confidence 🦪 silver shellfish (2/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Refactor · Worth it: Yes · Fix scope: Partial
User problem: Doctor stops a healthy Gateway before determining whether repairs need downtime.
Reason: The maintainer-authored direction supports a measured outage-reduction plan, while this stage deliberately preserves existing repairs and stopping behavior.

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: b44384e8bbbc5515b970ca309c5d9b4ec32b1851

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The PR owner should provide a v2026.11.10-to-candidate upgrade exercising Doctor with seeded settings and data preserved, with IPs, credentials, phone numbers, and non-public endpoints redacted.
Agent review details

How this fits together

Doctor 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]
Loading

Technical review

Best 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

  • Doctor pending tracing keeps the original intent (d0f7698: Record conservative read-only work decisions before making Gateway stopping conditional.)
  • Contribution ownership and orchestration keeps the original intent (1ae0dfe: Split the ordered Doctor flow while preserving repair ownership, ordering, lazy imports, and output.)
  • Pre-stop retained-runtime cleanup keeps the original intent (3495c16: Remove abandoned updater runtimes before stopping the Gateway without changing custody or removal decisions.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Jason (Json): Raw commit d0f7698 adds src/flows/doctor-health-contribution-utils.ts:62 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: d0f769895093; files: src/flows/doctor-health-contribution-utils.ts)
  • Peter Steinberger: Raw commit 1ae0dfe adds src/flows/doctor-health-contribution.ts:18 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 1ae0dfed4d14; files: src/flows/doctor-health-contribution.ts)

PR surface

Source +479, Tests +703, Other +3. Total +1185 across 45 files. Added test files: 3.

View PR surface stats
Area Files Added Removed Net
Source 25 669 190 +479
Tests 18 723 20 +703
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 2 3 0 +3
Total 45 1395 210 +1185

Preflight source

Source 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 cluster

Relationship: partial_overlap
Canonical: #204775
Summary: This PR implements one Doctor workstream stage within the broader prepared-update design.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Complete the upgrade scenario identified in the proof assessment.
  • Inspect the failed ratchet diagnostics and establish their cause before landing.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 26, 2026, 7:45 PM ET / November 27, 2026, 00:45 UTC.

@fuller-stack-dev
fuller-stack-dev merged commit 5c81526 into openclaw:main Nov 27, 2026
223 of 226 checks passed
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Merged via squash.

@fuller-stack-dev
fuller-stack-dev deleted the feat/doctor-contribution-pending-checks branch November 27, 2026 00:56
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 27, 2026
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. scripts Repository scripts size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant