Skip to content

fix: restore Matrix context reads in official installs - #147665

Merged
shakkernerd merged 4 commits into
openclaw:mainfrom
shakkernerd:fix/matrix-context-reads
Sep 14, 2026
Merged

shakkernerd merged 4 commits into
openclaw:mainfrom
shakkernerd:fix/matrix-context-reads

Conversation

@shakkernerd

@shakkernerd shakkernerd commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes Matrix message-tool context reads that are rejected after installing the official plugin from npm or ClawHub, even when the same read succeeds with the bundled plugin and the selected Matrix account allows the destination.

For example, an agent responding in one room cannot read messages from another explicitly allowed room because the installed plugin is restricted to the exact current conversation. Matrix already has provider-owned room and DM checks for these reads, but it does not participate in the host's live read-authority contract.

User Impact

The official Matrix plugin supports the same six scoped reads across bundled and installed registrations: read, reactions, list-pins, emoji-list, member-info, and channel-info.

The selected account's action settings and room/DM policy still govern access. Member profiles require membership in the authorized room. Custom emotes retain their existing combination of that room's packs and the account's personal pack. Verification, recovery-key access, mixed permissions operations, and message mutations keep their existing authorization requirements.

A completed, still-authorized read can return after normal one-off client cleanup. Actual caller or plugin revocation blocks late results, and a stopped client cannot start more network work.

Why This Change Was Made

Matrix now explicitly lists the six actions in readAuthorityActions. The shared host already recognizes these context actions; an adapter must still opt each action in separately. This uses the contract from #143341 and the complete target-alias prerequisite in #147492. The merged Discord metadata support in #147658 supplies the host eligibility needed for Matrix member and emoji reads. This PR preserves that dispatcher and adds Matrix participation. The selection repair in #147754 is included in the base.

Matrix has its own HTTP routes and injects a fetch implementation into matrix-js-sdk. Both routes now retain the submitting read's authority through DNS resolution, redirects, body consumption, and dispatcher cleanup. The action/client helpers recheck that same authority after awaited preparation and cleanup.

Encrypted reads also require shared SDK maintenance. The SDK's missing-key queue can process a later read under the first caller's asynchronous context. Crypto initialization, decryption retries, and that maintenance therefore run under the existing client's generation. A distinct read entered from an SDK callback retains its own caller check. This lets a valid read continue when an earlier caller expires, blocks a newly revoked caller inside a callback, and stops maintenance when its actual client closes.

Shared clients are attached to the exact registering plugin instance. Within this module’s shared client cache, acquisition under a replacement instance waits for the prior client to stop; late cleanup cannot stop its successor. Concurrent one-off preparation shares one crypto initialization, and shutdown joins pending initialization before closing the backend and releasing its asynchronous context.

Evidence

The final Matrix implementation and tests are byte-identical to validated source 941c883. The conflict resolution onto the landed Discord result keeps the target's dispatcher unchanged and adds Matrix's six-action documentation without replacing Discord's policy text. Proof retains its actual execution identities rather than relabeling earlier runs as the replayed head 6ed4e50.

  • All 26 registered Matrix cases pass on 941c883, using real handlers, SDK HTTP, host-created plugin instances, and normal client cleanup. They cover the six reads for bundled and official-installed registrations, room/action/account denials before provider access, membership before profile retrieval, caller and plugin revocation during preparation and content delivery, excluded actions, and partial declarations.
  • The complete Matrix suite passes in CI: 2,297 tests across all 143 tracked files. That run tested merge 4156bfd4 of 941c883 into 128bfff; Matrix implementation/test inputs are unchanged by those upstream changes. All 19 transport cases pass across JSON, raw, and SDK requests, covering initial and redirect DNS, body consumption, dispatcher cleanup, client shutdown, and a valid second read.
  • Both SDK-callback caller cases pass again on native 941c883. The original closed-caller case received provider data; it now rejects before physical HTTP while the active-caller control succeeds. This is the corrected autoreview finding, independently reviewed with its regression proof. The original implementation also fails 14 transport/lifecycle cases and four crypto-initialization cases covering duplicate initialization and shutdown before initialization finishes.
  • The production MatrixClient probe uses Matrix SDK 42.3.0, Rust crypto, the missing-key queue, encrypted events, and loopback HTTP. Caller B decrypts after caller A expires; A cannot receive content; stopping the client blocks further HTTP and leaves no SDK workers. Crypto-store and provider-fixture cleanup pass. This retained production probe supplements the fresh source and package runs.
  • Fresh matched core and Matrix package fixtures built from 941c883 pass full canonical core inventory/tarball checks, native npm and official ClawHub installation, SDK surface and runtime inspection, compiled-export and installed-entry byte checks, and all 16 behavior subprocesses (26 scenario cells). The 31 stages cover the six reads, policy denials, caller/plugin revocation points, successful cleanup, and unchanged installer configuration. Both registry fixtures stop and no task processes remain.
  • The freshly built Matrix entry imports successfully with peak RSS of 95.27 MiB against a 46.13 MiB bare-Node baseline. The package path and content inventories contain 9,693 and 9,692 entries respectively. Package fixtures use disposable 2026.9.5 metadata; source versions and dependencies are unchanged.
  • Generic compatibility and updater qualification is retained from fix: restore context reads for installed official Discord and Slack plugins #143341. Native installers on published core 2026.9.3 and 2026.9.4 reject packages requiring the new API before replacement. Actual published update drivers reach the matching candidate while preserving authored channel configuration, plugin entries, and workspace settings. The tested Matrix package declares pluginApi >=2026.9.5; this is a matching-core requirement, not compatibility with released core 2026.9.4 or an encrypted Matrix state-migration claim.
  • Native selection inspection includes all seven required Matrix entry/lifecycle/SDK/root regression targets. The remaining two entry-boundary files pass all 35 cases; five other entry/SDK files pass 40 cases in CI. Root integration lint and exact-base line/assertion ratchets pass natively. Formatting, Matrix/core lint, production types, and the core plugin-platform, extension-test and root-test type programs pass in CI. Independent corrective and final integration reviews have no unresolved findings.
  • The narrowed shared owner checks pass all 124 required cases across loader setters, host policy ownership, SQLite/runtime readiness, CLI/entry diagnostics, startup configuration, cold startup/live reload, and native test routing. Two earlier passing setter cases were retained; only a missed parameterized name and the unrun selections were executed afterward.

The completed CI run has one unrelated Docker-helper assertion failure, with the aggregate gate reporting that failure. The identical existing assertion was reproduced on unchanged 46ac2bc: it expects the old ClawHub fixture name while its consumed script uses the renamed fixture. All 16 relevant test/script/tooling inputs match the CI tree, and Matrix changes none of them. The existing repair is #148118; no Matrix behavior or test assertion was weakened.

Representative reproducible integration commands:

node scripts/run-vitest.mjs test/matrix-channel-read-authority.integration.test.ts test/matrix-transport-read-authority.integration.test.ts test/matrix-client-crypto-authority.integration.test.ts
node scripts/run-vitest.mjs src/channels/plugins/message-action-dispatch.registry.test.ts

Matched original and candidate reload captures reproduce the same pre-existing loss of a synthetic backup-key marker when an older client persists late; both clean controls retain it. This bounded persistence finding remains a separate non-blocking follow-up. The Matrix patch does not change the snapshot algorithm or Gateway reload policy.

Package tests use native installers with synthetic provider and registry responses. No release was published and no live Matrix service was used.

@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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: matrix Channel integration: matrix size: XL maintainer Maintainer-authored PR labels Sep 14, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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
@clawsweeper

clawsweeper Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 14, 2026, 7:31 AM ET / 11:31 UTC (Revision 5).

ClawSweeper review

What this changes

Restores six scoped Matrix context reads in official installations and preserves caller and plugin authorization through HTTP requests, crypto maintenance, and client cleanup.

Merge readiness

⛔ Blocked before merge - 1 item remains

This PR remains necessary: current main lacks Matrix’s read-authority participation. No blocking defect was found, and the updated package qualification resolves the previous review’s outstanding request.

Priority: P2
Reviewed head: 6ed4e50eeaed9e76927ff856d7f1dfb130e2f1a6

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, well-supported repair with no blocking findings and an explicitly qualified coordinated-release requirement.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (linked_artifact): The captured evidence exercises registered Matrix handlers and real HTTP, installed npm/ClawHub packages, and Rust-crypto maintenance, covering allowed reads, forbidden destinations and accounts, revocation before further I/O, and stale-result rejection. All introduced non-doc inputs match validated 941c883; the package-entry/import-cost follow-up is addressed. These are synthetic-provider boundary runs, not authenticated Matrix-service rollout evidence.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): The captured evidence exercises registered Matrix handlers and real HTTP, installed npm/ClawHub packages, and Rust-crypto maintenance, covering allowed reads, forbidden destinations and accounts, revocation before further I/O, and stale-result rejection. All introduced non-doc inputs match validated 941c883; the package-entry/import-cost follow-up is addressed. These are synthetic-provider boundary runs, not authenticated Matrix-service rollout evidence.
Evidence reviewed 8 items Current main still needs the Matrix opt-in: Current main advertises Matrix reads and provider-owned gates but has no readAuthorityActions declaration. The dispatcher requires that explicit declaration for official installed registrations; the merged Discord and Slack prerequisites do not supply Matrix participation.
Prior validated source matches the reviewed implementation: Compared GitHub’s complete recursive tree for 941c88346f120bb486379cc31fa718145d211913 with local HEAD blob identities for all 20 introduced non-doc files: zero differences. Local historical comparison could not retrieve the older object; the GitHub tree comparison independently established equivalence. No tests or target code were executed during this review.
Registered authority boundary coverage: The inspected harness uses host-created plugin instances, actual Matrix handlers and SDK HTTP against loopback. It covers six reads under both registration forms, denied rooms/actions/accounts, nonmember profile rejection, caller/plugin revocation, and excluded actions. The captured PR body reports all 26 cases passing on the matching validated source.
Findings None None.
Security None None.

How this fits together

OpenClaw’s message tool delegates Matrix reads to the selected account’s room and DM policies. The Matrix client then retrieves provider data while the host controls whether the originating caller and plugin instance remain authorized.

flowchart TD
  A[Agent message tool] --> B[Host caller and plugin authority]
  B --> C[Matrix account and room policy]
  C --> D[Shared Matrix client]
  D --> E[HTTP and crypto maintenance]
  E --> F[Authorized result delivery]
  B --> F
  G[Plugin disposal] --> D
Loading

Before merge

  • Resolve merge risk (P1) - Publishing this Matrix implementation with metadata that admits released core 2026.9.4 would cause an unavailable SDK export failure; distribution must retain the qualified matching-core API floor.
Agent review details

Security

None.

PR surface

Source +258, Tests +1263, Docs +6. Total +1527 across 22 files.

View PR surface stats
Area Files Added Removed Net
Source 13 354 96 +258
Tests 7 1272 9 +1263
Docs 2 6 0 +6
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 22 1632 105 +1527

Review metrics

Metric Value Why it matters
Production versus test growth production +354/-96; tests +1,272/-9 Production growth implements request and client lifetime ownership; most added coverage exercises revocation, cleanup, and installation parity.
Existing reads restored 6 actions; 0 new configuration options The adapter opts existing capabilities into an established host contract without adding user settings.

Merge-risk options

Maintainer options:

  1. Retain coordinated package alignment (recommended)
    Accept the documented matching-core requirement and keep canonical release tooling responsible for enforcing the qualified plugin API floor.

Technical review

Best possible solution:

Keep Matrix on the existing host read-authority contract and distribute it through coordinated core/plugin version alignment with the qualified API floor.

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

Yes: current main’s missing Matrix opt-in causes the dispatcher to enforce exact-current-conversation access for installed plugins. Source and supplied before/after boundary evidence establish the path; this read-only review did not execute it.

Is this the best way to solve the issue?

Yes: the patch reuses the established host authority contract and Matrix policy owner, with client-generation handling for shared crypto work and verified preservation of the previously tested implementation.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: Repairs scoped context retrieval for official Matrix installations with a limited channel-specific blast radius.
  • merge-risk: 🚨 compatibility: The new SDK import requires coordinated package API metadata because released core 2026.9.4 lacks the export.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (linked_artifact): The captured evidence exercises registered Matrix handlers and real HTTP, installed npm/ClawHub packages, and Rust-crypto maintenance, covering allowed reads, forbidden destinations and accounts, revocation before further I/O, and stale-result rejection. All introduced non-doc inputs match validated 941c883; the package-entry/import-cost follow-up is addressed. These are synthetic-provider boundary runs, not authenticated Matrix-service rollout evidence.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured evidence exercises registered Matrix handlers and real HTTP, installed npm/ClawHub packages, and Rust-crypto maintenance, covering allowed reads, forbidden destinations and accounts, revocation before further I/O, and stale-result rejection. All introduced non-doc inputs match validated 941c883; the package-entry/import-cost follow-up is addressed. These are synthetic-provider boundary runs, not authenticated Matrix-service rollout evidence.

Evidence

