Skip to content

fix(doctor): decide config-flow's graph steps and update history without writing - #207274

Merged
fuller-stack-dev merged 13 commits into
openclaw:mainfrom
fuller-stack-dev:fix/doctor-config-flow-owner-steps
Nov 28, 2026
Merged

fuller-stack-dev merged 13 commits into
openclaw:mainfrom
fuller-stack-dev:fix/doctor-config-flow-owner-steps

Conversation

@fuller-stack-dev

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

Copy link
Copy Markdown
Member

Related: #204775

What Problem This Solves

openclaw doctor --fix stops 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's pending answer stayed work on 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-flow still answers work, now only because of config-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-flow check calls the same predicate. Every SQLite read runs inside decideDoctorPendingFromLiveStores, so an unheld store answers undecidable.

Input Predicate (owner) Writer change
legacy-state-steps.config-machine-state hasDaemonRuntimePinMigrationWork (completed pin receipt for this source, read without creating control/services.sqlite) and hasLegacyConfigMachineState (retired machine-owned config fields) same functions; no behavior change
legacy-state-steps.transcript-directives hasHistoricalTranscriptDirectiveWork over every discovered agent database; an unfinished cursor is work the lease inspection (a state database snapshot copy) runs only once a database needs the pass, and still runs before any admitted work
legacy-state-steps.orphan-session-keys checkOrphanedSessionKeysPending: the migration's own pass without its write the deferred plugin migration read runs only when a legacy JSON store exists
legacy-state-steps.shared-auth-store the detection's sharedAuthStore.hasLegacy, the only thing the writer acts on (also in the detection preview) none
legacy-state-steps.delivery-queues hasDoctorDeliveryQueueWork: retired queue files or pending legacy entries same count, shared
legacy-state-steps.workspace-aliases collectRepointedWorkspaceAliasFindings, the function the writer already checks first none; undecidable when the process environment names another state root, since the collector reads through it
legacy-state-steps.skill-workshop hasSkillWorkshopProposalRetirementWork: retired tables (live catalog through a read-only connection), legacy proposal files, earlier exports reads first; a store with nothing to retire is never opened for writing or locked
legacy-state-steps.acp-session-metadata checkLegacyAcpSessionMetadataPending: the migration's own pass without its import or rewrite the pass moves beside its importer (state-migrations.acp-session-metadata.ts, the session store module was at its line cap); the deferred plugin read runs only when a source exists
update-history readInterruptedUpdateCandidate + canSettleInterruptedUpdate, the gate reconcileInterruptedUpdateRuns applies; read through a read-only connection, undecidable on PostgreSQL none; no update or settlement code is edited

What 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 answer work: 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-repairs keeps work: 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), head 4f57954471c (green and guards). The PR head cf307475b72 differs 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 of main. The merges touch none of these owners except a warning-text change in state-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 two doctor --fix runs, and restored byte-identical (sha256 over all files) before every run. Method: strace -f plus a preload recording write-intent fs calls and node:sqlite opens, write statements and BEGIN IMMEDIATE/EXCLUSIVE with their JS callers, limited to the doctor.config-flow span and to each doctor.pending.config-flow.* span.

Red (base, healthy install). config-flow answers work with legacy-state-steps, update-history and config-repairs at work check=default. Inside the doctor.config-flow span:

doctor.config-flow 6294.4ms: rw-opens=1 snapshot-copies=1 store-writes=6 begin=0 fs-writes=0
  sqlite-open ~/state/openclaw.sqlite?mode=rw <= openOpenClawStateDatabase < readDatabaseProposals < retireProposals
  sqlite-open ~/.cache/openclaw/.../owner.sqlite?mode=rw (snapshot staging) <= assertNoOpenClawAgentDatabaseLeasesReadOnly < hasActiveAgentDatabaseLease < migrateHistoricalTranscriptDirectives
  sqlite-write ~/state/openclaw.sqlite?mode=rw PRAGMA journal_mode = WAL / wal_autocheckpoint / journal_size_limit / synchronous / foreign_keys (connection setup of that writable open)

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

doctor.pending.config-flow.legacy-state-steps.config-machine-state 4.4ms pending=none check=owner
doctor.pending.config-flow.legacy-state-steps.transcript-directives 26.1ms pending=none check=owner
doctor.pending.config-flow.legacy-state-steps.orphan-session-keys 2.5ms pending=none check=owner
doctor.pending.config-flow.legacy-state-steps.shared-auth-store 0.1ms pending=none check=owner
doctor.pending.config-flow.legacy-state-steps.delivery-queues 19.7ms pending=none check=owner
doctor.pending.config-flow.legacy-state-steps.workspace-aliases 51.7ms pending=none check=owner
doctor.pending.config-flow.legacy-state-steps.skill-workshop 6.5ms pending=none check=owner
doctor.pending.config-flow.legacy-state-steps.acp-session-metadata 48.9ms pending=none check=owner
doctor.pending.config-flow.update-history 3.2ms pending=none check=owner
doctor.pending.config-flow.config-repairs 0.0ms pending=work check=default
doctor.pending.config-flow 0.0ms pending=work check=owner

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, no BEGIN and no write-intent fs call. In the doctor.config-flow span the Skill Workshop writable open and the snapshot copy are gone:

doctor.config-flow 4597.8ms: rw-opens=1 snapshot-copies=0 store-writes=6 begin=0 fs-writes=0
  sqlite-open ~/state/openclaw.sqlite?mode=rw <= openOpenClawStateDatabase < readLegacyMigrationReceipt < recoverAuthAliasMigration < maybeRepairLegacyAuthProfileStores < runDoctorRepairSequence

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 --fix on the healthy install, head: 104 decisions trace none check=owner (95 on base). Not none: steps client-credentials (no check), database-migrations (undecidable inside the stop), config-flow (config-repairs), service-definition (no check); contributions auth-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):

Seed Base Head, first run Head, next run Result content (base vs head)
runtime pin receipt row deleted from control/services.sqlite receipt rewritten complete legacy-state-steps.config-machine-state=work all new inputs none identical receipt
transcript directive cursor deleted in the work agent database cursor rewritten legacy-state-steps.transcript-directives=work none identical cursors
retired delivery queue file delivery-queue/fixture.json archived as .migrated retired-state=work, legacy-state-steps.delivery-queues=work none identical
retired table skill_workshop_collection_reviews table dropped legacy-state-steps.skill-workshop=work none identical table list
agents/work/sessions/sessions.json with an orphaned main key imported and archived legacy-state-steps.orphan-session-keys=work new inputs none; agent-databases=work identical; archive and run-record names differ only by timestamp
sessions.json row with legacy ACP metadata imported to acp_sessions, archived legacy-state-steps.acp-session-metadata=work new inputs none; agent-databases=work identical acp_sessions rows; names differ only by timestamp

All runs exited 0. After either session store import the next run's agent-databases input (the agent database plan from #206707) answers work. Base does the same: a base second run after each seed also answers agent-databases=work and rewrites the work agent database and its seal (real work, not a stale answer), and the third run answers none with the agent database unchanged. So the import converges over two Doctor passes on base and head alike; it does not keep the step at work. 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 at work only through config-repairs; per sub-step, seeded work answers work, the real writer runs, and the next check answers none, 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 orphaned main key; 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 input undecidable for another state root and none for the process's own; and undecidable without 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 on main, where the inputs do not exist (11 failed, run on 22a3aec1c89). 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 guards doctor-health-contributions.pending-read-only.test.ts and doctor-maintenance.stopped-systemd.test.ts: pass (75).

Checks. pnpm tsgo:core pass. node scripts/check-changed.mjs: every lane passes except the dead-export scan, which reports AgentHarnessSideQuestionRequest and requestChatSessionSnapshot in files this PR does not touch (inherited from main). 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 plus state-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 answers undecidable for 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 merging main (it touched state-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 on 79a57ec6103: scoped-clean. Later merges of main (to cf307475b72) 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 on main without this change and since fixed there: the protocol event allowlist (#207288), the changed-lanes lint test, the Skill Workshop import cycle (#207345), the Board drop test mock type (#207348) and the no-map-spread lint error in the dashboard widget drop test (#207341). Nothing was rerun for green. An earlier head failed check-source-contracts on 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
== red (22a3aec1c89) doctor.pending.config-flow*
doctor.pending.config-flow.state-write-admission 0.7ms pending=none check=owner
doctor.pending.config-flow.legacy-state-dir 0.2ms pending=none check=owner
doctor.pending.config-flow.legacy-config 175.5ms pending=none check=owner
doctor.pending.config-flow.state-schema 114.1ms pending=none check=owner
doctor.pending.config-flow.retired-state 3.6ms pending=none check=owner
doctor.pending.config-flow.session-entry-state 52.8ms pending=none check=owner
doctor.pending.config-flow.plugin-convergence 3.3ms pending=none check=owner
doctor.pending.config-flow.plugin-obligations 236.8ms pending=none check=owner
doctor.pending.config-flow.cron 1034.5ms pending=none check=owner
doctor.pending.config-flow.legacy-state-detection 1068.7ms pending=none check=owner
doctor.pending.config-flow.agent-databases 945.0ms pending=none check=owner
doctor.pending.config-flow.legacy-state-steps 0.1ms pending=work check=default
doctor.pending.config-flow.a2ui-widgets 48.9ms pending=none check=owner
doctor.pending.config-flow.relative-session-stores 2.7ms pending=none check=owner
doctor.pending.config-flow.update-history 0.0ms pending=work check=default
doctor.pending.config-flow.config-repairs 0.0ms pending=work check=default
doctor.pending.config-flow 0.1ms pending=work check=owner

== green (4f57954471c) doctor.pending.config-flow*
doctor.pending.config-flow.state-write-admission 0.7ms pending=none check=owner
doctor.pending.config-flow.legacy-state-dir 0.1ms pending=none check=owner
doctor.pending.config-flow.legacy-config 153.7ms pending=none check=owner
doctor.pending.config-flow.state-schema 104.3ms pending=none check=owner
doctor.pending.config-flow.retired-state 3.7ms pending=none check=owner
doctor.pending.config-flow.session-entry-state 48.3ms pending=none check=owner
doctor.pending.config-flow.plugin-convergence 2.5ms pending=none check=owner
doctor.pending.config-flow.plugin-obligations 198.6ms pending=none check=owner
doctor.pending.config-flow.cron 930.9ms pending=none check=owner
doctor.pending.config-flow.legacy-state-detection 889.7ms pending=none check=owner
doctor.pending.config-flow.agent-databases 793.5ms pending=none check=owner
doctor.pending.config-flow.legacy-state-steps.config-machine-state 4.4ms pending=none check=owner
doctor.pending.config-flow.legacy-state-steps.transcript-directives 26.1ms pending=none check=owner
doctor.pending.config-flow.legacy-state-steps.orphan-session-keys 2.5ms pending=none check=owner
doctor.pending.config-flow.legacy-state-steps.shared-auth-store 0.1ms pending=none check=owner
doctor.pending.config-flow.legacy-state-steps.delivery-queues 19.7ms pending=none check=owner
doctor.pending.config-flow.legacy-state-steps.workspace-aliases 51.7ms pending=none check=owner
doctor.pending.config-flow.legacy-state-steps.skill-workshop 6.5ms pending=none check=owner
doctor.pending.config-flow.legacy-state-steps.acp-session-metadata 48.9ms pending=none check=owner
doctor.pending.config-flow.a2ui-widgets 38.3ms pending=none check=owner
doctor.pending.config-flow.relative-session-stores 2.4ms pending=none check=owner
doctor.pending.config-flow.update-history 3.2ms pending=none check=owner
doctor.pending.config-flow.config-repairs 0.0ms pending=work check=default
doctor.pending.config-flow 0.0ms pending=work check=owner

== red span io
doctor.config-flow 6294.4ms: rw-opens=1 snapshot-copies=1 store-writes=6 begin=0 fs-writes=0
    sqlite-open  ~/state/openclaw.sqlite?mode=rw  <= acquire < runStateOpenSteps < openOpenClawStateDatabaseWithBusyTimeout < openOpenClawStateDatabase < readDatabaseProposals < retireProposals
    sqlite-open  ~/.cache/openclaw/sqlite-<id>/openclaw-sqlite-readonly-v2-r0nFai/owner.sqlite?mode=rw  <= assertNoOpenClawAgentDatabaseLeasesReadOnly < hasActiveAgentDatabaseLease < migrateHistoricalTranscriptDirectives < runLegacyStateMigrationSteps < autoMigrateLegacyState < measureGatewayBootstrapStep
    sqlite-write  ~/state/openclaw.sqlite?mode=rw PRAGMA journal_mode = WAL; <= runWithSqliteBusyTimeout < openEngineStore < runUpdateSqliteMigration < runStateOpenSteps < openUnpublishedStateDatabase < open
    sqlite-write  ~/state/openclaw.sqlite?mode=rw PRAGMA wal_autocheckpoint = 16384; <= runStateOpenSteps < openUnpublishedStateDatabase < open < withStateDatabaseColdAdmission < acquire < runStateOpenSteps
    sqlite-write  ~/state/openclaw.sqlite?mode=rw PRAGMA journal_size_limit = 67108864; <= runStateOpenSteps < openUnpublishedStateDatabase < open < withStateDatabaseColdAdmission < acquire < runStateOpenSteps
    sqlite-write  ~/state/openclaw.sqlite?mode=rw PRAGMA synchronous = NORMAL; <= openUnpublishedStateDatabase < open < withStateDatabaseColdAdmission < acquire < runStateOpenSteps < openOpenClawStateDatabaseWithBusyTimeout

== green span io
doctor.config-flow 4597.8ms: rw-opens=1 snapshot-copies=0 store-writes=6 begin=0 fs-writes=0
    sqlite-open  ~/state/openclaw.sqlite?mode=rw  <= openOpenClawStateDatabase < readLegacyMigrationReceipt < recoverAuthAliasMigration < maybeRepairLegacyAuthProfileStores < runDoctorRepairSequence < withDoctorProgress
    sqlite-write  ~/state/openclaw.sqlite?mode=rw PRAGMA journal_mode = WAL; <= runWithSqliteBusyTimeout < openEngineStore < runUpdateSqliteMigration < runStateOpenSteps < openUnpublishedStateDatabase < open
    sqlite-write  ~/state/openclaw.sqlite?mode=rw PRAGMA wal_autocheckpoint = 16384; <= runStateOpenSteps < openUnpublishedStateDatabase < open < withStateDatabaseColdAdmission < acquire < runStateOpenSteps
    sqlite-write  ~/state/openclaw.sqlite?mode=rw PRAGMA journal_size_limit = 67108864; <= runStateOpenSteps < openUnpublishedStateDatabase < open < withStateDatabaseColdAdmission < acquire < runStateOpenSteps
    sqlite-write  ~/state/openclaw.sqlite?mode=rw PRAGMA synchronous = NORMAL; <= openUnpublishedStateDatabase < open < withStateDatabaseColdAdmission < acquire < runStateOpenSteps < openOpenClawStateDatabaseWithBusyTimeout
    sqlite-write  ~/state/openclaw.sqlite?mode=rw PRAGMA foreign_keys = ON; <= openUnpublishedStateDatabase < open < withStateDatabaseColdAdmission < acquire < runStateOpenSteps < openOpenClawStateDatabaseWithBusyTimeout
doctor.pending.config-flow.state-write-admission 0.7ms: rw-opens=0 snapshot-copies=0 store-writes=0 begin=0 fs-writes=0
doctor.pending.config-flow.legacy-state-dir 0.1ms: rw-opens=0 snapshot-copies=0 store-writes=0 begin=0 fs-writes=0
doctor.pending.config-flow.legacy-config 153.7ms: rw-opens=0 snapshot-copies=0 store-writes=0 begin=0 fs-writes=0
doctor.pending.config-flow.state-schema 104.3ms: rw-opens=0 snapshot-copies=0 store-writes=0 begin=0 fs-writes=0
doctor.pending.config-flow.retired-state 3.7ms: rw-opens=0 snapshot-copies=0 store-writes=0 begin=0 fs-writes=0
doctor.pending.config-flow.session-entry-state 48.3ms: rw-opens=0 snapshot-copies=0 store-writes=0 begin=0 fs-writes=0
doctor.pending.config-flow.plugin-convergence 2.5ms: rw-opens=0 snapshot-copies=0 store-writes=0 begin=0 fs-writes=0
doctor.pending.config-flow.plugin-obligations 198.6ms: rw-opens=0 snapshot-copies=0 store-writes=0 begin=0 fs-writes=0
doctor.pending.config-flow.cron 930.9ms: rw-opens=0 snapshot-copies=0 store-writes=0 begin=0 fs-writes=0
doctor.pending.config-flow.legacy-state-detection 889.7ms: rw-opens=0 snapshot-copies=0 store-writes=0 begin=0 fs-writes=0
doctor.pending.config-flow.agent-databases 793.5ms: rw-opens=0 snapshot-copies=0 store-writes=0 begin=0 fs-writes=0
doctor.pending.config-flow.legacy-state-steps.config-machine-state 4.4ms: rw-opens=0 snapshot-copies=0 store-writes=0 begin=0 fs-writes=0
doctor.pending.config-flow.legacy-state-steps.transcript-directives 26.1ms: rw-opens=0 snapshot-copies=0 store-writes=0 begin=0 fs-writes=0
doctor.pending.config-flow.legacy-state-steps.orphan-session-keys 2.5ms: rw-opens=0 snapshot-copies=0 store-writes=0 begin=0 fs-writes=0
doctor.pending.config-flow.legacy-state-steps.shared-auth-store 0.1ms: rw-opens=0 snapshot-copies=0 store-writes=0 begin=0 fs-writes=0
doctor.pending.config-flow.legacy-state-steps.delivery-queues 19.7ms: rw-opens=0 snapshot-copies=0 store-writes=0 begin=0 fs-writes=0
doctor.pending.config-flow.legacy-state-steps.workspace-aliases 51.7ms: rw-opens=0 snapshot-copies=0 store-writes=0 begin=0 fs-writes=0
doctor.pending.config-flow.legacy-state-steps.skill-workshop 6.5ms: rw-opens=0 snapshot-copies=0 store-writes=0 begin=0 fs-writes=0
doctor.pending.config-flow.legacy-state-steps.acp-session-metadata 48.9ms: rw-opens=0 snapshot-copies=0 store-writes=0 begin=0 fs-writes=0
doctor.pending.config-flow.a2ui-widgets 38.3ms: rw-opens=0 snapshot-copies=0 store-writes=0 begin=0 fs-writes=0
doctor.pending.config-flow.relative-session-stores 2.4ms: rw-opens=0 snapshot-copies=0 store-writes=0 begin=0 fs-writes=0
doctor.pending.config-flow.update-history 3.2ms: rw-opens=0 snapshot-copies=0 store-writes=0 begin=0 fs-writes=0
doctor.pending.config-flow.config-repairs 0.0ms: rw-opens=0 snapshot-copies=0 store-writes=0 begin=0 fs-writes=0
doctor.pending.config-flow 0.0ms: rw-opens=0 snapshot-copies=0 store-writes=0 begin=0 fs-writes=0

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

clawsweeper Bot commented Nov 28, 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 cli CLI command changes commands Command implementations size: XL labels Nov 28, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. impact:ux-friction User-facing flow adds avoidable confusion or support burden without fully blocking progress. labels Nov 28, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Nov 28, 2026
@clawsweeper

clawsweeper Bot commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

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

  • Before: Transcript inspection copies the state database, and Skill Workshop retirement opens it for writing.
  • After: Those operations are skipped when their owners have no work; Doctor still stops the Gateway.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) Useful owner-based implementation with genuine CLI evidence, but an introduced source-contract failure and incomplete repair/upgrade proof prevent a pass.
Proof confidence 🦪 silver shellfish (2/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🦪 silver shellfish (2/6) 1 actionable review finding remain.

Product

Kind: Performance · Worth it: Yes · Fix scope: Partial
User problem: Healthy Doctor runs perform avoidable database work, while coarse pending answers prevent later maintenance planning from distinguishing clean owners.
Reason: The maintainer-authored direction follows the recorded owner plan, removes measured waste, and accurately retains config-repairs as unfinished work.

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

Before merge

  • [P2] Give the legacy canonicalizer a distinct exported name (P2) - Adding export here creates a second exported canonicalizeSessionKeyForAgent alongside src/gateway/session-store-key.ts:70. scripts/check-export-name-collisions.mts collects both definitions and rejects this name, so the source-contract gate fails on this patch; its check annotation identifies the same guard. Rename the legacy migration helper and its local/ACP callers while preserving both implementations' existing semantics.
  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.

Findings

  • [P2] [P2] Give the legacy canonicalizer a distinct exported name — src/infra/state-migrations.session-store.ts:58
Agent review details

How this fits together

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

Technical review

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

  • [P2] [P2] Give the legacy canonicalizer a distinct exported name — src/infra/state-migrations.session-store.ts:58
    Adding export here creates a second exported canonicalizeSessionKeyForAgent alongside src/gateway/session-store-key.ts:70. scripts/check-export-name-collisions.mts collects both definitions and rejects this name, so the source-contract gate fails on this patch; its check annotation identifies the same guard. Rename the legacy migration helper and its local/ACP callers while preserving both implementations' existing semantics.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.95

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against b3ba96f88c9a.

Provenance checked

  • Config-flow pending decisions keeps the original intent (218d29f: Expose each owner's pending work before making Gateway stops conditional; owners lacking predicates conservatively remained work.)
  • Transcript lease inspection keeps the original intent (d43865a: Defer optional cursor bookkeeping while another agent holds maintenance custody, while preserving exclusion for real repairs.)
  • Retained ACP metadata keeps the original intent (fix(acp): Doctor drops retained ACP metadata after archiving legacy session stores #169759: Import retained ACP metadata after core source archival without replaying metadata into replaced or closed canonical sessions.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

Acceptance criteria:

  • pnpm lint:tmp:export-name-collisions
  • pnpm test src/commands/doctor-config-flow-pending.test.ts src/infra/state-migrations.acp-session-metadata.test.ts src/acp/runtime/session-meta.legacy-migration.test.ts
  • pnpm check:changed -- src/infra/state-migrations.session-store.ts src/infra/state-migrations.acp-session-metadata.ts

What I checked:

  • Introduced change: The pinned introduction diff adds owner predicates, moves the ACP migration beside its importer, updates its consumers, and changes the two healthy-store writer paths. (src/commands/doctor-config-flow-pending.ts:320, 7c24d879e022)
  • Concrete source-contract failure: The newly exported canonicalizeSessionKeyForAgent duplicates the existing export in src/gateway/session-store-key.ts:70; the collision guard rejects duplicate exported definitions and has no exception for this name. (src/infra/state-migrations.session-store.ts:58, 7c24d879e022)
  • CI attribution: The reviewed head's check-source-contracts annotation identifies lint:tmp:export-name-collisions as failing, consistent with the introduced export collision. The full log redirected to a blocked artifact host, so its detailed output was unavailable. (7c24d879e022)
  • Real Doctor evidence and limits: The complete PR body supplies Linux Docker/systemd Doctor traces comparing base 22a3aec with tested head 4f57954: new pending spans have no writes or copies, and the transcript snapshot disappears. The changed owners are identical at the reviewed head. Repair guard results remain unfinished, and no latest-stable upgrade run is supplied. (7c24d879e022)
  • Current main and prior direction: Current main still leaves legacy-state-steps and update-history without predicates. The earlier owner work in fix(doctor): report which config-flow owners have work #207146 explicitly identified these remaining inputs; Design: prepared-release updates (state, ownership and plan) #204775 tracks the broader conditional-maintenance program. (src/commands/doctor-config-flow-pending.ts:297, b3ba96f88c9a)
  • Policy and history: Applied the complete root and applicable update-CLI/test AGENTS files, plus simplification, testing, database, and performance guidance. No maintainer-notes directory exists. History establishes prior config-flow and transcript owners; some deeper introduction searches stopped at unavailable historical objects. (AGENTS.md:1, 7c24d879e022)

Likely related people:

  • Jason (Json): Raw commit 218d29f adds src/commands/doctor-config-flow-pending.ts:9 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 218d29f3bd1d; files: src/commands/doctor-config-flow-pending.ts)
  • Peter Steinberger: Raw commit ed339f9 adds src/infra/state-migrations.transcript-directives.ts:217 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: ed339f9ba382; files: src/infra/state-migrations.transcript-directives.ts)

PR surface

Source +413, Tests +234, Other -1. Total +646 across 17 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 9 756 343 +413
Tests 6 245 11 +234
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 2 1 2 -1
Total 17 1002 356 +646

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.

Labels

Label changes:

  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦪 silver shellfish.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

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 28, 2026, 1:03 AM ET / 06:03 UTC.

@fuller-stack-dev
fuller-stack-dev enabled auto-merge (squash) November 28, 2026 08:28
@fuller-stack-dev
fuller-stack-dev merged commit 0d24c65 into openclaw:main Nov 28, 2026
143 of 145 checks passed
@fuller-stack-dev
fuller-stack-dev deleted the fix/doctor-config-flow-owner-steps branch November 28, 2026 08:48
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Merged via squash auto-merge.

obviyus added a commit that referenced this pull request Nov 28, 2026
…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]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 29, 2026
…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
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 29, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes commands Command implementations impact:ux-friction User-facing flow adds avoidable confusion or support burden without fully blocking progress. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: XL status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant