Skip to content

fix(matrix): prevent shared clients from colliding across accounts - #119667

Merged
Patrick-Erichsen merged 2 commits into
openclaw:mainfrom
Alix-007:alix/oc-t25-01-matrix-shared-key
Aug 6, 2026
Merged

Patrick-Erichsen merged 2 commits into
openclaw:mainfrom
Alix-007:alix/oc-t25-01-matrix-shared-key

Conversation

@Alix-007

@Alix-007 Alix-007 commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

AI-assisted: This change was developed with Codex.

What Problem This Solves

Fixes an issue where distinct Matrix authentication configurations could resolve to the same module-global shared client state when raw tuple fields formed the same delimiter-joined key. This could couple client identity, encryption preparation, startup state, and lease ownership across accounts.

The regression uses a historical Matrix user ID shape that Matrix clients are required to accept.

Why This Change Was Made

The shared-client identity tuple is now serialized as one JSON value instead of joining independently serialized fields with |. The same seven fields and boolean normalization remain part of the key, so ordinary sharing behavior is unchanged while field boundaries become unambiguous.

User Impact

Distinct Matrix accounts keep independent client, crypto, startup, and lease state even when their authentication values contain delimiter-shaped text. Repeated requests for the same account still share one client normally.

Evidence

  • Exact PR head: 6561fa6a08bd00d5e6a7d9a1640e12aaf067a66d.
  • Public Node 24 exact-head proof: run 31030735958, with immutable-source verification and downloadable terminal artifact.
  • The current shared-client generation suite passed 20/20 tests.
  • A separate production-path harness instantiated real MatrixClient objects for two delimiter-colliding auth tuples, confirmed distinct identities, confirmed same-auth reuse, verified that the first release kept the shared generation alive, and verified independent final replacement. Its marker reports real-client=true distinct=true same-auth-reused=true first-release-held=true first-release-final=true second-release-final=true secret-output=false.
  • Current upstream main at 414616f583897a161645d0b15faffb6c41542845 was merged without changing the two-file PR surface; the regression test now exercises the generation-lease API.
  • Exact-base reproduction at 29175dd11e90335e608543cd83b2ae66f5bd69d9 returned the first tuple's client for the second colliding tuple.
  • Targeted oxfmt, focused oxlint, and git diff --check passed.

@openclaw-barnacle openclaw-barnacle Bot added channel: matrix Channel integration: matrix size: S labels Aug 5, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 High-priority user-facing bug, regression, or broken workflow. labels Aug 5, 2026
@clawsweeper

clawsweeper Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 5, 2026, 4:31 PM ET / 20:31 UTC.

ClawSweeper review

What this changes

This PR serializes the complete Matrix account identity tuple as JSON so delimiter-containing authentication values cannot make separate accounts share one client generation.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

Keep open: current main still uses an ambiguous delimiter-joined Matrix shared-client key, while this PR repairs that owner boundary with focused regression and runtime evidence.

Priority: P1
Reviewed head: 6561fa6a08bd00d5e6a7d9a1640e12aaf067a66d

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused owner-boundary repair with strong exact-head runtime proof and no actionable review finding.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The PR body supplies exact-head production-path harness output showing collision isolation, same-account reuse, and independent lease finalization.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR body supplies exact-head production-path harness output showing collision isolation, same-account reuse, and independent lease finalization.
Evidence reviewed 5 items Current-main defect: Current main joins seven identity fields with |; the resulting key indexes both shared client states and pending client creation, so delimiter-shaped values can alias separate accounts.
Owner-boundary repair: The PR serializes the same ordered fields as one JSON array, preserving boolean and dispatcher-policy normalization while retaining unambiguous field boundaries.
Regression coverage: The added test proves formerly colliding tuples construct separate clients, retain same-account reuse, prepare crypto independently, and retire leases independently.
Findings None None.
Security None None.

How this fits together

The Matrix plugin maps account authentication to a process-local shared client generation, which owns startup, encryption preparation, leases, and retirement. Bootstrap and monitoring flows acquire those generations before performing Matrix work.

flowchart LR
  A[Matrix account authentication] --> B[Shared client identity key]
  B --> C{Existing generation?}
  C -->|yes| D[Reuse client lease]
  C -->|no| E[Create Matrix client]
  D --> F[Crypto and lifecycle]
  E --> F
  F --> G[Bootstrap and monitor flows]
Loading

Before merge

  • Complete next step (P2) - No repair lane is needed because the submitted patch is a coherent fix; it only needs ordinary maintainer review of GitHub's clean merge result.
Agent review details

Security

None.

PR surface

Source -2, Tests +44. Total +42 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 5 7 -2
Tests 1 44 0 +44
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 49 7 +42

Review metrics

Metric Value Why it matters
Production vs test LOC production +5/-7 (net -2); tests +44/-0 The repair reduces production code while adding focused collision and lifecycle coverage.

Stored data model

Persistent data-model change detected: serialized state: extensions/matrix/src/matrix/client/shared.ts. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best possible solution:

Merge the structured producer-side key and keep the collision-plus-lease regression as the canonical protection for Matrix shared-client identity.

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

Yes. The legacy key visibly maps the supplied delimiter-shaped tuples to the same joined string, and the exact-head harness records isolated real-client behavior after the change.

Is this the best way to solve the issue?

Yes. Encoding the existing ordered identity tuple once at the shared-client producer prevents aliasing without adding escaping rules, downstream guards, config, or a parallel lifecycle path.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 2db3431f4aa1.

Labels

Label justifications:

  • P1: A collision can make distinct configured Matrix accounts share client, crypto-startup, and lease lifecycle state.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body supplies exact-head production-path harness output showing collision isolation, same-account reuse, and independent lease finalization.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body supplies exact-head production-path harness output showing collision isolation, same-account reuse, and independent lease finalization.

Evidence

What I checked:

Likely related people:

  • vincentkoc: Authored the recent shared Matrix-client generation and retirement work that retained this key path. (role: recent area contributor; confidence: high; commits: a3419d4a4b4c, 6dbdcbda; files: extensions/matrix/src/matrix/client/shared.ts)
  • mordred: Historical Matrix multi-account work established the surrounding ownership boundary. (role: feature owner; confidence: medium; commits: caf5d2dd; files: extensions/matrix/src/matrix/client/shared.ts, extensions/matrix/src/matrix/client/types.ts)

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-08-05T16:08:15.600Z sha 2f115ff :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-05T17:46:36.188Z sha 6561fa6 :: needs maintainer review before merge. :: none

@Alix-007

Alix-007 commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 5, 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: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@Alix-007

Alix-007 commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 5, 2026
@Patrick-Erichsen Patrick-Erichsen self-assigned this Aug 6, 2026
@Patrick-Erichsen

Copy link
Copy Markdown
Contributor

Maintainer outcome for exact head 6561fa6a08bd00d5e6a7d9a1640e12aaf067a66d: qualified for landing. The structured authentication tuple fixes the delimiter collision at the shared Matrix-client owner, preserves same-account reuse, and already has convincing exact-head proof. No code change is requested; I’m continuing through the remaining autoreview, CI, ClawSweeper, and guarded merge gates.

@Patrick-Erichsen
Patrick-Erichsen merged commit f5849f1 into openclaw:main Aug 6, 2026
109 checks passed
@Patrick-Erichsen

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 6, 2026
vincentkoc added a commit to VACInc/openclaw that referenced this pull request Aug 6, 2026
…cope

* origin/main: (24 commits)
  fix(backup): skip transient gateway lock databases (openclaw#119782)
  test(agents): use canonical auth session fixtures (openclaw#119821)
  fix(memory): keep QMD file hints after stale docid misses (issue openclaw#113041) (openclaw#113515)
  test(doctor): align fast-path repair contracts (openclaw#119812)
  perf(agents): index subagent recovery ownership (openclaw#119793)
  fix(gateway): keep chat startup off catalog discovery (openclaw#119742)
  fix(test): keep TUI PTY suites in their owner lane (openclaw#119787)
  docs: correct dashboard auth precedence (openclaw#119785)
  docs: document control ui owner handoff
  fix: grant host-authorized control ui owner access
  fix(worktrees): preserve registered roots during orphan cleanup (openclaw#119709)
  fix(matrix): prevent shared client key collisions (openclaw#119667)
  fix(diagnostics-otel): propagate exported span context (openclaw#112283)
  fix(worker): isolate state observer failures (openclaw#117507)
  fix(qa): attest realized profile executions (openclaw#119761)
  fix(gateway): finish successful sessions after timestamp races (openclaw#119752)
  fix(agents): fence restart recovery lifecycle (openclaw#119776)
  fix(ui): preserve chat history and active run timing (openclaw#119729)
  improve(ollama): reduce inactive startup cost (openclaw#119745)
  improve(gateway): defer inactive plugin runtime imports (openclaw#119733)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: matrix Channel integration: matrix P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor 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.

2 participants