Skip to content

fix(line): surface partial delivery when rich or media send fails alongside text - #100996

Merged
steipete merged 4 commits into
openclaw:mainfrom
masatohoshino:fix/line-quick-reply-partial-delivery
Jul 6, 2026
Merged

steipete merged 4 commits into
openclaw:mainfrom
masatohoshino:fix/line-quick-reply-partial-delivery

Conversation

@masatohoshino

@masatohoshino masatohoshino commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

When a LINE reply contains both quick-reply buttons and rich or media content (an image, a flex/template bubble, or a location), the plugin sends the rich/media messages first so the quick replies can stay attached to the trailing text bubble. That first send was wrapped in a try/catch that only logged the error and never rethrew:

if (hasQuickReplies && hasRichOrMedia) {
  try {
    await sendLineMessages([...richMessages, ...mediaMessages], false);
  } catch (err) {
    deps.onReplyError?.(err); // swallowed — text still sends below
  }
}

So if the image/flex/location push failed (e.g. LINE rejects an unreachable image URL or a malformed flex), the text still sent and the channel reported a full success (recordChannelRuntimeState({ lastOutboundAt })). The user silently lost the rich/media bubble with no failure surfaced.

This path is not covered by the generic honest-delivery handling: monitor-durable.ts opts payloads carrying channelData.line or media out of the durable delivery path, so exactly these payloads depend on this custom deliver() callback being honest — and it was not. The sibling branch in the same file (rich/media without quick replies) already lets the error propagate, so the two paths were inconsistent.

Why This Change Was Made

deliverLineAutoReply is consumed by the core dispatcher (dispatchReplyWithBufferedBlockDispatcher), which already has a first-class contract for partial delivery: isVisiblePartialDeliveryError (src/auto-reply/dispatch.ts) treats a thrown error carrying visibleReplySent: true as "the visible reply was sent, but delivery partially failed" — it records the sent text on the reply fence and rethrows so the failure is surfaced, without resending the text.

The fix unifies both branches of the chunks.length > 0 block: a rich/media send failure from either ordering is captured and returned from deliverLineAutoReply alongside replyTokenUsed (as a visibleReplySent-tagged error), rather than thrown from deep inside. The monitor callback adopts the consumed reply-token state, then surfaces the partial failure. Returning-then-surfacing (instead of throwing directly) keeps replyTokenUsed correct so later blocks in the same turn route through the right delivery path instead of retrying an already-consumed reply token. This makes the previously-swallowing quick-reply branch consistent with the already-throwing sibling. The visibleReplySent tag marks the text as visibly delivered so the foreground reply-fence does not treat the reply as undelivered.

The swallow has existed since the plugin was first added (c96ffa7186, #1630); it is an original inconsistency, not a deliberate design choice.

User Impact

  • LINE replies that mix quick replies with an image/flex/location no longer report success when the rich/media bubble fails to send. Operators/health now see the failure instead of a false clean delivery, while the text the user did receive is preserved (no duplicate resend).
  • No config, schema, or behavior change on the success path; happy-path delivery and quick-reply ordering are unchanged.

Evidence

  • Exact prepared head: d2cd1284742cf2036044eb06a82c6691172597e0.

  • Live localhost HTTP E2E through the installed @line/bot-sdk 11.1.0 and its real MessagingApiClient:

    current main:
    scenario=quick result=pass order=/v2/bot/message/push->/v2/bot/message/reply failure_surfaced=false
    visible_text=delivered rich_message=failed partial_error=hidden duplicate_text=none
    
    exact PR head:
    scenario=quick result=pass order=/v2/bot/message/push->/v2/bot/message/reply failure_surfaced=true
    scenario=plain result=pass order=/v2/bot/message/reply->/v2/bot/message/push failure_surfaced=true
    visible_text=delivered rich_message=failed partial_error=surfaced duplicate_text=none
    

    The server deliberately returned HTTP 400 for the rich-message push and HTTP 200 for the visible text reply. The exact head retained the real SDK HTTPFetchError, tagged it with sentBeforeError: true and visibleReplySent: true, adopted the reply token, and sent no duplicate text.

  • node scripts/run-vitest.mjs extensions/line/src/auto-reply-delivery.test.ts — 9/9 pass, including both send orders and a frozen dependency error.

  • Fresh whole-branch GPT-5.5 AutoReview — no accepted/actionable findings (confidence 0.82).

  • git diff --check — clean.

  • Exact-head CI — code, type, lint, build, and test shards run on the prepared tree.

  • A new sanitized AWS lease was unavailable at the owner active-lease limit (11/10), so the repository-permitted narrow local test fallback and exact-head hosted CI were used.

  • Official LINE contracts checked: quick replies disappear after a later message and the last message object owns the displayed quick reply.

  • Scope: 2 production files and 1 focused test file. The contributor-authored release entry was removed for the maintainer batch changelog pass. No cross-channel, config, dependency, or durable-path changes.

Compatibility / Migration

  • Backward compatible? Yes
  • Config/env changes? No
  • Migration needed? No

Risks and Mitigations

  • Risk: on a partial failure the reply is surfaced as failed, so recordChannelRuntimeState({ lastOutboundAt }) is skipped for that reply.
    • Mitigation: intended — a partially-failed delivery should not record a clean outbound success. The reply-token state is still adopted before surfacing, so same-turn follow-ups route correctly (this was an earlier review concern, now handled by returning the failure instead of throwing from inside the delivery helper).
  • Note (not introduced by this PR): the shared ACP block-reply finalizer (dispatch-acp.ts) counts any thrown deliver as a failed visible delivery via the dispatcher's failedCounts, independent of visibleReplySent. A "throw after visible text was sent" shape already exists in shipped LINE code (the sibling branch and the original monitor callback both throw without a catch), and it is only reachable when a session is explicitly bound to an ACP runtime (a default LINE turn on the embedded agent never reaches finalizeAcpTurnOutput). This PR does not change that behavior; visibleReplySent only feeds the orthogonal foreground reply-fence.

@openclaw-barnacle openclaw-barnacle Bot added channel: line Channel integration: line size: S labels Jul 6, 2026
@clawsweeper

clawsweeper Bot commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 6, 2026, 12:57 PM ET / 16:57 UTC.

Summary
The PR extends LINE auto-reply delivery to return and surface visible partial-delivery errors when rich/media sends fail after visible text is delivered.

PR surface: Source +37, Tests +66. Total +103 across 3 files.

Reproducibility: yes. at source level: current main catches a rich/media send failure in the quick-reply ordering path, continues to send text, and the monitor records outbound success after a normal return. I did not run a live LINE account reproduction in this read-only review.

Review metrics: 1 noteworthy metric.

  • LINE partial-failure paths: 2 rich/media ordering paths covered. The patch changes both quick-reply-before-text and text-before-rich failure orders to surface visible partial delivery rather than silent success.

Merge readiness
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🐚 platinum hermit
Result: blocked until real behavior proof from a real setup is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P1] Add redacted real LINE proof, runtime logs, copied live output, or a maintainer proof override showing partial failure is surfaced without resending visible text.

