fix: report immediate cron run status for depleted repeat jobs - #57689
fix: report immediate cron run status for depleted repeat jobs#57689kibooncoll wants to merge 1 commit into
Conversation
cronjob run computed execution_success by re-reading last_status after run_one_job. For repeat-limited jobs, mark_job_run can remove the job record once the repeat limit is depleted, so successful repeat=1 runs could report execution_success: false even though their output artifact showed success. Add an opt-in structured result snapshot to run_one_job(..., return_result=True) for immediate-run callers, while preserving the default bool return for scheduler callers. _execute_job_now now uses that snapshot when available and keeps the old job-store re-read path as a fallback. Add regression coverage for depleted repeat=1 success, failure, and silent no_agent runs, plus scheduler tests for the structured result snapshot.
|
Independent rediscovery of this bug — came across it during live testing of #18565 and opened #63570 before finding yours. Closed #63570 as a duplicate. Your approach is the better fix — capturing structured status at the source is more robust than inferring from job absence (which is what our simpler fix did). Happy to help get this merged if a review is needed. |
teknium1
left a comment
There was a problem hiding this comment.
Thanks for tracing this to the status read after terminal-job removal. The current main still has that exact sequence: tools/cronjob_tools.py:639-647 calls run_one_job() and then derives success from get_job(), while cron/jobs.py:1524-1529 removes a finite-repeat record before that read.
Problems
tests/tools/test_cronjob_run_immediate.py:62mocks bothrun_one_jobandget_job, so the new cases do not exercise the realmark_job_run()deletion path that triggers the bug.
Suggested changes
- Add a temp-
HERMES_HOMEintegration regression using a real repeat=1 job and the actualrun_one_job/mark_job_runchain; assert a removed successful job reportsexecution_success: true.
Automated hermes-sweeper review.
| with patch("tools.cronjob_tools.resolve_job_ref", return_value=dict(_JOB)), \ | ||
| patch("tools.cronjob_tools.claim_job_for_fire", return_value=True), \ | ||
| patch("cron.scheduler.run_one_job", return_value=run_result), \ | ||
| patch("tools.cronjob_tools.get_job", return_value=None): |
There was a problem hiding this comment.
This mocks both run_one_job and the post-run get_job() absence, so it cannot verify the actual mark_job_run() auto-deletion path that caused the regression. Please add one temp-HERMES_HOME integration case that leaves run_one_job, mark_job_run, and get_job real.
Summary
cronjob runstatus reporting for repeat-limited jobs that are removed after execution.run_one_job(..., return_result=True)status snapshot for immediate-run callers.Root cause
_execute_job_nowpreviously computedexecution_successby re-readinglast_statusfrom the job store afterrun_one_jobcompleted.For finite repeat jobs,
mark_job_runcan remove the job record as soon as the repeat limit is depleted. In the repeat=1 case, a successful run could therefore lose its post-run job record before_execute_job_nowre-read it, causing the tool response to reportexecution_success: falseeven though the run output artifact showed success.Fix
cron.scheduler.run_one_jobwithreturn_result=Trueto return a structured snapshot containingprocessed,success,status,error, anddelivery_error.return_resultis omitted.tools.cronjob_tools._execute_job_nowto use the structured snapshot when available.get_job()path as a back-compat fallback.Tests
Command run:
scripts/run_tests.sh tests/tools/test_cronjob_run_immediate.py tests/cron/test_run_one_job.py -vResult:
Additional syntax check:
python -m py_compile tools/cronjob_tools.py cron/scheduler.py tests/tools/test_cronjob_run_immediate.py tests/cron/test_run_one_job.pypy_compile_okRuntime verification
Fresh patched-runtime verification covered the repeat=1 no-agent cases:
011c67e09485->execution_success: truead625b6487e7->execution_success: false05102215b538->execution_success: trueOutput artifacts:
/home/deco/.hermes/cron/output/011c67e09485/2026-07-03_20-10-57.md/home/deco/.hermes/cron/output/ad625b6487e7/2026-07-03_20-10-57.md/home/deco/.hermes/cron/output/05102215b538/2026-07-03_20-10-57.mdCaveats
Non-goals