Repository navigation
fix: resolve each cron agent_sequence step as its own crew (#15139) - #16047
Conversation
de2ebed to
c47441d
Compare
Design Review (Fable 5) — 🟡 CONCERNSDesign-level review of Design-Verdict: CONCERNS A permanently malformed sequence (empty step) now defers on every fire forever, never engaging the failure ladder — a transient-condition mechanism applied to a permanent condition. Watch
Suggestions
[DESIGN-REVIEWED] 36ad2de Description read[DESCRIPTION-READ] d2a0fcd30c6ce0a7bb62beed34327f6d070d1201194d17a1fc0eec58fb5e5423 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 (Fable 5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Verify the undeclared post-start rebind: Not justified as shipped
What this change shipsInventory (10 items) — 8 justifiedIntent: FIX — a cron whose captured identity is a crew member must run each
[FIRST-PRINCIPLES-REVIEWED] 36ad2de Description read[DESCRIPTION-READ] 8f5a03b06ce38a74c60218fa4493e81fbcf1d9a0b51121adb96d297a08babf47 That sha256 names the PR description this verdict read. Recompute it with |
GPT 5.6 Review — ✅ no blocking findingsGPT 5.6 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 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: |
c47441d to
efba895
Compare
|
self-added: yes 🤖 Kiro Crew Auto-Pipeline [operator: cruisercohen#97bc2b11]
|
efba895 to
bde7226
Compare
|
self-added: yes 🤖 Kiro Crew Auto-Pipeline [operator: cruisercohen#97bc2b11]
|
bde7226 to
9099f7d
Compare
|
self-added: yes 🤖 Kiro Crew Auto-Pipeline [operator: cruisercohen#97bc2b11]
|
8bb2afa to
09e29f0
Compare
|
self-added: yes 🤖 Kiro Crew Auto-Pipeline [operator: cruisercohen#97bc2b11]
|
|
self-added: yes 🤖 Kiro Crew Auto-Pipeline [operator: cruisercohen#97bc2b11]
|
|
self-added: yes 🤖 Kiro Crew Auto-Pipeline [operator: cruisercohen#97bc2b11]
|
A schedule whose captured execution names a crew member dispatched every agent_sequence step as that one member: _resolve_cron_agent applied the captured-member identity pin to all steps, so each step's runtime, workspace, pinned model and capability gates came from the captured member instead of the step's own crew. The sequence ran its steps in order but the crews it named never actually ran as themselves. Gate the captured-member pin behind a new sequence_step flag. A declared agent_sequence step passes sequence_step=True, which skips the pin and resolves the step by its own alias; a single-agent captured job is unchanged and keeps the pin that stops a recreated same-name alias adopting a retired member's memory silo. The captured memory store is still shared by every step (bound per session key by the caller), so the run keeps one memory identity while each step runs as the crew the sequence names. Documents the per-step rule in the owning learn-cron-dashboard spec. Closes #15139
09e29f0 to
36ad2de
Compare
|
self-added: no 🤖 Kiro Crew Auto-Pipeline [operator: cruisercohen#97bc2b11]
|
|
self-added: no 🤖 Kiro Crew Auto-Pipeline [operator: cruisercohen#97bc2b11]
|
|
self-added: no 🤖 Kiro Crew Auto-Pipeline [operator: cruisercohen#97bc2b11]
|
|
self-added: no 🤖 Kiro Crew Auto-Pipeline [operator: cruisercohen#97bc2b11]
|
|
self-added: no 🤖 Kiro Crew Auto-Pipeline [operator: cruisercohen#97bc2b11]
|
iamwhatever
left a comment
There was a problem hiding this comment.
Reviewed: sequence_step=True skips the captured-member pin only in the sequence loop (gateway.py:4673), single-agent jobs keep the pin, and every step still builds its context with the captured execution and store (gateway.py:4790), so no step gets its own memory store. Two advisory notes, not blocking: (1) gateway.py:4576 _rebind_prepared_execution CAS-checks against bound_execution, but bind_session_execution stores with_mode(current.memory_mode), so a retained stricter mode would raise 'session changed during admission' after the session was created; re-read and pass that as expected, as :4538 does. (2) gateway.py:4537 passes a fresh read as expected with replace_existing=True, which is effectively an unconditional replace; asserting that only template_id / selection_kind / selection_name differ would match the PR's claim.
Problem / Motivation
Goal: A scheduled job whose captured identity is a crew member now runs each step of its
agent_sequenceas that step's own crew, instead of running every step as the one captured member.A cron schedule that carries a captured crew member (created with a
member_id, or from a member's own session) dispatched every entry of itsagent_sequenceas that one member. The sequence still ran its steps in order, with a session key per step (cron:<job id>:<step>), but each step's runtime, workspace, pinned model and capability gates came from the captured member rather than from the step's own crew — so the other crews the sequence named never actually ran.Why it matters
A
agent_sequenceexists to run a pipeline of distinct crews in order. When the schedule carried a captured member, that intent silently collapsed: a two-crew sequence ran twice as one crew. The misdispatch is invisible — the path logs nothing on success — so a job looks like it is honoring its sequence while every step uses the wrong agent's tools, model and workspace.Not a goal
wakesCrew); it still groups a member-captured sequence under itsmember_id.What changed (motivation → approach → change)
The misdispatch was the captured-member identity pin in
_resolve_cron_agent(src/kiro_crew/slack/gateway.py): when the captured execution named a member, it resolved the member's alias and ignored itsaliasargument, so each sequence step resolved to the captured member, not its own crew.That pin is right for a single-agent captured job but wrong for a sequence, where each step's
aliasalready names its crew. A keyword-onlysequence_stepflag makes the sequential loop call_resolve_cron_agent(agent, sequence_step=True), skipping the pin so the step resolves its own crew'skiro_agent, workspace, model and capability gates. The single-agent call site keeps the pin.Resolving the step as its own crew surfaced a second mismatch: the session record bound under the step key (
bind_session_execution) drives sub-agent spawn authorization viaparent_spawn_allowlists(execution.template_id), and it was still the captured member's. The loop now binds a per-step execution fromcron_execution.with_template(step kiro_agent, step crew), rewriting only the template/selection the spawn gate reads while preserving the capturedmember_id, store, mode and app. The step keycron:<job id>:<step>is stable across fires, so the binding uses a compare-and-swap replace (replace_existing=True, the freshly read record asexpected); without it an already-fired member-captured sequence would crash on every later fire.bind_session_executionis not weakened for any other caller, and deny-by-default is unchanged.The captured memory store is untouched — bound per session key by the caller — so the run keeps one memory identity while its steps run as the crews the sequence names.Because a step now runs as its own crew, a step's session can outlive a fire (while sub-agent work is pending) under a runtime that no longer matches the crew it resolves to after a crew edit, and the session is reused by key. So the single-agent retained-session check and the sequence path share one helper, and the sequence resolves each step's agent once per fire, above the sweep, into a list parallel to the sequence (duplicate aliases stay distinct steps). The sweep only compares each step against its frozen dispatch agent and defers the whole fire on a mismatch (and, if a step names no crew, logs loudly and defers the same way — never-started, so a
delete_after_runone-shot is retained); the dispatch loop reuses the frozen triple. Resolving once closes the window — the compared string is the dispatched string, so a crew edit after the sweep applies next fire rather than slipping onto an unchecked runtime; deferring before any step runs stops a mid-loop deferral replaying a partly-run fire. One window remained: the step's execution record (the spawn gate's parent-identity input) was bound from the pre-loop snapshot, but dispatch re-reads the template fresh, so a config write to the step's alias could leave the bound template stale and drop the parent'savailableAgents. So after preparation the record is rebound from the dispatched template (replace_executiononly, positive-evidence only, store/member/mode/app preserved) — one source of truth. The single-agent guard is unchanged, and the owning specdocs/system-specs/modules/learn-cron-dashboard.mdis updated in the same commit.Backwards compatibility
Compatible: no contract is tightened, renamed or removed.
sequence_stepdefaults toFalse, so every existing caller (including the single-agent path) behaves exactly as before; only the sequential loop opts in. A member-captured sequence now runs as its named crews — the intended fix — while single-agent captured jobs are unchanged.Tests
test/test_cron_sequence_member_alias.py(new): eleven tests driving the real_cron_callbackclosure with a stubbed session manager. (1) A member-captured sequence[beta, alpha]dispatches its first step as crewbeta(itscrew_agent,kiro_agentmode, owncwd), not the captured memberalpha(reds without thesequence_stepgate). (2) A step whose crew declares a sub-agentavailableAgentsallowlist binds its spawn policy from the step crew while the boundmember_id, store, mode and app stay the captured run's (reds without the per-step binding). (3) A sequence fired twice succeeds on the second fire and the step record upgrades to the step crew's template keeping the captured identity (reds without the CAS replace). (4) A step key retaining a live session under a different agent defers the whole fire, no step dispatched. (5) A mismatch on a later step still defers before the first step dispatches. (6) A crew edit landing after the sweep read it does not change that step's dispatch. (7) A two-step sequence resolves each step exactly once. (8)[beta, beta]dispatches twice on one shared key. (9) An empty step["", beta]defers (never-started, loud error) rather than raising. (10) The same empty step on adelete_after_runone-shot keepsrun_never_startedso it is not consumed. (11) A config write to the step's alias between resolve and dispatch leaves the bound record carrying the dispatched template, not the stale snapshot, keeping the parent'savailableAgents(reds without the rebind). The single-agent loosening is caught bytest/test_slack_gateway_cron_exec_coverage.py::test_recreated_alias_does_not_cross_captured_member_identity, andtest/test_cron_execution_capture_async.pyasserts a sequence step binds its own template while single-agent capture keeps the job's.Manual verification
N/A — unit coverage is sufficient. The change is a backend dispatch-resolution gate with no UI surface; the new tests exercise the real callback up to the session acquire, and the existing cron/crew suites pass. One pre-existing property is intentionally left as-is: a sequence step's
CapabilityStartupErrorpropagates out of the loop as before; this fix makes a different crew's startup reachable but does not change that error handling, which is out of goal.Related Issues
Closes #15139
Pattern harvest
Not generalizable: a single wrong-subject bug — an identity pin applied to a caller-supplied alias it should have left alone for one dispatch mode. No broader class to lint for beyond the mutation-pin the new tests provide.
Checklist