Skip to content

feat(schedule): set a cron job's auto-pause limit from the edit form - #22875

Merged
iamwhatever merged 1 commit into
kirodotdev:mainfrom
Pearcekieser:feat/schedule-auto-pause-limit-control
Oct 22, 2026
Merged

iamwhatever merged 1 commit into
kirodotdev:mainfrom
Pearcekieser:feat/schedule-auto-pause-limit-control

Conversation

@Pearcekieser

@Pearcekieser Pearcekieser commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Let a job's owner see and set its auto-pause limit from the Schedule page's edit form.

#15524 added a per-job auto-pause limit, auto_pause_after_failures. It ranges from 0 to 10000, defaults to 5, and 0 means the job never auto-pauses. The limit can be set only from the CLI (kirocrew cron add/update --auto-pause-after) and the cron_add and cron_update chat tools. An owner looking at a job on the Schedule page can't see its limit or change it there.

Why it matters

The Schedule page is where an owner edits every other part of a job. A job that fails often may need a higher limit, or 0, and today that means leaving the page for a chat or a terminal.

Not a goal

  • Changing what the limit does, its range or its default.
  • Lifting a pause when the limit is raised. A changed limit applies from the next run, as feat(cron): per-job auto-pause limit, including never #15524 specifies.
  • Setting the limit on the create form. New jobs start at the default, and the field appears on the edit form.

What changed (motivation → approach → change)

  1. The cron board (GET /api/crons) now reports auto_pause_after_failures for each job, so the edit form shows the stored value, including 0.
  2. PATCH /api/crons/{id} accepts auto_pause_after_failures. It validates the value with the store's own validate_auto_pause_after_failures before touching the store, so a bad value is a 400 with code invalid_auto_pause_after_failures and nothing is written. null is refused too, because the store reads None as "leave unchanged". The value goes to update_job with an audit_actor that names the writer, so the limit-change SEL row from feat(cron): per-job auto-pause limit, including never #15524 is written exactly as for a chat-tool or CLI write. An app token's write is filed under app:<name>, the name _refuse_foreign_app_job records for the same request. An owner write is filed through audit_actor(request, "dashboard"), which keeps the forwarded marker.
  3. The job edit form shows the limit as a number field from 0 to 10000. Its help text says 0 means never pause, and that from the 5th failure in a row a job set to 0 or above 5 waits 5 minutes before its next run, doubling up to an hour. The form sends the field only when the owner changed it. It hides the field on the create form and when the gateway doesn't report a limit.
  4. The new strings are in all 12 catalogs and en-XA.json is regenerated.
  5. The Schedule page paragraph of learn-cron-dashboard.md names the form as a third way to set the limit.

Backwards compatibility

Additive. The board gains one field, and the PATCH route accepts one more optional key. A client that sends neither sees no change. An older gateway that doesn't report the field makes the form hide it.

Tests

  • test/test_cron_auto_pause_limit_api.py covers the board reporting the default and 0, a PATCH reaching the store with the dashboard as actor, an app token's PATCH filed under app:<name>, a forwarded owner PATCH keeping the forwarded marker, an unrelated PATCH not sending the limit, bad values (-1, 10001, a string, a float, a boolean, null and a list) returning 400 with nothing written, a 0 write producing the never_pause_set SEL row, and a refused value leaving the stored limit and writing no row.
  • website/src/test/JobForm.autoPauseLimit.test.tsx covers showing the stored limit including 0, sending a changed limit, sending nothing when it's unchanged, refusing an out-of-range value without saving, and hiding the field on the create form or when the limit isn't reported.
  • On the rebased head, 4,881 cron and dashboard-cron tests and 1,878 docs tests pass. 334 JobForm, SchedulePage and i18n frontend tests pass. tsc -p tsconfig.app.json, I18N_BASE_REF=origin/main npm run i18n:check, black, flake8 and mypy are clean.

Manual verification

I rendered the edit form for a job with a limit of 0 at desktop width and at 390 px, using a captured board payload. The field shows 0 with its help text.

Screenshots / video

Desktop:

schedule-auto-pause-desktop

Phone, 390 px:

schedule-auto-pause-phone

Out-of-range value: 10001 entered and Save pressed. The hint is plain text under the field, and the page has no alert.

Desktop:

schedule-auto-pause-hint-desktop

Phone, 390 px:

schedule-auto-pause-hint-phone

Related Issues

Fixes #22874

Follow-up deferred from #15524.

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

Contributed under the project's Apache-2.0 license.

