Skip to content

fix(matrix): recover providers after disconnected sync stop - #125362

Merged
jalehman merged 3 commits into
openclaw:mainfrom
bdjben:codex/fix-matrix-sync-poison-recovery
Aug 19, 2026
Merged

jalehman merged 3 commits into
openclaw:mainfrom
bdjben:codex/fix-matrix-sync-poison-recovery

Conversation

@bdjben

@bdjben bdjben commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

A Matrix provider that is restarted while matrix-js-sdk classic sync is parked in its disconnected keepalive path can become permanently unrecoverable inside the gateway process.

The SDK's SyncApi.stop() fences that path, but version 41.9.0 does not emit a later STOPPED event there. OpenClaw waited only for STOPPED, timed out after five seconds, and retained the resulting poisonError in the keyed shared-client state. Every provider auto-restart then synchronously rethrew the old error instead of creating a new Matrix client.

On a real six-account deployment, Synapse and nginx recovered, but every OpenClaw Matrix account remained stopped and disconnected until the gateway process was replaced.

Why This Change Was Made

This patch makes shutdown match the exact pinned SDK contract while preserving fail-closed cursor handling:

  1. Freeze sync-cursor persistence before stopping classic sync, as before.
  2. For SDK ERROR/RECONNECTING, capture the actual parked keepalive resolver.
  3. Call protected SyncApi.stop().
  4. Settle without waiting for STOPPED only when the exact captured resolver is still installed; clear and reject it with the SDK's own SyncApi.stop() was called reason so the parked SDK task unwinds.
  5. If no resolver exists, or it was replaced during stop, retain the existing real-STOPPED wait and five-second fail-closed timeout.
  6. Memoize both successful and failed quiescence for the client generation, making the production quiesceSync() -> stopAndPersist() double call idempotent and preventing a timed-out generation from later persisting an untrusted cursor.
  7. After a poisoned generation has drained leases and called stopWithoutPersist(), evict it from the shared-client registry in finally. The current caller still receives the original error, but a later provider retry creates a genuinely fresh client instead of reusing cached poison.

The exact SDK version assertion remains in place. This does not change Matrix dependencies or relax the timeout for active sync work.

User Impact

Before this change, one disconnected health-monitor restart could strand a Matrix account for the lifetime of the gateway process. Provider auto-restart exhausted all attempts while replaying a stale five-second error in milliseconds.

After this change, the pinned SDK's parked keepalive path quiesces deterministically. Genuine uncertainty still discards the pending cursor and fails closed, but the discarded generation no longer poisons every future provider acquisition.

Evidence

Production account labels below are anonymized consistently as agent1 through agent6; timestamps, durations, versions, state transitions, and account cardinality are unchanged.

Pinned matrix-js-sdk source contract

This source proof is independent of a live deployment: both sides of the comparison are commit-pinned. The Matrix extension pins matrix-js-sdk to exactly 41.9.0, whose v41.9.0 tag resolves to upstream commit ab387673152848cf676d264003b17f2e7e780370. The PR head is 77f4df4e36dc5aa8d50d9c26c94aa1e2e7b3c3bc.

The pinned SDK establishes the failure contract directly:

  1. SyncApi owns the private connectionReturnedResolvers used by disconnected keepalive.
  2. SyncApi.stop() sets running = false, aborts the current request, and clears keepAliveTimer, but it neither settles nor clears connectionReturnedResolvers.
  3. After a sync error, onSyncError() starts keepalive, publishes RECONNECTING or ERROR, and awaits that resolver-backed promise. startKeepAlives() schedules the timer and creates the resolver. Clearing the timer in stop() can therefore leave the awaited promise unsettled, so execution does not reach the SDK's normal STOPPED emission.
  4. The SDK's own stopped-keepalive branch defines the missing terminal action: pokeKeepAlive() rejects the resolver with exactly SyncApi.stop() was called, clears it, and returns without emitting STOPPED.

