Repository navigation
feat(slack): start code-channel sessions in a configured approval mode - #21997
iamwhatever merged 2 commits into
Conversation
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: every mode change goes through the dashboard's own [DESIGN-REVIEWED] c73628e Description read[DESCRIPTION-READ] 56b53f8a042534a24ebb27b17272382ebacf9eeaf0d6c92fa14510554c6f6e3a That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. One mechanism goes past the frozen Notes
What this change shipsInventory (10 items) — 9 justifiedIntent: let a Slack code channel's session run in Normal, Reads or Trust, and answer its approvals from Slack, so it doesn't stall waiting on the dashboard. ADDITION.
[FIRST-PRINCIPLES-REVIEWED] c73628e Description read[DESCRIPTION-READ] 31db3f91c820c004f9ec114a9c6385b5bd506fe35f560c9e545e48fc215efdf1 That sha256 names the PR description this verdict read. Recompute it with |
UX Review (Opus 5.5) — ✅ PASSUX-level review of UX-Verdict: PASS Nothing blocks: the Approval mode pickers in Settings and the kickoff were both read correctly, and every added state appears in a screenshot. Notes
[UX-REVIEWED] c73628e Description read[DESCRIPTION-READ] c4477070402d98dc519dd41acadef1242e02934c1e211af9f614d6ccfc9a6091 That sha256 names everything this verdict read: the PR description, plus the 16 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
c9289e3 to
e6a8146
Compare
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
634fb3b to
ab21606
Compare
e6a8146 to
408d621
Compare
ab21606 to
8fb73a3
Compare
408d621 to
90250b1
Compare
8fb73a3 to
d4d41df
Compare
85e5f6e to
35c15a7
Compare
5cb23f3 to
932b57a
Compare
35c15a7 to
c0bce46
Compare
7cf60a1 to
7ddbc57
Compare
932b57a to
e4fb454
Compare
7ddbc57 to
09bfe4f
Compare
A code channel's session starts in the approval mode set on the Code channels card (Normal / Reads / Trust). The channel's owner can change it from the kickoff message's Approval mode menu, with /kirocrew trust ask|reads|all, or with "Trust this channel" on an approval card. Every change goes through apply_approval_mode, the same audited path as the dashboard picker, and ends a live YOLO grant on Ask. Approval cards for a code channel post top-level in the channel. Workers started by the channel's own session relay their approval cards into the channel; only the owner can answer them, and each click settles only that worker's waiting call. A mode change reaches the channel session's own running workers (raise and lower, capped at the channel's mode), and a raise to Trust approves their waiting prompts the way a mid-wait dashboard switch does. Person-only question cards are never answered automatically.
…utation A lowering reaches every session that inherited the channel's grant (a worker's workers, linked ones) and the reply names any it could not change. Each grant re-checks, right before it applies, that the channel is not archived here, the feature is on and the channel session is the one the caller authorized against. A cancelled change releases the cards it claimed. Worker cards keep the UNVERIFIED warning and post only where the channel's own prompt would. A literal code fence cannot end a code-channel card's code block, and a hand-edited command name is never echoed into the channel.
Stacked on #21991 (
feat/slack-code-channel-agent-select@454f15d89d). Two commits: the feature, and the pre-push review fixes. Full backend CI runs when this retargets to main after the parents merge.Guard fix (toggles-off check, row 7): the three code-channel approval test modules no longer read the dashboard turn's source (
test_source_pin_budgetallows them 0). They drive a real turn throughtest/turn_harness.pyrun_turn(helpertest/slack_code_channel_turns.py): the card posts top-level with Trust this channel only in a code channel; a Trust-rewritten card is kept; a worker's card is relayed and settles with how its prompt ended; a prompt born rejected is never relayed. Each was mutation-checked againstchat_turn/permission_prompt.py. The facade-import guards (test_nothing_but_the_facade_imports_an_owner,test_only_the_facade_imports_an_owner) now pass on this base.Inherited reds (verified failing identically on #21991 @
7ddbc57a75without this PR; this PR touches none of their files):test/test_dashboard_server_composition_contract_reach.py: the MCP route table and the dashboard / headless boot chain order (3 tests). This PR touches no server or route file. Still the only Python failures on454f15d89d.website/src/i18n/style/zhStyle.test.ts("thread" as 话题; no more than two 的): the base's zh-CNslackCode.agent_sessions_desc,agent_sessions_irreversibleandagent_sessions_permanentvalues. This PR's own zh-CN values pass it.test_config_refactor_contract.pybuilder count (27 vs 28) passes on this base.Problem / Motivation
Goal: A Slack code channel's session can start in a configured approval mode (Normal, Reads or Trust), and its approvals can be answered and its mode changed from the channel itself, so a channel driven from Slack does not stall on approval prompts nobody in the dashboard is there to answer. In scope:
/kirocrew trust ask|reads|all, and Trust this channel on an approval card;This deliberately reverses the earlier "Trust excluded in group channels" decision for code channels: Kyle approved all three modes (Normal, Reads, Trust) for a code channel, with the owner-only gate and the in-channel Trust warning.
A code channel is a dashboard session that people drive from Slack. Today that session always starts in Normal: every tool call waits for an approval click in the dashboard. Nobody is usually watching the dashboard while the channel is in use, so the agent stops at its first shell command and the channel goes quiet. The owner asked for a code-channel default approval mode, next to the existing folder / agent / model / effort defaults, applied when the channel's session is created.
Why it matters
Without it, the first build or test command in a code channel waits on an approval prompt that only someone at the dashboard can answer. Slack Code is meant to let a team run coding work from Slack. The workaround today is for someone to open each channel's session in the dashboard and flip it to Trust by hand, every time a channel opens.
Not a goal
What changed (motivation → approach → change)
A new default,
slack.code_channel_defaults.approval_mode, takesask(the default, stored as unset),trust_readsortrust. It resolves like model and effort: set here, otherwiseask. Anything else reads asask, the side that keeps asking.Settings. The Code channels card gets an Approval mode picker. It uses the labels of the session's own approval picker (Normal / Reads / Trust), so the mode reads the same on the session where it can be changed later. A new code channel runs with gains an Approvals row. Picking Trust shows an inline warning: anyone allowed to talk to the bot in the channel drives an agent whose tools run without asking, and sessions it starts inherit that.
PUT /api/slack/configaccepts the three values, storesaskas unset and refuses anything else. A value already stored is not re-checked on a save that does not touch it. The copy is in all 12 locales, in the informal register.Runtime. When
create_bound_sessionhas created and bound the channel's session, it puts the slot on the mode. This runs only after the binding is written, so a session that is retracted leaves no audit record behind. It goes through a new shared helper,dashboard/slot_approval_seed.seed_slot_approval. The helper writes what the dashboard picker's Reads / Trust writes:_trust/_trust_readson every slot sharing the session, the session's approval policy, and amode_change:<mode>SEL record. Here the record is attributed toslack:code_channel. Unlike a person's press (apply_approval_mode), it never touches the YOLO override, so creating a channel cannot end an operator's declared grant. It also never replaces trust the slot already holds. The crewmate thread seed (handlers/members._seed_member_approval) did the same thing inline, so it now calls the shared helper.askchanges nothing. Afterwards the session is an ordinary one: its own approval picker changes the mode.Hook point. Crew's script hooks (
AgentSpawn,UserPromptSubmit,PreToolUse,PostToolUse,Stop) fire once a turn is under way. They can add prompt context or decide one tool call, but they have no way to set a session's approval mode. The code-channel turn hooks (slack/code_channels/hooks.py) are internal. So there is no override point. The setup guide says so and tells the user how to keep one channel on Normal.RFC addition (for #21425's
rfc-slack-code-channels.md, §1 Resolution order): one row,approval mode | code_channel_defaults.approval_mode only; unset is ask. The API paragraph gains: an approval mode must beask,trust_readsortrust, withaskstored as unset. The runtime applies it throughseed_slot_approvalonce the session is bound, never touching the YOLO override.Docs:
docs/guides/slack-setup.mdgets an Approval mode for code channels section covering the three modes, the Trust warning, the audit record, the restart behaviour and the lack of a hook.src/kiro_crew/docs/slack-integration.md,docs/feature-map/README.mdandconfig-baseline.json(regenerated) are updated to match.config/sections_slack.py,config/section_builders.py,config/sections.pyslack/features.pyslack/code_channels/binding.py,dashboard/slot_approval_seed.py,dashboard/handlers/members_thread.py(+ themembers.pyfacade's type-checker list)dashboard/slack_code_settings.py,website/src/api/client/messaging.tspages/settings/SlackCodePanel.tsx,website/src/i18n/locales/(12 locales + regenerateden-XA.json)Approval cards in the channel, Trust this channel, worker approvals
Added after a live test of the stacked build: in a code channel nobody watches the dashboard, so its approval prompts have to be answerable where the conversation is.
Cards post in the channel. A code channel's own session used to post its "Tool approval requested" card as a thread reply under the kickoff, so it had to be found. It now posts top-level, the same place the agent's replies go. That rule (
code_channel_post_threadfor the card's thread,post_linked_approval(thread_ts: str | None)) now lives in #21410, below this PR; this PR adds only thechannel_trustcard and the worker relay on top of it. Ordinary linked threads keep threading.Trust this channel. The card keeps Approve (the one primary button) and Reject and adds a secondary Trust this channel. Only the owner can use it (anyone else gets an ephemeral refusal), under the gates every code-channel command applies: bound workspace, owner, channel and origin admit the bot, not archived. It puts the session on Trust through
apply_approval_mode, the dashboard picker's own audited mutation, whose sweep approves the waiting call; posts one warning line in the channel (tools run without asking, for its workers too, running ones included); and writes aslack.code_channel.approval_modeSEL row. There is no approval store of its own. Request ids are only unique per session, so nothing is resolved by id state-wide: the race where the session was already on Trust is answered withresolve_slot_approvalon the channel's slot, pinned to the future the card was posted for.A spent card changes nothing.
apply_approval_modegains an optionalstill_livepredicate, asked after its own override-deactivation await and before any trust flag or policy is written (no yield between); a prompt answered or expired in the meantime gets a 409 and no mode change. Existing callers omit it and are unchanged.Worker approvals are relayed. A conductor's workers run with at most the channel's mode, so on Normal a worker's prompt showed only in the dashboard. A prompt from a session the channel's current session created (
_created_by, resolved back to a live binding throughsurface.binding_for_slot) is now also posted top-level in the channel, headed Worker: <title> wants to run:. It shows the tool and its arguments through the usual outbound redaction, and nothing from the worker's transcript. A session that is not this channel's worker, a worker of a replaced channel session, a Slack-linked worker, an archived channel and the feature off are never relayed.resolve_slot_approval, pinned to the card's future, so the worker answers the backend exactly once._run_chat's own host-decline / cancel / stop flags)._run_chatstarts the relay as a task (no await between the approval future's registration and itstry/finally), andfinishre-raises the turn's own cancellation, stopping a relay that has not posted yet.Slack entities. Code-channel cards now mrkdwn-escape the footer and the tool arguments, so agent-authored text cannot ping the channel or break out of the code block. Every other card is unchanged.
Approval mode from the channel. The kickoff gains an owner-only Approval mode select (Normal / Reads / Trust, the dashboard's own names; the command words stay
ask/reads/all) below #21991's Agent for this channel, preselected with the session's mode, and/kirocrew trust ask|reads|alljoins/kirocrew agent(bare/kirocrew trustshows the mode; outside a code channel it is not a sub-command and falls to the help text). Both reuse #21991's pieces rather than copying them:agent_picker.authorize(now taking the caller's audit writer and refusal text),kickoff_blocks(now drawing the optional Approval select), and the/kirocrewsub-command parse, withagentandtrustsharing one branch incommands.handle_slash. A pick or command runsapproval_picker.set_channel_mode→apply_approval_mode; the kickoff is redrawn with who set the mode, and Trust posts the warning line. Refusals (non-owner, not the kickoff, unknown mode, wrong channel) change nothing and each writes aslack.code_channel.approval_moderow; the command rows keep their per-command denial reasons.apply_approval_mode, which ends the grant (as Normal does on the dashboard), and the reply says the grant is off. The select has no YOLO state, so while YOLO is on the kickoff carries a line saying tools run without asking.test_slack_code_channel_agent_picker.pyis updated to pin that.Tests:
test/test_slack_code_channel_approval_select.py(27): both pickers on the kickoff in order; the select starts on the session's mode; owner sets each mode from the select and the command; Normal back; refused picks and commands change nothing and are audited (including a non-owner pick refused by the dispatcher); bare, unknown and escaped words; outside a code channel and with the feature off it is not ours; Normal ends a live declared or ad-hoc YOLO grant when the slot already reads Normal; an unreadable override never reads as unchanged; the kickoff's YOLO line; the agent command's denial row unchanged. Each new gate was mutation-checked.Files:
slack/code_channels/approval_picker.pyandworker_approvals.py(new),slack/handler_runtime/approvals.py,slack/interactions.py(+6 lines on a baselined file: the routing lives inworker_approvals.dispatch_card_click),dashboard/chat_runner.py(imports) anddashboard/chat_turn/permission_prompt.py(the approval-card wiring, which the base moved there out of_run_chat; same statements, relocated),dashboard/chat_api/slot_approval.py, the pinned shapes intest_slack_handler_composition_contract.pyandtest_chat_handlers_composition_contract.py,docs/guides/slack-setup.md,docs/system-specs/modules/slack-gateway.md.Tests:
test/test_slack_code_channel_trust_from_slack.pyandtest/test_slack_code_channel_worker_approvals.py(49): a code-channel card has nothread_tsand an ordinary thread keeps one; one primary button; owner Trust approves the call, flips the mode and writes both audit rows; refusals change nothing (non-owner, origin off, another session's card, unknown card, policy denies); a same-id call in another session stays pending; a worker approval posts to the channel; owner approve / reject resolve it; a non-owner is refused; a stale card is refused; the card updates in place for dashboard approve / decline, timeout and host-ended; nothing but this channel's workers is relayed; a card spent during the policy check or insideapply_approval_mode's own await grants nothing; cancelling the turn during cleanup is not swallowed; tool arguments cannot leave the code fence. Each new gate was mutation-checked. 2010 related tests pass; the twotest_nothing_but_the_facade_imports_an_ownerreds fail identically ond4d41df95c.Card frames below are drawn from the exact Block Kit JSON the code emits, in a Slack-style page: a mock, not a Slack client capture.
Running workers follow the channel's mode
Found in Kyle's live test of build 5: with the channel on Trust, the conductor's existing worker still posted an approval card for a read-only git command, because a channel mode change reached only workers started afterwards.
approval_picker.set_channel_mode(the Trust button on either card, the kickoff select,/kirocrew trust) now also runsapply_approval_modeon each ofworker_approvals.live_workers: the relay's own_created_bylineage, direct children of the channel's current session only, never Slack-linked, nothing outside the channel. Raising and lowering both apply, and a worker the dashboard raised is lowered when the channel already sits on the lower mode. Each worker change writes the dashboard switch'smode_change:<mode>row plus aslack.code_channel.approval_moderow naming the worker (result=worker_set/worker_refused).apply_approval_modeastill_livepredicate asked right before the mutation: the exact worker object is still the registered slot under its key (not a replacement under a reused key), still the unlinked direct child of the channel's current session, and the mode is not above the channel's mode at that moment (a concurrent lowering wins). While no grant has committed yet (the channel already held the mode), the asking card's own fence rides on it, so a card spent mid-await grants nothing._run_chat's delete (approval_picker.keep_card), and a worker card claimed for the sweep whose prompt ended another way says how it ended. The card a click asked from is written once, by that click.ask_questioncards wait in_question_futures, which no sweep reads, so a person-only question is never answered. There is noanswers_onlyflag on this stack; that is what covers it.commandin its own code block, the other arguments as JSON only when there are any, and drops the tool title from the lock line only when it is justRunning: <command>. Any other title, anUNVERIFIED child requestwarning above all, stays. Decoded parts are redacted again (decoding can undo an escape the redactors could not read), and an input whose decoded parts carry control or format characters (bidi overrides, zero-width) is shown raw. Helpers:slack.format.command_and_rest/title_restates_command.Tests:
test/test_slack_code_channel_mode_reaches_workers.py(27): an existing worker inherits a raise and a lower, and Reads; a worker is lowered to a channel already on Normal; unrelated sessions (another creator, none, Slack-linked, a grandchild) are untouched; pending channel and worker cards resolve on a raise and say so, and the runner keeps the rewritten card; a lower answers nothing; a question card is never answered; Trust on a worker card raises the channel and every sibling; a replacement under the worker's key, a concurrent lowering and a card spent mid-grant all grant nothing; the command shows once, other arguments still show, an ordinary card is unchanged, decoded credentials are redacted, hidden characters show raw, warning titles stay; a clicked card is written once; a claimed card rejected meanwhile says so. One or more fails per item onf3322175e5, and each review fix's tests fail on the commit before it. Reviews: GPT (security) and Opus (UX) fresh-context lanes on9e6c5615e3; their findings are fixed in33384a3d68and7d2cbfadff, and the GPT re-check's two findings in5cb23f318d.Pre-push review fixes (second commit)
A fresh-context review of the whole diff before this push, aimed at stuck state, missing channel-policy checks and secret exposure, plus two re-checks, found 2 blocking and 12 advisory points. All are fixed in the second commit, except one documented limit:
Lowering reaches every inherited grant. A session starts with its creator's mode, so a worker's own workers and Slack-linked workers inherit the channel's Trust. A lowering now walks the whole
_created_bytree under the channel's current session (worker_approvals.descendants, auditeddepth=deeper) behind its own fence (_lowering_live: same object, still in the tree, still a lowering). A raise still reaches only the direct, unlinked workers. Known limit: a session whose creator already closed is orphaned from the tree and keeps its mode (documented in the guide).Fenced at the mutation. A raise re-checks, right before it applies, that the feature is on and the channel is not archived (the in-process fence and the stored stamp, so an archive that finished meanwhile counts), and that the channel session is the one the caller authorized against. Every Trust write counts as a raise, since it re-runs the sweep (
_raises). A lowering never waits on those checks. The worker card's Approve / Reject and Trust paths re-check after their awaits before answering by hand.Reported, not hidden. A worker the change could not lower is named in the reply, from
/kirocrew trustand (ephemerally) from the kickoff select.Cancellation. A cancelled change drops the cards it kept and releases the worker cards it claimed, so each card's own cleanup says how it ended.
Worker cards. The relayed card keeps the
UNVERIFIED child requestwarning. A new card posts only where the channel's own prompt would (mirror not paused, channel and origin admit the bot, no Slack Stop); a card already posted stays answerable.Card and copy safety. A literal
```in a tool's input is shown asˋˋˋso it cannot end the card's code block, and the slash-command name in replies and the Trust warning is the routed one, shown only when it matches[a-z0-9_-]{1,32}(elsekirocrew).Card rewrites say only what happened (CI review round on
62a5036a5a). Every rewrite of a channel card now sends replacement blocks (approval_picker.settled_blocks/write_card):chat.updatekeeps a message's buttons when no blocks are sent, so a text-only rewrite left live Approve / Trust / Reject buttons on a decided card. Only a card whose exact future (captured before any await) was still waiting at the grant's last fence and was approved after it says "Ran under Trust", and only those are kept from the runner's delete, added after the sweep with no yield in between. A card answered another way meanwhile (declined in the dashboard, its own Slack button, Stop) is deleted as usual, including when the grant then fails. The clicked card says it approved the call only when it did (ModeResult.trusted_cards). Worker cards follow the same rule: a claimed card the worker's own sweep did not answer says only what happened (worker_approvals.CLAIMED_ENDED), and one its own click answered keeps that click's line.The agent switch's hardening reaches the mode change (restack onto
454f15d89d). feat(slack): pick each code channel's agent #21991 hardened its agent switch against gates closing during its awaits and against stalling the loop on a restored session's transcript. The mode change now does the same: a raise re-runsagent_picker._still_admittedafter taking the channel lock andagent_picker._sync_gatesat each grant's commit (owner, workspace, channel and origin, Slack inbound, archive, feature), and every slot's window is loaded off the loop (agent_picker._load_window) before its grant; a slot whose window can't load changes nothing. A worker card's Approve or Trust re-runs the same gates afterauthorize. A lowering, and a Reject, are never held back by them.Tests:
test/test_slack_code_channel_approval_prepush.py(54). 45 of them fail on the commit before their fix; the other 9 pin protections that already held (a lowering never raises a deeper session, a raise is blocked on a closing channel, a clicked card declined mid-change is refused, a lowering lands after a gate closes, five_raisesrows).Premise (for the maintainer override)
First Principles blocked an earlier head because per-channel mode changes contradicted the old
## Not a goal("No per-channel override") and because the worker relay, live-worker propagation and top-level cards were outside the stated Goal. Kyle ruled (2026-10-23) to amend the Goal rather than split, and the Goal above now owns all of it:/kirocrew trustand Trust this channel are the Goal's per-channel mode changes, owner-only, throughapply_approval_mode(the dashboard picker's own audited mutation), with no approval store of their own;The override is the maintainer's to post; nothing here posts it.
Backwards compatibility
Compatible: the new key is optional and defaults to today's behaviour (
ask). An existing config without it, or with a value other than the three, keeps every new code channel asking. The crewmate seed's behaviour is unchanged;test/test_member_approval_default.pypasses as is.Removes nothing: the change adds one optional config key, one API field and one picker.
_seed_member_approvalkeeps its name, signature and outcome and only delegates its body.Tests
test/test_slack_code_channel_approval_mode.py:ask/ unset / junk read as unset, round-trip throughconfig.json;ask, an explicit mode carries intoSessionSpec;ask/ null / blank clear, other values refused, a stored hand-edited value does not block an unrelated save;create_bound_sessionon a fake dashboard state:trust/trust_readsset the slot flags, the session policy and exactly one SELmode_changerecord;askleaves the slot alone; a retracted session records nothing; the YOLO override is never touched. With the seed call removed, the runtime tests fail.website/src/test/SettingsSlackCodePanel.test.tsx: the draft and payload mapping (asksent as null, an unknown value read asask); picking Reads shows no warning; picking Trust shows the warning, updates the preview and savesapproval_mode: 'trust'; a saved Trust shows the warning on load.test/test_slack_code_settings.py: the GET defaults shape now includesapproval_mode.website/src/test/settingsCoverage.test.ts: the waiver count for the Code channels card's pickers goes from 3 to 4, with the reason updated.Manual verification
The Settings frames below were captured from the built SPA with canned API responses, in dark and light themes, after checking the default Normal state and the Trust warning and preview. The one-off capture script is not part of this PR. The Slack frames are drawn from the exact Block Kit JSON the code emits, in a Slack-style page: a mock, not a Slack client capture.
Screenshots / video
Code channels card, default (Normal, no warning) and Trust picked (warning, preview reads Trust · Set here):
Light theme
Related Issues
None: the owner asked for this change directly, and no tracking issue was opened.
Checklist