Repository navigation
fix(governance): give cron turns their agent at the governance gate - #29412
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: this closes a governance gap by naming the agent at the gate, the same way chat already does, and takes nothing away. Notes
[DESIGN-REVIEWED] 7b7b954 Description read[DESCRIPTION-READ] c735177ebfadbd55b7e2d71caa4ec16d770b03b1137d196a81a1252b5a97cccb 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. Every item is part of handing the cron turn's gate the agent name a chat turn already hands it, and the member lookup reuses What this change shipsInventory (5 items) — 5 justifiedIntent: an administrator's task profile bound to an agent also governs that agent's unattended cron turns. FIX.
[FIRST-PRINCIPLES-REVIEWED] 7b7b954 Description read[DESCRIPTION-READ] 74b8b9f7eaabf2635948febccad61e11aa99fe0fb637aeee0026e2fcbfa83fd7 That sha256 names the PR description this verdict read. Recompute it with |
A cron turn handed the PreToolUse gate its cron:<job> session key but no agent, so resolve_active_scope skipped the task bind on the agent name. A profile an administrator binds to an agent governed its chat turns but not its cron turns. Pass the dispatched template as agent= at both stream calls: each step's dispatch_agent on an agent_sequence, _dispatch_agent on the single-agent path. That is the id a chat turn hands the gate. Mirrors #29412 on main. (cherry picked from commit 2012f5e) Forward-port conflict: test/test_cron_sequence_member_alias.py. On main the new test follows tests from #28410, which this branch does not carry. Kept the release file and appended only the new test.
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: |
2012f5e to
f6c0486
Compare
|
self-added: yes
|
A cron turn handed the PreToolUse gate its cron:<job> session key but no agent, so resolve_active_scope skipped the task bind on the agent name. A profile an administrator binds to an agent governed its chat turns but not its cron turns. Pass the agent's alias or crew record name as agent= at both stream calls: each step's alias on an agent_sequence, cron_agent on the single-agent path. That is the name every chat surface hands the gate; the template it collapses to stays on session acquisition and message build. Mirrors #29412 on main. (cherry picked from commit f6c0486) Forward-port conflict: test/test_cron_sequence_member_alias.py. On main the new test follows tests from #28410, which this branch does not carry. Kept the release file and appended only the new test.
f6c0486 to
47efc8f
Compare
|
self-added: yes
|
|
self-added: yes
|
A cron turn handed the PreToolUse gate its cron:<job> session key but no agent, so resolve_active_scope skipped the task bind on the agent name. A profile an administrator binds to an agent governed its chat turns but not its cron turns. Hand the gate the alias or crew record name a chat turn on that agent hands it: each step's alias on an agent_sequence; on a single-agent job the job's agent_id, else the member the capture selected, read before a crewmate's worker swap, else the agent that runs. The dispatched template stays on session acquisition and message build. Mirrors #29412 on main. (cherry picked from commit 47efc8f) Forward-port conflict: test/test_cron_sequence_member_alias.py. On main the new test follows tests from #28410, which this branch does not carry. Kept the release file and appended only the new test.
47efc8f to
615a844
Compare
|
self-added: yes
|
|
self-added: yes
|
A cron turn handed the PreToolUse gate its cron:<job> session key but no agent, so resolve_active_scope skipped the task bind on the agent name. A profile an administrator binds to an agent governed its chat turns but not its cron turns. Hand the gate the alias or crew record name a chat turn on that agent hands it: each step's alias on an agent_sequence. On a single-agent job whose capture selected a member, the member's live alias (the record dispatch resolves through member_config_for_id), else its captured selection_name, whatever the job's agent names; otherwise the job's agent_id, else the agent that runs. Read before a crewmate's worker swap. The dispatched template stays on session acquisition and message build.
615a844 to
7b7b954
Compare
bolichen97
left a comment
There was a problem hiding this comment.
[operator: bolichen97] Approving at 7b7b954.
Both cron paths now pass the gate agent to stream_and_collect: _cron_run_sequence uses the step alias, and _cron_run_single uses gate_agent, computed in cron_fire.py before the crewmate worker swap. In turn_stream.py, agent is only forwarded to the governance gate, so session and dispatch behavior do not change. The new _CronCapture field has a default, so existing constructors still work. A failed member lookup falls back to selection_name instead of crashing the cron. The effect is a tightening: an agent with a task bind now gets that profile on its cron turns, as chat turns already do. This is not on main yet. #29386 added only session_key=/unattended= on the 0.12 branch.
Minor, non-blocking:
- The
except Exception: _gate_alias = ""incron_fire.pyfalls back silently. A debug log there would make wrong-profile cases easier to diagnose. cap.gate_agent or ""is redundant, because the capture already falls back tocron_agent.
AI-assisted, approved by bolichen97
…29412) (#29565) A cron turn handed the PreToolUse gate its cron:<job> session key but no agent, so resolve_active_scope skipped the task bind on the agent name. A profile an administrator binds to an agent governed its chat turns but not its cron turns. Hand the gate the alias or crew record name a chat turn on that agent hands it: each step's alias on an agent_sequence. On a single-agent job whose capture selected a member, the member's live alias (the record dispatch resolves through member_config_for_id), else its captured selection_name, whatever the job's agent names; otherwise the job's agent_id, else the agent that runs. Read before a crewmate's worker swap. The dispatched template stays on session acquisition and message build. (cherry picked from commit 46af64f) Forward-port conflict: test/test_cron_sequence_member_alias.py. On main the new test follows tests from #28410, which this branch does not carry. Kept the release file and appended only the new test.
Problem / Motivation
Goal: A governance profile bound to an agent governs that agent's cron turns, the same as its chat turns
A cron turn hands the PreToolUse gate its
cron:<job>session key andunattended=True, but no agent.resolve_active_scopelooks up ataskbind on the agent name only when it is given one, so a profile an administrator binds to an agent (Bind(type="task", id="researcher")) is skipped on that agent's cron turns. The turn is judged by thecronsurface profile or the policy ceiling instead.Why it matters
An administrator who scopes an agent tightly gets that scope on its chat turns only. Its unattended cron runs, the ones nobody is watching, are governed more loosely than they set.
Not a goal
What changed (motivation → approach → change)
Both cron stream calls in
cron_turn.pyhand the gate the agent's alias or crew record name, the same name every chat surface (dashboard, Slack, messaging channels) hands it. The template that name collapses to stays on session acquisition and message build only:agent=_cron_run_sequencealias_cron_run_singlemember_config_for_id), else its capturedselection_name, whatever the job'sagentnames; otherwise the job'sagent_id, else the agent that runs. Read incron_fire.pybefore a crewmate's worker swap_cron_stream_with_posttoken_resumeforwards it tostream_and_collect, which already takesagentand hands it to the gate. The governance spec names the agent in its unattended-turns paragraph.Backwards compatibility
Compatible: a cron turn whose agent has no task bind resolves exactly as before. Only an agent with a bound task profile now gets that profile on its cron turns, which is what the bind already means for its chat turns.
Removes nothing: no key, path or record is removed.
Tests
Proof: PROVEN test/test_cron_sequence_member_alias.py::test_each_sequence_step_hands_the_gate_its_alias_not_its_template (head 615a844)
test_each_sequence_step_hands_the_gate_its_alias_not_its_template: each sequence step streams with its own session key, its alias (not thekiro_agenttemplate it runs) andunattended=True.test_cron_turn_hands_the_gate_its_alias_not_its_template: on the single-agent path the session runs the template while the gate gets the alias.test_a_member_cron_hands_the_gate_the_member_alias[member|crewmate-worker]: a cron captured from a member's chat, with noagent_id, hands the gate the member alias, also after a crewmate's capture is swapped to the worker template.test_a_member_capture_hands_the_gate_its_live_alias_whatever_the_job_names[dashboard-template-agent|other-member-agent|renamed-member]: a member schedule whoseagentholds a template (the dashboard's create/edit shape) or another member's name (acron_update) still hands the gate the member's live alias, and follows a rename; dispatch stays on the member's template. Restoringjob.agent_idpriority fails the first two; dropping the live lookup fails the third.test_a_task_profile_bound_to_the_cron_agent_governs_its_turn: with acron:session key, a task bind on the agent wins.agent=line alone fails its own test.-n0; both files (35 tests) green in three shuffled orders, seeds 11, 22, 33.cron_turn.py(182 files), single process in batches: 5,861 passed. One failure,test_cron_run_scratch.py::TestUnderTheRealSandbox::test_script_cron_writes_into_its_temp_dir, fails the same way on a cleanorigin/main: the real sandbox cannot pin this host's temp path.Manual verification
N/A - unit coverage pins the keyword at both call sites and the resolver's task-bind lookup.
Related Issues
Closes #29411
Sibling sweep
Swept: git grep -n "unattended=True" -- src/kiro_crew/
Sibling: src/kiro_crew/messaging/dispatch.py:1037 -- not affected -- a channel monitor wake passes agent=agent and unattended
Sibling: src/kiro_crew/slack/gateway_runtime/nudge_channel_fire.py:269 -- tracked in #29411
Sibling: src/kiro_crew/slack/gateway_runtime/heartbeat_turns.py:211 -- tracked in #29411
The Slack-thread nudge's
stream_and_collectpath and the heartbeat task stream withunattended=Truebut no session key or agent; the nudge'sTurnDriverpath passes both. They are listed on #29411 rather than changed here, to keep this PR to the cron turn.Pattern harvest
Rule candidate: review-prompt
Pattern: an unattended
stream_and_collect(unattended=True)call that passes nosession_key=/agent=, so the gate cannot resolve the session's or agent's profile.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.