Skip to content

feat(cron): per-job project directory so agent crons load repo steering - #13408

Closed
billygerhard wants to merge 1 commit into
kirodotdev:mainfrom
billygerhard:feat/cron-project-dir
Closed

billygerhard wants to merge 1 commit into
kirodotdev:mainfrom
billygerhard:feat/cron-project-dir

Conversation

@billygerhard

@billygerhard billygerhard commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

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

  • Changing anything for a job that does not set project_dir: no default, loop, monitor or command behaviour moves for an unscoped job.
  • Scoping script/command jobs: they launch no session, so the field is refused on them rather than given a meaning.
  • A second steering-loading mechanism: the job reuses the cwd the session layer already accepts for a dashboard slot's project.
  • Hardening the agent spawn path, or any other surface's project-directory validation (chat folders, slot projects): this PR touches cron only. An earlier revision carried a spawn-time work-dir pin, a Windows volume-GUID cwd and a Windows probe CI job; every reviewer judged them oversized for this feature and they have been removed. What stays in the cron validator is the repository's existing _screen_windows_links and is_unc_shape helpers, reused as-is: on Windows, resolving a path follows each link's target, so a locally spelled project whose link points at a \\server\share would make realpath itself the SMB probe; the shared screen runs before resolution so that path is refused without touching the share. No new Windows machinery is introduced.
  • Reconciling this field with the project_path proposed 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/isdir rule the dashboard's chat-folder validator applies to a folder's project directory, persists the realpath, caps the retained value, refuses a UNC/network spelling before realpath can contact a host, and refuses the field on script/command jobs. Enforced at build_job (create) and apply_job_update under _update_job_locked (update), the one chokepoint every surface converges on.
  • Gateway wake (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-audited moved denial rather than followed) and passed as cwd= to get_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.
  • Rescope ends the conversation: get_or_create resumes a key's stored conversation at the cwd it was rooted at, so a persistent job whose project_dir was set, changed or cleared would otherwise keep running in the old directory. The store records the old project in project_dir_was on a change or clear; a wake that reads the marker ends the conversation outright before claiming its session, through the existing SessionManager.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 a persistent_session=false job 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.
  • Claim check: get_or_create ignores cwd for 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 same discard_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.
  • Agent confinement: MCP cron_add/cron_update hand agent.subagent_cwd_allowed_roots to the store, which judges containment on the canonical value it persists inside the same locked operation (CronProjectDirOutOfScope, audited as a denied authz tool event); kirocrew cron add/update pass 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.
  • Surfaces: MCP cron_add/cron_update accept project_dir and cron_list shows 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. The cron_add tool description and the kirocrew-commands skill carry the agent-path guidance (a repo-work job should set project_dir under a configured allowed root).
  • Audit: the sensitive-path and network-spelling refusals are security decisions, so the validator records a SEL denial (operation=cron.project_dir) attributed to the invoking surface (cli, the MCP session key, the dashboard user, cron:<id> at fire time) via an audit_caller call parameter that is never persisted -- the same shape the chat-folder validator emits.
  • Docs: docs/system-specs/modules/learn-cron-dashboard.md gains the project_dir section; 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=...) and discard_conversation(skip_if_busy=True) as they exist today. Two frozen inventories (CronService member digests, the gateway composition contract) gain the new parameters' rows.

Tests

test/test_cron_project_dir.py (102 tests):

  • Validator: empty/None mean unset; relative, missing, non-directory, sensitive, UNC, non-string and oversize paths refused (the cap also on the canonical value); realpath persisted (symlink collapses); tilde expands; the sensitive verdict comes from is_sensitive_canonical_path on the computed realpath, not the pool-bounded resolver; the refusal is SEL-audited with the calling surface.
  • Store: agent roots are confined on the value persisted (the dashboard passes no roots; an empty allowlist admits nothing; the raw string is resolved once; an out-of-scope add persists nothing and an out-of-scope update keeps the old root); add/update/clear round-trip; project_dir_was is 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 (CronPendingMismatch otherwise).
  • Gateway (real cron fire path against a fake session layer): [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 audited moved; on Windows links along the path are screened (shared hooks screen) before realpath so 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.
  • MCP, dashboard REST and CLI surfaces: field accepted, refused, cleared, listed redacted; CLI add/update pass audit_caller="cli" and the allowed roots through the single store call, and a real-store test refuses an out-of-root --project-dir on 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.py pinned call signatures gain audit_caller="cli"; test_slack_gateway_cron.py job 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 to get_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

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@billygerhard
billygerhard requested review from a team and dwu96 September 24, 2026 16:21
@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: action required A blocking check or review needs attention labels Sep 24, 2026
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Sep 24, 2026
@github-actions

github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5, fork) — ✅ PASS

