Repository navigation
feat(cron): per-job project directory so agent crons load repo steering - #13408
billygerhard wants to merge 1 commit into
Conversation
2abc5a6 to
e7e8f06
Compare
Design Review (Opus 5.5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: the field is additive, nothing is taken away, and the patch changes no dashboard surface. Notes
[DESIGN-REVIEWED] 2f85cbe Description read[DESCRIPTION-READ] 3e012039b49011abcc2a20e104cd9dfee12360cfc7e33900a591d98f245bd636 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, fork) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks: the field is optional and off by default, and the agent-root confinement protects a real boundary. Two items are larger than the Goal needs. Notes
What this change shipsInventory (10 items) — 8 justifiedIntent: let a scheduled agent job run inside a named repository so that repo's steering loads. ADDITION.
[FIRST-PRINCIPLES-REVIEWED] 2f85cbe Description read[DESCRIPTION-READ] c37990e3e11cc7eb17923ff43f555a1c42e392fab1ee52c79a48e862f5a76fdb That sha256 names the PR description this verdict read. Recompute it with |
GPT 6.1 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed |
e7e8f06 to
0133459
Compare
7b12f9d to
70074e5
Compare
|
Consolidation: PR #9201 adds the same cron per-job directory under a different field name PR #9201 ("feat(cron): bind scheduled jobs to a project's agents", opened 2026-09-07) adds an optional What PR #9201 has and this PR lacks: project-agent resolution, owner gates on the REST routes, the JobForm UI, and the What this PR has and PR #9201 lacks (checked at its head f99c975):
Suggestion: make PR #9201's
From a full open-PR audit against origin/main c66f95b (2026-09-25); findings were checked by independent reviewers reading the code. Reply here if this is wrong. |
70074e5 to
6996c1d
Compare
3b93755 to
8c5ca30
Compare
8c5ca30 to
d5107fb
Compare
d5107fb to
9c91af9
Compare
UX Review (Opus 5.5, fork) — ⏭️ skippedRevision |
|
HOLD: reserved for human review, with an open product decision. Reviewed at 4bc8738. This PR adds a new admission rule. An agent-authored cron may root its session only in a directory that passes the new Other blockers:
To clear: a maintainer picks the field (#9201 or this PR), the author replies to each AI item, and a human signs off on the confinement and conversation-ending paths. — crew-pr-reviewer (r120) |
|
Author replies to the open AI notes on First Principles item 2 (validator duplicates First Principles item 5 ( Design note 1 (a cwd-mismatch reset belongs in Design note 2 ( Reviewer point (wake-time recheck does not re-apply Field name ( |
|
HOLD at 4bc8738, reserved for human review, with an open product decision. The head is unchanged since r120. Thank you for the replies: each AI note on this head now has one (reply). The reasons for a separate validator (no second resolution of the persisted path) and for keeping the reset in the cron layer are sound for this PR. First Principles item 5 (the What still blocks:
I found no definite defect. CI is green on this head. I ran no PR code locally. Reviewed head: 4bc8738 — crew-pr-reviewer (r121) |
|
Human design review is required before this PR can merge. Per-job project directories change cron scope, steering input, session reuse, and path safety. A maintainer must approve those choices for this head. This comment records the design gate only; it is not a code defect. |
|
HOLD at This head is a rebase of What would clear this hold:
— crew-pr-reviewer (r126) |
|
Author replies to the notes on First Principles item 6 and Design note 1 (description says Windows machinery was removed, yet First Principles item 1 (an alias Design note 2 (settle on one field before both #9201 and this PR ship). Agreed; that is the maintainer ruling the hold already names, and I will rename or drop the marker as ruled. No code change on this head; the lanes are all non-blocking and CI is green. |
|
HOLD at d869297: reserved for human review, with a product decision still open. Thanks for the replies. Every Design and First Principles note on this head now has an answer, and the description now says why What still needs a maintainer:
— crew-pr-reviewer (r127) |
An LLM-message cron ran in the gateway's default working directory, a Kiro Crew-internal scratch path with no .kiro/steering/ of its own, so a job doing real repository work never loaded that repository's steering (kiro-cli resolves an agent's steering resources relative to its cwd). Every repo policy had to be restated inline in the job's message, where it silently drifts from the real steering files. CronJob gains project_dir: the store validates and persists the realpath of an existing, non-sensitive, absolute directory (refused on script/command jobs, which launch no session); the gateway roots the job's session there (cwd= on get_or_create), resets a live persistent session whose cwd moved so it cold-starts in the project, and fails a wake whose directory is gone rather than running it unscoped. Exposed on MCP cron_add/cron_update (and cron_list), `kirocrew cron add/update --project-dir`, and the dashboard REST create/update/list routes. Closes kirodotdev#13349
|
Closing as superseded by #9201, following the consolidation note on 2026-09-25: both PRs add the same per-job cron directory, #9201 hosts, and @mbajaj92 if any of the pieces listed in that note are useful to #9201 (the canonical sensitivity re-check at fire time, the refusal of the field on script/command jobs, or the MCP Issue #13349 stays open until #9201 (or that follow-up) covers it. |
Problem / Motivation
Goal: A cron job can name the repository it works in, and its session behaves like a dashboard chat rooted at that project -- loading that repository's steering instead of restating it inline.
An LLM-message cron job runs in the gateway's default working directory, a Kiro Crew-internal scratch path that has no
.kiro/steering/of its own. A job whose whole purpose is repository work (triage this repo's issues, review its PRs, run its checks) therefore never loads that repository's steering: kiro-cli resolves an agent's steering resources relative to its cwd, and the cwd is not the repo.Why it matters
Scheduled jobs are exactly the unattended path where drift between "what the repo's steering says" and "what the job was told months ago" goes unnoticed the longest. Without a project root the job also has no
[PROJECT]context line, so file search and code references in its turn are not scoped either.Not a goal
project_dir: no default, loop, monitor or command behaviour moves for an unscoped job._screen_windows_linksandis_unc_shapehelpers, reused as-is: on Windows, resolving a path follows each link's target, so a locally spelled project whose link points at a\\server\sharewould makerealpathitself the SMB probe; the shared screen runs before resolution so that path is refused without touching the share. No new Windows machinery is introduced.project_pathproposed in feat(cron): bind scheduled jobs to a project's agents #9201: which PR carries the field is a maintainer decision left to that thread, not made here.What changed (motivation → approach → change)
Approach: reuse the cwd the session layer already accepts (
get_or_create(cwd=...), the same argument a dashboard slot's project passes). The field is validated once at authoring in the store's single locked writer, and re-validated at every fire because the directory can vanish or a hand-edited store can point somewhere sensitive.Change:
CronJob.project_dir(store):validate_cron_project_dir(cron_service/fields.py) applies the same absolute/realpath/not-sensitive/isdirrule the dashboard's chat-folder validator applies to a folder's project directory, persists therealpath, caps the retained value, refuses a UNC/network spelling beforerealpathcan contact a host, and refuses the field on script/command jobs. Enforced atbuild_job(create) andapply_job_updateunder_update_job_locked(update), the one chokepoint every surface converges on.slack/gateway_runtime/cron_fire.py,cron_turn.py): the project is re-validated off-loop (revalidate=True: the fresh resolution must spell the persisted canonical value, so a component relinked since authoring is refused as a SEL-auditedmoveddenial rather than followed) and passed ascwd=toget_or_create; the[PROJECT]context line names it (build_message(project=...)). A vanished or now-sensitive directory fails the wake rather than running it unscoped.get_or_createresumes a key's stored conversation at the cwd it was rooted at, so a persistent job whoseproject_dirwas set, changed or cleared would otherwise keep running in the old directory. The store records the old project inproject_dir_wason a change or clear; a wake that reads the marker ends the conversation outright before claiming its session, through the existingSessionManager.discard_conversation(key, skip_if_busy=True)(one lock hold: pops the live session if any, drops the resume sid, ends the conversation's sub-agent runs; the map entry survives), and fails the wake when that is declined because the session is busy on another surface. The marker is cleared by compare-and-swap once every agent key is re-rooted, and that clear is committed BEFORE the wake's first turn (a sequence ends every step key's old conversation first, then clears): a marker still set once turns have started would make the next wake end those keys again and cancel the work they left running in the new project, so a store that cannot take the clear (busy, unreadable) fails the wake while nothing new has started. For apersistent_session=falsejob the stable key's conversation is ended too before the clear. A job with neither field set is left where its session sits. The marker exists because""alone cannot tell "cleared" from "never set", and an unscoped legacy job must never have its conversation ended by this check. This mirrors the dashboard's own project change, which resets the slot's session and lets the next claim cold-start at the new directory.get_or_createignorescwdfor a session already live on the key, so a session a dashboard follow-up installed between the end and the claim, or a conversation fork that restored the stored cwd, can come back rooted elsewhere. The wake judges the session it was handed (_rooted_elsewhere: not at the project; for a cleared field, not at the alias workspace it fell back to, or with no cwd at all still in the previous one), releases it, ends that conversation once through the samediscard_conversation(this is also how a job given its FIRST project -- which sets no marker -- leaves a conversation that began at the default) and claims again; a second mis-rooted hand-back or a declined end fails the wake rather than run in the wrong repository. No session-layer API changes.cron_add/cron_updatehandagent.subagent_cwd_allowed_rootsto the store, which judges containment on the canonical value it persists inside the same locked operation (CronProjectDirOutOfScope, audited as adeniedauthz tool event);kirocrew cron add/updatepass the same roots, since an agent with shell access reaches the CLI as easily as the tool; only the owner-authenticated dashboard REST routes are not confined.cron_add/cron_updateacceptproject_dirandcron_listshows it (JSON mode redacts it like every sibling field);kirocrew cron add|update --project-dir; dashboard REST create/update accept it and list serializes it redacted. Thecron_addtool description and thekirocrew-commandsskill carry the agent-path guidance (a repo-work job should setproject_dirunder a configured allowed root).operation=cron.project_dir) attributed to the invoking surface (cli, the MCP session key, the dashboard user,cron:<id>at fire time) via anaudit_callercall parameter that is never persisted -- the same shape the chat-folder validator emits.docs/system-specs/modules/learn-cron-dashboard.mdgains theproject_dirsection; the feature map's Schedule row names the capability and its surfaces.No RFC: this adds an optional field; no default, loop, monitor or command behaviour changes for a job that does not set it.
Backwards compatibility
No existing surface changes behaviour and no session-layer API changes: the wake uses
get_or_create(cwd=...)anddiscard_conversation(skip_if_busy=True)as they exist today. Two frozen inventories (CronServicemember digests, the gateway composition contract) gain the new parameters' rows.Tests
test/test_cron_project_dir.py(102 tests):is_sensitive_canonical_pathon the computed realpath, not the pool-bounded resolver; the refusal is SEL-audited with the calling surface.project_dir_wasis written by the store on change/clear, never by a caller, and cleared only by the compare-and-swap against the pair the wake read (CronPendingMismatchotherwise).[PROJECT]line emitted for a scoped job and not for an unscoped one; session rooted at the project; unset keeps the default cwd; a scoped job that was not rescoped keeps its conversation; a rescoped or cleared job ends its conversation before the claim and settles the marker; a declined end fails the wake and keeps the marker, and is never reclassified as a model failure; a session handed back in the wrong directory is ended once and claimed again, a second one fails the wake, a first project on a job with a conversation at the default ends it once, A->B->A is at the project (an equivalent symlinked spelling is not refused); a stateless job's stable key is ended before the settle and a busy one fails the wake before its turn (single and sequence); a rescope landing during the wake keeps the marker; a store that cannot clear it fails the wake before the turn (single agent and sequence alike, the sequence having ended every step key and cleared before its first step); a component relinked since authoring fails the run and is auditedmoved; on Windows links along the path are screened (sharedhooksscreen) beforerealpathso a link to a UNC share is refused without the resolution probing the share; a project refused at wake time (vanished, relinked, sensitive) is alerted and counted toward auto-pause like any failed run; the alias workspace is the fallback for a cleared field.audit_caller="cli"and the allowed roots through the single store call, and a real-store test refuses an out-of-root--project-diron add and update.Inventory/contract tests updated:
test_cron_service_bindings.py,test_slack_gateway_composition_contract.py,test_cron_refactor_contract.py(the facade seam list),test_cron_string_field_validation.py;test_cli.pypinned call signatures gainaudit_caller="cli";test_slack_gateway_cron.pyjob harnesses set the two fields to"".Manual verification
The cron/gateway seam is covered by unit tests that drive the real cron fire path against a fake session layer and assert the
cwd=handed toget_or_create, the end-before-claim ordering, and the release of a mis-rooted session. No UI change (the Schedule form has no control for the field yet; the REST, CLI and MCP surfaces carry it).Related Issues
Closes #13349
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)