@Pearcekieser
Pearcekieser requested review from a team and KiroCrewCaptain as code owners October 21, 2026 19:17
@github-actions github-actions Bot added fork Pull request from a fork (external contributor) 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 Oct 21, 2026
@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5, fork) — ✅ PASS

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

Design-Verdict: PASS

Nothing blocks: the change only adds things. It reuses the store's own validator and the existing audit path, and both screenshots of this revision downloaded.

[DESIGN-REVIEWED] ed224c6

Description read

[DESCRIPTION-READ] 84fd6689427f820f22d9a53c1516a34335bf4489a873c072f5efc19bb5081f92

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

Copy link
Copy Markdown
Contributor

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

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

First-Principles-Verdict: PASS

Nothing blocks. The PATCH route's app-token branch re-labels the audit actor, which audit_actor already does.

Notes

  • Item 3 — duplicate of dashboard/server_runtime/security_middleware.py:87-90: audit_actor already files an app-token request under its app claim. The added f"app:{app}" if app else audit_actor(request, "dashboard") gives that same request a second label (app:<name>), and the _app_caller path drops the forwarded suffix. Subtraction: delete the _app_caller branch and its import, and pass audit_actor(request, "dashboard") on its own.

What this change ships

Inventory (6 items) — 5 justified

Intent: let a job's owner see and change its auto-pause limit on the Schedule page instead of going to the CLI or chat. ADDITION.

  1. The Schedule edit form shows a number field for the auto-pause limit (0..10000), hidden on the create form and on an older gateway — justified
  2. GET /api/crons reports each job's auto_pause_after_failures — justified
  3. PATCH /api/crons/{id} accepts the limit, checked with the store's validator, and records an audit actor (app:<name> or dashboard) — duplicate of security_middleware.audit_actor's app-claim mapping
  4. A bad or null limit returns 400 with invalid_auto_pause_after_failures and nothing is written — justified
  5. New strings in all 12 catalogs — justified
  6. The spec names the edit form as a third way to set the limit — justified

[FIRST-PRINCIPLES-REVIEWED] ed224c6

Description read

[DESCRIPTION-READ] 6fa41b3948f074bbee9b0b9a9c802bbbce68a3beb9ba92bb8ed63942caf0edc9

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

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5, fork) — ✅ PASS (a BLOCK with no Trigger and no Outcome does not block)

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

UX-Verdict: PASS

cannot evaluate: missing the out-of-range hint state. Neither screenshot shows what the form says when someone enters a value outside 0–10000 and presses Save.

Evidence gaps

  • Validation hint. The field shows autoPauseHint ("The auto-pause limit must be a whole number from 0 to 10000.") below the input, and Save stops. Neither attachment shows this state, so nobody has checked where it sits, how it looks next to the muted help text, or whether it can be seen when Save is pressed from the footer. To close it, attach a screenshot of the edit form after entering something like -1 or 10001 and pressing Save.

Notes

  • Help text. "From the 5th failure in a row, a job set to 0 or above 5 waits 5 minutes before its next run, doubling up to an hour" explains the backoff mechanism, not the choice the owner is making. Keep "0 means never pause." and move the backoff detail to a docs link or tooltip.
  • Help text contrast. The help uses text-muted/70, and in attachment-01 it is fainter than the sibling help lines. Use text-muted so the "0 means never pause" meaning stays readable.
  • Label. "Auto-pause after N failures in a row" makes the user work out that N is the number in the box. "Pause after this many failures in a row" says it directly.

[UX-REVIEWED] ed224c6

Description read

[DESCRIPTION-READ] c0f236b3c8dad6407d87a388581ad79c26b57e47a8d4483399c924a0cdd68214

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

Copy link
Copy Markdown
Contributor

Opus 5.5 Review (fork) — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] ed224c6

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review (fork) — ✅ no blocking findings

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

Review details

No findings.
[GPT-REVIEWED] ed224c6

@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 Oct 21, 2026
@Pearcekieser

Pearcekieser commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor Author

fixed in debee13. The out-of-range limit no longer goes through setError, so it never reaches <ErrorNotice>. It is held in its own autoPauseHint state and shown as plain text under the field, with no alert role and no danger colour. The field gets aria-invalid and adds the hint to aria-describedby, and typing in the field clears the hint. refuses an out-of-range limit without saving now checks that the hint has no role="alert" ancestor and that no alert carries its text. It fails on 3649554, where the hint rendered inside the ErrorNotice banner.

