Skip to content

fix(twitch): retain native sender identity in execution audits - #130730

Merged
steipete merged 4 commits into
mainfrom
codex/twitch-participant-provenance
Aug 27, 2026
Merged

steipete merged 4 commits into
mainfrom
codex/twitch-participant-provenance

Conversation

@steipete

@steipete steipete commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Opt-in Twitch execution audits lost the native sender's account-scoped provenance even though replies succeeded. Moderator authorization could substitute a role for the participant, and allowedRoles: ["all"] could overstate sender-policy enforcement.

Fixes #130728. Related: #122863.

Why This Change Was Made

The Twitch producer now forwards the Gateway's registered runtime, passes the real account ID through both access checks, and keeps the native user ID primary with roles used only as authorization aliases. The declared all role becomes the existing SDK wildcard at the policy boundary. This removes duplicate wildcard logic without changing shared authorization or widening plugin trust.

The reply fixture now awaits and drains accepted delivery work, fixing an observed cold-dispatch race that leaked a reply into the next case. Current-main integration also updates evidence expectations for its identifier-authentication contract; no assertion or build budget was weakened.

User Impact

Enabled audit collection attributes allowed Twitch turns to the correct native sender and account. Missing native IDs stay unknown; external installations remain untrusted for this evidence path; disabled collection permits normal replies without collecting identity. Stored identities are opaque rather than raw Twitch IDs. Mention gating, allowlist precedence, explicit-empty denial, and supported role decisions remain unchanged.

No configuration, schema, storage, SDK API, or host authorization change. AI-assisted.

Release-note intent: Fix account-scoped native sender attribution in opt-in Twitch execution audits while preserving existing admission and reply behavior.

Evidence

  • Original registered-plugin reproduction: six intended failures for default/named accounts under allowlist, role, and open policies while native replies still succeeded. Separate wildcard failures exposed overstated policy-enforcement evidence.
  • Candidate c9c2f0071dccb056a8ba8dfa1e019c47897dd634: 95 focused functional tests pass across registered-host ingress, all supported roles, native-ID absence, external-origin and disabled-collection negatives, startup lifecycle, reply delivery, and context-builder inventory. An additional 35 plugin-artifact and SDK-shape tests pass. The final host test uses the real account resolver through the canonical public-artifact contract.
  • Complete changed-file gate passes, including core/plugin types, type-aware lint, plugin boundaries, database-first guards, and zero runtime import cycles. Fresh isolated Codex review has no actionable findings.
  • Canonical private-QA build passes on Node 24.20.0. An earlier head failed the UI budget by 14 bytes; integrating the already-landed main fix restored the canonical build without changing its budget.
  • Actual compiled Gateway proof on c9c2f007: four isolated policy configurations, 24 transport inputs, exactly 14 replies/model requests/successful terminal runs, and 10 negative inputs with no extra output. Public audit inspection verifies stable native identity, distinct participants, account separation, role/open/wildcard attribution-only evidence, missing-ID unknown state, and disabled identity collection. All four Gateways exited cleanly, all listeners closed, and the frozen source/runtime graph remained unchanged.
  • Proof boundary: the Gateway, registered plugin, agent dispatch, persistence, reply delivery, and audit RPCs are real; Twurple's ChatClient transport and model are controlled fixtures. This is not authenticated Twitch/IRC-parser or real-model validation. Only the bundled third-party ChatClient region is substituted, with hashes checking that surrounding OpenClaw code is unchanged.
  • Earlier CI 33111040076 exposed a core test importing plugin types, a source-artifact import outside its canonical contract helper, and a broad SDK type import. These boundaries are repaired, with actual failing/passing guard proof. The same old run exceeded the startup-memory limit (401.69 MiB median versus 401 MiB effective limit); no memory or build budget was changed. The final candidate's build/startup-memory and boundary jobs pass. Full exact-head CI 33113015045 completed successfully: 127 successful jobs, 20 skipped, no failures, and a successful ci-gate. Native prepare/merge is next.
OPENCLAW_VITEST_MAX_WORKERS=1 node scripts/run-vitest.mjs src/plugins/registry-runtime.twitch-ingress.test.ts src/plugins/registry-runtime.channel-ingress.test.ts extensions/twitch/src/access-control.test.ts extensions/twitch/src/plugin.lifecycle.test.ts extensions/twitch/src/monitor.test.ts src/channels/message-access/context-builder-callers.test.ts

Relative to the integrated main baseline: production +41/-42 (net -1), tests +469/-102, docs +13. The existing producer owns the repair; no additional identity or authorization layer is introduced.

The generic normalized-wildcard diagnostic fact remains a separate, unproven follow-up because sibling adapters and shared hasWildcard also participate in authoritative DM and mutable-identifier policy. This PR does not claim that shared-policy repair.

Forward the registered channel runtime and actual account identity, keeping native participants distinct from role authorization. Normalize the all role at the Twitch policy producer and preserve unknown and disabled-collection paths.

Cover actual registered-plugin ingress and native reply delivery, and drain asynchronous monitor test work before cleanup. Related to #122863; no shared authorization or storage change.
@clawsweeper

clawsweeper Bot commented Aug 27, 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: L maintainer Maintainer-authored PR labels Aug 27, 2026
@steipete steipete self-assigned this Aug 27, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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 27, 2026
@clawsweeper

clawsweeper Bot commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed August 27, 2026, 2:31 AM ET / 06:31 UTC.

ClawSweeper review

What this changes

The PR preserves account-scoped native Twitch sender identity in opt-in execution audits while keeping role-based admission separate from participant identity.

Regression provenance

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

Merge readiness

⚠️ Ready for maintainer review - 4 items remain

Keep open: the provenance repair follows the correct registered-runtime boundary, but its new Twitch source-inventory entry still asserts the removed global-runtime marker and will fail the focused contract test.

Priority: P2
Reviewed head: 70b3e7de6d40445fb9a2d40123bd54fb1c0a1288

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The owner-boundary repair is coherent, but the stale deterministic inventory assertion prevents a merge-ready rating.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR is exempt from the contributor-proof gate; its declared exact-head validation remains required before landing.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR is exempt from the contributor-proof gate; its declared exact-head validation remains required before landing.
Evidence reviewed 4 items Inventory mismatch: The exhaustive host-builder inventory requires the old core.channel.inbound.buildContext marker for Twitch, but the changed monitor contains only the injected runtime call; its assertion loop will fail.
Correct runtime owner boundary: Gateway startup supplies a task-scoped channel runtime, Twitch rejects startup without it, and the plugin registry wraps only the live registered record's context builder for passive provenance attachment.
Audit contract: Core documents that only a trusted active registered native plugin supplies participant facts and that wildcard admission remains attribution-only.
Findings 1 actionable finding [P2] Update the Twitch context-builder inventory
Security None None.

Live Verification

Command: node scripts/run-vitest.mjs src/plugins/registry-runtime.twitch-ingress.test.ts

Result: PASS (completed)

[test] starting test/vitest/vitest.plugins.config.ts

 RUN  v4.1.11 /tmp/clawsweeper-live-proof-130730-B9OWtV/target

[vitest] still running with no output for 30000ms.
 ✓  plugins  src/plugins/registry-runtime.twitch-ingress.test.ts (10 tests) 4595ms
     ✓ preserves 'default' 'allowlist' sender through actual ingress and reply  862ms
     ✓ preserves 'default' 'role' sender through actual ingress and reply  399ms
     ✓ preserves 'default' 'open' sender through actual ingress and reply  380ms
     ✓ preserves 'default' 'wildcard' sender through actual ingress and reply  362ms
     ✓ preserves 'secondary' 'allowlist' sender through actual ingress and reply  500ms
     ✓ preserves 'secondary' 'role' sender through actual ingress and reply  361ms
     ✓ preserves 'secondary' 'open' sender through actual ingress and reply  362ms
     ✓ preserves 'secondary' 'wildcard' sender through actual ingress and reply  355ms
     ✓ does not promote a role or username when the native user id is absent  361ms
     ✓ keeps normal replies working with collection disabled  358ms

 Test Files  1 passed (1)
      Tests  10 passed (10)
   Start at  06:32:12
   Duration  30.87s (transform 22.01s, setup 967ms, import 24.96s, tests 4.59s, environment 0ms)

[test] passed 1 Vitest shard in 37.10s

Assertions:

  • PASS expect_output: Test Files

How this fits together

Twitch callbacks are admitted by the bundled plugin and handed to the registered channel runtime. That runtime builds agent context and attaches validated diagnostic provenance before a reply is dispatched.

flowchart LR
  A[Twitch callback] --> B[Twitch plugin]
  B --> C[Access and route resolution]
  C --> D[Registered channel runtime]
  D --> E[Context and audit provenance]
  E --> F[Agent reply dispatch]
Loading

Before merge

  • Update the Twitch context-builder inventory (P2) - The monitor now calls channelRuntime.inbound.buildContext, but HOST_BUILDERS still requires core.channel.inbound.buildContext in this file. Its exhaustive source assertion will fail; update the Twitch marker to the injected-runtime call and rerun the focused inventory gate.
  • Resolve merge risk (P1) - The cross-channel context-builder inventory is stale, so its focused gate will fail until the Twitch marker is updated.
  • Resolve merge risk (P1) - The draft declares exact-head Gateway/mock-transport and CI validation still pending.
  • Complete next step (P2) - Correct the stale inventory assertion and complete exact-head validation; this active maintainer draft should not be replaced by an automated repair.

Findings

  • [P2] Update the Twitch context-builder inventory — src/channels/message-access/context-builder-callers.test.ts:108
Agent review details

Security

None.

PR surface

Source +8, Tests +358, Docs +13. Total +379 across 9 files.

View PR surface stats
Area Files Added Removed Net
Source 3 41 33 +8
Tests 5 450 92 +358
Docs 1 13 0 +13
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 9 504 125 +379

Review metrics

Metric Value Why it matters
Production and test LOC production +41/-33 (net +8); tests +450/-92; docs +13 Production growth is limited to forwarding and validating the registered context boundary; most added coverage exercises account and policy combinations.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #130728
Summary: This PR is the candidate repair for the reported Twitch provenance loss.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Repair the inventory contract (recommended)
    Replace the obsolete Twitch marker with channelRuntime.inbound.buildContext and rerun the inventory and registered-ingress tests.

Technical review

Best possible solution:

Update the Twitch inventory to the injected registered-runtime marker, then complete the focused and exact-head validation before merge.

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

Yes: the source inventory and changed monitor call provide a high-confidence deterministic failure path, although this read-only review did not execute it.

Is this the best way to solve the issue?

Yes for the provenance repair: only the host-wrapped runtime can attach host-minted one-shot evidence; the inventory assertion needs the corresponding update.

Full review comments:

  • [P2] Update the Twitch context-builder inventory — src/channels/message-access/context-builder-callers.test.ts:108
    The monitor now calls channelRuntime.inbound.buildContext, but HOST_BUILDERS still requires core.channel.inbound.buildContext in this file. Its exhaustive source assertion will fail; update the Twitch marker to the injected-runtime call and rerun the focused inventory gate.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.99

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add merge-risk: 🚨 automation: The changed inventory assertion references a removed source marker, causing the repository's focused validation automation to fail.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This maintainer-authored PR is exempt from the contributor-proof gate; its declared exact-head validation remains required before landing.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.
  • remove status: 👀 ready for maintainer look: Current PR status label is status: ⏳ waiting on author.

Label justifications:

  • P2: The PR has a deterministic, bounded test-contract regression that should be corrected before normal merge validation.
  • merge-risk: 🚨 automation: The changed inventory assertion references a removed source marker, causing the repository's focused validation automation to fail.
  • 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: This maintainer-authored PR is exempt from the contributor-proof gate; its declared exact-head validation remains required before landing.

Evidence

Acceptance criteria:

  • [P1] node scripts/run-vitest.mjs src/channels/message-access/context-builder-callers.test.ts.
  • [P1] node scripts/run-vitest.mjs src/plugins/registry-runtime.twitch-ingress.test.ts.

What I checked:

Likely related people:

  • steipete: Current history includes this change and prior Twitch monitor fixes. (role: recent Twitch-area contributor; confidence: high; commits: 70b3e7de6d40, 4a029e5279a4, e04ea7916c5b; files: extensions/twitch/src/monitor.ts, src/channels/message-access/context-builder-callers.test.ts)
  • joshavant: Merged the channel-admission binding work that this Twitch repair uses. (role: feature-history owner; confidence: medium; commits: 97a53a9b35a8; files: src/plugins/registry-runtime.ts)

Rank-up moves

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

  • Update the Twitch inventory marker and run src/channels/message-access/context-builder-callers.test.ts.
  • Run the declared exact-head registered Gateway/mock-transport proof and applicable CI.

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 (1 earlier review cycle)
  • reviewed 2026-08-27T05:48:50.703Z sha 70b3e7d :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. 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 27, 2026
@steipete
steipete marked this pull request as ready for review August 27, 2026 19:49
@steipete
steipete merged commit 3424633 into main Aug 27, 2026
208 checks passed
@steipete
steipete deleted the codex/twitch-participant-provenance branch August 27, 2026 20:45
@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 28, 2026
…law#130730)

* fix(twitch): retain native sender identity in execution audits

Forward the registered channel runtime and actual account identity, keeping native participants distinct from role authorization. Normalize the all role at the Twitch policy producer and preserve unknown and disabled-collection paths.

Cover actual registered-plugin ingress and native reply delivery, and drain asynchronous monitor test work before cleanup. Related to openclaw#122863; no shared authorization or storage change.

* test(twitch): track the registered context builder in inventory

* test(twitch): honor host and plugin contract boundaries
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 maintainer Maintainer-authored PR merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: L 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.

[Bug]: Twitch replies lose native participant provenance in execution audits

1 participant