Skip to content

fix(matrix): preserve approval reactions after Gateway failures - #129879

Merged
steipete merged 1 commit into
mainfrom
codex/qa-matrix-approval-error-propagation
Aug 26, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/qa-matrix-approval-error-propagation

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where Matrix users approving an execution or plugin request with a reaction would see no outcome when the Gateway temporarily failed, and the same approval reaction could not be replayed after recovery.

Why This Change Was Made

The Matrix approval reaction owner treated non-terminal Gateway errors as successfully consumed reactions. That caused the inbound owner to commit its durable replay claim even though the approval never resolved. Propagating the original error lets the existing inbound owner report it and release the uncommitted claim, while retaining the original approval anchor for an authorized replay. Sender authorization, reviewer identity, approval authority, terminal cleanup, and expired-approval behavior remain unchanged. Production delta: +1/-1 (net zero).

User Impact

Operators can recover a Matrix approval reaction after a temporary Gateway outage instead of losing the action silently and waiting for the approval to expire.

Evidence

  • Tests-first owner regression: before the fix, the authorized Matrix reaction incorrectly resolved successfully instead of rejecting the injected gateway 503 error; after the fix, the error propagates, the exact account/room/event approval anchor remains registered, and replay resolves the same approval and retires its anchor.
  • Matrix owner, inbound handler, durable replay deduplication, approval-reaction authorization, approval anchors, and execution-approval suites: 218 tests passed across 6 suites.
  • iMessage approval sibling suite: 35 tests passed. Total: 253 tests passed.
  • Strict production TypeScript project: 10,837 source files, zero diagnostics; strict test TypeScript project: 10,887 source files, zero diagnostics.
  • Canonical formatting, targeted oxlint, assertion-safety ratchet, maximum-lines ratchet, and git diff --check all passed.
  • Independent owner/security-boundary review and authenticated Codex review: no findings.
  • Live authenticated Matrix proof was not available because this task has no isolated configured Matrix homeserver or account; the authentic reaction-handler, Gateway-failure, replay-anchor, and full inbound-owner regressions exercise the changed channel boundary instead.

@clawsweeper

clawsweeper Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added channel: matrix Channel integration: matrix size: XS maintainer Maintainer-authored PR labels Aug 26, 2026
@steipete
steipete marked this pull request as ready for review August 26, 2026 04:53
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. 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 26, 2026
@clawsweeper

clawsweeper Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 26, 2026, 12:58 AM ET / 04:58 UTC.

ClawSweeper review

What this changes

Propagates transient Gateway approval failures from Matrix reaction handling and adds a regression test that preserves the approval anchor for replay.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open. Current main still treats a non-expired Gateway error as a successfully handled Matrix reaction, which commits the inbound replay claim; this PR propagates that error so the existing handler releases the claim. No blocking patch defect found.

Priority: P1
Reviewed head: 82307ac9ee8eab359ce2866cd797891081d6c99e

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, net-neutral owner-boundary repair with source-backed replay behavior and no blocking finding.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR is exempt from the contributor proof gate; its body nevertheless documents focused after-fix regression coverage, while no live Matrix trace is claimed.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR is exempt from the contributor proof gate; its body nevertheless documents focused after-fix regression coverage, while no live Matrix trace is claimed.
Evidence reviewed 6 items Current-main defect: Current main logs a non-terminal approval-resolution error and returns success, so its caller proceeds to commit the inbound replay claim.
Caller and owner boundary: The ingress handler commits only after the reaction handler returns; the outer handler releases an uncommitted claim in its finally block when the propagated error reaches it.
Patch and focused regression: The branch changes the non-terminal path to throw and verifies the anchor survives a rejected Gateway call, then resolves and retires on replay.
Findings None None.
Security None None.

Live Verification

Command: pnpm test extensions/matrix/src/matrix/monitor/reaction-events.test.ts

Result: FAIL (partial) — step 2 expect_output retains approval anchors and propagates transient Gateway failures for replay: expected terminal output was not visible within 30 seconds: "retains approval anchors and propagates transient Gateway failures for replay"

$ node --import tsx scripts/test-projects.mts extensions/matrix/src/matrix/monitor/reaction-events.test.ts
[test] starting test/vitest/vitest.extension-matrix.config.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-129879-p5NgYB/target

 ✓  extension-matrix  extensions/matrix/src/matrix/monitor/reaction-events.test.ts (10 tests) 157ms

 Test Files  1 passed (1)
      Tests  10 passed (10)
   Start at  04:59:46
   Duration  9.92s (transform 7.77s, setup 961ms, import 8.44s, tests 157ms, environment 0ms)

