Skip to content

fix(signal): recover inbound messages after crashes - #109907

Merged
steipete merged 3 commits into
mainfrom
claude/ingress-signal
Jul 17, 2026
Merged

steipete merged 3 commits into
mainfrom
claude/ingress-signal

Conversation

@steipete

Copy link
Copy Markdown
Contributor

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/src and node 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.

@openclaw-barnacle openclaw-barnacle Bot added channel: signal Channel integration: signal size: XL maintainer Maintainer-authored PR labels Jul 17, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +149 to +151
return {
eventId: JSON.stringify([senderKey, timestamp]),
laneKey: groupId ? `group:${groupId}` : `direct:${senderKey}`,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment on lines +113 to +116
function inspectSignalIngressEvent(event: SignalSseEvent): SignalIngressEventFacts | null {
const envelope = parseReceiveEnvelope(event);
if (!envelope || "syncMessage" in envelope) {
return null;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

steipete added 3 commits July 17, 2026 11:27
… 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).
@steipete
steipete force-pushed the claude/ingress-signal branch from a16fcb9 to 683b4be Compare July 17, 2026 10:27

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

await inboundLane.enqueue(entry);

P2 Badge Release durable claims when debounce flushes fail

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".

@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready evidence for exact head 683b4be62ea56da1c0b911e100af5295e56cb8c2:

  • Hosted CI run 29573546684: all exact-head check runs completed successfully, skipped, or neutral; openclaw/ci-gate green.
  • PATH=/Users/steipete/Projects/openclaw/node_modules/.bin:$PATH node scripts/run-vitest.mjs extensions/signal: 37 files, 571 tests passed.
  • Three claim-ownership regressions pass: deferred adoption, merged debounce fan-out, and handled no-adoption settlement.
  • Signal format/lint clean; targeted Signal tsgo clean.
  • node scripts/check-deadcode-exports.mjs and node scripts/check-deadcode-unused-files.mjs: hard-zero gates clean.
  • Repo-native review artifacts validated READY FOR /prepare-pr with zero findings.
  • CI initially exposed two branch-owned Signal return/narrowing type errors; fixed by the rebased head commit and verified green.
  • A separate Google Meet boundary failure reproduced on plain main; no unrelated patch was added here. Main healed via fix: restore bundled plugin boundary checks after Meet export coverage #109915 and test(google-meet): keep temp cleanup inside plugin boundary #109917, this branch rebased past both, and the fresh exact-head run is green.

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.

@steipete
steipete merged commit dd54c18 into main Jul 17, 2026
87 checks passed
@steipete
steipete deleted the claude/ingress-signal branch July 17, 2026 10:34
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 18, 2026
* 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
zooqueen pushed a commit to zooqueen/openclaw that referenced this pull request Sep 11, 2026
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: signal Channel integration: signal maintainer Maintainer-authored PR size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant