Skip to content

Improve cron workflow robustness and diagnostics#283

Merged
tbrandenburg merged 1 commit intomainfrom
codex/improve-crontab-task-execution-reliability
Mar 14, 2026
Merged

Improve cron workflow robustness and diagnostics#283
tbrandenburg merged 1 commit intomainfrom
codex/improve-crontab-task-execution-reliability

Conversation

@tbrandenburg
Copy link
Owner

Motivation

  • Cron-triggered workflows were occasionally missing runs and offered limited runtime visibility, making failures hard to debug.
  • The scheduler should tolerate brief pauses and avoid overlapping runs while capturing richer per-job metadata to surface issues in the API and logs.

Description

  • Hardened scheduler registration by setting max_instances=1 and adding misfire_grace_time=300 to reduce missed or overlapping runs and make behavior predictable.
  • Added explicit warning logs when workflows are skipped for missing schedule, missing shellScriptPath, or missing script files to aid immediate diagnosis.
  • Captured per-job diagnostics in runtime state: lastStartedAt, lastFinishedAt, lastDurationMs, lastExitCode, lastError, nextRunAt, and running by introducing get_cron_job_diagnostics and backing fields (_last_finished_by_job, _last_duration_ms_by_job, _last_exit_code_by_job, _last_error_by_job).
  • Exposed diagnostics in the workspace workflows API by wiring get_cron_job_diagnostics() into list_workspace_workflows so UI/clients can display runtime status alongside lastRun.
  • Added a failedJobsSinceStartup counter to get_cron_clock_status and ensured runtime diagnostics maps are cleared on clock start.
  • Small behavior adjustments: new logs and ensured single-instance per job, and updated/added unit tests to cover diagnostics and API wiring.

Testing

  • Ran unit tests with uv run --project packages/pybackend python -m pytest packages/pybackend/tests/unit/test_cron_service.py packages/pybackend/tests/unit/test_workflow_service.py packages/pybackend/tests/unit/test_api.py which executed the test suite and all tests passed (109 passed, 1 warning).

Codex Task

@vercel
Copy link

vercel bot commented Mar 14, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
made Ready Ready Preview, Comment Mar 14, 2026 6:21am

@tbrandenburg tbrandenburg merged commit 79496a0 into main Mar 14, 2026
8 checks passed
@tbrandenburg tbrandenburg deleted the codex/improve-crontab-task-execution-reliability branch March 14, 2026 06:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant