Skip to content

fix(matrix): preserve encryption keys across snapshot upgrades - #112919

Merged
steipete merged 4 commits into
mainfrom
fix/matrix-crypto-snapshot-doctor
Jul 23, 2026
Merged

steipete merged 4 commits into
mainfrom
fix/matrix-crypto-snapshot-doctor

Conversation

@steipete

@steipete steipete commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where Matrix users upgrading from releases that wrote crypto-idb-snapshot.json could have encryption state imported, renamed, or bypassed by the running client instead of by the explicit upgrade repair flow. This runtime fallback shipped in v2026.6.10 through #91100 (0566b969274) and could leave encryption keys split between a legacy sidecar and canonical SQLite state.

Why This Change Was Made

The existing Matrix legacy-crypto doctor migration is now the single owner for snapshot upgrades. openclaw doctor --fix reads the legacy snapshot under the same cross-process lock used by runtime persistence, imports it to SQLite, reads it back for structural/content verification, and only then moves the original bytes to a timestamped recovery archive. Partial or invalid SQLite writes are repaired from a valid source; valid conflicts keep SQLite canonical and archive the differing source; malformed sources are archived without deletion; filesystem read failures leave the source active.

The Matrix runtime now reads and writes SQLite only. If canonical state is missing or unusable while an active legacy snapshot exists, crypto startup and persistence fail closed with a typed, path-free diagnostic directing the operator to openclaw doctor --fix.

AI-assisted implementation; the final branch passed the repository's Codex autoreview gate.

User Impact

Upgrade behavior is explicit and one-time: run openclaw doctor --fix, then restart Matrix. Doctor preserves the original snapshot bytes in a timestamped archive, while normal runtime no longer lazily imports or renames legacy snapshots. Existing valid SQLite state remains canonical, and unreadable key material is never moved or discarded.

Release-note context: Matrix upgrades now migrate legacy crypto snapshots through doctor once; runtime no longer imports snapshot sidecars.

Evidence

  • Shipped-contract proof: v2026.6.10 contains the runtime fallback in extensions/matrix/src/matrix/sdk/idb-persistence.ts from refactor(matrix): store crypto sidecars in sqlite #91100 / 0566b969274.
  • OPENCLAW_HEAVY_CHECK_LOCK_SCOPE=worktree node scripts/run-vitest.mjs extensions/matrix/doctor-contract-api.test.ts extensions/matrix/src/matrix/sdk/idb-persistence.test.ts extensions/matrix/src/matrix/client/storage.test.ts — 3 files, 34 tests passed.
  • node scripts/check-changed.mjs — hosted Blacksmith Testbox exit 0 on the production-equivalent patch before the final test-only consolidation; extension production/test typechecks, all-extension lint, formatting, database-first legacy-store guard, sidecar-loader guard, and import-cycle check passed. Run: https://github.com/openclaw/openclaw/actions/runs/29981397679
  • Exact final head 4f56ea5817f6efe0b677e0a7103d6efba05c323e — CI run https://github.com/openclaw/openclaw/actions/runs/29982021488 completed successfully; 176 check runs reported zero pending and zero failed.
  • AR="$HOME/.claude/skills/autoreview/scripts/autoreview"; "$AR" --mode branch --base origin/main — clean, no accepted/actionable findings.
  • git diff --check — clean.
  • Numstat: 499 insertions / 503 deletions across 9 files (net -4). The doctor-side safety checks add explicit lock/verify/archive handling, paid for by deleting both runtime import paths and the obsolete fallback lock-order test module.

@openclaw-barnacle openclaw-barnacle Bot added channel: matrix Channel integration: matrix size: XL maintainer Maintainer-authored PR labels Jul 23, 2026
@steipete steipete self-assigned this Jul 23, 2026
@steipete
steipete marked this pull request as ready for review July 23, 2026 05:23
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 23, 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: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@steipete
steipete merged commit d893f79 into main Jul 23, 2026
172 of 176 checks passed
@steipete
steipete deleted the fix/matrix-crypto-snapshot-doctor branch July 23, 2026 06:25
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 23, 2026
…law#112919)

* fix(matrix): migrate legacy crypto snapshots via doctor

* fix(matrix): harden snapshot migration failures

* fix(matrix): preserve unreadable crypto snapshots

* test(matrix): consolidate crypto snapshot coverage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: matrix Channel integration: matrix maintainer Maintainer-authored PR size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant