Repository navigation
fix(signal): recover inbound messages after crashes - #109907
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3827ae29fe
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| return { | ||
| eventId: JSON.stringify([senderKey, timestamp]), | ||
| laneKey: groupId ? `group:${groupId}` : `direct:${senderKey}`, |
There was a problem hiding this comment.
Preserve configured Signal debounce across durable lanes
When messages.inbound.debounceMs is configured and two same-sender/group Signal text messages arrive within the debounce window, this per-conversation laneKey makes createChannelIngressDrain keep the second row blocked while the first claim is deferred, so the second event cannot reach createChannelInboundDebouncer until the first message has already flushed/adopted. That breaks the documented batching behavior in docs/concepts/messages.md and the existing handler-level debounce tests; the changed monitor test now expects two separate replies instead of one batched turn.
Useful? React with 👍 / 👎.
| function inspectSignalIngressEvent(event: SignalSseEvent): SignalIngressEventFacts | null { | ||
| const envelope = parseReceiveEnvelope(event); | ||
| if (!envelope || "syncMessage" in envelope) { | ||
| return null; |
There was a problem hiding this comment.
Keep logging receive exception events
For receive events whose payload contains only exception.message, parseReceiveEnvelope() returns null and inspectSignalIngressEvent() drops the event before it reaches createSignalEventHandler, which is where receive exception: ... used to be logged. In manual/container receive modes this makes signal-cli receive errors disappear silently instead of surfacing through runtime.error, so exception-only events should still be dispatched/logged or logged at this durable chokepoint before being ignored.
Useful? React with 👍 / 👎.
… debounce Signal's receive loop was purely in-memory: a crash between signal-cli receive and dispatch silently lost the message with no re-emit. Dispatchable receive envelopes (data/edit/reaction; never sync/receipt/typing) now journal their raw JSON at one chokepoint (event_id = [sender uuid/number, timestamp], lane per group/sender) before the SSE loop continues — the awaited enqueue is the only receive boundary signal-cli offers. Dispatch, retry, dead-letter, and 30d/1000 tombstones run through the core drain with startup + interval pumps. Debounce merging stays on under the drain: claims defer (held, watchdog armed) instead of completing at enqueue, a merged flush fans adoption out to every constituent claim, terminal no-dispatch turns settle by completing (skipped -> completed), and exhausted flush retries abandon claims back to queue retry policy. Regression tests cover deferred return, merged fan-out adoption, and no-adoption settlement. No prior replay guard existed; this adoption adds durable cross-restart dedupe. Autoreview blocked by codex sandbox network in the build stage; full manual review performed (caught the debounce bypass and the unsettled gated claims). Part of the #109657 fleet adoption program (wave 1).
a16fcb9 to
683b4be
Compare
There was a problem hiding this comment.
💡 Codex Review
When a durable Signal event reaches inboundLane.enqueue, createInboundDebouncer catches onFlush exceptions and only calls onError, so this await still resolves if handleSignalInboundMessage fails before the reply lane adopts the turn (for example, an attachment/RPC or non-session preflight error). The code then returns deferred, leaving the queue claim held until the stall watchdog dead-letters it instead of releasing it for the ingress retry policy, so transient receive failures can permanently drop the message rather than replay it.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Land-ready evidence for exact head
Proof gap: no live Signal account exercise was performed because no authorized test credential or external recipient was in scope. The full Signal extension suite covers the changed durable-ingress and claim-settlement paths. |
|
Merged via squash.
|
* fix(signal): adopt durable ingress drain with deferred claims through debounce Signal's receive loop was purely in-memory: a crash between signal-cli receive and dispatch silently lost the message with no re-emit. Dispatchable receive envelopes (data/edit/reaction; never sync/receipt/typing) now journal their raw JSON at one chokepoint (event_id = [sender uuid/number, timestamp], lane per group/sender) before the SSE loop continues — the awaited enqueue is the only receive boundary signal-cli offers. Dispatch, retry, dead-letter, and 30d/1000 tombstones run through the core drain with startup + interval pumps. Debounce merging stays on under the drain: claims defer (held, watchdog armed) instead of completing at enqueue, a merged flush fans adoption out to every constituent claim, terminal no-dispatch turns settle by completing (skipped -> completed), and exhausted flush retries abandon claims back to queue retry policy. Regression tests cover deferred return, merged fan-out adoption, and no-adoption settlement. No prior replay guard existed; this adoption adds durable cross-restart dedupe. Autoreview blocked by codex sandbox network in the build stage; full manual review performed (caught the debounce bypass and the unsettled gated claims). Part of the openclaw#109657 fleet adoption program (wave 1). * fix(signal): keep ingress test helpers private * fix(signal): align ingress lifecycle result types
* fix(signal): adopt durable ingress drain with deferred claims through debounce Signal's receive loop was purely in-memory: a crash between signal-cli receive and dispatch silently lost the message with no re-emit. Dispatchable receive envelopes (data/edit/reaction; never sync/receipt/typing) now journal their raw JSON at one chokepoint (event_id = [sender uuid/number, timestamp], lane per group/sender) before the SSE loop continues — the awaited enqueue is the only receive boundary signal-cli offers. Dispatch, retry, dead-letter, and 30d/1000 tombstones run through the core drain with startup + interval pumps. Debounce merging stays on under the drain: claims defer (held, watchdog armed) instead of completing at enqueue, a merged flush fans adoption out to every constituent claim, terminal no-dispatch turns settle by completing (skipped -> completed), and exhausted flush retries abandon claims back to queue retry policy. Regression tests cover deferred return, merged fan-out adoption, and no-adoption settlement. No prior replay guard existed; this adoption adds durable cross-restart dedupe. Autoreview blocked by codex sandbox network in the build stage; full manual review performed (caught the debounce bypass and the unsettled gated claims). Part of the openclaw#109657 fleet adoption program (wave 1). * fix(signal): keep ingress test helpers private * fix(signal): align ingress lifecycle result types
Related: #109657
AI-assisted implementation and review.
What Problem This Solves
Fixes an issue where Signal users could silently lose an inbound message when OpenClaw crashed after signal-cli delivered it but before the agent turn adopted it. Signal's receive stream does not re-emit an already-consumed envelope after reconnect, so the prior in-memory receive loop had no recovery path.
Why This Change Was Made
Signal now journals each raw receive envelope at the single transport chokepoint before returning ownership. A stable event ID derived from
[sender, timestamp]supplies durable cross-restart deduplication, while direct messages use sender lanes and group messages use group lanes to preserve conversation ordering.Ingress claims remain deferred through debounce. One merged turn fans its adoption or abandonment settlement across every constituent claim, and deliberately handled no-adoption paths settle their claims instead of stalling. No durable Signal replay guard existed before this change; this adds durable deduplication rather than replacing a prior guard.
User Impact
Signal messages received before a crash can now replay after restart until an agent turn durably adopts them. Adopted duplicates remain rejected by durable tombstones, conversation ordering stays isolated by sender or group, and debounced messages retain correct claim ownership.
Evidence
PATH=/Users/steipete/Projects/openclaw/node_modules/.bin:$PATH node scripts/run-vitest.mjs extensions/signal— 37 files and 571 tests passed, including three new claim-ownership regression tests for deferred adoption, merged debounce fan-out, and handled no-adoption settlement.node scripts/check-deadcode-exports.mjs— zero unused exports across production, full-tree, and script scans.node scripts/check-deadcode-unused-files.mjs— zero unused files across production and full-tree scans./Users/steipete/Projects/openclaw/node_modules/.bin/oxfmt --check extensions/signal/srcandnode scripts/run-oxlint.mjs extensions/signal/src— clean.git diff --check origin/main -- extensions/signal— clean.The initial structured autoreview was blocked by the isolated reviewer sandbox's network access. Manual review covered receive chokepoints, queue lifecycle, client stream ordering and error propagation, debounce and control lanes, merged fan-out, non-dispatch settlement, retry abandonment, and the core ingress-drain contract; it caught and fixed an earlier debounce bypass and unsettled gated-claim path. A fresh targeted autoreview of the follow-up helper-privacy fix completed clean; a later full-branch retry reproduced the network stall.