Repository navigation
feat(slack): code-channel agent tools, commands and wrap-up - #21429
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS No design blocker: the channel comes from who calls, not from an argument; the patch removes nothing that readers depend on; and nothing under Notes
[DESIGN-REVIEWED] 349ce1c Description read[DESCRIPTION-READ] 989432fa6774c2525797562fc6d091648c54f824b2c4b5c0887ba998c9beb464 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 Every item sits behind Notes
What this change shipsInventory (10 items) — 9 justifiedIntent: let a Slack code channel's agent publish its work, keep the channel current, and let people finish and archive the channel from Slack. ADDITION.
[FIRST-PRINCIPLES-REVIEWED] 349ce1c Description read[DESCRIPTION-READ] f63bcdf1b76748d7d09afe2845017e8501ff2aca6eafb4beef36bd21394c67ed That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Review detailsNo findings. Notes:
[OPUS-REVIEWED] 349ce1c 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: |
cc54755 to
84f04ad
Compare
|
Dispositions for the review of Opus 5.5
GPT 6.1
|
84f04ad to
d48919d
Compare
|
Dispositions for the review of
|
d48919d to
a5ed55a
Compare
|
Dispositions for the review of
|
Sensitive Change ReviewSensitive files changed:
|
c7a1b15 to
517b6bd
Compare
Security Scope Review -- 🟡 CONCERNSWhich legitimate operations does Verdict basis: the reviewer's own judgement; no confirmed regression. Security scope review -- adjudicated candidates
No candidate flipped from allowed to refused. Scope-Verdict: CONCERNS TIGHTENING: a crew home leaf, ADJUDICATED: 13 candidates, 0 confirmed newly-refused PLATFORM COVERAGE: The diff hard-codes one leaf filename under each
I wrote no UNC-path or UNADJUDICATED:
[SCOPE-REVIEWED] 90250b1 |
a5ed55a to
691f9cb
Compare
b0953b3 to
98c0ea4
Compare
98c0ea4 to
eb5d873
Compare
90250b1 to
98c623d
Compare
iamwhatever
left a comment
There was a problem hiding this comment.
REQUEST_CHANGES at fd858de.
One defect on the archive failure path:
- In wrapup.py#L493-L504, the channel is fenced before
_stamp_archived. If both stamp attempts fail, the fence stays up for the life of the process. A later click then stops atis_archived(L446-L451) and answers already archived, soarchived_atis never written and the worktree is never cleaned. The dashboard notice (L369-L383) says Slack's archive event will record it, but nothing insrc/kiro_crew/slackhandles that event at this head. This is the Opus lane's current-head finding, and it has no reply yet. - Smallest fix: when a click finds the channel fenced but
archived_atunset, retry the stamp and cleanup. Or remove the retry and archive-event promises from the comment and the notice, and tell the operator what to do by hand.
Also open:
- First Principles item 8 (a third per-channel store) needs the stack owner's ruling. If it is deferred, link a tracking issue in the description.
- First Principles item 10 (the
code_channels_togglefallback that never runs) has no reply. - Sensitive Change Review is red until the author posts its reasoning template for
security_posture.py.
Even after these are fixed, this PR goes to a human reviewer. It adds a STRICT route that trusts an attested session key, changes the redaction registry in security_posture.py, and deletes worktrees and branches on Archive. It also targets feat/slack-code-channels-workspace, not main, so it needs a fresh review once it is retargeted.
— crew-pr-reviewer (r116)
iamwhatever
left a comment
There was a problem hiding this comment.
Request changes at 66687b7.
The archive-fence defect from r116 is fixed: a click on a channel that is fenced but not recorded now starts the recovery (
KiroCrew/src/kiro_crew/slack/code_channels/wrapup.py
Lines 745 to 754 in 66687b7
- Plan canvas (Opus). When the first create times out or the socket resets after Slack made the canvas,
_publish_canvas_lockedre-raises without recording anything (). The next call creates again, getsKiroCrew/src/kiro_crew/slack/code_channels/tools.py
Lines 446 to 469 in 66687b7
channel_canvas_already_exists, and refuses for good with "a canvas that Kiro Crew did not create". Smallest fix: on amaybe_appliedcreate error, remember that a create may have landed for the channel; when a later create answerschannel_canvas_already_existswith that record present, read the channel's canvas id and adopt it. - Worktree removal (GPT, upheld by adjudication). For sessions filed under the channel's folder,
_turn_runningreturns the folder scan's cached answer (). It is checked before the awaited setters, andKiroCrew/src/kiro_crew/slack/code_channels/cleanup.py
Lines 262 to 267 in 66687b7
git worktree removere-checks nothing ( ). A worker that starts a turn in that window keeps running in a deleted directory, and its output can be lost. Smallest fix: read each affected slot's liveturn_runningjust before removal, and keep the tree if any is busy.
The GPT Stop finding was downgraded by its adjudicator and First Principles item 9 (15 commit-point policy re-checks) is a simplification note; neither blocks by itself, but please reply to each.
Even with these fixed, this PR goes to a human reviewer. It adds a strict route that trusts an attested session key, changes security_posture.py and security_posture_sinks_delivery.py (Sensitive Change Review needs the template for this head), and deletes worktrees and branches on Archive. It also targets feat/slack-code-worktree-diff, not main, so it needs a fresh review after it is retargeted.
— crew-pr-reviewer (r143)
|
@iamwhatever, replies to crew-pr-reviewer r143 (on 66687b7). The review has no inline threads, so all five points are answered here. Everything is checked on head b7abba1, based on main 759bb96 (#28305 has merged). The fixes are in that head's second commit,
Could you re-review at b7abba1? |
|
@iamwhatever, re-review ask at b7abba1. Your change request at 66687b7 named two defects. kyleseaman answered all five points on 11-03 against this head, and the code on b7abba1 looks like it addresses both:
Could you re-review this head, and clear your change request if you agree? Separately, the Sensitive Change Review check on this head still needs the author's reasoning template. |
|
Rebased onto main as |
|
@kyleseaman @bolichen97 status at
Opus 5.5 Review failed on infra (no discovery marker); I will rerun it. Sensitive Change Review needs the template again naming the new head |
A session bound to a Slack code channel gets code_channel_* MCP tools (views, plan canvas, its own context-bar items, rename, status, wrap-up) that act only on its own channel: the channel is derived from the transport-attested calling session through the strict route POST /api/slack/code-channel/tool, never from an argument. The channel offers /summarize, /wrap-up and, when the session can open a pull request, /create-pr (agents.conversations.setCommands over Socket Mode, redeliveries deduplicated). The wrap-up posts a summary with an Archive button; a click authorized against the origin conversation archives with summary_message_ts and releases the worktree, which is kept when it holds uncommitted work. Every decision is SEL-audited, and with slack.code_channels off (or the install unable to run it) nothing here runs.
…canvas creates, idle-at-removal, shown-text screen Every code-channel handler re-checks the per-channel allowed_channel_ids refusal after its awaits, right before each side effect (surface.policy_gated_handlers() is the audit list); the slash entry gate pairs channel_inbound_permitted with channel_refusal. A plan-canvas create whose answer was lost is remembered, and on the next already-exists the channel canvas is adopted only when files.info names our bot as its creator, no earlier than that create began. The Archive cleanup keeps the worktree when a session started a turn, or joined the folder, while the sessions were being moved. A view is screened on the text Slack shows: a credential split across Block Kit elements or HTML spans, or a label held apart from its value, refuses it, through the dashboard cards' own screen (card_lifecycle.readings_hide_secret, lifted from _hides_secret); Block Kit link destinations are no longer mention-defanged.
Sensitive change reviewDrafted for the human reviewer to check and post; the agent does not post this as a comment.
|
Problem / Motivation
Goal: In a Slack code channel, the bound Kiro Crew agent can publish views and a plan canvas, keep the context bar and the channel's name and status current, and wrap the work up, acting only on its own channel. The people in the channel get
/summarize,/wrap-upand (when possible)/create-pr, plus an Archive button that archives the channel with its summary and cleans the worktree.The parent PRs open a code channel, bind it to a dashboard session, and give it a worktree, a diff tab and a repo/branch/PR/CI context bar. Without this PR, the agent in that channel can only chat. It cannot show a report or a plan as a tab, tell the channel it is waiting on someone, or retitle the channel when the work changes direction. The people in the channel have no commands and no way to close the channel out. The owner asked for exactly this surface, quoted here from the brief: "MCP tools for the bound agent, PINNED SERVER-SIDE to the calling session's own channel … set_view (html / block_kit / canvas), publish_plan_canvas, set_context_bar (merge with B's repo/branch/PR/CI items, <=5 unique keys), rename, set_status", "/summarize (always), /wrap-up (always), /create-pr ONLY when the bound agent can actually open PRs", and "Wrap-up: post a summary message … with an Archive button; on click … archive with summary_message_ts, then call B's worktree cleanup".
Why it matters
Slack's code-channel lifecycle guidance expects all of this from the channel's agent:
rename"if the session's focus changes", so the channel list stops naming work that has moved on;suspendedwhen the agent asked a question and needs the answer;Without it, a code channel runs in Slack but cannot be finished from Slack: someone has to archive it by hand and clean up the worktree on disk. And an agent tool that could address any channel would let one session write into another team's channel. That is why the tools are pinned to the caller's own channel server-side.
Not a goal
/run-testscommand. The owner's brief names/summarize,/wrap-upand/create-pr; tests are a prompt away.code_channel_actionclick event, but its reference page 404s, its payload is undocumented and the manifest does not subscribe to it. The tool refusesitem_typeand suggests a link item.Binding.wrapped_up_at/archived_at, which this PR stamps.What changed (motivation → approach → change)
Pinning. The tools must not be able to name a channel, so the channel is derived from WHO calls, never from an argument.
mcp_tools/code_channels.pyresolves the caller throughrequire_strict_session_key. It never uses the/procwalk, so a sub-agent cannot resolve to its parent. It forwards to a new STRICT route,POST /api/slack/code-channel/tool(dashboard/handlers/slack_code_channel_tools.py).X-Session-Key(session_key_is_attested).slack/code_channels/tools.pymaps the key to its dashboard slot (caller_slot_key). It takes the binding whosesession_keyis that slot AND whose Slack link still resolves to that slot, in that channel. A replaced session therefore loses its channel.channel,channel_id,team_id(and the like) are refused before anything else. The only canvas tab is the channel's own plan canvas, attached bycode_channel_publish_plan_canvas(comment-only).channelsoutbound ceiling.slack.code_channel.toolSEL row.Tools.
code_channel_set_view: html with no CSP resource domains; Block Kit through a display-only allowlist with noaction_id, accessories or remote media. The diff stays the workspace's and the Plan tab comes with the plan canvas.code_channel_publish_plan_canvas:channel_canvas_already_existsis never retried, and a canvas this gateway did not create is never written.code_channel_set_context_bar: the agent's items ride after the workspace's inWorkspaceService._publish_bar(five in all, the workspace's keys reserved), so the bar keeps one publisher. The workspace takes at most four slots, so at least one is the agent's, and more when there is no PR or no repository.code_channel_rename:agents.sessions.rename.code_channel_set_status:suspendedholds through the turn end.code_channel_wrap_up.security.redact: exfiltration URLs and credentials), a context-bar link that redaction would change is refused, and@channel/@here/ user-group pings are neutralized.routing/slack-code-channel-surface.json, beside the core'srouting/slack-code-channels.json: theroutingdirectory is already fenced as a whole (agent file tools refuse it on the read and write floors, every sandbox masks it, it is pre-created), so this PR adds no entry tosandbox_leaves,sandbox_precreateorsecurity/paths*.slack.code_channelsis on.Commands.
commands.pyregisters the command set withagents.conversations.setCommandsat turn start, off the turn's path, and only when the set changed./create-pris included only when the channel has a worktree, a GitHub remote this install may reach, andghsigned in for that host. Socket Mode delivers invocations toevents._handle_slash, which askscommands.handle_slashfirst. A repeatedtrigger_idis dropped (the gateway'sSeenCache). Thechannelsinbound ceiling applies before any side effect. Then the sender is authorized like a message in the channel: an allowed user, and an origin that still admits the bot. Each command becomes a prompt delivered throughrouting.deliver_directed, and a/wrap-upthat never reached the session is disarmed.Wrap-up and archive (
wrapup.py).The wrap-up posts the agent's summary, the facts the gateway knows (branch, PR, CI, changes, uncommitted work) and an Archive channel button. It is recorded as
summary_messageand stampsBinding.wrapped_up_at. An older wrap-up's button goes stale; its message is not edited. If the/wrap-upturn ends without the tool call, the facts alone are posted.A click (
interactions.dispatch→handle_archive_click) is authorized like a message (allowed user, and both the origin and the code channel itself admit the bot:channel_and_origin_permit, as on the message path) and must be the current session's current wrap-up. Under a per-channel lock the code:retires the button;
calls
agents.conversations.archive(summary_message_ts);fences the channel in-process at once, then stamps
Binding.archived_at(retried once); if the stamp cannot be written, nothing is cleaned up and the dashboard is told;runs this PR's
cleanup.release_channel_workspace. The workspace PR no longer ships a cleanup, so this PR owns it. It runs under the workspace's channel lock with no bind in flight (WorkspaceService.channel_quiet), and checks before it removes anything:git_ops.is_channel_worktree(a channel-derived branch whose registered worktree is the recorded one), the sealed binding's repository (or, when the binding names no project, the one its bind resolved), and no sensitive path. The record is read once, under the service's own store lock, and that same snapshot is acted on;git worktree remove;A kept tree is reported to the dashboard.
An archived channel's turns fire no hooks afterwards (
binding.notify_turn_start).A second click archives nothing.
Minimal hunks in the parents' files:
client.pyis unchanged: the surface's ownagents.*writes live insurface_client.SurfaceClient, a subclass of the core's client that inherits its validation,okcheck, no-retry and latch rules.status.py:hold_after_turn.hooks.py:on_turn_start(..., first=True), so the wrap-up's turn counter observes a start before any other hook awaits.__init__.py:surface.install.workspace/service.py: the merge in_publish_bar(off the loop), plusrepublish_barandchannel_quiet.binding.py:notify_turn_startskips an archived channel.routing.py:_dispatch_directedsplit into a delivery-reportingdeliver_directed(unchanged for existing callers).events_slash.py(where the base moved_handle_slash) /interactions.py: one pass-through seam each.Registration (
mcp_tools/__init__.py,REFLEXIVE_TOOL_MODULES, tool titles, strict path, deferred route).security_posture.py(cross-owned, additive only): a_REDACTION_SINKSrow "Slack code-channel posts" forslack/code_channels/wrapup.py, whose_redact(the dual-passredact()plus a ping defang) every surface post goes through, and aNON_EGRESS_REDACTION_MODULESentry forslack/code_channels/tools.py, which posts only through that redactor. No other entry moved;test_every_redactor_call_site_is_a_registered_sink_or_allowlistedpasses on this head.Docs:
slack-gateway.md§ Code-channel agent surface, and a feature-map row.Sensitive change review
Drafted for the human reviewer to check and post; the agent does not post this as a comment.
main...head):src/kiro_crew/security_posture_sinks_delivery.py+7 / -0 (the "Slack code-channel posts" sink row, right before "Slack cron / notification posts") andsrc/kiro_crew/security_posture.py+5 / -0 (theNON_EGRESS_REDACTION_MODULESentry incl. its required reason comment). These are the same 12 lines, byte for byte, as the earlier single-file hunk; the base split the sink table intosecurity_posture_sinks_delivery.py, so the sink row moved there. No other file matchesSENSITIVE_GLOBS;security/paths*.py,sandbox_leaves.py,sandbox_precreate.pyare untouched.slack/code_channels/wrapup.pyregistered as the "Slack code-channel posts" redaction sink, andslack/code_channels/tools.pyallowlisted as a non-egress redactor caller.test_every_redactor_call_site_is_a_registered_sink_or_allowlistedrefused both new modules; after, the panel countswrapup.py's posts as a redacted output boundary andtools.pyis recorded as posting only through it. Nothing is newly allowed or blocked at runtime. The surface record lives in the existing protectedrouting/directory, so no new protection entry was added.tools.pygets an egress path later that skips the shared redactor and the allowlist hides it from the omission test. No redaction is removed by these rows; they only describe calls the code already makes.slack/code_channels/wrapup.py, thenslack/code_channels/tools.py); with both rows in, every test intest/test_security_posture.pypasses. A fresh-context review confirmed the relocated record keeps at least its old file-tool and sandbox protection under both data-home prefixes and aKIROCREW_HOMEoverride.slack.code_channelsoff neither module runs.test/test_security_posture.pyandtest/test_security_posture_facade.pyplus the focused code-channel suites, flake8, isort and mypy, all on 349ce1c.src/kiro_crew/security_posture_sinks_delivery.pyand the allowlist entry fromsrc/kiro_crew/security_posture.py(the omission test will then name both modules until they are re-classified).Backwards compatibility
Compatible: everything is new and behind
slack.code_channels. With the toggle off, or the install unable to run code channels, the tools are not listed and refuse, the slash and button seams return "not mine" so the existing handlers run unchanged, and no hook fires.Removes nothing: the diff only adds tools, a route, a store file and pass-through seams; no existing key, record, path or validator is removed or tightened.
Tests
test/test_slack_code_channel_agent_surface.py(91 tests; recorded Slack payloads and fakes, real git for the worktree cleanup). It covers the nearby inputs:not_bound; the refusal is audited and nothing reaches Slack.channel,channel_id,team_id) is refused before Slack, as is a foreigncanvas_id. Two bound sessions each reach only their own channel, and a replaced session loses its channel./summarize,/wrap-upand/create-prwhile its origin stays active./create-pron a non-git project explains instead of running, and the command set offers/create-pronly when possible.feature_disabled/missing_scopedegrade, andfeature_disabledlatches the feature off.channelspolicy denying Slack inbound refuses a command; denying outbound refuses tools, wrap-up and archive.cardcontainer), and group pings are neutralized.suspendedoutlasts the turn..bak, a lookalike name or the same basename in a project; a pre-created{}reads as no records and the gateway's first write replaces it./wrap-upposts no fallback; exfiltration URLs in views are redacted and such links are refused on the bar; wrap-up facts (branch, git output), view keys, bar keys and Block Kit keys pass the same redaction; a forged workspace record (base at the tip of unpushed commits, a foreign worktree, a foreign branch) never drives the cleanup.Manual verification
There is no live pilot workspace, so the Slack side is verified only against fakes and recorded payloads. A fresh-context adversarial review of the diff attempted to break the channel pinning and found no cross-channel path. Its state findings are fixed with regression tests above: plan-canvas adoption, a binding lost-update, unguarded archive bookkeeping, wrap-up racing the archive, a replaced session's old button, the Block Kit denylist and group pings.
Local gates run against this PR's base: flake8, mypy, black (diff-scoped), subprocess-encoding, comment-history, sync-io-in-async, file-line-cap, brand, harness-parity, feature-map, loop-bound-locks, docs-lint, and the related suites.
Related Issues
Part of #15175
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributed under the project's Apache-2.0 license.