Skip to content

fix(plugins): preserve newer schema errors - #125493

Merged
steipete merged 1 commit into
mainfrom
codex/preserve-plugin-schema-error
Aug 18, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/preserve-plugin-schema-error

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Follow-up to #125115 and #125133.

AI-assisted: yes. I reviewed the implementation and proof.

What Problem This Solves

Older OpenClaw builds correctly refuse a shared SQLite database created by a newer schema, but plugin install-record inspection caught that compatibility error and relabeled it as corrupt plugin metadata. Operators saw Persisted plugin install records are invalid even when the records were valid and the real action was to update the stale build.

Why This Change Was Made

SQLite schema compatibility remains owned by the database boundary. A shared isSqliteSchemaVersionError guard now preserves that terminal error through both plugin-index read paths, while malformed plugin rows, missing state, and other unreadable index cases keep their existing soft classifications.

The same guard replaces duplicate string checks in shared and per-agent database open failure handling.

Provenance: the generic install-record failure path was introduced by #121045 (1471881af7aa, authored and merged by @vincentkoc) and made operational for schema-8 readers when #124728 (4bc37cd59761, authored and merged by @steipete) advanced shared state to schema 9. The sibling catch-to-null path came from #119228 (ef11eae39b29, authored and merged by @vincentkoc).

User Impact

A stale CLI now reports the database path, observed and supported schema versions, refusing install identity, upgrade/rebuild or alternate-state-directory remediation, and database-schema documentation. Truly malformed plugin install records still produce the existing Doctor repair guidance.

Production LOC: +21/-6 (net +15) for the canonical compatibility-error guard and two owner-boundary rethrows. Tests: +49/-0.

Evidence

The focused regressions failed before the production fix for the intended reasons: the install-record loader emitted the generic invalid-record message and the full index reader resolved null (54 unaffected tests passed). After the fix:

node scripts/run-vitest.mjs src/plugins/installed-plugin-index-records.test.ts src/plugins/installed-plugin-index-store.test.ts
2 files passed, 56 tests passed

Rebased intended-head proof: Blacksmith Testbox tbx_01m097cx2xwx94jr0zy1wd6vjj, https://github.com/openclaw/openclaw/actions/runs/32087981638

Changed-surface format, typechecks, lint, dead exports, import cycles, plugin boundaries, and database guards passed on Blacksmith Testbox tbx_01m0968g3p66etxy5x79g5vhb3: https://github.com/openclaw/openclaw/actions/runs/32086773934

Source-blind CLI behavior validation passed both clauses on Blacksmith Testbox tbx_01m097kje0d3sfv5emw9zxk419: https://github.com/openclaw/openclaw/actions/runs/32088201788

  • Future schemas 10 and 11 each produced the actionable newer-schema diagnostic and never claimed install-record corruption.
  • Supported schema 9 with malformed install_records_json retained the existing invalid-record Doctor diagnostic.

Final branch autoreview completed clean with no accepted/actionable findings, confidence 0.99.

@clawsweeper

clawsweeper Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added size: S maintainer Maintainer-authored PR labels Aug 18, 2026
@steipete
steipete marked this pull request as ready for review August 18, 2026 01:28
@steipete
steipete merged commit 19e68d1 into main Aug 18, 2026
277 checks passed
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

@steipete
steipete deleted the codex/preserve-plugin-schema-error branch August 18, 2026 01:37
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. 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. labels Aug 18, 2026
@clawsweeper

clawsweeper Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 17, 2026, 9:36 PM ET / August 18, 2026, 01:36 UTC.

ClawSweeper review

What this changes

The PR makes plugin install-index reads rethrow newer SQLite schema errors while retaining their existing handling for malformed or unavailable plugin records.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep this PR open: current main still masks the database-owned newer-schema error as invalid plugin state or a missing index, while the branch preserves the actionable compatibility diagnostic through both affected readers.

Priority: P2
Reviewed head: ffa6820e6fe534ac3fe245a1c6d865ea949d5c20

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch is focused, preserves the correct owner boundary, and has meaningful real-SQLite regression coverage; exact-head revalidation remains appropriate after rebase.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer PR is exempt from the external-contributor proof gate; its body nevertheless supplies source-blind CLI/Testbox proof claims for the changed diagnostic path.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer PR is exempt from the external-contributor proof gate; its body nevertheless supplies source-blind CLI/Testbox proof claims for the changed diagnostic path.
Evidence reviewed 6 items Current-main defect: Current main converts every install-record inspection failure to invalid, which reaches the generic Doctor message; its sibling full-index read similarly returns null.
Database owner contract: The read-only state owner checks user_version before any row access and throws the canonical newer-schema error, so the two broad catches erase a terminal compatibility result rather than malformed-record state.
Proposed owner-boundary repair: The branch centralizes the existing error name and rethrows only that typed error from both plugin-index reader boundaries; other failures still follow their prior invalid/null paths.
Findings None None.
Security None None.

