Skip to content

fix(imessage): replay approval reactions after transient Gateway failures - #130893

Merged
obviyus merged 4 commits into
openclaw:mainfrom
wangmiao0668000666:fix/signal-approval-reaction-replay
Aug 29, 2026
Merged

obviyus merged 4 commits into
openclaw:mainfrom
wangmiao0668000666:fix/signal-approval-reaction-replay

Conversation

@wangmiao0668000666

@wangmiao0668000666 wangmiao0668000666 commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

An iMessage approval tapback was lost when the Gateway approval request failed temporarily. The channel returned a terminal handled result, so the durable ingress queue completed the reaction instead of replaying it.

Signal already uses the correct replay path on current main. This PR aligns iMessage with Signal and Matrix.

Fixes #131003.

Why This Change Was Made

iMessage now throws every non-NotFound resolver error to the shared durable ingress drain. The drain records the failure, releases the claim, and replays the same reaction under its bounded retry policy.

NotFound remains terminal and clears the expired binding. The obsolete resolver-error result was removed. The poller now preserves the binding and retries on its next interval.

User Impact

An approval reaction now survives a temporary Gateway failure. The operator does not need to tap the approval again after the Gateway recovers.

Evidence

  • Current main at 6b1eacad93819efeb324e056aa57a782d6280bd5: the iMessage SQLite replay contract failed because the resolver ran once instead of twice.
  • Exact head 0db5a1a146e99073acf506bff5312f37bf12daa5: the Signal and iMessage SQLite replay contracts passed.
  • The replay proof uses the real channel owner, SQLite queue, monitor, drain, retry, completion, and tombstone. Only the external Gateway approval call is fault-injected.
  • The first request fails. The second request is identical and succeeds. A duplicate ingress event cannot cause a third approval execution.
  • Focused channel tests: 61 passed. Final iMessage poller and durable replay tests: 8 passed.
  • Formatting, focused Oxlint, import cycles, plugin boundaries, dependency guards, database-first guard, dead-code scan, assertion safety, max-lines, and test temporary-directory checks passed.
  • Effective delta: production +4/-2, with one return replaced by one throw; tests +230/-5.

Redacted iMessage-to-Gateway replay trace

The exact-head proof ran an isolated Gateway over authenticated WebSockets. The first Gateway call committed the approval, but the harness dropped its response. The durable iMessage drain released and reclaimed the reaction. The replay reached the Gateway, received the recorded terminal result, and completed the queue once.

{
  "head": "0db5a1a146e99073acf506bff5312f37bf12daa5",
  "requestReplayEqual": true,
  "gatewayResults": [
    { "attempt": 1, "applied": true, "observedByChannel": false },
    { "attempt": 2, "applied": false, "terminalStatus": "allowed" }
  ],
  "queue": ["claimed", "released", "reclaimed", "completed", "duplicate-suppressed"],
  "approvalResolvedEvents": 1,
  "resolverCallsAfterDuplicate": 2,
  "result": "pass"
}

@clawsweeper

clawsweeper Bot commented Aug 27, 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: imessage Channel integration: imessage channel: signal Channel integration: signal size: M triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Aug 27, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 27, 2026
@clawsweeper

clawsweeper Bot commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed August 29, 2026, 4:02 AM ET / 08:02 UTC.

ClawSweeper review

What this changes

This PR makes iMessage approval tapbacks replay through durable ingress after a transient Gateway resolution failure and adds poller and durable-replay coverage.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⛔ Blocked until real behavior proof from a real setup is added - 4 items remain

Keep open. The retry design is correct on the inspected branch, but the submitted after-fix evidence remains a mocked integration test rather than a real iMessage-to-Gateway recovery run.

Priority: P1
Reviewed head: 0db5a1a146e99073acf506bff5312f37bf12daa5

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The implementation and focused regression coverage are strong, but real behavior proof for this external PR is still missing.
Proof confidence 🦪 silver shellfish (2/6) Needs real behavior proof before merge: The added test exercises the real SQLite queue, iMessage ingress monitor, drain, retry, and tombstone behavior, but directly injects the reaction and mocks the Gateway resolution call; no real iMessage-to-Gateway after-fix recovery evidence was provided. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The added test exercises the real SQLite queue, iMessage ingress monitor, drain, retry, and tombstone behavior, but directly injects the reaction and mocks the Gateway resolution call; no real iMessage-to-Gateway after-fix recovery evidence was provided. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 7 items Introduced repair: The introduced catch branch now rethrows a non-NotFound Gateway error, allowing the surrounding durable ingress owner to retain and retry the reaction rather than treating it as completed.
Caller and retry owner: The monitor invokes the approval handler in its priority lane, while the shared drain catches a pre-adoption throw and applies its failure disposition, including claim release for retry.
Replay remains safe after a remote success: Gateway approval resolution returns the recorded terminal approval with applied:false for later resolution attempts, so a retry after an ambiguous transport failure does not reopen execution rights.
Findings None None.
Security None None.

