Repository navigation
fix(discord): honor discord:user:<id> command owners in voice access and exec approvals - #172385
Conversation
…and exec approvals Doctor now preserves commands.ownerAllowFrom entries such as discord:user:<id> as the canonical direct-user owner form (openclaw#167059), but the Discord owner selector still dropped every discord:user: entry as a retired envelope. For an owner list holding only that form the selector returned an empty list, so /vc rejected the owner with "You are not authorized to use this command.", voice speakers lost owner status, and owner-derived exec approvers resolved to none, leaving execApprovals enabled "auto" disabled. Keep discord:user: entries in the selector. The existing allowlist and approver normalizers already resolve user:<id> to the native sender id.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs real behavior proof before merge. What this changesPreserve discord:user:<id> command owners for Discord voice access, speaker ownership, and owner-derived exec approvals. Example: commands.ownerAllowFrom contains discord:user:100000000000000001.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 2 items remain This PR fixes a current mismatch between Discord owner selection and the documented owner format; no discrete introduced defect was found. Priority: P1 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherThe Discord plugin selects configured command owners and passes them through existing voice allowlist and approval-target normalizers to authorize interactions and approval decisions. flowchart TD
A[Configured command owners] --> B[Discord owner selector]
B --> C[Voice admission and speaker ownership]
B --> D[Exec approver normalization]
C --> E[Voice operations and agent turns]
D --> F[Approval delivery and Gateway settlement]
Technical reviewBest possible solution: Keep the shared-selector repair and existing account-specific approval overrides. Do we have a high-confidence way to reproduce the issue? Current-main source deterministically drops discord:user:100000000000000001; the supplied before/after interaction trace corroborates the resulting voice refusal and absent approver. Is this the best way to solve the issue? Removing the obsolete exclusion at the existing shared selector aligns all Discord consumers with the canonical target format without adding another authorization path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against cfbf3b014c6e. Provenance checked
TestingProof path: in-process harness. SecurityNeeds attention: Typed owner entries now reach privileged voice and exec-approval paths through the existing authorization owners. EvidenceWhat I checked:
Likely related people:
PR surfaceSource -3, Tests +104. Total +101 across 5 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (3 earlier review cycles)Reviewed October 15, 2026, 11:22 PM ET / October 16, 2026, 03:22 UTC (Revision 4). |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
…and exec approvals (#172385) * fix(discord): honor discord:user:<id> command owners in voice access and exec approvals Doctor now preserves commands.ownerAllowFrom entries such as discord:user:<id> as the canonical direct-user owner form (#167059), but the Discord owner selector still dropped every discord:user: entry as a retired envelope. For an owner list holding only that form the selector returned an empty list, so /vc rejected the owner with "You are not authorized to use this command.", voice speakers lost owner status, and owner-derived exec approvers resolved to none, leaving execApprovals enabled "auto" disabled. Keep discord:user: entries in the selector. The existing allowlist and approver normalizers already resolve user:<id> to the native sender id. * test(discord): prove typed owner approval authority at the capability boundary * test(discord): prove typed owner vc leave authority follows live owner policy --------- Co-authored-by: Dallin Romney <[email protected]> (cherry picked from commit 2a41d1f)
…and exec approvals (openclaw#172385) * fix(discord): honor discord:user:<id> command owners in voice access and exec approvals Doctor now preserves commands.ownerAllowFrom entries such as discord:user:<id> as the canonical direct-user owner form (openclaw#167059), but the Discord owner selector still dropped every discord:user: entry as a retired envelope. For an owner list holding only that form the selector returned an empty list, so /vc rejected the owner with "You are not authorized to use this command.", voice speakers lost owner status, and owner-derived exec approvers resolved to none, leaving execApprovals enabled "auto" disabled. Keep discord:user: entries in the selector. The existing allowlist and approver normalizers already resolve user:<id> to the native sender id. * test(discord): prove typed owner approval authority at the capability boundary * test(discord): prove typed owner vc leave authority follows live owner policy --------- Co-authored-by: Dallin Romney <[email protected]>
…and exec approvals (#172385) * fix(discord): honor discord:user:<id> command owners in voice access and exec approvals Doctor now preserves commands.ownerAllowFrom entries such as discord:user:<id> as the canonical direct-user owner form (#167059), but the Discord owner selector still dropped every discord:user: entry as a retired envelope. For an owner list holding only that form the selector returned an empty list, so /vc rejected the owner with "You are not authorized to use this command.", voice speakers lost owner status, and owner-derived exec approvers resolved to none, leaving execApprovals enabled "auto" disabled. Keep discord:user: entries in the selector. The existing allowlist and approver normalizers already resolve user:<id> to the native sender id. * test(discord): prove typed owner approval authority at the capability boundary * test(discord): prove typed owner vc leave authority follows live owner policy --------- Co-authored-by: Dallin Romney <[email protected]> (cherry picked from commit 2a41d1f) (cherry picked from commit 3b0a9f5)
Summary
When
commands.ownerAllowFromholds a Discord owner in the canonical direct-user formdiscord:user:<id>, the Discord plugin treats the owner list as empty:/vc join|leave|statusreplies "You are not authorized to use this command." to everyone, including the configured owner, and voice transcript turns lose owner status and admission.channels.discord.execApprovals.enabled: "auto"stays disabled and the owner cannot approve exec requests from Discord.Doctor writes and preserves this form since #167059, and
docs/tools/slash-commands.mddocumentsownerAllowFrom: ["discord:user:123456789012345678"]as the example config. Text and native slash command authorization already accept it through coresrc/auto-reply/command-auth.ts; only the Discord-local owner selector disagrees.Root cause
extensions/discord/src/command-owners.tsstill drops everydiscord:user:entry, a filter added in #137780 when that form was a retired envelope that Doctor rewrote away:For
["discord:user:<id>"]this returns[], notundefined. Every Discord owner consumer routes through this selector:voice/owner-access.ts:admissionAllowFrom = commandOwnerAllowFrom ?? accountAllowFrom ?? ....[]is not nullish, so the accountallowFromfallback is skipped and voice admission is an empty allowlist.ownerAllowFromis also[], so speakers are never the owner.exec-approvals.ts: the owner fallback passes[]as the explicit approver list, so there are zero approvers andisDiscordExecApprovalClientEnabledis false forenabled: "auto".monitor/native-command-auth.ts: the native command owner gate sees a configured but empty owner list.#167059 made
discord:user:<id>canonical (docs/gateway/doctor/config-migrations.md, "Command-owner target kinds"). ClawSweeper's review of #167059 flagged this exact gap as P1 before merge ("Update Discord owner consumers for the preserved target kind", #167059 (comment)): "resolveDiscordCommandOwnerEntries()still filters out everydiscord:user:entry atextensions/discord/src/command-owners.ts:10. Consequently, Doctor's recovery changes a working bare owner into an empty voice admission list and removes owner-derived exec approvers." That PR merged without the selector change, and current main still has the filter.Fix
Keep
discord:user:entries in the selector:No new parsing is needed.
resolveDiscordCommandOwnerAllowFromalready stripsdiscord:, which yieldsuser:<id>, andnormalizeDiscordAllowListalready resolves that to the native sender id. That is the same path the existinguser:<id>owner cases use. On the approval side,normalizeDiscordApproverIdalready parsesdiscord:user:<id>throughparseDiscordTarget, which is how explicitexecApprovals.approvers: ["discord:user:456"]already works. Wildcards keep their current behavior:discord:user:*becomesuser:*, which the allowlist and the approver parser both still reject. The stale comment describing the retired envelope is removed.Why this is the right boundary
The selector is the single Discord-owned place that turns
commands.ownerAllowFrominto Discord owner entries, and all of its consumers (voice admission, voice speaker owner status, the native command owner gate, exec approvers) now agree with core command authorization and with the form Doctor preserves. Bare ids,discord:<id>,user:<id>,pk:<id>, and mention forms are unchanged, and so are foreign-channel entries.Slack sibling, out of scope:
extensions/slack/src/exec-approvals.tspasses rawcommands.ownerAllowFromentries toparseSlackTarget, which has noslack:channel-prefix handling. That gap predates #167059, is not this filter, and would need its own Slack-specific change.Possible rebase overlap: open #157298 edits
extensions/discord/src/exec-approvals.tsand its test for linked-requester approval discovery. It does not touch the owner selector, so the two changes are independent.Verification
extensions/discord/src/voice/command.test.ts:discord:user:100000000000000001owner is now authorized for/vc status.extensions/discord/src/voice/speaker-context.test.ts:discord:user:123456789012345678owner now yieldssenderIsOwner: true.extensions/discord/src/exec-approvals.test.ts:commands.ownerAllowFrom: ["discord:user:123"]now resolves approver123and enables the client withenabled: "auto". Explicit approver targets are unchanged.Real behavior proof
Behavior addressed: A Discord owner configured as
commands.ownerAllowFrom: ["discord:user:<id>"]is refused on/vcand gets no exec approval delivery or approve rights on Discord.Real environment tested: The shipped Discord provider interaction surface (
createDiscordProviderInteractionSurfacefromextensions/discord/src/monitor/provider.interactions.ts, the same buildermonitor/provider.tsuses at boot) registered on the real internal DiscordClient, with a realDiscordVoiceManageron a realGatewayScheduler. A raw Discord APPLICATION_COMMAND payload for/vc statusfrom the owner goes throughClient.handleInteraction, and the reply is read from the REST call the client sends back to Discord. The only replaced seam is the Discord HTTP fetch (requestOptions.fetch), which records outgoing REST calls and answers guild/channel GETs. Exec approval state comes from the shippeddiscordPlugin.approvalCapabilityfromextensions/discord/src/channel.ts. Runs used pristine main 512cc70 (no changes toextensions/discord/src,src/plugin-sdk, orsrc/auto-reply/command-auth.tsbetween it and current main 49563b5) and this branch at 09ef7b5, with identical inputs. Config:commands.ownerAllowFrom: ["discord:user:100000000000000001"],channels.discord.allowFrom: ["*"],channels.discord.execApprovals.enabled: "auto",groupPolicy: "open".Exact steps or command run after this patch:
ROOT=$PWD node --import tsx drive.mtsfrom the repository root, once on pristine main and once on this branch. The driver builds the provider interaction surface and Client as above, callsclient.handleInteraction(<raw /vc status interaction from user 100000000000000001 in a guild text channel>), prints the content of the outgoing interaction response, then printsapprovalCapability.getExecInitiatingSurfaceState,delivery.hasConfiguredDmRoute, andauthorizeActorAction({ senderId: owner, approvalKind: "exec" }).authorized.Evidence after fix:
Observed result after fix: The configured
discord:user:owner now gets the real/vc statusanswer instead of the authorization refusal, and Discord native exec approvals become enabled with that owner as an authorized approver. Nothing else in the run changed.What was not tested: No live Discord bot token or real Discord API. Voice audio capture and an actual approval DM delivery were not exercised, and the full gateway process was not booted.
Maintainer proof (release lane 2026.10.5)
Added
extensions/discord/src/approval-native.test.ts› "lets only the current typed Discord owner approve owner-derived exec requests". It drives the shippedgetDiscordApprovalCapability(), the same capability Gateway approval custody (src/gateway/approval-channel-custody.ts) calls throughauthorizeActorActionbefore it settles a decision. Withcommands.ownerAllowFrom: ["discord:user:555555555"]andexecApprovals.enabled: "auto":[{ to: "555555555" }](the owner receives the approval);666666666) is rejected;execApprovals.approvers, the global owner is rejected (account binding unchanged);discord:user:888888888), the former owner is rejected. Authority is evaluated against the current config at decision time; custody additionally refuses a decision prepared under a superseded config (configCurrent, unchanged core).Fail-before/pass-after on current main
01cf74e6469+ this PR (pnpm test <4 files> --maxWorkers=1):expected [] to deeply equal [{ to: '555555555' }]), exec-approvals typed owner,/vccommand typed owner, voice speaker typed owner.approval-native,exec-approvals,voice/command,voice/speaker-context); shard wall ~99s including worker compile. New test adds no timers or I/O.Gateway settlement proof (production-path authority harness)
Uncommitted maintainer harness (core tests may not import bundled plugins, so it is not part of this diff). It loads the shipped
discordPluginandslackPlugininto the active plugin registry and drives the realapproval.resolveGateway handler (createApprovalHandlers) with real durable exec approval managers and the real, unmockedprepareApprovalChannelCustody. Each decision carries a channel reviewer{ channel, accountId, senderId }; the runtime config is read throughcontext.getRuntimeConfig()at decision time. Config:commands.ownerAllowFrom: ["<channel>:user:<owner>"],execApprovals.enabled: "auto", plus anopsaccount with explicitexecApprovals.approvers. Command:pnpm test src/gateway/server-methods/zz-typed-owner-custody.proof.test.ts --maxWorkers=1on main01cf74e6469with both fixes applied, then with both selectors restored to main.The typed owner settles a pending exec approval to
allowed(the waiter resolvesallow-once). An unlisted sender, the owner on a request bound to theopsaccount (whether reviewing viaopsor viadefault), and the former owner after the owner list is reassigned while the approval is pending are all refused before settlement; their records staypending. Voice:voice/command.test.tsdrives/vcthrough the command handler and asserts the voice manager is invoked for the typed owner (fails on main), and rejects wildcard/foreign owners.Voice privileged-effect proof
Added
extensions/discord/src/voice/command.test.ts› "runs vc leave only for the current typed owner". It drives the shipped/vc leavesubcommand with the realcreateDiscordLivePolicyReaderreading a mutable runtime config (the same live-policy owner the provider wires at boot). Withcommands.ownerAllowFrom: ["discord:user:<owner>"]: an unlisted member is refused andmanager.leaveis never called; the typed owner's/vc leavereachesmanager.leaveonce; after the owner list is reassigned in config, the former owner is refused on the next interaction andmanager.leaveis not called again. On main's selector the owner case fails (expected { content: "You are not authorized…" } to match { content: "Left voice." }).Branch integration: merged current
origin/mainbecause this test's import was adjacent to a main-side import removal in the same file (textual conflict). Result on maincf7311c1048+ this PR:approval-native,exec-approvals,voice/command,voice/speaker-context43/43 passed (pnpm test <4 files> --maxWorkers=1, ~121s shard wall including worker compile).Not run: a live Discord bot/voice session and a real approval DM click; the remaining live-surface proof is limited to the contributor's real-
Clientinteraction trace above plus the Gateway custody harness.