Skip to content

fix(twitch): record empty sends as a non-outcome, not a delivery receipt - #131689

Merged
steipete merged 6 commits into
mainfrom
steipete/twitch-skipped-receipt
Aug 29, 2026
Merged

steipete merged 6 commits into
mainfrom
steipete/twitch-skipped-receipt

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Important

review-required: acknowledgement-vs-no-send SDK semantics. Prepared under the auto-QA campaign from a channel-delivery audit (finding C6). Adds an optional typed no-send fact to the shared message-result SDK, so this stays a draft for maintainer review.

What Problem This Solves

A Twitch reply whose entire content sanitizes away to nothing (e.g. ---) was recorded as a successful delivery. Twitch's chunker returns no chunks; shared planning restores the nonempty original; Twitch's send strips it again and returns ok:true, messageId:"skipped" with an empty receipt before client-manager lookup. Downstream, the nonempty "skipped" field is preferred over the empty provider receipt, so accounting records one physical send even though Twitch received nothing. Success accounting can then complete the intent or suppress a legitimate fallback.

Why This Change Was Made

The invariant: a provider's explicit no-send must remain a recorded non-outcome, not positive delivery evidence. The fix carries a typed owner-confirmed no-send fact through the shared message SDK (optional field; omission preserves existing acknowledgement behavior). Core records adapter_returned_no_send, produces no successful delivery result/hook/pin, projects the existing suppressed / no_visible_payload audit terminal with zero physical sends, and intentional queue settlement counts as recovered:1 (not a failed send). The global empty-chunker protection and identity predicate are untouched; no arbitrary string blacklist was added.

A deep-context review also found and fixed a related recovery gap: a persisted suppressed owner surviving a crash/ack-failure could be retired on the next scan without publishing its audit non-outcome. Terminal-owner recovery now shares one ack path and emits suppression only after queue custody ends (delivered/rejected owners keep their semantics; stale owners do not manufacture suppression).

User Impact

An empty Twitch send is now honestly recorded as an intentional non-outcome instead of a phantom success, so completion/fallback logic sees the truth. Normal Twitch messages still send and count. The three delivery states — no-send, acknowledged-without-editable-ID, unknown-after-send — stay distinct.

Scope note for the reviewer (siblings deliberately unchanged)

This fix does not reclassify legitimate ack-without-ID producers: iMessage ok/unknown placeholders still count as one physical acknowledgement, legacy LINE push results remain delivered, and aggregate receipts (Telegram/Discord/Slack) keep their physical multiplicity. One audit premise was corrected during review: Synology is not positively "counted delivered" on current main — since #110770 removed its synthetic sc-* ID (after v2026.7.1), core already treats its empty-ID webhook as identityless ambiguity. This branch preserves that current behavior and does not convert Synology to no-send; making Synology positively-delivered would require a separate explicit acknowledgement contract, which this review deliberately did not invent.

Evidence

  • Production net +39 whole branch (typed no-send fact + recovery evidence preservation; review follow-up absorbed three shadow failure variables); tests net +502; docs +10; assertion ratchet −1. No schema/store/persisted-reason-code change.
  • Additive SDK: the new optional owner fact on the message result type is source-compatible (omission = existing behavior); plugin-sdk:surface:check clean.
  • Failing-first: Twitch --- physical count 1 → 0 (real sanitizer+planner+adapter+recorder, no client manager); a second probe exposed the recovery gap (failed:1 → recovered:1) with real SQLite queue/conversation reopen and no replay.
  • Post-rebase Twitch/receipt/recovery suites green; changed-file gate + two Codex autoreviews clean.

@clawsweeper

clawsweeper Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: twitch Channel integration: twitch size: XL maintainer Maintainer-authored PR labels Aug 28, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 28, 2026
@clawsweeper

clawsweeper Bot commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed August 29, 2026, 1:25 AM ET / 05:25 UTC.

ClawSweeper review

What this changes

The branch represents Twitch messages emptied by Markdown stripping as an intentional no-send outcome and carries that fact through shared delivery, queue recovery, receipts, and operator output.

Regression provenance

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

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep open. The central bug remains on current main, but the branch retains a prior P2 test-boundary violation and introduces a shared channel SDK outcome that needs maintainer confirmation.

Priority: P2
Reviewed head: c5bfc8ae7ea10d47affd73cf832fc3af92cd25c5
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The repair has a coherent owner-boundary design and authority coverage, but the unresolved private-plugin test coupling remains a merge blocker.
Proof confidence 🌊 off-meta tidepool Not applicable: The PR is authored by a repository member, so the external-contributor proof gate does not apply; the supplied test claims remain supplemental rather than independently rerun in this read-only review.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The PR is authored by a repository member, so the external-contributor proof gate does not apply; the supplied test claims remain supplemental rather than independently rerun in this read-only review.
Evidence reviewed 8 items Current-main bug remains: Current main returns a successful Twitch result with the nonempty sentinel skipped when Markdown stripping produces no text, so the requested behavior is not already implemented.
Owner-boundary repair: The branch returns outcome: "not_sent" with no message ID before client-manager lookup, preserving the fact at the Twitch transport owner.
Shared accounting recognizes no-send: The shared delivery owner suppresses a payload with the explicit no-send reason and bypasses successful lifecycle accounting.
Findings 1 actionable finding [P2] Keep the Twitch transport mock in the plugin test lane
Security None None.

How this fits together

Twitch’s plugin turns agent and Gateway message actions into transport sends. Shared outbound delivery records receipts, queue settlement, audit terminals, and source-reply completion from those results.

flowchart LR
  A[Agent or Gateway action] --> B[Twitch plugin]
  B --> C[Shared outbound delivery]
  C --> D{Transport outcome}
  D -->|Sent| E[Receipt and completion]
  D -->|Intentionally omitted| F[Suppression and audit]
  C --> G[Queue recovery]
Loading

Decision needed

Question Recommendation
Should the shared channel SDK permanently distinguish an adapter-confirmed pre-dispatch no-send from an acknowledged send without a platform ID? Accept the explicit no-send contract: Keep the optional outcome after relocating the private Twitch mock to the plugin-owned test lane.

Why: This is an additive public plugin contract with semantics for all channel adapters, so source compatibility alone cannot determine the intended long-term API.

Before merge

  • Keep the Twitch transport mock in the plugin test lane (P2) - This root test directly mocks extensions/twitch/src/client-manager-registry.js, a private plugin module. That couples core coverage to an internal extension layout and violates the established core/plugin test boundary; keep the no-client-manager assertion in extensions/twitch/src/send.test.ts and leave generic delivery behavior in core tests.
  • Resolve merge risk (P1) - The optional not_sent field changes the shared channel result contract; maintainers should explicitly confirm that intentional pre-dispatch omission is the permanent distinction from an acknowledged send without an ID.

Findings

  • [P2] Keep the Twitch transport mock in the plugin test lane — test/twitch-message-tool-delivery.test.ts:23-26
Agent review details

Security

None.

PR surface

Source -8, Tests +951, Docs +10, Other -1. Total +952 across 36 files.

View PR surface stats
Area Files Added Removed Net
Source 21 271 279 -8
Tests 12 1226 275 +951
Docs 2 11 1 +10
Config 0 0 0 0
Generated 0 0 0 0
Other 1 0 1 -1
Total 36 1508 556 +952

Review metrics

Metric Value Why it matters
Production versus test LOC production +271/-279 (net -8); tests +1226/-275 (net +951); docs +11/-1 The repair is net-negative in production but adds substantial cross-boundary regression coverage.
Shared channel result contract 1 optional outcome added The new not_sent outcome is source-compatible when omitted but affects every adapter using the shared receipt and delivery path.

Stored data model

Persistent data-model change detected: serialized state: extensions/twitch/src/actions.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Relocate the private transport assertion (recommended)
    Remove the root test’s direct mock of Twitch private source and retain that assertion in the plugin-owned send suite before merge.
  2. Confirm the shared result contract
    Have the channel SDK owner explicitly accept not_sent as the distinction between intentional omission and identityless acknowledgement.

Technical review

Best possible solution:

Retain the typed no-send model, move the Twitch-private transport assertion into the plugin test lane, and land only after the channel SDK contract is explicitly accepted.

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

Yes, from source: current main returns successful messageId: "skipped" after Twitch sanitizes a payload to empty, while the branch supplies a typed no-send outcome. Runtime execution was not performed because this is a read-only review.

Is this the best way to solve the issue?

Yes, conditionally: recording an owner-confirmed no-send in the shared delivery owner is preferable to retaining a magic successful ID, but the new shared SDK meaning needs maintainer acceptance and its private-plugin mock must move.

Full review comments:

  • [P2] Keep the Twitch transport mock in the plugin test lane — test/twitch-message-tool-delivery.test.ts:23-26
    This root test directly mocks extensions/twitch/src/client-manager-registry.js, a private plugin module. That couples core coverage to an internal extension layout and violates the established core/plugin test boundary; keep the no-client-manager assertion in extensions/twitch/src/send.test.ts and leave generic delivery behavior in core tests.
    Confidence: 0.98

Overall correctness: patch is incorrect
Overall confidence: 0.92

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This is a meaningful delivery-accounting repair with a bounded unresolved test-boundary defect.
  • merge-risk: 🚨 compatibility: The PR adds an optional shared channel SDK outcome whose semantics affect existing adapters and delivery accounting.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: The PR is authored by a repository member, so the external-contributor proof gate does not apply; the supplied test claims remain supplemental rather than independently rerun in this read-only review.

Evidence

What I checked:

  • Current-main bug remains: Current main returns a successful Twitch result with the nonempty sentinel skipped when Markdown stripping produces no text, so the requested behavior is not already implemented. (extensions/twitch/src/send.ts, 4ee2216cd76b)
  • Owner-boundary repair: The branch returns outcome: "not_sent" with no message ID before client-manager lookup, preserving the fact at the Twitch transport owner. (extensions/twitch/src/send.ts:112, c5bfc8ae7ea1)
  • Shared accounting recognizes no-send: The shared delivery owner suppresses a payload with the explicit no-send reason and bypasses successful lifecycle accounting. (src/infra/outbound/deliver-core.ts:461, c5bfc8ae7ea1)
  • Authority final-effect check: The canonical Gateway send path passes the live authority guard into the platform-dispatch callback; its introduced test closes authority immediately before dispatch and observes no platform send. (src/gateway/server-methods/send.ts:1172, c5bfc8ae7ea1)
  • Prior finding remains at the exact head: The root-level Twitch integration test directly mocks the private plugin source module; the only change after the preceding reviewed head is the separate contract-helper addition, so the prior finding remains unresolved. (test/twitch-message-tool-delivery.test.ts:23, c5bfc8ae7ea1)
  • Applicable test boundary: Repository policy keeps core tests out of private extension source; the plugin-owned send test already covers that the client manager is not called for a no-send result. (extensions/twitch/src/send.test.ts:205, c5bfc8ae7ea1)

Likely related people:

  • steipete: Current-main and branch history both associate Peter Steinberger with the affected Twitch send path and shared delivery repair. (role: recent Twitch and outbound contributor; confidence: high; commits: 5d88e1818a41, c191ab20272a; files: extensions/twitch/src/send.ts, src/infra/outbound/deliver-core.ts)
  • wangmiao0668000666: The merged Synology receipt correction is a related but distinct precedent for avoiding fabricated delivery identity. (role: adjacent receipt-contract contributor; confidence: medium; commits: 77e9ee092fc6; files: src/channels/message/receipt.ts)

Rank-up moves

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

  • Move the private client-manager mock and no-send transport assertion into extensions/twitch/src/send.test.ts.
  • Obtain explicit maintainer acceptance of the shared not_sent channel-result contract.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (7 earlier review cycles)
  • reviewed 2026-08-28T09:17:36.465Z sha 89362bd :: needs maintainer review before merge. :: none
  • reviewed 2026-08-28T20:30:51.316Z sha 929dec1f9d35407c9d1f112aee218c4517be4f4d :: needs maintainer review before merge. :: none
  • reviewed 2026-08-28T21:33:19.208Z sha 579cf1a8e79717289108e25f29e0e1645c5ffa44 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-28T21:44:30.768Z sha 7c2aa07 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-28T22:59:27.085Z sha 4806a06 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-29T04:29:36.004Z sha 64230a7 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-29T05:12:16.761Z sha f913e54 :: found issues before merge. :: [P2] Keep the Twitch transport mock in the plugin test lane

@steipete
steipete force-pushed the steipete/twitch-skipped-receipt branch from 89362bd to 929dec1 Compare August 28, 2026 20:23
@steipete
steipete marked this pull request as ready for review August 28, 2026 20:23
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. labels Aug 28, 2026
@steipete
steipete force-pushed the steipete/twitch-skipped-receipt branch 3 times, most recently from 7c2aa07 to 4806a06 Compare August 28, 2026 22:50
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 28, 2026
@steipete
steipete force-pushed the steipete/twitch-skipped-receipt branch from 4806a06 to 64230a7 Compare August 29, 2026 04:19
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 29, 2026
Carry earlier unknown sends through later pre-dispatch failures and derive best-effort settlement from canonical payload outcomes. Let proven unsent recovery failures retain retry eligibility, and publish persisted suppression only after queue acknowledgement. Consolidate terminal-owner acknowledgement paths and verify restart, stale-owner, and partial-send controls.
…he survivor poller

The new Twitch delivery test reached into core outbound internals through relative
paths, which the extension/plugin-sdk boundary guard rejects. Its pipeline coverage
already exists generically in src/infra/outbound/deliver.test.ts, so the file is
removed and its one plugin-owned assertion (a no-send disposition must never reach
the platform client) moves into extensions/twitch/src/send.test.ts.

Separately, test/scripts/upgrade-survivor-systemd.test.ts JSON-parsed a record file
while the restarted service was still appending to it, so a read landing mid-append
threw "Unexpected end of JSON input" out of the poll loop. The poller now counts only
whole newline-terminated records and retries on a torn tail; a malformed earlier line
still fails the test.
Remove redundant Twitch native send execution so the shared delivery owner records suppression, operator output, and terminal reply evidence. Preserve proven no-send queue state after acknowledgement failures in live and recovery paths, including database reopen.
Strip Twitch Markdown once before the existing client-manager chunking so
literal formatting and inline-code horizontal rules remain visible.

Keep public message.action sends working without native handlers by using
the canonical outbound route, including account defaults, plugin payload
preparation, and dispatch authority. Expose Twitch's existing target rules
and source-target equivalence through the plugin contracts.

Retain real-plugin successful-send, receipt, audit, source-reply, and
operator-output coverage alongside suppressed-send controls. Clarify the
documented target defaults for source replies, CLI, and Gateway actions.
@steipete
steipete force-pushed the steipete/twitch-skipped-receipt branch from 64230a7 to f913e54 Compare August 29, 2026 05:03
@openclaw-barnacle openclaw-barnacle Bot added the gateway Gateway runtime label Aug 29, 2026
@clawsweeper clawsweeper Bot added 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. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 29, 2026
…ability

The surface contract required a declared threading surface to expose one of
five functions, but core also consumes threading.matchesToolContextTarget
directly (src/infra/outbound/source-reply-mirror.ts:364). Every existing
implementer happened to pair that hook with resolveReplyToMode, so the gap
stayed hidden until Twitch declared threading for target matching alone.
@steipete
steipete merged commit c218971 into main Aug 29, 2026
234 checks passed
@steipete
steipete deleted the steipete/twitch-skipped-receipt branch August 29, 2026 05:29
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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

* fix(twitch): record empty sends as a non-outcome, not a delivery receipt

* fix(outbound): preserve delivery evidence through recovery

Carry earlier unknown sends through later pre-dispatch failures and derive best-effort settlement from canonical payload outcomes. Let proven unsent recovery failures retain retry eligibility, and publish persisted suppression only after queue acknowledgement. Consolidate terminal-owner acknowledgement paths and verify restart, stale-owner, and partial-send controls.

* test: keep Twitch no-send proof inside the plugin lane and de-flake the survivor poller

The new Twitch delivery test reached into core outbound internals through relative
paths, which the extension/plugin-sdk boundary guard rejects. Its pipeline coverage
already exists generically in src/infra/outbound/deliver.test.ts, so the file is
removed and its one plugin-owned assertion (a no-send disposition must never reach
the platform client) moves into extensions/twitch/src/send.test.ts.

Separately, test/scripts/upgrade-survivor-systemd.test.ts JSON-parsed a record file
while the restarted service was still appending to it, so a read landing mid-append
threw "Unexpected end of JSON input" out of the poll loop. The poller now counts only
whole newline-terminated records and retries on a torn tail; a malformed earlier line
still fails the test.

* fix(outbound): keep Twitch no-sends under core delivery custody

Remove redundant Twitch native send execution so the shared delivery owner records suppression, operator output, and terminal reply evidence. Preserve proven no-send queue state after acknowledgement failures in live and recovery paths, including database reopen.

* fix(twitch): preserve ordinary sends through core routing

Strip Twitch Markdown once before the existing client-manager chunking so
literal formatting and inline-code horizontal rules remain visible.

Keep public message.action sends working without native handlers by using
the canonical outbound route, including account defaults, plugin payload
preparation, and dispatch authority. Expose Twitch's existing target rules
and source-target equivalence through the plugin contracts.

Retain real-plugin successful-send, receipt, audit, source-reply, and
operator-output coverage alongside suppressed-send controls. Clarify the
documented target defaults for source replies, CLI, and Gateway actions.

* test(channels): recognize matchesToolContextTarget as a threading capability

The surface contract required a declared threading surface to expose one of
five functions, but core also consumes threading.matchesToolContextTarget
directly (src/infra/outbound/source-reply-mirror.ts:364). Every existing
implementer happened to pair that hook with resolveReplyToMode, so the gap
stayed hidden until Twitch declared threading for target matching alone.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: twitch Channel integration: twitch docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XL 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.

1 participant