Skip to content

fix(matrix): forward-port 2026.10.10 startup and shutdown fixes - #192385

Merged
RomneyDa merged 5 commits into
mainfrom
fix/forward-port-1010-matrix
Nov 5, 2026
Merged

RomneyDa merged 5 commits into
mainfrom
fix/forward-port-1010-matrix

Conversation

@RomneyDa

@RomneyDa RomneyDa commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

Problem

Matrix fixes found during the 2026.10.10 stable release did not reach main: monitor readiness could be announced before startup maintenance completed, request deadline timers kept finished CLI commands alive, and late in-room verification failures could become unhandled rejections.

Solution

This independently mergeable slice of #191830 targets main (not another split PR). It retains the Matrix startup/status fix, the SDK shutdown/error-handling patch, and the related E2EE QA scenarios aligned with offline state ownership and corrupt-snapshot refusal. No Codex, process, storage, scheduling, or unrelated fixes are included.

Forward-ports release commits 5fe32d9c57, 4bbc5971ba, 2a6a3bc041, and 0f4dc59109; original references and authorship are preserved in the commits. The original aggregate test-line allocation is replaced with 162 lines specific to these regressions.

Evidence

  • The 11 changed product/test/patch/scenario files are byte-identical to the corresponding files at the original fix(codex): forward-port 2026.10.10 thread ownership and cleanup fixes #191830 head; the lockfile changes retain only this Matrix SDK patch hash.
  • git diff --check: passed.
  • Changed-file oxfmt --check: passed.
  • Changed TypeScript oxlint --type-aware: passed.
  • node scripts/run-vitest.mjs run --config test/vitest/vitest.extension-matrix.config.ts extensions/matrix/src/matrix/monitor/index.test.ts extensions/matrix/src/matrix/monitor/status.test.ts extensions/matrix/src/matrix/sdk/matrix-js-sdk-patch.sdk.test.ts: 3 files, 31 tests passed.
  • node scripts/run-vitest.mjs run --config test/vitest/vitest.extension-qa.config.ts extensions/qa-lab/src/live-transports/matrix/scenarios/scenario-runtime-e2ee-destructive.test.ts extensions/qa-lab/src/live-transports/matrix/scenarios/scenario-runtime-e2ee-cli-recovery.test.ts extensions/qa-lab/src/live-transports/matrix/scenarios/scenario-runtime-e2ee-cli-account.test.ts: 3 files, 25 tests passed.
  • Fresh local autoreview (Codex), base 34007820fa2c, head 31a8cba635cc: scoped-clean through P2; no accepted/actionable findings. Used the autoreview fallback because the local ClawSweeper checkout had no installed dependencies; hosted review will provide the normal additional review lane.
  • Initial monitor/QA setup attempts failed because the new worktree lacked package-local dependency links for subprocess builds; after restoring links to the existing matching install, the suites above passed.
  • Simplification pass: every retained hunk serves Matrix startup, shutdown, verification, or the matching QA contract; no new generic helper or owner was introduced. Delta versus main: 349 added / 42 removed lines across 13 files, including 162 regression lines and the two-line scoped allocation.

Limitations / before landing

  • The SDK patch extends patches/[email protected]; explicit dependency-patch approval remains required before landing. These hunks were already shipped in 2026.10.10's SDK 42.4.0 patch, and the guarded 43.0.0 code is identical.
  • SDK/QA paths have not been exercised against a live Matrix homeserver in this split.
  • A fresh package typecheck was attempted but stopped at the repository declaration-input custody check because the split worktree reused an external dependency install. No typecheck bypass was used; broad fresh type validation remains with PR CI.
  • The original combined PR recorded passing Matrix suites (43 + 99 tests), QA E2EE 26/26, and both pnpm tsgo and pnpm tsgo:extensions. These are inherited evidence, not a fresh broad typecheck of this split.
  • The test-lines ratchet reports a pre-existing 47-line deficit on the selected main base; this split's +162 test lines are fully offset by its scoped allocation.

Split CI status

  • Observed CI failure is inherited from main 34007820fa2c: missing McpCatalogTool export in mcp-metadata.ts and consequent optional UI metadata errors. That file and agent-bundle-mcp-materialize.ts / agent-bundle-mcp-types.ts are byte-identical to the base; SDK declaration preparation propagates the same error into build/boundary/lint lanes.
  • Test-line ratchet retains the pre-split 47-line deficit: baseline total 6,444,916 versus ceiling 6,444,869. This split’s dedicated allocation covers its exact positive test-line delta; inflating it would violate the allocation checker.
  • Ready for review does not mean green CI or ready to merge. Remaining broad checks are still running; no merge requested.

Exact-head CI attribution audit

Audited 2026-11-04 at 31a8cba635ccba54b331fe923ed49122369fcd4c. Failed job logs were inspected individually, not inferred from their names.

The MCP failures are inherited from base 34007820fa2c: src/agents/mcp-metadata.ts, agent-bundle-mcp-materialize.ts, and agent-bundle-mcp-types.ts have identical Git blob IDs at base and PR head. The missing McpCatalogTool export and consequent optional-property errors propagate through SDK declarations into boundary/build/lint/type lanes.

The test-line ratchet is also inherited: this PR offsets its exact positive test-line delta, and its job still exceeds the adjusted ceiling by the same 47 lines already present at base (6,444,916 vs 6,444,869). No baseline increase or unrelated repair is included.

Failed check Attribution
build-artifacts Inherited MCP declaration/type failure
build-artifacts Inherited MCP declaration/type failure
checks-fast-baseline-ratchets Inherited 47-line test-budget deficit
check-additional-extension-package-boundary Inherited MCP declaration/type failure
check-prod-types Inherited MCP declaration/type failure
check-test-types Inherited MCP declaration/type failure
check-test-types-core-1 Inherited MCP declaration/type failure
check-test-types-core-2 Inherited MCP declaration/type failure
check-test-types-core-3 Inherited MCP declaration/type failure
check-test-types-core-4 Inherited MCP declaration/type failure
check-test-types-core-5 Inherited MCP declaration/type failure
openclaw/ci-gate Aggregate of failed or downstream-skipped prerequisite jobs above; not an independent runtime failure
openclaw/ci-gate Aggregate of failed or downstream-skipped prerequisite jobs above; not an independent runtime failure

Cancelled dispatch jobs are orchestration cancellations, not passing tests or additional source defects. CI remains red; this section explains the failures rather than claiming green.

Rebase onto current main

Rebased onto a1f99240c8367a0e012b401bed71831a3cc65026, including merged Goal-test correction #192387. New candidate: ef3258ef9031a95f381fd46897b550e2bd62d5a8. This PR still targets main independently.

Verified the complete rebased tree equals the previous PR patch integrated with that main snapshot. No new behavior was added during rebase. Prior test and CI attribution sections remain evidence for their named old revisions; fresh CI on this head is pending, not claimed green.

@clawsweeper

clawsweeper Bot commented Nov 3, 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 November 3, 2026 23:36
@github-actions github-actions Bot added the dependencies-changed PR changes dependency-related files label Nov 3, 2026
@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Dependency graph changes

This maintainer PR changes the dependency graph.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: ef3258ef9031a95f381fd46897b550e2bd62d5a8
  • Maintainer: @RomneyDa
  • Repository role: maintain

These dependency graph changes were made:

Carefully review these changes before merging.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 3, 2026
@clawsweeper

clawsweeper Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

This PR delays Matrix readiness until startup completes, releases request timers, contains late verification failures, and updates related QA scenarios.

Example: A Matrix CLI command completes a request with a 110000 ms deadline and stops its client.

  • Before: The referenced deadline timer can keep the finished command running.
  • After: The deadline timer no longer keeps the process alive.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused patch appears correct and preserves existing contracts, with confidence limited to source inspection and supplied test evidence.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor proof gate; supplied evidence covers focused mocked and SDK tests, while the body explicitly disclaims live Matrix qualification for this split.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Matrix can report readiness too early, leave completed CLI commands running, or exit after a late verification failure.
Reason: The maintainer-authored direction restores useful lifecycle behavior without adding configuration, public APIs, or another owner.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep this maintainer-authored PR open: current main still needs these Matrix lifecycle fixes, and review found no actionable correctness defects.

Priority: P1
Reviewed head: 31a8cba635ccba54b331fe923ed49122369fcd4c

Before merge

  • Await maintainer action - Approve the matrix-js-sdk dependency-patch extensions before landing, as required by repository policy and retained in the PR body.

Findings

None.

Tests

  • Missing end-to-end proof: No supplied shipped-entry-point trace demonstrates delayed readiness, prompt CLI exit, and late verification failure containment; red-on-base results for this split are also not recorded.
Agent review details

How this fits together

The Matrix plugin owns account startup and status, while its patched Matrix SDK handles homeserver requests and encrypted verification events.

flowchart TD
  A[Gateway or Matrix CLI] --> B[Matrix account client]
  B --> C[Matrix SDK]
  C --> D[Matrix homeserver]
  B --> E[Startup maintenance]
  E --> F[Monitor readiness]
  C --> G[Request and verification cleanup]
Loading

Technical review

Best possible solution:

Retain the focused fixes in the existing Matrix owners and land after dependency-patch approval and resolution of the CI gate.

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

Current-main readiness ordering and the pinned SDK source establish the failing paths; no target code was executed during this read-only review.

Is this the best way to solve the issue?

The change repairs readiness in its existing controller and detached failure handling in the SDK, while aligning QA with established ownership contracts.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Matrix readiness publication keeps the original intent (0c00c3c: The earlier lifecycle repair made sync readiness authoritative and contained channel failures; this change adds the missing startup-maintenance boundary.)
  • SDK request deadlines and detached verification changes intended behavior with a stated reason (https://github.com/matrix-org/matrix-js-sdk/blob/5723f58cb8675398970fc2945819ae0f4b7c1b58/src/rust-crypto/rust-crypto.ts: Upstream implements request deadlines and detached live-event processing; the release repair commits explain why timer references and unhandled late failures need correction.)
  • QA encryption setup during Gateway ownership changes intended behavior with a stated reason (623ec0f: The original scenario exercised CLI setup followed by Gateway replies; later exclusive offline ownership requires setup inside the existing stop/run/restart operation.)
  • QA corrupt-snapshot recovery expectation changes intended behavior with a stated reason (ad34552: The migrated scenario expected backup restore to repair corruption; the later crypto ownership contract deliberately refuses corrupt snapshots and preserves them.)

Testing

Proof path: unit tests only.

Security

None.

Evidence

What I checked:

PR surface

Source +73, Tests +162, Other +72. Total +307 across 13 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 6 111 38 +73
Tests 3 162 0 +162
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 4 76 4 +72
Total 13 349 42 +307

Labels

Label changes:

No label changes.

Label justifications:

  • P1: The repairs address premature Matrix readiness, finished CLI commands remaining alive, and late verification rejections that can initiate process exit.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: ⏳ waiting on maintainer: Only explicit maintainer approvals or decisions remain; merge is still blocked.

Rank-up moves

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

  • Add a redacted CLI/Gateway trace exercising startup completion, command exit, and late verification failure handling.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-11-04T00:02:07.373Z sha 31a8cba :: blocked before merge. :: none

Reviewed November 4, 2026, 5:11 PM ET / 22:11 UTC (Revision 2).

@RomneyDa

RomneyDa commented Nov 4, 2026

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 4, 2026
Keep account readiness in startup until Matrix startup maintenance and crypto ownership initialization have settled, preventing hard-restart consumers from interrupting final state handoff.

The monitor is the status controller's only consumer, so deferral is unconditional rather than an option.

Forward-port of 5fe32d9 from release/2026.10.10.
matrix-js-sdk's timeoutSignal ponyfill arms a referenced setTimeout for every
request and never clears it. /sync requests use pollTimeout + 80s, so each
Matrix CLI command stayed alive for up to 110s after printing its result once
CLI completion stopped forcing process exit (#168587). matrix-js-sdk 43.0.0
still ships the same ponyfill.

Unref the deadline timer, matching AbortSignal.timeout semantics: an in-flight
request still keeps the process alive through its socket and the deadline still
fires while the loop is running.

Forward-port of 4bbc597 from release/2026.10.10.
…shing

matrix-js-sdk starts in-room verification processing without awaiting it,
including after an encrypted verification event finishes decrypting. Once the
client has stopped, OpenClaw's retired crypto IndexedDB generation rejects
receiveVerificationEvent, and the rejection reaches the process
unhandled-rejection guard, which begins process exit. In the QA Matrix lane the
exit gate stopped the CLI scheduler mid-run, so every later isolated scenario
failed with "Failed to stage the isolated QA auth profile store".
matrix-js-sdk 43.0.0 still leaves this path unguarded.

Catch and log the failure inside the SDK's fire-and-forget verification path.

Forward-port of 2a6a3bc from release/2026.10.10.
Two Matrix QA scenarios asserted behavior the product intentionally retired;
earlier lane failures masked them.

- matrix-e2ee-cli-setup-then-gateway-reply ran `openclaw matrix encryption
  setup` while the Gateway owned the state root. Since #168471 only verify
  status/bootstrap/device route through a running Gateway; other Matrix
  commands refuse until it is stopped (docs/channels/matrix.md). Run setup in
  the stop/run/restart window, then keep the Gateway reply proof.
- matrix-e2ee-corrupt-crypto-idb-snapshot expected backup restore to repair a
  corrupted crypto snapshot. Since #160707 crypto ownership refuses unsafe or
  corrupt snapshots and points at `openclaw matrix doctor inspect`
  (docs/channels/matrix/encryption.md). Assert that refusal and that the
  corrupted snapshot is left in place.

The refusal assertion and the backup-bootstrap classifier move to the
destructive-recovery sibling to keep the scenario module under its line cap.

Forward-port of 0f4dc59 from release/2026.10.10.
@RomneyDa
RomneyDa force-pushed the fix/forward-port-1010-matrix branch from 31a8cba to ef3258e Compare November 5, 2026 01:49
@RomneyDa
RomneyDa merged commit ae420c5 into main Nov 5, 2026
136 checks passed
@RomneyDa
RomneyDa deleted the fix/forward-port-1010-matrix branch November 5, 2026 02:15
RomneyDa added a commit that referenced this pull request Nov 5, 2026
Carry the final reviewed changes from #191830, #192378, #192379,
#192380, #192383, #192385, and #192386. Preserve #191838's existing
file-transfer import fix. Adapt Gateway readiness to the release owner
and include the narrow SQLite cold-admission prerequisite from #192586.

Do not carry #192387: its Goal expectation depends on main-only
Stop-to-paused behavior absent from this release.

Retain regression allocations without changing the shared baseline.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 5, 2026
…claw#192385)

* fix(matrix): defer ready status through startup

Keep account readiness in startup until Matrix startup maintenance and crypto ownership initialization have settled, preventing hard-restart consumers from interrupting final state handoff.

The monitor is the status controller's only consumer, so deferral is unconditional rather than an option.

Forward-port of 5fe32d9 from release/2026.10.10.

* fix(matrix): let Matrix CLI commands exit after their client stops

matrix-js-sdk's timeoutSignal ponyfill arms a referenced setTimeout for every
request and never clears it. /sync requests use pollTimeout + 80s, so each
Matrix CLI command stayed alive for up to 110s after printing its result once
CLI completion stopped forcing process exit (openclaw#168587). matrix-js-sdk 43.0.0
still ships the same ponyfill.

Unref the deadline timer, matching AbortSignal.timeout semantics: an in-flight
request still keeps the process alive through its socket and the deadline still
fires while the loop is running.

Forward-port of 4bbc597 from release/2026.10.10.

* fix(matrix): report late in-room verification failures instead of crashing

matrix-js-sdk starts in-room verification processing without awaiting it,
including after an encrypted verification event finishes decrypting. Once the
client has stopped, OpenClaw's retired crypto IndexedDB generation rejects
receiveVerificationEvent, and the rejection reaches the process
unhandled-rejection guard, which begins process exit. In the QA Matrix lane the
exit gate stopped the CLI scheduler mid-run, so every later isolated scenario
failed with "Failed to stage the isolated QA auth profile store".
matrix-js-sdk 43.0.0 still leaves this path unguarded.

Catch and log the failure inside the SDK's fire-and-forget verification path.

Forward-port of 2a6a3bc from release/2026.10.10.

* test(qa): align Matrix E2EE scenarios with offline ownership contracts

Two Matrix QA scenarios asserted behavior the product intentionally retired;
earlier lane failures masked them.

- matrix-e2ee-cli-setup-then-gateway-reply ran `openclaw matrix encryption
  setup` while the Gateway owned the state root. Since openclaw#168471 only verify
  status/bootstrap/device route through a running Gateway; other Matrix
  commands refuse until it is stopped (docs/channels/matrix.md). Run setup in
  the stop/run/restart window, then keep the Gateway reply proof.
- matrix-e2ee-corrupt-crypto-idb-snapshot expected backup restore to repair a
  corrupted crypto snapshot. Since openclaw#160707 crypto ownership refuses unsafe or
  corrupt snapshots and points at `openclaw matrix doctor inspect`
  (docs/channels/matrix/encryption.md). Assert that refusal and that the
  corrupted snapshot is left in place.

The refusal assertion and the backup-bootstrap classifier move to the
destructive-recovery sibling to keep the scenario module under its line cap.

Forward-port of 0f4dc59 from release/2026.10.10.

* test(matrix): scope forward-port regression allocation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: matrix Channel integration: matrix dependencies-changed PR changes dependency-related files extensions: qa-lab P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant