Repository navigation
fix(cron): run the configured default agent for an agent-less cron - #5706
Conversation
|
👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review. When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically. |
3 similar comments
|
👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review. When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically. |
|
👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review. When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically. |
|
👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review. When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically. |
bolichen97
left a comment
There was a problem hiding this comment.
Description / code mismatch
The Description states that the default-agent fallback is in-memory only and cannot reach the durable job store, but the object it mutates is the same object _save() reserialises, so the resolved agent name is written into crons.json on the first completed run.
1. The default-agent resolution is not in-memory only — it persists into crons.json on the first merged run
The Description says —
Resolve the fallback at job execution, mirroring the chat transports (
agent or cfg.agent.default_agent): if a job has noagent_idand noagent_sequence, setjob.agent_idtoconfig.agent.default_agentin memory._merge_job_resultnever persistsagent_id, so stored job definitions are unchanged.
The code does — the first clause is literally true and the conclusion is not. _merge_job_result's field-by-field merge does not copy agent_id onto by_id[job.id], but by_id[job.id] is job: the scheduler passes the live CronJob out of self._jobs to the callback (await self._on_job(job), src/kiro_crew/cron.py:3591), so the assignment added at src/kiro_crew/slack/gateway.py:4047 mutates the stored object in place. _merge_job_result (src/kiro_crew/cron.py:3641) then calls self._save(), and _save (src/kiro_crew/cron.py:4269) reserialises every field of every object in self._jobs, agent_id included. The mutated value is also what the run itself already reads back — job.agent_id or None at src/kiro_crew/slack/gateway.py:4279 and :4299, and the usage row at :4357 (line numbers as of head bc61ccc7f). The aliasing the Description denies is already documented three lines below the callback: src/kiro_crew/cron.py:3592-3594 notes that "the command/script paths return NORMALLY and signal failure by mutating the shared job". The diff adds no test, so nothing catches the write.
Risk — an LLM cron created with no agent, meaning "follow the configured default", is silently rewritten on disk to pin the concrete agent name after its first completed run. The job then stops tracking agent.default_agent: an operator who later changes the default keeps running the old agent forever, and anyone inspecting crons.json, the Schedule UI, cron_list, or GET /api/crons sees an explicit agent they never set. This is a second, undisclosed user-visible change on top of the runtime fix the PR intends, and because the Description asserts the durable store cannot be touched, a reviewer who trusts that sentence will not look for it.
Required change — do not mutate the shared CronJob. Resolve the agent into a local and pass it through the call sites that consume it: _acquire_with_model_fallback(session_key, ...) at src/kiro_crew/slack/gateway.py:4279, ctx_builder.build_message(..., agent=...) at :4299, and the usage row agent= at :4357. Alternatively restore the previous agent_id in a finally, or add agent_id to a documented runtime-only exclusion that _save() skips. Either way, correct the Description sentence and add a test asserting that a cron run leaves crons.json's agent_id untouched.
|
👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review. When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically. |
|
👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review. When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically. |
1 similar comment
|
👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review. When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically. |
|
@leozhad Thanks for this. The #9201 (@mbajaj92, project-scoped cron agents). It replaces the same two consumer sites, the #9038 (@rubencu, pruned-install retryable skips). It rewrites the same Two other items before this can move. The branch is 1984 commits behind with a dirty merge state, so it needs a rebase. The code comment claiming the change is in-memory only and cannot rewrite Posted from the 2026-09-08 open-PR relationship audit (read-only, one auditor per PR); reply here if any of this is wrong. |
bc61ccc to
7a31c62
Compare
|
👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review. When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically. |
7a31c62 to
ec6256a
Compare
|
Thanks — the finding was correct on both counts, and the fix has been rewritten around it. Required change implemented. The default is now resolved into a local and folded into the execution capture; the shared Test added, as required. One thing that changed underneath this PR while it sat. Two small additions beyond the required change, both flagged in the Description: the sequence gate now uses Cron suite: 3338 → 3346 passed, 0 regressions. |
|
👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review. When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically. |
|
👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review. When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically. |
3 similar comments
|
👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review. When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically. |
|
👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review. When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically. |
|
👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review. When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically. |
ec6256a to
091ffdd
Compare
|
The required change is in at The default is now resolved into a local and folded into the Why "resolve into a local" was the only one of the three options that worksA write to The tests discriminate in both directions8 new cases in
Rebased onto One housekeeping note: the red Marking ready for review. |
|
👋 Hi! This PR's description is missing some required sections from our PR template. Workflow runs won't be auto-approved until the description is updated. Missing sections:
Please update your PR description to include these sections, then push or re-save the description. The workflows will be approved on the next cycle. |
68972db to
20f12a7
Compare
20f12a7 to
deaca8d
Compare
deaca8d to
8ed7d28
Compare
|
@bolichen97 @iamwhatever @CrysisDeu — two things on this PR need commit access, and neither is a code change. MAINTAINERS.md says tagging the list to get a decision unstuck is fine, so I am doing that rather than pinging anyone directly. 1. A re-review to clear the stale
The review's diagnosis was correct and the risk it described was real: an agent-less cron would have been pinned to a concrete agent name in 2. Run approval for On Local verification on the current base |
8ed7d28 to
473df7a
Compare
|
GPT 5.6 F1 — fixed (
|
GPT 5.6 F1 (second round) — fixed:
|
|
The spawn-allowlist finding is real and I reproduced it before changing anything. I closed it by a different mechanism than the one prescribed, and that is deliberate — head is now The finding, verified leg by leg. The substitution reaches the dispatched Why not the prescribed remedy. "Use the substituted template as the non-durable parent execution for spawn admission" needs a non-durable parent-execution channel that the spawn gate reads. There is no such channel today: What I did instead — a narrowing, not an addition. A default whose spec declares an allowlist is not substituted; the job keeps the Positive evidence only, the same rule the retained-session guard follows. Only a NON-EMPTY tuple declines. Mutation-proved in both directions: disabling the gate fails exactly the bypass test (1 failed / 21 passed), and also declining on |
A cron with no explicit agent_id was dispatched as the AcpClient fallback
CLIENT_NAME ("kirocrew"), whose agent config carries none of the default
agent's MCP servers -- so agent-less cron sessions silently ran without the
expected toolset (observed in production). Now mirrors the chat transports'
fallback (transport_dispatch: `self.agent or cfg.agent.default_agent`).
Resolved into a local above the execution branch, applied to the dispatched
agent below it, and only where that resolved agent is still the bare "kirocrew"
floor. All three placements are load-bearing.
Above the branch, because every record created since the execution-context
migration carries execution_context and takes the other arm, so resolving inside
the legacy arm alone leaves the symptom in place for all of them.
Out of the capture, because the captured execution is what bind_session_execution
publishes under the session key, and a persistent_session job (the default)
reuses the stable key cron:{job.id} on every fire; that binder refuses a
candidate differing from the record, so folding the default into the captured
identity makes every later fire of an already-run job raise "session already
belongs to another execution" until it auto-pauses. Only the dispatched agent
carries the default; the captured identity is left byte-for-byte alone, which is
also what keeps the resolved name out of the durable store.
Floor-gated, because a captured template_id that names a real template is a
deliberate selection. A schedule created from a template chat with no `agent`
argument names its template ONLY there, agent_id staying empty (cron.py:381-385),
so an agent_id-only gate reads that job as agent-less. Overriding it would
re-point the job onto the default on every fire while its captured execution and
memory store stayed the original template's, and dispatched_agents_from_disk --
the delete guard's one walk of the dispatch-mirroring rule -- would still report
the old agent, so guard and dispatch would drift. That is the same silent
wrong-agent class this commit fixes, reintroduced on the other arm.
Leaving the shared CronJob untouched is what keeps the resolved name out of
crons.json. CronService hands the callback the live object from self._jobs
(`await self._on_job(job)`) and _save() reserialises self._jobs wholesale, so
mutating job.agent_id would pin an agent-less cron to a concrete agent name on
its first completed run -- the job would stop tracking agent.default_agent.
_cron_callback snapshots its selectors before yielding ("captured selectors,
never the scheduler's mutable job") and job.agent_id has no reader after that
capture, so a write below it reaches nothing.
Gated on agent_sequence_dispatches rather than on a bare agent_sequence: a lone
sequence entry is dormant and dispatch falls through to agent_id, which must
still receive the default. That helper is the one spelling of the gate.
The configured value is accepted only when it is a str, so a malformed default
degrades to the existing "kirocrew" floor rather than reaching the dispatched
agent kwarg. A whitespace-only agent_id is treated as absent at the dispatch
gate, where the comparison is made after .strip(); the capture is not rewritten,
so an already-bound whitespace template_id keeps its recorded value.
|
Both blocking findings were real and both are fixed in 1. The retained-session guard failed open in the case it was written for. Keying it on "did this fire substitute" meant fire N could substitute and defer its reset, the operator could then clear 2. 3. The expected-failures justification is corrected too. It claimed depth 30 is "refused on both platforms"; the test asserts Each fix was reproduced before it was written: the two new/inverted tests fail on the previous head and pass here. Mutation-proved — reverting the guard to the flag fails exactly the cleared-default test (1 of 24), and restoring |
|
This one I am not folding, and the reason is in the adjudication attached to it: The window is real and it is pre-existing, not opened by this change. The finding needs an operator to tighten their own default template's spec strictly between this fire's pre-dispatch read and a spawn inside that same turn. In that window the gate resolves the parent from the persisted capture, which this change deliberately leaves unmutated — it assigns only the local Three things bound it, each verified against source rather than argued:
The prescribed fix is the same change I declined two revisions ago — "make live spawn-policy resolution use the dispatched default template" is the non-durable parent-execution mechanism that requires editing the spawn admission gate in I have folded every other finding this review raised, including two on my own guards in the previous revision where the reviewer was right and my in-code reasoning was wrong. This one I am declining on the mechanism, with its own adjudicator's flag as the supporting evidence. |
|
Heads-up: the |
…ling docs Two test-layer changes in one commit because this repository caps a pull request at two commits (code-review.yml, MAX_COMMITS: 2) and the first is the behaviour change plus the module spec AGENTS.md requires to move with it. Everything here is test-layer: no runtime file is touched. -- Cron default-agent dispatch cover -- Eleven cases, asserting on the agent kwarg get_or_create actually receives -- the only place a default resolved below the capture is distinguishable from one that reaches dispatch. Includes the two assertions this path had no cover for: that the stored CronJob is unchanged after a run (the scheduler hands the callback its live object, so a mutation would reach crons.json via _save), and that a non-str configured default degrades to the floor rather than aborting the dispatch on ExecutionContext's str template_id requirement. Plus the dormant lone-sequence case, a dispatching sequence keeping its own agents, and the explicit-agent and no-default-configured negatives. Two cases cover records that carry an execution_context, which every record created since the execution-context migration does. A captured template_id="researcher" must survive -- a schedule created from a template chat names its template only there, agent_id staying empty -- while a captured template_id="kirocrew" must still pick the configured default up at dispatch. Each dies without one half of the placement: the researcher case fails against an ungated cross-arm override, the floor case against a resolution confined to the legacy arm. -- Gap-list node-id spelling, documented correctly -- Two passages described `windows-expected-failures.txt` entries as "plain node ids ... no `[params]`", and said the matcher "reduces both the list and each collected item to that base form". That is true only for a line without `[`. `_apply_tracked_gap_list` compares a line carrying `[` with its params intact (`_ungrouped_nodeid`), so such a line covers that one parametrization rather than every one -- which is the only way to track a test whose params do not all fail on the platform. `test_seed_audit_uses_rail_tag_not_raw_path` is the existing entry in that form, so the documented rule contradicted the file it documents. Both passages now state the two-spelling rule, in testing-conventions.md and in the matcher's own docstring summary, which had contradicted the parametrization paragraph thirty lines below it. The `@group` stripping those passages describe IS unconditional, and that half is preserved. An earlier revision of this commit also registered two apps-registry symlink tests as Windows expected failures. Upstream has since removed the platform divergence they encoded, so both now pass on Windows and a strict entry for either would XPASS and red the job; the registration is dropped and only the documentation correction remains.
|
Confirmed, and fixed in c14bdd1 — thank you, this was exactly right on both entries. Verified against
So both would XPASS under the strict list, and What changed: the whole registration is dropped — the two node ids and their comment block come out of What I kept: the Commit title and message updated to match, and the PR description section rewritten so it no longer describes a registration that isn't there. Verified locally: |
bolichen97
left a comment
There was a problem hiding this comment.
Re-reviewed on head c14bdd1: the changes I requested earlier are present and verified (sweep 2026-09-30). Superseding my stale CHANGES_REQUESTED; approving.
bolichen97
left a comment
There was a problem hiding this comment.
Reviewed on behalf of the maintainers (sweep 2026-09-30): readiness passed, required checks green on c14bdd1, no blocking review threads, security posture unchanged. Approving and merging.
Problem / Motivation
Goal: An LLM cron job that names no agent runs the agent the operator configured as the default, instead of silently running without its toolset.
A cron LLM job with an empty
agent_idruns the wrong agent. The empty selector reachesexecution_for_storeastemplate_id=... or "kirocrew", and"kirocrew"isAcpClient's ownCLIENT_NAMEfloor — an agent config that carries none of the configured default agent's MCP servers. The job still runs, silently without the toolset the operator expects.Why it matters
The failure is silent: no error, no conflict, no failing test. The job completes on an agent whose config carries none of the expected MCP servers, so the first signal an operator gets is a cron that produced the wrong work. Observed in production on 2026-08-19.
Every chat transport already honours the configured default —
transport_dispatchresolvesself.agent or cfg.agent.default_agent— so cron was the one dispatch path that ignored it. An operator who setsagent.default_agentand leaves a cron's agent blank has expressed the intent unambiguously in both places; only cron failed to act on it.Not a goal
"kirocrew"floor. It is kept deliberately as the degradation path for an unset or non-strconfigured default, so a malformed config cannot abort a dispatch withmissing execution template.agent_sequencepicks agents. A dispatching sequence owns its own dispatch and is left untouched; only a dormant lone entry falls through toagent_id.CronJob, the captured execution, orcrons.json, so an agent-less cron keeps trackingagent.default_agentinstead of being pinned to one agent."kirocrew"floor. A schedule created from a template chat with noagentargument names its template ONLY inexecution_context.template_id,agent_idstaying empty, so anagent_id-only gate would read that job as agent-less and replace a deliberate selection on every fire — the same silent wrong-agent class this PR fixes, on the other arm.execution_contextbranch and applied below it, to the dispatched agent alone, so a job that carries anexecution_contextkeeps the exacttemplate_idit was created with. Both halves of that placement are load-bearing: above the branch because every record created since the execution-context migration carriesexecution_context, so resolving inside theelse:arm would reach only pre-migration jobs and leave the reported symptom in place for everything created since; out of the capture becausebind_session_executionpublishestemplate_idunder the stablecron:{job.id}key and refuses a candidate that differs from what apersistent_sessionjob has already recorded.What changed (motivation → approach → change)
Resolve
config.agent.default_agentinto a local above theexecution_contextbranch in_cron_callback, then apply it below the branch to the dispatchedcron_agentalone, and only where that resolved agent is still the bare"kirocrew"floor. Neither the sharedCronJobnor the captured execution is written to.This is the review's required change ("do not mutate the shared
CronJob; resolve the agent into a local"), and it is also now the only placement that has any effect._cron_callbacksnapshots its selectors before yielding — "captured selectors, never the scheduler's mutable job" — and after that capturejob.agent_idhas no remaining reader in the callback; every downstream consumer reads the resultingcron_agent. A write tojob.agent_idplaced below that capture reaches nothing: no error, no conflict, no failing test, just a cron quietly running on the floor agent.Leaving the shared job untouched is also what keeps the resolved name out of the durable store.
CronServicehands the callback the live object fromself._jobs(await self._on_job(job)) and_save()reserialisesself._jobswholesale, so mutatingjob.agent_idwould pin an agent-less cron to a concrete agent name incrons.jsonon its first completed run, and the job would stop trackingagent.default_agent. Only the dispatched agent carries the default.Two details worth flagging for review:
Gated on
agent_sequence_dispatches(job.agent_sequence)rather than on a barejob.agent_sequence. A lone sequence entry is dormant and dispatch falls through toagent_id, which must still receive the default; that helper documents itself as the one spelling of the gate.The configured value is accepted only when
isinstance(..., str).ExecutionContext.__post_init__requires a strtemplate_id, so a malformed or unset default degrades to the existing"kirocrew"floor instead of aborting the dispatch withmissing execution template.Gated on the resolved
cron_agentbeing the"kirocrew"floor rather than onjob.agent_idalone.bind_cron_memory(cron_service/identity.py:143-152) captures the CREATOR session's execution and overwritestemplate_idonlyif job.agent_id, so a job created from a template chat names its template only in the capturedexecution_context.template_id; comparing the resolved agent is what lets such a job keep it while the reported floor case still picks the default up.Also gated on the capture carrying no
member_id.resolve_member_executionsetstemplate_idtoagent.kiro_agent or "kirocrew", so a cron created from a crew member's chat whose member agent names nokiro_agentcaptures the floor SPELLING withagent_idempty. A floor-only gate reads that as "selected nothing"; substituting there would havebuild_messageinject the substituted template's system prompt and documents into that member's envelope while_resolve_cron_agentstill dispatches the member's ownkiro_agent, and would attribute the usage row to the substituted name.member_idalone does not narrow it far enough, which is the blocking GPT 5.6 finding on this gate: a member predating the identity migration persists nomember_idat all, andwith_templatestates the admitting rule -- such a record "is named byselection_kind == "member"andselection_namealone". The gate therefore also requiresselection_kind != "member", the namespaceExecutionContext.__post_init__constrains to exactly"member"or"template", so it answers "did this capture select a member?" for the persisted and unpersisted member alike. Both capture gates together are still not sufficient, which is the SECOND blocking GPT 5.6 finding on this gate (raised againstd6ceb8c2b) and is fixed here: on thejob.execution_context is Nonearmcron_executionis RECONSTRUCTED rather than loaded --resolve_legacy_executioncallsexecution_for_store, which for a V1 store returnsExecutionContext(None, MemoryStoreRef(name), "template", template_id), hardcoding a nullmember_idand the"template"namespace whatever the schedule selected. A member cron predating the execution-context migration therefore passed BOTH capture gates whilejob.member_idstill named the member, andresolve_cron_memorydeliberately keeps that record dispatching instead of raising ("Older V1 schedules may still carry the historical member selector beside their explicit legacy store",cron_service/identity.py), with nothing backfillingexecution_contexton load -- so the arm stays live and the substitution ran the configured default template against that member's own silo. The gate now also requiresnot job.member_id: on that arm the job record is the only surviving evidence of the selection. A truthy non-strdeclines too, which is the safe direction -- declining leaves the pre-change floor behaviour.Also gated on the SUBSTITUTED VALUE: a default whose agent spec declares
toolsSettings.subagent.availableAgentsis NOT substituted, and the job keeps the floor. This is the THIRD blocking GPT 5.6 finding on this gate (raised against99fded90a) and is fixed here. The substitution reaches the dispatchedagent=only, whilebind_session_executionpublishes the UNSUBSTITUTED capture, and both spawn entry points derive the parent's declaration from that record alone --read_session_execution(parent)->parent_spawn_allowlists(execution.template_id)indashboard/handlers/messaging.pyand the off-loop twin insubagent.py. The floor spelling resolves to(), which_vet_parent_available_agentsadmits as "no declaration to honour", so a restrictive declaration on the substituted template is never consulted and a child it forbids starts. I did not take the prescribed remedy, which was to publish the substituted template as a non-durable parent execution for spawn admission: that is a new cross-cutting mechanism in two files this PR does not touch, whose reviewers are scoped to spawn admission rather than cron, andPR Scope/First Principlesare already flagging ride-alongs here. Narrowing the substitution removes the finding's precondition instead, and a declined job keeps exactly the floor it has onmaintoday, so nothing regresses. Honouring the declaration is worth its own CR. Deny by default: a non-empty tuple declines and so does the reader'sNone, and only()permits the substitution. The first revision of this gate substituted onNone, arguing the spawn gate would refuse anyway from the capture's floor spelling -- a FALSE premise Opus 5 disproved and this revision fixes:agent.pyinstallskirocrew.jsoninto the agents directory andconfig/defaults.jsondeclares"name": "kirocrew", so a readable spec DOES declare the floor name, andparent_spawn_allowlistsanswersNoneonly when NO readable spec declares the name -- for the floor it returns(), which ADMITS.()is "no declaration", the unchanged case.Noneis the reader's UNKNOWN, on which the spawn gate ITSELF refuses -- and it computes that answer from the floor spelling the capture names, so the same unreadable state refuses the spawn whether or not the fire substituted; there is no bypass to close there, and declining would strip the configured default from every agent-less cron on such a host.The substituted default keeps its template namespace.
_resolve_cron_agentcollapses any name that merely keyscfg.agentsinto a crew alias and returns it ascrew_agent, whichresolve_crew_identityhonours verbatim -- binding that member's workspace, pinned model and capability MCP servers.agent.default_agentis a free-formstrin the TEMPLATE namespace with no alias validation (config/sections.py); the alias-namespaced default is a separate field guarded bydefault_agent_not_alias, so an operator naming a crew member in the template field is ordinary input rather than an extreme one. That is the blocking GPT 5.6 finding on this hunk: the collapse would widen an agent-less cron's capabilities and identity with no signal above DEBUG. The substitution therefore calls_resolve_cron_agent(..., template_namespace=True), which returnscrew_agent=""-- the spellingresolve_crew_identitydocuments as opting out ("an explicitcrew_agentwins verbatim -- including"""), notNone, which is its fallback-ENABLED spelling and would letif agent and agent in config.agentsreselect the colliding crew and make the bypass a no-op (config/loader.py:5859-5867). ThatNone-vs-""distinction is the second blocking GPT 5.6 finding on this hunk.kiro_agent/cwdstayNone, so the name dispatches as the template it was configured as, in the default workspace. Consequence, and the intended one: a default that is really only a crew alias now fails closed and loudly with "Agent mode '' is not available" instead of quietly inheriting that crew's identity.Read from
live.snapshot() or self._cfg, not the boot snapshot.agent.default_agentcarries norestart=Truemark, so the config watcher adopts a dashboard/CLI change live whileself._cfgis rebuilt only by unrelated MCP handlers — a boot-only read would keep dispatching the"kirocrew"floor after an operator sets a default, the exact symptom this change removes, until a gateway restart. Same one-liner the sibling resolver below already uses for the same reason.A whitespace-only
agent_idis treated as absent at that dispatch gate — the comparison is made after.strip(). The capture itself is left byte-for-byte alone, so a whitespace job's already-boundtemplate_idis not rewritten.Also in this PR: a gap-list node-id spelling correction
Declared here rather than left as undeclared scope. Two passages documented the
windows-expected-failures.txtspelling rule backwards, and both are corrected:docs/system-specs/common/testing-conventions.mdand_apply_tracked_gap_list's own docstring summary inconftest.py.What was wrong. Both asserted entries are "plain node ids ... no
[params]" and that the matcher "reduces both the list and each collected item to that base form". That holds only for a line without[. A line carrying[is compared with its params intact (_ungrouped_nodeid), so it covers that one parametrization rather than every one -- which is the only way to track a test whose params do not all fail on the platform.test_seed_audit_uses_rail_tag_not_raw_pathis the existing entry in that form, so the documented rule contradicted the file it documents. The docstring summary also contradicted the parametrization paragraph thirty lines below it in the same docstring.The
@groupstripping those passages describe IS unconditional, and that half is preserved. No matcher behaviour changes --conftest.pyis a docstring edit only.An earlier revision of this PR also registered two apps-registry symlink tests as Windows expected failures. That registration is dropped. Upstream has since removed the platform divergence those tests encoded, so both now pass on Windows; a strict entry for either would XPASS and red the job. Only the documentation correction remains.
Also in this PR: a fail-closed retained-session guard
Declared here rather than left as undeclared scope.
GPT 5.6 Reviewraised it as a blocking finding on head8699e0f4aandOpus 5 Reviewupheld it. This PR opens the window, so it closes it.The window. Before this change an agent-less cron dispatched the constant
"kirocrew"floor on every fire, so two consecutive fires could not differ. With the fallback in place they can -- an operator narrowsconfig.agent.default_agentbetween fires. Three facts then compose: the cron session key is the stablecron:{job.id}with no agent term; the post-run reset is DEFERRED while_subagent_work_pending(...)or_cron_injecting > 0; and the claim path returns the livesession.providerwithout ever comparing theagentkwarg (session_allocation.py:1913-1961). So the next fire builds agent B's context and reuses agent A's runtime, leaving A-only capability MCP servers, workspace and pinned model reachable.It defers; it does not reset. A retained session implies pending subagent work -- the no-pending case already reset in the prior fire's
finally-- so resetting to obtain a correct runtime would destroy work in flight. The guard routes through the existing_defer_cron_before_dispatch, which marks the run retained (run_never_started, so adelete_after_runjob is not consumed) and records the reason onlast_errorWITHOUT callingrecord_failure(), so a transient state cannot auto-pause a job that never ran a line. The deferral is temporary by construction:_subagent_doneclears the pend and the reaper still targets the key, so it cannot become permanent.Scoped to the AGENT-LESS PREDICATE (
not job.agent_id.strip() and not agent_sequence_dispatches(job.agent_sequence)), which is exactly the window this PR opens. It is deliberately NOT keyed on whether this fire substituted: that spelling failed open in the case the guard exists for, which Opus 5 raised as blocking againstd2df4f420and this revision fixes -- fire N substitutes and defers its reset, the operator clearsagent.default_agent, fire N+1 resolves an empty default so the flag is false, the guard is skipped, and the fire runs the FLOOR's context on the process still holding the previous default's runtime. Every other reason for declining the substitution reaches the same hole. A job pinningagent_iddispatches one name on every fire, so its own stale-session case predates this change and fixing it here would newly defer fires for jobs this PR does not touch. The sequence path is immune for a different reason -- it keys per agent (f"cron:{job.id}:{agent}"), so a changed agent already lands on a different session.Positive evidence only, and that is load-bearing. The guard fires only on a non-empty
strfrom_get_session_agentthat differs from the dispatched name. No reader, an unreadable reader, a non-strand""all behave exactly as before. Deferring on a silent reader would stall every agent-less cron on such a host forever, which is a worse failure than the widening being closed. Fail-closed here means refusing the unsafe REUSE, not treating an unanswerable question as a mismatch.docs/system-specs/modules/learn-cron-dashboard.mdis updated in the SAME commit as the code, whichAGENTS.md:203-204makes a MUST.Backwards compatibility
Compatible. The fallback fills
agent_idonly when it is empty or whitespace-only and noagent_sequencedispatches; nothing that main accepts today is rejected, renamed or removed. A job with an explicitagent_iddispatches exactly as before, an unset or non-strconfig.agent.default_agentstill degrades to the existing"kirocrew"floor, and neither the sharedCronJobnorcrons.jsonis written to.Tests
New
TestCronDefaultAgentintest/test_cron_gateway_integration.py— 24 cases. Most assert on theagentkwargget_or_createactually receives, which is the only place the dispatch difference is observable; one also asserts on the execution the binder publishes, which is where the durable half is observable; and the retained-session mismatch case assertsget_or_createis never reached at all, plus the retention markers_defer_cron_before_dispatchsets:CronJobafter that runagent_idunchangedagent_idagent_id"kirocrew"floor"kirocrew"floor, dispatch completestemplate_id="kirocrew"template_id="researcher"researchertemplate_id="kirocrew""kirocrew"member_idexecution_context,job.member_idset)availableAgents"kirocrew"floorNone)agent_idjob past a stale sessionget_or_createnever calledstragent_idpast a stale sessionThe suite discriminates in both directions, verified by mutation rather than asserted. Against a write placed below the capture the dispatch cases fail identically, which is the silent no-op demonstrated; against a mutating placement the stored-record assertion fails as well. The bind case fails on its own against a version that folds the resolved default into the captured execution. The
researchercase fails against an ungatedcron_agent = _default_agent or cron_agent(assert 'configured-default' == 'researcher'), and the floor-captured case fails against a resolution confined to theelse:arm — so the two halves of the placement each have a test that dies without them. The member case fails against a floor-only gate (assert 'configured-default' != 'configured-default') and the live-config case fails against a boot-snapshot read (assert 'stale-boot-default' == 'live-default').test_a_legacy_member_with_no_member_id_keeps_its_own_agentfails against the removal of theselection_kindterm alone (assert 'configured-default' != 'configured-default') and no other case does, so that term carries its own guard.test_a_default_naming_a_crew_alias_does_not_inherit_that_crewfails against the removal of thetemplate_namespacegate alone (assert 'kirocrew' == 'shared-name'), proving the collapse really did hijack the template name into the crew'skiro_agent. It assertscrew_agent == ""exactly rather than merely falsy, and fails against theNonespelling (assert None == '') -- the assertion the reviewer correctly identified as too weak when it readnot kwargs["crew_agent"]. The retained-session guard's three clauses were verified the same way, each arm caught and the control restored byte-identical: dropping the_default_substitutedgate fails 1 case (the explicit-agent one), droppingisinstance(_live_agent, str)fails 9, and inverting!=to==fails 2 (the mismatch and same-agent cases). Theisinstancearm failing 9 is itself the evidence for that clause:_make_gw_for_llmleavessessionsaMagicMock, so the reader answers a non-strin every pre-existing case, and without the type check the guard would defer them all.test/test_cron_gateway_integration.pyalone: 130 passed. Whole cron suite (114 files matchingtest/*cron*.py): 3225 collected, 3221 passed, 4 skipped, 0 failed. flake8 and black clean on both files. Rebased onto5332beab7, which contains thecron.py->cron_servicesplit (#14615); the figures above and thecron_service/identity.pycitations are both measured against that base.The two
xdistfailures reported against an earlier head (test_cron_reaper,test_cron_resilience) are INHERITED, not introduced by this change. Running those two files on cleanmainwith both of this PR's files reverted to main's version failed them 1, then 5, then 0 times across three consecutive runs. The cause isxdistworker-count variance under host memory pressure: the worker budget is chosen from free memory at collection time (3 of 16 workers on the full run above, 4 of 16 on the run that showed failures), and those two modules are order-sensitive across that split. One run of either arm therefore proves nothing in either direction, and the full-suite figures above are from a single 3-worker run.Pattern harvest
Rule candidate: grep
Pattern: a dispatch path that resolves an agent selector without applying the
agent.default_agentfallback its sibling transports already apply.The defect was not the floor itself but its reach:
transport_dispatchresolvesself.agent or cfg.agent.default_agentfor every chat transport, and cron was the one dispatch path that read the selector and stopped at the"kirocrew"CLIENT_NAMEfloor. A grep for selector reads that pass straight intotemplate_id=... or "kirocrew"without consulting the configured default enumerates the whole family, and the same shape would catch any future transport added alongside cron.