Repository navigation
fix(cron): report a restart-cut run and send call_tool args as written - #33905
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Neither change has a design flaw that blocks: the restart path now goes through Notes
[DESIGN-REVIEWED] a99e533 Description read[DESCRIPTION-READ] aeef02048471c044ccff97ec31ffeea57108c3df5b56775879fc81026bb1a41c 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 |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. The issue is linked (#33831) and tests pin both defects. Two items carry more surface than the Goal needs. Notes
What this change shipsInventory (8 items) — 6 justifiedIntent: a cron run cut by a restart is recorded and its owner told, and script
[FIRST-PRINCIPLES-REVIEWED] a99e533 Description read[DESCRIPTION-READ] f43db8b28efaf441d6701f05912e897832355a843baeaae5bfcdb775a8649fcf That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findings (all downgraded on adjudication)GPT 6.1 flagged blocking issues on This comment is updated in place on each push. Review detailsBLOCKING -- src/kiro_crew/slack/gateway_runtime/cron_failure.py:395 -- Interrupted-run notices promise another run for paused jobs
Adjudication (Opus 5.5) — is blocking on each finding proportionate?F1 — LOW. It needs a narrow pair of conditions: the operator pauses a job while it is running ( False positive or not applicable? A repository writer can comment: |
buluoray
left a comment
There was a problem hiding this comment.
Approved at 637dc8d. Fixes #33831: a cron run cut by a restart now gets a history row and a bell/channel notice on every planned restart path (src/kiro_crew/cron_service/service/run_execution.py:239, service_lifecycle.py:168, src/kiro_crew/cron.py:381, src/kiro_crew/dashboard/handlers/updates_apply.py:309, src/kiro_crew/slack/gateway_runtime/update_schedule.py:1038, src/kiro_crew/slack/events_slash.py:633). call_tool sends args as written or refuses by path (src/kiro_crew/cron_script_context.py:504, :587). Credentials are still refused, so the scan got stricter, not looser. Backend shards were still running when posted.
637dc8d to
0a10f61
Compare
0a10f61 to
ac2d74c
Compare
ac2d74c to
201895c
Compare
buluoray
left a comment
There was a problem hiding this comment.
Approve on 201895c. Since the APPROVE verdict at ac2d74c, the branch was rebased from main 16d40aa onto 08e371d (15 main commits, incl. #33670 restart close). The src/ and test/ patch is identical apart from hunk offsets; range-diff shows only two doc rewordings (cli.md "the one-shot an --at schedule makes"; slack-gateway.md /restart row merges #33670's close_all bound wording with this PR's cron stop). Tests pass and the Slack cron-stop guard still reddens its test on the new base. Decisive lines: src/kiro_crew/slack/events_slash.py:634-639 (cron stop after the slot save and before record_running_slots/close_all, beside main's #33670 bounded close), src/kiro_crew/slack/gateway_runtime/update_schedule.py:1038-1040 (stop_cron_before_restart after the fence, before the session close), src/kiro_crew/cron.py:381-409 (bounded, never raises), plus every Decisive line of review-33905-ac2d74c.md (src/test patch unchanged)
A cron run in flight when the gateway stops or restarts is filed cancelled and not retried, so a daily job skips that day, and its owner was never told. The run now rings the bell and takes the failure alert's one-surface delivery (silent jobs stay quiet, nothing is counted as a failure). The planned in-app restarts stop the cron service after their last refusal, so the run they cut is recorded and its in-flight marker cleared, and kirocrew restart names the running jobs before it signals anything. It reads each job's stored schedule to say whether the job runs again: a consumed one-shot does not, so the line says to schedule it again. ctx.call_tool() and kirocrew cron preview sent arguments rewritten by the credential scrubber, so a Graph message id, a drive id or a CodeDeploy target reached the server corrupted while the run recorded success. A call the scan would change is now refused, naming the argument's path and never its value, and an id or an account and resource name the scan only mistook is sent as written. Chat and display redaction are unchanged. Fixes #33831
201895c to
a99e533
Compare
Code change approver recommendation: A person should decideAutomated, not a person, and not a review: a maintainer still decides.
Why: the decider approves but is not confident enough to auto-approve (p_defect 0.15 > 0.12). Two cron fixes with tests. (1) When stop() cuts a run that has no outcome of its own (no cancel or reap flag), the run is filed cancelled and now starts an owner notice; stop() waits up to 3 s for those notices. All three planned in-app restarts (dashboard and update apply, the update restart, Slack /kirocrew restart) now call stop_cron_before_restart, bounded at 5 s, after their last refusal and before close_all(). Tests cover each refusal path leaving the scheduler running. stop() is safe to repeat, and the SIGTERM _shutdown path is unchanged except for the bounded wait. The kirocrew restart line reads the same home the cron service writes to and is best-effort. (2) The call_tool scan now refuses any change the scrubber would make, where main sent a redacted copy, so it is stricter and fails closed. It only loosens for narrow, documented identifier shapes: a Graph or drive id under an id-named key, and an account-id resource name, which is re-checked with the ':' read as a space. Verified against the callers, the restart ordering and the cron claim and cancel paths. No regressions or fail-open paths found. Windows backend CI was still pending. If this recommendation is wrong, reply here; the replies are how the approver is evaluated. |
buluoray
left a comment
There was a problem hiding this comment.
Approve on a99e533. Since buluoray's approval at 201895c the branch was only rebased, from main 08e371d onto 4477b72 (259 main commits). The PR's added/removed lines in src/, test/ and docs/ are byte-identical; the only diff text change is hunk context in the dashboard/handlers/updates.py TYPE_CHECKING import list (main added overlay_owners imports). Tests pass and the Slack cron-stop guard still reddens its test on the new base. The one [BLOCK-MERGE] on this head (GPT, downgraded) is a rare wrong-notice-text case: APPROVE with it named. Named finding for @bolichen97 (non-blocking, rare): cron_failure.py:394-395 decides 'will run again at the next scheduled time' from schedule.kind alone, so a recurring job an operator paused mid-run and then interrupted by a restart gets that text although it won't run; please gate the line on the job being enabled in a follow-up. Decisive lines: src/kiro_crew/slack/events_slash.py:637-643 (cron stop after the slot save, before record_running_slots/close_all), src/kiro_crew/slack/gateway_runtime/update_schedule.py:1039-1045 (cron stop before record/close), src/kiro_crew/dashboard/handlers/updates_apply.py:318-323 (dashboard restart, same order), plus every Decisive line of review-33905-201895c.md (src/test/docs +/- lines unchanged)
Backport of #33905 (main ffc89b7). Conflicts resolved to the release side: dropped main-only trigger_run, expected_owner and overlay_owners imports and the quiet_run context lines; added set_interrupt_alert only. security.md: the PR sentence was applied into the release JWT bullet. test_cron_stop_interrupt_notice.py got a local _trigger_run helper in place of CronService.trigger_run.
Backport of #33905 (main ffc89b7). Conflicts resolved to the release side: dropped main-only trigger_run, expected_owner and overlay_owners imports and the quiet_run context lines; added set_interrupt_alert only. security.md: the PR sentence was applied into the release JWT bullet. test_cron_stop_interrupt_notice.py got a local _trigger_run helper in place of CronService.trigger_run.
Problem / Motivation
Goal: A cron run that a gateway stop or restart cuts short leaves a history row and its owner is told, and a script cron's
ctx.call_tool()sends every argument exactly as the script wrote it or refuses the call by name.This PR fixes two cron defects, reported together in #33831:
cancelledand is not retried, so a daily job loses that day. The history row is the only trace: no bell note, no channel or Slack message. The planned in-app restarts (the dashboard's Restart and update apply, the gateway's update restart, and Slack/kirocrew restart) never stop the cron service, so the run they cut leaves no history row at all and its in-flight marker stays behind.kirocrew restartgives no warning that it is about to interrupt a job.ctx.call_tool()sends arguments the credential scrubber rewrote.ctx.call_tool()andkirocrew cron previewsend the redacted copy of the arguments, and refuse only an argument that the redaction tag replaced whole. A Microsoft Graph message id, a SharePoint drive id or a CodeDeploy target (<region>:<account>:<application>:<group>:CD) loses part of its text, the server rejects an id the script never wrote, and the run still records success.Why it matters
Not a goal
cancelledand runs again at its next scheduled time; this PR records it and tells the owner.call_toolargument scan reads two of those rules differently.What changed (motivation → approach → change)
A run that a restart cuts now leaves a history row and tells its owner, and a
call_toolargument goes out byte-identical or the call is refused with the argument's path.CronService.stop()filed the runcancelledand told no one. The planned in-app restarts end in an exec or a hard exit, so the gateway's_shutdown, wherestop()runs, never ran for themstop()starts a notice for each run it cut and waits for them, at most 3 s. Each planned restart calls the newstop_cron_before_restart, bounded at 5 scall_toolsends rewritten arguments_scanned_tool_argssentredact()'s output and refused only an argument the tag replaced wholeRestart-cut runs. The gateway's notice,
_alert_cron_interruptedinslack/gateway_runtime/cron_failure.py, is set incron_fire.pythrough the newCronService.set_interrupt_alert. It rings the bell with "Interrupted: the cron service stopped before this run finished." and when the job runs next: at its next scheduled time, or, on a cron expression, at once if Kiro Crew is back within the minute the run was due, because a stopped cron-expression run keeps the previous run'slast_run_ts. The same text goes to the job's channel or DM by the failure alert's one-surface delivery. A silent job stays quiet, and nothing counts as a failure. Incron_service/service/,run_execution.pystarts the notice as a cut run unwinds andservice_lifecycle.pywaits for it beforestop()returns. The dashboard Restart and update apply (dashboard/handlers/updates_apply.py), the update restart (update_schedule.py) and Slack/kirocrew restart(slack/events_slash.py) stop the cron service after their last refusal and before they close sessions. A restart that refuses or defers leaves the scheduler running.kirocrew restart(cli_server_restart.py) prints the cron jobs a restart interrupts before it signals anything, worded as what a restart does so it stays true when the restart is then refused. Each job then gets the line its stored schedule supports (cron_service.readers.job_schedules_from_diskreadscrons.json): a consumeddelete_after_runone-shot, the kindcron add --atmakes, does not run again and should be scheduled again; a one-shot that keeps its row runs at its set time, or at once if that has passed; a recurring job runs at its next scheduled time; a paused or unreadable job gets no promise. To keepupdate_schedule.pyat the 1,600-line target, one comment and the module docstring's field list are reflowed.call_tool arguments.
_scanned_tool_argsincron_script_context.pyjudges each string alone and beside its key, and a refused call raisesValueErrornaming the path (args.items[0].id), never the value. Two rules that read identifiers as secrets stand down only where the value is positively an identifier: the bare-secret pass for a whole Graph item id orb!drive id under an id-named key, and the bot-token rule for a 12-digit account id followed by PascalCase words or, inside a CodeDeploy target, a CloudFormation-generated name. A real credential is still refused, a bot token behind a padded or glued account id included. The one residual, a key glued behind an id's own opening under an id key, is stated in the spec.kirocrew cron previewshares the scan.The facades (
cron.py,cron_script.py,cli_server.py,slack/gateway.py,dashboard/handlers/updates.py) export the new names. The owning specs and user docs describe the new behaviour, the user doc naming the two id shapes the scan exempts (learn-cron-dashboard.md,cli.md,security.md,slack-gateway.md,src/kiro_crew/docs/cron-and-scheduling.md).Backwards compatibility
Breaking:
ctx.call_tool()andkirocrew cron previewrefuse a call when the credential scan would replace any part of a string argument, where main sent that call with a[REDACTED: ...]placeholder in place of the span. A script that relied on the rewrite gets aValueErrornaming the argument instead. Writer sweep on origin/main @ 39aecc7 (git grep -n "call_tool(" -- src/kiro_crew/apps src/kiro_crew/builtin_skills src/kiro_crew/docs, andgit grep -n "_scanned_tool_args"): no built-in app or skill callsctx.call_tool;apps/builtins/mochi/mcp_server.py:_call_toolis that MCP server's own dispatch, not this scan;src/kiro_crew/docs/cron-and-scheduling.mdis the user doc, which states the new rule. The only writers are operators' own script crons, and the error names the argument to change.Reader: src/kiro_crew/cron_script_context.py:ScriptContext.call_tool -- cron -- test_cron_call_tool_scan.py::test_a_call_the_scan_would_change_is_refused_by_path_and_never_sent
Reader: src/kiro_crew/cli_commands_cron.py:_cron_preview -- cron -- test_cron_preview_cmd.py::TestCronPreviewCallToolPath::test_call_tool_sends_identifiers_as_written_and_refuses_a_credential
Reader: src/kiro_crew/cron_script.py:_wholly_redacted_path -- cron -- removed with its only caller,
_scanned_tool_args;CREDENTIAL_REDACTION_TAGSleaves this facade too, and its other readers import it fromkiro_crew.security, unchangedTests
The full backend and frontend suites run in CI.
At head
84fc1bada4(this patch on maindb4ef699b0), on a Linux DevSpace. The GPT 6.1 finding (thekirocrew restartline promised a next run to a one-shot that never gets one) was reproduced first, atc5f93b61c8(the same patch on main39aecc7296). With this patch's tests and the restart code of the previous head0a10f6144d,test_cron_stop_interrupt_notice.pygave 8 failed, 24 passed: the twotest_restart_names_the_cron_run_it_interrupts_before_signallingcases,test_restart_does_not_promise_a_consumed_one_shot_runs_again,test_restart_says_a_kept_one_shot_runs_again_at_once,test_restart_keeps_the_next_run_line_for_a_recurring_job_beside_a_one_shotand the threetest_restart_names_a_run_it_cannot_promise_a_next_run_forcases. With this patch's code it gave 32 passed, 0 failed (-n0).test_a_stopped_one_shot_is_consumed_or_left_duepasses both ways, because it pins what the stop already does and the new wording rests on. The changed and added test files, the tests that readcli_server_restart.pyorcron_service/readers.py(test_cron_refactor_readers.py,test_cli_server_facade.py,test_stdlib_shadow.py,test_internal_python_isolation.py,test_mcp_call_site_auth_coverage.py,test_campaign_facades_base_public_names.py) andtest_cron_cancel.py,test_cron_gateway_integration.pyandtest_dashboard_stale_wake.py, plus the tests that readcli.mdorlearn-cron-dashboard.md(test_cli_cron_add_kinds.pyand eight more) and the planned-restart tests (test_restart_*.py,test_dashboard_updates_coverage_apply.py,test_inapp_restart_keeps_turn_marker.py,test_events_facade.py,test_managed_launcher_restart.py,test_r10_update_routes_owner_gate.py), gave 1936 passed, 0 failed at-n 8 --dist loadgroup --max-worker-restart=2, and the flake pattern ratchet passed. black, isort, flake8,mypy --platform linux, comment history, brand name, harness parity, file line cap, docs-lint andsemgrep --baseline-commit db4ef699b0 --errorexited 0 at this head.CI at
ac2d74ce4cfailedtest_cli_cron_add_kinds.py::TestArgparse::test_help_copy_numbers_track_the_production_boundson Linux and Windows: that test reads the onecli.mdrow that namescron add, and the restart row named it too. The restart row now says "the one-shot an--atschedule makes"; the test fails atac2d74ce4cand passes at this head.Rebased onto main
db4ef699b0after review. Main's #33670 rewrote the Slack restart row inslack-gateway.md, so that row is merged by hand: main's bounds wording, plus this patch's cron stop between the save andclose_all, the order_handle_restartruns them in.git range-difffromac2d74ce4cshows that row as the only change to the patch; the code inevents_slash.py,updates_apply.pyandupdate_schedule.pymerged cleanly with the cron stop still ahead ofclose_all. Then rebased onto the newest main with the patch unchanged (git range-diffshows=); main's commits sincedb4ef699b0touch none of this patch's files.At head
76b7cd9791on main941c3bd4da, on a Linux DevSpace, the changed and added test files (test_cron_call_tool_scan.pyandtest_cron_stop_interrupt_notice.py, both new, plustest_cron_failure_alert_one_spelling.py,test_cron_service_bindings.py,test_slack_gateway_composition_contract.py,test_cron_preview_cmd.pyandtest_cron_script.py) gave 787 passed, 0 failed at-n0. Every gate of the resolved profile except the three CI runs (the scoped backend and frontend suites andtest:electron) exited 0 there, mypy, flake8, isort, black, docs-lint, comment history, brand name, harness parity, the website build and jscpd included. jscpd ran after the other gates had finished:i18n:renderbuilds into a scratch directory underwebsite/and removes it, so a jscpd run beside it fails reading files that are gone. So didpython -m pytest -n0 test/test_flake_pattern_ratchet.pyandsemgrep scan --config semgrep/ --baseline-commit 941c3bd4da --error. The neighbouringtest_cron_cancel.py,test_cron_gateway_integration.pyandtest_cron_skip_dates.pygave 154 passed at-n 4at the previous head1250de3d8a, whose code differs from this head only in the wording of thekirocrew restartline and two comments.Determinism, at head
1250de3d8aon the same DevSpace (this head changes one expected string intest_cron_stop_interrupt_notice.py): the new and changed tests (689: the two new files,test_cron_failure_alert_one_spelling.py,test_cron_service_bindings.py,test_slack_gateway_composition_contract.py,TestCronPreviewCallToolPathandTestScriptContextCallTool) passed 20 of 20 runs at-n0, 10 of 10 at-n 4 --dist loadgroup --max-worker-restart=2besidetest_cron_script.pyandtest_cron_preview_cmd.py(787 tests), and one shuffled order (seed 7105, 689 node ids).What each test pins:
test_cron_stop_interrupt_notice.py: a gateway stop tells the owner about the run it cut; a silent job is not told; the notice says when the job runs next for each schedule kind, and a stopped cron-expression run is due again only inside its slot's minute while a stoppedeveryrun is not;stop()returns only after its notices and cuts one still running at its bound; a run that ended on its own, or that the user cancelled, is not told; each planned restart stops the cron run it cuts and tells the owner; a refused or deferred restart leaves the cron service serving; a cron stop past its bound does not hold the restart;kirocrew restartnames the run it interrupts before it signals and gives each job the next-run line its stored schedule supports: a consumed one-shot is told to be scheduled again, a kept one-shot runs at once, a recurring job at its next scheduled time, and a paused job or one it cannot read gets no promise; it names no run whose writer is gone; a stoppeddelete_after_runone-shot is consumed and one that keeps its row is left due.test_cron_call_tool_scan.py: Graph ids, drive ids, account and resource names and CodeDeploy targets reach the server byte-identical; a call the scan would change is refused by path, audited, never sent, and never echoes the value; a credential-shaped key is refused; an argument JSON cannot hold fails before the kept server is touched.test_cron_preview_cmd.pyandtest_cron_script.py: the preview shares the scan, and a credential span inside a longer string is refused rather than sent redacted.test_cron_failure_alert_one_spelling.py,test_cron_service_bindings.pyandtest_slack_gateway_composition_contract.py: the notice reaches Slack only through the shared one-surface helper, and the new members are bound on the service and the orchestrator.Proof: PROVEN test/test_cron_call_tool_scan.py::test_identifiers_reach_the_server_byte_identical[args0], test/test_cron_call_tool_scan.py::test_identifiers_reach_the_server_byte_identical[args1], test/test_cron_call_tool_scan.py::test_identifiers_reach_the_server_byte_identical[args2], test/test_cron_call_tool_scan.py::test_identifiers_reach_the_server_byte_identical[args3], test/test_cron_call_tool_scan.py::test_identifiers_reach_the_server_byte_identical[args4] (head 84fc1bada45b)
Manual verification
Each defect's user scenario was run end to end on a Linux DevSpace at head
84fc1bada4, and before that atc140fa741fandc5f93b61c8. Both exited 0 on the fix side each time. At the previous head both exited 1 (bug present) on main39aecc7296itself.kirocrew restart. Both restarts told the owner about the run they cut, andkirocrew restartnamed only that run (since 23:59 UTC) before it signalled, followed by "daily-report-crc runs again at its next scheduled time, or at once if the gateway is back within the minute that run was due." The line's wording at head, "A restart interrupts the cron job(s) running now: ...", is pinned bytest_restart_names_the_cron_run_it_interrupts_before_signalling. The bell note began "Interrupted: the cron service stopped before this run finished.", and no in-flight marker was left. The line on when the job runs next is pinned at head bytest_the_notice_says_when_the_job_runs_again. The harness's sign-in step reads the link withkirocrew token --port, because main'skirocrew restartprints it only to a terminal; the check itself is unchanged.kirocrew cron preview, a Graph message id, a Microsoft Loop drive id and a CodeDeploy target reached the MCP server byte-identical. A control call carrying a real credential was refused with "args.text reads as a credential" and never reached the server in plaintext. At head76b7cd9791, a 40-character AWS key alone undermessage_idwas refused and the same key behindAAMkwas sent, the residual the spec states.Screenshots / video
N/A: no frontend file changes. The bell note is backend text shown by the existing notification list.
Related Issues
Fixes #33831
#26246 (closed) is an earlier, related report about the same
call_toolscan replacing a whole opaque id.Sibling sweep
Swept: git grep -nE "reexec_launcher|reexec_python_module|hard_exit(" -- src/kiro_crew/
Sibling: src/kiro_crew/dashboard/handlers/updates_apply.py -- changed here
Sibling: src/kiro_crew/slack/gateway_runtime/update_schedule.py -- changed here
Sibling: src/kiro_crew/slack/events_slash.py -- changed here
Sibling: src/kiro_crew/slack/gateway_runtime/exit_path.py:516 -- not affected -- the second-signal force exit, an operator's way out of a stuck shutdown; the first signal's
_shutdownalready awaitscron_svc.stop()(line 319)Sibling: src/kiro_crew/mcp_gateway/stub.py:914 -- not affected -- an MCP stub process, which runs no cron service
Swept: git grep -nE "json.loads(redact(|redact(json.dumps(|_scanned_tool_args" -- src/kiro_crew/
Sibling: src/kiro_crew/cli_commands_cron.py:1064 -- not affected -- the preview's
notifyprints the redacted kwargs to the terminal and sends nothingSibling: src/kiro_crew/dashboard/handlers/debug.py:649 -- not affected -- a debug response for a person to read, where display redaction is the point
Sibling: src/kiro_crew/dashboard/file_api/outbox.py:260 -- not affected -- a stored display copy, not an argument sent to a tool
Pattern harvest
Rule candidate: review-prompt
Pattern: a scrubber's output sent onward as data (tool arguments, ids) instead of only judging it; refuse or send the original.
Rule candidate: review-prompt
Pattern: a planned restart that ends in exec or
os._exitskips the SIGTERM shutdown, so every service that shutdown stops must be stopped on that path too.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)