Proof guidance:

  • [P1] Needs real behavior proof before merge: Needs real behavior proof before merge: the PR body lists unit tests, formatting, and type checks, but no live LINE run, redacted runtime log, copied live output, or linked artifact showing the after-fix behavior. Redact IPs, tokens, phone numbers, non-public endpoints, and other private details; updating the PR body should trigger re-review, or a maintainer can comment @clawsweeper re-review. 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.

Risk before merge

  • [P1] Contributor proof is limited to unit tests, formatting, type checks, and CI; it does not show a real LINE bot/chat, runtime log, live output, or maintainer proof override for the changed delivery path.
  • [P1] The PR intentionally changes a partial rich/media failure from clean outbound success to dispatcher-visible failure, so health/error semantics and skipped lastOutboundAt should be accepted before merge.

Maintainer options:

  1. Require LINE proof before merge (recommended)
    Ask for a redacted live LINE run, runtime logs, or linked live output showing the text remains visible while the rich/media failure is surfaced without duplicate resend.
  2. Accept a maintainer proof override
    A maintainer with LINE context can explicitly accept the source-level proof and unit tests without waiting for contributor live proof.

Next step before merge

  • [P1] The remaining blocker is contributor real behavior proof or maintainer proof override, not a narrow source repair for ClawSweeper to queue.

Security
Cleared: The diff only changes LINE delivery logic and colocated tests; no dependency, workflow, secret, package, install, or code-execution surface change was found.

Review details

Best possible solution:

Land the focused LINE-plugin fix after redacted real LINE/runtime proof or an explicit maintainer proof override, preserving the existing visibleReplySent partial-delivery contract.

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

Yes at source level: current main catches a rich/media send failure in the quick-reply ordering path, continues to send text, and the monitor records outbound success after a normal return. I did not run a live LINE account reproduction in this read-only review.

Is this the best way to solve the issue?

Yes: the fix stays in the LINE plugin, reuses the existing visibleReplySent partial-delivery contract, and returns the error so the monitor can adopt replyTokenUsed before surfacing it. A generic durable-delivery fix would miss channelData.line and media payloads, which are deliberately kept on the plugin delivery path.

AGENTS.md: found and applied where relevant.

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

Label changes

Label changes:

  • add P2: The PR fixes a real LINE message-delivery observability bug with limited channel-specific blast radius.
  • add merge-risk: 🚨 message-delivery: The diff changes LINE delivery failure propagation and visible-send accounting when rich/media sends fail after text is visible.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab 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: Needs real behavior proof before merge: the PR body lists unit tests, formatting, and type checks, but no live LINE run, redacted runtime log, copied live output, or linked artifact showing the after-fix behavior. Redact IPs, tokens, phone numbers, non-public endpoints, and other private details; updating the PR body should trigger re-review, or a maintainer can comment @clawsweeper re-review. 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.

Label justifications:

  • P2: The PR fixes a real LINE message-delivery observability bug with limited channel-specific blast radius.
  • merge-risk: 🚨 message-delivery: The diff changes LINE delivery failure propagation and visible-send accounting when rich/media sends fail after text is visible.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab 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: Needs real behavior proof before merge: the PR body lists unit tests, formatting, and type checks, but no live LINE run, redacted runtime log, copied live output, or linked artifact showing the after-fix behavior. Redact IPs, tokens, phone numbers, non-public endpoints, and other private details; updating the PR body should trigger re-review, or a maintainer can comment @clawsweeper re-review. 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

PR surface:

Source +37, Tests +66. Total +103 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 2 47 10 +37
Tests 1 66 0 +66
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 113 10 +103

What I checked:

  • Repository policy applied: Root AGENTS.md and extensions/AGENTS.md were read; their deep review, plugin-boundary, and real-behavior-proof guidance apply to this LINE plugin PR. (AGENTS.md:1, 675045f49f11)
  • Current main silently swallows the rich/media failure: In the quick-reply plus rich/media branch, current main catches a rich/media send error, only calls onReplyError, and continues into text chunk delivery. (extensions/line/src/auto-reply-delivery.ts:144, 675045f49f11)
  • Current monitor records clean outbound success after normal return: The LINE monitor records lastOutboundAt after deliverLineAutoReply returns, so the swallowed rich/media failure can be reported as a clean outbound delivery today. (extensions/line/src/monitor.ts:261, 675045f49f11)
  • Existing dispatcher supports visible partial delivery: dispatch.ts already treats errors with visibleReplySent or sentBeforeError as visible partial deliveries, marking foreground delivery visible while still rethrowing the failure. (src/auto-reply/dispatch.ts:260, 675045f49f11)
  • Durable path does not cover this LINE payload shape: resolveLineDurableReplyOptions returns false for payloads with channelData.line or media, so rich/media LINE auto-replies rely on this plugin delivery callback being honest. (extensions/line/src/monitor-durable.ts:28, 675045f49f11)
  • PR head uses the existing partial-delivery contract: The PR captures rich/media send failures, tags the error with visibleReplySent, returns it with replyTokenUsed, and has the monitor throw only after adopting reply-token state. (extensions/line/src/auto-reply-delivery.ts:146, c8e9d41878a5)

