Repository navigation
fix: refuse person-only directives on task runner turns - #36792
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS This reuses the existing Notes
What this change shipsInventory (7 items) — 7 justifiedIntent: when a task runner turn calls a person-only directive, refuse it visibly and audit it, the same way other headless turns already do. FIX.
[FIRST-PRINCIPLES-REVIEWED] b0cce12 Description read[DESCRIPTION-READ] 48190ed6856aa66952e5bec675adea961270509e52562f920b5e293fbb77b8fb That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: the fix wires the existing Notes
[DESIGN-REVIEWED] b0cce12 Description read[DESCRIPTION-READ] d90d5137547c38f853c17f60afacaaec6907dafcb58fdf6b4cd73ec74a3936f4 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 |
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: |
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: |
Code change approver recommendation: A person should decideWhy: the decider estimates a 7% chance that this change introduces a defect, within the 12% limit for approving on its own, but it is held at tier pending: being reviewed. This PR wires the existing person_only_directive_refuser into all four task runner turns: the step, self-review, lesson and decomposition turns. Each uses its own session key. The step turn puts the refusal text ahead of task.result, while the three JSON turns record the refusal only in a SEL Tier: pending: being reviewed. An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit |
No session applier reads a task runner turn, so a person-only directive (a USER_ORIGIN_DIRECTIVES call such as set_project or chat_tag) made by a step, its self-review, the decomposition turn or the lesson turn was neither applied nor refused, and no SEL denied row recorded it. The task result could only echo the tool's own "requested" text. Each of those turns now observes its stream with person_only_directive_refuser on its own session key, as the cron, workflow, app and completion turns already do. The step turn leads task.result with every attempt's refusals; the JSON turns keep their text for the parse, so the refusal lives in its SEL row. stream_and_collect_json gains a pass-through on_event keyword for that. Fixes #34756 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Rebased: main moved in docs/system-specs/modules/taskrunner.md, src/kiro_crew/task_executor.py, src/kiro_crew/taskrunner_parts/run_reporting.py and test/test_taskrunner_deny_notice.py since this head's CI ran (c22557c -> 226c9d6); CI re-running. Why a re-sync at all: the only red on the old head that was not infrastructure was Coverage Gate, on Main touched four of this PR's files, all outside its hunks: #36361 and #35183 edited other paragraphs of the task runner spec, #31863 swapped a fixture token in an unrelated test of the deny-notice file, #37578 and #35011 changed lines of The other three reds on the old head were infrastructure: [operator: bolichen97] |
15df7b4 to
b0cce12
Compare
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Approving. On head b0cce12, the review confirmed four things. The shared person_only_directive_refuser is now wired into all four task runner turns, each with its own session key: the step turn, decompose, self review and the lesson call. The refusal list is created once, before the retry loop, and leads task.result. A turn with no directive call keeps its result byte-identical. The JSON turns still parse to the same verdict, lesson or plan. CI and PR Readiness are green on this head.
Done well: the fix reuses the one existing refuser instead of copying it. The tests drive the real turn functions against a real synchronous security event log, and each one pins the exact (key, tool, outcome) row.
Optional:
task_executor.py:967: the every-50-chunks refresh oftask.resultleaves outrefusals. A step that gives up after repeated process deaths keeps the audit row, but its result has no refusal line. Building the refresh from the same"\n\n".join([*refusals, result_prefix + result_text])expression would keep both writers in step.- No test drives a retry. A case where the first attempt calls
set_projectand then retries, with an assertion that the refusal still leadstask.result, would pin the "every attempt" promise in the taskrunner spec. - The Tests section's Proof line names head 15df7b4, not b0cce12. The production and test hunks are the same, so this is wording only.
Problem / Motivation
Goal: A person-only directive (
set_project,reset_conversation,chat_tag,suggest_followup) that a task runner turn calls is refused out loud and audited, the way cron, workflow, app and completion turns already refuse it.Why it matters
A task runner step, its self-review, its decomposition turn and its lesson turn can call
set_projecttoday and get only the tool's own "requested" text back: nothing is changed, nothing says so, and no SELdeniedrow records the call. Someone reading the task result or the audit log sees a call that looks like it worked.Not a goal
What changed (motivation → approach → change)
A person-only directive call on a task runner turn (any of
USER_ORIGIN_DIRECTIVES:set_project,reset_conversation,chat_tag,chat_rename,suggest_followup) is refused and recorded instead of silently doing nothing: the step's result starts with the refusal, and the SEL log gets adeniedrow on that turn's key. Cron, workflow, app and completion turns already behave this way.Symptom: such a call ends with only the tool's "requested" text, and the SEL log has no
deniedrow. Cause: no session applier reads a task runner turn, and unlike the other headless turns, none of the four task runner turns passed its stream to the existingperson_only_directive_refuser. Each one does now, on its own session key.execute_task)task_executor.pytask.result(joined with a blank line), plus a SELdeniedrow ontaskrunner:{id}:task{N}self_review)task_executor.pydeniedrow ontaskrunner:{id}:review; the JSON text is left alone_call_llm_for_lesson)taskrunner_parts/run_reporting.pydeniedrow on the lesson key; the JSON text is left alonedecompose)task_planner.pydeniedrow ontaskrunner:{id}:decompose; the JSON text is left aloneThe three JSON turns leave their text alone because a refusal line ahead of the JSON would break the parse. Their refusal lives only in the SEL row, as it does on a workflow
schema=step. To reach the self-review and lesson turns,stream_and_collect_json(src/kiro_crew/llm_helpers_parts/turn_stream.py) now accepts anon_eventkeyword (defaultNone) and passes it tostream_and_collect. Existing callers are unchanged. The refuser is imported inside each function, as at every other call site. There is no new rule, wording, directive set or config.docs/system-specs/modules/taskrunner.mdgets one paragraph under Tool Approval.Backwards compatibility
Compatible: the
on_eventkeyword defaults toNone. A turn that calls no person-only directive produces a byte-identical result and writes no new SEL row (smoke happy path below).Removes nothing: the only things added are a refusal line on the step result and a
deniedaudit row, and only when such a call happens. Nothing is hidden, deleted, renamed or tightened.Tests
test/test_taskrunner_deny_notice.py::test_a_step_turns_person_only_directive_leads_the_resultruns the realexecute_taskwith a provider that completes aset_projectcall.task.resultstarts with the user-origin refusal (naming the turn's key) and ends with the turn's text. A synchronous SEL undertmp_pathholds exactly onemcp-directivedeniedrow on the step's key.test/test_taskrunner_deny_notice.py::test_a_json_turns_person_only_directive_is_audited_and_parses[self_review|lesson|decompose]runs the real JSON turns. Each one's JSON still parses to the same verdict, lesson or plan, and exactly onedeniedrow lands on that turn's own key.test/test_taskrunner_v2_scenarios.py: twostream_and_collect_jsonfakes now accept keywords.Proof: PROVEN test/test_taskrunner_deny_notice.py::test_a_step_turns_person_only_directive_leads_the_result, test/test_taskrunner_deny_notice.py::test_a_json_turns_person_only_directive_is_audited_and_parses[self_review], test/test_taskrunner_deny_notice.py::test_a_json_turns_person_only_directive_is_audited_and_parses[lesson], test/test_taskrunner_deny_notice.py::test_a_json_turns_person_only_directive_is_audited_and_parses[decompose] (head 15df7b4)
Determinism (testing-conventions D12): the new tests passed 20/20 at
-n0, then 10/10 at-n 4 --dist loadgroup --max-worker-restart=2besidetest_task_planner_decompose_gate.pyandtest_taskrunner_v2_scenarios.py. The whole file also passed in a shuffled order (seed 17641, 28 passed).Manual verification
How it was verified, on Linux (Ubuntu 24.04.5 LTS, x86_64). This host has no signed-in agent backend, so the exact code path was driven instead. The script calls the real
execute_task,self_review,_call_llm_for_lessonandtask_planner.decomposeunder an isolatedKIROCREW_HOME=$(mktemp -d). Each gets a scripted provider whosestream()yields the frames a realset_projectcall produces: a tool call on the core MCP server, its final result, text, then completion. The script then reads the realsecurity_events.jsonlwritten under that home. Only the session manager, the prompt builder, the context check and the config load are doubles.Before (base, fix not applied):
After (this branch):
Happy path, the same script with no directive call:
task.resultis"Step done."both before and after, the JSON turns parse the same, and the SEL log has nomcp-directiverows (0 rows in total).Related Issues
Closes #34756
Sibling sweep
Swept: git grep -n "stream_and_collect|.stream(|continue_timed_out_calls" -- src/kiro_crew/task_executor.py src/kiro_crew/task_planner.py src/kiro_crew/taskrunner_parts/ src/kiro_crew/taskrunner.py
Swept: git grep -ln "taskrunner" -- src/kiro_crew | xargs grep -ln "stream_and_collect|run_bg_oneliner|.stream("
Sibling: src/kiro_crew/task_executor.py:961 -- changed here
Sibling: src/kiro_crew/taskrunner_parts/run_reporting.py:236 -- changed here
Sibling: src/kiro_crew/task_planner.py:350 -- changed here
task_executor.pyholds two of the four sites: the step turn (line 961) andself_review(line 1741).Sibling: src/kiro_crew/dashboard/handlers/taskrunner.py -- not affected -- _run_refine is the spec-writer turn a person starts from the dashboard, not a headless task runner turn, so the headless refusal this fix adds does not describe it
Pattern harvest
Rule candidate: review-prompt
Pattern: "a headless turn that streams a provider itself (
client.stream,stream_and_collect[_json]) withoutperson_only_directive_refuser, where no session applier reads the stream"Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributed under the project's Apache-2.0 license.