The PR mirrors only that exact terminal action. It asserts SDK version 41.9.0 before crossing the private boundary, verifies the object is the classic SyncApi, captures a resolver only from pre-stop ERROR/RECONNECTING, calls stop(), then clears and rejects only if the same resolver identity is still installed. If the state is active, no resolver exists, or the resolver was replaced, the existing real-STOPPED wait and fail-closed cursor discard remain in force. The patch deliberately does not call retryImmediately(), which routes through startKeepAlives(0) and can create a replacement resolver.

This is intentionally narrow reliance on one private field in one exact SDK version, guarded by both a version assertion and resolver-identity check. A future SDK change fails closed rather than silently using a changed private contract. Whether OpenClaw should carry that bounded private-field dependency remains an explicit maintainer decision.

Evidence scope

The commit-pinned SDK comparison remains independent of deployment state. The first production-after trace below is retained as evidence for built behavior commit c17e4ff4. A second production-after trace now covers the final PR head 77f4df4e applied to exact integration head e8a5035, which was 299 commits ahead of the cut used for the original PR submission. That newer trace exercises all six production accounts through the disconnected health-restart path and proves recovery without replacing the gateway process.

Production before: six accounts remained poisoned after the server recovered

Incident runtime:

  • OpenClaw 2026.8.1, gateway source 793669c8f6dd
  • Current PR base 1ea18c8cd8c; the relevant Matrix files were byte-identical between those revisions
  • Bundled Matrix plugin 2026.8.1
  • matrix-js-sdk 41.9.0
  • Synapse 1.150.0; nginx 1.29.8

Initial failure chain on 2026-08-17 (UTC+03:00):

18:57:04.519 [matrix:agent1] health-monitor: restarting (reason: disconnected)
18:57:09.653 [matrix:agent2] health-monitor: restarting (reason: disconnected)
18:57:12.631 Sync startup aborted with an error: SyncApi.stop() was called
18:57:14.659 [matrix:agent3] health-monitor: restarting (reason: disconnected)
18:57:19.665 [matrix:agent4] health-monitor: restarting (reason: disconnected)
18:57:24.672 [matrix:agent5] health-monitor: restarting (reason: disconnected)
18:57:30.363 [matrix:agent6] health-monitor: restarting (reason: disconnected)

Before the final failed retry cycle, the homeserver path was independently healthy:

20:46:45 GET :8008/_matrix/client/versions -> HTTP 200 (1.722 ms)
20:46:45 GET :8010/_matrix/client/versions -> HTTP 200 (1.940 ms)
20:46:45 GET :8086/health -> HTTP 200
20:46:45 GET :8087/health -> HTTP 200
20:46:45 GET :9088/health -> HTTP 200
20:46:45 GET :9089/health -> HTTP 200

Nevertheless, attempt 10/10 for every account replayed the nominal 5000ms error in only 2-5 ms:

Account Provider start Same cached error Elapsed
agent4 20:48:20.242 20:48:20.247 5 ms
agent3 20:48:20.249 20:48:20.252 3 ms
agent5 20:48:23.679 20:48:23.681 2 ms
agent1 20:48:27.177 20:48:27.180 3 ms
agent2 20:48:27.257 20:48:27.259 2 ms
agent6 20:48:29.984 20:48:29.986 2 ms

At 20:49:19, the reachable gateway reported all six configured accounts as enabled/configured but stopped, disconnected, and in health error with Matrix classic sync did not reach STOPPED within 5000ms. The 2-5 ms rethrows prove cached poison rather than a fresh five-second server timeout.

Regression proof

On unmodified main, the new tests failed at both causal boundaries while the prior 158 owner-suite tests passed:

  • disconnected keepalive quiescence remained pending waiting for an event the pinned SDK never emits;
  • acquisition after poisoned retirement rethrew the cached timeout and created no replacement client.

On this branch:

pnpm test extensions/matrix/src/matrix/sdk.test.ts extensions/matrix/src/matrix/client/shared.test.ts
Test Files  2 passed (2)
Tests       163 passed (163)

pnpm test:extension matrix
Test Files  122 passed (122)
Tests       1931 passed (1931)

pnpm build
exit 0

Coverage includes parked ERROR and RECONNECTING, stale ERROR without a resolver, active SYNCING, resolver replacement during stop, double quiescence through stopAndPersist(), permanent rejection memoization after cursor discard, and fresh acquisition after poisoned retirement.

Production after

The exact built head c17e4ff4e41958327d336e83846f6003a959bbb6 was applied to the incident installation with one ordinary managed-gateway restart at 21:04:50. No force restart or repeated restart was used. The old process completed shutdown cleanly in 1.749 seconds. The replacement process then completed the installation's known slow SQLite startup and reported:

21:09:26.683 http server listening (...; 168.5s)
21:09:45.982 [agent1] starting provider
21:09:45.982 [agent2] starting provider
21:09:45.983 [agent3] starting provider
21:09:45.983 [agent4] starting provider
21:09:45.983 [agent5] starting provider
21:09:45.983 [agent6] starting provider
21:09:46.054 gateway ready
21:09:47.799 matrix: logged in as agent5
21:09:47.829 matrix: logged in as agent6
21:09:47.837 matrix: logged in as agent1
21:09:47.850 matrix: logged in as agent2
21:09:47.858 matrix: logged in as agent4
21:09:47.874 matrix: logged in as agent3

At 21:10:04, a live gateway status query reported each of the six configured accounts with:

running=true
connected=true
healthState=healthy
lifecycle=ready
restartPending=false
reconnectAttempts=0
lastError=null

The first post-start syncs included transient nginx 502s, then recovered in-process: all six clients logged Resuming queue after resumed sync instead of entering the old cached-poison loop. The gateway also recovered four real pending Matrix deliveries between 21:09:50.337 and 21:09:51.085; the delivery summary was 4 recovered, 0 failed, 0 skipped, 0 deferred.

Finally, a unique live probe traversed the complete path through an existing two-member room: Matrix user -> homeserver -> recovered OpenClaw agent5 provider -> agent -> Matrix reply. The reply matched the requested probe exactly. The homeserver recorded inbound at 21:14:05.629 and outbound at 21:14:16.162, a 10.533-second round trip (10.652 seconds client-observed). Sanitized correlation hashes: room c98e15387b9d, inbound event 9d3a5bdbcf2c, outbound event d207b143fabb. The ephemeral client login used for the probe was revoked afterward.

No Matrix classic sync did not reach STOPPED within 5000ms error occurred after the patched process started.

Production after: final PR head on exact integration head e8a5035

The final PR head 77f4df4e36dc5aa8d50d9c26c94aa1e2e7b3c3bc was applied to exact integration head e8a5035ca6bf2604665aad6c54d2c346221bc3a6, which was 299 commits ahead of the cut used for the original PR submission. The running composite revision was d5f8d87ec72b383b6318d5183c6c33f38bce5316; its two parents are exactly e8a5035 and 77f4df4e, and both are ancestors of the clean installed worktree.

The gateway process started from that composite build at 23:44:36 UTC+03:00 on 2026-08-18. At 01:34 on 2026-08-19, all six production Matrix accounts entered a real disconnected health-monitor restart inside that same gateway process:

01:34:25.642 [matrix:agent1] health-monitor: restarting (reason: disconnected)
01:34:25.823 Sync startup aborted with an error: SyncApi.stop() was called
01:34:26.049 [matrix:agent2] health-monitor: restarting (reason: disconnected)
01:34:26.072 Sync startup aborted with an error: SyncApi.stop() was called
01:34:26.310 [matrix:agent3] health-monitor: restarting (reason: disconnected)
01:34:26.330 Sync startup aborted with an error: SyncApi.stop() was called
01:34:26.600 [matrix:agent4] health-monitor: restarting (reason: disconnected)
01:34:26.604 Sync startup aborted with an error: SyncApi.stop() was called
01:34:26.772 [matrix:agent5] health-monitor: restarting (reason: disconnected)
01:34:26.777 Sync startup aborted with an error: SyncApi.stop() was called
01:34:26.958 [matrix:agent6] health-monitor: restarting (reason: disconnected)
01:34:26.961 Sync startup aborted with an error: SyncApi.stop() was called

This is the exact pinned-SDK terminal branch addressed by the PR: each stopped disconnected generation reached the SDK's own SyncApi.stop() was called rejection. Instead of waiting five seconds for a STOPPED event that this branch does not emit, every account acquired a fresh provider generation in 149-445 ms:

Account Restart requested Fresh provider start Elapsed
agent1 01:34:25.642 01:34:26.087 445 ms
agent2 01:34:26.049 01:34:26.339 290 ms
agent3 01:34:26.310 01:34:26.605 295 ms
agent4 01:34:26.600 01:34:26.788 188 ms
agent5 01:34:26.772 01:34:26.963 191 ms
agent6 01:34:26.958 01:34:27.107 149 ms

All six replacement clients then completed fresh Matrix login in-process:

01:34:36.685 matrix: logged in as agent5
01:34:39.830 matrix: logged in as agent6
01:34:40.097 matrix: logged in as agent4
01:34:40.338 matrix: logged in as agent3
01:34:40.524 matrix: logged in as agent1
01:34:40.656 matrix: logged in as agent2

No gateway restart or process replacement occurred during this recovery. From the composite gateway's 23:44:36 start through the post-recovery check, the log contains zero Matrix classic sync did not reach STOPPED within 5000ms errors and zero Matrix channel exited events.

At 02:08:22 UTC+03:00, a fresh live channels status query reported all six configured production accounts with the same healthy terminal state:

enabled=true
configured=true
running=true
connected=true
healthState=healthy
lifecycle=ready
restartPending=false
reconnectAttempts=0
lastError=null

This newer-base run directly covers both causal boundaries requested in review: parked disconnected sync shutdown completed without the impossible STOPPED wait, and each retired generation was followed by fresh client acquisition and a healthy provider rather than a cached-poison rethrow.

Safety and Scope

  • No dependency or lockfile changes.
  • No Synapse, nginx, Matrix worker, credential, room, or schema changes.
  • Active or ambiguous sync states still require a real STOPPED event or fail closed after five seconds.
  • Timeout still discards pending cursor persistence.
  • A failed quiescence remains permanently failed for that client generation.
  • A poisoned generation is evicted only after monitor retirement, lease draining, decryption draining, and stopWithoutPersist().

@openclaw-barnacle openclaw-barnacle Bot added channel: matrix Channel integration: matrix size: S labels Aug 17, 2026
@bdjben
bdjben marked this pull request as ready for review August 17, 2026 18:13
@bdjben

bdjben commented Aug 17, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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 Aug 17, 2026
@clawsweeper

clawsweeper Bot commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 19, 2026, 2:25 PM ET / 18:25 UTC.

ClawSweeper review

What this changes

The PR unwinds a disconnected Matrix classic-sync keepalive and conditionally evicts a safely retired poisoned shared client so a later provider retry can create a new client.

Regression provenance

Possible regression — probable (reviewed change; failure trace). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep open for a Matrix-owner decision: the source-level repair is coherent and the PR supplies production recovery evidence, but it deliberately depends on a private pinned SDK field.

Priority: P1
Reviewed head: 8bf8f5d3e7294261fc962997df87b1c6efe58ba5
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Strong production and regression evidence support a focused repair, with the private SDK lifecycle contract reserved for owner acceptance.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (logs): The PR body records an after-fix six-account production recovery through the disconnected restart path, including healthy provider state and a real Matrix reply; private details are stated as redacted.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (logs): The PR body records an after-fix six-account production recovery through the disconnected restart path, including healthy provider state and a real Matrix reply; private details are stated as redacted.
Evidence reviewed 5 items Current main still retains poisoned clients: Current-main retirement records a quiesce failure as poison, stops the client, and rethrows without removing the shared state; acquisition synchronously rethrows an existing poison error. The PR adds conditional deletion only after all retirement ownership has completed and decryption drain succeeds.
Shutdown repair preserves fail-closed paths: The PR only settles the no-STOPPED path for pre-stop ERROR or RECONNECTING states with the same captured resolver; unknown, active, replaced-resolver, and version-mismatch paths retain the stopped-event wait or failure behavior.
Regression coverage exercises both lifecycle boundaries: Focused tests cover resolver unwind without STOPPED, resolver replacement, stale ERROR timeout, memoized quiesce failure, fresh acquisition after safe retirement, and retained poison when monitor cleanup or lease drain is incomplete.
Findings None None.
Security None None.

Live Verification

Command: pnpm openclaw --help

Result: PASS (completed)

pnpm openclaw --help
runner@runnervmzvulz:/tmp/clawsweeper-live-proof-125362-JUPaYa/target$ pnpm openclaw --help
$ node scripts/run-node.mjs --help
pnpm openclaw --help
[openclaw] Building TypeScript (dist is stale: missing_build_stamp - build stamp missing).
[openclaw] Building bundled plugin assets.
[canvas] build: node scripts/bundle-a2ui.mjs
[log] ‹DIR›/a2ui.bundle.js  chunk │ size: 399.88 kB
[log]
[success] rolldown v1.2.0 Finished in 47.87 ms
[diffs] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts curated
[diffs-language-pack] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts full
[discord] build: node --import tsx ../../scripts/build-discord-activity-sdk.mts
[tsdown-build] invocation 1/2 finished in 0.8s
node_modules/web-tree-sitter/web-tree-sitter.js (2343:30) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2343:31 ]
      │
 2343 │           ASM_CONSTS[start] = eval(func);
      │                               ──┬─
      │                                 ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2366:32) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2366:33 ]
      │
 2366 │           moduleExports[name] = eval(func);
      │                                 ──┬─
      │                                   ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

node_modules/playwright-core/lib/coreBundle.js (65821:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65821:29 ]
       │
 65821 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/playwright-core/lib/coreBundle.js (65828:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65828:29 ]
       │
 65828 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

[tsdown-build] invocation 2/2 finished in 14.8s
[plugin-control-plane-loads] verified 36 built modules with native require and checked doctor closures
runtime-postbuild: 10 phases completed in 4592ms (slowest: built plugin control-plane loads 3801ms)

OpenClaw 2026.8.1 (8bf8f5d) — All your chats, one OpenClaw.

Usage: openclaw [options] [command]

Options:
  --container ‹name›   Run the CLI inside a running Podman/Docker container named ‹name› (default: env OPENCLAW_CONTAINER)
  --dev                Dev profile: isolate state under ~/.openclaw-dev, default gateway port 19001, and shift derived ports (browser/canvas)
  -h, --help           Display help for command
  --log-level ‹level›  Global log level override for file + console (silent|fatal|error|warn|info|debug|trace)
  --no-color  
… output truncated …

Assertions:

  • PASS expect_output: Usage: openclaw

How this fits together

Matrix providers share client generations across monitor and transient leases. On restart, sync shutdown determines whether cursor state can be persisted and whether a subsequent provider retry can acquire a fresh client.

flowchart LR
  A[Matrix provider restart] --> B[Shared client generation]
  B --> C[Classic sync shutdown]
  C --> D{Parked disconnected keepalive?}
  D -->|yes| E[Unwind captured resolver]
  D -->|no or uncertain| F[Wait for stopped event]
  E --> G[Retire leases and client]
  F --> G
  G --> H[Later provider retry]
Loading

Decision needed

Question Recommendation
Should OpenClaw accept the exact-version Matrix SDK private-field dependency to repair disconnected keepalive shutdowns? Accept the bounded dependency: Merge with the existing version, implementation, and identity guards, treating future matrix-js-sdk upgrades as an explicit contract-review point.

Why: The code limits the dependency to one pinned version and production evidence supports the behavior, but accepting ownership of a private upstream lifecycle field is a maintainer policy decision.

Before merge

  • Resolve merge risk (P1) - The fix relies on matrix-js-sdk’s private connectionReturnedResolvers field; a future SDK upgrade will fail closed rather than silently adapt, but can still leave affected Matrix shutdowns unavailable until the contract is updated.
  • Complete next step (P2) - A narrow code repair already exists; the remaining blocker is maintainer acceptance of its private Matrix SDK dependency boundary.
Agent review details

Security

None.

PR surface

Source +38, Tests +120. Total +158 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 3 42 4 +38
Tests 2 126 6 +120
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 168 10 +158

Review metrics

Metric Value Why it matters
Production versus regression coverage production +42/-4, tests +126/-6 The production growth implements a narrowly guarded lifecycle boundary; the larger test delta covers the failure and retirement permutations.

Merge-risk options

Maintainer options:

  1. Accept the pinned private lifecycle contract (recommended)
    A Matrix owner can accept the guarded 41.9.0 dependency after confirming it is an acceptable upgrade obligation.
  2. Pause for a public SDK lifecycle API
    Keep the PR open until a supported matrix-js-sdk shutdown API can replace the private resolver access.

Technical review

Best possible solution:

Accept the narrowly version-guarded private SDK action only if a Matrix owner is comfortable owning it on future dependency upgrades, then merge after exact-head checks finish green.

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

Yes, from source: current main preserves a quiesce poison in the keyed shared-client state and rethrows it on acquisition; the PR’s regression tests model the resulting failed retry path.

Is this the best way to solve the issue?

Yes for the reported pinned-SDK behavior: the fix is scoped to the Matrix lifecycle owner, preserves fail-closed cursor handling, and avoids a parallel retry path; accepting the private SDK boundary remains a maintainer choice.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 03a48b5801e3.

Labels

Label changes:

  • add merge-risk: 🚨 compatibility: The repair binds runtime behavior to a private field in the pinned matrix-js-sdk version.

Label justifications:

  • P1: A disconnected restart can leave Matrix providers unavailable for the gateway lifetime.
  • merge-risk: 🚨 compatibility: The repair binds runtime behavior to a private field in the pinned matrix-js-sdk version.
  • merge-risk: 🚨 availability: A mistaken lifecycle assumption could keep Matrix providers stopped after restart.
  • 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 (logs): The PR body records an after-fix six-account production recovery through the disconnected restart path, including healthy provider state and a real Matrix reply; private details are stated as redacted.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body records an after-fix six-account production recovery through the disconnected restart path, including healthy provider state and a real Matrix reply; private details are stated as redacted.

Evidence

What I checked:

  • Current main still retains poisoned clients: Current-main retirement records a quiesce failure as poison, stops the client, and rethrows without removing the shared state; acquisition synchronously rethrows an existing poison error. The PR adds conditional deletion only after all retirement ownership has completed and decryption drain succeeds. (extensions/matrix/src/matrix/client/shared.ts:338, 03a48b5801e3)
  • Shutdown repair preserves fail-closed paths: The PR only settles the no-STOPPED path for pre-stop ERROR or RECONNECTING states with the same captured resolver; unknown, active, replaced-resolver, and version-mismatch paths retain the stopped-event wait or failure behavior. (extensions/matrix/src/matrix/sdk/client-sync-quiesce.ts:67, 8bf8f5d3e729)
  • Regression coverage exercises both lifecycle boundaries: Focused tests cover resolver unwind without STOPPED, resolver replacement, stale ERROR timeout, memoized quiesce failure, fresh acquisition after safe retirement, and retained poison when monitor cleanup or lease drain is incomplete. (extensions/matrix/src/matrix/sdk.test.ts:1545, 8bf8f5d3e729)
  • Dependency contract is an affirmative dependency boundary: The Matrix plugin pins matrix-js-sdk to 41.9.0 and the changed code asserts that version before accessing the private resolver field. The installed SDK source and upstream network were unavailable in this review environment, so the upstream field contract could not be independently re-read here. (extensions/matrix/package.json:15, 8bf8f5d3e729)
  • Current-head provenance: The latest head adds the conditional retention rule for incomplete retirement; current-main blame attributes the preceding shared-generation lifecycle to Peter Steinberger. (extensions/matrix/src/matrix/client/shared.ts:348, 8bf8f5d3e729)

Likely related people:

  • jalehman: Authored the current-head retirement safety change and is assigned to the PR. (role: latest lifecycle repair author and assigned reviewer; confidence: high; commits: 8bf8f5d3e729; files: extensions/matrix/src/matrix/client/shared.ts, extensions/matrix/src/matrix/client/shared.test.ts)
  • steipete: Current-main blame attributes the shared-generation retirement owner surface to Peter Steinberger. (role: recent shared-client lifecycle contributor; confidence: medium; commits: 9f8d53d6fb14; files: extensions/matrix/src/matrix/client/shared.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Record Matrix-owner acceptance of the pinned private SDK dependency.
  • Wait for the current-head required checks to complete before merge.

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 (5 earlier review cycles)
  • reviewed 2026-08-17T18:24:02.654Z sha c17e4ff :: needs maintainer review before merge. :: none
  • reviewed 2026-08-17T18:29:53.647Z sha c17e4ff :: needs maintainer review before merge. :: none
  • reviewed 2026-08-17T18:56:31.402Z sha 77f4df4 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-17T19:58:07.486Z sha 77f4df4 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-18T23:15:50.250Z sha 77f4df4 :: needs maintainer review before merge. :: none

@bdjben

bdjben commented Aug 17, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 17, 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 rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. 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 Aug 17, 2026
@bdjben

bdjben commented Aug 17, 2026

Copy link
Copy Markdown
Contributor Author

I updated the PR description with the direct, commit-pinned source-contract comparison requested in the latest review:

  • the exact matrix-js-sdk v41.9.0 tag/commit and its private connectionReturnedResolvers field;
  • the SDK's stop() ordering, disconnected keepalive wait, normal STOPPED path, and stopped-keepalive reject/clear behavior;
  • the corresponding version guard, SyncApi check, captured-resolver identity guard, and exact reject/clear action at PR head 77f4df4e;
  • the explicit maintainer decision boundary for relying on that exact-version private field.

I also made the evidence scope explicit: this update supplies pinned-SDK source proof only. It does not claim an exact-head live disconnected-recovery trace; the existing production-after trace remains identified as the built c17e4ff4 behavior commit. No code or PR-head change was made in this update.

@bdjben

bdjben commented Aug 17, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 17, 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.

@clawsweeper clawsweeper Bot added the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Aug 17, 2026
@bdjben

bdjben commented Aug 18, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 18, 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 proof: sufficient ClawSweeper judged the real behavior proof convincing. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 18, 2026
@clawsweeper clawsweeper Bot added 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 Aug 18, 2026
@jalehman jalehman self-assigned this Aug 19, 2026
@jalehman

Copy link
Copy Markdown
Contributor

Land-ready at 8bf8f5d3e7294261fc962997df87b1c6efe58ba5.

Maintainer decision: accept the narrowly bounded [email protected] private resolver contract. The exact-version assertion, resolver-identity check, timeout fallback, and unsafe-cursor discard keep dependency drift and uncertain lifecycle states fail-closed. The follow-up commit also retains poison when monitor cleanup or transient lease drain is incomplete, so a replacement generation cannot overlap old work.

Proof:

Known proof gap: I did not induce a new authenticated Matrix outage. The PR body already contains redacted production recovery evidence across six accounts and a real Matrix request/reply round trip; focused dependency-backed lifecycle tests and exact-head CI cover the maintainer follow-up.

Production delta: +42/-4; tests: +126/-6. The growth is the exact-version SDK boundary plus lifecycle classification needed to recover completed sync poison while preserving incomplete cleanup/drain poison.

@jalehman
jalehman merged commit 0a8f2c1 into openclaw:main Aug 19, 2026
106 checks passed
@jalehman

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 20, 2026
…#125362)

* fix(matrix): recover poisoned sync generations

* fix(matrix): compile private sync resolver boundary

* fix(matrix): retain incomplete retirement poison

---------

Co-authored-by: Benjamin Badejo <[email protected]>
Co-authored-by: Josh Lehman <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: matrix Channel integration: matrix merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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.

2 participants