What I checked:

  • Current main still needs the Matrix opt-in: Current main advertises Matrix reads and provider-owned gates but has no readAuthorityActions declaration. The dispatcher requires that explicit declaration for official installed registrations; the merged Discord and Slack prerequisites do not supply Matrix participation. (extensions/matrix/src/actions.ts:126, ee0cf1662306)
  • Prior validated source matches the reviewed implementation: Compared GitHub’s complete recursive tree for 941c88346f120bb486379cc31fa718145d211913 with local HEAD blob identities for all 20 introduced non-doc files: zero differences. Local historical comparison could not retrieve the older object; the GitHub tree comparison independently established equivalence. No tests or target code were executed during this review. (6ed4e50eeaed)
  • Registered authority boundary coverage: The inspected harness uses host-created plugin instances, actual Matrix handlers and SDK HTTP against loopback. It covers six reads under both registration forms, denied rooms/actions/accounts, nonmember profile rejection, caller/plugin revocation, and excluded actions. The captured PR body reports all 26 cases passing on the matching validated source. (test/matrix-channel-read-authority.integration.test.ts:209, 6ed4e50eeaed)
  • Transport and crypto authority remain distinct: Transport retains the submitted authority through DNS, redirects, body reads and cleanup. Crypto maintenance uses client-generation authority while a distinct nested reader retains its own callback. The captured body reports real Rust-crypto/loopback recovery for reader B after reader A expires, rejection of A’s content, and blocked HTTP after client shutdown; mocked transport regressions supplement that production probe. (extensions/matrix/src/matrix/sdk/client-base.ts:124, 6ed4e50eeaed)
  • Dependency contract inspected: The patch directly wraps matrix-js-sdk decryptEventIfNeeded and supplies its fetch implementation, establishing the dependency signal. At pinned v42.3.0, decryptEventIfNeeded starts decryption and returns the event’s pending promise; the inspected backup downloader queues missing-key requests behind a shared download loop. GitHub resolves this dependency tag to the recorded SHA. (src/client.ts:6388, 4419a679fa4b)
  • Previous package qualification request addressed: The captured PR body reports native npm and official ClawHub installation of matching packages built from 941c883, 31 successful stages, 26 behavior cells, compiled-entry checks, and entry import peak RSS of 95.27 MiB against 46.13 MiB baseline. It explicitly preserves the execution identity and uses disposable 2026.9.5 metadata. Published-driver upgrade and old-core rejection qualification is retained from fix: restore context reads for installed official Discord and Slack plugins #143341. (941c88346f12)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • shakkernerd: 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 (4 earlier review cycles)
  • reviewed 2026-09-14T01:33:20.075Z sha 5cd15ab3eabd0e52f9eab20cbff8ea303e73a7f1 :: blocked before merge. :: none
  • reviewed 2026-09-14T03:14:44.637Z sha 5cd15ab3eabd0e52f9eab20cbff8ea303e73a7f1 :: blocked before merge. :: none
  • reviewed 2026-09-14T09:29:46.297Z sha 941c88346f120bb486379cc31fa718145d211913 :: blocked before merge. :: none
  • reviewed 2026-09-14T09:54:57.584Z sha 941c88346f120bb486379cc31fa718145d211913 :: blocked before merge. :: none

@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Sep 14, 2026
shakkernerd added a commit that referenced this pull request Sep 14, 2026
Preserve complete affected-test selection for common source names while retaining existing helper and tooling routing.

Refs #147665.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 14, 2026
Preserve complete affected-test selection for common source names while retaining existing helper and tooling routing.

Refs openclaw#147665.
@shakkernerd
shakkernerd force-pushed the fix/matrix-context-reads branch from 5cd15ab to 941c883 Compare September 14, 2026 09:02
@shakkernerd
shakkernerd requested a review from a team as a code owner September 14, 2026 09:02
@shakkernerd
shakkernerd changed the base branch from stack/official-plugin-reads to main September 14, 2026 09:03
@openclaw-barnacle openclaw-barnacle Bot added channel: discord Channel integration: discord channel: imessage Channel integration: imessage channel: mattermost Channel integration: mattermost channel: msteams Channel integration: msteams channel: nextcloud-talk Channel integration: nextcloud-talk channel: nostr Channel integration: nostr channel: signal Channel integration: signal channel: slack Channel integration: slack channel: telegram Channel integration: telegram channel: voice-call Channel integration: voice-call app: android App: android app: ios App: ios app: macos App: macos labels Sep 14, 2026
@openclaw-barnacle openclaw-barnacle Bot added extensions: crabbox channel: reef Channel integration: reef app: linux extensions: browser extensions: groq and removed channel: discord Channel integration: discord channel: imessage Channel integration: imessage channel: mattermost Channel integration: mattermost channel: msteams Channel integration: msteams channel: nextcloud-talk Channel integration: nextcloud-talk channel: nostr Channel integration: nostr channel: signal Channel integration: signal channel: slack Channel integration: slack channel: telegram Channel integration: telegram channel: voice-call Channel integration: voice-call app: android App: android app: ios App: ios app: macos App: macos app: web-ui App: web-ui labels Sep 14, 2026
@shakkernerd

Copy link
Copy Markdown
Contributor Author

Fixed: scoped Matrix context reads now work in official npm and ClawHub installs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: matrix Channel integration: matrix docs Improvements or additions to documentation maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL 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