Likely related people:

  • plum-dawg: The original merged LINE plugin commit added the auto-reply delivery branch that swallowed rich/media errors before quick-reply text. (role: introduced LINE plugin behavior; confidence: high; commits: c96ffa7186a4; files: src/line/auto-reply-delivery.ts, src/line/monitor.ts, src/line/reply-chunks.ts)
  • vincentkoc: Git history shows Vincent Koc moved LINE/channel ownership into the extensions boundary and touched the same delivery surface during plugin SDK and ownership refactors. (role: recent area contributor; confidence: high; commits: 213198123042, ef1346e50339; files: src/line/auto-reply-delivery.ts, extensions/line/src/auto-reply-delivery.ts, extensions/line/src/monitor.ts)
  • steipete: Peter Steinberger merged the original LINE plugin PR and authored nearby LINE reply-payload/reply-chunk refactors around this delivery boundary. (role: adjacent refactor owner and merger; confidence: medium; commits: c96ffa7186a4, 39d5590230db, 62edfdffbdd0; files: src/line/auto-reply-delivery.ts, src/line/reply-chunks.ts, src/plugin-sdk/reply-payload.ts)
  • cxbAsDev: Current blame on the exact extension-path lines points to a recent broad current-path add, though older history shows the behavior predates that commit. (role: current-line carrier; confidence: low; commits: 9606fe43231b; files: extensions/line/src/auto-reply-delivery.ts, extensions/line/src/monitor.ts, extensions/line/src/reply-chunks.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.

@clawsweeper clawsweeper Bot added 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. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. labels Jul 6, 2026
@steipete steipete self-assigned this Jul 6, 2026
@steipete

steipete commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Land-ready proof for exact head d2cd1284742cf2036044eb06a82c6691172597e0:

  • Real HTTP E2E through @line/bot-sdk 11.1.0: current main delivered the quick-reply text but hid a deliberate rich-message HTTP 400; this head surfaces the tagged partial error in both rich-before-text and text-before-rich orders, preserves the consumed reply-token state, and sends the visible text exactly once.
  • node scripts/run-vitest.mjs extensions/line/src/auto-reply-delivery.test.ts: 9/9 passed, including frozen dependency errors.
  • Fresh whole-branch GPT-5.5 AutoReview: no accepted/actionable findings (confidence 0.82).
  • git diff --check: passed.
  • Exact-head hosted CI: https://github.com/openclaw/openclaw/actions/runs/28812539610

I also inspected the installed LINE SDK source/types and the current official quick-reply/reply-message contracts. A fresh sanitized AWS lease was refused at the owner capacity limit (11/10), so I used the repository-permitted narrow local fallback plus exact-head hosted CI. No real LINE tenant was mutated; the E2E used the real SDK against a local HTTP server with controlled LINE-compatible responses.

Thanks @masatohoshino — the original fix correctly identified the silent partial-delivery path; the follow-up keeps reply-token ownership correct and hardens errors from frozen dependency objects.

@steipete

steipete commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Maintainer verification on exact head d2cd1284742cf2036044eb06a82c6691172597e0:

  • Reworked the delivery result into a closed delivered | partial state, so text-first rich/media failures cannot be mistaken for a clean delivery.
  • Preserved both delivery markers (sentBeforeError and visibleReplySent) for the shared dispatcher, including a frozen/non-extensible Error regression case.
  • Sanitized AWS Crabbox run run_6eaa55b3e1a2: 27/27 focused LINE tests passed across auto-reply delivery, lifecycle, durable state, and reply chunking.
  • Sanitized AWS Crabbox changed-surface run run_849533c30112: broad extension/type/architecture checks passed after it identified one test-only lint issue, which was fixed in the exact head.
  • Hosted CI run 28812539610 attempt 2: 45 jobs passed on the exact head with no failures.
  • Fresh GPT-5.5 autoreview: no actionable findings.

Live-proof gap: no maintainer LINE Messaging API credentials were available in the approved environment or the exact 1Password item lookup, so I could not perform a real LINE chat send. I am explicitly accepting the focused transport/state-machine proof plus exact-head CI for this backend failure-accounting fix. No screenshot was added because there is no honest UI state to capture without a live LINE account.

Related PR #81299 changes how LINE rich payloads consume reply-token slots; it is adjacent but not a duplicate and should rebase after this fix.

@steipete
steipete merged commit f859d78 into openclaw:main Jul 6, 2026
97 of 116 checks passed
@steipete

steipete commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Merged via squash.

@steipete

steipete commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Landed as f859d78b6126455d3d56e7e82cfcde69c308251b after exact-head CI passed, including QA Smoke CI.

The merged fix preserves visible LINE text and reply-token state while surfacing failed rich/media delivery, with focused 9/9 regression coverage and real-SDK localhost HTTP before/after proof. Thanks again @masatohoshino.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 7, 2026
…ngside text (openclaw#100996)

* fix(line): surface partial delivery when rich or media send fails alongside text

* fix(line): harden partial delivery result

* test(line): preserve frozen error type

* chore: keep release changelog owner-only

---------

Co-authored-by: Peter Steinberger <[email protected]>
steipete added a commit that referenced this pull request Oct 14, 2026
…of diagnostics (#171606)

## What Problem This Solves

Older channel-plugin code duplicates shared SDK ownership and carries defensive machinery for unsupported internal inputs, synthetic clocks, and throwing diagnostic hooks. Several normal inbound paths also put message content or pairing codes into diagnostics.

## User Impact

Message delivery, account/security policy, conversation identity, provider features, and ordinary shutdown/restart durability remain supported. Inbound message text, malformed Teams consent payloads and pairing codes no longer appear in the repaired diagnostic paths. No configuration, CLI, protocol, SDK export, dependency, schema, retention, or permission changes are required.

## Why This Change Was Made

This is the second old-code channel-plugin pass. Only production files with no origin/main commit in the preceding seven days are included; eligibility is refreshed before every push. The overlapping Feishu Markdown fence repair was removed from this branch once main independently landed it in #171222.

The packet removes **512 net production lines** (+503/-1015; tests, fixtures, test support, generated files, and declarations excluded). It reuses existing public SDK owners for plugin setup composition, secret-contract wiring, receipts, status summaries, process-global maps, error traversal, and account-scoped DM policy. There are no private-core or cross-plugin imports.

## Best-effort tradeoffs accepted

Each removed mechanism below was checked against callers, dependency behavior, and introducing history. Synthetic tests and hypothetical PR race descriptions are not treated as human production reports. Actual incident fixes, live security authority, FIFO, resource bounds, and accepted-write settlement are retained.

- Discord identify clock-skew observation (`c767b37e3b2`): the only added proof jumps the clock from a trillion milliseconds to zero; no human report is linked. A drastic backward clock jump can now prolong reconnect until clock recovery/restart; ordinary five-second parallel identify spacing remains.
- WhatsApp second synchronous close observation (#109886, `bf413374cca`): native Baileys uses EventEmitter and cannot asynchronously close between synchronous check/listener registration. A nonstandard reentrant `newListener` hook can reach the existing bounded timeout; transport-confirmed close and cleanup remain.
- Tlon formatter fallback (#1837, `51720980736`): validated decimal BigInt input cannot fail the pinned @ud formatter. A broken dependency now fails visibly instead of sending the incorrect raw ID that the original threading fix rejected.
- Matrix second private sync waiter (#62779, `0c00c3c2306`): the actual monitor waits once; only a synthetic test calls twice. An unsupported second call may replace the first callbacks; real outage/fatal/abort settlement remains.
- ClickClack outer setup catches (`752567dbc8e`): network/config failures are already caught by their owners; the extra path catches a broken logger/formatter then invokes the same logger again. Such internal failures now surface; ordinary setup diagnostics remain.
- ClickClack second workspace snapshot (`3e352d67278`): verification now resolves ID/name/slug from one provider response. A concurrent rename/removal is observed on the next verification/runtime request rather than an opportunistic second fetch.
- SMS generated-fragment revalidation (#118665, `0758316883f`): raw URL validation stays; only URLSearchParams-generated fragment bytes were checked twice. A monkeypatched/broken encoder is no longer revalidated; length, auth, URL and retry bounds remain.
- Feishu timeout-warning catch (`0028e6040a7`): the cited stuck-task/FIFO issues concern the retained five-minute cap, not a throwing logger. A broken warning hook now rejects that queue call visibly; subsequent same-key work continues.
- Feishu private timeout customization (`0028e6040a7`, `fab8d29d211`, #101949): only tests passed disabled/oversized/custom values. Unsupported direct imports can no longer tune/disable the private cap; all production callers retain five-minute progress/FIFO behavior.
- Reef logger-fatal deferred/race (#162669; synthetic hook in #110870): ordinary transport-error containment and shutdown from the recorded live relay incident stay. A throwing error logger is reported by the scheduler instead of intentionally killing an otherwise healthy inbox.
- Matrix nonfinite media size fallback (`9b71382efb6`, #149128): the sole production producer passes Buffer.byteLength; NaN cases were synthetic cleanup fixtures. Unsupported private NaN calls now carry that supplied value; MIME, encryption, image fields and duration remain.
- Buzz subscription count coercion (`6c7a96e588e`): the sole caller supplies array.length. Unsupported negative/fractional private values are not repaired; the actual room/resource cap remains.
- Teams upload-byte coercion (#104120, `0c8220ebf9a`): both callers supply Buffer.length. Unsupported malformed private counts follow transfer arithmetic; timer clamping and upload budgets stay.
- Nostr zero-count score fallback (`7b6cbf58697`): private entries are synchronously created and incremented together. An unsupported new zero-outcome insertion could score NaN; actual outage/circuit-breaker/failover behavior stays.
- Buzz profile-limit coercion (`ba2510e8fa8`): the only explicit producer supplies the bounded integer budget. Unsupported direct malformed limits are not normalized; ordinary caps, zero-budget and untrusted-event checks stay.
- Feishu card-launcher clock injection/max-Date guard (`05634708e05`): only a synthetic year-275760 test supplies the private clock. A corrupt clock may create an unusable expiry until recovery/restart; effect-side expiry, actor/chat and approval validation stay.
- QA private empty media-batch guard (#115290, `641c82b5bd0`): all three callers prove a nonempty batch. Unsupported direct empty calls take the ordinary text path; real media caps and atomic loading remain.
- Slack private global-map slot revalidation (original sharing fix `55318df83ff`): normal module sharing/replacement is retained. No human private-slot corruption report is linked; third-party mutation/deletion of our private Symbol slot is no longer checked on every read, and restart repairs unsupported corruption.
- Buzz synchronous subscription-construction compensation (`b48984792f4`, `828f88c5ca5`, #130300): native nostr-tools construction emits no callbacks and authored filters are plain/nonempty. Unsupported throwing/cyclic private filters or replaced constructors surface without immediate count/generation/timer compensation; close/deadline/restart recovers temporary state.
- Buzz post-construction inline-EOSE/abort retry (same provenance): native callbacks are asynchronous. A non-native constructor emitting EOSE inline no longer gets a second cleanup attempt; real EOSE-before-CLOSE, late EOSE, close-once, deadlines, queued slots, abort listeners, membership authority and shutdown remain. Fixtures now schedule EOSE with queueMicrotask while retaining assertions.
- Signal clean-end recovery duplication (#10240, `dff4a04c1f5`): clean EOF and transient failures share one backoff tail. An impossible non-abort internal sleep rejection or broken status/logger callback now surfaces rather than entering compensating reconnect; real sleep rejects on abort and actual recovery stays.
- WhatsApp optional native socket-end fallback (`69225003820`): actual callers use WASocket with required end(). An unsupported fake without end fails plainly; normal teardown and its error reporting stay.
- Nextcloud post-synchronous-route abort check (#159067, `5fd7c3d95e0`): the old awaited server-start path became synchronous route registration. A reentrant registry callback abort may briefly publish ready; installed abort cleanup, post-spool-ready check, auth and durable settlement stay.
- Buzz history-count clamps (`132e39bff64`): the actual positive room count and queue-capacity invariant guarantee the result. Unsupported private negative/oversized counts are not repaired; actual FIFO/resource reservations remain.
- LINE frozen-error wrapper (#100996, `f859d78b612`): native SDK HTTPFetchError is mutable; Object.freeze was a synthetic fixture, not a cited human incident. An unsupported frozen replacement error can now fail annotation with TypeError; actual partial-send/recovery contracts stay.
- LINE duplicate missing-receipt invariant (`05eda57b3c7`, #99600, #142092, #165718): all native sends return validated IDs and required receipts. Unsupported fake results use canonical bridge normalization instead of the former private throw; physical-send progress, caption quoting, receipt order and declared capabilities stay. The bridge also preserves already-sanctioned chatId metadata.
- Feishu display-cache extreme-clock guards (`23e1aac9b2c`): introduced with a synthetic max-Date test, no linked human report. Corrupt clocks follow ordinary arithmetic; account scope, positive/negative TTL and the 500-entry bound remain.
- Mattermost reaction-identity extreme-clock guards (`77b334a9845`): only invalid/max-Date tests support the machinery, no linked human report. Corrupt clocks follow arithmetic; token/base-URL scope, ten-minute expiry, delegated conversation/post/self-DM checks and request authority remain.

Other cuts remove duplicate facts/checks under one existing owner and introduce no additional failure tradeoff: Signal subscription/abort state, Zalouser Promise settlement and DM setter, Nextcloud claimed version/lane validation, Teams media/header validation and empty-array merging, Buzz refresh-state identity, Nostr flush identity, Matrix encryption gating, Mattermost runtime-config guard, immutable plugin setup bases, and private Discord/iMessage test overrides.

Matrix's private zero-answer poll fallback is also removed: its sole caller has already passed the shared minimum-two-options validator (`c49b6cc241a`, #163574). No reachable input loses a fallback. Teams attachment header rejection remains owned by the canonical bounded media saver; malformed/oversize headers now use the existing `attachmentView save failed` warning instead of the special malformed-header tag or silent oversized-header skip. The unavailable result and byte protection remain unchanged.

## Evidence

Focused owning-boundary/sibling tests and independent isolated reviews were run per checkpoint. Latest batches passed: Discord/LINE/Matrix/Synology 76 cases (157.00s wrapper), LINE/Feishu/Mattermost 66 cases (132.62s), Mattermost reaction 12 cases, Zalo Personal setup 17 cases (48.97s), and Teams consent/parser/lifecycle 52 cases (29.18s). The Teams malformed-content regression failed on the original handler before the one-line repair. The new Zalo test fixture initially assumed the wrong promotion target; source inspection and an explicit two-account fixture corrected it without changing production behavior or weakening retained assertions.

Production/test extension typechecks and targeted type-aware lint/format pass. Runtime and Madge checks report zero cycles. Existing SDK export checks pass. Earlier fresh cliStartup build and affected built-entry import proof passed; no performance improvement is claimed from dirty-tree profiling. No live accounts, operator state, driver installation, Gateway or remote lease was used.

Final Matrix poll/send/shared-normalization proof passes 55 cases across three shards (138.50s wrapper). Independent full-branch review and the supplemental poll review found no actionable P0–P2 findings.

Two local baseline gates are inherited from the branch base: suppression inventory expects 87 versus the untouched proxy's 88 (current main has repaired the entry); aggregate check-changed stops on stale untouched max-lines entry src/agents/btw.ts after conflict/line-cap gates pass. No allowlist/budget expansion was made. Earlier cold-start timing-sensitive failures remain observations, not claimed repaired/inherited; the complete changed cold-start file subsequently passed all eight cases with unchanged timers/assertions.

The first exact-head hosted run [38503961141](https://github.com/openclaw/openclaw/actions/runs/38503961141) completed in 643 seconds: 51 jobs passed, 25 planned jobs skipped, and the baseline ratchet plus its aggregate gate failed. The defect was ours: removed Slack/Twitch assertions and two removed ClickClack mocks needed exact inventory shrinkage. Those four inventory items are corrected without adding allowances or changing behavior. All actual tests, types, lint, architecture, package boundaries, QA and security jobs passed on that production patch. Final exact-head run [38505676106](https://github.com/openclaw/openclaw/actions/runs/38505676106) passed on `86922ccf92825d4b53b77005119590d1e7759a32`: 55 successful jobs, 25 planned skips, zero failed/cancelled jobs, 643 seconds wall time and 9,679 summed reported job seconds. The exact-head required CI/security gate passes. CodeQL also reports a neutral warning for unselected main configurations; those skipped configurations are not claimed as proof. No CI rerun, inherited-failure admin exception, or green-seeking push was used.

<details>
<summary>Round-2 largest-first coverage log</summary>

Setup/runtime composition is consolidated for Buzz, Nostr, A2A and Google Chat; setup stays dependency-light. Matrix/Feishu secret activation uses the existing factory with activation/order/owner rules unchanged. IRC shares parsing/status owners. LINE shares receipt/progress mapping without routing through legacy media behavior. Zalo Personal shares the existing account-scoped DM policy owner. Privacy regressions reach real WhatsApp/iMessage/Synology inbound and Feishu pairing diagnostic paths while asserting complete dispatch/challenge behavior.

Largest old owners retained after source/caller/history review include iMessage catchup/conversation repair; Matrix formatting/actions/crypto/shutdown; Mattermost interactive access/draft boundary/final receipts; Signal approvals/transport setup; Slack ingress FIFO/thread visibility/workspace identity/streaming; WhatsApp paid-STT/admission/quoted identity/partial delivery; Teams Graph/Bot Framework/upload consent security; Buzz signed membership/archival authority/resource budgets; Nostr circuit breakers/profile mutation auth; LINE provider caps/reply-token/media ordering; Twitch listener/auth resource ownership; SMS callback/API ordering; Synology auth/rate limits/durable acknowledgments; Reef encryption/transport error containment; FaceTime trust/rollback/permissions; and paid X request accounting.

Recent files were deferred, including remaining Teams inbound-body, Tlon admin/approval-text and WhatsApp outbound-content diagnostics; recently landed feature foundations were not treated as dead code. QA setup-base consolidation was held because completing its runtime caller would exceed the one-line recent-file exception. No Phase E standalone memory code was touched. Detailed per-mechanism provenance and checkpoint evidence is retained in the requested round-2 lane ledger.

</details>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 14, 2026
…of diagnostics (openclaw#171606)

## What Problem This Solves

Older channel-plugin code duplicates shared SDK ownership and carries defensive machinery for unsupported internal inputs, synthetic clocks, and throwing diagnostic hooks. Several normal inbound paths also put message content or pairing codes into diagnostics.

## User Impact

Message delivery, account/security policy, conversation identity, provider features, and ordinary shutdown/restart durability remain supported. Inbound message text, malformed Teams consent payloads and pairing codes no longer appear in the repaired diagnostic paths. No configuration, CLI, protocol, SDK export, dependency, schema, retention, or permission changes are required.

## Why This Change Was Made

This is the second old-code channel-plugin pass. Only production files with no origin/main commit in the preceding seven days are included; eligibility is refreshed before every push. The overlapping Feishu Markdown fence repair was removed from this branch once main independently landed it in openclaw#171222.

The packet removes **512 net production lines** (+503/-1015; tests, fixtures, test support, generated files, and declarations excluded). It reuses existing public SDK owners for plugin setup composition, secret-contract wiring, receipts, status summaries, process-global maps, error traversal, and account-scoped DM policy. There are no private-core or cross-plugin imports.

## Best-effort tradeoffs accepted

Each removed mechanism below was checked against callers, dependency behavior, and introducing history. Synthetic tests and hypothetical PR race descriptions are not treated as human production reports. Actual incident fixes, live security authority, FIFO, resource bounds, and accepted-write settlement are retained.

- Discord identify clock-skew observation (`fa56d13411c`): the only added proof jumps the clock from a trillion milliseconds to zero; no human report is linked. A drastic backward clock jump can now prolong reconnect until clock recovery/restart; ordinary five-second parallel identify spacing remains.
- WhatsApp second synchronous close observation (openclaw#109886, `ca60d105ece`): native Baileys uses EventEmitter and cannot asynchronously close between synchronous check/listener registration. A nonstandard reentrant `newListener` hook can reach the existing bounded timeout; transport-confirmed close and cleanup remain.
- Tlon formatter fallback (openclaw#1837, `a898f3d7bb5`): validated decimal BigInt input cannot fail the pinned @ud formatter. A broken dependency now fails visibly instead of sending the incorrect raw ID that the original threading fix rejected.
- Matrix second private sync waiter (openclaw#62779, `aec73fd9ca4`): the actual monitor waits once; only a synthetic test calls twice. An unsupported second call may replace the first callbacks; real outage/fatal/abort settlement remains.
- ClickClack outer setup catches (`9079efe9026`): network/config failures are already caught by their owners; the extra path catches a broken logger/formatter then invokes the same logger again. Such internal failures now surface; ordinary setup diagnostics remain.
- ClickClack second workspace snapshot (`188ce1e28e9`): verification now resolves ID/name/slug from one provider response. A concurrent rename/removal is observed on the next verification/runtime request rather than an opportunistic second fetch.
- SMS generated-fragment revalidation (openclaw#118665, `37690fb4f4b`): raw URL validation stays; only URLSearchParams-generated fragment bytes were checked twice. A monkeypatched/broken encoder is no longer revalidated; length, auth, URL and retry bounds remain.
- Feishu timeout-warning catch (`7a2ce698b8c`): the cited stuck-task/FIFO issues concern the retained five-minute cap, not a throwing logger. A broken warning hook now rejects that queue call visibly; subsequent same-key work continues.
- Feishu private timeout customization (`7a2ce698b8c`, `491abe564ce`, openclaw#101949): only tests passed disabled/oversized/custom values. Unsupported direct imports can no longer tune/disable the private cap; all production callers retain five-minute progress/FIFO behavior.
- Reef logger-fatal deferred/race (openclaw#162669; synthetic hook in openclaw#110870): ordinary transport-error containment and shutdown from the recorded live relay incident stay. A throwing error logger is reported by the scheduler instead of intentionally killing an otherwise healthy inbox.
- Matrix nonfinite media size fallback (`96ff92e82bb`, openclaw#149128): the sole production producer passes Buffer.byteLength; NaN cases were synthetic cleanup fixtures. Unsupported private NaN calls now carry that supplied value; MIME, encryption, image fields and duration remain.
- Buzz subscription count coercion (`d656588ae32`): the sole caller supplies array.length. Unsupported negative/fractional private values are not repaired; the actual room/resource cap remains.
- Teams upload-byte coercion (openclaw#104120, `6d759fe8b17`): both callers supply Buffer.length. Unsupported malformed private counts follow transfer arithmetic; timer clamping and upload budgets stay.
- Nostr zero-count score fallback (`25838b5d7de`): private entries are synchronously created and incremented together. An unsupported new zero-outcome insertion could score NaN; actual outage/circuit-breaker/failover behavior stays.
- Buzz profile-limit coercion (`67bce4fe0d7`): the only explicit producer supplies the bounded integer budget. Unsupported direct malformed limits are not normalized; ordinary caps, zero-budget and untrusted-event checks stay.
- Feishu card-launcher clock injection/max-Date guard (`207f045b11c`): only a synthetic year-275760 test supplies the private clock. A corrupt clock may create an unusable expiry until recovery/restart; effect-side expiry, actor/chat and approval validation stay.
- QA private empty media-batch guard (openclaw#115290, `4dbddeefcc9`): all three callers prove a nonempty batch. Unsupported direct empty calls take the ordinary text path; real media caps and atomic loading remain.
- Slack private global-map slot revalidation (original sharing fix `564ccc6f56a`): normal module sharing/replacement is retained. No human private-slot corruption report is linked; third-party mutation/deletion of our private Symbol slot is no longer checked on every read, and restart repairs unsupported corruption.
- Buzz synchronous subscription-construction compensation (`2bd60a2e983`, `eb99a1b3432`, openclaw#130300): native nostr-tools construction emits no callbacks and authored filters are plain/nonempty. Unsupported throwing/cyclic private filters or replaced constructors surface without immediate count/generation/timer compensation; close/deadline/restart recovers temporary state.
- Buzz post-construction inline-EOSE/abort retry (same provenance): native callbacks are asynchronous. A non-native constructor emitting EOSE inline no longer gets a second cleanup attempt; real EOSE-before-CLOSE, late EOSE, close-once, deadlines, queued slots, abort listeners, membership authority and shutdown remain. Fixtures now schedule EOSE with queueMicrotask while retaining assertions.
- Signal clean-end recovery duplication (openclaw#10240, `1b2dfffddeb`): clean EOF and transient failures share one backoff tail. An impossible non-abort internal sleep rejection or broken status/logger callback now surfaces rather than entering compensating reconnect; real sleep rejects on abort and actual recovery stays.
- WhatsApp optional native socket-end fallback (`3294ef6f0cb`): actual callers use WASocket with required end(). An unsupported fake without end fails plainly; normal teardown and its error reporting stay.
- Nextcloud post-synchronous-route abort check (openclaw#159067, `af36cf97537`): the old awaited server-start path became synchronous route registration. A reentrant registry callback abort may briefly publish ready; installed abort cleanup, post-spool-ready check, auth and durable settlement stay.
- Buzz history-count clamps (`bbde46b881f`): the actual positive room count and queue-capacity invariant guarantee the result. Unsupported private negative/oversized counts are not repaired; actual FIFO/resource reservations remain.
- LINE frozen-error wrapper (openclaw#100996, `a2aad76fdba`): native SDK HTTPFetchError is mutable; Object.freeze was a synthetic fixture, not a cited human incident. An unsupported frozen replacement error can now fail annotation with TypeError; actual partial-send/recovery contracts stay.
- LINE duplicate missing-receipt invariant (`15be48ecd0e`, openclaw#99600, openclaw#142092, openclaw#165718): all native sends return validated IDs and required receipts. Unsupported fake results use canonical bridge normalization instead of the former private throw; physical-send progress, caption quoting, receipt order and declared capabilities stay. The bridge also preserves already-sanctioned chatId metadata.
- Feishu display-cache extreme-clock guards (`ab53c2998a1`): introduced with a synthetic max-Date test, no linked human report. Corrupt clocks follow ordinary arithmetic; account scope, positive/negative TTL and the 500-entry bound remain.
- Mattermost reaction-identity extreme-clock guards (`6199cc7df89`): only invalid/max-Date tests support the machinery, no linked human report. Corrupt clocks follow arithmetic; token/base-URL scope, ten-minute expiry, delegated conversation/post/self-DM checks and request authority remain.

Other cuts remove duplicate facts/checks under one existing owner and introduce no additional failure tradeoff: Signal subscription/abort state, Zalouser Promise settlement and DM setter, Nextcloud claimed version/lane validation, Teams media/header validation and empty-array merging, Buzz refresh-state identity, Nostr flush identity, Matrix encryption gating, Mattermost runtime-config guard, immutable plugin setup bases, and private Discord/iMessage test overrides.

Matrix's private zero-answer poll fallback is also removed: its sole caller has already passed the shared minimum-two-options validator (`306de68c026`, openclaw#163574). No reachable input loses a fallback. Teams attachment header rejection remains owned by the canonical bounded media saver; malformed/oversize headers now use the existing `attachmentView save failed` warning instead of the special malformed-header tag or silent oversized-header skip. The unavailable result and byte protection remain unchanged.

## Evidence

Focused owning-boundary/sibling tests and independent isolated reviews were run per checkpoint. Latest batches passed: Discord/LINE/Matrix/Synology 76 cases (157.00s wrapper), LINE/Feishu/Mattermost 66 cases (132.62s), Mattermost reaction 12 cases, Zalo Personal setup 17 cases (48.97s), and Teams consent/parser/lifecycle 52 cases (29.18s). The Teams malformed-content regression failed on the original handler before the one-line repair. The new Zalo test fixture initially assumed the wrong promotion target; source inspection and an explicit two-account fixture corrected it without changing production behavior or weakening retained assertions.

Production/test extension typechecks and targeted type-aware lint/format pass. Runtime and Madge checks report zero cycles. Existing SDK export checks pass. Earlier fresh cliStartup build and affected built-entry import proof passed; no performance improvement is claimed from dirty-tree profiling. No live accounts, operator state, driver installation, Gateway or remote lease was used.

Final Matrix poll/send/shared-normalization proof passes 55 cases across three shards (138.50s wrapper). Independent full-branch review and the supplemental poll review found no actionable P0–P2 findings.

Two local baseline gates are inherited from the branch base: suppression inventory expects 87 versus the untouched proxy's 88 (current main has repaired the entry); aggregate check-changed stops on stale untouched max-lines entry src/agents/btw.ts after conflict/line-cap gates pass. No allowlist/budget expansion was made. Earlier cold-start timing-sensitive failures remain observations, not claimed repaired/inherited; the complete changed cold-start file subsequently passed all eight cases with unchanged timers/assertions.

The first exact-head hosted run [38503961141](https://github.com/openclaw/openclaw/actions/runs/38503961141) completed in 643 seconds: 51 jobs passed, 25 planned jobs skipped, and the baseline ratchet plus its aggregate gate failed. The defect was ours: removed Slack/Twitch assertions and two removed ClickClack mocks needed exact inventory shrinkage. Those four inventory items are corrected without adding allowances or changing behavior. All actual tests, types, lint, architecture, package boundaries, QA and security jobs passed on that production patch. Final exact-head run [38505676106](https://github.com/openclaw/openclaw/actions/runs/38505676106) passed on `86922ccf92825d4b53b77005119590d1e7759a32`: 55 successful jobs, 25 planned skips, zero failed/cancelled jobs, 643 seconds wall time and 9,679 summed reported job seconds. The exact-head required CI/security gate passes. CodeQL also reports a neutral warning for unselected main configurations; those skipped configurations are not claimed as proof. No CI rerun, inherited-failure admin exception, or green-seeking push was used.

<details>
<summary>Round-2 largest-first coverage log</summary>

Setup/runtime composition is consolidated for Buzz, Nostr, A2A and Google Chat; setup stays dependency-light. Matrix/Feishu secret activation uses the existing factory with activation/order/owner rules unchanged. IRC shares parsing/status owners. LINE shares receipt/progress mapping without routing through legacy media behavior. Zalo Personal shares the existing account-scoped DM policy owner. Privacy regressions reach real WhatsApp/iMessage/Synology inbound and Feishu pairing diagnostic paths while asserting complete dispatch/challenge behavior.

Largest old owners retained after source/caller/history review include iMessage catchup/conversation repair; Matrix formatting/actions/crypto/shutdown; Mattermost interactive access/draft boundary/final receipts; Signal approvals/transport setup; Slack ingress FIFO/thread visibility/workspace identity/streaming; WhatsApp paid-STT/admission/quoted identity/partial delivery; Teams Graph/Bot Framework/upload consent security; Buzz signed membership/archival authority/resource budgets; Nostr circuit breakers/profile mutation auth; LINE provider caps/reply-token/media ordering; Twitch listener/auth resource ownership; SMS callback/API ordering; Synology auth/rate limits/durable acknowledgments; Reef encryption/transport error containment; FaceTime trust/rollback/permissions; and paid X request accounting.

Recent files were deferred, including remaining Teams inbound-body, Tlon admin/approval-text and WhatsApp outbound-content diagnostics; recently landed feature foundations were not treated as dead code. QA setup-base consolidation was held because completing its runtime caller would exceed the one-line recent-file exception. No Phase E standalone memory code was touched. Detailed per-mechanism provenance and checkpoint evidence is retained in the requested round-2 lane ledger.

</details>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: line Channel integration: line merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S 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.

2 participants