Design-level review of 2f85cbe18e826d9f36ed50e51d0f699ab66b16c0 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks: the field is additive, nothing is taken away, and the patch changes no dashboard surface.

Notes

  • The rescope handling has many moving parts: the project_dir_was marker, a compare-and-swap clear, a second claim, and ending each sequence key before its first turn. Keying the persistent session on the project would remove most of that, but it would break the cron-{id} tab and chat-folder identity, so the current shape is defensible. Keep the learn-cron-dashboard.md section as the single source of truth for it.

[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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5, fork) — ✅ PASS

Premise-level review of 2f85cbe18e826d9f36ed50e51d0f699ab66b16c0 via the fork AI-review pipeline — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

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

  • Item 4 — oversized: the project_dir_was marker, the compare-and-swap clear, _settle_rescope, _end_rescoped_conversation and the sequence pre-end exist only for the cleared case. _rooted_elsewhere plus discard-and-reclaim already re-roots a set or changed project ("this is also how a job given its FIRST project … leaves a conversation"). Subtraction: delete project_dir_was and its CAS/settle path, so that _rooted_elsewhere alone re-roots a session. Clears when: the mechanism is removed, or a human amends the Goal.
  • Item 10 — duplicate of hook_runtime/safe_reads.py::screen_file_path, which already does the UNC check before realpath, the Windows link screen, expanduser, realpath and the sensitive-path check. validate_cron_project_dir writes that chain out again with three is_unc_shape calls plus _screen_windows_links, and this is a third spelling next to chat_folders_paths._validate_project_dir. Subtraction: canonicalise through screen_file_path, and keep only isdir, the length cap, the moved compare and the roots check.

What this change ships

Inventory (10 items) — 8 justified

Intent: let a scheduled agent job run inside a named repository so that repo's steering loads. ADDITION.

  1. Agent cron jobs can name a project directory, and the wake runs rooted there — justified
  2. The [PROJECT] context line names it on cron wakes — justified
  3. A wake whose directory is gone, relinked or now sensitive fails, alerts and counts toward auto-pause — justified
  4. Changing or clearing the directory ends the job's conversation at the next wake (persisted project_dir_was marker) — oversized
  5. A claimed session rooted elsewhere is ended and claimed again; a second mismatch fails the wake — justified
  6. MCP and CLI values are confined to subagent_cwd_allowed_roots, and denials are audited — justified
  7. Sensitive-path and network-path refusals write SEL denials under cron.project_dir — justified
  8. --project-dir on the CLI, MCP cron_add/cron_update fields, REST create/update, and list output — justified
  9. Dashboard create now builds the job off the event loop — justified
  10. A cron-specific UNC, link-screen and realpath canonicaliser — duplicate of hook_runtime/safe_reads.py::screen_file_path

[FIRST-PRINCIPLES-REVIEWED] 2f85cbe

Description read

[DESCRIPTION-READ] c37990e3e11cc7eb17923ff43f555a1c42e392fab1ee52c79a48e862f5a76fdb

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review (fork) — ✅ no blocking findings

Reviewed 2f85cbe18e826d9f36ed50e51d0f699ab66b16c0 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 2f85cbe

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 24, 2026
@github-actions

github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review (fork) — ✅ no blocking findings

Reviewed 2f85cbe18e826d9f36ed50e51d0f699ab66b16c0 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 2f85cbe

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 24, 2026
@billygerhard
billygerhard force-pushed the feat/cron-project-dir branch 6 times, most recently from 7b12f9d to 70074e5 Compare September 24, 2026 22:12
@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Sep 25, 2026
@bolichen97

Copy link
Copy Markdown
Contributor

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 CronJob directory that becomes the cron session's cwd, so the repo's steering loads. That is the same mechanism as this PR. This PR calls the field project_dir (src/kiro_crew/cron.py:982). PR #9201 calls it project_path. Both validate it in the store, check it again at fire time, and pass it as cwd= inside _acquire_with_model_fallback. The two branches conflict in cron.py, dashboard/handlers/cron.py and slack/gateway.py. Merging both would ship two fields for one concept.

