Repository navigation
fix(cron): keep a due recurring run when an edit re-saves the same schedule - #96159
Conversation
|
@clawsweeper re-run |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
Codex review: needs maintainer review before merge. Reviewed June 24, 2026, 12:38 AM ET / 04:38 UTC. Summary PR surface: Source +20, Tests +164. Total +184 across 2 files. Reproducibility: yes. source-reproducible: current main recomputes Review metrics: 1 noteworthy metric.
Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Next step before merge
Security Review detailsBest possible solution: Land the service-level cron update fix after normal maintainer review and merge gates, keeping add/remove/update aligned on preserving present past-due recurring slots. Do we have a high-confidence way to reproduce the issue? Yes, source-reproducible: current main recomputes Is this the best way to solve the issue? Yes. The fix is at the service update boundary that owns CRUD next-run state, reuses the existing schedule identity helper, and now preserves edit-time anchoring for genuine interval changes. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 9e3a917d9ee0. Label changesLabel justifications:
Evidence reviewedPR surface: Source +20, Tests +164. Total +184 across 2 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
…hedule update() advanced state.nextRunAtMs to the next future slot whenever a patch carried schedule or enabled, even when the schedule was unchanged, dropping an already-due run and re-phasing every-job anchors to now. Gate the advance on cronSchedulingInputsEqual so only a genuine schedule or enabled change recomputes, and inherit the previous every anchor when a re-save omits it, matching the add/remove maintenance recompute.
Only inherit the previous cadence anchor for an unchanged-interval every re-save. A real everyMs change (UI omits anchorMs) now re-anchors to the edit time, matching the prior update semantics, while idempotent re-saves still preserve a due slot and phase. Adds a regression test for the interval-change path.
f070dc8 to
f6d4ecc
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
…hedule (openclaw#96159) * fix(cron): keep a due recurring run when an edit re-saves the same schedule update() advanced state.nextRunAtMs to the next future slot whenever a patch carried schedule or enabled, even when the schedule was unchanged, dropping an already-due run and re-phasing every-job anchors to now. Gate the advance on cronSchedulingInputsEqual so only a genuine schedule or enabled change recomputes, and inherit the previous every anchor when a re-save omits it, matching the add/remove maintenance recompute. * fix(cron): re-anchor every-job to edit time on a genuine interval change Only inherit the previous cadence anchor for an unchanged-interval every re-save. A real everyMs change (UI omits anchorMs) now re-anchors to the edit time, matching the prior update semantics, while idempotent re-saves still preserve a due slot and phase. Adds a regression test for the interval-change path. (cherry picked from commit e38d64c)
…hedule (openclaw#96159) * fix(cron): keep a due recurring run when an edit re-saves the same schedule update() advanced state.nextRunAtMs to the next future slot whenever a patch carried schedule or enabled, even when the schedule was unchanged, dropping an already-due run and re-phasing every-job anchors to now. Gate the advance on cronSchedulingInputsEqual so only a genuine schedule or enabled change recomputes, and inherit the previous every anchor when a re-save omits it, matching the add/remove maintenance recompute. * fix(cron): re-anchor every-job to edit time on a genuine interval change Only inherit the previous cadence anchor for an unchanged-interval every re-save. A real everyMs change (UI omits anchorMs) now re-anchors to the edit time, matching the prior update semantics, while idempotent re-saves still preserve a due slot and phase. Adds a regression test for the interval-change path.
…hedule (openclaw#96159) * fix(cron): keep a due recurring run when an edit re-saves the same schedule update() advanced state.nextRunAtMs to the next future slot whenever a patch carried schedule or enabled, even when the schedule was unchanged, dropping an already-due run and re-phasing every-job anchors to now. Gate the advance on cronSchedulingInputsEqual so only a genuine schedule or enabled change recomputes, and inherit the previous every anchor when a re-save omits it, matching the add/remove maintenance recompute. * fix(cron): re-anchor every-job to edit time on a genuine interval change Only inherit the previous cadence anchor for an unchanged-interval every re-save. A real everyMs change (UI omits anchorMs) now re-anchors to the edit time, matching the prior update semantics, while idempotent re-saves still preserve a due slot and phase. Adds a regression test for the interval-change path.
What Problem This Solves
Editing a recurring cron job (
everyorcron) while one of its slots is already due silently drops that pending run. The control UI andcron editresubmit the job's schedule on save, and any update that carriesschedule(orenabled) advancesstate.nextRunAtMsto the next future slot without executing the slot that was already due. For an hourly job edited a few seconds after its slot came due, that hour's run never fires; for a daily job, that day's run is lost. Foreveryjobs the same edit also re-phases the cadence anchor to "now", shifting every future fire time.Root cause:
add()andremove()were fixed (#94323) to recompute throughrecomputeNextRunsForMaintenance, which preserves a past-duenextRunAtMsso the pending run still fires.update()was never converted; it advances unconditionally whenever the patch carries a schedule or enabled field, even when the schedule is unchanged.src/cron/service/ops.ts(before):computeJobNextRunAtMsreturns the strictly-future next slot, so a still-duenextRunAtMs <= nowis overwritten. Theeveryanchor backfill compounds it: when a re-save omits the internalanchorMs, the backfill mintsanchorMs = now, re-phasing the cadence.Why This Change Was Made
Only advance the next run when the scheduling inputs actually changed, using the existing
cronSchedulingInputsEqualhelper (the same helperservice/store.tsalready uses to decide whether stored timer state is still valid).For the
everyanchor backfill, inherit the previous cadence anchor only when the interval is unchanged (an idempotent re-save), so the job keeps its existing phase and a due slot survives. A genuine interval change (a differenteveryMs, which UIs also submit withoutanchorMs) still anchors to the edit time, exactly as before, so the new cadence starts now; that edit already counts as a scheduling change and recomputes the next run as it always did.src/cron/service/ops.ts(after):A genuine schedule change (different
everyMs,expr,tz, or an enable transition) still recomputes exactly as before, and aneveryinterval change still re-anchors to the edit time; only the unchanged re-save now preserves a due slot and its phase. This is the right boundary: the defect is in the cron serviceupdate()op that owns next-run state for CRUD edits, the sibling load-time path (service/store.ts invalidateStaleNextRunOnScheduleChange) already gates on the same identity, andadd()/remove()already preserve due slots via maintenance recompute. The fix bringsupdate()to parity and preserves #15905 (genuine edits still recompute).User Impact
Recurring cron jobs no longer skip a fire when the user edits them during an already-due slot, and
everyjobs keep their cadence phase across an unchanged re-save instead of drifting to the edit time. A real interval edit still starts the new cadence from the edit time, unchanged from today's behavior. Without this, any save that resubmits the schedule (the normal control-UI behavior) can silently swallow a scheduled run.Evidence
Drove the real
CronService.update()against a real on-disk cron store with an injected clock, on the prior PR head and on the patched tree with identical inputs. The only stub is the isolated-agent job runner (the external execution boundary); the store, schedule math, anchor backfill, and update op are all real.Two cases,
base = 2025-12-13T00:00:00Z:every: 10sjob (anchored atbase), then atbase+3000callupdate(jobId, { schedule: { kind: "every", everyMs: 3_600_000 } })(UI omitsanchorMs).every: 10sjob, fire it once, advance the clock 50ms past the next due slot, then callupdate(jobId, { schedule: { kind: "every", everyMs: 10000 } }).Case A now re-anchors a real interval change to the edit time (
base+3000) instead of keeping the old phase, matching the existing update semantics. Case B is unchanged: the due slot'snextRunAtMsis retained and the cadence anchor stays at its original phase, so the pending run still fires.The idempotent-preserve before/after against pristine main is unchanged from the original PR (main advances the due slot
base+1820005 -> base+1830055; this patch keepsbase+1820005).Additional checks: the colocated regression suite now has three cases (
everyidempotent,everyinterval-change re-anchor,cronidempotent); the new interval-change test fails on the prior PR head and passes here, and the two preserve-due tests still fail on pristine main and pass with the patch. The add/remove/ops/apply-patch/at-reschedule suites stay green (29 cases across the cron service suites run here). oxlint and oxfmt are clean on the changed files. Not covered: no live gateway or real isolated-agent execution; full project typecheck not run on this box (the one new call mirrors the existing un-castcronSchedulingInputsEqual(CronJob, CronJob)call inservice/store.ts).