[test] passed 1 Vitest shard in 16.23s
$ node --import tsx scripts/test-projects.mts extensions/matrix/src/matrix/monitor/reaction-events.test.ts
[test] starting test/vitest/vitest.extension-matrix.config.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-129879-p5NgYB/target

 ✓  extension-matrix  extensions/matrix/src/matrix/monitor/reaction-events.test.ts (10 tests) 95ms

 Test Files  1 passed (1)
      Tests  10 passed (10)
   Start at  05:00:03
   Duration  4.76s (transform 2.60s, setup 441ms, import 3.91s, tests 95ms, environment 0ms)

[test] passed 1 Vitest shard in 11.18s

Assertions:

  • FAIL expect_output: retains approval anchors and propagates transient Gateway failures for replay

How this fits together

Matrix reaction events enter the Matrix channel handler, which claims an inbound event for replay protection and resolves authorized approval reactions through the Gateway. Successful or terminal resolutions retire approval anchors; transient failures must leave both the anchor and inbound claim available for recovery.

flowchart LR
  A[Matrix approval reaction] --> B[Inbound replay claim]
  B --> C[Authorize reaction sender]
  C --> D[Gateway approval resolution]
  D -->|resolved or expired| E[Retire approval anchor]
  D -->|transient failure| F[Release replay claim]
  F --> G[Retry same approval reaction]
Loading

Before merge

  • Resolve merge risk (P1) - GitHub reports the branch behind main and several exact-head checks are still running; refresh the merge result and required checks before landing.
  • Complete next step (P2) - This maintainer-authored, protected PR has a coherent repair and needs normal exact-head CI and merge review rather than an automated replacement.
Agent review details

Security

None.

PR surface

Source 0, Tests +46. Total +46 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 1 1 0
Tests 1 46 0 +46
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 47 1 +46

Review metrics

Metric Value Why it matters
Production versus test LOC production +1/-1 (net 0); tests +46/-0 The repair changes only the error outcome at the owner boundary; the added regression exercises failure, retained anchor, and replay.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep transient Gateway errors on the failure path so the Matrix handler releases its replay claim while the approval anchor remains available for an authorized retry.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep transient Gateway errors on the failure path so the Matrix handler releases its replay claim while the approval anchor remains available for an authorized retry.

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

Yes—current main's non-terminal error return, the caller's subsequent commit, and the outer handler's release-on-error path establish a high-confidence source reproduction.

Is this the best way to solve the issue?

Yes—the smallest correct repair is to propagate the existing Gateway error to the inbound replay owner; retaining a success return would preserve the lost-action behavior.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 33c88afc6dbe.

Labels

Label changes:

  • add P1: A temporary Gateway failure can silently consume an authorized Matrix approval reaction and block the approval workflow until expiry.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored PR is exempt from the contributor proof gate; its body nevertheless documents focused after-fix regression coverage, while no live Matrix trace is claimed.

Label justifications:

  • P1: A temporary Gateway failure can silently consume an authorized Matrix approval reaction and block the approval workflow until expiry.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored PR is exempt from the contributor proof gate; its body nevertheless documents focused after-fix regression coverage, while no live Matrix trace is claimed.

Evidence

What I checked:

Likely related people:

  • steipete: Recent Matrix handler and channel-replay history, plus the current focused repair, connects this person to the replay-owner boundary. (role: recent area contributor; confidence: high; commits: 21f0cef5d5ae, 82307ac9ee8e; files: extensions/matrix/src/matrix/monitor/handler.ts, extensions/matrix/src/matrix/monitor/reaction-events.ts)
  • Gustavo Madeira Santana: Authored the original Matrix execution-approval reaction shortcuts. (role: introduced reaction approval behavior; confidence: high; commits: 0aaf7531481d; files: extensions/matrix/src/approval-reactions.ts)
  • Alex Knight: Authored the persistent Matrix approval-anchor work used by the recovery path. (role: persistent-state contributor; confidence: high; commits: f27ecffc0c26; files: extensions/matrix/src/approval-reactions.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.

@steipete
steipete merged commit 9719616 into main Aug 26, 2026
177 checks passed
@steipete
steipete deleted the codex/qa-matrix-approval-error-propagation branch August 26, 2026 05:09
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 27, 2026
obviyus pushed a commit to wangmiao0668000666/openclaw that referenced this pull request Aug 29, 2026
… errors

Transient Gateway 5xx/network/auth errors in approval reaction resolution
were returning {handled:true, stopPolling:true}, which caused the durable
ingress while(true) loop to commit the claim (GUID tombstone) and lose
the operator's approval click permanently.

Fix: return {handled:false} so the loop retries via
iMessageApprovalControlBindings.wait(), keeping the durable claim alive.
This is the same fix pattern as matrix (openclaw#129879) and signal (openclaw#130134).

Test: prove transient errors keep the binding alive and return handled:false.

Fixes: imessage approval reaction silent drop on resolver-error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: matrix Channel integration: matrix maintainer Maintainer-authored PR P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS 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