feat(gateway): enforce allowed_channel_ids on outbound emit (with DM exemption)#1884
Open
kgabryje wants to merge 1 commit into
Open
feat(gateway): enforce allowed_channel_ids on outbound emit (with DM exemption)#1884kgabryje wants to merge 1 commit into
kgabryje wants to merge 1 commit into
Conversation
…exemption) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
mistercrunch
approved these changes
Jul 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
agor_gateway_emit_message(proactive outbound Slack) now honors the gateway channel'sallowed_channel_idswhitelist. #1851 enforced the allowlist on the reaction/file-upload write tools but left the emit path unconstrained — this extends the same policy to emit, reusing the sameisSlackWriteTargetAllowedhelper so the semantics (including the DM exemption) stay identical.How
The nuance: emit's
targetis not always a channel id — it can be a channel name (resolved viaconversations.list) or a user email (resolved to a DM viausers.lookupByEmail+conversations.open), while the allowlist operates on concrete conversation ids. So enforcement happens inGatewayService.emitMessageafter target resolution, right beforesendSlackMessage:allowed_channel_ids; denied with an error naming the target and the resolved conversation id if not listed.D-prefixed targets → always allowed (isSlackWriteTargetAllowedDM-exempts, matching feat(gateway): capability-gated outbound Slack — reactions, file upload, thread replies #1851 and the inbound listening whitelist).Denials happen before any Slack send and before the outbound audit row is written.
Tests
New
gateway.test.tsblock covering: channel-id target outside the allowlist → denied; channel-name target resolving to a non-allowlisted id → denied (the resolution-order crux); email→DM target → allowed despite an allowlist; allowlisted channel → allowed; no allowlist → any target allowed.🤖 Generated with Claude Code