← Back to PRs

#8698: fix(cron): default enabled to true for new jobs

by emmick4 open 2026-02-04 09:00 View on GitHub →
gateway agents stale
Cluster: Cron Job Fixes
## Problem Jobs created via the `cron.add` tool/API were silently disabled because `enabled` was not set by default. The scheduler treated `undefined` as disabled, so jobs never ran. ## Solution Add `enabled: true` to the defaults applied during job creation in `normalize.ts`, matching the documented behavior that jobs are enabled by default. ## Changes - One-line fix in `src/cron/normalize.ts` - Two tests added in `src/cron/normalize.test.ts`: - Verifies enabled defaults to true when not provided - Verifies explicit `enabled: false` is preserved Fixes #6988 <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR fixes cron job creation defaults by setting `enabled: true` when `enabled` is omitted in `src/cron/normalize.ts`, with new tests ensuring the default is applied and explicit `enabled: false` is preserved. In addition, it introduces a new disk-backed gateway lifecycle/crash detection mechanism (`src/infra/lifecycle-state.ts`) plus a checkpoint persistence layer (`src/agents/checkpoint.ts`), and wires lifecycle transitions into gateway startup/shutdown (`src/gateway/server.impl.ts`, `src/gateway/server-close.ts`). On startup, it logs a warning if the previous run appears to have crashed and surfaces any incomplete checkpoints. Main things to double-check are the shutdown path reliably marking `stopped` even when teardown steps fail, and that lifecycle heartbeats are actually updated periodically so crash time/uptime reporting is accurate. <h3>Confidence Score: 3/5</h3> - This PR is likely safe to merge, but the new lifecycle/crash-detection additions have a couple correctness gaps around heartbeat accuracy and shutdown-state recording. - The cron default change and tests look correct and low risk. However, the PR also adds new persistence and lifecycle tracking; as written, crash time/uptime will be stale without a periodic `updateLifecycleHeartbeat()` call, and failures during shutdown can prevent marking `stopped`, affecting future crash classification. - src/infra/lifecycle-state.ts, src/gateway/server-close.ts <!-- greptile_other_comments_section --> <sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub> <!-- /greptile_comment -->

Most Similar PRs