Skip to content

feat(cron): bind scheduled jobs to a project's agents - #17554

Closed
kyleseaman wants to merge 2 commits into
mainfrom
feat/cron-project-agents
Closed

kyleseaman wants to merge 2 commits into
mainfrom
feat/cron-project-agents

Conversation

@kyleseaman

@kyleseaman kyleseaman commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Takeover of #9201 by @mbajaj92. #9201 came from a fork and touches sensitive paths, which Sensitive Change Review cannot pass from a fork, so it is re-opened here on an in-repo branch. The first commit is @mbajaj92's work from #9201 (its two commits folded into one, authored by them, rebased onto current main with no conflicts). The second commit fixes the three blocking findings from #9201's GPT review and carries Co-authored-by: mbajaj92. When squash-merging, keep the Co-authored-by: mbajaj92 <mbajaj.92@gmail.com> trailer.

Split: this PR is now the backend half (src, tests, docs). The website/ half is #17580, stacked on this one, because together the review diff was 1,021,670 bytes, over the review lanes' 1,000,000-byte cap.

Problem / Motivation

Goal: A scheduled job runs as the agent you picked -- or skips and says why -- and can use the agents a checkout ships.

A scheduled job names an agent. If that name stopped resolving, the job did not
fail — it ran under the default agent instead, and said nothing. The Schedule
page kept showing the name you picked, so a job could run as the wrong agent for
weeks and look green the whole time.

There was also no way to point a job at a checkout. A repo that ships its own
.kiro/agents/ could not lend those agents to a job, so the agent that knows a
repo was unreachable from the schedule.

Why it matters

Silent substitution is the worse half. A job that runs the wrong agent produces
plausible output, so nobody looks. The failure is invisible exactly when it
matters most — an unattended job, running while you are not there.

Not a goal

  • Changing how an UNBOUND chat session resolves its agent. The precedence change
    (a project's agent beats a same-named configured alias) does reach a chat slot
    that is bound to a directory; see Backwards compatibility.
  • Proving project-wins precedence on the KAS or Claude backends. It is established
    on kiro-cli, whose project-first lookup the change matches.
  • Any new agent-authoring surface. A job borrows the agents a checkout already
    ships; it does not create, edit or install one.

What changed (motivation → approach → change)

A job now has a Project directory. Set it, and that directory's agents join
the picker beside your configured ones, and the job fires with that directory as
its working directory.

An agent that does not resolve is now a named skip, not a substitution. The
job goes red and says which agent and which directory. This covers jobs bound to
a directory — where a project definition can shadow the name — and unbound
delete-after-run one-shots, whose vanished agent must not consume scheduled work
that never ran. An unbound recurring job keeps firing on its captured template
by design: an app-registered or un-aliased crew name is not a config.agents
alias, so re-resolving it would strand jobs that work today.

On a name collision, the directory's agent answers, matching the layer
underneath: kiro-cli searches <project>/.kiro/agents before the user-level
registry, with the bound directory as cwd. That was also the picker's bug — the
roster endpoint computed project_names - config.agents, so a colliding project
name never became a row, and the form offered the configured agent while
dispatch ran the project file.

flowchart LR
  subgraph before["Before — the picker disagreed with dispatch"]
    B1["job names<br/>release-checklist"] --> B2["picker shows<br/>CONFIGURED row"]
    B1 --> B3["dispatch runs<br/>PROJECT file"]
  end
  subgraph after["After — one answer"]
    A1["job names<br/>release-checklist"] --> A2["picker shows<br/>PROJECT row<br/>+ overrides global"]
    A2 --> A3["dispatch runs<br/>PROJECT file"]
  end
  class B2 removed
  class B3 ctx
  class A2 added
  class A3 ctx
  class B1,A1 ctx
  classDef added fill:#DCFCE7,stroke:#16A34A
  classDef changed fill:#FEF3C7,stroke:#D97706
  classDef removed fill:#FEE2E2,stroke:#DC2626,stroke-dasharray:4 3
  classDef ctx fill:#E0F2FE,stroke:#0284C7
Loading

🟩 added · 🟨 changed · 🟥 removed · 🟦 unchanged

The endpoint now emits the project row, suppresses the shadowed configured one,
and says overrides global. The winner lands on default_agent's bindings, not
the shadowed alias's: a .kiro/agents/*.json is writable by anyone who can land
a branch, so inheriting a named crew's private store would turn landing a branch
into a read of that crew's memory. ResolvedBindings gains resolved_source.

Two callers keep their lineage via selection_kind: a member-bound job,
since a same-named project definition would re-base it and trip
parent_identity_changed; and a caller that named a provider template on
purpose. An imported job's project_path is re-validated on this host, a
sensitive or unresolvable binding cleared, and a bound job restored paused.

A crew alias and the provider template it dispatches are two different
backend-visible names, so the member opt-out judges both — once, as
agent_discovery.py:agent_binding_is_shadowed, which agent.py's
fork-governance refusal calls too, so neither name sees a stale snapshot.

The fire path's per-job binding cache is evicted on job removal through one
chokepoint and length-checked per string; its size already mirrors the live job
list. A stateless job mints a fresh key per fire, so the prune matches on the
job-id prefix.

A bound job is owner-only to read: a non-owner sees neither the directory nor
its output, replayed chat rows included.

The reset notice beside the Agent field now outlives the roster settling:
emptying the directory ran the clear-on-unbind effect twice, and the second pass
erased the first's notice.

The field is Project directory, matching the folder-settings field that uses
this picker. Three smaller fixes ride along, each a harm this work exposed:
ProjectPicker gains Radix scroll/dismiss handling; the enable route rejects a
non-boolean enabled with a 400 instead of coercing it; and the roster resolves
scope from requesting_slot_project, so a request no longer answers for whichever
unrelated tab happened to be focused.

Area What changed there
src/kiro_crew/config the resolver and ResolvedBindings
src/kiro_crew/cron.py the job record
src/kiro_crew/cron_service the port of the job record, fire fields, store and execution onto the split service modules: model.py carries project_path, fields.py validates it, store.py persists and re-validates it on import, and execution.py resolves the agent at fire time
src/kiro_crew/cron_history.py the skip reason a named skip records, so a run's history says which agent and which directory rather than only that it did not run
src/kiro_crew/session_agent_selection.py selection_kind, the field the two preserved-lineage callers ride so neither needs a second switch
src/kiro_crew/execution_context.py the projection a winning project definition runs under — an unowned template on Global memory, so a project file cannot reach the displaced alias's private store
src/kiro_crew/slack both fire paths. A sequence member resolves from its OWN alias rather than the job-level carrier; a member-shadow refusal emits a best-effort SEL denial (cron.fire.project_bound_job); skip log lines read redact_log_via_context; and the three binding pending-work probes are awaited through _subagent_work_pending, whose store read runs off the event loop
src/kiro_crew/dashboard roster endpoint, save validation
src/kiro_crew/security + portability.py the shared resolve_project_path verdict
docs the owning specs
.github/black-baseline.txt loses entries only, as two files graduate to formatted

Takeover fixes (second commit)

Three blocking findings from #9201's GPT review, each traced in the code:

  • Slot list previews reached non-owners. The hub only judges dict frames, and the slots list is deliberately unfiltered, but each row quotes its newest turn (last_message, prompt_preview, options). A visible project-bound job's output therefore reached every dashboard user. DashboardState.serialize_slot now blanks those fields outside the owner boundary (include_check_status) for a cron- slot whose newest turn is not explicitly project_bound: False, the same unknown-is-withheld rule project_output_visible_to_non_owner applies to frames. _reproject_slots restores them on the owner view for those rows only, so the single-pass serialization holds.
  • The job's folder was in an INFO log line. session_allocation's Pool decision line logged cwd, and the log-ring replay admits any dashboard-user socket, exposing the path the cron API withholds. It now logs the cwd's relation to the pool (none / pool / other), which is what the pool decision turns on. Chose redaction at emission over making the log stream owner-only, matching the redaction this PR already applies to its other project-path log lines.
  • A binding change broke a persistent job permanently. _cron_session_binding_requires_reset resets the live session but nothing rewrote the durable execution record, so the single-agent path's plain bind_session_execution raised session already belongs to another execution on every later fire. cron_service.identity.rebind_own_cron_execution now replaces the record before acquisition (compare-and-set against a fresh read, like the sequence path), only when the record is one this job published: same member, store and app, or the Global project-override shape. A record naming another member or app is still refused. Not conditioned on "reset on this fire", so a fire that reset and then failed to acquire is repaired on the next one.

Backwards compatibility

  • Reader: handlers/side.py:_run_side_turn -- chat -- slot dir
  • Reader: chat_threads.py:_run_thread_turn -- chat -- slot dir
  • Reader: chat_handlers.py:api_chat -- chat -- stored dir
  • Reader: session_agent_selection.py:record_provider_agent_switch -- chat
  • Reader: handlers/cron.py:_resolve_cron_bindings -- cron -- opt-out

Those are every reader of the chat-slot precedence flip; all live under
src/kiro_crew/. One behaviour change on upgrade: project_wins is new here and
allow_project_override defaults true, so the flip is NOT confined to this PR's
cron bindings -- any already-bound session whose project directory declares an
agent sharing a configured alias's name resolves the project's file after upgrade
where it resolved the alias before. Each reader above is a chat caller passing a
project directory, except the cron one, the only caller that opts out
(allow_project_override=not member_id).

That flip is the intended correction: kiro-cli already resolves
<project>/.kiro/agents first with the project as cwd, so the alias row
advertised one answer while another ran, and inheriting the shadowed crew's
private store would let anyone who can land a branch read that crew's memory.
Outside the project directory the alias is untouched, pinned by
test_config_loader.py::test_the_alias_is_untouched_outside_the_project.

Otherwise compatible. The alias-plus-template pair check reaches only the member
opt-out (allow_project_override=False), which no caller on main passes; an
ordinary resolution receives an empty effective name, so its probe and its answer
are unchanged, and agent.py's fork-governance refusal keeps its existing
alias-or-declared-name semantics through the shared helper. A job that stops
resolving is one whose project directory declares the crew alias's provider
template, and it takes the same named skip as any other unresolved name rather
than running the project's spec under the member's private memory store.

Takeover commit:

  • Reader: website/src/hooks/useAgentSync.ts, website/src/components/commandPalette/providers/recentsProvider.ts, website/src/pages/members/* (last_message / prompt_preview) -- chat / crew page -- a non-owner sees an empty preview for a project-bound cron- slot, the same shape every fresh slot already has; the owner view is unchanged (test_cron_project_bound_slot_previews.py)
  • Reader: options / has_options on a non-owner's view of that slot -- chat -- the option chips are not offered to a non-owner there; the owner still gets them
  • Reader: the Pool decision INFO line (cwd=, pool_cwd=) -- log stream -- now reports cwd=none|pool|other and drops both paths; nothing parses the line (test_session_pool.py::...::test_pool_decision_log_names_no_cwd_path)

Release note: a job whose agent no longer resolves now skips with a named reason instead of quietly running the default agent, and a one-shot in that state is parked disabled. Jobs that relied on the silent fallback stop running after upgrade.

Tests

Backend, in test/:

  • the collision emits the project row and suppresses the shadowed configured one,
    with the non-colliding rows on both sides untouched
  • an unbound job's roster is unchanged, so the rule is scoped to a bound directory
  • a member-bound caller keeps its global lineage
  • a member-bound job dispatches under its member's config.agents name, not
    its persisted member_id. The two are different key spaces —
    resolve_crew_identity returns crew_agent verbatim and its consumers look it
    up by name, while member_id is a lossy slug stored as a field — so passing the
    id lost the crew's pinned model, effort and watchdog windows, and made
    session_capabilities fail closed. Pinned on single AND sequence dispatch with
    a member whose display name is deliberately NOT slug-shaped, since a
    slug-shaped fixture is exactly what hid this. A deleted member still fires,
    falling back to the resolved alias rather than raising.
  • a deliberate template pick is not re-pointed at a project file
  • resolved_source distinguishes the case the other fields cannot
  • fire time: a vanished directory and an unresolvable agent each skip with their
    own message, and neither spends an auto-pause strike — and a one-shot is
    parked disabled rather than left enabled, in memory and on disk, because a
    past-due at job is due again on every scan and would refire with no delay. A
    pool-starved one-shot is deliberately not parked: that condition self-heals
  • a job's removal evicts its exact session key and notifies observers only after
    the store write commits, so a failed save cannot erase the one handle that
    cancel and the reaper use to reach a live session
  • a member-bound slot in a project that declares the member's own name now
    resolves as a project agent instead of reporting the member unavailable, and
    records no private store under a name the project file answers
  • save time refuses a relative, sensitive or non-existent directory, and the
    owner gate is audited on both outcomes — including a clear, which removes
    the project scope and is the same privileged field transition as setting one,
    so it is audited by the field's presence rather than by its value
  • GET /api/crons returns project_path only to the owner view, on the same
    boundary as the secret-grant metadata beside it; a non-owner's save of that
    blanked field is refused 403 and leaves the owner's binding intact
  • src/kiro_crew/messaging/commands.py refuses a cron resume of a
    project-bound job: a channel allow-list says who may type, not who owns the
    folder, so the shared messaging layer — which carries no authenticated owner
    identity — reuses the dashboard's own atomic expect_project_path
    precondition, names the refusal, and points the caller at the owner dashboard
    or the CLI. cron pause stays open because it removes execution permission
    rather than granting it
  • the cached binding is evicted on job removal, bounded by count, and bounded per
    string — including a pin that a maximal legitimate composed key is still
    admitted, since a refused admission would defer that job's fire silently and
    permanently
  • both dispatch sites are asserted to call the prune, so a stateless job's
    fresh-per-fire key cannot accumulate
  • two sequence members with different aliases dispatch two different templates,
    and a project-won member keeps the unowned execution rather than the job's.
    Deliberately runs the real resolver: every other sequence test stubs it with
    one return value, so a per-member resolution bug is invisible to them
  • a member-shadow refusal emits its SEL denial on both fire paths, and an SEL
    sink that raises leaves the refusal intact rather than letting the fire
    dispatch
  • a credential-shaped job name and an exfiltration-shaped agent name are absent
    from all three skip log lines
  • a shadow refusal is not logged as an empty roster on a host whose configured
    roster is populated
  • every binding pending-work probe is reached through the awaited off-loop seam:
    the synchronous entry is asserted never called, at both fire paths and in the
    prune, so a double that models only the sync method cannot silently pass

Frontend tests moved with the UI to #17580.

Takeover commit:

  • test/test_cron_rebind_own_execution.py: the plain bind refuses a moved identity (the old failure, pinned); the project-override and capture shapes each replace the other; a template move on the same store is replaced; another member's or app's record is left for the bind to refuse; a matching, absent or unattributable record is not rewritten
  • test/test_cron_project_bound_slot_previews.py: a project-bound row is blank on the bare and dashboard-user views and full on the owner view, across both direct serialization and the broadcast's derived views; an unstamped cron row and a follow-up typed into a project-bound slot are withheld; an explicitly unbound cron row and an ordinary chat slot are unchanged
  • test/test_session_pool.py::test_pool_decision_log_names_no_cwd_path: the requested folder never appears in the line
  • test/test_execution_context.py::test_every_binder_declares_whether_it_vouches: registers the new binder as vouch=False (a cron: key is never an own-store caller slot)
  • Each new test was mutation-checked: removing the fix it covers turns it red.
  • Locally on the backend half alone: feat(cron): bind scheduled jobs to a project's agents #9201's own test files plus the suites above, 4,249 passed. flake8, black, isort and mypy clean on the touched files.

Manual verification

Walked the whole surface on an isolated gateway against two fixture checkouts —
one declaring a colliding agent plus a project-only one, one declaring a
different agent — covering the field, the merged picker, the collision marker,
the A→B directory switch, all three save rejections, and both fire-time skips.

Takeover commit: unit coverage only. The three fixes are backend serialization, a log format and an identity-record write, each exercised against the real DashboardState, SessionManager and bind_session_execution; no UI changed.

Related Issues

Closes #8952
Supersedes #9201 (same work, re-opened in-repo; author @mbajaj92)
UI half: #17580 (stacked on this PR)

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|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

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.

@github-actions

github-actions Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Sensitive Change Review

Sensitive files changed:

  • src/kiro_crew/security/__init__.py

  • src/kiro_crew/security/_exports.py

  • src/kiro_crew/security/paths.py

  • No reasoning template for 627a6b0 yet.

How to clear this check:

  1. The PR author posts the template below as a PR comment, with
    every field filled (N/A needs a reason). Keep the
    Head commit line: it must name the current head SHA.
  2. The check turns green within a minute, with no push.
  3. A new push resets this check: post it again for the new head.

Only the author's comment counts this way. A reviewer can instead
paste the filled template into an "Approve" review on this head.
Merging still needs a reviewer's approval.

## Sensitive change review
- Head commit: 627a6b06bf4195ecc9c7fae520cff4e5df676aad
- What rule changed:
- Before -> after (what was allowed/blocked, now):
- Worst case if wrong (breaks commands / leaks secret / locks user out):
- Evidence checked (which sandbox result proves it):
- No regression:
  - Tools still work (which tools/commands were run, result):
  - Backward compatible (old config / old data / old callers still work, how checked):
  - Existing tests (which suites passed on this head):
- How to undo:

@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 7, 2026
@github-actions

github-actions Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — 🟡 CONCERNS

Premise-level review of 627a6b06bf4195ecc9c7fae520cff4e5df676aad — 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/CONCERNS are advisory.

First-Principles-Verdict: CONCERNS

The precedence override takes a crewmate's memory away on every backend, though it's only shown to hold on kiro-cli, and the description misstates what triggers it.

Not justified as shipped

  • Item 3 — inherited: the override has no backend gate, but its premise is only "established on kiro-cli". The description also says "On a name collision, the directory's agent answers", while the hunk says "A project file sharing only an alias's NAME displaces nothing". The real trigger is the alias's kiro_agent template.
    Clears when: project-first lookup is confirmed on the KAS and Claude backends, or the override does not fire there, and the description names the template trigger rather than a name collision.
  • Item 8 — rides along: declared; it removes a coerced non-boolean enabled value.
  • Item 9 — rides along: declared; the roster stops answering for an unrelated tab that happens to have focus.
  • Item 10 — symptom-level: the cache's own comment names the cause, "restored/imported records reach _job_from_record's type-only … readers without that length gate". It also concedes "every retained string is held (larger) in self._jobs", so the cap protects against nothing.
    Subtraction: delete the per-string check and _cron_binding_overflow_count in _retain_cron_session_bindings. Apply the existing _CRON_STRING_FIELD_CAPS where _job_from_record loads restored records instead.
    Clears when: the sink check is gone and the caps are enforced at load.

What this change ships

Inventory (10 items) — 6 justified

Intent: a scheduled job runs as the agent you picked, or skips and says why, and can use a checkout's own agents. This is mostly an ADDITION, with a fix included.

  1. A job gains a Project directory; that directory's agents join the picker and it becomes the job's working directory — justified
  2. An agent that no longer resolves on a bound job or an unbound one-shot now skips red with a named reason — justified
  3. In a bound folder, a project file declaring a crewmate's template displaces that crewmate (default memory, no model pin), chat slots included — inherited
  4. The roster shows the project row marked "overrides global" and hides the shadowed configured row — justified
  5. A member-bound job whose folder declares its name is refused, and an SEL denial is logged — justified
  6. A bound job's directory, output, history and replayed chat rows are owner-only — justified
  7. An imported job's directory is re-validated on this host, and a bound job is restored paused — justified
  8. The enable route returns 400 for a non-boolean enabled — rides along
  9. The roster scope follows the requesting slot, not the focused tab — rides along
  10. The fire-path binding cache refuses over-long strings and counts the refusals — symptom-level

[FIRST-PRINCIPLES-REVIEWED] 627a6b0

Description read

[DESCRIPTION-READ] 75d460528c30d8b26fb7e32bb2b20332e75b30205a112a2812fd709d78bd7d4a

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 Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — 🔴 changes requested (blocking)

GPT 6.1 found at least one blocking issue that must be resolved before merging 627a6b06bf4195ecc9c7fae520cff4e5df676aad. 1 of 1 blocking finding(s) are security-class and were withheld from adjudication, so the blocking verdict stands.

This comment is updated in place on each push.

BLOCKING -- src/kiro_crew/dashboard/chat_api/slot_summary.py:65 -- Cron-summary authorization decisions are not audited

owner_only = bool(cron_slot_job_id(slot)) and not is_owner_dashboard_request(request)
Authenticated non-owner GET of a cron-slot summary -> api_chat_slot_summary withholds it with HTTP 200 -> no SEL denial records this decision; the dashboard audit middleware excludes GET, and token-auth auditing records authentication, not this refusal.
Anchor: backend-security-controls
Fix: Emit a best-effort SEL event for both allowed and denied cron-summary owner decisions before returning or reading the summary.
[BLOCK-MERGE] 627a6b0
[GPT-REVIEWED] 627a6b0

Adjudication (Opus 5.5) — is blocking on each finding proportionate?

F1 is fenced, so it keeps blocking whatever I write here. My only choice was between upholding the finding as written and flagging it as too rare to matter. I upheld it, for three reasons:

  • The trigger is common. slot_summary.py:65 sets owner_only = bool(cron_slot_job_id(slot)) and not is_owner_dashboard_request(request). Any signed-in non-owner who opens the summary panel for a cron slot reaches it. The response is an ordinary HTTP 200 with empty fields (:66-77), and no audit (SEL) event is written. That isn't an extreme or contradictory set of conditions, so the rarity case a flag needs can't be made.
  • The audit gap is real, but nothing leaks. The refusal itself works: the cached summary is never read (:79-86). What's missing is the record of the decision. The anchored blocking rule in .review-base-rules/AUTOSDE.yaml (backend-security-controls, blocking: true) says "All tool invocations and permission decisions MUST emit a SEL audit event via sel.py". This is a permission decision, and the code doesn't record it.
  • The fix is cheap. It's one best-effort SEL emit in this handler.
[ADJUDICATION] 627a6b06bf4195ecc9c7fae520cff4e5df676aad total=0 uphold=0 downgrade=0
[GPT-ADJUDICATED] 627a6b06bf4195ecc9c7fae520cff4e5df676aad
[ADJUDICATION-FENCED] 627a6b06bf4195ecc9c7fae520cff4e5df676aad fenced=1 flagged=0
UPHOLD-FENCED F1 src/kiro_crew/dashboard/chat_api/slot_summary.py:65 -- Any authenticated non-owner viewing a cron slot's summary reaches this unaudited permission decision on an ordinary path, contrary to the blocking backend-security-controls rule that every permission decision emit a SEL event, so no rarity argument exists for a FLAG.
[GPT-ADJUDICATED-FENCED] 627a6b06bf4195ecc9c7fae520cff4e5df676aad

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 627a6b06bf4195ecc9c7fae520cff4e5df676aad: <one-sentence reason>

Comment thread src/kiro_crew/security/paths.py Dismissed
@kyleseaman
kyleseaman force-pushed the feat/cron-project-agents branch from bb7bfaf to b49ce28 Compare October 7, 2026 01:26
@github-actions github-actions Bot added merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 7, 2026
@github-actions

github-actions Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — 🟡 CONCERNS

Design-level review of 627a6b06bf4195ecc9c7fae520cff4e5df676aad — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: CONCERNS

The Backwards compatibility section falls past the 8,000-byte truncation, so nobody can check its reader list against the precedence change, the new 400 and the owner gates.

Watch

  • The reader list can't be checked. The patch takes several things away. A directory-bound alias whose kiro_agent the project declares now resolves as a template session. It loses its workspace, private memory store and model pin (loader.py:_resolve_agent_selection, project_wins → alias_hit = False). api_cron_enable now returns 400 for a non-boolean enabled. Chat, export, transfer and websocket surfaces gain new owner-only gates. Under my take-away check, the known callers still work: website/src/api/client/cron.ts:toggleCron sends a boolean, and cron_service/identity.py unpacks the new 5-tuple. But the description is cut, so the author's list can't be matched against these readers.
    Clears when: the full description is reviewable, and its Backwards compatibility section lists the readers of directory-bound chat slots, of api_cron_enable, and of the newly owner-gated chat surfaces, each with the test that covers it.
  • The description and the code use different collision rules. The description says "a project's agent beats a same-named configured alias". The resolver's docstring says the opposite: an alias "is NOT displaced by a project file that merely shares its NAME". The override fires only when the project declares the alias's kiro_agent template, and the roster agrees with the code (shadowed = {n … if a.kiro_agent in project_names}). An operator who reads the description will expect a name match to override, and it won't.
    Clears when: the Not a goal and Backwards compatibility wording says the collision key is the alias's template, not its name. Those sections are frozen, so this edit needs a human to ask for it.
  • The swap stays silent in chat. In a directory-bound chat slot, a crewmate that loses to a project template drops its memory store and model pin. Only the cron picker shows overrides global. That leaves the same "looks right, runs as something else" gap this PR closes for cron.
    Clears when: a chat slot shows that a project file won, or the description states that chat shows nothing on purpose.

[DESIGN-REVIEWED] 627a6b0

Description read

[DESCRIPTION-READ] 28ac0be027f14089543e65235f64fe89aab79e9a1c6cb3063902899401c72411

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 Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed bf2132f0baa9773804b35c0589397bc8ade55105 — this comment is updated in place on each push.

Review details

No findings that block the merge.

FINDING — src/kiro_crew/cron.py:2254 — the 500-char project_path cap is checked on the raw value (("project_path", MAX_SHORT_STRING)) before resolve_project_path expands ~ and symlinks, but the stored realpath goes into _binding_now, and _retain_cron_session_bindings refuses anything over _CRON_SESSION_BINDING_STRING_LIMIT. A raw path of 500 characters or fewer that resolves to more than 500 is saved, then every fire hits _defer_cron_before_dispatch(job, "cron session binding retention capacity unavailable"), so the job never runs and never auto-pauses → Fix: in _validate_project_path, refuse when len(verdict.resolved) > MAX_SHORT_STRING.
FINDING — src/kiro_crew/dashboard/messaging_api/notifications.py:33 — for a non-owner the list is filtered but "unread": state._unread_count still counts every note. The badge disagrees with the list and reveals how many project-bound notifications were withheld → Fix: for a non-owner, compute unread from the filtered notifications.
FINDING — src/kiro_crew/dashboard/handlers/agents.py:1645 — the roster tests a.kiro_agent in project_names on the raw value, but the resolver probes dispatch_kiro_agent(effective_name). Take an alias that records a file stem (KiroPkg-captain) in a project that declares captain: the roster lists the alias as global and also adds a separate captain project row, while at dispatch the project file wins and runs on the default store → Fix: compare dispatch_kiro_agent(a.kiro_agent) in project_names.
FINDING — src/kiro_crew/config/loader.py:7780 — the comment says "every ordinary and app-bound resolution keeps the default True and so reaches no extra probe", but probe_runs = (... and (alias_hit or not allow_project_override)) runs _project_declares_agent on every alias hit that has a project_dir, including on-loop chat turns → Fix: correct the comment so it says ordinary alias hits probe the template (a cache-only read on the loop).

[OPUS-REVIEWED] bf2132f

Verdict parsed from the review's SHA-scoped output markers for commit bf2132f0baa9773804b35c0589397bc8ade55105.

False positive or not applicable? A repository writer can comment:
/ai-review override fable bf2132f0baa9773804b35c0589397bc8ade55105: <one-sentence reason>

@github-actions

github-actions Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Security Scope Review -- 🟡 CONCERNS

Which legitimate operations does 3a6f741aaa4adbb0983beee228962c182930671d newly refuse? Updated in place on each push. A script-confirmed regression blocks; the model proposes candidates and never decides a refusal.

Verdict basis: the reviewer's own judgement; no confirmed regression.

Security scope review -- adjudicated candidates

  • macos-latest (platform posix): 10 classified, 0 newly refused, 10 still allowed.
  • ubuntu-latest (platform posix): 10 classified, 0 newly refused, 10 still allowed.
  • windows-latest (platform windows): 11 classified, 0 newly refused, 11 still allowed.

No candidate flipped from allowed to refused.

Scope-Verdict: CONCERNS

TIGHTENING: Owner gating and re-validation of a cron job's project-directory binding -- this refuses a non-owner (including an allow-listed messaging user) who tries to bind, run, re-enable or read a job tied to an arbitrary absolute directory. The messaging hunk in src/kiro_crew/messaging/commands.py: if enabled: changed = await cron_service.enable_job_async(job_id, enabled=True, expect_project_path="") … "🔒 Project-bound cron jobs cannot be resumed from a messaging channel. Resume this job from the owner dashboard or the kirocrew cron CLI.". It is backed by the new resolve_project_path in security/paths.py (resolved = os.path.realpath(os.path.expanduser(raw)); sensitive = is_sensitive_path(resolved)) and by is_owner_dashboard_request(request) checks across dashboard/handlers/cron.py, agent_admin/roster.py, chat_api/* and handlers/sessions.py. The diff does not change hooks.py, the sensitive-bash/exfil/deny-rules tiers, or SHELL_DENY_TIERS.

ADJUDICATED: 15 candidates, 0 confirmed newly-refused
(The shell rows probe the cron CLI escape hatch the refusal points users to, and ordinary reads of a bound project directory. The tool-call deny composite is unchanged in this diff, so these rows are controls. They are not a measurement of the tightening.)

PLATFORM COVERAGE: Rows cover posix, windows and any. The diff assumes expanduser/realpath/isdir path spellings. Posix rows use ~ expansion, an absolute /home/... path, realpath/readlink -f on a possibly symlinked folder, and git -C in the bound folder. Windows rows use a drive letter with \ separators, a quoted path containing a space, a UNC share, %USERPROFILE% where posix uses ~, and the kirocrew.exe entry point. Rows marked any cover the platform-neutral kirocrew cron resume|pause|trigger|update|remove operations. Neither half covers macOS's /var→/private/var realpath or Windows 8.3 short names (C:\Users\DEVELO~1) going through realpath equality in _project_path_still_canonical. Those spellings exist only as stored binding strings, not as shell lines, so no shell row can probe them.

UNADJUDICATED: The classifier cannot reach any of the guards this diff tightens. Each guard, its call path, and the legitimate inputs I would have submitted:

  • Messaging cron resume CAS (messaging/commands.py cron_command_reply → cron_service.enable_job_async(job_id, enabled=True, expect_project_path="") → CronPendingMismatch → refusal). This is the clearest new refusal of a legitimate operation: a single-user install owner who drives their own install over Slack/messaging can no longer type cron resume <id> for their own project-bound job. The diff says it chose this ("no authenticated install-owner identity to compare") and gives kirocrew cron CLI / dashboard as the way out. I checked that the escape hatch works at the BASE: cli.py:1856 cron resume has no --project-path argument and enable_job's new parameter defaults to _UNSET, so the CLI skips the check. Input I would have submitted: cron resume job-1 from the install owner's own Slack DM, on a job bound to ~/code/myrepo.
  • Dashboard owner gates (is_owner_dashboard_request on POST/PATCH /api/cron, the run/enable routes, slot summary/detail/resume, the transcript copy, and GET /api/agents?project_path=). Inputs: an allow-listed teammate's !dashboard token (app == "") running, editing the message of, or re-enabling a project-bound job they did not create; the same teammate viewing a project-bound cron slot's summary. All of these are now 403 or have the path withheld, and nothing classifies these routes.
  • The stale_project_binding 409 at run/enable (the expect_project_path CAS). Input: an owner who clicks Run on a job whose folder was re-bound in another tab, which is legitimate but now refused with 409.
  • The fire-time canonical-path guard (_project_path_still_canonical: the stored string must equal its own realpath). Inputs: a binding saved as /var/folders/... on macOS (the realpath is /private/var/...), a Windows binding saved with different drive-letter case or an 8.3 short name, and a repo directory that is itself a symlink (~/code/myrepo -> /mnt/data/myrepo). I could not confirm whether create-time canonicalisation covers every path that writes a binding. This is a narrowing I can argue but not confirm.
  • Import sanitisation (portability._sanitize_imported_crons → resolve_project_path). This clears sensitive or unresolvable bindings and imports every still-bound job paused. Input: restoring settings on a new machine with a binding of ~/code/myrepo. It is kept but paused by design, so the cost is one manual resume per job.
  • The member_shadowed_by_project fire refusal (config/loader.py RESOLVED_SOURCE_MEMBER_SHADOWED). Input: a member-bound cron job whose bound project declares an agent with the same name as the member's crew alias. The fire is now refused instead of running.

[SCOPE-REVIEWED] 3a6f741

@kyleseaman
kyleseaman force-pushed the feat/cron-project-agents branch from b49ce28 to cced20c Compare October 7, 2026 03:04
@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 Oct 7, 2026
@kyleseaman
kyleseaman force-pushed the feat/cron-project-agents branch from cced20c to 522202f Compare October 7, 2026 15:54
@github-actions github-actions Bot added readiness: checking Automated validation is still running merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: checking Automated validation is still running labels Oct 7, 2026
@kyleseaman
kyleseaman force-pushed the feat/cron-project-agents branch from 522202f to 5d46378 Compare October 7, 2026 17:02
@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 Oct 7, 2026
@kyleseaman
kyleseaman force-pushed the feat/cron-project-agents branch from 5d46378 to 8cd2e0e Compare October 7, 2026 18:55
@github-actions github-actions Bot removed the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Oct 7, 2026
@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Oct 12, 2026
@kyleseaman
kyleseaman force-pushed the feat/cron-project-agents branch from 873ed66 to 472c3ff Compare October 13, 2026 15:48
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: checking Automated validation is still running labels Oct 13, 2026
@kyleseaman
kyleseaman force-pushed the feat/cron-project-agents branch from 472c3ff to 5dbe807 Compare October 13, 2026 21:44
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: checking Automated validation is still running labels Oct 13, 2026
@kyleseaman
kyleseaman force-pushed the feat/cron-project-agents branch from 5dbe807 to 8d1f4a0 Compare October 14, 2026 14:02
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: checking Automated validation is still running labels Oct 14, 2026
@kyleseaman
kyleseaman force-pushed the feat/cron-project-agents branch from 8d1f4a0 to 77692f9 Compare October 14, 2026 19:34
@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 Oct 14, 2026
mbajaj92 and others added 2 commits October 15, 2026 19:01
A scheduled job could name an agent that no longer resolved and run under the
default one instead, silently. Point a job at a project directory and its
.kiro/agents are offered alongside the configured ones; an agent that does not
resolve at fire time is now a named skip rather than a substitution.

On a name collision the project's agent answers, matching the precedence
kiro-cli already applies in that directory. The roster endpoint used to
subtract configured names from project names, so the colliding project row
never reached the picker at all -- the form offered the configured agent while
dispatch ran the project file. The project row is emitted instead, marked
"overrides global" with the reason on the row, and the shadowed configured
agent is suppressed.

The field is called "Project directory", matching the folder-settings field
that uses the same picker; "working directory" already means the process cwd
elsewhere in the dashboard.

Closes #8952

Review repairs folded in:

Review repairs on one head, keeping this PR at two commits.

DISCLOSURE -- project-bound cron output reached non-owners on several
paths. Notification and chat rows carry a real boolean project_bound
stamp, and HTTP, SSE, WebSocket and slot-detail delivery admit a row to
a non-owner only when that stamp is exactly False; a malformed stamp or
an unstamped cron row is unknown provenance and is withheld. Only a dict
frame can carry provenance, so only a dict frame is judged -- a list or
scalar payload is structural, and withholding it would deny every
non-owner frame while protecting nothing.

The to-chat replay filter took a whole-transcript shortcut whenever no
bound run was on record. Retention keeps 100 records per job, so pruning
removes a bound run's RECORD while its transcript rows survive, after
which "no bound windows" meant "nothing to hide" when it had to mean
"cannot prove safe". A row is served only when a retained unbound run's
window positively covers it, explicit row provenance outranks that
window fallback, and the bound-run flag the deleted-job branch gates on
now reports the run records rather than a constant.

Clearing a bound job's directory no longer carries its protected
last_result into the next prompt: that run would stamp derived output
unbound. A deleted job's notification body is taken newest-first and
only when its own stamp proves an unbound run.

A project-bound sequence step dispatches under its own template again,
so its spawn allowlist is its own rather than the job-level floor.

The shared predicate lives in handlers/source_providers because a
messaging_api owner's functions run on the facade's namespace, where a
name the owner merely defines is never bound.

PRECEDENCE -- the earlier change let a project file displace an explicit
Kiro Crew alias that merely shared its NAME, and deleted the pin saying
it must not. On base an alias dispatches its kiro_agent, and kiro-cli
looks up the project file only when that TEMPLATE name matches a project
agent, so the symptom the description gave does not occur in the pinned
case. Alias-first precedence is restored and
test_alias_still_wins_over_a_project_agent is back verbatim; the project
file wins only where it declares the alias's own kiro_agent template.

Raised by the GPT 6.1, Opus 5.5 and First Principles review lanes.
learn-cron-dashboard gains disclosure rows 2c and 2d, which the
adjudication noted were absent, and its precedence section reads
alias-first.
…d jobs

- Slot list: a cron- slot's text previews (last_message, prompt_preview,
  options) now stay inside the owner boundary unless its newest turn is
  explicitly unbound, matching the owner-only rule the notification and chat
  frames already apply. The owner view is re-projected for those rows only.
- Pool decision log: report the requested cwd as its relation to the pool's
  (none/pool/other) instead of the path, since the INFO line reaches every
  dashboard-user socket through the log replay.
- Single-agent fire: replace a stale durable execution identity this job
  itself published (same member/store/app, or the Global project-override
  shape) before acquisition, so a binding change no longer makes every later
  fire fail with "session already belongs to another execution".

Co-authored-by: mbajaj92 <mbajaj.92@gmail.com>
@iamwhatever

Copy link
Copy Markdown
Contributor

Thanks @kyleseaman for taking this over, and @mbajaj92 for the original work in #9201. We're closing this stack (#17554, #17580 and #9201) for now. Together it is over 17,000 lines, it has fallen behind main where cron agent identity has been reworked several times since, and a security-class review finding is still open. The need is still real and stays tracked in #8952. We'd welcome it again as two small PRs on current main: one that makes a job whose agent does not resolve skip loudly instead of running as the default agent, and one that lets the Schedule page pick a project's agents.

The branch is left untouched, so you can reopen this PR at any time, or open a fresh one on current main, if you want to pick it back up.

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

Labels

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: project agents never show up in the Schedule page's agent picker, and the binding can't persist

4 participants