Skip to content

fix(matrix): preserve encrypted sync state across restarts - #148152

Merged
RomneyDa merged 1 commit into
mainfrom
fix/maturity-348158-matrix-runtime
Sep 14, 2026
Merged

RomneyDa merged 1 commit into
mainfrom
fix/maturity-348158-matrix-runtime

Conversation

@RomneyDa

Copy link
Copy Markdown
Member

What Problem This Solves

Fixes an issue where Matrix encrypted sync state could fail to persist during restart or catch-up because deferred callbacks no longer had access to the plugin invocation runtime.

Why This Change Was Made

The Matrix client now retains its instance-scoped state-store capability when it is constructed and passes that narrow capability through deferred IndexedDB restore and persistence paths. This preserves plugin isolation without introducing a global runtime fallback.

User Impact

Matrix accounts can restart, restore encrypted sync state, and continue incremental catch-up without losing persistence access after plugin registration completes.

Evidence

@clawsweeper

clawsweeper Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@RomneyDa
RomneyDa marked this pull request as ready for review September 14, 2026 09:47
@openclaw-barnacle openclaw-barnacle Bot added channel: matrix Channel integration: matrix size: S maintainer Maintainer-authored PR labels Sep 14, 2026
@clawsweeper

clawsweeper Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 14, 2026, 7:42 AM ET / 11:42 UTC (Revision 3).

ClawSweeper review

What this changes

The Matrix client retains its plugin-scoped storage capability so deferred encryption-state restores and saves continue working during restart and catch-up.

Merge readiness

✅ Ready for maintainer review

The repair remains useful on current main, and no introduced correctness defect was found. This maintainer-authored PR also remains protected from automatic closure.

Priority: P1
Reviewed head: 6601cbcd4909cb1308f9d515eee5211e123fbb59

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with complete production wiring and useful regression coverage; no blocking defect was found.
Proof confidence 🌊 off-meta tidepool Not applicable: The member-authored PR is exempt from the external-contributor proof gate. Its discussion reports successful restart/catch-up verification of the changed persistence path, but the linked campaign run does not independently establish after-fix execution at this head.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The member-authored PR is exempt from the external-contributor proof gate. Its discussion reports successful restart/catch-up verification of the changed persistence path, but the linked campaign run does not independently establish after-fix execution at this head.
Evidence reviewed 8 items Verified patch scope: The merge-base-to-head comparison contains only the six supplied Matrix files. The host-verified test merge likewise changes only those files relative to its pinned main parent; unrelated endpoint drift is not attributed to this PR.
Complete persistence wiring: Client construction captures runtime.state, and client-base passes it through restore, initial persistence, periodic persistence, and final shutdown persistence. Snapshot serialization, storage namespaces, database-prefix filtering, and cancellation checks are unchanged.
Current-main necessity: Current main still resolves getMatrixRuntime().state inside openSyncStore, rather than accepting the client-retained capability. Its client factory also lacks the capture.
Findings None None.
Security None None.

How this fits together

The Matrix plugin saves its in-memory encryption databases into OpenClaw’s SQLite storage. Startup restores those databases, while periodic and shutdown saves preserve keys needed for subsequent encrypted conversations.

flowchart TD
  A[Matrix account configuration] --> B[Create Matrix client]
  C[Plugin storage capability] --> B
  B --> D[Client retains storage capability]
  D --> E[Restore encryption databases]
  E --> F[Encrypted sync]
  F --> G[Periodic and shutdown saves]
  G --> H[SQLite snapshot]
  H --> E
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +29, Tests +42. Total +71 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 4 41 12 +29
Tests 2 43 1 +42
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 84 13 +71

Review metrics

None.

Technical review

Best possible solution:

Keep deferred encryption persistence attached to the client’s existing plugin-scoped storage owner while preserving snapshot formats and shutdown ordering.

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

Yes, from source: deferred persistence without the originating plugin scope reaches an ambient runtime lookup that can throw. The focused regression covers retained-capability recovery; this review did not execute a current-main reproduction.

Is this the best way to solve the issue?

Yes. Capturing the existing storage capability fixes the lifetime mismatch without adding a global fallback, another persistence owner, a public API, or a data migration.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P1: The reported runtime-scope failure breaks Matrix encrypted-state persistence during restart and incremental catch-up.
  • 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: The member-authored PR is exempt from the external-contributor proof gate. Its discussion reports successful restart/catch-up verification of the changed persistence path, but the linked campaign run does not independently establish after-fix execution at this head.

Evidence

What I checked:

  • Verified patch scope: The merge-base-to-head comparison contains only the six supplied Matrix files. The host-verified test merge likewise changes only those files relative to its pinned main parent; unrelated endpoint drift is not attributed to this PR. (6601cbcd4909)
  • Complete persistence wiring: Client construction captures runtime.state, and client-base passes it through restore, initial persistence, periodic persistence, and final shutdown persistence. Snapshot serialization, storage namespaces, database-prefix filtering, and cancellation checks are unchanged. (extensions/matrix/src/matrix/client/create-client.ts:96, 6601cbcd4909)
  • Current-main necessity: Current main still resolves getMatrixRuntime().state inside openSyncStore, rather than accepting the client-retained capability. Its client factory also lacks the capture. (extensions/matrix/src/matrix/crypto-state-store.ts:425, f5c8b6e43f49)
  • Latest-release comparison: The supplied latest release, v2026.9.4, also lacks runtime-state capture in the Matrix client factory; this comparison does not establish that every released execution path reproduces the failure. (extensions/matrix/src/matrix/client/create-client.ts, 3a9d69db306c)
  • Storage isolation and lifecycle: The captured store factory retains its runtime-bound plugin ID and performs the existing trusted-plugin check when invoked. Matrix’s sync cache already retains its store for deferred writes. The patch does not transfer capabilities between principals or change the storage authorization contract. (src/plugins/registry-runtime.ts:233, 6601cbcd4909)
  • Regression coverage and reported validation: The new persistence test replaces ambient runtime access with a throwing implementation, then checks that explicitly retained runtime access saves and restores the original records. The captured discussion reports 14/14 focused tests and successful real restart/catch-up verification. No tests were executed during this read-only review. (extensions/matrix/src/matrix/sdk/idb-persistence.test.ts:95, 6601cbcd4909)

Likely related people:

  • Vincent Koc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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.

History

Review history (2 earlier review cycles)
  • reviewed 2026-09-14T09:57:58.469Z sha f38a3586b5a4cce6789307958a71f7523b8fdf11 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-14T11:02:21.955Z sha a4dc613f6d849f04465172d08a0ab7242c07228e :: needs maintainer review before merge. :: none

@RomneyDa
RomneyDa force-pushed the fix/maturity-348158-matrix-runtime branch from f38a358 to a4dc613 Compare September 14, 2026 10:44
@RomneyDa

Copy link
Copy Markdown
Member Author

@clawsweeper review

Exact-head proof for a4dc613f6d8: focused Matrix runtime tests pass 14/14, pnpm check:changed passes, the real restart and catch-up scenario passes, and local P0-P2 autoreview is clean. Please refresh the review against this amended head.

@clawsweeper

clawsweeper Bot commented Sep 14, 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 exact_review_queue).
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 P1 High-priority user-facing bug, regression, or broken workflow. 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 Sep 14, 2026
@RomneyDa

Copy link
Copy Markdown
Member Author

Exact-head proof after rebase onto current main: Matrix create-client and persistence suites passed 14/14 at b0dcd77; the real restart/catch-up proof remains green. @clawsweeper review

@RomneyDa
RomneyDa force-pushed the fix/maturity-348158-matrix-runtime branch from b0dcd77 to 6601cbc Compare September 14, 2026 11:20
@RomneyDa

Copy link
Copy Markdown
Member Author

Exact-head source refresh: 6601cbc has the same reviewed tree as the tested rebased commit; Matrix create-client and persistence suites passed 14/14 and the real restart/catch-up proof remains green. @clawsweeper review

@RomneyDa
RomneyDa merged commit fbaa870 into main Sep 14, 2026
91 checks passed
@RomneyDa
RomneyDa deleted the fix/maturity-348158-matrix-runtime branch September 14, 2026 15:48
vincentkoc added a commit that referenced this pull request Sep 14, 2026
* commit '3c08384584f57787a26da9998488233fc15ccf7e': (122 commits)
  fix(agents): keep tool result summaries when middleware details exceed shape limits (#147805)
  test: make full-suite fixtures portable across runtimes (#148247)
  refactor(qa): share unknown confidence results (#148200)
  chore(android): remove unused test dependencies and duplicate Wear settings (#148231)
  test: reuse compiled preflight in startup fixtures (#148330)
  test(wizard): route recovery integration through database forks (#148337)
  refactor(plugins): simplify provider auth patch recursion (#147933)
  fix(cli): drain failed web capability output (#148234)
  refactor(android): remove unused production helpers (#148233)
  fix(plugins): scope feed integrity to hosted ClawHub (#148220)
  test(qa): compare Telegram entities semantically (#148219)
  test(qa): recognize native Slack exec progress rows (#148217)
  test(cron): distinguish repeated delivery incidents (#148151)
  test(qa): preserve restart command ownership (#148218)
  test(qa): isolate bundled skill CLI gateway state (#148150)
  test(qa): align process lifecycle contracts (#148149)
  improve(media): reduce metadata fetched during orphan cleanup (#148244)
  fix(matrix): retain sync state runtime for deferred persistence (#148152)
  test: deduplicate gateway watch exit fixtures (#148237)
  refactor(cli): derive daemon status contract from gatherer (#148108)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 15, 2026
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 P1 High-priority user-facing bug, regression, or broken workflow. 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