Repository navigation
Conversation
…store _force_reap decides whether a reaped run counts toward auto-pause, and whether the user is told, from failure_recorded. It read the flag off the registry's job, but the flag is runtime-only and a store reload during the run replaces that object with one where it is False. A run that already recorded and alerted its own failure, then hung past the deadline, was counted a second time and sent a second "Run failed" alert. Read it off the run's own object (_RunClaim.job), as the next line already does for run_never_started. Closes kirodotdev#23096 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
UX Review (Opus 5.5, fork) — ⏭️ skippedRevision |
Design Review (Opus 5.5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: this is a one-line root-cause fix that reads the run-scoped flag off the run's own object, the same way the next line already reads [DESIGN-REVIEWED] 437b3b8 Description read[DESCRIPTION-READ] fbd15b1f33c419cc07219ef1463db5994e8e7077ccbdde62aee64dc888bfc33e 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, fork) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing to check. What this change shipsInventory (3 items) — 3 justifiedIntent: when a cron run has already counted and alerted its own failure, the reaper does not count or alert it again after a store reload. This is a FIX.
[FIRST-PRINCIPLES-REVIEWED] 437b3b8 Description read[DESCRIPTION-READ] 4a44ee826fe96009a4f8b332eab47c2f1f2df091786024ce85d280860d192678 That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed |
GPT 6.1 Review (fork) — 🔴 changes requested (blocking)Reviewed 1 of 1 blocking finding(s) are security-class and were withheld from adjudication, so the blocking verdict stands. BLOCKING -- src/kiro_crew/cron_service/service/run_teardown.py:303 -- Suppressing the count also loses an unpersisted failure
[BLOCK-MERGE] 437b3b8 Adjudication (Opus 5.5) — is blocking on each finding proportionate?F1: the bug is real and the harm is small, but a store reload while a run is stuck is a plausible combination, not an extreme one. I could not show from the code that it is rare enough to FLAG.
|
|
Closing this one. The GPT 6.1 finding on
After a store reload, the registry's copy is the disk copy, without that failure. Main's There is no double count to fix here. Whether the reaper could ever send a duplicate alert depends on whether the handler's alert was actually delivered, and the reaper cannot see that, so that is not a one-line change either. Closing #23096 with the same explanation. |
Problem / Motivation
Goal: A cron run that already counted and alerted its own failure is not counted or alerted a second time when the reaper later kills it after a store reload.
_force_reapdecides whether a reaped run counts toward auto-pause, and whether the user is alerted, withnot job.failure_recorded.jobis the registry's copy.failure_recordedis runtime-only, and a store reload during the run (another process writingcrons.json) replaces that object with one where the flag isFalse. So a run whose handler already calledrecord_failure()and sent "Run failed", and which then hung past the reaper deadline after a reload, is counted a second time (count_failure=True) and alerted a second time (_alert_timeout). The dedup does not catch the second alert, because its "Reaped after …" text differs. The Opus review on #22094 named this.Why it matters
The user gets two "Run failed" notifications (bell and Slack/channel) for one failed run, and the job reaches its auto-pause limit one run early. A job with the default limit of 5 can pause after four real failures.
Not a goal
job,result_produced. A reaped run's result is never merged, so which object it is read from has no visible effect established here.cancel()'s terminal merge, which fix(cron): fence scheduled terminal settlement #9038 is rewriting.What changed (motivation → approach → change)
countedin_force_reapreadsfailure_recordedoff the registry's job instead of the run's own object.ran(_RunClaim.job, falling back tojobwhen the claim has none), as the next line already does forrun_never_started. The comment abovecountednow says both markers are runtime-only and read offran.learn-cron-dashboard.mdbullet that explains why the reaper readsrun_never_startedoff_RunClaim.jobnow namesfailure_recordedtoo.Backwards compatibility
Compatible: without a reload,
ranandjobare the same object and nothing changes. After one, the reaper now reads the flag the run actually set.Removes nothing: a duplicate count and a duplicate alert stop happening; no path, field, key or validator is removed.
Tests
test_a_reload_during_the_run_does_not_count_or_alert_a_recorded_failure_again(new,test/test_cron_timeout_alert.py) gives_force_reapa claim whosejobhasfailure_recorded=True, with a separate reloaded copy of the same job insvc._jobs. It asserts the reaped run is still recorded (Reaped after …) and that the reloaded copy'sconsecutive_failuresstays 0 and no timeout alert is sent.origin/main'srun_teardown.pythe new test fails:assert 1 == 0onconsecutive_failures.test_cron_timeout_alert.py, everytest_cron_reaper*.py,test_cron_oneshot_end.pyandtest_cron_auto_pause*.py(245 passed);test_flake_pattern_ratchet.pyon the committed tree (60 passed). black, isort, flake8,mypyon the changed module,check_black_formatting.py,check_comment_history.pyandcheck_brand_name.pyare clean.Manual verification
N/A — unit coverage sufficient: the test drives the real
_force_reapand merge with the two-object state a reload leaves, which is the whole condition.Related Issues
Closes #23096
Follows the Opus review finding on #22094.
Pattern harvest
Rule candidate: review-prompt
Pattern: a runtime-only
CronJobfield read off the registry's job (self._jobs) after an await, instead of off the run's own object (_RunClaim.job); a store reload resets it.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
🤖 Generated with Claude Code