Skip to content

fix: stop Doctor from rewriting healthy agent databases while the Gateway is stopped - #206707

Merged
fuller-stack-dev merged 17 commits into
openclaw:mainfrom
fuller-stack-dev:fix/doctor-agent-db-plan
Nov 27, 2026
Merged

fuller-stack-dev merged 17 commits into
openclaw:mainfrom
fuller-stack-dev:fix/doctor-agent-db-plan

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

openclaw doctor --fix stops the Gateway and then migrates and maintains every agent database, even when there is nothing to do. On a healthy install it opens each agent database read-write twice, takes seven maintenance leases, deletes each database's clean-close seal, runs three write transactions per database and rewrites the agent_databases registry rows. All of that happens while the Gateway is stopped. Deleting the seal also means the restarted Gateway can no longer reuse the last integrity proof.

User Impact

On a healthy install, Doctor now reads each agent database once, read-only, and finds nothing to do. It does not open the database for writing, takes no maintenance lease, leaves the seal in place and begins no write transaction. When any check finds work, or cannot decide, that database goes through the same migration as before. The integrity check still runs on every Doctor run, but read-only. No configuration, schema, stored field or retention changes.

Why This Change Was Made

A read-only plan at the agent database migration owner (src/infra/state-migrations.agent-database-plan.ts) checks every condition the media pass and the cold-navigation pass act on. It answers work, none or undecidable for each database. The condition list came from going through the code write by write (table below). Each check reuses or extracts the writing code's own predicate, so the two cannot drift apart:

  • index drift: findCanonicalSqliteIndexDrift, now shared by repairCanonicalSqliteIndexes
  • archive verification: verifyOnly now returns pending
  • metadata: hasCurrentAgentSchemaMetadata, next to persistAgentSchemaMetadata
  • permissions: agentDatabasePermissionsNeedRepair
  • key contract: hasPendingSessionKeyContractSchema
  • entry validity and additive schema: hasPendingSessionEntryValidity, hasPendingSessionAdditiveSchema
  • misplaced copies: misplacedOwnerId
  • legacy archive files: transcriptArchiveNeedsMigration

migrateLegacyMediaPersistence skips a database only when all of its media-pass conditions are none. It skips the whole pass, discovery lease included, only when the discovery conditions are also none. A skipped database is still handed to the later steps as admitted and repair-ready, exactly as the full no-op pass reported it. migrateSessionColdNavigation drops admitted targets whose read-only query finds no cold archive to backfill, and takes no lease when none remain. The legacy archive-file pass moved to its owner, media-persistence-archive-source.ts, to keep the media pass under its line cap.

The integrity transaction. #158366 and #175402 make a fresh check of the current bytes part of every Doctor run, so the check stays. It never needed a write transaction, a lease or seal invalidation. The check itself already runs in a read-only child process (runSqliteIntegrityOperationInWorker). The BEGIN IMMEDIATE around it covers only the index repair that a failed check would trigger. The plan runs the same check, with the same full or quick coverage as the writing pass, on a read-only connection. A failure sends the database through the unchanged repair path. Expensive reads (archive verification, archive files, integrity) run only after every cheap condition is none, so a database that has work is not checked twice.

last_seen_at. Its consumers are the path-repair ordering among aliases of one database, the migration witness (which only checks that it is non-negative) and QA startup state, which strips it. None of them needs Doctor to refresh it: the Gateway re-registers every database when it boots, and Doctor restarts the Gateway. So a registry row with the right path and schema version is none, and only a missing or different row is work. size_bytes follows the same reasoning.

Planner statistics. SQLite cannot answer "would optimize analyze?" on a read-only connection. In debug mode, PRAGMA optimize still asks for a write transaction once two tables need its size check (seen on the agent schema). sqlitePlannerStatisticsNeedRefresh applies SQLite's per-table rule to the committed catalog:

  • unanalyzed indexes;
  • the 10x band around the last loaded estimate;
  • the -1 lower bound for small recorded counts;
  • empty tables;
  • the leftmost-path row estimate with the 3.51 interior-fanout change, read through dbstat.

