Skip to content

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

Open
mbajaj92 wants to merge 1 commit into
kirodotdev:mainfrom
mbajaj92:feature/cron-project-agents
Open

mbajaj92 wants to merge 1 commit into
kirodotdev:mainfrom
mbajaj92:feature/cron-project-agents

Conversation

@mbajaj92

@mbajaj92 mbajaj92 commented Sep 7, 2026 •

Copy link
Copy Markdown

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 a CHAT session resolves its agent. This PR's precedence change is
    reached by a chat slot only where one is already bound to a directory.
  • 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)

Scheduled message jobs can bind to a Project directory and run with that
checkout as their working directory. The owner-only Schedule form validates the
directory through the shared portability and sensitive-path checks, then loads
its .kiro/agents/ into the agent picker. Non-owner views do not receive the
host path.

The selected custom-agent namespace is stored as agent_kind="template" on
create and when an edit explicitly picks a catalog template. PATCH never infers
that marker from a project binding; omitting it preserves the stored namespace.
A same-named Bot cannot replace the template the person selected, while locked
and unchanged configured aliases still resolve normally. Save-time and fire-time
checks reject a missing agent, including every member of an agent sequence,
rather than silently substituting the default.

The edit form keeps its mounted project path as the comparison baseline. A PATCH
that validates a stored project or agent carries that value into the locked
write; concurrent changes return 409 stale_request instead of composing an
unchecked pair.

Imported project-bound jobs are revalidated on this host and restored paused.
Only the owner Schedule page and CLI can resume or manually run them; an enabled
job continues its ordinary schedule. Messaging commands, MCP cron tools,
CronSDK, app REST enable/run routes, and Ops Mission Control rotation arming
require the job to remain unbound. Manual-run callers await fresh-store admission
before reporting success. Dedicated refusal types distinguish this policy from
filesystem and store permission errors. Ops reports any partial changes from a
concurrent binding race.

App writers can clear a stale project binding but cannot add one. The cron, App
Kit, Crew Mode, messaging, and Ops Mission Control specifications and App Kit API
reference define these ownership rules. The Schedule form copy is translated in
every shipped locale, including the pseudo locale.

Area Change
src/kiro_crew/cron.py Keeps the legacy service facade's activation contract in parity.
src/kiro_crew/cron_service Persists agent kind and enforces import, enable, and run rules.
src/kiro_crew/cron_trigger.py Marks agent-controlled manual triggers as unbound-only.
src/kiro_crew/portability_vetting.py Revalidates imported project paths and agents.
src/kiro_crew/slack Rejects missing sequence agents before dispatch.
website/src/components Provides the project-aware Job form and roster behavior.
website/src/i18n Supplies the new copy in every locale.
website/src/types Carries project path, agent scope, and agent kind through the form.

Backwards compatibility

Breaking: Agent- and app-controlled activation of an existing project-bound job
is now refused. Owner actions from the Schedule page and CLI remain allowed.
Writer sweep on upstream/main @ c0760706ddb44fe9bf209eb82a0779fcb154484d:

  • messaging.commands:cron_command_reply marks resume as requiring an unbound job.
  • mcp_cron:_call_tool_inner marks resume and trigger as requiring an unbound job.
  • apps.cron_sdk:CronSDK.set_enabled, set_enabled_async, and run_job_async
    enforce the same rule for app-owned jobs.
  • dashboard.handlers.cron_jobs:api_cron_enable and
    dashboard.handlers.cron_runs:api_cron_run enforce it for app-token REST calls.
  • ops_mission_control.backend.rotation:apply_tiers enforces it while arming a
    rotation and records truthful partial results if an earlier change landed.
  • Owner Schedule handlers and CLI service calls do not request the restriction.

Reader: src/kiro_crew/messaging/commands.py:cron_command_reply -- cron -- unbound resume still works; project-bound resume returns the owner remedy (test_messaging_cannot_resume_a_project_bound_job).

Reader: src/kiro_crew/mcp_cron.py:_call_tool_inner -- cron -- unbound resume/run still works; project-bound activation returns the shared refusal (test_mcp_cron_security_wiring.py).

Reader: src/kiro_crew/apps/cron_sdk.py:CronSDK -- app -- unbound app jobs retain enable/run; project-bound rows are refused and audited (test_cron_sdk.py).

Reader: src/kiro_crew/dashboard/handlers/cron_jobs.py:api_cron_enable -- app -- owner Schedule activation remains allowed while app-token activation is refused (test_r12_cron_owner_gate.py).

Reader: src/kiro_crew/dashboard/handlers/cron_runs.py:api_cron_run -- app -- owner manual run remains allowed while app and agent triggers recheck the synchronized binding (test_cron_trigger.py, test_r12_cron_owner_gate.py).

Reader: src/kiro_crew/apps/builtins/ops_mission_control/backend/rotation.py:apply_tiers -- app -- unbound rotation jobs still arm; project-bound rows stop arming with accurate partial reporting (test_store_and_gate_arming.py).

Tests

  • Backend project-path, owner/API, import, sequence, messaging, MCP, CronSDK,
    manual-trigger, and Ops rotation tests cover validation and activation gates.
  • test_dashboard_cron_project_path.py covers owner-only path visibility,
    project catalog selection, client-declared PATCH namespace persistence,
    configured-alias preservation, concurrency conflicts, and app restrictions.
  • test_cron_project_path.py covers store persistence, same-name template
    dispatch, missing-agent failures, and fresh-snapshot manual-run refusals.
  • test_dashboard_cron_update_agent.py and
    test_cron_update_member_recapture.py keep existing PATCH contracts on the
    production async lookup seam.
  • JobForm.projectAgent.test.tsx covers project-agent loading, explicit template
    selection, path changes, stale selection reset, and request ordering.
  • Focused backend regression suite: 729 passed. Flake-pattern ratchet: 68 passed.
  • Related backend selection has 77 outer-sandbox failures; the exact same 77
    node IDs fail on clean current main, leaving zero branch-only failures.
  • JobForm regression suite: 201 passed. The four scoped frontend batches passed.
  • Formatting, lint, typing, Semgrep, docs, localization, Electron, bundle, and
    chunk-cycle gates passed on the rebased tree.

Manual verification

An isolated-gateway Playwright probe reached the Schedule page with the project
fixture. The final capture could not reuse the probe's one-time startup sign-in,
and the host security policy correctly refused minting another credential. The
preview gateway was stopped cleanly. The form behavior is also covered by the
focused browser tests and production build above.

Screenshots / video

Pending: the obsolete screenshots were removed because they show mechanisms and
copy that are not in this rewrite. A fresh Schedule-form screenshot must be
attached after an interactive dashboard sign-in; no credential or captured
sign-in URL is included in this PR.

Related Issues

Closes #8952

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

Contribution License Agreement

I agree to the repository's Apache-2.0 contribution terms.

@mbajaj92
mbajaj92 requested review from a team and Zedmor September 7, 2026 07:30
@github-actions github-actions Bot added the fork Pull request from a fork (external contributor) label Sep 7, 2026
@mbajaj92

mbajaj92 commented Sep 7, 2026

Copy link
Copy Markdown
Author

Intent: Let a scheduled cron job optionally bind to a project directory, so both the Schedule page's agent picker and fire-time execution can use that project's own .kiro/agents/*.json agents instead of only global ones.
Not a goal: Per-project memory stores, cron-folder-level path binding (path lives on the individual job), or changing agent-file existence checks at launch time (that is a separate, pre-existing gap tracked outside this PR).

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

github-actions Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5, fork) — 🟡 CONCERNS

Design-level review of e389382d0b66200fba9d1f4b6ed9e1975380532c via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: CONCERNS

Chat resolution changes along with the cron feature: directory-bound chat slots lose a crew's private memory, and that change can't be reverted alone.

Watch

  • The precedence change reaches chat, not just cron. The diff says that within a bound project_dir, the project file "carries the alias's INFRASTRUCTURE away", so its bindings come "from default_agent". This is in _resolve_agent_selection, which every caller shares. So a chat slot bound to a folder whose .kiro/agents declares a crew's kiro_agent template now runs on Global memory instead of that crew's private store. The user gets no notice in chat. The only overrides global label is in the cron picker. The "Not a goal" section says chat resolution is unchanged, but it is changed for exactly these slots.
    Clears when: the full Backwards compatibility section names this upgrade change for chat slots, and the chat surface shows when a project file has displaced a crew (or the flip is limited to callers that opt in to it).
  • Hard to walk back. The resolver change is a core session-start path. It ships together with a feature that adds project_path to saved job records, owner gates on read and re-enable, SEL denials, and three unrelated fixes. If the chat change goes wrong, the only clean revert also strips project_path from jobs users have already saved.
    Clears when: the resolver precedence change (loader.py/sections.py/execution_context.py) lands in its own PR ahead of the cron binding feature.
  • Take-away check is partial. The Backwards compatibility section is cut off at the truncation notice ("One behaviour change on upgra…"). So I checked only the readers it lists, plus the enabled-must-be-boolean rule (the in-repo caller website/src/api/client/cron.ts:toggleCron sends a boolean, so it still works).
    Clears when: the compat section fits under the description limit and lists every reader of the flipped precedence and of the new 400 on non-boolean enabled values.

Suggestions

  • Split the three side fixes (ProjectPicker Radix handling, the 400 on non-boolean enabled, roster scope via requesting_slot_project) into their own PRs. The repo allows one logical change per commit and at most two commits per PR.

[DESIGN-REVIEWED] e389382

Description read

[DESCRIPTION-READ] 2dc683e2585db6fa17ca7a56ef764532653bcf98b379e937c1da9bd5eedbfe00

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

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5, fork) — 🟡 CONCERNS

UX-level review of e389382d0b66200fba9d1f4b6ed9e1975380532c via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

UX-Verdict: CONCERNS

A typo in the project path says the agent "isn't defined in this project" when the real problem is that the path doesn't exist.

Watch

  • The reset notice blames the agent for a bad path. With an invalid or half-typed path, /api/agents?project_path= still returns 200 with only the global agents. The reconcile step then clears the project agent and shows "{{name}} isn't defined in this project, so the agent was reset to default." The user goes looking for a missing agent file in a folder that doesn't exist. The real cause only appears at Save ("must be an existing directory"), at the bottom of a long form. This hits anyone who types a path instead of using Browse, every time they mistype. Smallest fix: when the roster can't confirm the folder exists, say "Check the project directory path" instead of "isn't defined in this project".
  • The chip "overrides global" is clipped. Read alone, "global" what? It only works because the hint underneath explains it (attachment-03/04), and that hint is visible only while the picker is open. Nothing on the closed Agent field says the selected agent is the project's copy. A user who reopens the job later sees release-checklist with no sign that a project file has replaced their configured agent. Smallest fix: show the chip, or one muted line, beside the closed selector when the chosen agent is an override.
  • No first-time reader has seen any of the new controls in this lane. That covers the Project directory field, Browse, the "project agent" and "overrides global" chips, the reset notices, the roster error with Retry, and the reworked Last Error panel. The screenshots show all of them, so this caps the verdict at CONCERNS rather than blocking. The "Retrying…" pending label appears in no screenshot.

Suggestions

  • In attachment-03, every row, including project rows, also carries the kirocrew source badge, so a project row shows three chips. The project rows don't need kirocrew; drop it there so the scope chip reads as the row's identity.
  • Retry floats right-aligned below Browse, apart from the error text it belongs to (attachment-05). Put it inline right after the sentence.

[UX-REVIEWED] e389382

Description read

[DESCRIPTION-READ] 7d38c6cf9a047e81b943c93d23e6a70fc1d39e82555bb7844bd73623e40e6ed1

That sha256 names everything this verdict read: the PR description, plus the 15 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 7, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5, fork) — 🟡 CONCERNS

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

First-Principles-Verdict: CONCERNS

The shared resolver now lets a project file beat a crew alias in every directory-bound chat, not just in cron jobs. That is the chat change ## Not a goal rules out, and it rests on kiro-cli behaviour that has only been confirmed on kiro-cli.

Not justified as shipped

  • Item 4 — oversized: Not a goal says "Changing how a CHAT session resolves its agent", yet crew-mode.md now says "Inside a bound project directory that order inverts for step 1". A private member's chat in such a folder drops to memory_store_name == "default" (test_project_override_survives_the_wrapper…). The premise is "kiro-cli searches <project>/.kiro/agents first", but the PR says it is unproven on KAS and Claude. On those backends a chat can lose its member's store when no project file even runs.
    Subtraction: limit the project_wins override to callers on the cron fire/save path that pass a project_path. Chat-slot callers keep the base alias-first result.
    Clears when: the chat-side override is gated on the Kiro backend or removed, or a human amends the Goal.
  • Item 8 — rides along: the 400 for a non-boolean enabled has nothing to do with agent binding.
  • Item 9 — rides along: the Radix scroll/dismiss handling in ProjectPicker.

What this change ships

Inventory (10 items) — 7 justified

Intent: a scheduled job runs as the agent you picked or skips with a reason, and can use a checkout's agents. This is an ADDITION plus a FIX.

  1. A job gets a Project directory field, which sets its cwd and adds that directory's agents to the picker — justified
  2. An agent that no longer resolves is a named, red skip instead of silently running the default — justified
  3. On a name collision the picker shows the project row marked "overrides global" — justified
  4. A directory-bound chat slot now resolves a colliding alias to the project file on the Global store — oversized
  5. A non-owner cannot see a bound job's directory, output or replayed rows — justified
  6. An imported bound job is re-validated and restored paused — justified
  7. Last Error panel is now shown for message jobs, not only script jobs — justified
  8. Enable route rejects a non-boolean enabled — rides along
  9. ProjectPicker scroll/dismiss handling — rides along
  10. The agent roster is scoped by the requesting slot's folder, not whichever tab has focus — justified

[FIRST-PRINCIPLES-REVIEWED] e389382

Description read

[DESCRIPTION-READ] dd7dc29c7541573917dc8455abfa8e31d7eea77b7901df6194c25120332c41be

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

Copy link
Copy Markdown
Contributor

GPT 6.1 Review (fork) — 🔴 changes requested (blocking)

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

2 of 2 blocking finding(s) are security-class and were withheld from adjudication, so the blocking verdict stands.

BLOCKING -- src/kiro_crew/dashboard/websocket_hub.py:185 -- Slot summaries expose project-bound output to non-owners

and not project_output_visible_to_non_owner(data)
A project-bound cron result → injection retains the marked row → slot projection copies its text into last_message → the unmarked slots envelope passes this check and exposes the preview to non-owners; REST and SSE serve the same unfiltered summaries.
Anchor: residual/security
Fix: Filter project-bound rows before deriving non-owner slot summaries, including previews and options, across REST, SSE, and WebSocket delivery.

BLOCKING -- src/kiro_crew/slack/gateway.py:6244 -- Project overrides conflict with persistent execution records

execution=_dispatch_execution,
A persistent job previously run on a private V1 store gains a matching project agent → dispatch projects its execution onto Global → _acquire_with_model_fallback binds without replacement → UnknownMemoryStore aborts subsequent fires because runtime reset preserves the conflicting durable execution.
Anchor: residual/crash-data-loss-corruption
Fix: Reconcile the changed durable execution through compare-and-set replacement before acquisition, after pending-work admission, as the sequence path does.

[BLOCK-MERGE] e389382
[GPT-REVIEWED] e389382

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

F1 (fenced): cross-user information exposure. The slot projection copies a cron row's text into last_message (src/kiro_crew/dashboard/slot_projection.py:456). The new gate only checks dict frames, and the diff exempts the list-shaped slots envelope (websocket_hub.py hunk, patch lines 4092–4100). An ordinary project-bound cron that injects into chat is enough to reach it, so no extreme condition is involved.

F2 (fenced): every fire of an affected persistent job aborts, and the job stays stuck until someone edits it. If the session's record already belongs to a different execution, a bind without replace raises "session already belongs to another execution" (src/kiro_crew/execution_context.py:1142-1144). The single-agent path binds _dispatch_execution without replace_execution (patch 6022–6030; base gateway.py:4623). Meanwhile _unshadowed_dispatch_execution moves the store onto Global as soon as the checkout declares the dispatched name (patch 5066–5079). A branch landing a .kiro/agents file is a routine event.

[ADJUDICATION] e389382d0b66200fba9d1f4b6ed9e1975380532c total=0 uphold=0 downgrade=0
[GPT-ADJUDICATED] e389382d0b66200fba9d1f4b6ed9e1975380532c

[ADJUDICATION-FENCED] e389382d0b66200fba9d1f4b6ed9e1975380532c fenced=2 flagged=0
UPHOLD-FENCED F1 src/kiro_crew/dashboard/websocket_hub.py:185 -- The list-shaped slots envelope is exempt from the new dict-only check, but it still carries last_message previews built from project-bound cron rows, so an ordinary cron-to-chat run exposes owner-only output to non-owners.
UPHOLD-FENCED F2 src/kiro_crew/slack/gateway.py:6244 -- A routine project-agent addition moves a persistent job's dispatch store onto Global, and the non-replacing bind at gateway.py:4623 then raises against the retained durable record (execution_context.py:1142-1144) on every fire, which is not an extreme condition combination.
[GPT-ADJUDICATED-FENCED] e389382d0b66200fba9d1f4b6ed9e1975380532c

@github-actions

github-actions Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review (fork) — ✅ no blocking findings

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

Review details

No findings block this merge. Two advisory issues remain.

FINDING — website/src/components/JobForm.tsx:16151 (diff line) — effectiveAgents keeps every row from the global agents prop whose name is not in projectNames. The backend drops alias X from the project roster when the folder declares X's kiro_agent template T (shadowed = {n for n, a in cfg.agents.items() if a.kiro_agent in project_names}), but the form still offers X. shadowedGlobals does not mark X as overridden either. A job saved with X resolves to project_wins at fire time and runs T on Global memory, and the form never says so → Fix: when a project roster has loaded, drop global rows the fetched roster omits and mark them as overridden. Do not union them back from agents.

FINDING — src/kiro_crew/dashboard/messaging_api/notifications.py:4074 (diff line) — for a non-owner, the handler filters notifications but still returns the global "unread": state._unread_count. The Notifications page's unread card then counts project-bound notifications the non-owner can neither see nor clear → Fix: for a non-owner, compute unread from the filtered list.

[OPUS-REVIEWED] e389382

@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 7, 2026
@mbajaj92
mbajaj92 force-pushed the feature/cron-project-agents branch from d27f62b to d48d067 Compare September 7, 2026 19:08
@mbajaj92

mbajaj92 commented Sep 7, 2026

Copy link
Copy Markdown
Author
  • BLOCKING — src/kiro_crew/cron.py:2168 — Synchronous filesystem probes block the event loop

Fixed. Added _validate_project_path_async (a worker-thread offload via asyncio.to_thread) and a _resolved_project_path escape-hatch parameter on _build_job. add_job_async and add_job_if_absent_async now pre-resolve project_path off-loop before calling _build_job, so the sync os.path.realpath/os.path.isdir calls never run on the event loop from an async caller. Sync callers (add_job, add_job_if_absent, the MCP/CLI update paths) are unaffected since they never run on the loop. Verified via the repos own check_sync_io_in_async.py gate, which now passes.

@mbajaj92

mbajaj92 commented Sep 7, 2026

Copy link
Copy Markdown
Author
  • BLOCKING — src/kiro_crew/slack/gateway.py:4771 — Unresolved project agent silently runs as default

Fixed. Both fire-time paths now check resolve_agent_bindings(...).requested_resolved before dispatching. When False (the job named a specific agent inside project_path that could not be found there), the run is skipped with the same neutral shape as the existing missing-folder check: last_status="error", run_never_started=True, no record_failure() call. Added 3 regression tests in test_cron_gateway_integration.py::TestUnresolvedProjectAgentSkipsRun covering the single-agent skip, the sequential skip, and a resolved-agent control case.

@mbajaj92

mbajaj92 commented Sep 7, 2026

Copy link
Copy Markdown
Author
  • BLOCKING — src/kiro_crew/dashboard/handlers/cron.py:627 — Non-string project path crashes PATCH

Fixed. project_path now routes through validate_string_field(body, "project_path", max_len=MAX_SHORT_STRING) wrapped in a try/except ValidationError, mirroring the create/POST paths existing pattern and the name/message PATCH fields on the same handler. Added test/test_cron_patch_project_path_validation.py (5 tests: valid path, oversize cap, non-string array, falsy non-string 0, empty-string clears binding) modeled on the existing test_cron_patch_name_validation.py.

@mbajaj92

mbajaj92 commented Sep 7, 2026

Copy link
Copy Markdown
Author
  • FINDING — website/src/components/JobForm.tsx:277 — manual .then() bypasses use-react-query

Rebutted as disproportionate for this PR. useAgents() (the hooks own react-query wrapper) unconditionally calls syncKirocrewAgents() on every mount regardless of arguments, which would double-fire the sync/fetch for every JobForm mount even when no project path is set — the common case. Trying the useAgents() route while building this feature broke 11 existing JobForm.agentRoster tests via a React "Should not already be working" act() cascade. The local useEffect gated on a non-empty projectPath, calling the client fetch directly, is a deliberate choice made specifically to avoid that regression, not an oversight. Migrating useAgents() itself to skip the unconditional sync when unneeded is a real improvement but a separate, larger change than this PRs stated scope.

@mbajaj92

mbajaj92 commented Sep 7, 2026

Copy link
Copy Markdown
Author
  • Term drift for the run folder — a third name ("Operating folder") for a concept already called "Working directory"/"Project directory"

Fixed. Renamed operating_folder* -> working_directory* across en.json, all 11 translated locale files, JobForm.tsx, AgentSelector.tsxs comment, and en-XA.json (regenerated), reusing the apps existing "Working directory" term rather than the coined one.

@mbajaj92

mbajaj92 commented Sep 7, 2026

Copy link
Copy Markdown
Author
  • Redundant "Optional." — helper text repeats the (Optional) chip already on the label

Fixed. Dropped the leading "Optional." from the description string across all 12 catalogs; the field label already carries the (Optional) chip.

@mbajaj92

mbajaj92 commented Sep 7, 2026

Copy link
Copy Markdown
Author
  • Two undocumented, out-of-scope hunks: temp-screenshots/*.png and package-lock.json libc-field removals

The screenshots are intentional (the PR templates own mandatory UI-screenshot requirement) and stay, committed under temp-screenshots/<feature>/ per that templates own convention. The package-lock.json libc-field diff was investigated and found to be a false read against a stale fetched origin/main mid-session — against the actual merge-base the file has zero diff. No change needed on this PR.

@mbajaj92

mbajaj92 commented Sep 7, 2026

Copy link
Copy Markdown
Author
  • Sequential cron jobs never clear a restored project_path_missing

Fixed. The sequential paths missing-folder check now computes _path_missing unconditionally (not only inside the missing branch) and persists it whenever it differs from job.project_path_missing, mirroring the single-agent paths two-way update exactly. Added 2 regression tests (test_sequential_job_persists_the_missing_flag, test_sequential_job_clears_the_missing_flag_once_the_folder_returns) in test_cron_gateway_integration.py.

@mbajaj92

mbajaj92 commented Sep 7, 2026

Copy link
Copy Markdown
Author
  • project_path_missing has zero frontend consumers

Rebutted as not dead. The flag still has a real backend purpose independent of any frontend render: it gates whether the fire-time path re-persists a state change (if _path_missing != job.project_path_missing), avoiding an unconditional write on every tick. The visible-to-users signal is the runs own last_status="error"/last_error, which the design deliberately consolidated onto (the separate list-page badge this flag once drove was removed per an earlier explicit product decision). Adding a frontend consumer for it is a legitimate future enhancement, not a defect in this PR.

  • Duplicate validator: CronService._validate_project_path vs chat_folders._validate_project_dir

Rebutted as disproportionate for this PR. The duplication is real and worth consolidating, but doing so safely (extracting a shared helper both modules import, checking no caller relies on a subtle difference between the two) is a bigger refactor than this PRs stated scope. Flagging as a legitimate follow-up rather than fixing inline.

@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Sep 7, 2026
@mbajaj92
mbajaj92 force-pushed the feature/cron-project-agents branch from d48d067 to b1147c7 Compare September 7, 2026 19:21
@mbajaj92

mbajaj92 commented Sep 7, 2026

Copy link
Copy Markdown
Author
  • Subtraction: drop sourceLabel — only one folder is ever merged, so the existing source: "project" badge already identifies it

Fixed. Removed the sourceLabel field from AgentSelector.tsx (type + render) and the folderName computation + merge in JobForm.tsxs effectiveAgents. Verified: no test in the repo asserts on this specific field (the 18 sourceLabel hits in appstoreCategories.test.ts are an unrelated same-named function in the appstore module). 69 tests across the 4 affected files still pass.

@mbajaj92

mbajaj92 commented Sep 7, 2026

Copy link
Copy Markdown
Author
  • Subtraction: replace _validate_project_path with a call to chat_folders._validate_project_dir

Rebutted, with the concrete check actually done rather than a blanket "bigger refactor": chat_folders.py imports dashboard.state.DashboardState, dashboard.token_auth, and sandbox.voice_runtime_workspace_conflict -- a dashboard-layer import chain. cron.py is used standalone by the CLI and MCP surfaces with no dashboard dependency today; importing chat_folders into it would pull that whole chain into a module that currently has none of it, which is a real architectural regression, not just extra lines. The genuinely safe version of this fix is extracting the shared 4-check sequence into the leaf kiro_crew.security module (which both files already import is_sensitive_path from) and having BOTH cron.py and chat_folders.py call it -- but that touches chat_folders.py, a file entirely outside this PRs diff, which is a scope decision I am not making unilaterally mid-review. Filing as a follow-up.

@mbajaj92

mbajaj92 commented Sep 7, 2026

Copy link
Copy Markdown
Author
  • Subtraction: drop project_path_missing entirely — last_status/last_error already carry the signal

Rebutted, with the added cost now on the table: this field is not incidental residue -- both fire-time persist blocks that carry it are the exact code the Opus-flagged sequential-clear bug lives in, which this same round already fixed and covered with 2 new regression tests. Deleting the field now would mean re-touching that just-fixed code, deleting TestCronListFields list-serializer test coverage added deliberately last session, and losing the only mechanism that keeps the persist call from being unconditional on every tick (if _path_missing != job.project_path_missing). The "write-only from the frontend" observation is accurate and a legitimate case for adding a consumer later, but removing the field outright discards backend-side value the finding does not account for.

@mbajaj92

mbajaj92 commented Oct 5, 2026

Copy link
Copy Markdown
Author

Rebased: 22c3bb879 -> 23722cba85 onto c6bfd72db (base had advanced 44 commits and the PR had gone CONFLICTING). Three conflicts, all resolved as unions rather than a choice of side:

  • cron.py — CronService.create() gained upstream's quarantine_unreadable beside this PR's on_jobs_removed; the body already referenced both, so only the signature needed the union.
  • slack/gateway.py — upstream's store-quarantine handling kept alongside this PR's _cron_binding_loop and on_jobs_removed wiring.
  • test_security_gate_liveness.py — _PACKAGE_LINE_BUDGET measured from the merged tree at 28,477, above both sides (upstream 28,428, this branch 28,461), since each side counts only its own additions. Both sides' reason comments retained.

Why the AI review lanes have not been publishing. The authentic-diff step in every fork review workflow fails closed above 1,000,000 bytes, before any code is read. This PR's diff was 1,013,138 — 13,138 over — so GPT, Opus, Security Scope, Design, First Principles and UX were all exiting in 94-102s without reviewing (UX reports that as success, titled "skipped — no UI surface"). The diff is now 993,813 bytes, 6,187 under the cap.

How the bytes were freed — test consolidation only, no feature code removed and no test deleted:

  • website/src/test/ — 7 fragmented JobForm.* files merged into 2 (JobForm.projectAgentReset, JobForm.saveAndBinding), paying the shared vi.mock/import/helper preamble once instead of seven times. All 33 it(...) bodies preserved verbatim.
  • test/test_slack_gateway.py and test/test_cron_gateway_integration.py — repeated per-test mock scaffolding hoisted into shared fixtures (mock_cs.create = AsyncMock(...) appeared 12x, patch(...warm_project_agent_names...) 18x). Collected test count unchanged at 563 before and after.
  • test/test_cron_run_text_path_disclosure.py — the three history routes' withheld-on-bound / unchanged-on-non-bound control cases parametrized; every assertion preserved, including trace on run-detail and unified-history.
  • test_cron_mutating_route_owner_gate_coverage.py left fully intact: it is the completeness ratchet that enumerates mutating /api/crons routes from the real router, and its four concrete refusal tests are what keep _GATED honest.

A stale spec citation to one of the merged-away test files was caught by docs-lint and repointed to the merged file.

Verified on this head: mypy clean (2,183 files), flake8/black/isort clean, isort tripwire 0, docs-lint clean, tsc clean, 44,585 frontend tests passing, 739 backend tests over the security-gate pin and both conflict-resolved modules, body 498/500 words.

@mbajaj92

mbajaj92 commented Oct 5, 2026

Copy link
Copy Markdown
Author

Landing order, so reviewers aren't reviewing a half that will change.

@bolichen97's triage note flagged that this PR and #10107 both add ?project_path= to GET /api/agents with different resolvers. I own both, and the decision is: #10107 lands first and its resolver is the contract.

Why that way round: #10107 uses agent_discovery._resolve_roster_project_path with a descriptor-pinned walk and ScanUnverifiable → 503, which GPT drove in specifically for the check-then-use window on an owner-supplied ?project_path= — a caller pointing the scan at an arbitrary directory. Both GPT 6.1 and Opus 5.5 now pass that head with no findings. A cron's configured project_path is the same threat shape, so landing this PR's by-name walk on that endpoint would reopen a window two lanes already closed.

What changes here after #10107 merges: _resolve_agents_project_path and the api_kirocrew_agents.project_path SEL op give way to _resolve_roster_project_path. That is the endpoint read only — the cron-side resolution is untouched, because the pinned walk is confined to raise_unverifiable=True owner-supplied paths and every other caller keeps the by-name walk.

The cost, stated plainly: the endpoint read then answers 503 scan_unsupported_platform on Windows, where a directory descriptor cannot be pinned. Cron binding itself still resolves by name.

@Zedmor @dodgeblaster — the cron-side logic is the part worth your review time; the endpoint half is scheduled to change and I'll push that swap once #10107 is in. I can't make it now: _resolve_roster_project_path doesn't exist on main yet.

@mbajaj92

mbajaj92 commented Oct 6, 2026

Copy link
Copy Markdown
Author

Fixed: span=d9f6439f8c84 — ## Backwards compatibility is no longer truncated, and its readers are now inside the 8,000-byte window.

The finding was exact: the heading sat at byte 7,564 while the lane reads only the first 8,000, so just 436 bytes of the section were visible and all of it was prose. The section now opens with the reader list, measured to close inside the window:

  • 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 caller of resolve_agent_bindings that passes a project directory; the cron one is the only caller that opts out, via allow_project_override=not member_id. All five live under src/kiro_crew/.

Verified on the published body rather than a local draft: the section now starts at byte 7,441, leaving 559 bytes, and all five lines close inside the window under LF and worst-case CRLF — an earlier attempt passed under LF and cut the fifth line under CRLF. Bytes for this were freed by compressing four verbose passages in ## What changed, not by dropping content.

@mbajaj92

mbajaj92 commented Oct 6, 2026

Copy link
Copy Markdown
Author

Fixed: span=9a36abcd2692 — the description overclaimed; the code was right. Scoped the guarantee and gave the reason.

I checked the code before rewording, and the finding is correct: both fire paths gate the named skip on job.project_path or _validate_unbound_one_shot, so it was never "every job". The narrow scope is deliberate, and slack/gateway.py says why in its own comment — an unbound recurring job dispatches as captured because "an app-registered agent or an un-aliased crew name is not a config.agents alias and must keep firing". Re-resolving those at fire time would strand jobs that work today.

So the description was the defect, not the gate. It now reads:

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.

That takes the first of the two offered exits — scope the guarantee and state the reason — rather than widening the skip to recurring unbound jobs, which would be the behaviour change the code comment deliberately avoids.

@mbajaj92

mbajaj92 commented Oct 6, 2026

Copy link
Copy Markdown
Author

Accepted and deferred: span=8ebb37a6b9cb — the finding is correct. "Unbind the member" names no control, and I am not rebutting that.

I checked rather than argued. The message is slack/gateway.py:973, and the only user-facing "unbind" wording anywhere in the frontend is CrewEditorDialog.tsx:389 — "deleting a crew unbinds it from new sessions". Inside JobForm every unbind token is internal (unbindHandledRef, the clear-on-unbind effect). Decisively: boundMember = job?.member_id || memberId arrives as a prop, not a field, and the only write is body.member_id = boundMember — so the dialog has no affordance to clear it, exactly as reported.

Two reasons this is a defer rather than a fix on this head:

  1. The first remedy is fully actionable and is the one in the reader's own hands. "Rename the project's agent" is a file in their checkout, and the sentence leads with it. The reader is not left without a next step — they are left with one of two next steps unavailable.
  2. The honest fix is a code change, and this head cannot carry it. Rewording the second remedy means editing the f-string plus SchedulePage.lastErrorVisibility.test.tsx:59, which pins the literal "unbind the member.". Per this repo's review-repair routing a change answering an AI finding goes through model-pinned repair, not an inline parent edit; and the diff currently sits 6,187 bytes under the hard 1,000,000-byte authentic-diff cap that kept every review lane from reading this PR at all until this head. I am not spending that headroom on wording while two [BLOCK-MERGE] findings still need it.

Recorded for the same round as those fixes: reword the second remedy to name an action the UI offers, or add the control. Not forgotten, and not disputed.

@mbajaj92

mbajaj92 commented Oct 6, 2026

Copy link
Copy Markdown
Author

Rebutted: span=33b0b942bc0a — the kirocrew badge and the two new chips report different axes, and suppressing it on project rows would misreport provenance.

The observation is accurate: in attachment-03 release-checklist does show kirocrew next to overrides global, and repo-smoke shows it next to project agent. But the two labels are not redundant, and AgentSelector.tsx:38-39 already states the distinction the diff relies on — source names the row's provenance (kirocrew, package, app), while scope names where the definition came from (configured vs this project).

Those axes are independent, and the combination the finding reads as noise is the informative case: a project-supplied agent whose provenance is still Kiro Crew's own format is genuinely kirocrew + project agent, and an app-supplied one in the same directory would read app + project agent. Dropping the provenance badge on project rows would make those two indistinguishable — the row would say where it came from but not what kind of thing it is, which is the narrower of the two readings the picker has to support.

It is also the pre-existing convention rather than something this PR introduced: source renders kirocrew on a configured row today, and AgentSelector.tsx:315 notes the project row carries it "exactly as it does on a configured one". Making project rows the one place provenance is hidden would be the inconsistency.

If the concern is visual density rather than correctness, that is a picker-wide question about showing provenance at all — it applies equally to every configured row on main and should be decided for the component, not introduced as a divergence on the rows this PR adds.

@mbajaj92

mbajaj92 commented Oct 6, 2026

Copy link
Copy Markdown
Author

Both blocking findings are FIXED in c6b4a62adf, not rebutted. Both were security-fenced, so there was no rebuttal path and none is claimed.

F2 — handlers/cron.py:377, history pruning releases private transcript rows. The whole-transcript shortcut is deleted:

-    if not bound_windows:
-        return list(history), False

The report named the mechanism exactly: retention keeps 100 records per job, so pruning removes a bound run's record while its transcript rows survive, after which an empty bound_windows meant "nothing to hide" when it had to mean "cannot prove safe". A row is now served only when a retained unbound run's window positively covers it. A project_bound value that is not a bool returns [], True rather than being read as falsey.

F1 — gateway.py:5212, project-bound results bypass owner checks. Closed on all four paths the finding and the adjudication named. api_notifications was returning state._notification_log with no owner check, as messaging_api/notifications.py:21-25 reported; it now filters through is_owner_dashboard_request. Notification and chat rows carry a real boolean project_bound, and HTTP, SSE, WebSocket and direct 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. Direct GET /api/chat/slots/cron-{id} additionally applies the F2 run-window proof, which is what covers legacy unstamped rows and pruned records.

The adjudication's note that neither disclosure table listed /api/notifications or the cron-{id} slot is answered: learn-cron-dashboard.md gains rows 2c and 2d in the same commit.

Verification. The regression tests fail against unpatched 23722cba85 and pass here — proved in a detached worktree at that commit, not asserted: 11 failures, including test_pruned_bound_record_does_not_release_its_surviving_transcript, which serves 'private row' unpatched and withholds it patched. 411 backend and 33 frontend tests pass; black, isort, flake8, mypy (2,183 files), tsc and docs-lint are clean.

On diff size. The fix cost 18,013 bytes against 6,187 of headroom under the 1,000,000-byte cap that kept every lane from reading this PR until the previous head. Rather than trim the fix, I paid for it by splitting out the isolated ProjectPicker ride-along — which three lanes independently asked to split — and by hoisting repeated mock scaffolding into fixtures in three test files. No test was deleted and no assertion weakened: test counts are 36/36, 25/25 and 14/14 before and after, assertion counts 60→62 (the +2 are this fix's), 110→110 and 21→21, with no skip, xfail or .only added. The diff is 993,337 bytes, 6,663 under.

Copy link
Copy Markdown
Contributor

Open-PR triage (origin/main 5edf2feecb, head 22c3bb879e)

Rebase needed. The merge base 52171b38 is 152 commits behind main. git merge-tree origin/main origin/pr/9201 reports content conflicts in src/kiro_crew/cron.py, src/kiro_crew/slack/gateway.py and .github/black-baseline.txt.

Breaking change, declared but not yet signed off. The First-Principles review already raised the first point below. I am adding the second, which has not been raised by anyone other than the author:

  1. config/loader.py _resolve_agent_selection: when project_wins = alias_hit and project_declares_same_name, a project file now wins over a same-named config.agents alias. allow_project_override=True is the default, so this reaches every already-bound chat slot as well as cron jobs. On upgrade those slots lose the alias's memory store, because session_agent_selection.py skips restoring execution.store when resolved_source == RESOLVED_SOURCE_PROJECT. The base pin test_alias_shadows_project_agent_of_same_name is reversed into test_project_agent_wins_over_an_alias_of_the_same_name.
  2. On main, an existing job whose agent no longer resolves runs under the default agent. After this PR it becomes a named skip, and a one-shot is parked disabled (cron_service/execution.py apply_run_record, or not run.enabled). This is a fix for silent substitution, but any job that relied on the fallback stops running after upgrade, and that should be stated in release notes.

A maintainer needs to accept both flips explicitly before merge. I found no P0 at this head. The fenced GPT finding F1 (transcript replay to a non-owner) is now handled by _non_owner_transcript_rows, which filters per run and fails closed. The "false" truthiness finding is handled by _guard_disclosure_bool.

Overlaps (not duplicates):

Recommendation: REBASE + MERGE-DISCUSSION. Keep this PR open; it is not superseded.

@buluoray

Copy link
Copy Markdown
Contributor

🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca]: @mbajaj92, checking in on this PR for #8952 (also referenced from #13349).

What blocks it today at e389382 (last push 7 Oct): the branch conflicts with main and needs a rebase (the 6 Oct triage note already asked for one), and Backend Lint & Type Check, Sensitive Change Review, the GPT review lane and the Windows installer build are red on this head.

Do you still plan to finish it? If there is no reply within 7 days, a maintainer may take the PR over to land the change.

@bolichen97

Copy link
Copy Markdown
Contributor

Thanks for this PR. It now conflicts with main. Could you rebase onto the latest main and resolve the conflicts? We will review it again once it is rebased and CI is green.

@KiroCrewCaptain

KiroCrewCaptain commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

Code change approver recommendation: A person should decide

Why: the decider raised 2 possible problems and estimates a 60% chance that this change introduces a defect; a person should check them.

Large PR that lets scheduled jobs bind to a project directory, records a template namespace for the agent, and blocks agent- and app-driven activation of project-bound jobs. The backend gates are wired into every activation path I found, the compare-and-swap checks hold under the store lock, and import is handled correctly. Two defects remain. (1) The Schedule form's project-roster check resets a stored configured-alias agent on any project-bound job as soon as the form opens, and the next unrelated save rewrites the job's agent. The server and the PR's own backend test treat that pairing as valid, and no test covers it. (2) The new narrow exception catch in CronSDK.set_enabled drops the SEL 'denied' audit for missing jobs, because cron.py:1134 still raises a plain PermissionError; the existing test passes vacuously. No test, lint or build jobs had run on this head.

Things to check (possible problems the decider raised; at this confidence many turn out to be fine):

  • Open the edit form for a project-bound message job whose stored agent is a configured alias (the stock default crew, a shared-memory alias, or an older crewmate name with no member_id; for example, created with kirocrew cron add --agent coder --project-path /repo). Once the project catalog loads (website/src/components/JobForm.tsx, medium)
  • An app resume or pause of a job ID that doesn't exist no longer writes the SEL 'denied' audit that main writes. The spec (app-kit-platform.md: 'missing and foreign jobs are refused and the SDK audits ownership denial') says it must. test_foreign_and_missing_ids_refuse_and_audit still passes only b (src/kiro_crew/cron.py, low)

An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit a423af4685 · 2601 changed lines. If this recommendation is wrong, reply here: replies are how the approver is evaluated.

@mbajaj92

Copy link
Copy Markdown
Author

Current head 857c21946e6b is waiting for fork workflow approval (17 workflows show action_required). The only executed red is readiness publication, which hit the GitHub App installation rate limit. Could a maintainer approve the workflow run set and rerun PR Readiness afterward if it does not self-heal?

@mbajaj92

Copy link
Copy Markdown
Author

Rebased: main moved in Ops Mission Control rotation/configuration, the cron run contract, and locale catalogs since this head went green (f7e8e73c8d38 -> 8c94d1b55e44); CI re-running.

The approver's PATCH namespace concern is fixed in 6a61a9617c49: PATCH now records agent_kind="template" only when the form explicitly selects a catalog template. Unchanged configured aliases keep alias resolution. Backend and frontend regression tests cover both paths.

@mbajaj92

Copy link
Copy Markdown
Author

Conflict-resolved head 6a61a9617c49 is ready, but all 17 fork workflows are waiting in action_required. Could a maintainer approve this workflow run set so CI and GPT/Opus can start?

@mbajaj92

Copy link
Copy Markdown
Author

Rebased: main moved in the cron run registry and lifecycle files since this head went green (8c94d1b55e44 -> ffc89b7979fb); CI re-running.

The conflict resolution keeps upstream's interrupt alert and this PR's fresh manual-run admission. The newer e812bf0b7422 movement touches none of this PR's files and git merge-tree is clean.

@mbajaj92

Copy link
Copy Markdown
Author

Rebased: main moved in the cron trigger and scheduling files since this head went green (ffc89b7979fb -> c0760706ddb4); CI re-running.

The conflict keeps upstream's status-returning trigger helper and this PR's require_unbound flag. The newer 4c8e231f9085 movement touches none of this PR's files and git merge-tree is clean.

@mbajaj92

Copy link
Copy Markdown
Author

Conflict-resolved head a423af4685ad is ready, but all 17 fork workflows remain action_required. Could a maintainer approve this run set so CI and GPT/Opus can start?

@mbajaj92

Copy link
Copy Markdown
Author

The three re-sync budget is now spent. Main moved another 56 commits and the next conflict is in src/kiro_crew/cron_service/store.py. Could a project maintainer comment exactly Re-sync budget reset so I can resolve and repush it?

The 17 fork workflows also still require maintainer approval.

@mbajaj92

Copy link
Copy Markdown
Author

@bolichen97, could you comment exactly Re-sync budget reset and approve the current fork workflows? The three automated re-syncs are exhausted; the current head is conflicting and all 17 workflows remain action_required. I will do one final rebase onto the current tip after the reset.

This branch has not been deployed

No deployments
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 readiness: action required A blocking check or review needs attention

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