Skip to content

matrix: persist approval reaction targets best-effort - #75586

Merged
amknight merged 2 commits into
mainfrom
ak/plugin-state-matrix-default-on
May 3, 2026
Merged

amknight merged 2 commits into
mainfrom
ak/plugin-state-matrix-default-on

Conversation

@amknight

@amknight amknight commented May 1, 2026

Copy link
Copy Markdown
Member

Summary

Split from #75053. This migrates only Matrix approval reaction targets to best-effort SDK-backed persistence behind the existing in-memory target map.

Matrix still resolves reaction targets from memory first. Once the Matrix runtime is available, pending approval reaction targets mirror to api.runtime.state.openKeyedStore namespace matrix.approval-reactions. After a Gateway restart, reactions on still-pending approval prompts can resolve from the persisted target until the prompt TTL expires.

If the SQLite-backed store is unavailable or any persistent operation fails, Matrix logs the failure, disables persistent access for the process, and keeps the previous process-local behavior.

Files / behavior

  • extensions/matrix/src/approval-reactions.ts
    • adds best-effort persistent register/lookup/delete for versioned reaction-target records
    • keeps memory as the hot/source-of-truth path
  • extensions/matrix/src/approval-handler.runtime.ts
    • records/unregisters reaction targets without config-gating
  • extensions/matrix/src/matrix/monitor/reaction-events.ts
    • uses persistence-aware target lookup in the existing async reaction flow
  • extensions/matrix/src/runtime.ts
    • exposes optional runtime access for graceful no-op/fallback behavior
  • Matrix channel docs and changelog updated.

Validation

Local from ../openclaw-plugin-state-matrix-default-on:

  • pnpm test extensions/matrix/src/approval-reactions.test.ts extensions/matrix/src/matrix/monitor/reaction-events.test.ts extensions/matrix/src/approval-handler.runtime.test.ts — passed
  • pnpm exec oxfmt --check --threads=1 <touched ts files> — passed
  • git diff HEAD --check — passed
  • pnpm check:changed — passed

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: matrix Channel integration: matrix size: M maintainer Maintainer-authored PR labels May 1, 2026
@clawsweeper

clawsweeper Bot commented May 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

Summary
The PR adds best-effort SDK keyed-store persistence for Matrix approval reaction target bindings behind the in-memory map, wires inbound Matrix reactions to await persisted lookup on cache miss, updates Matrix reaction tests, and adds a changelog entry.

Reproducibility: not applicable. as a feature PR. Source inspection gives a high-confidence verification path: current main keeps Matrix approval reaction targets process-local, while the PR adds SDK-store register/lookup/delete behind that cache.

Next step before merge
Protected maintainer-labeled feature PR has no discrete narrow code defect; next action is maintainer review, CI completion, and sequencing against #75053.

Security
Cleared: The diff changes Matrix plugin runtime/test code and the changelog, with no workflow, dependency-source, lockfile, install/build-script, publishing, permission, or secret-handling changes.

Review details

Best possible solution:

Land this Matrix-only split after maintainer acceptance and exact-head validation, or fold the Matrix portion into #75053 if maintainers choose the broader migration.

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

Not applicable as a feature PR. Source inspection gives a high-confidence verification path: current main keeps Matrix approval reaction targets process-local, while the PR adds SDK-store register/lookup/delete behind that cache.

Is this the best way to solve the issue?

Unclear pending maintainer choice. The implementation is narrow and consistent with adjacent Slack/Discord best-effort persistence, but the best landing path depends on maintainer sequencing versus #75053 and completed exact-head checks.

Acceptance criteria:

  • pnpm test extensions/matrix/src/approval-reactions.test.ts extensions/matrix/src/matrix/monitor/reaction-events.test.ts extensions/matrix/src/approval-handler.runtime.test.ts
  • pnpm check:changed

What I checked:

  • Current main is process-local for Matrix approval reaction targets: matrixApprovalReactionTargets is a module-local Map, and register, unregister, and resolve operate against that in-memory structure on current main. (extensions/matrix/src/approval-reactions.ts:40, 95cee64ca6e8)
  • Current main reaction handling uses the in-memory resolver: Inbound Matrix reactions call resolveMatrixApprovalReactionTarget before falling through to generic reaction notifications, so restart recovery is not present on main. (extensions/matrix/src/matrix/monitor/reaction-events.ts:113, 95cee64ca6e8)
  • PR adds keyed-store persistence behind the Matrix cache: The net PR diff adds the matrix.approval-reactions namespace, opens runtime.state.openKeyedStore, writes versioned targets with TTL, deletes on unregister, and adds an async persistent lookup path. (extensions/matrix/src/approval-reactions.ts:22, 02f924a8861a)
  • PR wires persistence into pending approval and inbound reaction flow: bindPending now passes the pending view TTL into target registration, and handleInboundMatrixReaction awaits resolveMatrixApprovalReactionTargetWithPersistence. (extensions/matrix/src/approval-handler.runtime.ts:527, 02f924a8861a)
  • SDK store contract supports the proposed persistence shape: The plugin state store exposes register, lookup, consume, delete, entries, and clear with namespace, max-entry, value-size, and TTL validation; docs describe keyed stores as restart-durable and bundled-plugin scoped. (src/plugin-state/plugin-state-store.ts:211, 95cee64ca6e8)
  • Adjacent main history uses the same best-effort pattern: Current main already has Slack and Discord best-effort keyed-store persistence using optional plugin runtimes and failure-disable fallback, which makes this Matrix split consistent with adjacent merged work. (extensions/slack/src/sent-thread-cache.ts:69, 95cee64ca6e8)

Likely related people:

  • gumadeiras: Remote file history shows gumadeiras introduced Matrix exec approval reaction shortcuts and later centralized native approval lifecycle behavior in the affected Matrix files. (role: introduced behavior / Matrix approval owner; confidence: high; commits: 0aaf7531481d, d78512b09d1d, af4a2faa1da0; files: extensions/matrix/src/approval-reactions.ts, extensions/matrix/src/approval-handler.runtime.ts, extensions/matrix/src/matrix/monitor/reaction-events.ts)
  • steipete: Recent path history shows Matrix reaction import-boundary work and plugin SDK/runtime boundary refactors adjacent to the files and seam used by this PR. (role: recent maintainer / runtime boundary maintainer; confidence: high; commits: 0d7d1aa09cf3, 9b21540a4e3b, bac3d26fe76b; files: extensions/matrix/src/approval-reactions.ts, extensions/matrix/src/matrix/monitor/reaction-events.ts, extensions/matrix/src/approval-handler.runtime.ts)
  • amknight: Separate from opening this PR, current-main history shows amknight introduced the SQLite plugin state store and landed adjacent Slack/Discord best-effort persistence changes that this Matrix PR follows. (role: adjacent SDK state-store and persistence owner; confidence: high; commits: bbf985d50a64, d0ec3d1f09b0, 6c55106c807d; files: src/plugin-state/plugin-state-store.ts, extensions/slack/src/sent-thread-cache.ts, extensions/discord/src/components-registry.ts)

Remaining risk / open question:

  • Exact-head CI was still in progress at review time, so merge readiness needs completed green checks or maintainer triage of any remaining non-green jobs.
  • Maintainers still need to choose whether this Matrix-only split should land independently or be folded into the broader channels: make plugin state persistence best effort by default #75053 default-on persistence draft.

Codex review notes: model gpt-5.5, reasoning high; reviewed against 95cee64ca6e8.

@amknight
amknight marked this pull request as ready for review May 1, 2026 12:21
@amknight
amknight force-pushed the ak/plugin-state-matrix-default-on branch from e999ccb to 38b87fe Compare May 1, 2026 12:22
@openclaw-barnacle openclaw-barnacle Bot removed the docs Improvements or additions to documentation label May 1, 2026
@amknight
amknight force-pushed the ak/plugin-state-matrix-default-on branch from 38b87fe to 02f924a Compare May 3, 2026 06:52
@amknight
amknight merged commit f27ecff into main May 3, 2026
95 of 97 checks passed
@amknight
amknight deleted the ak/plugin-state-matrix-default-on branch May 3, 2026 07:17
vincentkoc added a commit that referenced this pull request May 3, 2026
…eleased

Both #75585 (msteams sent-message marker persistence) and #75586 (matrix
approval reaction target persistence) landed on main 2026-05-03 but
appended their changelog entries under `## 2026.4.30`, which was
finalized on 2026-05-01. Move them under `## Unreleased ### Fixes` so
the released section stays frozen and the new fixes are credited in the
right release window. Thanks @amknight.
lxe pushed a commit to lxe/openclaw that referenced this pull request May 6, 2026
* matrix: persist approval reaction targets best-effort

* docs: refine matrix approval changelog
lxe pushed a commit to lxe/openclaw that referenced this pull request May 6, 2026
…eleased

Both openclaw#75585 (msteams sent-message marker persistence) and openclaw#75586 (matrix
approval reaction target persistence) landed on main 2026-05-03 but
appended their changelog entries under `## 2026.4.30`, which was
finalized on 2026-05-01. Move them under `## Unreleased ### Fixes` so
the released section stays frozen and the new fixes are credited in the
right release window. Thanks @amknight.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
* matrix: persist approval reaction targets best-effort

* docs: refine matrix approval changelog
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
…eleased

Both openclaw#75585 (msteams sent-message marker persistence) and openclaw#75586 (matrix
approval reaction target persistence) landed on main 2026-05-03 but
appended their changelog entries under `## 2026.4.30`, which was
finalized on 2026-05-01. Move them under `## Unreleased ### Fixes` so
the released section stays frozen and the new fixes are credited in the
right release window. Thanks @amknight.
jameslcowan pushed a commit to jameslcowan/openclaw that referenced this pull request Jun 2, 2026
* matrix: persist approval reaction targets best-effort

* docs: refine matrix approval changelog
jameslcowan pushed a commit to jameslcowan/openclaw that referenced this pull request Jun 2, 2026
…eleased

Both openclaw#75585 (msteams sent-message marker persistence) and openclaw#75586 (matrix
approval reaction target persistence) landed on main 2026-05-03 but
appended their changelog entries under `## 2026.4.30`, which was
finalized on 2026-05-01. Move them under `## Unreleased ### Fixes` so
the released section stays frozen and the new fixes are credited in the
right release window. Thanks @amknight.
sablehead pushed a commit to sablehead/openclaw that referenced this pull request Jun 10, 2026
* matrix: persist approval reaction targets best-effort

* docs: refine matrix approval changelog
sablehead pushed a commit to sablehead/openclaw that referenced this pull request Jun 10, 2026
…eleased

Both openclaw#75585 (msteams sent-message marker persistence) and openclaw#75586 (matrix
approval reaction target persistence) landed on main 2026-05-03 but
appended their changelog entries under `## 2026.4.30`, which was
finalized on 2026-05-01. Move them under `## Unreleased ### Fixes` so
the released section stays frozen and the new fixes are credited in the
right release window. Thanks @amknight.
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: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant