Skip to content

fix(signal): publish terminal status on permanent SSE rejection - #136178

Merged
obviyus merged 7 commits into
openclaw:mainfrom
masatohoshino:signal-sse-reconnect-terminal-status
Sep 2, 2026
Merged

obviyus merged 7 commits into
openclaw:mainfrom
masatohoshino:signal-sse-reconnect-terminal-status

Conversation

@masatohoshino

@masatohoshino masatohoshino commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

The native Signal Server-Sent Events (SSE) client retried every non-success HTTP response forever. Operators saw a generic recovering status even when the daemon had definitively rejected the request and needed a configuration fix.

Why This Change Was Made

The native client now preserves the HTTP status in a typed SignalSseRejectionError instead of leaving reconnect policy to parse error text.

The reconnect owner publishes the shared blocked terminal status for permanent 4xx responses and settles after one attempt. HTTP 408, 425, and 429 remain retryable. Network errors, stream ends, 5xx responses, receive-handler failures, managed-daemon exits, and the container WebSocket transport retain their existing recovery policy.

This matches signal-cli v0.14.7: its native event endpoint returns permanent 400, 404, 405, and 421 request rejections, while handler failure returns 500.

User Impact

openclaw channels status now shows a stopped, blocked Signal account with a terminal disconnect and recovery guidance after a permanent native SSE rejection. Transient failures still reconnect automatically.

Evidence

  • Current main cb75c1a820cdb521c3f6e38d1bf431c518442b43: a production Signal channel against a local HTTP 400 SSE endpoint made eight requests and remained running: true, lifecycle: "recovering", without a terminal flag.
  • Repaired head 3c1793b688151c3ca5b5421546b053706eedcf68: the same product path made one request and reported running: false, lifecycle: "blocked", terminalDisconnect: true, and healthState: "terminal-disconnect".
  • Transient control on the repaired head: after channels.start, an HTTP 503 endpoint received six requests and status remained running: true, lifecycle: "recovering", without a terminal flag.
  • Regression provenance: the new real-server test fails on current main because the permanent case reconnects a second time; the 503 control passes.
  • Focused tests: node scripts/run-vitest.mjs extensions/signal/src/client.test.ts extensions/signal/src/client-adapter.test.ts extensions/signal/src/sse-reconnect.test.ts extensions/signal/src/sse-reconnect.real-server.test.ts — 37 passed.
  • Checks: Oxfmt, Oxlint, conflict markers, import cycles, extension import boundaries, max-lines, assertion safety, coercion helpers, deprecated API use, and test-temp reporting passed.
  • CI repair: run 33621364324 completed its bundled and guard checks, then failed because three comparison-base fetches ran after authenticated checkout discarded its token. Those bases now arrive in the authenticated checkout; 419 focused workflow/Git-owner tests and the workflow guard passed.
  • Upstream contract: https://github.com/AsamK/signal-cli/blob/b01b6b370dc063599a1a2b9fde0f5ff4e2d78fe8/src/main/java/org/asamk/signal/http/HttpServerHandler.java#L169-L241

Test Audit

The real-server regression crosses the production reconnect loop, client adapter, native HTTP client, and protocol endpoint. It adds no test-only production seam. The prior mocked 401-only test was removed because it could prove the mock without proving the changed boundary.

runSignalSseLoop's catch block treated every reconnect failure
identically, always publishing lifecycle:'recovering' and retrying
forever -- including a 401 status-carrying rejection that means the
signal-cli daemon permanently rejects the account (unregistered or
unlinked identity), not a transient network blip. Discriminate the
401 case, publish the shared channelBlockedPatch terminal status with
an actionable re-link message, and stop the retry loop instead of
looping on the generic recovering status forever.
The prior wording asserted the account was unregistered/unlinked as the
sole cause of a 401 SSE rejection. signal-cli's own HTTP daemon does not
document 401 as exclusively an account-registration signal, and a daemon
run behind an operator's own auth proxy could return the same status for
a misconfigured proxy credential. Cover both plausible causes instead of
asserting one.
@clawsweeper

clawsweeper Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@masatohoshino
masatohoshino marked this pull request as ready for review September 2, 2026 08:43
@openclaw-barnacle openclaw-barnacle Bot added channel: signal Channel integration: signal size: XS labels Sep 2, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 2, 2026
@clawsweeper

clawsweeper Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge. Reviewed September 2, 2026, 4:50 AM ET / 08:50 UTC.

ClawSweeper review

What this changes

The PR makes a native Signal SSE 401 publish a terminal blocked channel status with operator recovery guidance instead of retrying indefinitely.

Merge readiness

⚠️ Needs maintainer review before merge - 3 items remain

Keep open: the PR addresses a real Signal status gap and supplies credible boundary-level before/after evidence, but its new terminal decision derives protocol state from a formatted error message rather than a structured client result.

Priority: P2
Reviewed head: f0418a1e9ebcc73a8ba963f5260f5f6104eb9182

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The behavior proof is credible, but the patch should replace its formatted-error dependency with a structured status boundary.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The PR body supplies before/after live output from the real reconnect-loop entry point using the real native transport against injected local HTTP 401 and socket-failure cases; source confirms that the native client produces the exercised non-2xx failure path. The colocated mocked test is supplemental.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body supplies before/after live output from the real reconnect-loop entry point using the real native transport against injected local HTTP 401 and socket-failure cases; source confirms that the native client produces the exercised non-2xx failure path. The colocated mocked test is supplemental.
Evidence reviewed 7 items Native transport error source: The native SSE client receives every non-2xx response and currently converts its HTTP status into a human-readable Error message; this is the source that the new retry-loop branch parses.
Introduced terminal branch: The PR-added helper parses that formatted message and uses a 401 match to publish channelBlockedPatch and return before reconnect scheduling.
Gateway preserves terminal diagnosis: A terminalDisconnect status prevents the Gateway from replacing the operator diagnosis with a generic clean-exit error or scheduling recovery.
Findings 1 actionable finding [P2] Carry the SSE status outside the formatted error message
Security None None.

How this fits together

The Signal plugin opens an SSE event stream to the Signal daemon and reports connection lifecycle to the Gateway. The Gateway retains terminal channel status so health checks and operators see that manual recovery is required.

flowchart LR
  A[Signal daemon] --> B[Native SSE client]
  B --> C[Signal reconnect loop]
  C --> D{HTTP failure status}
  D -->|401| E[Blocked channel status]
  D -->|other failure| F[Retrying status]
  E --> G[Gateway health and operator]
  F --> G
Loading

Before merge

  • Carry the SSE status outside the formatted error message (P2) - The new terminal branch treats Error.message from the native client as a protocol. A wording change or error wrapper in that client turns the same 401 back into the generic retry path without a type-level failure. Expose the HTTP status in a typed native SSE error/result and classify it from that structured field instead.
  • Resolve merge risk (P1) - Until the HTTP status is carried as structured data, an otherwise harmless rewrite or wrapping of the native client's error text can silently return a 401 to the indefinite recovering/retry path.
  • Complete next step (P2) - Replace formatted-error parsing with a structured native SSE status signal before merge.

Findings

  • [P2] Carry the SSE status outside the formatted error message — extensions/signal/src/sse-reconnect.ts:33-36
Agent review details

Security

None.

PR surface

Source +19, Tests +23. Total +42 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 20 1 +19
Tests 1 23 0 +23
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 43 1 +42

Review metrics

Metric Value Why it matters
Production versus test LOC production +20/-1 (net +19); tests +23/-0 The production growth creates a new status-classification path; the repair should keep that boundary compact and structured.

Merge-risk options

Maintainer options:

  1. Carry the response status structurally (recommended)
    Replace error-message parsing with a typed native SSE response error or equivalent structured result, while preserving the demonstrated 401 terminal behavior and retries for other failures.
  2. Accept the message-format coupling
    Keep the current parser only if maintainers accept that future wording changes in the native client can alter reconnect behavior.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Replace parsing of the native SSE error message with a structured status error at the client boundary; preserve 401 terminal handling and other-status retries, and add focused client-to-reconnect coverage.

Technical review

Best possible solution:

Carry the native SSE HTTP status in a typed error or result at the client boundary, then retain the existing 401 blocked-status behavior and generic retry handling for non-401 failures.

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

Yes—current source proves that native non-2xx SSE responses become generic errors and enter the retry path, and the PR body includes a before/after production-entry-point harness trace for a 401 and transient control.

Is this the best way to solve the issue?

No—the terminal 401 policy is appropriate and reaches the correct Gateway status owner, but formatting an Error message as the status protocol is weaker than carrying the status structurally from the native client.

Full review comments:

  • [P2] Carry the SSE status outside the formatted error message — extensions/signal/src/sse-reconnect.ts:33-36
    The new terminal branch treats Error.message from the native client as a protocol. A wording change or error wrapper in that client turns the same 401 back into the generic retry path without a type-level failure. Expose the HTTP status in a typed native SSE error/result and classify it from that structured field instead.
    Confidence: 0.94

Overall correctness: patch is incorrect
Overall confidence: 0.9

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: The change repairs a limited-scope but operator-visible Signal channel failure mode.
  • add merge-risk: 🚨 availability: A native 401 now intentionally stops automatic inbound reconnection until an operator resolves the cause and restarts the channel.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body supplies before/after live output from the real reconnect-loop entry point using the real native transport against injected local HTTP 401 and socket-failure cases; source confirms that the native client produces the exercised non-2xx failure path. The colocated mocked test is supplemental.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (live_output): The PR body supplies before/after live output from the real reconnect-loop entry point using the real native transport against injected local HTTP 401 and socket-failure cases; source confirms that the native client produces the exercised non-2xx failure path. The colocated mocked test is supplemental.

Label justifications:

  • P2: The change repairs a limited-scope but operator-visible Signal channel failure mode.
  • merge-risk: 🚨 availability: A native 401 now intentionally stops automatic inbound reconnection until an operator resolves the cause and restarts the channel.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (live_output): The PR body supplies before/after live output from the real reconnect-loop entry point using the real native transport against injected local HTTP 401 and socket-failure cases; source confirms that the native client produces the exercised non-2xx failure path. The colocated mocked test is supplemental.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body supplies before/after live output from the real reconnect-loop entry point using the real native transport against injected local HTTP 401 and socket-failure cases; source confirms that the native client produces the exercised non-2xx failure path. The colocated mocked test is supplemental.

Evidence

Acceptance criteria:

  • [P1] node scripts/run-vitest.mjs extensions/signal/src/client.test.ts extensions/signal/src/sse-reconnect.test.ts.
  • [P1] node scripts/check-changed.mjs -- extensions/signal/src/client.ts extensions/signal/src/client-adapter.ts extensions/signal/src/sse-reconnect.ts extensions/signal/src/client.test.ts extensions/signal/src/sse-reconnect.test.ts.

What I checked:

  • Native transport error source: The native SSE client receives every non-2xx response and currently converts its HTTP status into a human-readable Error message; this is the source that the new retry-loop branch parses. (extensions/signal/src/client.ts:309, f0418a1e9ebc)
  • Introduced terminal branch: The PR-added helper parses that formatted message and uses a 401 match to publish channelBlockedPatch and return before reconnect scheduling. (extensions/signal/src/sse-reconnect.ts:28, f0418a1e9ebc)
  • Gateway preserves terminal diagnosis: A terminalDisconnect status prevents the Gateway from replacing the operator diagnosis with a generic clean-exit error or scheduling recovery. (src/gateway/server-channels.ts:944, f0418a1e9ebc)
  • Production entry point: Signal account startup creates an account status sink and passes it through monitorSignalProvider into the reconnect loop, so the blocked patch reaches Gateway channel status. (extensions/signal/src/channel.ts:590, f0418a1e9ebc)
  • Current-main check: Current main still has the generic reconnect catch path and does not contain the PR's 401 terminal branch, so this work is not already implemented. (extensions/signal/src/sse-reconnect.ts:105, fae30c7106b6)
  • Real behavior proof: The complete PR body records baseline and after-fix runs of the real exported reconnect loop against local HTTP servers: 401 changes from recovering to blocked while a socket-hangup control remains recovering. The focused mocked test is supplemental. (f0418a1e9ebc)

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

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

  • Carry the native SSE response status through a typed error or result and add focused coverage from that boundary to the reconnect decision.

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.

@obviyus obviyus self-assigned this Sep 2, 2026
…regex

sse-reconnect.ts detected the 401 terminal case by regex-parsing
client.ts's formatted `Signal SSE failed (${status} ${statusText})`
Error.message. A wording or wrapping change in the producer would
silently break the match and route a permanent rejection back into
the infinite retry path.

client.ts now throws SignalSseRejectionError, carrying the HTTP
status as a typed field; sse-reconnect.ts reads it directly. Mirrors
the WhatsApp channel's own precedent (session-errors.ts getStatusCode
reads a structured status field, never regex on message text).

Addresses ClawSweeper findings 3f796596872acbd1 / 611efac52d052c28 on
PR openclaw#136178.
@obviyus

obviyus commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@obviyus
obviyus merged commit 29bf3e8 into openclaw:main Sep 2, 2026
239 checks passed
@obviyus

obviyus commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator

Thanks @masatohoshino!

Proof: A production Signal channel against a protocol-real HTTP 400 SSE endpoint made one request, stopped reconnecting, and published blocked terminal status. An HTTP 503 control kept reconnecting and remained recovering.

  • Bug: A definitive native Signal SSE rejection retried forever and left operators with only recovering status.
  • Fix: The native client preserves HTTP status structurally, and the reconnect owner publishes one actionable terminal failure for permanent 4xx responses while transient failures retain reconnect behavior.
Before After
HTTP 400 retried forever with recovering status HTTP 400 stops after one request with blocked terminal status

steipete added a commit that referenced this pull request Sep 2, 2026
Reuse the gateway CLI fixture cleanup from #136469 (667ce2b) and
the landed startup-recovery queue assertions from #136473 (564e544).
These address independent lint and shared-worker test failures while
preserving all process, state, cancellation, and survivor assertions.

Keep Vincent Koc's scanner implementation and original PR ancestry unchanged.
The new commit also refreshes pull-request CI against main's authenticated
checkout repair from #136178.
steipete added a commit that referenced this pull request Sep 2, 2026
Remove the temporary copies of the CLI fixture and startup queue test fixes.
Main now owns the CLI suite split in aef65cc and queue assertions in #136473.
Keeping the earlier fixture cleanup here conflicts with main's new shared
test support and health suite.

Restore the cumulative PR tree exactly to Vincent Koc's reviewed 4a35cef
without replacing his ancestry. The merge then retains main's canonical
test repairs and authenticated checkout fix from #136178.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 3, 2026
…claw#136178)

## What Problem This Solves

The native Signal Server-Sent Events (SSE) client retried every non-success HTTP response forever. Operators saw a generic recovering status even when the daemon had definitively rejected the request and needed a configuration fix.

## Why This Change Was Made

The native client now preserves the HTTP status in a typed `SignalSseRejectionError` instead of leaving reconnect policy to parse error text.

The reconnect owner publishes the shared blocked terminal status for permanent 4xx responses and settles after one attempt. HTTP 408, 425, and 429 remain retryable. Network errors, stream ends, 5xx responses, receive-handler failures, managed-daemon exits, and the container WebSocket transport retain their existing recovery policy.

This matches signal-cli v0.14.7: its native event endpoint returns permanent 400, 404, 405, and 421 request rejections, while handler failure returns 500.

## User Impact

`openclaw channels status` now shows a stopped, blocked Signal account with a terminal disconnect and recovery guidance after a permanent native SSE rejection. Transient failures still reconnect automatically.

## Evidence

- Current main `1e38dfcc25c77a2412aaa0f8b344c76a4cf85714`: a production Signal channel against a local HTTP 400 SSE endpoint made eight requests and remained `running: true`, `lifecycle: "recovering"`, without a terminal flag.
- Repaired head `3c1793b688151c3ca5b5421546b053706eedcf68`: the same product path made one request and reported `running: false`, `lifecycle: "blocked"`, `terminalDisconnect: true`, and `healthState: "terminal-disconnect"`.
- Transient control on the repaired head: after `channels.start`, an HTTP 503 endpoint received six requests and status remained `running: true`, `lifecycle: "recovering"`, without a terminal flag.
- Regression provenance: the new real-server test fails on current main because the permanent case reconnects a second time; the 503 control passes.
- Focused tests: `node scripts/run-vitest.mjs extensions/signal/src/client.test.ts extensions/signal/src/client-adapter.test.ts extensions/signal/src/sse-reconnect.test.ts extensions/signal/src/sse-reconnect.real-server.test.ts` — 37 passed.
- Checks: Oxfmt, Oxlint, conflict markers, import cycles, extension import boundaries, max-lines, assertion safety, coercion helpers, deprecated API use, and test-temp reporting passed.
- CI repair: run `33621364324` completed its bundled and guard checks, then failed because three comparison-base fetches ran after authenticated checkout discarded its token. Those bases now arrive in the authenticated checkout; 419 focused workflow/Git-owner tests and the workflow guard passed.
- Upstream contract: https://github.com/AsamK/signal-cli/blob/b01b6b370dc063599a1a2b9fde0f5ff4e2d78fe8/src/main/java/org/asamk/signal/http/HttpServerHandler.java#L169-L241

## Test Audit

The real-server regression crosses the production reconnect loop, client adapter, native HTTP client, and protocol endpoint. It adds no test-only production seam. The prior mocked 401-only test was removed because it could prove the mock without proving the changed boundary.

Co-authored-by: Ayaan Zaidi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: signal Channel integration: signal merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants