Repository navigation
fix(doctor): report which config-flow owners have work - #207146
fuller-stack-dev merged 2 commits into
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: passed. What this changesThis PR adds read-only pending-work checks and individual trace entries for Doctor’s config-flow owners. Example: Doctor inspects an install without retired state files such as ~/.openclaw/acp/event-ledger.json.
Review scores
ProductKind: Refactor · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR adds useful owner-level diagnostics for the ongoing Doctor work, and inspection found no definite introduced correctness defect. Reviewed head: Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherDoctor calls these checks before running its existing config repair flow; they consume configuration and store inspections and produce maintenance trace decisions without controlling whether repairs execute. flowchart TD
A[Doctor command] --> B[Database preflight]
B --> C[Config-flow pending checks]
C --> D[Existing owner predicates]
D --> E[Per-owner maintenance trace]
E --> F[Existing config repair flow]
Technical reviewBest possible solution: Retain the existing repair owners and conservative pending answers, then complete the required validation before landing. Do we have a high-confidence way to reproduce the issue? Current main’s source establishes the diagnostic limitation: unchecked config-flow inputs force work without individual owner trace entries; no runtime reproduction was performed. Is this the best way to solve the issue? Reusing existing owner predicates and preserving unconditional repair execution is a coherent preparatory change; it does not yet solve unnecessary Gateway stops. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against f5453cb9377e. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +467, Tests +235. Total +702 across 11 files. Added test files: 0. 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. 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:
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 27, 2026, 9:40 PM ET / November 28, 2026, 02:40 UTC. |
|
Merged via squash.
|
Related: #204775
What Problem This Solves
openclaw doctor --fixstops the Gateway and runs its config flow on every run, even on a healthy install. To make that stop conditional later, each step must first report truthfully whether it has work. The config flow reportedworkwhenever anything other than its state schema input was involved, because only that one input had a read-only check. That answer said nothing about which owners actually had work.User Impact
None visible today: Doctor still stops the Gateway and runs every step exactly as before. The trace now shows, per owner, whether the config flow had work, and the step answers
noneonly when every owner answersnone. Three owners still have no read-only predicate, so on a healthy install the step still answerswork, now with the reason in the trace.Why This Change Was Made
Each input calls the predicate its owner's writer acts on, decided from one config snapshot read without observation. Every SQLite read goes through
decideDoctorPendingFromLiveStores, so a store nobody holds answersundecidable, and agent stores are listed inside the state database guard. Where a writer decided inline, the decision moved to a shared function the writer now also uses (retired state files, A2UI widget inspection, relative session stores, the legacy config file rename, cron preflight work, plugin obligations). Writer behavior is unchanged.Inputs, in the order the flow reaches them:
state-write-admissionr+probe writes nothing and stayslegacy-state-dirlegacy-configstate-schemaretired-statesession-entry-stateapply: false)plugin-convergenceplanStartupPluginConvergence().requiredplugin-obligationscronlegacy-state-detectiondetectLegacyStatepreviews and legacy exec approvalsagent-databasesplanAgentDatabaseMigration(...).pendingfrom #206707, with the preflight's discoverya2ui-widgetsrelative-session-storeslegacy-state-stepsupdate-historyconfig-repairsPlugin obligations: any recorded obligation, pending or deferred, is
work(the flow reopens and settles it again), and a configured plugin that is unavailable iswork(it becomes one). A plugin refused by policy is not recorded by the flow and is not counted. The reopen behavior and the registry queries are unchanged.Evidence
Tested commits: base
870f9a62706(main) and head9fd46d12b73. The PR headc0d6346772fdiffers from the tested head by a dropped unused export, test-only edits and a merge ofmainthat touches none of these owners. Cells: Linux Docker, systemd user Gateway, npm install of a local pack under the unpublished version 2026.11.13, Telegram and X channels, three agents, no network. The healthy store was seeded with the base build, settled with twodoctor --fixruns, and restored byte-identical (sha256 over all files) before every run.Method:
strace -fplus a preload that records every write-intentfscall and everynode:sqliteopen, write statement andBEGIN IMMEDIATE/EXCLUSIVEwith its JS caller, limited to thedoctor.config-flowspan (and, on the head, to eachdoctor.pending.config-flow.*span).Red (base, healthy install):
doctor.pending.config-flow pending=work check=owner, withconfig-flow.state-schemathe only input. What the flow still opens, writes or creates on that install (after #206694, #206707, #206513):r+open ofstate/openclaw.sqlitestate/openclaw.sqlitewith connection setup (journal_mode=WAL,wal_autocheckpoint,synchronous), no transaction, no rowreadDatabaseProposals), a legacy graph steplegacy-state-steps, no predicate yet~/.cache/openclawwith its staging token storehasActiveAgentDatabaseLease, artifact-preserving read)writable_schemacatalog reads,busy_timeout,cache_size) on read-only connectionsNo file bytes, rows, leases or
BEGIN IMMEDIATEin the span. With a configured plugin that cannot be installed (an earlier fixture hadslackconfigured), the same span also wrotemigration_runstwice, took the plugin lifecycle lease (fourstate_leaseswrites) and called npm; that case is theplugin-convergenceandplugin-obligationsguard below.Green (head, same restored store): every input with a check answers
none; the three without one keep the step atwork.Cost of the check on this store: about 1.9 s in all (cron 433 ms, legacy-state detection 629 ms, agent databases 524 ms, the rest under 100 ms each). Inside each
config-flow.*span the preload saw no write-intentfscall, no writable open of a real store, noBEGIN, and no copy: only read-only opens with connection-local PRAGMAs. The longest single SQLite statement the check issues is the agent database plan's read-only integrity check (the plan'sintegritycondition, run in its worker); it was not timed per statement here and grows with database size. The flow itself still runs everything after the check, so on large agent databases the integrity check now runs twice perdoctor --fixuntil the stop becomes conditional.Guards (base, then head on the same restored store, then head again without restoring). Schema and config seeds were applied while the Gateway was serving, because a Gateway boot heals them first.
capture_events_flow_idxconfig-flow.state-schema=worknoneworkagent databaseconfig-flow.agent-databases=worknoneroutingkeyconfig-flow.legacy-config=work(config-dependent inputsundecidableon the invalid config)noneopenclaw.jsonidentical to baseabsent-owner)pendingplugin-convergence=work,plugin-obligations=workplugin-obligations=work(pending row); the flow then settles itcompletedplugin-obligations=noneonce settlednonedetectLegacyStatepreview (an invalid events file)legacy-state-detection=workworkagain: the plugin keeps the invalid source, as on basenonenoneNot run through the CLI: the legacy state directory. With
~/.openclawmoved to~/.clawdbot, base and head both refuse before maintenance ("State directory selection changed before moving ...") because the service unit names the state directory; the input is covered by the unit test.Tests.
src/commands/doctor-config-flow-pending.test.ts(rewritten, 12 cases on real stores; fails onmain, where the inputs do not exist): every input traced in order and the stepworkwhile an input has no check, with no file changed beside a held store; per-inputwork/nonefor permission drift and orphaned sidecars, a legacy state directory, a legacy config shape, a retired state file, a retired cron store (held store, no file change), a recorded obligation with and without a config file, an unavailable configured plugin;undecidablewithout sidecars for every SQLite-reading input when no connection holds the store; the agent database planundecidablewithout the preflight's discovery. The one previous case (state-schema input only) is replaced by the first case, which covers it. Generic guards:doctor-maintenance.stopped-systemd.test.tsanddoctor-health-contributions.pending-read-only.test.tspass (75). Writer suites for every refactored owner pass.Checks.
pnpm tsgo:corepass.node scripts/check-changed.mjs: every lane passes except the dead-export scan, which reportsAgentHarnessSideQuestionRequestandisRemoteAgentDispatchInvocationin files this PR does not touch (inherited frommain). Session identity ratchet: no entries in touched files. CI onc0d6346772f: green.Review. autoreview, Codex route (gpt-6.1-sol),
--max-priority P2 --thinking high, with the owners and callers as committed source context (15 to 16 files) and the contract in the prompt. Pass 1: four P2. Fixed: agent stores the session scanners open were not guarded (now listed inside the state guard), the ledger was skipped without a config file, permission drift was missing from admission. Rejected: a policy-refused plugin is not recorded by the flow, so it is not ledger work. Pass 2: one P2, rejected with evidence (a nested artifact-preserving scope does not copy the state database under live reads;requiresArtifactPreservingSnapshotand the direct-read branch take the live read), and a held-store cron test added. Pass 3: scoped-clean.Whole
doctor --fixon the healthy install, head: 95 of 110 decisions tracenone check=owner. Notnone:client-credentials(no check),database-migrations(undecidable),config-flow(vialegacy-state-steps,update-history,config-repairs), contributionsauth-profile-migration,session-transcripts,state-integrity,codex-session-routes,legacy-cron,skills,memory-search,final-config-validation, andservice-definition.Not proven: macOS, Windows, pnpm, Bun and Git installs, PostgreSQL, large stores, a check beside a serving Gateway (the checks ran inside the stop, beside Doctor's own connections). No timing comparison is claimed.
Red: measured list in the config-flow span (base, healthy)
Green: config-flow span (head, same store)