A test checks it against SQLite's own debug output, on a writable copy, at every step of a growth, delete and reanalysis lifecycle. Before SQLite 3.46 the writing pass runs plain ANALYZE, so this condition is always work there.

Live-store guard. Inside the stop, the plan opens databases with the owner's read-only reader, as the agent-memory schema repair already does. That is the point where the writing pass would otherwise open them read-write. Incognito, deleted or ownerless stores, and stores the reader reports as database-missing, are undecidable. To feed the config-flow step's pending check later, wrap planAgentDatabaseMigration(...).pending in decideDoctorPendingFromLiveStores, using the state database path plus the discovered target paths. This PR does not wire it: the step's overall answer belongs to the state-schema work, and an export with no production consumer fails the dead-export gate.

Condition What the writing pass does (source) Read-only check Guard fixture (test)
discovery registry removals, pending-deletion preparation, held stores, warnings (media-persistence-targets.ts discoverAgentDatabaseMigrationTargets) same discovery, read-only existing targets tests
misplaced-copies recoverMisplacedAgentDatabaseCopies moves a copy aside hasMisplacedAgentDatabaseCopies existing owner-recovery tests
schema-version migrateAgentDatabase version migration; versionMigrations user_version and metadata version older-schema fixture
schema-owner assertOpenClawAgentDatabaseOwner failure becomes a warning same assertion (throws, so work)
schema-additive ensureAgentSchema same-version branch (openclaw-agent-db-schema.ts 400–409) pending current-version migration, key-contract row, startup columns and trigger dropped session_reactions
entry-validity ensureSessionEntryValidityProjection entry_valid = 0 exists rows reset to 0
schema-metadata persistAgentSchemaMetadata (418) same WHERE as its upsert stale app_version
canonical-indexes repairCanonicalSqliteIndexes (411, and inside the integrity steps) findCanonicalSqliteIndexDrift dropped index
runtime-schema assertOpenClawAgentCurrentRuntimeSchema same assertion (throws, so work)
integrity agentDatabaseIntegrityBeforeMutationSteps (593) plus index-corruption repair same check in the read-only child corrupted index key
quarantine quarantine clear (media-persistence.ts 265–283) terminal latch and persisted record (read, so work)
permissions ensureOpenClawAgentDatabasePermissions (578, 628) agentDatabasePermissionsNeedRepair mode 0644
registry registerOpenClawAgentDatabase (631) row with this path and schema version deleted row
media-rows media row rewrite and receipt (336–419) hasMediaRowsMigrationReceipt deleted receipt
entry-state-preparation deferred entry-state preparation (301) the pass's own prepared fact (consumer input)
transcript-archives migrateCanonicalTranscriptArchives (442): blob, file, journal and receipt writes verifyOnly pending drifted receipt; legacy row, differing, missing and canonical copies (canonical-archives test)
archive-files migrateLegacyTranscriptArchiveFiles transcriptArchiveNeedsMigration legacy archive file
planner-statistics refreshSqlitePlannerStatistics (453) sqlitePlannerStatisticsNeedRefresh deleted stat1; oracle lifecycle (planner test)
cold-navigation migrateSessionColdNavigation backfill hasPendingSessionColdNavigation cold archive without events (cold-navigation test)

Update behavior

Doctor-only. No updater, launcher or migration-driver change. A shipped updater reaches this through the candidate's own openclaw doctor --fix. Under OPENCLAW_UPDATE_IN_PROGRESS, under an updater migration capture or during an artifact-preserving read, the plan reads nothing and answers undecidable, so the migration runs exactly as before. storeReadsNeedCopies, now shared with decideDoctorPendingFromLiveStores, makes that check. The cold-navigation filter also does nothing there.

Evidence