What PR #9201 has and this PR lacks: project-agent resolution, owner gates on the REST routes, the JobForm UI, and the [PROJECT] line. It passes project=job.project_path to build_message. This PR's spec text and MCP description promise that line, but the diff never passes project=. Main only emits it when project is set (context.py:5317).

What this PR has and PR #9201 lacks (checked at its head f99c975):

Suggestion: make PR #9201's project_path the single field. Port the items above as a follow-up on top of it, or have PR #9201 adopt them. When porting:

  • Forward require_cwd through the recursive retries and the won-race return, as the GPT and Opus reviews here point out.
  • Leave out the unscoped retire at slack/gateway.py:5400. It ends conversations for jobs that never set the field (Opus BLOCKING above).
  • You probably don't need conversation_root / discard_conversation_root. On main, cron: keys are stateless (session.py:523, session_allocation.py:1623-1628), so they never read or write a session-map row.

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.

@github-actions github-actions Bot removed the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Sep 25, 2026
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 26, 2026
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 26, 2026
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 26, 2026
@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5, fork) — ⏭️ skipped

Revision 2f85cbe18e826d9f36ed50e51d0f699ab66b16c0 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@iamwhatever

Copy link
Copy Markdown
Contributor

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 validate_cron_project_dir: confined to agent.subagent_cwd_allowed_roots, refused for sensitive paths and UNC/link screening, with SEL denials (fields.py#L138-L265). It also ends conversations, and their sub-agent runs, on a rescope (cron_fire.py#L808-L840). Changes like these are reserved for a human reviewer. I found no definite defect. One point for that reviewer: the wake-time recheck does not re-apply the allowed roots, so narrowing them later does not stop an existing job (cron_fire.py#L572).

Other blockers:

  1. Open product choice: bolichen97 noted that feat(cron): bind scheduled jobs to a project's agents #9201 adds the same field as project_path and suggested one field. This PR leaves that to a maintainer, and nobody has replied.
  2. Unanswered AI notes on this head. First Principles item 2 says the validator duplicates validate_file_path. First Principles item 5 calls the project_dir_was marker machinery oversized. Design Review has two notes: fixing the cwd-mismatch reset in SessionManager, and a future JobForm round-tripping the field.

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)

@billygerhard

Copy link
Copy Markdown
Contributor Author

Author replies to the open AI notes on 4bc8738232, as the hold asks.

First Principles item 2 (validator duplicates validate_file_path / _validate_project_dir). The cron validator reuses the two parts that are reusable as-is: is_unc_shape and _screen_windows_links from hooks. It does not sit on validate_file_path because that helper re-resolves the candidate it is given, and the cron rule needs to judge the persisted spelling without a second resolution (the symlink-swap case GPT raised on an earlier head). Building on chat_folders_paths._validate_project_dir would mean touching the chat-folder surface, which an earlier First Principles round asked this PR not to do. A shared helper is a reasonable follow-up once a maintainer picks where it should live.

First Principles item 5 (project_dir_was only matters for a cleared field). Correct: set and changed are handled by the post-claim check and re-claim; the marker exists so that clearing the field ends the old repo-rooted conversation instead of silently reusing it at the default. If the maintainer prefers "a cleared job behaves like one that was never scoped" (the old conversation keeps running at the old repo until it ends on its own), I will delete the marker, _settle_rescope and the sequence pre-end path in one commit. That is a product call I did not want to make unilaterally.

Design note 1 (a cwd-mismatch reset belongs in SessionManager). Agreed as the long-term home. This PR keeps it inside the cron layer because an earlier round asked for the session-layer additions to be removed; it uses only existing SessionManager verbs (discard_conversation, release). If a second caller needs a session at a new cwd, lifting the check into SessionManager is the right follow-up.

Design note 2 (JobForm round-trip). Acknowledged and noted in the feature map. When the form gains a control it must send the field back unchanged on edit.

Reviewer point (wake-time recheck does not re-apply allowed_roots). Intentional, but worth the human reviewer's eye: the roots confine agent-authored values at admission (the MCP path passes them; the CLI and REST paths, operated by a human, do not). The job record carries no author kind, so re-applying the roots at every wake would also refuse operator-authored jobs that legitimately sit outside them. If narrowing the roots should stop existing agent jobs, the smallest change is to persist an "agent-confined" flag at admission and re-check only those jobs at wake; I will add it on request.