@Pearcekieser
Pearcekieser force-pushed the feat/schedule-auto-pause-limit-control branch from 3649554 to debee13 Compare October 21, 2026 20:26
@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 21, 2026
@Pearcekieser

Copy link
Copy Markdown
Contributor Author

fixed in 1ff6e86. The PATCH handler no longer hard-codes "dashboard". It sets audit_actor to app:<name> when _app_caller(request) names an app, the same name _refuse_foreign_app_job records for that request, and otherwise to audit_actor(request, "dashboard"), so a forwarded owner request keeps its forwarded marker. test_an_app_token_write_is_filed_under_the_app sends {"auto_pause_after_failures": 0} for the app's own job and gets app:poller-app. test_a_forwarded_owner_write_keeps_the_forwarded_marker sends X-Forwarded-For and gets a marked actor. Both fail on debee13. The spec paragraph names both actors.

@Pearcekieser
Pearcekieser force-pushed the feat/schedule-auto-pause-limit-control branch from debee13 to 1ff6e86 Compare October 21, 2026 21:01
@Pearcekieser

Copy link
Copy Markdown
Contributor Author

acknowledged. The two screenshots predate the validation hint's current form: since debee13 an out-of-range limit shows one line of plain text under the field, "The auto-pause limit must be a whole number from 0 to 10000.", with the field marked aria-invalid, and no banner. refuses an out-of-range limit without saving checks that text, that it sits in no alert, and that nothing is saved. Typing in the field clears it.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

intended. The branch exists for its prefix. audit_actor files an app-token request under the bare app name, while _refuse_foreign_app_job and _audit_app_cron file the allow row for this same PATCH under app:<name>. With the bare name, one request would leave two SEL rows naming the app two ways, and a reader grepping app:poller-app would find the allow row but not the never-pause row. The Opus finding on debee13 asked for app:<name> for that reason. The owner path still goes through audit_actor, so the forwarded marker comes from one place.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

acknowledged. No change needed. The field reuses the store's validator, and the writer's name goes through the existing audit_actor path that cron.py reads.

The per-job auto-pause limit (0..10000, 0 = never) was settable only through the cron chat tools and the CLI. The cron board now reports auto_pause_after_failures, the job edit form shows it as a number field with the backoff explained, and PATCH /api/crons/{id} validates it with validate_auto_pause_after_failures and passes it to update_job, so the limit-change SEL row is still written.
@Pearcekieser
Pearcekieser force-pushed the feat/schedule-auto-pause-limit-control branch from 1ff6e86 to ed224c6 Compare October 21, 2026 22:12
@Pearcekieser

Copy link
Copy Markdown
Contributor Author

fixed in ed224c6. The form's comparison baseline for the limit is now captured once, in useState, when the form opens. A crons refresh that hands the same mounted form a newer job no longer moves the baseline, so an untouched field still equals it and is not sent. does not send back an untouched limit after a refresh brings a newer one opens a job at 5, rerenders it with 0, saves a name edit and checks that the PATCH carries no limit. It fails on 1ff6e86. The same push also fixes the isort order of the _app_caller import that failed Backend Lint.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

fixed. The description now carries two screenshots of the hint state at ed224c6, desktop and 390 px. Each is the built Schedule page with 10001 typed into the field and the panel's Save pressed, captured after the hint text appeared and scrolled into view. The capture script counted no role="alert" element on the page in either shot.

@github-actions github-actions Bot removed the readiness: action required A blocking check or review needs attention label Oct 21, 2026
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Oct 21, 2026

@iamwhatever iamwhatever left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve. Reviewed head ed224c6.

The edit form shows the job's stored auto-pause limit and sends it only when the owner changes it. The baseline is captured once, so a refresh cannot write a stale value back (JobForm.tsx#L369). The PATCH route checks the value with the store's own validator before any write and refuses null, booleans, floats and out-of-range values with a 400 (cron_jobs.py#L848). The route's existing owner gate and foreign-app refusal run first and are unchanged. The audit row names the app or the owner who made the write. Every lane finding has a disposition at this head, the hint-state screenshots are attached, and all current checks are green. The UX copy notes (label and help wording) are optional and do not block. I read CI and the test source; I did not run the tests.

— crew-pr-reviewer (r119)

@iamwhatever
iamwhatever merged commit a932db7 into kirodotdev:main Oct 22, 2026
112 checks passed
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 22, 2026
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)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Schedule page: set a cron job's auto-pause limit

2 participants