Cell measurements: head 651057f7521 against base 788ca3c2f2b. Since 651057f7521, the production changes are:

  • four // SAFETY: comments;
  • one equivalent trigger lookup through the schema-facts owner;
  • two review fixes: no planning through copied store reads, and the planner check counting the creation of sqlite_stat1.

The healthy-install path in the cell runs neither case, so the measured results still apply. The other later commits are tests, the test-lines allocation and merges of main.

Cell: Linux Docker, systemd user Gateway, npm install, a 4 GiB main agent database and three small agents, 1 MiB/s of writes while serving. One seeded store had already been through two doctor --fix runs and was restored byte-identical before every run.

Red, base (two runs): for each of the four databases inside cli.bootstrap.legacy-state-migrations:

  • media pass: one read-write open, three BEGIN IMMEDIATE, one live .seal deleted (two more unlink attempts on the already-deleted seal), one statement write;
  • cold-navigation: one more read-write open;
  • state_leases inserts: 7 in all;
  • agent_databases writes: 4.

The migration step took 5.4 s and 6.1 s, of which the agent media pass was 4.2 s.

Green, head (two runs): read-only opens only. 0 read-write opens, 0 BEGIN IMMEDIATE, 0 seal changes, 0 lease inserts, 0 registry writes. doctor.agent-database-plan pending=none databases=4 unchanged=4. The migration step took 2.9 s and 2.7 s, of which the plan was 2.1 s and 1.9 s. That time is mostly the read-only full integrity check.

Red recording (base 788ca3c2f2b):

doctor-agent-db-plan-red.mp4

Green recording (head 651057f7521):

