Skip to content

refactor(plugins): single-source interactive dispatch and its auth downgrade via plugin SDK - #120062

Merged
steipete merged 1 commit into
mainfrom
steipete/loc2-interactive-6b4d
Aug 6, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/loc2-interactive-6b4d

Conversation

@steipete

@steipete steipete commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Discord, Slack, and Telegram each owned a near-identical interactive plugin dispatch template: the same six-key context projection, namespace payload reconstruction, binding-helper injection, and a security-sensitive pluginRoot downgrade. Keeping that authorization rule in three channel implementations made drift likely.

The three-way preflight found one premise mismatch worth making explicit: Discord and Telegram required authorized sender + nonblank sender/account/conversation identifiers, while Slack required only authorization + its normalized base conversation. This change intentionally adopts the frozen four-factor rule for all channels, so Slack's unusual authorized callbacks with a missing sender, account, or base conversation can still reach their handler but cannot acquire conversation-binding authority.

Why This Change Was Made

createChannelInteractiveDispatcher now lives beside dispatchPluginInteractiveHandler, the runtime owner. It owns the six omitted context keys, interaction payload reconstruction, deduped dispatch, binding-helper composition, and the only production pluginRoot downgrade. The existing Plugin SDK plugin-runtime facade exposes the factory without adding a new import edge or public subpath.

Discord and Slack map interaction directly; Telegram declares callbackMessage as the dispatch source for its public callback. Slack retains its channel-specific DM identity and thread/parent normalization as the optional binding-conversation override. The shared seam test covers authorized binding, unauthorized senders, missing sender/account/base conversation, and proves that a nonblank binding override cannot authorize a blank base context.

User Impact

Normal interactive callbacks retain the same namespace routing, payloads, deduplication, response helpers, Telegram post-handler behavior, and Slack DM/thread binding targets. The intentional security tightening affects only Slack callbacks missing one of the canonical binding-authority identifiers: their plugin handler still runs, while binding request/detach/get helpers fail closed.

Production/tooling/generated LOC: 167 additions, 168 deletions, net -1. Tests: 210 additions, 203 deletions, net +7. The refactor removes 371 lines overall and leaves one canonical authorization rule.

Evidence

Focused behavior:

  • node scripts/run-vitest.mjs src/plugins/interactive.test.ts — 22 tests passed, including the SDK seam authorization table.
  • OPENCLAW_VITEST_NO_OUTPUT_TIMEOUT_MS=300000 node scripts/run-vitest.mjs extensions/discord/src/monitor/monitor.test.ts extensions/slack/src/monitor/events/interactions.test.ts extensions/telegram/src/bot.test.ts — three shards passed: Discord 28, Slack 73, Telegram 134 (235 total).

SDK and static checks:

  • pnpm plugin-sdk:api:gen — regenerated the intentional module/plugin-runtime API hash.
  • pnpm plugin-sdk:surface:check — passed: 149 public entrypoints, 4,834 exports, 2,911 callable exports. The reasoned ledger rose by one public callable export.
  • pnpm plugin-sdk:api:check and pnpm plugin-sdk:check-exports — passed.
  • pnpm format <touched paths> — passed.
  • node scripts/run-oxlint.mjs <touched TypeScript/tooling paths> — passed, including Plugin SDK and Discord/Slack/Telegram declaration boundaries.
  • git diff --check — passed.
  • Production-only rg proof finds the four-factor condition and pluginRoot: undefined in exactly one place: src/plugins/interactive.ts.
  • .agents/skills/autoreview/scripts/autoreview --mode local --stream-engine-output — clean; no accepted/actionable findings (patch is correct, confidence 0.97).

Changed-gate note:

  • node scripts/check-changed.mjs delegated to Daytona run run_36ac970824ca / lease cbx_9256a65a198a; the remote command exited 1 after its captured stdout showed only green lanes and a final lifecycle marker, with no stderr event. The lease was released.
  • The documented trusted-source local fallback (OPENCLAW_HEAVY_CHECK_LOCK_SCOPE=worktree OPENCLAW_CHECK_CHANGED_REMOTE_CHILD=1 OPENCLAW_CHANGED_LANES_RAW_SYNC=1 CI=1 PNPM_CONFIG_VERIFY_DEPS_BEFORE_RUN=false node scripts/check-changed.mjs) passed all guards, formatting, SDK API/surface/export checks, dead-code scans, plugin boundaries, script declarations, and core production typecheck. Core-test typecheck stopped only on three unchanged branch-baseline errors in ui/src/e2e/appearance-settings-defaults.e2e.test.ts (browser/server are undefined at lines 478, 492, and 536); that parallel-sibling file was not touched or committed here.

@steipete
steipete marked this pull request as ready for review August 6, 2026 23:18
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: discord Channel integration: discord channel: slack Channel integration: slack channel: telegram Channel integration: telegram scripts Repository scripts size: L maintainer Maintainer-authored PR labels Aug 6, 2026
@steipete

steipete commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

Incident-mode landing note (operator-directed).

GitHub's declared Actions incident left this PR's core CI queued/skipped and blocked ClawSweeper; the operator directed landing without waiting. Compensating gates, all satisfied:

  • Coordinator diff review: the security-critical authorization downgrade now exists in exactly one place (interactive.ts:177-181 with the invariant comment); Discord/Slack/Telegram divergences (structured responses, block/modal payloads, callback normalization) preserved per channel.
  • Intentional behavior note: Slack previously gated pluginRoot on two factors (authorized sender + conversation); the unified rule uses the four-factor gate its siblings already had (adds senderId/accountId). The old code already passed those ids into binding helpers that fail closed, so the change only strips pluginRoot from malformed/synthetic payloads — a narrow fail-closed alignment across channels, judged intentional and security-positive by the coordinator.
  • Structured Codex autoreview: clean ("patch is correct, 0.94").
  • Proof: SDK seam 22/22; Discord/Slack/Telegram 235/235; SDK API gen/surface/export checks, format, lint, declaration boundaries green.
  • Merge verified clean against latest origin/main.

Production net −1 (371 deletions), tests net +7 (new seam coverage). Landed via operator-authorized admin merge at the verified head.

@steipete
steipete merged commit 0b849a3 into main Aug 6, 2026
155 of 158 checks passed
@steipete
steipete deleted the steipete/loc2-interactive-6b4d branch August 6, 2026 23:31
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: discord Channel integration: discord channel: slack Channel integration: slack channel: telegram Channel integration: telegram docs Improvements or additions to documentation maintainer Maintainer-authored PR scripts Repository scripts size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant