Repository navigation
feat(schedule): set a job's run time limit from the job form - #21496
Conversation
bolichen97
left a comment
There was a problem hiding this comment.
Looks good to me at 79b1a97. No must-fix or should-fix findings from this pass.
What I checked:
timeout_secs_from_bodyrefuses bool, float, string, null and out-of-range values before any write, on both POST and PATCH. On PATCH it runs beforeupdate_job_async, so a refused value writes nothing.- The store accepts the field on create (
build_job) and update (apply_job_update), andapply_job_updatedoes run the cover check on the post-update values. The spec correction inlearn-cron-dashboard.mdmatches the code on main. GET /api/cronsreportseffective_wake_budget(job), and the form sendstimeout_secsonly when the minutes change. A limit set elsewhere in seconds therefore survives an unrelated edit, and the frontend test pins that case.- No other dashboard caller sends a list row back to PATCH, so the new list field cannot be echoed into a write.
- The new module sits outside
dashboard/handlers/, so the feature map gate has no new handler row to require.handlers/cron.pygrowth past its baseline row is report-only. - The linked issue is tier T2, and no path hits the security path list.
Remaining before merge: the fork review lanes and CI have not reported on this head yet, and readiness is not passed. I will look again once they finish.
First Principles Review (Opus 5.5, fork) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. The fix addresses #18552 directly: the stored Notes
What this change shipsInventory (8 items) — 6 justifiedIntent: let a person see and change a scheduled job's run time limit from the Schedule page without hand-editing
[FIRST-PRINCIPLES-REVIEWED] 228ef14 Description read[DESCRIPTION-READ] ab9704b06aa5a7a9e2ec6faee1f3b7ee41aedc792651ae7f5e2414bc32729b4f That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: the patch only adds an optional field that the store already validates and enforces. It removes nothing, and four committed screenshots show the new control. Notes
[DESIGN-REVIEWED] 228ef14 Description read[DESCRIPTION-READ] fed9e77e2dc313ec2ff56e0c4812363e39726fd1bec8ca1f131445cccb69e9eb 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 |
UX Review (Opus 5.5, fork) — ✅ PASSUX-level review of UX-Verdict: PASS The four committed screenshots show every control this PR adds: Time limit in both layouts, in light and dark, and in Japanese. No first-time reader has looked at them, because this lane reviews forks without a blind read. Notes
[UX-REVIEWED] 228ef14 Description read[DESCRIPTION-READ] 9d865cfb3924126e44e69463f541c95559a7910051302b5e36ef77bf3e9ac80f That sha256 names everything this verdict read: the PR description, plus the 7 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 |
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed |
GPT 6.1 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
|
Thanks for the follow-up commit. The stale-tab fix in 6da1076 looks right to me: the field now compares against the limit it was seeded from, an untouched field follows a re-fetched value, and an edit survives it. The four new tests pin each case, and the spec paragraph matches the code. Clearing and retyping the field also works now. One thing blocks merge: PR Hygiene fails on f1f40a3 because the branch has 4 commits, including a merge of main. The check allows at most 2 and counts a merge commit. Please rebase onto main instead of merging, and squash your commits into one: Then force-push the branch. The screenshot links in the description point at 79b1a97, so they keep working after the rebase. The fork review lanes have reported on this head: Design, Opus and GPT have no findings. First Principles and UX have advisory concerns (the duplicated range check, the horizontal-layout field, and silent clamping above 1440 minutes). They do not block, but a short reply on each would help. |
f1f40a3 to
cd483c4
Compare
|
Thanks @bolichen97. The branch is now one commit, |
bolichen97
left a comment
There was a problem hiding this comment.
Thanks for the rebase. The branch is one commit now and PR Hygiene passes. I compared the new net diff with the previous branch: the form, its tests, the API tests, the field module and the types are line for line the same, and the route hunks sit where the handler split put them.
One thing blocks merge: Backend Tests shard 5 fails on cd483c4 in test/test_cron_handler_facade.py::test_every_name_served_from_outside_the_family_is_visible_to_type_checkers. The new module-level import of timeout_secs_from_body in cron_jobs.py makes the cron facade serve that name, and the facade test requires every such name to also be imported under TYPE_CHECKING in handlers/cron.py. Adding this block to the second if TYPE_CHECKING: section of dashboard/handlers/cron.py, right after the cron_inject import, should turn it green:
from kiro_crew.dashboard.cron_timeout_field import ( # noqa: F401
timeout_secs_from_body,
)
Coverage Gate fails only because that shard failed. Everything else on this head is green or skipped, and the Design, Opus and GPT lanes report no findings.
| from kiro_crew import model_registry | ||
| from kiro_crew.cron import CronStoreBusy, CronStoreUnreadable, is_valid_timezone, parse_time_string | ||
| from kiro_crew.dashboard.cron_inject import chat_folder_exists, move_cron_job_tab | ||
| from kiro_crew.dashboard.cron_timeout_field import timeout_secs_from_body |
There was a problem hiding this comment.
This import fails the cron facade manifest test.
A module-level import in a cron owner module is served through the handlers/cron.py facade, and test_every_name_served_from_outside_the_family_is_visible_to_type_checkers requires the facade to name each such import under TYPE_CHECKING. The facade has no entry for this one, so shard 5 fails with Right contains 1 more item: {'timeout_secs_from_body': ('kiro_crew.dashboard.cron_timeout_field', 'timeout_secs_from_body')}.
from kiro_crew.dashboard.cron_timeout_field import timeout_secs_from_bodySuggestion: add the matching block to the second if TYPE_CHECKING: section of dashboard/handlers/cron.py, after the cron_inject import:
from kiro_crew.dashboard.cron_timeout_field import ( # noqa: F401
timeout_secs_from_body,
)Rule: a required check failing on the current head blocks merge.
Fixed on ac54c0b: the cron handler facade now lists timeout_secs_from_body in its TYPE_CHECKING imports, and the facade and time limit tests pass on this head.
bolichen97
left a comment
There was a problem hiding this comment.
Re-reviewed at ac54c0b.
The blocker from my last review is fixed: the cron handler facade (dashboard/handlers/cron.py) now imports timeout_secs_from_body under TYPE_CHECKING, so the cron facade manifest matches. I ran test/test_cron_handler_facade.py and test/test_cron_timeout_secs_api.py on this head: 35 passed. The rest of the change is the rebase onto main (the job type now lives in website/src/types/index.jobs.ts after the types split, and the i18n context entries moved with it); the feature diff is otherwise unchanged.
I dismissed my earlier request for changes. Approval waits on CI: several Backend Tests shards are still running and readiness has not passed on this head yet. I will approve once it does.
|
The only red check on this head is Could you rebase onto current main and push? Once CI is green on the new head I can re-check and merge it. Nothing else in the change needs to move. |
ac54c0b to
239b4b0
Compare
|
@bolichen97 Rebased onto current main ( Main had added the auto-pause field to Local checks on this head: 136 backend tests passed ( |
bolichen97
left a comment
There was a problem hiding this comment.
Thanks for the rebase. On 239b4b0 the branch merges cleanly with main again, and the range diff against the previous head shows only the conflict resolution next to the new auto pause field: the dirty check, the submit payload and the imports keep both features. The new API tests and the facade tests pass locally on this head.
One blocking item remains, raised by the GPT lane on this head and reproduced here: the Time limit field reads its value with parseInt, so a number written with an exponent or a decimal is cut to its leading digits and saved as a much shorter limit. Details and a suggested fix are inline. Backend and frontend checks were still running when this was written, so I have not confirmed the earlier slow test failure is gone yet.
| const [timeLimitBase, setTimeLimitBase] = useState(defaults.savedTimeoutSecs) | ||
| // The raw text, so the field can be cleared and retyped; it is clamped on blur. | ||
| const [timeLimitText, setTimeLimitText] = useState(String(defaults.timeLimitMin)) | ||
| const parsedLimit = parseInt(timeLimitText) |
There was a problem hiding this comment.
A value like 1e2 is saved as a 1 minute limit
parseInt stops at the first character it cannot read as an integer, and a number input accepts exponent and decimal notation. Typing 1e2 (100) gives parseInt("1e2") === 1, 2e3 gives 2, and 1.5 gives 1. The blur handler then writes that value back and buildBody sends timeout_secs: 60, so every run of the job is stopped after one minute. Checked in Node on this head; main has no such field.
const parsedLimit = parseInt(timeLimitText)Suggestion: parse the whole string, keep the empty draft fallback (note Number("") is 0), and round before the existing clamp:
const trimmed = timeLimitText.trim()
const parsedLimit = trimmed === '' ? NaN : Math.round(Number(trimmed))A test that types 1e2 and expects timeout_secs: 6000 would pin it.
239b4b0 to
caf63bf
Compare
|
self-added: yes
The field now parses its whole text with @bolichen97 the head moved from |
The Time limit parsing issue is fixed on caf63bf, with a test that fails without the fix.
bolichen97
left a comment
There was a problem hiding this comment.
Thanks for the fix. On caf63bf the Time limit field now parses its whole text with Number, keeps an empty field as a draft that falls back to the stored limit, and rounds before the existing 1 to 1440 clamp. I checked the parse and clamp logic directly: 1e2 gives 100 minutes, 1.5 gives 2, 2e3 and Infinity clamp to 1440, and a blank field falls back as before.
The new test reads the whole number the field holds, exponent and fraction included passes on this head (14 of 14 in JobForm.timeLimit.test.tsx), and with only JobForm.tsx reverted to the previous head it fails at the 1e2 step, so it pins the fix. The branch still merges cleanly with current main, and the only change since the last review is this fix and its test.
All five AI review lanes report no blocking findings on this head. Some backend and frontend test shards were still running when I checked, and none had failed.
My earlier change request is resolved, so I have dismissed it. From my side this is ready for maintainer approval. Because it is a feature change across more than 20 files, I am leaving the approval to a maintainer.
A scheduled run that is still going after its time limit is stopped and recorded as timed out. The store, the CLI and the cron tools all carry that limit (timeout_secs), but the dashboard did not: POST /api/crons dropped it, PATCH refused it, the list omitted it, and the Schedule form had no control. So the only way to give a long job more than 30 minutes was a hand edit of crons.json. - GET /api/crons returns each job's effective limit (effective_wake_budget), the one a run actually gets. - POST and PATCH take an optional timeout_secs: a JSON integer in 1..86400, else 400 invalid_timeout_secs before anything is written. The store's own check that a command job's budget covers its subprocess still runs after it. - The job form gains Time limit, in whole minutes, in both layouts and for every job kind. It sends the field only when the minutes change, so a limit set in seconds elsewhere survives an unrelated edit. The cron spec also stops saying that an update skips the budget cover check; apply_job_update runs it on the post-update values. The field holds the limit it was seeded from, so a job re-fetched under an open form (another tab saved a new limit) does not turn an untouched field into an edit that writes the old limit back. It holds raw text and clamps on blur, so clearing it and retyping works. Part of kirodotdev#18552 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
caf63bf to
228ef14
Compare
iamwhatever
left a comment
There was a problem hiding this comment.
APPROVE at 228ef14.
The change carries the existing timeout_secs field across the dashboard's cron routes and into the job form, without changing execution. Invalid values are refused with 400 invalid_timeout_secs before anything is written (cron_timeout_field.py#L21), the list returns the effective budget (cron_board.py#L156), and the form sends the limit only when the minutes change, so a seconds-precise limit survives an unrelated edit. The earlier parseInt defect is fixed with a whole-text parse (JobForm.tsx#L399). Since the last human review (caf63bf) only rebase context changed.
All AI lanes pass on this head with advisory notes only, the earlier change requests were dismissed, and every check is green. Not touched by the sensitive-path rules.
— crew-pr-reviewer (r124)
Problem / Motivation
Goal: A scheduled job's run time limit can be seen and changed from the Schedule page, so a long job is no longer stuck at 30 minutes unless someone hand-edits
crons.json.#18552 reports exactly that: "Long-running tasks appear limited to 30 minutes", and "the timeout appears configurable through manual edits to
/home/$USER/.kiro/crew/crons.json, but the Kiro Crew UI does not expose this setting."The limit is real and already stored per job:
timeout_secs, the whole-run budget, after which_execute_with_timeoutstops the run and recordsTimed out after <N>s. The CLI and the cron tools set it. The dashboard's three cron routes did not:POST /api/cronsdropped the field,PATCH /api/crons/{id}did not accept it,GET /api/cronsdid not return it, and the job form had no control.Why it matters
Anyone who schedules a job that needs more than half an hour (a test sweep, a report over a large repo) gets a run that is cut off. The only remedy inside the product is to ask an agent or use the CLI, and nothing on the Schedule page even says the limit exists.
Not a goal
timeoutof a command or script job. The dashboard does not create those jobs (the create form is always an agent job), and the CLI and cron tools set it. The issue asks to label the two separately if both exist; this form labels its field as the whole run's limit and leaves the subprocess bound where it is set today._JOB_TIMEOUT_SECS, 1800 s) or the accepted range (1..86400).mcp_cron._sub_floor_timeout_notealready describes.What changed (motivation → approach → change)
Approach. The store already validates and enforces the field, so this PR only carries it across the dashboard's HTTP boundary and into the form, and changes no execution behavior.
GET /api/cronsreturns each job'stimeout_secsaseffective_wake_budget(job), not the raw field. A stored value outside the range runs under the default, so the form must show the limit a run actually gets.POST /api/cronsandPATCH /api/crons/{id}take an optionaltimeout_secsthrough one helper,dashboard/cron_timeout_field.timeout_secs_from_body(a new module beside the route owners). The create and update routes live inhandlers/cron_jobs.pyand the list inhandlers/cron_board.py, the owner modules refactor(dashboard): split cron.py handlers into cron_* owner modules #21672 split out ofhandlers/cron.py. A JSON integer in1..86400passes. Anything else (a boolean, a float, a string,null, out of range) is400withcode: invalid_timeout_secsbefore anything is written: a client sending one of those has a bug, and coercing it would store a guess as the job's real limit.apply_job_updateevaluates it on the post-update values, and itsValueErroris the400the form shows.JobFormgains Time limit, a whole-minutes field (1 to 1440) for every job kind. Both places that render the form, the Schedule page's job panel and the crew wake section, use its vertical layout, where the field has a heading and help text. The horizontal layout (the component's default, rendered by nothing in production today) gets the same field with a visible label, as its checkbox neighbours have.timeout_secsonly when the minutes change. A limit set elsewhere in seconds (1000 s shows as 17 minutes) would otherwise be rewritten to 1020 s by an unrelated rename.components.jobFormkeys inen.json, translated in all 11 catalogs (reusing each catalog's existing word for "minutes"), withen.context.jsonentries and the regenerated pseudolocale.learn-cron-dashboard.mdgains "Run Time Limit (timeout_secs)". Its App SDK section also stops saying thatapply_job_updateskips the budget cover check: the code (cron_service/fields.py, "Cross-field: the wake budget must cover the subprocess bound") runs it on every update that changes either value, and a test below drives that through the new PATCH path.Backwards compatibility
Compatible: every new request field is optional and every response field is additive. A client that never sends
timeout_secscreates and edits jobs exactly as before, and a job's stored limit is untouched unless the field is sent.Removes nothing: the change only adds an accepted field to two routes, a returned field to one, and a form control.
Tests
test/test_cron_timeout_secs_api.py(24):400 invalid_timeout_secswith nothing created.400.CronService: a PATCHed limit is whateffective_wake_budgetgives a run; a 60 s budget on adf -hcommand job is refused and the stored limit is unchanged.website/src/test/JobForm.timeLimit.test.tsx(9): default 30 minutes; an existing limit is shown; a change is sent in seconds; an unchanged limit is not sent on create or edit; a 1000 s limit survives a rename; a script job's limit is sent; both layouts edit and save through the real form; the field clamps to 1..1440.Red before the change: backend 20 failed, 2 passed (the two absent-field guards); frontend 8 failed, 1 passed.
Local gates, run on this Windows box:
20fcbd54e8(one commit, no merge): the four route hunks moved fromhandlers/cron.pyintocron_jobs.pyandcron_board.py. The rest of the diff is the previous branch's net change, line for line.test_cron_timeout_secs_api.pyplus everytest_dashboard_cron*.pyandtest_*cron*api*.py: 306 passed, 2 skipped.JobForm.timeLimit.test.tsxpassed.npx tsc -bis clean. black, isort, flake8,check_comment_history.py,check_brand_name.py,check_file_line_cap.py(0 failures) and mypy pass.src/i18n+JobForm: 1,167 passed. The one failure is the samenavLabels.test.tsx15 s timeout, which also fails on a clean main worktree.Earlier gates, on the pre-rebase head:
check_black_formatting.py,check_subprocess_encoding.py,check_comment_history.py,check_brand_name.py,check_file_line_cap.py(0 failures; it reportshandlers/cron.pyandtypes/index.tsgrowing past their baseline rows, report-only), mypy onhandlers/cron_jobs.py,handlers/cron_board.pyandcron_timeout_field.py(clean),docs_lint.py(passed),gen-ui-index --check(up to date),npx tsc -b(clean),npm run lint:i18n(OK), eslint on the changed frontend files (clean),pr-description-check.sh(success).test/test_cron*.py, everytest/test_dashboard_cron*.py,test_api_input_validation.pyandtest_client_py_route_contract.py: 126 files, 3,186 passed, 0 failed.src/i18n(1,022 tests): one failure,navLabels.test.tsx's 15 s timeout, which fails identically with this PR's frontend diff reverted.scripts/local-gate.pyfrontend related set (488 files, run in batches): 14,840 passed. Its two style failures were real and are fixed in the second commit: the Bengali help text used Bengali digits and the French one a plain space before a colon. The four remaining failing files (decisionStripContract,ToolRiskBadgeContract,electronShellEvidence,uiIndex) fail identically at the merge base with this diff reverted.scripts/local-gate.pybackend related set:handlers/cron.pyis a hub file, so it selects 1,483 files, run as the gate's three chunks to the end: 49,754 passed, 221 failed, 10 errors. The 141 unique failing nodes were rerun on a clean worktree at the merge base with nothing of this diff: 140 fail there the same way (cloud source and launch, the AI-review workflow greps, private workflow execution, ACP liveness and sandbox, Slack gateway coverage, and other Windows-local cases). The one that passed there,test_spec_builder_routes_coverage.py::TestScanSubdirs::test_the_listing_is_bounded, passes 3 of 3 alone on this branch and has no path to this diff. Chunk 2 also ended in an xdist INTERNALERROR after six crashed workers, so not every test in that chunk ran locally; CI runs the full suite.Manual verification
The screenshots below are the real
JobForm, rendered by Vite with the real stylesheet and catalogs, with onlyfetchstubbed, editing a job whosetimeout_secsis 7200. Not exercised against a live gateway: the round trip is covered by the real-CronServicetests above.Screenshots / video
The vertical layout, which the Schedule page's job panel and the crew wake section render, light and dark:
The horizontal layout (unused in production), and the Japanese catalog
Related Issues
Part of #18552
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
🤖 Generated with Claude Code