How this fits together

Plugin discovery and startup read the installed-plugin index from OpenClaw’s shared SQLite state. The read-only database boundary rejects newer schemas before exposing records; plugin readers then feed either normal registry loading or actionable operator diagnostics.

flowchart LR
  A[Plugin startup or CLI] --> B[Plugin index reader]
  B --> C[Read-only state database]
  C --> D{Schema supported?}
  D -->|No| E[Newer-schema guidance]
  D -->|Yes| F[Validate plugin records]
  F --> G[Registry or Doctor guidance]
Loading

Before merge

  • Resolve merge risk (P1) - The branch is behind current main; rebase and repeat the exact-head focused and CLI behavior checks before landing.
  • Resolve merge risk (P1) - Production grows by 15 lines for a shared classifier and targeted rethrows; retain this single canonical error path rather than adding caller-specific fallbacks.
  • Complete next step (P2) - The protected maintainer label and required rebase/exact-head validation leave this as normal maintainer landing work, not a repair-lane candidate.
Agent review details

Security

None.

PR surface

Source +15, Tests +49. Total +64 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 5 21 6 +15
Tests 2 49 0 +49
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 70 6 +64

Review metrics

Metric Value Why it matters
Production vs test delta production +15/-6 (net +15); tests +49/-0 The production increase is confined to one shared error classifier and two preserving catches, with separate regressions for each affected read boundary.

Stored data model

Persistent data-model change detected: database schema: src/plugins/installed-plugin-index-records.test.ts, database schema: src/plugins/installed-plugin-index-store.test.ts, serialized state: src/plugins/installed-plugin-index-records.test.ts, serialized state: src/state/openclaw-agent-db.ts, serialized state: src/state/openclaw-state-db.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Rebase and revalidate schema-forward recovery (recommended)
    Rebase onto current main and rerun the focused database and source-blind CLI checks so stale builds reliably receive the actionable newer-schema diagnostic.
  2. Pause if the new terminal error is not desired
    Do not merge if maintainers intend schema-ahead plugin reads to remain best-effort, because that would require an explicit compatibility policy rather than another local catch.

Technical review

Best possible solution:

Rebase this narrow owner-boundary repair, retain the two real-SQLite regressions, and land it once exact-head checks confirm the current main merge result.

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

Yes, from source: a database with user_version above the supported state schema throws before row access, and current main’s catches collapse that error; the supplied regressions enact this with a real SQLite database, though they were not run in this read-only review.

Is this the best way to solve the issue?

Yes. Preserving the database boundary’s terminal error at both plugin-index reader boundaries is narrower and safer than teaching downstream callers to distinguish a misleading invalid-record result.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 6f6691c9a61a.

Labels

Label changes:

  • add P2: This is a bounded operator-facing diagnostic and recovery defect during schema-forward state use.
  • add merge-risk: 🚨 compatibility: Merging changes stale-build behavior from soft plugin-index fallback to a terminal newer-schema diagnostic for existing shared state.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer PR is exempt from the external-contributor proof gate; its body nevertheless supplies source-blind CLI/Testbox proof claims for the changed diagnostic path.

Label justifications:

  • P2: This is a bounded operator-facing diagnostic and recovery defect during schema-forward state use.
  • merge-risk: 🚨 compatibility: Merging changes stale-build behavior from soft plugin-index fallback to a terminal newer-schema diagnostic for existing shared state.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer PR is exempt from the external-contributor proof gate; its body nevertheless supplies source-blind CLI/Testbox proof claims for the changed diagnostic path.

Evidence

What I checked:

Likely related people:

  • steipete: Recent schema-v9 state work and this corrective PR connect this person to the schema-forward compatibility boundary. (role: recent schema and state contributor; confidence: high; commits: 4bc37cd59761, ffa6820e6fe5; files: src/infra/sqlite-user-version.ts, src/state/openclaw-state-db.ts)
  • vincentkoc: Merged plugin persistence work introduced and maintained the index-reading paths whose broad catches this PR narrows. (role: persisted plugin-index contributor; confidence: high; commits: 1471881af7aa, ef11eae39b29; files: src/plugins/installed-plugin-index-record-state.ts, src/plugins/installed-plugin-index-store.ts)

Rank-up moves

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

  • Rebase onto current main and rerun the focused schema-forward CLI behavior proof.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

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

Labels

maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant