Repository navigation
feat(slack): after a code channel's Stop, nothing it stopped starts until a person writes - #38882
kyleseaman wants to merge 5 commits into
Conversation
Sensitive Change ReviewSensitive files changed:
How to clear this check:
Only the author's comment counts this way. A reviewer can instead |
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: the Stop hold is one synchronous decision, read in the same span as each effect it guards, and it follows the rule RFC §3 records. Notes
[DESIGN-REVIEWED] 53fda25 Description read[DESCRIPTION-READ] 42fe7d5a1c463aed97c7cab168b7bb9a4e592dec5904466acb85e35b26ea4fbf 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. The base RFC ( Notes
What this change shipsInventory (9 items) — 7 justifiedIntent: after pressing Stop in a Slack code channel, the owner wants nothing to start again until a person writes. This is an ADDITION (it builds the RFC's hold).
[FIRST-PRINCIPLES-REVIEWED] 53fda25 Description read[DESCRIPTION-READ] df5ed02d751aa4705f4dbfcc312774dcc0677818e301dfe8a18f99ba7a7f01a7 That sha256 names the PR description this verdict read. Recompute it with |
GPT 6.1 Review — 🔴 changes requested (blocking)GPT 6.1 found at least one blocking issue that must be resolved before merging This comment is updated in place on each push. BLOCKING -- src/kiro_crew/slack/code_channels/stop_hold.py:434 -- Fence lazy-window hold saves against slot replacement
[BLOCK-MERGE] 53fda25 Adjudication (Opus 5.5) — is blocking on each finding proportionate?The one finding was fenced, so there was nothing to rule on in the downgradable set. For F1 I kept the block in place (UPHOLD-FENCED) rather than flagging it for a human override. F1 (fenced): I confirmed the mechanism at False positive or not applicable? A repository writer can comment: |
Opus 5.5 Review — ✅ no blocking findingsReviewed Review detailsNo findings. None of the six candidates holds up against the code. [OPUS-REVIEWED] 53fda25 Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
Security Scope Review -- ✅ PASSWhich legitimate operations does Verdict basis: adjudicated, zero confirmed regressions. Security scope review -- adjudicated candidates
No candidate flipped from allowed to refused. Scope-Verdict: PASS Reason: The change adds a refusal outside the shell deny composite. After a Slack code channel's Stop, a turn, a queue drain and a script-hook spawn are all refused until a person writes. None of the three shell tiers is touched, so the 15 shell candidates can only show the composite is unchanged. The new refusals are an admission gate that nothing could classify, and they are named under UNADJUDICATED below. No regression is confirmed, and no gap could be shown with a call path. TIGHTENING: a hold after a code channel's Stop, at turn admission and at script-hook spawn ( ADJUDICATED: 15 candidates, 0 confirmed newly-refused PLATFORM COVERAGE: The rows cover posix and windows, with no UNADJUDICATED:
[SCOPE-REVIEWED] 53fda25 |
e472a38 to
4ab67cb
Compare
4ab67cb to
bb30a25
Compare
cc4735e to
ad078e9
Compare
ad078e9 to
dee3673
Compare
dee3673 to
0d49cff
Compare
0d49cff to
2c306bd
Compare
2c306bd to
6ba5919
Compare
…ntil a person writes
…istry's slot, and imports no ACP class
…time ask goes through stream_command
…arts a Stop-held session
6ba5919 to
53fda25
Compare
Problem / Motivation
Goal: after a Stop in a Slack code channel, nothing it stopped starts again on its own until a person writes.
Since the brake (#38243), Stop and
!stopin a code channel stop the channel's session, every helper agent the code-channel store records for it, and their sub-agents. But nothing is held afterwards. A message queued for a stopped helper, its AutoNudge or patrol, a helper's report waking the channel's session, or a send from that session can start them again seconds after the person pressed Stop.Why it matters
A brake that lets the work start again by itself is not a brake. The RFC amendment (#35935,
docs/request-for-change/rfc-slack-code-channels.md§3 "Stop", "What happens next") records the rule: nothing starts again on its own until a person sends a message, a message to one helper agent releases only that one, who is a person is read from the gateway's own record, and restart resume does not resume a turn a Stop ended.Not a goal
session_sendcarries no turn identity the gateway can prove, so that half needs its own design and comes in a later PR. Here a held helper is released only by a person's message to that helper (in its dashboard chat); the channel's session can start a new helper instead, and a helper born of a released session is not held.What changed (motivation → approach → change)
Goal → approach. An earlier version went red over six review rounds on one class: a hold decided before an await and acted on after it. So this version has exactly one decision,
stop_hold.decide(slot, stamp), which is synchronous and reads only the slot. Every path asks it in the same synchronous span as the effect it guards, and the dispatch gate asks it last with no await between it and the stream. No write carries a captured value. The first review round of this version found the same class in where a person's stamp came from (read late, after the request's awaits), and a later one found that a handler's own entry is still late: middleware awaits before it. So the press is now read where the request ARRIVES at the process (the outermost middleware, the Socket Mode listener) and passed down unchanged. The second found it in the relay from the channel's session to its helpers, which is left out (see Not a goal).What was built (
src/kiro_crew/slack/code_channels/stop_hold.py, new):The hold.
slot._stop_heldis persisted as the slot's own metadata-line fieldstop_held. The key is slot-owned: the full line writes it while held and omits it once released, and the empty-window merge writestrueorfalse.slot._stop_hold_seqis the press that set it, from one process-wide counter, so no clock is compared anywhere.The press.
stop_helpers.stop_channel(feat(slack): a code channel's Stop also stops its helper agents #38243's Stop afterrouting._stop_bound's fence) callsstop_hold.pressbefore its first await, right after feat(slack): a code channel's Stop also stops its helper agents #38243's read of whether the channel's session was running at the press; both stay in that first synchronous span (test_the_press_and_the_running_read_both_come_before_the_first_await). It holds the channel's session in memory, then reads its helpers from the store and holds them. The Stop writes the holds BEFORE the brake, so a crash during the brake keeps them. A session the Stop did not stop because it was compacting (the channel's own or a helper) has its hold undone. The reply ends "Nothing starts again until someone writes." only when the Stop still holds a session, by its live slot or by its key alone (a closed tab, a helper with no live slot).stop_hold.persist, pinned withexpected_history_key); the bound intest_slot_sweep_invariant_gates.pygoes from 26 to 27./context,/codeor/knowledge(they only send engine RPCs) runs as a task recorded for its slot; the press cancels it, so a Stop ends it at its next await. Only that cancel ends there (an outer cancel goes on, judged by its count growing during the wait)./clearand every other local command are never cancelled.SlotRegistry.put_slot). The press stays pending until a person releases that helper, so a reopen that is refused does not spend it. Reading the line back never lowers a press already applied.session_create, read on the loop after the store records the worker).A person's stamp, read on arrival. The stamp is
<boot>:<press>: the last press when the request ARRIVED at the process. The press is read only at the arrival points instop_hold.ENTRIES, before any await of ours, and the stamp is built once the gateway's own authorization admitted a human:stop_hold.stop_hold_arrival_middlewareis first in both servers' middleware lists (before route latency). It writes the press into the request synchronously. Send, Continue, Regenerate, Edit & Resend and Rewind build their stamp from that value (stop_hold.http_stamp(request)) and never read the press themselves, so no middleware await (the slot-ownership transcript read among them) lets a later Stop in first. They stamp only a request token auth marked as a dashboard user (is_dashboard_user), never the loopback internal caller (internal_auth: an MCP tool, a script) nor an app token. A request that never passed the middleware carries none.events._on_event) reads the press before its first await;_route_messagebuilds a message's stamp once its sender is admitted (a trusted bot gets none);code_channels.commands.handle_slashbuilds a command's afteris_allowed_user. An action button (block_actions) carries none, so it never releases (fails closed).Everything below the entry takes the stamp as a parameter:
routing.dispatch,deliver_directed,_route_to_slot,route_linked_threadand its reroutes, queue entries, the queue drain (the newest person's stamp among its entries; the drained transcript row does not carry it), and the/prompts getre-entry of_run_chat. A queue entry restored from history loses its stamp: a stamp is valid only in the live queue it was minted into. A stamp releases a hold no newer than its press. Peers (the channel's own session included), wakes, births and resume carry none.Shared users. A shared user (
slack.shared_access) never presses or lifts a hold: code channels stay the owner's, so their message, typed!stop, command, context-bar Stop or linked reply is refused or dropped before a person's stamp is minted or a press is made (test/test_slack_code_channel_stop_hold_shared.py).A send to a held helper. It is queued and waits.
send_to_targetanswersheld: true, and thesession_sendtool says in one sentence that a Stop holds the session and it starts when a person messages it, so a conductor does not wait on it.Where it is asked:
chat_sendandenqueue_or_run_promptqueue a held send.chat_sendasks again after its replay read, and refuses with 409channel_stoppeda send a Stop held during its turn admission, when nothing can be queued any more.channel_stoppedand the pause keeps its hand-back (it never answers ok with nothing run).steer_into_running_turnrefuses every steer into a held turn after its last await, so a person's steer takes the send's stamped queue path, which releases./command acts before the dispatch gate, so_turn_slash_gateasks first, before its first await. Held, the turn ends; a person's own command releases there. A local command that starts work asks again where it acts:/workflowhandsWorkflowService.start_definitionanadmitpredicate, asked synchronously at the run's commit point (start_background_run's admission check for a script,TaskRunner.execute_planright before its task starts for a task plan;admit=None, every other caller, is as on main), and a harness-local command asks right before_answer_slash_for_harness._turn_dispatch_gatesasks last for a model turn, after every other refusal and beforemark_accepted. A held turn ends there aschannel_stopped. A release is an in-memory flip whose save is started, not awaited. The transport asks once more under its write lock, right before the prompt is written (stop_hold.write_gate, through the existingprompt_gateseam, given to a client whosestreamdeclares that keyword, as both real providers do), and earlier asks end a held turn before admission's first await, before the session claim, before the hook commands (and at each command's spawn) and before the first post (the third table below).Line cap.
chat_send.pystays at 1998 lines.routing.pygains 14 lines (1,935 on feat(slack): a code channel's Stop also stops its helper agents #38243 to 1,949): the stamp onInboundResult, its hand-on throughdispatch,_route_to_slotanddeliver_directed, andcarryafter a replacement's binding write. The press, the write before the brake, the compacting undo and the reply's closing sentence live instop_helpers.stop_channel, beside feat(slack): a code channel's Stop also stops its helper agents #38243's Stop.Docs: "What a Stop holds" in
docs/system-specs/modules/slack-gateway.md(the restart facts included) and the Stop paragraph ofsrc/kiro_crew/docs/slack-integration.md.Every path that passes the hold, with its last await and where the hold is asked (the invariant: no await between the ask and what starts work):
_run_chat)_turn_dispatch_gates' own earlier awaits (the monitor authorize, the crew-pause owe)_turn_dispatch_gates, synchronous, beforemark_acceptedand the stream; then the transport's own awaits, asked again under the write lock (stop_hold.write_gate)test_the_gate_is_the_last_refusal_and_nothing_awaits_after_it,test_a_stop_in_the_transports_wait_writes_no_prompt/workflowscript runrun_background→registry.register_asyncstart_background_run'sadmission_closed()(withadmit), thenensure_futuretest_a_workflow_started_across_a_stop_never_runs/workflowtask planexecute_plan's_bound_history_keyexecute_plan, right beforecreate_task(_execute())test_a_task_plan_held_at_its_commit_point_starts_nothing/clear, KAS verbs)_slash_command_backend/context,/codeor/knowledge(they only send engine RPCs,stop_hold.ENDABLE_LOCAL) is ended by the press at its next await;/clearand every other local command are never cancelledtest_each_local_command_that_starts_work_asks_the_hold_where_it_acts,test_a_stop_ends_a_running_context_add_before_its_second_rpc,test_a_stop_never_cuts_a_clear_short_and_only_rpc_verbs_are_endable/prompts get_expand_prompt_mention_off_looptest_a_turns_nested_rerun_carries_its_stampholds_queueafter them; the turn it starts meets the dispatch gatetest_the_drain_holds_a_queue_with_no_persons_entry_wherever_the_stop_landstest_a_persons_dashboard_send_decided_before_the_stop_never_releases..._decided_before_the_stop_never_releasestestsenqueue_or_run_prompt, peer deliverytest_enqueue_or_run_queues_a_held_session,test_a_peers_send_to_a_held_helper_waitswait_for_cleartest_a_non_persons_steer_into_a_held_turn_goes_to_the_queue_path,test_a_persons_steer_into_a_held_turn_takes_the_stamped_queue_path_dashboard_mode_admitstest_an_autonudge_wake_is_busy_wherever_the_stop_lands_before_its_spawn_interrupted_turn_resume_slotafter it;_recheck_forunder the slot lock before the queue insert; the notice drops a held session after its last await before the post (no Resume button for it)test_restart_resume_refuses_a_held_slot,test_restart_resume_neither_resumes_nor_offers_a_held_slot,test_a_held_session_is_offered_no_resume_button_bind_channel(replace=True))record_binding, right after the write and before any routing: the channel's press holds the replacementtest_a_stop_at_any_await_of_a_replace_bind_holds_the_replacementsession_createbirthstop_hold.inheriton the loop after it; the first message meetsenqueue_or_run_prompttest_a_helper_born_of_a_held_session_is_heldcode_channel_action)run_command's gates, thenroute_linked_thread's awaitedadmitand its readsroute_linked_thread's queue-or-run decision, with the person's stamp built inrun_commandafteris_allowed_userfrom the pressevents._on_eventread on the click's arrival (as a typed/create-pr); then the dispatch gatetest_a_create_pr_click_carries_the_press_its_event_arrived_aftersession_events.handle_stopped→routing._stop_bound→stop_helpers.stop_channel→stop_hold.pressbefore its first await, as the typed Stop and Slack's own Stoptest_the_bars_stop_stops_the_channels_helper_agents_as_slacks_stop_does(the reply's hold sentence and the keys the press recorded, for the bar and Slack's Stop alike)comments._deliver→route_gate._route_to_slot)admitroute_linked_thread's queue-or-run decision with no stamp (a poll's read, not an arrival), so a held session queues the comment until a person writestest_new_comments_reach_the_session_attributed_and_framed(pins the empty stamp)views.write_view,make_room)Where the hold lives. Review rounds 4 to 7 found one defect four times (a replacement session's new key, a copy made around an await, a publication without
put_slot, a same-boot reopen): the hold's truth lived on a slot OBJECT, and objects are replaced. So the truth is now the press recorded BY KEY (stop_hold._keys), for every session a press holds, live or absent;stop_hold.holdsanswers from that record (and the channel's fact, for a session replacing the channel's under a new key) and mirrors it onto whatever object carries the key. The slot's own fields are only a mirror, for its line and a restart. A stamp is judged against the key's press, so a stamp read before a Stop is refused on any object of that key. Nothing is copied from one object to another, so no hold moves:stop_hold.pressstop_channelreads the binding again right before ittest_the_press_holds_the_session_before_reading_its_helpers_in_memory_onlystop_hold.holds(every decision)persist, which also skips a slot under construction); until then the save is owed, and a registration never saves; the line itself writes the hold from the key's record, never from an object's mirror (stop_hold.held_flag, which every writer of the line goes through), so a direct publication no ask reached is still written held, and a retained old object saved by any writer after a person released its key (routing._persist_request, a turn-end save) writes the releasetest_a_pending_press_holds_a_slot_whatever_published_it(on_registera no-op),test_a_live_helper_held_then_reopened_keeps_its_press,test_a_stop_at_any_await_of_a_reserved_resume_holds_the_reopened_helper,test_a_close_rolled_back_after_a_stop_publishes_a_held_helper,test_a_stop_at_any_await_of_a_helpers_reopen_holds_it,test_a_hold_applied_on_first_ask_is_saved_only_for_the_live_entry,test_a_refused_reserved_resume_of_a_held_helper_stays_closed_after_a_restart,test_a_directly_published_held_slot_no_ask_reached_still_writes_its_holdstop_hold.restore)test_restoring_the_line_keeps_a_press_already_applied_and_a_refused_reopen_spends_nonestop_hold.carry), birth (stop_hold.inherit)test_a_stop_at_any_await_of_a_replace_bind_holds_the_replacement,test_a_stop_at_any_await_of_a_helpers_birth_holds_the_newborn,test_the_floor_and_a_newborns_press_come_from_the_key_s_recordstop_hold.gate), undo (compacting)test_a_live_helper_held_then_reopened_keeps_its_press(no record left),test_the_hold_is_written_before_the_brake_and_undone_where_not_applied,test_a_helper_whose_compaction_declined_the_stop_is_not_heldstop_hold.persist, which every hold save goes through)expected_slot_name); an object closed, replaced or under construction meanwhile is not written, and the key stays owed to the first ask on the object published under ittest_a_helper_released_during_the_stops_save_stays_released_after_a_restart,test_a_hold_save_of_an_object_replaced_before_its_commit_is_refused,test_a_held_object_the_stop_could_not_write_is_saved_on_its_first_askWhat bounds the map: only Stops add keys (a channel's session and its helpers); a person's release drops a key, an undo its own press, and a restart starts empty. No code removes a binding in this build (
CodeChannelStore.drop_bindinghas no caller), so an unreleased key stays until a person writes or the gateway restarts. A session transfer install mints a fresh key (name=None), so it never reopens a held key. Onlystop_hold.pyreads or writes a slot's_stop_heldand_stop_hold_seq(the codec writes the line throughstop_hold.held_flag);test_every_decision_goes_through_holdsscans the product for any other access.Left as is (low, from the Opus lane, each failing closed):
Where a turn's work begins. Review round 9 found the hold asked once, at the dispatch gate, while a turn's work also begins before it (the hook commands) and after it (the prompt write, behind the transport's own awaits). So the hold is asked at every point where a turn's work begins, each synchronously with no await before what it guards, and last at the write. Every effect a turn has between its arrival and the prompt write, and whether a held turn can cause it:
_turn_admit, before its first awaitsession/neworsession/load)state.sessions.get_or_create, no await between/prompts getre-entry is a nested turn with all of these asks._turn_dispatch_gatesbefore the hooks; each command again right before its spawn, after its last await (run_script_hook(admit=)); again after the hooksCreateProcess(see Limits). A command asked held is not run and the turn endschannel_stopped.set_model, and the decision model when model routing is on)mark_accepted,turn/started, heartbeatstop_hold.gate, the last refusalsession/prompt, after ready-confirm, MCP reinjection, prompt build, timeout resolution, the write lock)stop_hold.write_gateas the transport'sprompt_gate, under the write lock right before the framechannel_stopped, as at the gate./command sent to the engine (stream_command:_kiro.dev/commands/execute, orsession/prompton the prompt fallback)stop_hold.write_gate(..., call="stream_command")as the transport'sprompt_gate, under the write lock right before the frame, on both providerschannel_stopped.Limits
A turn that arrives after the press and was not sent by a person does not start. A turn already starting at the press is asked at the dispatch gate and again at the prompt write, and what it does between those two asks is not undone. Two things can still go out for a turn that was starting when the Stop landed:
_route_model_for_turnawaits (the history budget) and then sends its request to the decision model; a Stop inside those awaits does not stop that request.CreateProcess; a Stop handled on the loop thread in the instant between that ask andCreateProcessstill lets that one command start (no lock between them, no kill after the spawn).This is the same window main's own Stop has for a starting turn:
stop_slot_turnanswersno_turnfor it (its_turn_donestill set) and cancels nothing. That is main's and #38243's behaviour, unchanged here; the write gate is what refuses that turn's prompt. The fix for the two rows belongs in the Stop itself, not in more asks here.Two more follow from where the Stop now writes the hold:
pressed,stop_helpers.stop_channel) before it writes the holds and uses that answer after the write's await. If the session's turn ends during that write and a person then writes, their message releases the hold and the Stop still stops their new turn; the reply's closing sentence then describes a hold that is already released. This is feat(slack): a code channel's Stop also stops its helper agents #38243's known limit (a turn started during its first sub-agent sweep), with a longer window here. The fix is a turn-scoped cancel in the Stop, not this PR.stop_hold.persist) run one after another, each behind the transcript's patient lock, so a busy transcript lock delays the Stop. This follows from writing the hold before the brake; the delay is not measured.Known limits that fail closed (the work waits until someone writes): a Slack message in a thread linked to a dashboard chat outside a code channel, and an action button's answer, carry no stamp. An agent's
session_continueon a held helper still answers "continued" while its entry waits held (an honest answer did not fit in three lines). A hold save refused at its locked commit (the slot replaced afterpersistchecked it) is not owed again until the key's next registration, and a release's save of a slot no longer published is skipped; both leave the line held, so they fail closed.Sensitive change
Two Sensitive Change Review paths, both this PR's own (not inherited):
src/kiro_crew/hook_runtime/script_hooks.pyandsrc/kiro_crew/sandbox_rlimit.py.Sensitive change review
src/kiro_crew/hook_runtime/script_hooks.py(+45/-5 against main).run_script_hookandScriptHookStore.firetake one new keyword,admit: Callable[[], bool] | None = None.firepasses it to eachrun_script_hookonly when it is set.run_script_hookasks it after its own last await (the governance, deny-list and sandbox-argv vetting). Then, around the spawn only, it setsspawn_admit(platform_compat_offloop_spawn.py) to it, so a Windows build asks it on its worker thread right beforePopen. It also passes it on tocreate_subprocess_limited, and resetsspawn_admitright after the spawn and in its outerfinally.held()result: the command does not spawn, the sandbox's temporary file is removed, and the hook answersrefused(exit_code=2, "not run: held by a code channel's Stop").stored_runandgatedbecomedict[str, Any].src/kiro_crew/sandbox_rlimit.py(+13/-0).create_subprocess_limitedtakes one new keyword,admit: Callable[[], bool] | None = None.admitright before every spawn attempt: the no-shim fallback, each pass of the interpreter-ENOENT retry loop, and the final unguarded attempt. Those asks come after the function's own awaits (the PATH lookup thread hop and the retry backoff).SpawnNotAdmitted, and nothing spawns. The check and the exception's import are local to the function (the exception lives inplatform_compat_offloop_spawn), sosandbox_rlimitgains no module-level name and the sandbox facade,src/kiro_crew/sandbox.py, is unchanged.chdir_fdpinning, retry budget or preexec handling changes.turn_dispatch_gates._hook_admits, the hold's own read-only ask). There, no AgentSpawn or UserPromptSubmit command spawns once the Stop has landed. That includes a Stop during the spawn function's PATH lookup or retry backoff, and on Windows a Stop while the build waits for a spawn worker.admitand sets nospawn_admit, getsNone, and runs exactly as before.create_subprocess_limitedhas 44 call sites, and onlyrun_script_hookpassesadmit.channel_stoppedanyway, and the next person's message runs its hooks again.CreateProcessstill lets that one command start. There is no lock between them and no kill after the spawn.test_slack_code_channel_stop_hold_write.py:::test_a_stop_during_the_spawns_path_lookup_spawns_nothing::test_a_stop_during_the_spawns_retry_backoff_spawns_nothing::test_a_stop_during_the_last_backoff_runs_no_final_attempt::test_a_held_spawn_without_the_shim_spawns_nothing::test_a_hook_whose_spawn_is_refused_answers_held_and_cleans_up::test_a_hook_command_never_spawns_once_the_stop_lands[posix|windows]::test_a_stop_while_a_hook_is_vetted_spawns_no_command[AgentSpawn|UserPromptSubmit]test_slack_code_channel_stop_hold_spawn.py:::test_a_stop_while_the_build_waits_for_a_worker_builds_no_child[shell|no-shim exec](a one-worker pool held busy: no child,held(), the file removed,spawn_admitreset)::test_a_cancelled_build_the_stop_held_builds_no_child::test_the_ask_raising_on_the_worker_builds_no_child::test_an_admitted_build_spawns_as_today_and_an_unset_ask_is_not_asked::test_held_now_answers_as_queues::test_held_now_writes_nothing::test_a_hook_held_by_the_channels_fact_alone_still_writes_the_holdtest/test_script_hooks.py,test/test_hooks_composition_contract.pyand the hold's hook and spawn tests (test_slack_code_channel_stop_hold_write.py,test_slack_code_channel_stop_hold_spawn.py) passed in the scoped run below.Noneandspawn_admitdefaults toNone, so no caller had to change.firepassesadmitonly when it is set, so a test double that patchesrun_script_hookwithout the keyword still works. No hook config, schema or stored data changes.6234c1113conec5abb77a5, range-diff=for both commits): the PR's own test files with the hold, hook, dispatch-gate,sandbox_rlimit, off-loop spawn and sandbox facade tests, 14,151 passed and 14 failed; the 14 fail the same way on clean main on this host (tentest_terminal_commands.py::TestRunProbecases on the sandbox probe, two symlink-loop tests, one Python 3.13 type-hint repr, one edit-gate path test). The static gates (prepush-gates.sh), fail=0; every Fast Gate step run locally, rc=0; ratchets in PR mode, 178 passed; the agent-SDK boundary gate, passed; Semgrep, 0 findings.sandbox_rlimit.pyhunk. Inscript_hooks.py, revert thespawn_admitset and resets, theadmit=admitargument and theSpawnNotAdmittedcatch; the hook's own ask before the spawn stays.platform_compat_offloop_spawn.py, the worker-side ask can stay or go: unset, it asks nothing.script_hooks.pyhunk and dropadmit=_hook_admitsfrom the two_firecalls inturn_dispatch_gates.py. The hold's ask before the hooks and its ask after them stay.Backwards compatibility
Compatible. No config key or route changes; both servers gain one middleware, first in their lists, that only records a value on the request. One new metadata-line key,
stop_held: an older build ignores it, and a line without it reads as not held._run_chatgains the keyword_stop_hold_stamp. A send refused during admission while held answers 409channel_stopped, as a Pause all answers 409crew_paused.Reader: src/kiro_crew/slack/code_channels/stop_helpers.py:reply_text -- gains
held; its one callerstop_helpers.stop_channelpasses the press; the reply stays counts only -- test_bang_stop_in_a_code_channel_stops_the_bound_sessionTests
test/test_slack_code_channel_stop_hold.pyandtest/test_slack_code_channel_stop_hold_send.py(new) have one interleaving test per await-table row. The path runs from its entry under a stepping driver that presses the Stop at one of its suspension points, then the next, through all of them. Rows:mark_acceptedfollows it, and that it relays only for a person's words;_route_messageand the Slack command fromhandle_slash, through the creation barrier and the bind lock; the linked route hands the entry's stamp on unchanged;/command turn: the hold's ask reaches the write on both providers, nativecommands/executeand the prompt fallback, a Stop while the command waits for the write lock or its readiness writes nothing, and a stamp from before the Stop never releases it (test/test_slack_code_channel_stop_hold_command.py);test/test_slack_code_channel_stop_hold_unstarted.py);!stop, command, context-bar Stop and linked reply mint no stamp, press nothing and release nothing, each with the owner's control (test/test_slack_code_channel_stop_hold_shared.py);held: true, the tool's sentence);enqueue_or_run_prompt, peer delivery with and without a relayed stamp, and the steer chokepoint;/workflowwith the Stop at each await of its start (script and task plan), and the harness-local commands;test/test_slack_code_channel_stop_hold_write.py(new) covers the third table: a Stop while the prompt waits for the write lock writes nothing (the real session handle), the write's refusal ends the turn quietly aschannel_stopped(the turn harness), a hook command never spawns once the Stop lands at any of its vetting awaits (stepped), a turn held as it starts claims and announces nothing, a person's Continue on a member held by both Pause all and the Stop sends its restored queue (an internal caller's is refused, the pause kept), and AST checks pin each ask before the point it guards with no await between.A provenance guard scans the product's AST:
seen()is called only at the arrival points instop_hold.ENTRIES, before their first await;stamp()andhttp_stamp()only where the gateway's authorization admitted a human; nothing else reads the press. A planted late read fails it.test_the_arrival_middleware_is_first_in_both_appschecks both servers' lists, and the composition contract (test_dashboard_server_composition_contract_reach.py) pins each booted chain whole with the arrival middleware first.Mutation checks: each test fails when its guard is removed or moved late.
Source pins: each hold ask in a dashboard turn is tested by what the turn does, through
test/turn_harness.py'srun_turnwith a Stop pressed inside the await right before that ask (test_slack_code_channel_stop_hold_write.py): dropping any one ask fails its test. One read of the turn's source stays,test_a_harness_local_command_runs_in_the_span_of_its_ask(a row of 1 intest/test_source_pin_budget.py): no turn can land a Stop at an await added between that ask and the local command, and nothing asks again after it. The dispatch gate needs no such pin: the prompt write's ask follows it for both providers.Each ask's mutation and the test that catches it (the hold's tests, the source pin deselected):
test_a_stop_during_the_echo_is_ended_at_the_gate,test_a_persons_stamp_from_after_the_stop_releases_at_the_gate""instead of the turn's stamptest_a_persons_stamp_from_after_the_stop_releases_at_the_gate/prompts getstamp hand-on/command before the nested turn; a Stop during the expansion holds it whatever its stamp)/workflowand harness-local commandadmit=dropped at the/workflowcalltest_a_stop_during_a_workflows_start_runs_nothing_admits()droppedtest_a_stop_before_a_harness_local_command_runs_nothingtest_a_harness_local_command_runs_in_the_span_of_its_asktest_a_stop_after_the_claim_fires_no_hookadmit=dropped on AgentSpawntest_a_stop_while_a_hook_is_vetted_spawns_no_command[AgentSpawn]admit=dropped on UserPromptSubmittest_a_stop_while_a_hook_is_vetted_spawns_no_command[UserPromptSubmit]queueschecktest_a_stop_during_the_hooks_starts_nothing_after_themtest_a_stop_during_the_prompts_last_steps_announces_nothingwrite_gatenot passed to the streamtest_the_runner_hands_the_stream_the_write_gatetest_a_turn_held_as_it_starts_prepares_nothingtest_a_stop_before_the_claim_claims_no_sessiontest_slack_code_channel_stop_helpers.py,test_slack_code_channels_routing.py,test_slot_metadata_codec.py,test_chat_persistence_composition_contract.py(the merge's golden bytes),test_chat_runner_composition_contract.py(the entry signature),test_slot_sweep_invariant_gates.py(the census bound),test_dashboard_server_composition_contract.pyandtest_dashboard_server_composition_contract_reach.py(the arrival middleware's lazy import and its place in both chains),test_hooks_composition_contract.py(the shape digest, forrun_script_hook's trailingadmit=None),test_chat_runner_base_surface.py(_handle_workflow_command'sadmit=None),chat_test_helpers._make_app(the arrival middleware first, as in the servers),conftest.py(an autouse reset ofstop_hold's process-wide records, as for the other process-wide registries, so one test's Stop never holds another test's key) and the chat-send tests whose_run_chatfakes list their keywords are updated for the reply's closing sentence, the new metadata key and the new keyword.Manual verification
N/A: every path is covered through its real entry point. No live Slack workspace was used.
Related Issues
RFC:
docs/request-for-change/rfc-slack-code-channels.md§3 "Stop" (#35935). Builds on the brake, #38243, as merged on main (its counts-only reply and itsstop_helpers.stop_channel). Head53fda2568da861a1dde44c1b2f19017d5d282a2c. Rebased onto #22370 as merged: its context bar's Create PR and Stop, its canvas comments and its view tabs are in the "Where it is asked" table.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license.