Repository navigation
fix(doctor): decide config-flow's graph steps and update history without writing - #207274
fuller-stack-dev merged 13 commits into
Conversation
…-only Each graph step that ran on every Doctor pass now has a read-only predicate at its owner, and its writer reads that predicate before opening anything for writing: config machine state, transcript directives, orphan session keys, the shared auth store, delivery queues, workspace aliases, Skill Workshop proposals and ACP session metadata. Interrupted update reconciliation is decided from its own settle gate. The Skill Workshop retirement no longer opens the state database for writing on a healthy store, and the transcript directive pass reads agent database leases only for an unfinished cursor. The ACP metadata pass moves beside its importer.
…lias reads The transcript directive pass still inspects agent database leases before any admitted work, including archive recovery. The workspace alias input answers undecidable when the process environment names another state root.
|
🦞👀 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: blocked before merge. What this changesAdds read-only pending checks for Doctor migration steps and update history, and avoids unnecessary healthy-store writes and snapshot copies. Example: Run openclaw doctor --fix on a healthy Linux installation with three agents.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Partial Merge readiness⛔ Blocked before merge - 2 items remain Keep open: this maintainer-authored PR provides useful Doctor groundwork that current main still lacks, with one narrow source-contract failure to repair. Reviewed head: Before merge
Findings
Agent review detailsHow this fits togetherDoctor's config flow combines configuration, migration receipts, agent databases, and legacy artifacts into pending decisions, then runs the existing repair owners under maintenance custody. flowchart TD
A[Doctor CLI] --> B[Config flow pending checks]
B --> C[Existing owner predicates]
C --> D[Config and live stores]
B --> E[Maintenance decision]
E --> F[Existing repair writers]
Technical reviewBest possible solution: Retain the existing-owner predicates and healthy-store shortcuts, resolve the export collision, and complete repair-preservation and upgrade validation. Do we have a high-confidence way to reproduce the issue? Current-main source retains unconditional pending answers and the unnecessary writer operations; the supplied real Doctor traces independently demonstrate their healthy-install effects. Is this the best way to solve the issue? Sharing decisions with existing migration owners is appropriate, and the ACP move preserves one importer rather than introducing a competing repair path. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against b3ba96f88c9a. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceAcceptance criteria:
What I checked:
Likely related people:
PR surfaceSource +413, Tests +234, Other -1. Total +646 across 17 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. 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 Reviewed November 28, 2026, 1:03 AM ET / 06:03 UTC. |
|
Merged via squash auto-merge.
|
…07585) ## Problem Native release updates launch advisory Doctor inspections after activation. The 120-second subprocess gates nothing and can time out even though the update has already succeeded. ## Change - Delete the native Gateway's post-activation inspection task, its legacy-trial completion callback, and the unused selector export. - Remove tests for that deleted task and clarify the native-versus-legacy behavior in Doctor docs. - Keep the frozen legacy bridge's inspection helper, callers, step names, and coverage unchanged. - In a separate test-only commit, pin ownership-guidance POSIX fixtures to Linux so Windows hosts do not select Windows guidance. Native updates still succeed at core readiness; boot plugin maintenance and rollback behavior remain unchanged. Operators can run `openclaw doctor --lint` explicitly. No new mechanisms. ## Simplification and impact Removed the advisory subprocess, scheduling path, projection loop, and error-reporting branch rather than replacing them. Production: +2/-68, net -66 lines. Tests: +2/-125, net -123 lines. Docs: +5/-2. ## Validation - Local builds/tests were not run; hosted PR CI is the requested verification route. - Do not dispatch the update-restart-auth lane: the known unrelated Doctor state-db lock is tracked by #207274 / #207535 and its validation is owned separately. - No autoreview; no release-branch changes; do not merge. Co-authored-by: Ayaan Zaidi <[email protected]>
…out writing (openclaw#207274) * fix(doctor): decide config-flow's graph steps and update history read-only Each graph step that ran on every Doctor pass now has a read-only predicate at its owner, and its writer reads that predicate before opening anything for writing: config machine state, transcript directives, orphan session keys, the shared auth store, delivery queues, workspace aliases, Skill Workshop proposals and ACP session metadata. Interrupted update reconciliation is decided from its own settle gate. The Skill Workshop retirement no longer opens the state database for writing on a healthy store, and the transcript directive pass reads agent database leases only for an unfinished cursor. The ACP metadata pass moves beside its importer. * fix(doctor): gate transcript work on the lease inspection and guard alias reads The transcript directive pass still inspects agent database leases before any admitted work, including archive recovery. The workspace alias input answers undecidable when the process environment names another state root. * chore(doctor): keep the moved ACP pass inside the lint and assertion ratchets * chore(doctor): drop the session store's stale max-lines baseline entry * fix(doctor): give the legacy session key canonicalizer its own exported name * fix(doctor): keep the transcript lease inspection SQLite-only
…enclaw#207585) ## Problem Native release updates launch advisory Doctor inspections after activation. The 120-second subprocess gates nothing and can time out even though the update has already succeeded. ## Change - Delete the native Gateway's post-activation inspection task, its legacy-trial completion callback, and the unused selector export. - Remove tests for that deleted task and clarify the native-versus-legacy behavior in Doctor docs. - Keep the frozen legacy bridge's inspection helper, callers, step names, and coverage unchanged. - In a separate test-only commit, pin ownership-guidance POSIX fixtures to Linux so Windows hosts do not select Windows guidance. Native updates still succeed at core readiness; boot plugin maintenance and rollback behavior remain unchanged. Operators can run `openclaw doctor --lint` explicitly. No new mechanisms. ## Simplification and impact Removed the advisory subprocess, scheduling path, projection loop, and error-reporting branch rather than replacing them. Production: +2/-68, net -66 lines. Tests: +2/-125, net -123 lines. Docs: +5/-2. ## Validation - Local builds/tests were not run; hosted PR CI is the requested verification route. - Do not dispatch the update-restart-auth lane: the known unrelated Doctor state-db lock is tracked by openclaw#207274 / openclaw#207535 and its validation is owned separately. - No autoreview; no release-branch changes; do not merge. Co-authored-by: Ayaan Zaidi <[email protected]>
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 report truthfully whether it has work. The config flow'spendinganswer stayedworkon every healthy install because three of its owners had no read-only check: the migration graph steps that decide inside their writers, interrupted update reconciliation, and the config repairs. Two of those writers also did needless work on a healthy store: the Skill Workshop proposal retirement opened the state database for writing just to look for retired tables, and the transcript directive pass copied the state database into private scratch to inspect agent database leases it did not need.User Impact
No visible change: Doctor still stops the Gateway and runs every step. On a healthy install Doctor no longer opens the state database for writing to look for retired Skill Workshop tables and no longer copies the state database to inspect leases. The Doctor trace now reports each graph step and the update history separately;
config-flowstill answerswork, now only because ofconfig-repairs.Why This Change Was Made
Each graph step's writer now reads a read-only predicate at its owner first and writes only when it finds work; the
config-flowcheck calls the same predicate. Every SQLite read runs insidedecideDoctorPendingFromLiveStores, so an unheld store answersundecidable.legacy-state-steps.config-machine-statehasDaemonRuntimePinMigrationWork(completed pin receipt for this source, read without creatingcontrol/services.sqlite) andhasLegacyConfigMachineState(retired machine-owned config fields)legacy-state-steps.transcript-directiveshasHistoricalTranscriptDirectiveWorkover every discovered agent database; an unfinished cursor is worklegacy-state-steps.orphan-session-keyscheckOrphanedSessionKeysPending: the migration's own pass without its writelegacy-state-steps.shared-auth-storesharedAuthStore.hasLegacy, the only thing the writer acts on (also in the detection preview)legacy-state-steps.delivery-queueshasDoctorDeliveryQueueWork: retired queue files or pending legacy entrieslegacy-state-steps.workspace-aliasescollectRepointedWorkspaceAliasFindings, the function the writer already checks firstundecidablewhen the process environment names another state root, since the collector reads through itlegacy-state-steps.skill-workshophasSkillWorkshopProposalRetirementWork: retired tables (live catalog through a read-only connection), legacy proposal files, earlier exportslegacy-state-steps.acp-session-metadatacheckLegacyAcpSessionMetadataPending: the migration's own pass without its import or rewritestate-migrations.acp-session-metadata.ts, the session store module was at its line cap); the deferred plugin read runs only when a source existsupdate-historyreadInterruptedUpdateCandidate+canSettleInterruptedUpdate, the gatereconcileInterruptedUpdateRunsapplies; read through a read-only connection,undecidableon PostgreSQLWhat each check cannot decide, and answers
undecidable(counted as work): PostgreSQL state or agent databases (config machine state, transcript directives, Skill Workshop, update history); a store nobody holds; any warning the writer would emit (orphan keys, ACP metadata), since skipping the step would drop it. Over-approximations that answerwork: an unfinished transcript cursor while another process holds an agent database (the writer would wait); an archived ACP index whose rows were already imported.config-repairskeepswork: the config repair sequence runs about 30 stages, several with side effects outside the config file (plugin links, auth profile stores, Tailscale identities, OAuth shadows), and none has a read-only answer yet.Evidence
Tested commits: base
22a3aec1c89(red), head4f57954471c(green and guards). The PR headcf307475b72differs from the tested head by a rename of the moved session key canonicalizer (canonicalizeLegacySessionKeyForAgent, for the export-name collision check), by restoring the SQLite-only condition on the transcript lease inspection (review pass 3, below), and by merges ofmain. The merges touch none of these owners except a warning-text change instate-migrations.media-persistence-targets.ts(#207257); the merged Doctor tests (doctor-original-capture,doctor-capture-repeat,doctor-capture-reuse,doctor-state-integrity,agents.delete,media-persistence-targets) pass on the merged head. 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 recording write-intentfscalls andnode:sqliteopens, write statements andBEGIN IMMEDIATE/EXCLUSIVEwith their JS callers, limited to thedoctor.config-flowspan and to eachdoctor.pending.config-flow.*span.Red (base, healthy install).
config-flowanswersworkwithlegacy-state-steps,update-historyandconfig-repairsatwork check=default. Inside thedoctor.config-flowspan:The snapshot copy stages a private copy of the state database (staging directory, token store,
database.sqlite), about 0.26 s on this small store before cleanup.Green (head, same restored store).
The nine new inputs cost about 0.16 s together (strace run; 0.12 s in the plain run). Every
doctor.pending.config-flow.*span shows no writable open, no snapshot copy, no store write, noBEGINand no write-intentfscall. In thedoctor.config-flowspan the Skill Workshop writable open and the snapshot copy are gone:One writable open of the state database remains: on base the Skill Workshop open came first and later readers reused that handle; now the first opener is the config repair sequence's auth alias recovery (
config-repairs), which reads its migration receipt through the writable handle. That is the next owner to convert. The span durations above are single runs and not a timing comparison.Whole
doctor --fixon the healthy install, head: 104 decisions tracenone check=owner(95 on base). Notnone: stepsclient-credentials(no check),database-migrations(undecidableinside the stop),config-flow(config-repairs),service-definition(no check); contributionsauth-profile-migration,session-transcripts,state-integrity,codex-session-routes,legacy-cron,skills,memory-search,final-config-validation.Guards (base, then head on the same restored store, then head again without restoring; each seed applied while the Gateway was serving):
control/services.sqlitecompletelegacy-state-steps.config-machine-state=worknoneworkagent databaselegacy-state-steps.transcript-directives=worknonedelivery-queue/fixture.json.migratedretired-state=work,legacy-state-steps.delivery-queues=worknoneskill_workshop_collection_reviewslegacy-state-steps.skill-workshop=worknoneagents/work/sessions/sessions.jsonwith an orphanedmainkeylegacy-state-steps.orphan-session-keys=worknone;agent-databases=worksessions.jsonrow with legacy ACP metadataacp_sessions, archivedlegacy-state-steps.acp-session-metadata=worknone;agent-databases=workacp_sessionsrows; names differ only by timestampAll runs exited 0. After either session store import the next run's
agent-databasesinput (the agent database plan from #206707) answerswork. Base does the same: a base second run after each seed also answersagent-databases=workand rewrites theworkagent database and its seal (real work, not a stale answer), and the third run answersnonewith the agent database unchanged. So the import converges over two Doctor passes on base and head alike; it does not keep the step atwork. Not seeded through the CLI: the shared auth store, a repointed workspace alias and an interrupted update run (unit tests only).Tests.
src/commands/doctor-config-flow-pending.test.ts(whole file audited; 10 cases added, 2 extended, none removed): every input traced in order with the step atworkonly throughconfig-repairs; per sub-step, seeded work answerswork, the real writer runs, and the next check answersnone, with no store file changed by any check beside held stores (runtime pin receipt and a retired config field; an agent database with no transcript cursor; an orphanedmainkey; a missing shared auth ownership record; a retired delivery queue file; a retired Skill Workshop table and the legacy proposal directory; legacy ACP metadata; an interrupted update run that the reconciliation would settle); the workspace alias inputundecidablefor another state root andnonefor the process's own; andundecidablewithout sidecars for every new SQLite-reading input when no connection holds the store. Writer regression: Skill Workshop retirement beside a held healthy store leaves every file unchanged; on base it fails because the writable open removes the clean-close seal (expected [ 'state/openclaw.sqlite.seal' ] to deeply equal []). The new cases fail onmain, where the inputs do not exist (11 failed, run on22a3aec1c89). Owner suites: ACP metadata, legacy ACP migration, upgrade-survivor ACP, stale receipt, orphan keys,state-migrations.test.ts, Skill Workshop retirement, transcript directive batching and large corpus, runtime pins, config machine state, workspace alias, preflight migration input: pass. Generic guardsdoctor-health-contributions.pending-read-only.test.tsanddoctor-maintenance.stopped-systemd.test.ts: pass (75).Checks.
pnpm tsgo:corepass.node scripts/check-changed.mjs: every lane passes except the dead-export scan, which reportsAgentHarnessSideQuestionRequestandrequestChatSessionSnapshotin files this PR does not touch (inherited frommain). The session store's assertion and max-lines baselines shrink with the moved ACP pass. Session identity ratchet: OK.Review. autoreview, Codex route (gpt-6.1-sol, high),
--max-priority P2, with 14 owners and callers as committed source context plusstate-migrations.doctor.ts, and the read-only contract in the prompt; the report lists the files inspected. Pass 1: two P2, both fixed: the workspace alias collector reads through the process environment, so the input now answersundecidablefor another state root; and archive-recovery work could start without the lease inspection, which now runs before any admitted work. Pass 2: scoped-clean. Pass 3, after mergingmain(it touchedstate-migrations.media-persistence-targets.ts): one P2, fixed: the lease inspection before admitted work had lost its SQLite-only condition, so a failed inspection would have skipped PostgreSQL work. Pass 4 on79a57ec6103: scoped-clean. Later merges ofmain(tocf307475b72) touched no file this change depends on (Doctor changes were agent deletion warnings and session title repair; their tests pass on the merged head), so no further pass.CI. Earlier heads failed only on failures inherited from
main, each reproduced onmainwithout this change and since fixed there: the protocol event allowlist (#207288), thechanged-laneslint test, the Skill Workshop import cycle (#207345), the Board drop test mock type (#207348) and theno-map-spreadlint error in the dashboard widget drop test (#207341). Nothing was rerun for green. An earlier head failedcheck-source-contractson an export-name collision introduced here; fixed by the rename.Not proven. macOS, Windows, pnpm, Bun, Git installs, PostgreSQL, large stores, checks beside a serving Gateway, the shared auth store, workspace alias and interrupted update guards through the CLI (unit tests only), a timing comparison.
Raw: red and green config-flow traces and span io