Field name (project_dir vs #9201's project_path). #9201 is open, last updated 2026-10-07, with a wider scope (binding a job to a project's agents). I will rename to whichever a maintainer picks.

@iamwhatever

Copy link
Copy Markdown
Contributor

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 project_dir_was marker) is left to a maintainer, as you say.

What still blocks:

  1. A maintainer picks one field: this PR's project_dir or feat(cron): bind scheduled jobs to a project's agents #9201's project_path (bolichen97's note). The same ruling settles whether a cleared field must end the old conversation, which decides whether the marker stays.
  2. A human signs off on the new admission rule (fields.py#L138-L265) and the conversation-ending path (cron_fire.py#L808-L840). That includes the wake-time recheck, which does not re-apply the allowed roots (cron_fire.py#L572).
  3. If a maintainer accepts any of the follow-ups you offered (a shared path helper, the reset in SessionManager, an agent-confined flag), please open one issue for each and link it in the description.

I found no definite defect. CI is green on this head. I ran no PR code locally.

Reviewed head: 4bc8738

— crew-pr-reviewer (r121)

@bolichen97

Copy link
Copy Markdown
Contributor

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.

@iamwhatever

Copy link
Copy Markdown
Contributor

HOLD at d869297e82f54fec52be6af69a30127a7873b7f9. This one is reserved for human review, and a product decision is still open.

This head is a rebase of 4bc8738. The range-diff shows only test adjustments from main, so the r121 points still apply. The PR adds an admission rule for which directories an agent-authored cron may root its session in (fields.py). It also ends conversations and their sub-agent runs on a rescope (cron_fire.py). A human needs to sign off on both. I found no definite defect, and CI is green.

What would clear this hold:

  1. A maintainer picks one field, this PR's project_dir or feat(cron): bind scheduled jobs to a project's agents #9201's project_path. That ruling also decides whether the project_dir_was marker stays. @bolichen97 has recorded a human design gate for this head.
  2. Reply to the new notes on this head from Design and First Principles (item 6). ## Not a goal says the Windows machinery was removed, but validate_cron_project_dir still runs _screen_windows_links and the UNC refusals. Either drop that branch or correct the description.
  3. Open one issue for each follow-up a maintainer accepts (a shared path helper, the reset in SessionManager, an agent-confined flag), and link it in the description.

— crew-pr-reviewer (r126)

@billygerhard

Copy link
Copy Markdown
Contributor Author

Author replies to the notes on d869297e82 (rebase-only head), as the r126 hold asks.

First Principles item 6 and Design note 1 (description says Windows machinery was removed, yet _screen_windows_links and the UNC refusals remain). The description was stale and is now corrected. What was removed is the spawn-time work-dir pin, the Windows volume-GUID cwd and the Windows probe CI job. What stays is the reuse of two existing hooks helpers, _screen_windows_links and is_unc_shape, with no new Windows code of this PR's own. The branch stays because of a real finding on an earlier head: on Windows realpath follows each link's target, so a locally spelled project whose link points at \\server\share would make the resolution itself the SMB probe; the shared screen runs before resolution so that path is refused without touching the share. Dropping the branch and keeping only the lexical UNC check would reopen that gap, so I kept it and fixed the text.

First Principles item 1 (an alias workspaces entry can already root a cron job). Agreed, and noted as a note rather than a finding: the alias route is per-agent and needs an alias per repository; this field is per-job and needs none.

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.

@iamwhatever

Copy link
Copy Markdown
Contributor

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 _screen_windows_links and the UNC refusals stay, so item 2 of the r126 hold is cleared. I found no definite defect, and CI is green.

What still needs a maintainer:

  1. The PR adds an admission rule for which directories an agent-authored cron may root its session in (fields.py), and a rescope ends the job's conversation and its sub-agent runs (cron_fire.py). A human has to sign off on both; @bolichen97 has recorded that design gate.
  2. Pick one field, this PR's project_dir or feat(cron): bind scheduled jobs to a project's agents #9201's project_path. That ruling also decides whether the project_dir_was marker stays.

— 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
@billygerhard

Copy link
Copy Markdown
Contributor Author

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 project_path stays the only field.

@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 cron_add / CLI --project-dir surfaces), I'm happy to send them as a small follow-up PR against project_path once #9201 lands.

Issue #13349 stays open until #9201 (or that follow-up) covers it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor) merge conflict Branch has merge conflicts with its base — author must resolve before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cron: no per-job project directory, so LLM crons never load project-scoped .kiro/steering/

3 participants