How this fits together

iMessage tapbacks enter the channel’s durable ingress queue before priority approval handling. The handler resolves an authorized tapback through Gateway, then the shared drain either completes the claim or releases it for retry.

flowchart TD
  A[iMessage approval tapback] --> B[Durable ingress queue]
  B --> C[Priority approval handler]
  C --> D{Gateway resolution}
  D -->|Temporary failure| E[Release claim for retry]
  D -->|Terminal result| F[Complete reaction claim]
  E --> C
Loading

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The added test exercises the real SQLite queue, iMessage ingress monitor, drain, retry, and tombstone behavior, but directly injects the reaction and mocks the Gateway resolution call; no real iMessage-to-Gateway after-fix recovery evidence was provided. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Resolve merge risk (P0) - The only observed after-fix evidence is an isolated Vitest setup with the Gateway resolver mocked, so real iMessage transport and Gateway outage/recovery behavior remain unproven.
  • Resolve merge risk (P1) - The partial checkout could not fetch current-main and older history objects, so non-redundancy against fetched main and original regression provenance remain unverified.
  • Complete next step (P2) - No repair lane is needed because no introduced correctness defect was found; the remaining merge gate is contributor-supplied real behavior proof.
Agent review details

Security

None.

PR surface

Source +2, Tests +225. Total +227 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 4 2 +2
Tests 2 230 5 +225
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 234 7 +227

Review metrics

Metric Value Why it matters
Production versus test LOC production +4/-2 (net +2); tests +230/-5 (net +225) The small production change replaces terminal consumption with error propagation; most of the change is focused replay coverage.

Merge-risk options

Maintainer options:

  1. Add real recovery proof (recommended)
    Run an iMessage approval tapback through a temporary Gateway outage and recovery, then attach redacted evidence that the original tapback is replayed once.
  2. Accept mocked-boundary evidence
    A maintainer may merge based on the durable-owner test and Gateway idempotency contract while explicitly accepting the unproven live transport integration.

Technical review

Best possible solution:

Keep the direct throw into the durable retry owner and add a redacted real iMessage-to-Gateway transient-failure-and-recovery trace before merge.

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

Yes, from source: the pre-change terminal result completed the claim, while the new test encodes a transient resolver failure followed by durable redelivery. It was not independently executed in this read-only review.

Is this the best way to solve the issue?

Yes. Rethrowing to the already-established durable drain keeps retry and claim ownership in one place, rather than adding a channel-local retry path.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The added test exercises the real SQLite queue, iMessage ingress monitor, drain, retry, and tombstone behavior, but directly injects the reaction and mocks the Gateway resolution call; no real iMessage-to-Gateway after-fix recovery evidence was provided. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • remove proof: sufficient: Current real behavior proof status is mock_only, not sufficient.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦪 silver shellfish, so this older rating label is no longer current.
  • remove status: 👀 ready for maintainer look: Current PR status label is status: 📣 needs proof.

Label justifications:

  • P1: A transient Gateway failure can silently discard an operator’s approval tapback until the approval expires or another route is used.
  • merge-risk: 🚨 message-delivery: The PR changes whether an authorized approval reaction is completed or retained and replayed after a delivery-time Gateway failure.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The added test exercises the real SQLite queue, iMessage ingress monitor, drain, retry, and tombstone behavior, but directly injects the reaction and mocks the Gateway resolution call; no real iMessage-to-Gateway after-fix recovery evidence was provided. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

Likely related people:

  • obviyus: Authored the current-head durable-owner replay test that exercises this exact iMessage ingress path. (role: recent relevant contributor; confidence: medium; commits: 0db5a1a146e9; files: extensions/imessage/src/monitor.approval-reaction-replay.test.ts)

Rank-up moves

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

  • Attach redacted evidence of a real iMessage approval tapback surviving a temporary Gateway failure and resolving after recovery.

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-08-27T12:33:54.164Z sha ea134df8be61c77c8d79266c013f3c9de379df4b :: needs real behavior proof before merge. :: [P1] Propagate retryable resolver errors to the ingress drain
  • reviewed 2026-08-27T13:39:32.985Z sha dfa294d81e5c6ab39a341d97a4bbd6b404a69661 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-27T16:04:27.830Z sha 987b2a015deff7f03264fddb54e474955d8670be :: needs maintainer review before merge. :: none
  • reviewed 2026-08-27T18:52:55.059Z sha 987b2a015deff7f03264fddb54e474955d8670be :: needs maintainer review before merge. :: none

@wangmiao0668000666 wangmiao0668000666 changed the title fix(imessage): keep durable claim alive on transient Gateway approval errors fix(channels): replay signal and imessage approval reactions after transient Gateway failures Aug 27, 2026
@wangmiao0668000666

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Head dfa294d81e5 replaces the retry mechanism per the P1 finding and adds the durable replay proof:

  • [P1] Propagate retryable resolver errors to the ingress drain — fixed: extensions/imessage/src/approval-reactions.ts now throws the non-NotFound resolver error instead of returning handled:false. The throw escapes the priority lane into the real drain (src/channels/message/ingress-drain.ts), which owns release + retry. NotFound stays terminal. The dead resolver-error union member was removed; production delta is effectively net-neutral (one return swapped for throw error).
  • Real behavior proof — new extensions/imessage/src/monitor.approval-reaction-replay.test.ts runs the real SQLite ingress queue, real monitor/drain, and real approval-reaction resolution; only the Gateway approval-resolution call is mocked. It proves: the transient failure never falls through to the chat lane, the drain releases and reclaims the row, redelivery carries the identical resolution request, the replayed attempt completes the row, and the completion tombstone blocks a third dispatch.
  • Regression proof — the new replay test fails on both pre-fix variants (shipped resolver-error return on origin/main, and this PR's earlier handled:false revision) and passes with the fix; the rewritten unit test now asserts the throw and also fails pre-fix.
  • Verified on this head: imessage 35/35 (approval-reactions, monitor.approval-poll-ingress, replay), signal 20/20 (approval-reactions, signal-ingress.approval-reaction-replay), pnpm tsgo:extensions, pnpm tsgo:test:extensions, oxfmt --check — all green.

PR body and title updated to the final mechanism.

@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Aug 27, 2026
@clawsweeper

clawsweeper Bot commented Aug 27, 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. 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. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 27, 2026
@wangmiao0668000666

Copy link
Copy Markdown
Contributor Author

CI fix on head 987b2a015de: the changed throw contract invalidated one pre-existing poller test (stops scanning after an authorized resolver failure) that pinned the old resolver-error stop-polling behavior. Rewritten as propagates an authorized resolver failure and retries it on the next poll, covering the new semantics end to end at poller level:

  • the transient failure propagates out of the poll cycle (the monitor-provider caller logs it and re-polls next interval);
  • the cycle aborts before the later 👎 is resolved, so first-answer ordering survives the retry;
  • the binding stays registered; the next poll resolves the 👍 with an identical request and the 👎 never reaches the resolver.

Verified locally: full imessage suite 1179/1179 (node scripts/run-vitest.mjs extensions/imessage; two status.test.ts failures seen only under a zh_CN locale on this machine pass under LC_ALL=C and are unrelated to this change), oxfmt --check clean.

@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. label Aug 27, 2026
@openclaw-barnacle openclaw-barnacle Bot reopened this Aug 27, 2026
wangmiao0668000666 and others added 4 commits August 29, 2026 09:45
… 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
@obviyus
obviyus force-pushed the fix/signal-approval-reaction-replay branch from 987b2a0 to 0db5a1a Compare August 29, 2026 07:55
@openclaw-barnacle openclaw-barnacle Bot removed the channel: signal Channel integration: signal label Aug 29, 2026
@obviyus obviyus changed the title fix(channels): replay signal and imessage approval reactions after transient Gateway failures fix(imessage): replay approval reactions after transient Gateway failures Aug 29, 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. 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 29, 2026
@obviyus
obviyus merged commit b55dbce into openclaw:main Aug 29, 2026
130 checks passed
@obviyus

obviyus commented Aug 29, 2026

Copy link
Copy Markdown
Collaborator

Thanks @wangmiao0668000666!

Proof: On the merged head, an isolated iMessage reaction reached a real Gateway over authenticated WebSockets. The first approval completed but its response was dropped. The durable queue replayed the identical request, the Gateway returned the recorded terminal result, one approval event was emitted, and a duplicate reaction caused no third resolver call.

  • Bug: A temporary Gateway failure could consume an iMessage approval reaction without replaying it.
  • Fix: iMessage now sends non-terminal resolver errors to the durable ingress drain, which releases and replays the reaction. Signal already uses the same path.

Example

Before After
One temporary Gateway failure permanently loses the approval tapback. The same tapback replays after recovery and resolves once.

@wangmiao0668000666

Copy link
Copy Markdown
Contributor Author

Thanks for the review and the merge, @obviyus — much appreciated. 🙏

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 30, 2026
…ures (openclaw#130893)

Preserve operator approval reactions across transient Gateway failures by returning retry ownership to the durable ingress drain. NotFound remains terminal, while replayed terminal decisions stay idempotent.\n\nCo-authored-by: wangmiao0668000666 <[email protected]>\nCo-authored-by: Ayaan Zaidi <[email protected]>
@wangmiao0668000666
wangmiao0668000666 deleted the fix/signal-approval-reaction-replay branch October 28, 2026 07:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: imessage Channel integration: imessage merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: M status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: iMessage approval reactions are silently dropped on transient Gateway failures

2 participants