Skip to content

fix(cli): keep read commands off the writable shared state DB - #119585

Closed
Jackten wants to merge 1 commit into
openclaw:mainfrom
Jackten:fix/cli-readonly-state-db
Closed

Jackten wants to merge 1 commit into
openclaw:mainfrom
Jackten:fix/cli-readonly-state-db

Conversation

@Jackten

@Jackten Jackten commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Several CLI inspection paths could re-enter task and TaskFlow runtime restore through writable state owners. On a host with a running Gateway, commands such as task listing/audit, maintenance preview, TaskFlow inspection, and default plugin inventory could therefore create or migrate the shared state database, or record configuration observation, despite being read-only operations.

This change makes those inspection restores fail closed when the existing state DB is older than the current schema, rather than opening it writable. It preserves the writable migration path for explicit mutations.

Why This Change Was Made

#124110 now owns the generic non-creating, non-migrating state/doctor loaders. This PR has been reshaped after it and drops the overlapping work.

The remaining scope is limited to the unique guarantees:

  • task and TaskFlow runtime inspection restores use a current-schema read-only state DB path;
  • explicit task and flow mutations still restore writable state and may migrate it;
  • plugin/task inspection config reads use an internal non-observing config seam;
  • channels status has regression coverage for its non-observing fallback config reads;
  • task maintenance preview does not promote a failed read-only restore into a writable migration.

No schema version, public config option, or CLI flag is added.

Refs: #119583, #120222

#120222 is retained as resilience context only. This PR does not change Gateway startup ordering or claim to resolve that open product decision.

User Impact

Read-only CLI inspection no longer creates or migrates state/openclaw.sqlite. If a task or TaskFlow inspection encounters an older state schema, it explains how to repair it (openclaw doctor --fix or starting the Gateway) without changing the DB.

Explicit mutation commands, including task notification/cancellation and flow cancellation, retain their existing writable migration behavior.

Evidence

  • Rebased and narrowed on current openclaw/main after fix: keep doctor lint from migrating shared state #124110.
  • Focused tests: 98/98 passing across 7 files, including old-schema assertions that inspection leaves user_version unchanged and mutations can then migrate.
  • Targeted formatting and git diff --check passed.
  • CI=true pnpm build completed.
  • Local autoreview completed clean.

@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes commands Command implementations size: M triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Aug 5, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Aug 5, 2026
@clawsweeper

clawsweeper Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

The branch makes task and flow inspection restore state read-only and gives plugin inventory commands configuration reads that do not record observations.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) Useful inspection work remains, but obsolete runtime scope, the retained diagnostic defect and unauditable current behavior proof limit readiness.
Proof confidence 🦪 silver shellfish (2/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Merge readiness

⛔ Blocked before merge - 5 items remain

Distinct plugin-inspection work remains useful, so closure would discard a meaningful contribution. Most task-related work is now obsolete, and the pinned branch still contains the previously reported Doctor regression.

Priority: P2
Reviewed head: 633ab2bcf2e7b3bf147a338d40e60ccb9d79b061

Before merge

  • Add real behavior proof - The changed task restoration and configuration-observation owners are covered by reported tests, but the captured narrowed-head body supplies no inspectable after-fix CLI output. Older-head production transcripts are referenced in comments without retained output establishing the surviving plugin paths. Add a redacted real CLI transcript showing plugin inspection leaves shared state unchanged; terminal output or a recording is suitable. Redact credentials, IPs and private endpoints. Updating the body should trigger review; otherwise ask a maintainer for @clawsweeper re-review. No stored-data format changes are introduced.
  • Preserve older-schema Doctor snapshot inspection (P1) - On the pinned head, Doctor's workspace findings call this loader and the task snapshot loader without catching schema refusals. Replacing their existing read-only opener with the current-schema guard therefore makes an older database abort Doctor diagnostics instead of remaining inspectable without migration. This prior finding remains unfixed. Current main has retired these task owners, so resolve it by dropping the obsolete task/store changes when refreshing the branch; if any diagnostic loader is retained, preserve its older-schema contract.
  • Resolve merge risk - The branch has not been reconciled with current main's task retirement and substantially changed state readers; no pinned resolved merge is available to verify the surviving implementation.
  • Resolve merge risk - The production increase includes obsolete task restoration machinery and a schema wrapper that should disappear when the PR is narrowed to its remaining plugin-inspection repair.
  • Complete next step - Refresh the branch against current main, discard the retired task and schema-guard changes, and provide redacted after-fix CLI proof for plugin inspection.

Findings

  • [P1] Preserve older-schema Doctor snapshot inspection — src/tasks/task-flow-registry.store.sqlite.ts:221
Agent review details

How this fits together

CLI inspection commands read configuration and shared SQLite state to report installed plugins and runtime records. Configuration observation and runtime restoration can also enter writable persistence paths.

flowchart TD
  A[CLI command] --> B[Configuration reader]
  B --> C[Plugin inventory]
  A --> D[Inspection or mutation]
  D --> E[Read-only state reader]
  D --> F[Writable runtime owner]
  E --> G[Diagnostic output]
  C --> G
  F --> H[Persisted changes]
Loading

Technical review

Best possible solution:

Keep plugin inventory on the existing non-observing configuration owner, remove the retired task machinery and its schema guard, and preserve current Doctor diagnostics.

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

Yes, source-reproducible: cold plugin inventory uses observing configuration reads, which can write configuration-health state. No current-main runtime reproduction was executed.

Is this the best way to solve the issue?

No, the full branch is no longer the best fit: most of its runtime owners have been retired. A focused repair using the existing non-observing configuration factory is the maintainable remainder.

Full review comments:

  • [P1] Preserve older-schema Doctor snapshot inspection — src/tasks/task-flow-registry.store.sqlite.ts:221
    On the pinned head, Doctor's workspace findings call this loader and the task snapshot loader without catching schema refusals. Replacing their existing read-only opener with the current-schema guard therefore makes an older database abort Doctor diagnostics instead of remaining inspectable without migration. This prior finding remains unfixed. Current main has retired these task owners, so resolve it by dropping the obsolete task/store changes when refreshing the branch; if any diagnostic loader is retained, preserve its older-schema contract.
    Confidence: 0.98

Overall correctness: patch is incorrect
Overall confidence: 0.94

AGENTS.md: found and applied where relevant.

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

Merge-risk options

Maintainer options:

  1. Retain only the surviving inspection repair (recommended)
    Refresh against current main, discard retired task changes and their strict diagnostic guard, and validate the remaining plugin configuration reads.

Security

None.

Evidence

What I checked:

  • Pinned introduced changes: Reviewed the merge-base-to-head changes separately from current-main drift. The original head has raw recorded parent 146350f; no pinned test merge is available. (633ab2bcf2e7)
  • Prior Doctor finding remains on the pinned head: The changed task and flow snapshot loaders invoke the new current-schema guard. Doctor workspace findings call both loaders without catching that refusal, so an older database aborts these diagnostics. This is the same finding retained in the previous completed review. (src/tasks/task-flow-registry.store.sqlite.ts:221, 633ab2bcf2e7)
  • Merged retirement supersedes the task scope: GitHub verifies refactor: remove Tasks and TaskFlow runtime #159179 as merged. Its recorded commit removes Tasks and TaskFlow runtime, CLI and SDK surfaces while preserving stored rows; current main lacks the task command and runtime files. Doctor's current workspace module no longer calls the retired task loaders. (src/commands/doctor-workspace-status.ts, 6652f7eac8d9)
  • Plugin remainder is not implemented on current main: Current plugin listing still calls getRuntimeConfig with skipPluginValidation. The runtime reader does not disable observation, normalized configuration dependencies default observe to true, and observation can patch configuration-health state through the writable transaction owner. The branch's non-observing plugin reads therefore remain distinct. (src/cli/plugins-list-command.ts:28, 9ae1a44bf05d)
  • Existing configuration owner: The new inspection seam forwards observe:false into the existing configuration factory rather than implementing another persistence mechanism. Current-main configuration observation and health-state modules confirm the writable callee boundary. (src/config/io.runtime.ts:119, 633ab2bcf2e7)
  • Tests and proof continuity: The added task and flow tests cover absent databases and inspection refusal followed by writable mutation, but their old-schema fixtures lower the version of a current database. The captured body at sourceRevision a33b56b72d207f3739c586beb3f4fb483c5557e903958d8c753f0f4dd684923c lists 98 tests and build results. Earlier comments describe production transcripts at older heads; the captured narrowed-head body contains no inspectable transcript for the surviving plugin paths. Tests were inspected, not executed. (src/commands/tasks.readonly-state.test.ts:77, 633ab2bcf2e7)

PR surface

Source +135, Tests +195. Total +330 across 23 files.

View PR surface stats
Area Files Added Removed Net
Source 19 185 50 +135
Tests 4 197 2 +195
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 23 382 52 +330

Review metrics

Metric Value Why it matters
Production versus test growth Production +185/-50, net +135; tests +197/-2, net +195 The internal inspection boundary explains some growth, but task retirement makes much of the added production machinery unnecessary.
Configuration surface 1 internal inspection reader added; 0 public flags, options or schema versions added The remaining repair can avoid expanding the operator-facing configuration contract.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: The remaining current-main contribution concerns plugin inspection; the larger task-runtime scope has been retired.
  • merge-risk: 🚨 compatibility: The pinned branch changes shared diagnostic loaders to reject older schemas; those obsolete changes must be discarded rather than carried into the refreshed PR.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rank-up moves

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

  • Refresh against current main and remove retired task changes, including the shared diagnostic schema guard.
  • Attach redacted real CLI evidence for the remaining plugin-inspection paths.

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.

History

Review history (19 earlier review cycles; latest 8 shown)
  • reviewed August 15, 2026, 5:47 PM ET / 21:47 UTC sha unknown :: needs maintainer review before merge. :: none
  • reviewed August 15, 2026, 6:48 PM ET / 22:48 UTC sha unknown :: needs maintainer review before merge. :: none
  • reviewed 2026-08-16T15:46:06.644Z sha 633ab2b :: needs maintainer review before merge. :: none
  • reviewed 2026-08-22T00:12:43.143Z sha 633ab2b :: needs maintainer review before merge. :: none
  • reviewed 2026-08-28T02:05:49.354Z sha 633ab2b :: needs real behavior proof before merge. :: none
  • reviewed September 5, 2026, 4:04 AM ET / 08:04 UTC sha unknown :: needs real behavior proof before merge. :: [P1] [P1] Preserve older-schema support in diagnostic snapshot readers
  • reviewed 2026-09-05T08:04:51.437Z sha 633ab2b :: needs real behavior proof before merge. :: [P1] [P1] Preserve older-schema support in diagnostic snapshot readers
  • reviewed 2026-09-25T18:46:24.123Z sha 633ab2b :: needs real behavior proof before merge. :: [P1] Preserve older-schema support in Doctor snapshot readers

Reviewed October 2, 2026, 9:44 PM ET / October 3, 2026, 01:44 UTC (Revision 20).

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: L and removed size: M labels Aug 5, 2026
@Jackten

Jackten commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review — round-2 pushed (42c76881fbb): all three findings repaired with call-site evidence, plugin-sdk API baseline regenerated, compact-small shard failures addressed, and redacted real-behavior proof added to the PR body (before/after descriptor + migration evidence from a production host, including the fail-closed schema-mismatch path).

@clawsweeper

clawsweeper Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@Jackten

Jackten commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review — R3 pushed (4785ade29bb): clears the three follow-up CI failures (test tuple typing, dependency-check facade export, Windows ACL inspection timeout with preserved error cause — no Windows skips or weakened checks). 213 focused tests + check:test-types + dependency checks + full build/check green locally.

@clawsweeper

clawsweeper Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added the merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. label Aug 5, 2026
@openclaw-barnacle openclaw-barnacle Bot added size: XL and removed docs Improvements or additions to documentation size: L labels Aug 5, 2026
@Jackten

Jackten commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review — R4 pushed (0a5ffd3c09f): both remaining P1 findings fixed (maintenance preview non-observing with the apply/preview branch traced; all 15 catalog-inferred inspection commands classified + regression-tested), the SDK merge-risk resolved by keeping observe off the exported helper types via an internal inspection entry point (baselines restored unchanged), and the PR body now carries inspectable current-head proof transcripts captured from a production host at this exact commit.

@clawsweeper

clawsweeper Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 5, 2026
@Jackten

Jackten commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review — R5 pushed (84c5a31aed6): the two shard failures were deterministic R4 test-mock regressions (mocks now cover getRuntimeConfigForInspection); PR body headings aligned to the template. No production-code changes.

@clawsweeper

clawsweeper Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. label Aug 15, 2026
@Jackten
Jackten force-pushed the fix/cli-readonly-state-db branch from 84c5a31 to 633ab2b Compare August 16, 2026 15:39
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 22, 2026
@fuller-stack-dev fuller-stack-dev self-assigned this Sep 17, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This assigned pull request has been automatically marked as stale after being open for 27 days.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Sep 18, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. and removed P1 High-priority user-facing bug, regression, or broken workflow. labels Oct 3, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the stale Marked as stale due to inactivity label Oct 3, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This assigned pull request has been automatically marked as stale after being open for 27 days.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Oct 3, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. clawsweeper-recovery-stuck labels Oct 17, 2026
@steipete

Copy link
Copy Markdown
Contributor

Thanks for the PR. We're closing older pull requests that have gone stale against current main.

This PR has had no commits since August 16, CI is failing, and it still needs real behavior proof against current main. Please open a fresh, narrower PR if the read-only inspection paths still create writable state.

@steipete steipete closed this Oct 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. clawsweeper-recovery-stuck cli CLI command changes commands Command implementations merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: XL stale Marked as stale due to inactivity status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants