Repository navigation
feat(chat): channel-bound chat triggers; share a Slack workspace or Teams tenant among companies - #537
Merged
artempartos merged 10 commits intoOct 22, 2026
Conversation
One Slack workspace or Microsoft 365 tenant serving several companies as peers, with no company owning it. A chat trigger listens in exactly one channel, and a channel reaches a company only when someone in it posts a one-time code there — a typed channel id is never trusted, because channel ids are not secret. Records the agreed decisions, the gaps the review found and the phasing (#199). Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Artem Petrov <[email protected]>
A chat trigger used to take any channel id, or none, in its conditions, and agent tools posted to any channel id the bot could reach. Channel ids are not secret, so neither boundary held. Now a channel is connected to a company only by redeeming a one-time code inside it (`@<bot> connect <code>`), answered publicly by the bot. An enabled chat trigger must listen in exactly one connected channel; routing keys in its conditions are refused; chat_* tools reach only connected channels and the thread a run came from. Template export/install, archive restore, project move and removing an install no longer carry or keep a channel the company has not connected. The migration connects the channels each company already uses and splits a channel-less trigger that fired from several channels into one per channel, reading everything from the database. A copy of the channel stays in filter_predicate so the previous release keeps matching during the rolling deploy. Phase 1 of docs/design/shared-chat-workspaces.md (#199). Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Artem Petrov <[email protected]>
A workspace used to belong to exactly one company, so a second company connecting the same Slack workspace or Microsoft 365 organization was refused. Now companies connect it as peers: chat_workspaces is the shared thing, each company's install links to it, and the channel registry lives under it, so one company's disconnect leaves the others' channels and triggers alone. A message is routed by Chat::WorkspaceRouter: connect codes, help, commands and private messages are answered once, then each company with a matching trigger on that channel gets an event of its own (dedup per company), so a message is stored only in the companies it reached. Self-service /run spans the person's companies on the workspace, agents change only the bot messages posted for their company in a shared channel (chat_messages), and Slack's rate limit reaches agents as rate_limited with retry_after. Also: a link to the bot's confirmation on the Channels list, the trigger form keeps sender conditions it does not show, the builder's Triggers tab shows a refused switch, and Teams channel messages use the registry's channel key. Phase 2 of docs/design/shared-chat-workspaces.md (#199). Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Artem Petrov <[email protected]>
…rs-without-channels-audit * origin/develop: feat(feature-flags): admin pages, writes and audit (3/7) (#536) # Conflicts: # CHANGELOG.md
From the design review (decisions 21-23 in docs/design/shared-chat-workspaces.md): - A code is issued for one named channel (Slack "#deploys"; Teams "Team / Channel" or a group chat's name). Posted in any other channel it connects nothing and stays good for its own, so a code left in a channel the bot is not in cannot be carried elsewhere. - The bot's public confirmation and help name the company and the command, never the person who asked or the project: a channel may hold guests and other organizations. - A refused code is answered only to whoever posted it (Slack ephemeral; Teams at most once a minute per person), and codes are stored as an HMAC keyed with a server secret instead of a plain SHA-256. The connect dialog now asks for the channel before it asks for a code. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Artem Petrov <[email protected]>
…rs-without-channels-audit #544 took migration version 20261022120000, so the chat workspace migrations move to 20261022121000/121100 (order unchanged, nothing has run them outside dev). The fully wired user scenario gains rows behind the two new requested_by foreign keys, which already nullify. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Artem Petrov <[email protected]>
…s Slack does The channels list sat inside the integrations table as an extra row; it now opens from a Channels button on the messenger's row. Slack completes a mention only from the bot's display name, while auth.test returns the username, so the connect instructions named a bot nobody could mention. users:read lets users.info give the display name, and the name of whoever posted a connect code, which replaces the raw Slack user id shown as "posted by". Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Artem Petrov <[email protected]>
The channels list no longer loads on the page; it waits for its dialog. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Artem Petrov <[email protected]>
artempartos
marked this pull request as ready for review
October 22, 2026 17:22
This was referenced Oct 23, 2026
Merged
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.
Implements docs/design/shared-chat-workspaces.md (board task #199), both phases:
Why
A Slack or Teams chat trigger took any channel id in its conditions, or none, and the
chat_*tools posted to any channel id the bot could reach. Channel ids are not secret: public channel ids are visible to every workspace member, and ids travel in links and mentions. So neither was a boundary. A workspace also belonged to exactly one company, so tenants could not share one.Phase 1 — a channel per trigger, connected by code
aixle-XXXXXXXX: single use, 10 minutes, at most 10 open per company). It can be asked for from the trigger form, the Slack/Teams row on Integrations, the API or MCP.@<bot> connect <code>. The bot connects that channel and answers publicly in the thread; the Channels list links to that answer.trigger_bindings.chat_conversation_id, validated in the model: an enabled chat trigger needs a channel of its own messenger connected to its company. Conditions may not name a place (channel,conversation.*,workspace.*, …).chat_channel_idon triggers;GET/DELETE /api/v1/projects/:id/chat_channels,POST/GET /api/v1/projects/:id/chat_connect_codes; MCPlist_chat_channels,create_chat_connect_code,get_chat_connect_code.auth.test.channels:read/groups:readare requested for channel names, andchannel_rename/group_renamekeep them current./run,/statusandhelpstill answer there.Phase 2 — one workspace, many companies
chat_workspaces. Each company's install links to it, and the channel registry lives under it. One company's disconnect leaves the others' channels, triggers and endpoint alone. Uninstalling the app in Slack stops it for every company; reinstalling from any of them restores it for all.Chat::WorkspaceRouter.slack:<event_id>key would have dropped the second company's copy./run, the shortcut and/statusspan the person's companies on the workspace. Account linking accepts a member of any of them, and the link page names only the person's own companies.chat_messages. In a channel two companies share, an agent edits or deletes only the bot messages posted for its company.Slack::Client::RateLimitedreaches agents asrate_limitedwithretry_after.Migrations and rollout
20261022100000/20261022120000add the tables and columns.20261022100100connects the channels each company already uses and gives every chat trigger exactly one channel.20261022120100links every Slack/Teams install, its channels and its endpoint to a workspace.filter_predicate["channel"], so the previous release keeps matching correctly during the rolling deploy. API and MCP never show it. Removing it is a later contract step.channels:read,groups:readto the Slack app and to an explicitSLACK_SCOPES;channel_renameandgroup_rename;commands. Until then channels show their id instead of their name; nothing else depends on it.Verification
bin/rails testpassed (8727 runs, 0 failures). rubocop and brakeman are clean.tsc,eslintandsteigerare clean. vitest passed for the triggers, integrations, chat-channels, workflows and integrations-pages folders.@botmention in Slack). The connect dialog already tells people to pick the bot from the list.Notes for review:
app/frontend/shared/routes.tswas regenerated withRAILS_ENV=test. Besides the four new helpers it picks up existing drift (adminCompanyInvitations*,gitlabOauth*, …) from routes added earlier without regenerating.🤖 Generated with Claude Code