Repository navigation
fix(plugins): preserve read errors before registry recovery - #131521
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
9f15d77 to
39b7447
Compare
|
Land-ready proof for 39b7447d49cd07d4986d0b85e6e6a1a3df284eca: the shared plugin-index row reader preserves original read errors, so unreadable state cannot select invalid-record guidance or a persisted rebuild. Genuine absence and independent install-record salvage remain supported. Writer, schema, retention, transaction, and cache lifecycle semantics are unchanged, within the accepted persistence design. Rebased only to resolve the conflict with #131417's reader/writer module split; the new writer module remains untouched. Production +48/-70 (net -22); tests +304; docs +2. All 163 focused/sibling tests passed again, original EACCES reproduction preserved all four original exceptions, and the real SQLite exclusive-lock probe preserved the row and succeeded after unlocking. Fresh isolated Codex autoreview: no actionable findings. Commands completed: node scripts/run-vitest.mjs src/plugins/installed-plugin-index-records.test.ts src/plugins/installed-plugin-index-store.test.ts src/plugins/installed-plugin-index-read-state.test.ts src/commands/doctor/shared/plugin-registry-migration.test.ts src/plugins/installed-plugin-index-store.install-record-map.test.ts src/plugins/installed-plugin-index-generation-precedence.test.ts src/plugins/plugin-registry-inspection.test.ts src/plugins/plugin-registry-snapshot.test.ts src/plugins/manifest-metadata-scan.test.ts
node scripts/check-changed.mjs -- docs/cli/plugins.md src/plugins/installed-plugin-index-record-state.ts src/plugins/installed-plugin-index-row.ts src/plugins/installed-plugin-index-store.ts src/plugins/installed-plugin-index-records.test.ts src/plugins/installed-plugin-index-read-state.test.ts src/commands/doctor/shared/plugin-registry-migration.test.ts
node scripts/watch-pr-ci.mjs 131521 39b7447d49cd07d4986d0b85e6e6a1a3df284eca
scripts/pr review-init 131521
scripts/pr review-checkout-main 131521
scripts/pr review-checkout-pr 131521
scripts/pr review-artifacts-init 131521
scripts/pr review-validate-artifacts 131521
OPENCLAW_TESTBOX=1 scripts/pr prepare-run 131521CI run 33141896737, attempt 1 passed on this exact head, including required openclaw/ci-gate. Native prepare passed and retained the same head. No CI failure or rerun. Live rules require linear history and this check; no independent approval rule is enforced. No review findings or requests are outstanding; ClawSweeper currently has only a review-start placeholder, with no published rank-up moves. Proof limits: full local build and built CLI lock/unlock proof completed before the mechanical module-split rebase; fresh source proof and hosted CI cover the rebased head. The CLI lock was caught earlier in shared-state bootstrap, not the changed reader; the real SQLite owner probe covers that boundary. No operator Gateway or live state was touched, and no observed production data-loss claim is made. The original stat-injection probe was not run against a stable binary. |
|
Merged via squash.
|
Closes #131327 — plugin-state read failures misreported as invalid or missing records.
What Problem This Solves
Fixes an issue where operators inspecting or repairing plugin state received invalid-record and row-deletion guidance when the database could not actually be read. The sibling full-index reader reported the same failures as an absent index, allowing a transient failed read to select a rebuild with empty install records.
The original isolated EACCES reproduction fails on current-main baseline
ecb6acff90057a31b482f54146ea87e984e06cbc. A real-SQLite regression fixture additionally demonstrates a manual refresh overwriting its synthetic authoritative records after one injected read failure. This is synthetic-state proof, not a claim of observed production data loss.Why This Change Was Made
Both projections now share a light read-only row boundary that propagates original errors and explicitly recognizes genuine missing database/table/row state. Removed the two broad catches and redundant SQLite forwarding function; kept install-record parsing independent of full-index parsing so intact records remain recoverable when derived metadata is malformed.
The persistence-recovery contract was explicitly accepted before implementation. No schema/version, representation, migration format, retention, transaction, writer, rollback, or successful-cache lifecycle changes. A failed authoritative read cannot authorize fallback, migration, or a persisted refresh. Malformed-envelope and missing-revision behavior remains unchanged. A code revert requires no data migration, but would restore the misleading classifications.
Best-fix judgment: repair the read owner, not runtime/Doctor diagnostics. An error-code allowlist would omit other real failures; a new unavailable-result layer adds no needed caller capability; routing records through full-index validation would break record salvage.
Production LOC: +48/-70 (net -22). Tests: +304/-0. Docs: +2/-0. The new row module replaces duplicated reader policy; no test-only production seam or dependency was added.
Provenance: original catch-to-null in #88794 — SQLite plugin-index persistence, authored and merged by @steipete; invalid-record classification in #121045 — install-record recovery, authored and merged by @vincentkoc. #125493 — newer-schema error preservation, authored and merged by @steipete, exempted schema errors but retained the remaining catch behavior. Blame and live merge metadata checked. Older stable tags contain catch-to-null behavior; the supplied current-main stat-injection reproduction was not run against a stable binary.
User Impact
Permission and lock failures remain permission and lock failures. Operators can restore database access and retry without being told to delete unread records. Genuine absence, invalid-record guidance after successful inspection, newer-schema refusal, and successful recovery remain supported. Updated the plugin state documentation.
AI-assisted repair and review; reporter and maintainer: @steipete.
Evidence
Rebased onto
629a47e3cc20a9f8b6d19c105f840b8a693ec4aato resolve conflicts with #131417 — keep write machinery out of metadata reads. The writer module remains unchanged; the new regression suite imports refresh functions from its current owner. The approved read-error semantics are unchanged. All 163 tests across 9 files pass again, the original four-path EACCES reproduction and real SQLite owner lock probe pass again, and fresh isolated Codex autoreview is clean. Full build and built CLI proof below were completed before this module-split rebase; exact-head hosted CI run 33141896737 passed on39b7447d49cd07d4986d0b85e6e6a1a3df284eca, including the requiredopenclaw/ci-gate. The complete changed-file gate also passed again after rebase.invalid, a replacement runtime error,null, and Doctor row-deletion guidance. After, all four propagate the exact original error; no misleading classification or deletion guidance. The lead independently reran this probe.{}and advanced revision; policy refresh also wrote after a failed required read.BEGIN EXCLUSIVEreturns actualERR_SQLITE_ERROR/errcode: 5/database is lockedthrough full-index, runtime-record, and Doctor reads; the row remains unchanged; all succeed after unlocking.node openclaw.mjs plugins registry --jsonexits 1 withSQLite read-only worker database is locked, leaves exact row bytes/revision untouched, then exits 0 after unlock and preserves authoritative records. Limit: this CLI lock is caught by earlier shared-state bootstrap, not the changed plugin reader; changed-owner proof is the real SQLite probe and regression suite above. No operator Gateway or live state was touched.pnpm build: passed, including CLI bootstrap/import checks and SDK exports; no ineffective-dynamic-import warning.Focused test command:
Changed gate:
Dependency contract checked directly: Node 26.7.0 SQLite get distinguishes
SQLITE_DONEfrom errors; SQLite error construction retains result codes; SQLite BUSY/LOCKED describe concurrency failures rather than malformed data.