#8698: fix(cron): default enabled to true for new jobs
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
#8701: fix: default enabled to true for cron jobs created via tool API
by maximus-claw · 2026-02-04
86.8%
#7984: fix undefined variable in cron
by ThunderDrag · 2026-02-03
83.8%
#9088: fix(cron): ensure nextRunAtMs is computed when enabled is undefined...
by divol89 · 2026-02-04
83.0%
#13065: fix(cron): Fix "every" schedule not re-arming after gateway restart
by trevorgordon981 · 2026-02-10
82.9%
#8744: fix(cron): load persisted cron jobs on gateway startup
by revenuestack · 2026-02-04
82.8%
#11857: fix: recompute stale cron nextRunAtMs on gateway restart
by Yida-Dev · 2026-02-08
82.3%
#8578: fix(cron): add failure limit and exponential backoff for isolated t...
by Baoxd123 · 2026-02-04
82.3%
#12303: fix(cron): correct nextRunAtMs calculation and prevent timer stall
by colddonkey · 2026-02-09
82.1%
#13055: fix: prevent cron RPC stalls with timeout and caching (#13018)
by trevorgordon981 · 2026-02-10
81.8%
#10829: fix: prevent cron scheduler permanent death on transient startup/ru...
by meaadore1221-afk · 2026-02-07
81.1%