Repository navigation
fix(plugins): preserve install records during recovery - #121045
Conversation
Preserve canonical fields, passthrough metadata, untouched record identity, and deterministic serialized ordering across SQLite and post-core handoff. Punchcard-Session: amber-workshop-workshop-36 Co-authored-by: Galin Iliev <[email protected]>
Preflight persisted and legacy install-record state before registry repair, package cleanup, generation retirement, archival, or state-directory moves. Punchcard-Session: amber-workshop-workshop-36 Co-authored-by: Galin Iliev <[email protected]>
Punchcard-Session: amber-workshop-workshop-36 Co-authored-by: Galin Iliev <[email protected]>
Punchcard-Session: amber-workshop-workshop-36 Co-authored-by: Galin Iliev <[email protected]>
|
🦞👀 Pull request received. I will update this pull request when review starts. |
Punchcard-Session: amber-workshop-workshop-36 Co-authored-by: Galin Iliev <[email protected]>
Punchcard-Session: amber-workshop-workshop-36 Co-authored-by: Galin Iliev <[email protected]>
|
Codex review: needs maintainer review before merge. Reviewed August 9, 2026, 7:47 AM ET / 11:47 UTC. ClawSweeper reviewWhat this changesThis PR centralizes parsing and prototype-safe persistence of plugin install records so updates, Doctor, and the SQLite index preserve valid records and stop before mutating invalid ones. Merge readinessKeep open for maintainer merge review: the branch is a coherent replacement for the remaining install-record work and fixes a current unsafe recovery boundary, but its fail-closed upgrade behavior needs exact-head upgrade proof before landing. Priority: P1 Review scores
Verification
How this fits togetherPlugin install records connect configured plugin sources to the durable plugin index used by startup, updates, and Doctor. The changed paths validate persisted records before recovery, then either preserve them through the next lifecycle step or produce recovery guidance. flowchart LR
A[Config and SQLite install records] --> B[Shared record parser]
B --> C{Valid record map?}
C -->|Yes| D[Doctor and update recovery]
C -->|No| E[Recovery guidance]
D --> F[Plugin index persistence]
D --> G[Plugin startup and updates]
Decision needed
Why: This intentionally changes behavior for persisted upgrade state and may stop recovery or startup until the operator repairs invalid data; a maintainer must accept that compatibility tradeoff. Before merge
Agent review detailsSecurityNone. PR surfaceSource +222, Tests +743. Total +965 across 30 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Land one shared install-record owner only after a copied-state upgrade run proves valid legacy records survive unchanged and invalid records leave the index, package files, and state-directory layout untouched while Doctor gives usable recovery guidance. Do we have a high-confidence way to reproduce the issue? Yes—source-reproducible: the base code treats invalid config install records as empty state, while the branch validates them before recovery or persistence; no runtime test was run in this read-only review. Is this the best way to solve the issue? Yes: centralizing parsing, own-key semantics, and serialization at the install-record owner is safer than retaining separate permissive readers in update, Doctor, and SQLite paths. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 5d98d2e6ecd7. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
Punchcard-Session: amber-workshop-workshop-36 Co-authored-by: Galin Iliev <[email protected]>
|
@clawsweeper re-review Please review exact head Exact-head CI run |
|
🦞👀 Command router queued. I will update this comment with the next step. |
|
@clawsweeper status Report the exact-head review state for Status only. Do not repair, rebase, or merge. |
|
🦞👀 Reason: freeform assist requires an open issue or PR. Request: Report the exact-head review state for |
|
Maintainer acceptance: the fail-closed recovery behavior for malformed persisted plugin install records is intentional. Invalid config or SQLite state must remain non-mutating and require the documented manual recovery path. The two optional ClawSweeper Rank-up moves are satisfied on exact head I accept the compatibility and availability tradeoff: malformed historical records stop recovery until the operator follows the actionable Doctor guidance; valid records, including prototype-named IDs, continue through the canonical owner path. |
|
Merged via squash.
|
* fix(plugins): canonicalize install record persistence Preserve canonical fields, passthrough metadata, untouched record identity, and deterministic serialized ordering across SQLite and post-core handoff. Punchcard-Session: amber-workshop-workshop-36 Co-authored-by: Galin Iliev <[email protected]> * fix(doctor): block invalid plugin record mutations Preflight persisted and legacy install-record state before registry repair, package cleanup, generation retirement, archival, or state-directory moves. Punchcard-Session: amber-workshop-workshop-36 Co-authored-by: Galin Iliev <[email protected]> * fix(plugins): harden install record map ownership Punchcard-Session: amber-workshop-workshop-36 Co-authored-by: Galin Iliev <[email protected]> * fix(update): preserve special plugin ids in payload checks Punchcard-Session: amber-workshop-workshop-36 Co-authored-by: Galin Iliev <[email protected]> * test(doctor): assert canonical install record maps Punchcard-Session: amber-workshop-workshop-36 Co-authored-by: Galin Iliev <[email protected]> * test(doctor): preserve invalid plugin index fixtures Punchcard-Session: amber-workshop-workshop-36 Co-authored-by: Galin Iliev <[email protected]> --------- Co-authored-by: Galin Iliev <[email protected]>
Related: #120687
Related landed slice: #120906
What Problem This Solves
Fixes an issue where malformed or legacy plugin install-record state could be treated like missing state and enter destructive migration or recovery paths. The same owner path could lose legal plugin IDs such as
__proto__,constructor, andtoString, reorder numeric-looking or Unicode IDs inconsistently, and drop passthrough data or record identity during update and Doctor handoffs.Invalid persisted input must now stop before revisions, SQLite rewrites, archive/recovery work, package cleanup, generation retirement, host-link repair, or state-directory movement.
Why This Change Was Made
The install-record owner now has one canonical flow:
Doctor remains non-mutating for invalid state and reports a precise backup/manual recovery step.
Why a replacement PR is required
The source PR, #120687, is currently conflicting/dirty and has maintainer edits disabled, so the source branch cannot be repaired directly. Its agent-database portion was independently rebuilt and landed through #120906 with a materially different diff. This PR is the clean current-main replacement for the remaining plugin install-record owner work; it deliberately excludes fingerprint semantic changes, agent-database relocation, and SQLite schema changes.
Do not close #120687 until this replacement actually lands.
User Impact
Operators upgrading or repairing plugin state get deterministic, lossless install-record persistence. Invalid state fails closed without changing package files, revisions, archives, links, or databases, and Doctor tells the operator exactly how to recover. Updates and startup checks continue to recognize legal special-key plugin IDs.
Credit
Galin Iliev (@galiniliev) originated the investigation and historical intent in #120687. All six semantic task commits plus the signed current-main merge preserve Galin's
Co-authored-bycredit.Evidence
585212ebfe6a8875543892676b4a2b2239365d27.Punchcard-Session: amber-workshop-workshop-36and Galin co-author trailers.__proto__,constructor, andtoStringidentity/enumerability plus active__proto__smoke/path classification.__proto__,constructor, andtoStringas inert own properties in a null-prototype map.openclaw.json, repair the record, and rerunopenclaw doctor --fix.install_records_json, migration version, and update timestamp. Doctor instructed the operator to stop the Gateway, back up the database, delete only theinstalled_plugin_indexrow withindex_key='installed-plugin-index', and rerunopenclaw doctor --fix.node scripts/run-vitest.mjs --config test/vitest/vitest.unit-fast.config.ts src/plugins/installed-plugin-index-store.install-record-map.test.ts -t "persists legal prototype-named plugin ids as inert own properties" --reporter=verbose;node scripts/run-vitest.mjs --config test/vitest/vitest.commands.config.ts src/commands/doctor/shared/plugin-registry-migration.test.ts -t "rejects invalid SQLite install records without rewriting the row|rejects invalid config install records before recovery or persistence" --reporter=verbose;node scripts/run-vitest.mjs --config test/vitest/vitest.commands.config.ts src/commands/doctor-plugin-registry.test.ts -t "does not mutate stale packages when config install records are invalid|reports the supported manual recovery for invalid persisted records" --reporter=verbose.31310878068, job93238607739, found one stale current-main assertion that strictly expected a plain empty object. The focused load-path file now passes 2/2 while explicitly asserting no keys and a null prototype.31311350221, job93239605272, found one stale state-migration fixture that treated malformed legacy record metadata as a benign conflict. The selected test now passes while asserting the exact warning, absent notices, unchanged source bytes, and no archive.git diff --checkpass for the follow-up. The path-scoped oxlint wrapper did not reach the changed file because its Plugin SDK DTS prerequisite hit an unrelated local dependency/type mismatch inpackages/terminal-core/src/ansi.ts; hosted exact-head CI is the authority for that gate.git diff --checkpassed before publication.4cb33d48cddb527101123e3ff69f73a00fd7e049is a parent of the signed head; the only merge conflict was the repaired test assertion.openclaw/ci-gateis therefore the remaining validation gate.+573/-351(net+222). The growth establishes the canonical map/parser/serializer owner, private tri-state persisted-state inspection, atomic mutation barriers, and actionable Doctor recovery.+844/-90(net+754).No live provider or channel proof is claimed. No release, tag, package publication, fingerprint semantic change, agent-database relocation, or SQLite schema change is included.
AI-assisted: yes. The implementation and proof were independently reviewed before publication.