doctor-agent-db-plan-green.mp4
Raw red log (base 788ca3c)
=== red: Linux cell, systemd user Gateway, npm install, 4 GiB main agent database + 3 small agents, 1 MiB/s writes while serving; build 788ca3c2f2b
=== openclaw doctor --fix --non-interactive --yes; io trace of agent database writes inside cli.bootstrap.legacy-state-migrations
==== redB1 (run redB1 build B OpenClaw 2026.11.15 (788ca3c))
startup trace: cli.bootstrap.legacy-state-migrations 5418.2ms 
startup trace: doctor.config-flow 6788.8ms 
The Gateway was stopped for 47.2 s.
main cold {'open-rw': 1}
main media {'begin-immediate': 3, 'open-ro': 1, 'open-rw': 1, 'seal-unlink': 1, 'seal-unlink-absent': 2, 'write-stmts': 1}
main other {'open-ro': 4}
ops cold {'open-rw': 1}
ops media {'begin-immediate': 3, 'open-ro': 1, 'open-rw': 1, 'seal-unlink': 1, 'seal-unlink-absent': 2, 'write-stmts': 1}
ops other {'open-ro': 4}
research cold {'open-rw': 1}
research media {'begin-immediate': 3, 'open-ro': 1, 'open-rw': 1, 'seal-unlink': 1, 'seal-unlink-absent': 2, 'write-stmts': 1}
research other {'open-ro': 4}
work cold {'open-rw': 1}
work media {'begin-immediate': 3, 'open-ro': 1, 'open-rw': 1, 'seal-unlink': 1, 'seal-unlink-absent': 2, 'write-stmts': 1}
work other {'open-ro': 4}
agent maintenance leases taken: {}
span media 4.19 s
span cold 0.33 s
==== redB2 (run redB2 build B OpenClaw 2026.11.15 (788ca3c))
startup trace: cli.bootstrap.legacy-state-migrations 6100.4ms 
startup trace: doctor.config-flow 7707.4ms 
The Gateway was stopped for 51.9 s.
main cold {'open-rw': 1}
main media {'begin-immediate': 3, 'open-ro': 1, 'open-rw': 1, 'seal-unlink': 1, 'seal-unlink-absent': 2, 'write-stmts': 1}
main other {'open-ro': 4}
ops cold {'open-rw': 1}
ops media {'begin-immediate': 3, 'open-ro': 1, 'open-rw': 1, 'seal-unlink': 1, 'seal-unlink-absent': 2, 'write-stmts': 1}
ops other {'open-ro': 4}
research cold {'open-rw': 1}
research media {'begin-immediate': 3, 'open-ro': 1, 'open-rw': 1, 'seal-unlink': 1, 'seal-unlink-absent': 2, 'write-stmts': 1}
research other {'open-ro': 4}
work cold {'open-rw': 1}
work media {'begin-immediate': 3, 'open-ro': 1, 'open-rw': 1, 'seal-unlink': 1, 'seal-unlink-absent': 2, 'write-stmts': 1}
work other {'open-ro': 4}
agent maintenance leases taken: {}
span media 4.71 s
span cold 0.37 s
Raw green log (head 651057f)
=== green: Linux cell, systemd user Gateway, npm install, 4 GiB main agent database + 3 small agents, 1 MiB/s writes while serving; build 651057f7521
=== openclaw doctor --fix --non-interactive --yes; io trace of agent database writes inside cli.bootstrap.legacy-state-migrations
==== greenH1 (run greenH1 build H4 OpenClaw 2026.11.19 (651057f))
startup trace: doctor.agent-database-plan 2058.1ms 
startup trace: cli.bootstrap.legacy-state-migrations 2877.4ms 
startup trace: doctor.config-flow 4234.5ms 
doctor.agent-database-plan 2058.1ms pending=none databases=4 unchanged=4
The Gateway was stopped for 41.0 s.
main cold {'open-ro': 1}
main media {'open-ro': 2}
main other {'open-ro': 3}
ops cold {'open-ro': 1}
ops media {'open-ro': 2}
ops other {'open-ro': 3}
research cold {'open-ro': 1}
research media {'open-ro': 2}
research other {'open-ro': 3}
work cold {'open-ro': 1}
work media {'open-ro': 2}
work other {'open-ro': 3}
agent maintenance leases taken: {}
span media 1.93 s
span cold 0.00 s
==== greenH2 (run greenH2 build H4 OpenClaw 2026.11.19 (651057f))
startup trace: doctor.agent-database-plan 1918.9ms 
startup trace: cli.bootstrap.legacy-state-migrations 2739.9ms 
startup trace: doctor.config-flow 4035.2ms 
doctor.agent-database-plan 1918.9ms pending=none databases=4 unchanged=4
The Gateway was stopped for 43.2 s.
main cold {'open-ro': 1}
main media {'open-ro': 2}
main other {'open-ro': 3}
ops cold {'open-ro': 1}
ops media {'open-ro': 2}
ops other {'open-ro': 3}
research cold {'open-ro': 1}
research media {'open-ro': 2}
research other {'open-ro': 3}
work cold {'open-ro': 1}
work media {'open-ro': 2}
work other {'open-ro': 3}
agent maintenance leases taken: {}
span media 1.79 s
span cold 0.00 s

Outage A/B, using the same cell and store restored byte-identical before every run. Runs are offline and the builds alternate (B,H / H,B / B,H). Each hold discards one warm-up per build, leaving 6 measured runs per build. The probe hits /healthz every 250 ms. Medians with ranges:

base 788ca3c2f2b head 651057f7521 delta
Gateway not serving 40.5 s [38.6–42.4] 38.7 s [37.0–43.1] −1.8 s
Doctor's "stopped for" 42.3 s 40.1 s −2.2 s
doctor.config-flow 5.52 s 3.80 s −1.72 s
cli.bootstrap.legacy-state-migrations 4.36 s 2.56 s −1.80 s
restart to serving 4.22 s 4.32 s +0.10 s
Doctor CPU user 43.6 s 41.6 s −2.0 s

Paired differences (head minus base): −1.8, +2.7, −1.6, −0.8, −1.3, −4.3 s. The one positive pair ran while host load peaked at 9.9; the other runs were between 1.4 and 6.8. No other section moved by 0.10 s or more. Keeping the seal did not measurably shorten the restart. The remaining time for this owner, 1.9 to 2.1 s, is the read-only full integrity check of the 4 GiB store, which runs on every Doctor run by design (#175402).

Unit, red then green: one healthy-rerun test runs only the existing entry points. On base it fails ("expected 4 to be +0": four maintenance leases on a no-op rerun); on head it passes. The tests written for the review findings each fail with their fix reverted and pass with it:

  • verifyOnly changed-row pending;
  • 3.51 interior fanout;
  • empty-table lower bound;
  • last-loaded estimate;
  • empty table with an unanalyzed index.

Commands on the final head:

  • node scripts/run-vitest.mjs on 22 affected files (head f092ccb8ba0), including the generic guards doctor-health-contributions.pending-read-only.test.ts and doctor-maintenance.stopped-systemd.test.ts: all pass.
  • node scripts/check-changed.mjs: passes (exit 0) on f092ccb8ba0.
  • release-update-survivor Docker lane, run locally through pnpm test:docker:all on PR head 0c4ae3e2b30, a build of 0c4ae3e2b30 against its merge base: all three release cases pass (healthy, crash, and the schema downgrade that schema-downgrade-source.mjs selects because this PR changes src/state/*schema* and *migrations* files), in 2038 s. On CI the same lane timed out twice at its 3300 s budget: the last output came seconds before the kill, while the runner was still fetching packages, not stalled in Doctor. A daemon-only PR (improve: avoid Windows task imports during Linux service discovery #206777), which does not select the downgrade case, passed in 1358 s.
  • Session identity ratchet: OK.

Autoreview: Codex route, --max-priority P2 --thinking high, with 17 owner and caller files as source context. Seven passes found ten P2 findings, all fixed with regression tests. The last two, from after a merge of main, were: planning under migration capture, and sqlite_stat1 creation. Each regression test fails with its fix reverted. The eighth pass, on head f092ccb8ba0 with 19 source-context files, was scoped-clean ("patch is correct"), and its report lists the inspected files.

Test files audited in full:

  • state-migrations.agent-database-plan.test.ts (new);
  • sqlite-planner-statistics.test.ts (existing cases kept; oracle and 3.44 cases added);
  • state-migrations.cold-navigation.test.ts (one case added);
  • state-migrations.media-persistence.canonical-archives.test.ts (four verify cases added).

Nothing in the existing tests was removed. While compacting, two of the new cases were folded away:

  • the planner "refreshed agent schema" case, because the plan's healthy-database test reads the same real agent schema;
  • one of the two healthy-database cases, merged into the other.

Test-lines allocation: config/test-lines-allocations/206707-doctor-agent-db-plan.txt records 109 lines above the 400-line allowance. They cover one real-database guard per maintenance condition (the coverage this change exists to keep honest), the SQLite optimize oracle, and the archive, cold-navigation and copied-read consumer cases.

Platform gates: on Windows, permissions are rewritten on every pass, and before SQLite 3.46 planner statistics are refreshed on every pass, so the no-op cases expect work there.

Not proven: PostgreSQL agent stores (undecidable by design), macOS launchd, pnpm installs, databases large enough that the read-only integrity check outweighs the saved transactions, and the config-flow step's overall answer (not wired).

On the steady-state store, no other owner in the migration window opened an agent database read-write (only read-only opens). On a store that had never been through doctor --fix, the transcript-directives cursor and the workspace-setup auth-profile cleanup also wrote agent databases once. Those are other owners and outside this PR.

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

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. impact:session-state Session, memory, transcript, context, or agent state can drift or corrupt. impact:ux-friction User-facing flow adds avoidable confusion or support burden without fully blocking progress. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Nov 27, 2026
@clawsweeper

clawsweeper Bot commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

This PR plans agent database maintenance read-only and skips writable maintenance when every applicable condition reports no work.

Example: Run openclaw doctor --fix again on a healthy Linux installation with four agent databases.

  • Before: The media and cold-navigation passes open databases for writing and invalidate their clean-close seals.
  • After: Healthy databases remain read-only, retain their seals, and avoid maintenance leases and write transactions.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) Useful production-path evidence supports the optimization, but required upgrade proof is incomplete and a deterministic platform-test defect prevents a pass.
Proof confidence 🧂 unranked krab (1/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: Complete
User problem: Running Doctor on a healthy installation prolongs Gateway downtime and discards reusable clean-close integrity proof.
Reason: The maintainer-authored direction addresses measured unnecessary maintenance without adding configuration or changing the broader stop policy.

Merge readiness

⛔ Blocked before merge - 2 items remain

Keep this maintainer-authored PR open: it addresses unnecessary Doctor maintenance still present on main, but its new healthy-database test fails on supported platform paths.

Reviewed head: 7fca2e5b728e4715ea5eed734697f5dd61a81821

Before merge

  • [P2] Match the condition inventory to platform short-circuiting (P2) - This test runs on Windows and SQLite versions before 3.46, but it always requires all condition keys. On Windows, permissions is work; on older SQLite, planner-statistics is work. The planner therefore returns at state-migrations.agent-database-plan.ts:330–331 before adding transcript-archives, archive-files, or integrity, making this assertion fail on those supported runtimes. Make the expected inventory account for that intentional early return while retaining the complete inventory check on runtimes where every cheap condition is none.
  • 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] Match the condition inventory to platform short-circuiting — src/infra/state-migrations.agent-database-plan.test.ts:133-135

Tests

  • Missing end-to-end proof: The PR owner should provide a fresh-install check and an upgrade from v2026.11.10, showing Doctor repair, a subsequent healthy rerun, successful Gateway restart, and retained settings, sessions, and archives, with sensitive values redacted.
Agent review details

How this fits together

Doctor's migration graph supplies discovered agent stores to media maintenance and cold-navigation repair; the new plan determines which stores can bypass those writes while remaining available to later repair steps.

flowchart TD
  A[Doctor migration graph] --> B[Discover agent stores]
  B --> C[Read-only maintenance plan]
  C --> D[Healthy stores skip writes]
  C --> E[Existing maintenance and repair]
  D --> F[Later Doctor steps]
  E --> F
Loading

Technical review

Best possible solution:

Keep the plan within the existing migration owners, preserve fallback repair and fresh integrity checks, and correct the platform-dependent test expectations.

Do we have a high-confidence way to reproduce the issue?

Current-main source shows healthy stores entering writable maintenance, and supplied CLI logs demonstrate that behavior on the baseline; this read-only review ran no reproduction.

Is this the best way to solve the issue?

Planning at the migration owner is a coherent way to eliminate unnecessary writes while retaining repair behavior; the reviewed production paths reveal no definite new data-loss defect.

Full review comments:

  • [P2] [P2] Match the condition inventory to platform short-circuiting — src/infra/state-migrations.agent-database-plan.test.ts:133-135
    This test runs on Windows and SQLite versions before 3.46, but it always requires all condition keys. On Windows, permissions is work; on older SQLite, planner-statistics is work. The planner therefore returns at state-migrations.agent-database-plan.ts:330–331 before adding transcript-archives, archive-files, or integrity, making this assertion fail on those supported runtimes. Make the expected inventory account for that intentional early return while retaining the complete inventory check on runtimes where every cheap condition is none.
    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 89425fd75d4e.

Provenance checked

  • Doctor media migration keeps the original intent (367ff3c: Established the Doctor-owned, idempotent migration of legacy media into canonical persisted facts.)
  • Fresh integrity verification keeps the original intent (2e20625: Reuse full verification within one migration owner while ensuring separate Doctor invocations inspect current bytes.)
  • Cold-navigation backfill keeps the original intent (fce0e56: Retain navigation facts so archived history can be read without restoring full payloads, with resumable Doctor backfill.)
  • Planner-statistics maintenance keeps the original intent (8d6db33: Maintain useful SQLite planner statistics; the new read-only predicate attempts to preserve the existing writer's refresh decisions.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

Acceptance criteria:

  • node scripts/run-vitest.mjs src/infra/state-migrations.agent-database-plan.test.ts
  • Run the same focused command on Windows and a supported SQLite runtime before 3.46.
  • git diff --check

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit fce0e56 adds src/infra/state-migrations.cold-navigation.ts:34 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: fce0e56fc0a6; files: src/infra/state-migrations.cold-navigation.ts)
  • Jason (Json): Raw commit d0f7698 adds src/commands/doctor-maintenance-pending.ts:23 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/commands/doctor-maintenance-pending.ts)

PR surface

Source +905, Tests +710. Total +1615 across 16 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 12 1029 124 +905
Tests 4 712 2 +710
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 16 1741 126 +1615

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.

Review metrics

Metric Value Why it matters
Production versus test changes Production +1,029/-124 lines; tests +712/-2 lines Growth implements the maintenance-condition inventory and SQLite planner predicate, with distinct repair guards and an independent SQLite oracle; the stages must remain coherent to avoid skipping required work.

Labels

Label changes:

  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab 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: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab 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 27, 2026, 8:59 AM ET / 13:59 UTC.

@openclaw-barnacle openclaw-barnacle Bot added the commands Command implementations label Nov 27, 2026
@fuller-stack-dev
fuller-stack-dev merged commit 0f54067 into openclaw:main Nov 27, 2026
153 checks passed
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Merged via squash.

@fuller-stack-dev
fuller-stack-dev deleted the fix/doctor-agent-db-plan branch November 27, 2026 20:55
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 28, 2026
…eway is stopped (openclaw#206707)

* fix(doctor): skip agent database maintenance that has nothing to do

Plan the agent database migration read-only and leave a database whose
every condition is none unopened for writing, unleased and sealed.

* test(doctor): cover deleted and incognito agent databases in the plan

* fix(doctor): count changed archive rows and interior fanout in the agent database plan

* fix(doctor): accept an empty table within optimize's lower bound

* fix(doctor): keep SQLite's last loaded table estimate in the planner check

* fix(doctor): skip empty tables with an unanalyzed index in the planner check

* test(doctor): honor supported SQLite versions and Windows in the plan tests

* test(doctor): compact the agent database plan guards and satisfy the CI ratchets

* test(doctor): walk fixture files without recursive readdir and type the state directory

* fix(doctor): plan nothing through copied store reads and count stat1 creation

* chore: drop the test-lines allocation the change no longer needs

* chore: record the plan's regression-test allocation
@obviyus

obviyus commented Nov 28, 2026

Copy link
Copy Markdown
Collaborator

Follow-up from main's hourly CI. src/commands/doctor-maintenance.interruption.process.test.ts fails 3 cases on main in every scheduled run since run 46070235079 (2026-11-27 21:25Z; latest failing run 46149578049):

  • "restores its stopped Gateway before SIGTERM with progress exits"
  • "restores its stopped Gateway before SIGHUP during archives exits"
  • "restores its stopped Gateway before SIGINT during archives exits"

Each one fails with no such table: schema_meta in readTranscriptArchiveRecoveryJournal. The first-bad window (cbfed7c1..4849bb76) contains this PR, which is the only change in that window to state-migrations/Doctor, so it's the likely cause. It hasn't been bisected yet. PR CI's changed-file selection doesn't run this test, which is why it only shows up hourly. How to resolve it is your call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations impact:session-state Session, memory, transcript, context, or agent state can drift or corrupt. 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: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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.

2 participants