Skip to content

refactor: plugin-run turns get owner status from commands.ownerAllowFrom, like text messages - #205373

Merged
obviyus merged 1 commit into
mainfrom
refactor/oa2-sdk-owner-claim
Nov 25, 2026
Merged

obviyus merged 1 commit into
mainfrom
refactor/oa2-sdk-owner-claim

Conversation

@obviyus

@obviyus obviyus commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

What Problem This Solves

A plugin that runs an agent turn for a channel message decided for itself whether the sender was the owner, by passing senderIsOwner to runCommandFromIngress. The host trusted that claim only from bundled or officially installed plugins. A community channel plugin that passed true got an error, and its turn failed. So the same person could get owner tools in a Discord text message but not through a plugin's voice or command turn, depending on which code started the turn.

Why This Change Was Made

The Gateway's admission now makes this decision, using the same commands.ownerAllowFrom rule as a text message from that channel. The plugin passes facts (the channel, account and sender), and the host decides.

  • runCommandFromIngress ignores options.senderIsOwner. The host makes the turn an owner turn exactly when commands.ownerAllowFrom lists runContext.senderId for options.messageChannel (readIngressSenderAdmission in operator-admission.ts, using the same matcher as decideChannelOwnerPrincipal). Any other sender runs as a non-owner.
  • A plugin that still passes senderIsOwner: true gets one DEP_PLUGIN_SDK deprecation warning per plugin per process, through the existing warnPluginSdkDeprecation. The field stays on the type as @deprecated until the next Plugin SDK major (public SDK contract, src/plugin-sdk/AGENTS.md). Only one public plugin references it (@drakon-systems/multi-clawd, as a typeof feature probe).
  • Deleted: the trusted-install owner gate in registry-runtime.ts. Kept: the check that only the active plugin registered for messageChannel can run turns for it. Its error no longer says "owner authority": Plugin "<id>" cannot run turns for channel "<channel>": it is not the active plugin registered for that channel.
  • Discord voice passes the speaker as runContext.senderId instead of its own owner bit. The host's matcher accepts the same owner forms the voice resolver did (discord:, user:, pk:, <@id>, discord:user:id; wildcards stripped).
  • Remote worker: deleted requester: { senderIsOwner: true } from the worker's tool hook context. Its only reader is the before-tool-call hook context, which returns early when no hooks and no trusted policies are registered. The worker runs with plugins: { enabled: false } and nothing under src/worker initializes a hook runner. The Gateway already limits worker tools through toolAuthority.allowedToolNames.
  • OWNER_PRODUCER_FILES goes from 24 to 22 (worker and registry runtime removed).

Not in this PR: FaceTime. It claims owner through consultRealtimeVoiceAgent, using the plugin's own ownerHandles list. Moving those handles into commands.ownerAllowFrom needs a Doctor config migration, which is waiting on a separate decision. It stays on the allowlist, and the allowlist comment now gives this reason. Discord voice's realtime overlay still uses its own owner match. That moves to the core matcher in a later PR.

Production diff: +45/−20 (net positive, recorded). The owner decision needs a new admission function in operator-admission.ts, because the owner-producer lint allows the bit only from grant.owner. The approved design also requires the deprecation warning. Together those outweigh the deleted claim and trust gate.

User Impact

  • Discord voice: a configured owner speaking in voice still gets owner turns, and other speakers do not. The answer is unchanged; it now comes from the host.
  • Community channel plugins (a widening): a sender listed in commands.ownerAllowFrom now gets owner turns, the same as their text messages on that channel. Before, the turn failed if the plugin claimed owner, and ran as non-owner if it did not.
  • Plugin authors: no type break. Passing senderIsOwner has no effect and logs one deprecation warning. Pass runContext.senderId and accountId.

Release note: Plugin SDK: runCommandFromIngress now decides owner status from runContext.senderId and commands.ownerAllowFrom, the same as a text message from that channel. The senderIsOwner option is deprecated and ignored (one warning per plugin). Community channel plugins no longer fail when they pass it.

Evidence

  • Matrix cells (src/plugins/runtime/runtime-agent.ingress.integration.test.ts: real host runtime, real tool loop, Discord-shaped ingress, commands.ownerAllowFrom: ["discord:owner-1"]):
    • configured owner sender, no claim → owner tools (sessions patch applied). Red on base 5730bde18a60 (base ignored senderId, so the turn ran as non-owner).
    • guest sender claiming senderIsOwner: true → non-owner, exactly one deprecation warning. Red on base (base honored the claim).
    • guest sender, and owner with toolsAllow restricted → non-owner. Green on both.
  • Community plugin ingress (src/plugins/registry-runtime.channel-ingress.test.ts): a workspace (untrusted) channel plugin passing senderIsOwner: true for its own channel runs the turn. Red on base (it threw "cannot admit authenticated owner authority"). Foreign-channel and unloaded-plugin calls are still refused with the new text.
  • Discord voice owner cell: voice tests now assert the speaker reaches the host as runContext.senderId. voice-runtime.e2e.test.ts "keeps owner-only tools for commands.ownerAllowFrom" is green.
  • Worker: nothing under src/worker calls initializeGlobalHookRunner or loads plugins (WORKER_TOOL_CONFIG = { plugins: { enabled: false } }), so wrapToolWithBeforeToolCallHook returns before it reads requester.
  • Pre-push: one ocx test run of 49 files (touched tests, plus importers of operator-admission.ts, registry-runtime.ts, runtime-agent.ts, the worker runtime and Discord voice ingress): all green. Reruns after the final edits (21 files, then 3): green. pnpm tsgo:core exit 0; tsgo:test green after the voice test fix; oxlint and oxfmt clean on the changed files.
  • pnpm check:changed: the only failures are on main. check-changelog-attributions fails on CHANGELOG/2026.11.10.md:8130. The dead-export scan flags SESSION_APPROVAL_RECIPIENTS and two scripts/e2e/parallels exports. Our own Knip finding was fixed.
  • pnpm plugin-sdk:api:diff --base origin/main --head HEAD: "No Plugin SDK API changes."
  • Bundled SDK scan (plugin-sdk-impact scan-bundled.mjs, Inspector 0.4.3) timed out after 25 min, so bundled coverage is a gap. Source grep: the only bundled caller of runCommandFromIngress is Discord voice (extensions/discord/src/voice/ingress.ts). ClawHub: one plugin references the member (@drakon-systems/multi-clawd 2.7.3, a typeof probe).

…e sender

- runCommandFromIngress ignores the plugin's senderIsOwner claim (one deprecation warning per
  plugin); the host makes the turn an owner turn when commands.ownerAllowFrom lists
  runContext.senderId for that channel.
- Drop the trusted-install owner gate; keep the channel-binding check with a reworded error.
- Discord voice passes the speaker as runContext.senderId instead of its owner bit.
- Worker tool hooks no longer claim owner: the worker runs no hooks or trusted policies.

Co-authored-by: obviyus <[email protected]>
@clawsweeper

clawsweeper Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: discord Channel integration: discord gateway Gateway runtime scripts Repository scripts agents Agent runtime and tooling plugin: file-transfer size: M labels Nov 25, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. impact:auth-provider Auth, provider routing, model choice, or SecretRef resolution may break. clawsweeper:intake:bug Preliminary submission classification; full source review pending. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 25, 2026
@clawsweeper

clawsweeper Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR derives plugin-ingress owner status from the sender and commands.ownerAllowFrom instead of a plugin-supplied boolean.

Example: commands.ownerAllowFrom contains discord:owner-1, and a plugin starts a turn with runContext.senderId set to owner-1 without claiming owner status.

  • Before: The turn runs without owner-only tools.
  • After: Host admission grants owner status using the configured channel-owner rule.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The production change appears sound, but required runtime proof is absent and one changed test substitutes a hard-coded authority decision.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Product

Kind: Refactor · Worth it: Yes · Fix scope: Complete
User problem: Configured owners can receive different tool authority depending on whether text ingress or a plugin starts their turn.
Reason: The maintainer-authored direction consolidates admission in its existing owner and explicitly accepts the community-plugin behavior change.

Merge readiness

✅ Ready for maintainer review

Keep this maintainer-authored PR open: centralizing plugin-ingress owner admission is useful, and source review found no blocking production defect.

Reviewed head: 78406f978cfd4e9465214018ae3dfda20123d66c

Before merge

None.

Findings

None.

Tests

  • Low-value test extensions/discord/src/voice/voice-runtime.e2e.test.ts: Remove the tool-authority assertions driven by senderId === "100000000000000001": they fabricate the owner decision and remain green if config-based host admission fails; retain the distinct voice sender-propagation and admission checks.
  • Missing end-to-end proof: Provide a redacted running-Gateway or channel trace showing configured-owner access and guest rejection through the injected plugin runtime, including an existing-install upgrade with owner settings intact.
Agent review details

How this fits together

Channel plugins submit sender and channel facts through their injected runtime; the registry checks channel ownership, admission determines owner status, and the agent runtime applies tool restrictions.

flowchart LR
  A[Channel sender] --> B[Channel plugin]
  B --> C[Registry channel binding]
  C --> D[Host ingress runtime]
  E[Owner allowlist] --> F[Operator admission]
  D --> F
  F --> G[Agent tool execution]
Loading

Technical review

Best possible solution:

Keep owner decisions in existing host admission, retain channel binding and SDK migration guidance, and remove the hard-coded Discord tool-authority assertions.

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

Current-main source directly shows the trusted-install owner gate and the runtime's reliance on senderIsOwner; the PR reports red-on-base integration cases, which were inspected but not executed during this read-only review.

Is this the best way to solve the issue?

Reusing the existing configured-owner matcher is a focused consolidation with no unnecessary production machinery; the new admission function names a real authority boundary.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 28d47b9be738.

Provenance checked

  • Plugin ingress owner claim and trusted-install gate changes intended behavior with a stated reason (20b453f: Prevent public plugin ingress from forging owner privileges; the PR replaces boolean claims with the host's configured-owner decision.)
  • Discord voice owner forwarding keeps the original intent (35f80a1: Preserve owner-only capabilities for configured Discord voice owners; forwarding sender identity retains that intent under host admission.)
  • Worker hook requester owner bit keeps the original intent (6edf4a2: The worker startup refactor retained generic hook context while narrowing tool construction; current workers initialize no hook runner, and the policy path returns before reading requester when hooks and trusted policies are absent. A historical stat read encountered an unavailable promisor object; the scoped patch and linked PR were readable.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Ayaan Zaidi: Raw commit e2a9a6d adds src/gateway/operator-admission.ts:275 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: e2a9a6d6f3e8; files: src/gateway/operator-admission.ts)

PR surface

Source +25, Tests +19, Docs +5, Other 0. Total +49 across 20 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 7 45 20 +25
Tests 11 90 71 +19
Docs 1 10 5 +5
Config 0 0 0 0
Generated 0 0 0 0
Other 1 4 4 0
Total 20 149 100 +49

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add merge-risk: 🚨 compatibility: The public SDK parameter remains source-compatible but changes behavior: senderIsOwner is ignored, and configured sender identity determines owner status; the maintainer-authored PR explicitly accepts this transition.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • merge-risk: 🚨 compatibility: The public SDK parameter remains source-compatible but changes behavior: senderIsOwner is ignored, and configured sender identity determines owner status; the maintainer-authored PR explicitly accepts this transition.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 25, 2026, 8:47 AM ET / 13:47 UTC.

@obviyus
obviyus merged commit e968a68 into main Nov 25, 2026
173 checks passed
@obviyus
obviyus deleted the refactor/oa2-sdk-owner-claim branch November 25, 2026 13:51
@obviyus

obviyus commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator Author

Landed as e968a68.

  • Bug: a plugin decided owner status for its own ingress turns. Community channel plugins that claimed owner failed outright, and a configured owner got owner tools only if the plugin claimed them.
  • Fix: runCommandFromIngress now gets owner status from commands.ownerAllowFrom and runContext.senderId, the same rule as a text message. The senderIsOwner claim is ignored and logs one deprecation warning per plugin. Discord voice passes the speaker id. The worker no longer claims owner for tool hooks.
  • Proof: the owner-by-sender, claim-ignored and community-plugin cells were red on base and are green here. Plugin SDK API diff is empty. Local review is clean. One-admission E2E Q/R/S passes. CI is green on 78406f978cfd.

vincentkoc added a commit that referenced this pull request Nov 25, 2026
* commit '92569e37ab84a8cb1e4a12c3dcbb45acb97977c9':
  fix: distinguish Desktop sources without wrapping their names or IDs (#203747)
  fix(ui): Greek sigma searches miss matches outside Sessions and Files (#189518)
  fix: keep agent skill names on one line beside their switches (#203734)
  test(cron): admit scheduled occurrences in cron fixtures and fix Node 24 toHex in Vitest (#205383)
  fix: keep the Agents menu usable after copying an ID (#203739)
  fix(whatsapp): preserve code table spaces across message chunks (#205327)
  refactor(cron): admit legacy scheduled requesters through operator admission (#205346)
  fix: keep silent Codex turns healthy with running commands (#196062)
  test(update): verify the recorded preparation failure (#205363)
  fix(test): prove sibling imports on the active update path
  fix(chat): complete mentions without leaving part of the name behind (#205326)
  fix(test): restore Side chat hydration and retry checks (#205376)
  refactor: plugin-run turns get owner status from commands.ownerAllowFrom, like text messages (#205373)
  chore(ui): refresh control ui locales (#205378)
  fix: keep Telegram rich <details> and list blocks in one message when replies stream in chunks (#205318)
  refactor(gateway): one refusal owner with a required next step (#205337)
  fix(discord): keep long table labels bold across messages (#205328)
  feat: invitation, sharing and participant controls in the Control UI (#204920)
  fix(test): distinguish stamped Skill Library upgrade policies
  fix(markdown): preserve trailing inline-code spaces in plain-text tables (#205317)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 26, 2026
…rom, like text messages (openclaw#205373)

## What Problem This Solves

A plugin that runs an agent turn for a channel message decided for itself whether the sender was the owner, by passing `senderIsOwner` to `runCommandFromIngress`. The host trusted that claim only from bundled or officially installed plugins. A community channel plugin that passed `true` got an error, and its turn failed. So the same person could get owner tools in a Discord text message but not through a plugin's voice or command turn, depending on which code started the turn.

## Why This Change Was Made

The Gateway's admission now makes this decision, using the same `commands.ownerAllowFrom` rule as a text message from that channel. The plugin passes facts (the channel, account and sender), and the host decides.

- `runCommandFromIngress` ignores `options.senderIsOwner`. The host makes the turn an owner turn exactly when `commands.ownerAllowFrom` lists `runContext.senderId` for `options.messageChannel` (`readIngressSenderAdmission` in `operator-admission.ts`, using the same matcher as `decideChannelOwnerPrincipal`). Any other sender runs as a non-owner.
- A plugin that still passes `senderIsOwner: true` gets one `DEP_PLUGIN_SDK` deprecation warning per plugin per process, through the existing `warnPluginSdkDeprecation`. The field stays on the type as `@deprecated` until the next Plugin SDK major (public SDK contract, `src/plugin-sdk/AGENTS.md`). Only one public plugin references it (`@drakon-systems/multi-clawd`, as a `typeof` feature probe).
- Deleted: the trusted-install owner gate in `registry-runtime.ts`. Kept: the check that only the active plugin registered for `messageChannel` can run turns for it. Its error no longer says "owner authority": `Plugin "<id>" cannot run turns for channel "<channel>": it is not the active plugin registered for that channel.`
- Discord voice passes the speaker as `runContext.senderId` instead of its own owner bit. The host's matcher accepts the same owner forms the voice resolver did (`discord:`, `user:`, `pk:`, `<@id>`, `discord:user:id`; wildcards stripped).
- Remote worker: deleted `requester: { senderIsOwner: true }` from the worker's tool hook context. Its only reader is the before-tool-call hook context, which returns early when no hooks and no trusted policies are registered. The worker runs with `plugins: { enabled: false }` and nothing under `src/worker` initializes a hook runner. The Gateway already limits worker tools through `toolAuthority.allowedToolNames`.
- `OWNER_PRODUCER_FILES` goes from 24 to 22 (worker and registry runtime removed).

Not in this PR: FaceTime. It claims owner through `consultRealtimeVoiceAgent`, using the plugin's own `ownerHandles` list. Moving those handles into `commands.ownerAllowFrom` needs a Doctor config migration, which is waiting on a separate decision. It stays on the allowlist, and the allowlist comment now gives this reason. Discord voice's realtime overlay still uses its own owner match. That moves to the core matcher in a later PR.

Production diff: +45/−20 (**net positive, recorded**). The owner decision needs a new admission function in `operator-admission.ts`, because the owner-producer lint allows the bit only from `grant.owner`. The approved design also requires the deprecation warning. Together those outweigh the deleted claim and trust gate.

## User Impact

- **Discord voice:** a configured owner speaking in voice still gets owner turns, and other speakers do not. The answer is unchanged; it now comes from the host.
- **Community channel plugins (a widening):** a sender listed in `commands.ownerAllowFrom` now gets owner turns, the same as their text messages on that channel. Before, the turn failed if the plugin claimed owner, and ran as non-owner if it did not.
- **Plugin authors:** no type break. Passing `senderIsOwner` has no effect and logs one deprecation warning. Pass `runContext.senderId` and `accountId`.

Release note: Plugin SDK: `runCommandFromIngress` now decides owner status from `runContext.senderId` and `commands.ownerAllowFrom`, the same as a text message from that channel. The `senderIsOwner` option is deprecated and ignored (one warning per plugin). Community channel plugins no longer fail when they pass it.

## Evidence

- Matrix cells (`src/plugins/runtime/runtime-agent.ingress.integration.test.ts`: real host runtime, real tool loop, Discord-shaped ingress, `commands.ownerAllowFrom: ["discord:owner-1"]`):
  - configured owner sender, no claim → owner tools (`sessions` patch applied). **Red on base `8edcaa7b766f`** (base ignored `senderId`, so the turn ran as non-owner).
  - guest sender claiming `senderIsOwner: true` → non-owner, exactly one deprecation warning. **Red on base** (base honored the claim).
  - guest sender, and owner with `toolsAllow` restricted → non-owner. Green on both.
- Community plugin ingress (`src/plugins/registry-runtime.channel-ingress.test.ts`): a workspace (untrusted) channel plugin passing `senderIsOwner: true` for its own channel runs the turn. **Red on base** (it threw "cannot admit authenticated owner authority"). Foreign-channel and unloaded-plugin calls are still refused with the new text.
- Discord voice owner cell: voice tests now assert the speaker reaches the host as `runContext.senderId`. `voice-runtime.e2e.test.ts` "keeps owner-only tools for commands.ownerAllowFrom" is green.
- Worker: nothing under `src/worker` calls `initializeGlobalHookRunner` or loads plugins (`WORKER_TOOL_CONFIG = { plugins: { enabled: false } }`), so `wrapToolWithBeforeToolCallHook` returns before it reads `requester`.
- Pre-push: one `ocx test` run of 49 files (touched tests, plus importers of `operator-admission.ts`, `registry-runtime.ts`, `runtime-agent.ts`, the worker runtime and Discord voice ingress): all green. Reruns after the final edits (21 files, then 3): green. `pnpm tsgo:core` exit 0; `tsgo:test` green after the voice test fix; oxlint and oxfmt clean on the changed files.
- `pnpm check:changed`: the only failures are on main. `check-changelog-attributions` fails on `CHANGELOG/2026.11.10.md:8130`. The dead-export scan flags `SESSION_APPROVAL_RECIPIENTS` and two `scripts/e2e/parallels` exports. Our own Knip finding was fixed.
- `pnpm plugin-sdk:api:diff --base origin/main --head HEAD`: "No Plugin SDK API changes."
- Bundled SDK scan (`plugin-sdk-impact` `scan-bundled.mjs`, Inspector 0.4.3) timed out after 25 min, so bundled coverage is a gap. Source grep: the only bundled caller of `runCommandFromIngress` is Discord voice (`extensions/discord/src/voice/ingress.ts`). ClawHub: one plugin references the member (`@drakon-systems/multi-clawd` 2.7.3, a `typeof` probe).

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

Labels

agents Agent runtime and tooling channel: discord Channel integration: discord docs Improvements or additions to documentation gateway Gateway runtime impact:auth-provider Auth, provider routing, model choice, or SecretRef resolution may break. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. plugin: file-transfer rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. scripts Repository scripts size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant