Repository navigation
fix(cron): preserve future one-shots during manual runs - #114491
Conversation
Co-authored-by: Jerry-Xin <[email protected]>
|
Codex review: needs real behavior proof before merge. Reviewed July 27, 2026, 5:52 AM ET / 09:52 UTC. ClawSweeper reviewWhat this changesPreserves a future one-shot cron occurrence when an operator manually runs it before its scheduled time, including when that manual request waits in the cron command lane. Merge readiness⛔ Blocked until real behavior proof from a real setup is added - 4 items remain Keep open for maintainer review. The patch targets a real P1 cron data-loss path and is a focused alternative to the broader related proposal, but the supplied PR body does not yet contain inspectable after-fix live-run output and the protected Priority: P1 Review scores
Verification
How this fits togetherThe cron service accepts manual and timer-triggered job runs, persists each job's scheduling state, and finalizes results through shared outcome handling. This change carries the time at which a manual run acquired schedule ownership so result handling can distinguish an out-of-band verification from the real future scheduled occurrence. flowchart TD
A[Operator manual cron run] --> B[Cron command lane]
C[Timer-scheduled one-shot] --> D[Run preparation]
B --> D
D --> E[Job execution]
E --> F[Outcome and schedule handling]
F --> G[Persisted cron job]
G --> H[Later scheduled execution]
Decision needed
Why: Both branches address the same destructive operator workflow but choose different ownership boundaries; the protected maintainer label and overlapping open PR require an explicit owner choice rather than an automated supersession judgment. Before merge
Agent review detailsSecurityNone. PR surfaceSource +24, Tests +317. Total +341 across 4 files. View PR surface stats
Review metricsNone. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep a single explicit manual-run ownership boundary, verify it against a real cron store and CLI/gateway run, and decide whether this narrow timestamp-based repair is preferred over the broader run-origin design in #83933. Do we have a high-confidence way to reproduce the issue? Yes in source: the new focused test suite encodes successful, failed, skipped, queued, reload, and later-scheduled-run paths against a SQLite-backed cron store. This read-only review did not independently execute the path or inspect a live transcript. Is this the best way to solve the issue? Unclear. The timestamp boundary directly addresses a manual request admitted after its scheduled deadline, but the overlapping origin-based PR covers wider manual scheduler-state semantics; maintainers should compare both boundaries before selecting the lasting design. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 2bd485825215. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
) Co-authored-by: Jerry-Xin <[email protected]>
* fix(cron): preserve paused one-shots after manual runs Keep the documented future one-shot occurrence after an out-of-band manual run, including paused jobs and runs queued across the scheduled deadline. Reuse the existing preserved-occurrence marker across reload and enablement, while clearing it when scheduling inputs change. Ordinary completed one-shots remain consumed, and retry slots keep precedence over the authored date. Extends the manual-run scheduling contract from #114491. Existing deleted jobs are not recovered; downgrading to older code can lose this protection. * fix: restore SQLite test compilation * fix(cron): retain manual one-shot ownership before enablement Record the borrowed future occurrence in the authoritative manual reservation before an enablement edit can stale its completion. This preserves the pending scheduled run across restart when queued execution begins after its deadline. Keep actual schedule changes authoritative, including changes away and back. The same entry-point regression fails on the original parent and the first paused-job fix. Cover both admission times, active schedule invalidation, restart, and eventual scheduled consumption through CronService.
…152126) * fix(cron): preserve paused one-shots after manual runs Keep the documented future one-shot occurrence after an out-of-band manual run, including paused jobs and runs queued across the scheduled deadline. Reuse the existing preserved-occurrence marker across reload and enablement, while clearing it when scheduling inputs change. Ordinary completed one-shots remain consumed, and retry slots keep precedence over the authored date. Extends the manual-run scheduling contract from openclaw#114491. Existing deleted jobs are not recovered; downgrading to older code can lose this protection. * fix: restore SQLite test compilation * fix(cron): retain manual one-shot ownership before enablement Record the borrowed future occurrence in the authoritative manual reservation before an enablement edit can stale its completion. This preserves the pending scheduled run across restart when queued execution begins after its deadline. Keep actual schedule changes authoritative, including changes away and back. The same entry-point regression fails on the original parent and the first paused-job fix. Cover both admission times, active schedule invalidation, restart, and eventual scheduled consumption through CronService.
Closes #83538
Supersedes #83933
What Problem This Solves
Fixes an issue where operators manually verifying a future one-shot cron job would silently lose the actual scheduled occurrence. Successful manual runs deleted delete-after-run jobs; failed and skipped runs disabled their scheduled occurrence. A manually enqueued run could also cross the scheduled deadline while waiting in a command lane and accidentally consume the scheduled job.
Why This Change Was Made
Treat a force-run accepted before a future one-shot as out-of-band verification, carry its original schedule-ownership timestamp through both command-lane and execution-admission queues, and restore the original durable scheduled occurrence after every manual result. Preserve the existing behavior for already-due one-shots, required-delivery retries, timer and startup execution, and on-exit watchers. No configuration, schema, public API, protocol, or storage-format changes.
Maintainer decision: adopt this narrow, existing-boundary ownership repair instead of the broader new run-origin/config/schema model in #83933. Jerry-Xin's investigation is explicitly credited in the co-authored commit.
User Impact
Operators can safely run or enqueue a future one-shot for verification without deleting, disabling, or retrying away its real scheduled execution. The scheduled occurrence still runs exactly once and retains its normal delete-after-run behavior. Already-due manual jobs retain their existing behavior.
Evidence
Real packaged Gateway and CLI proof
Built and installed the actual PR package into the production Docker image, started a real Gateway, and ran the public cron CLI against its SQLite-backed state. The complete live transcript (no credentials):
{"step":"created","id":"ffe1a972-86c8-4723-b552-1fdad4df1391","enabled":true,"deleteAfterRun":true,"at":"2026-07-27T10:08:07.176Z","nextRunAtMs":1785146887176} {"step":"manual-run","completed":true,"status":"ok"} {"step":"after-manual-run","enabled":true,"deleteAfterRun":true,"nextRunAtMs":1785146887176,"lastRunStatus":"ok"} {"step":"after-failed-manual-run","enabled":true,"deleteAfterRun":true,"nextRunAtMs":1785146950104,"lastRunStatus":"error"} {"step":"after-scheduled-fire","jobRemoved":true,"successfulRuns":2,"summaries":["one-shot-manual-and-scheduled-ok","one-shot-manual-and-scheduled-ok"]}LIVE_ONE_SHOT_PROOF_OKThe two successful history entries are exactly the manual verification and the subsequent real scheduled occurrence; the failing manual run was independently verified against another future one-shot.
Red/green regression and stress evidence
main: successful, failed, skipped, and queued manual force runs.pnpm test src/cron: 153 files, 1,696 tests passed.pnpm check:changed: passed, including formatting, production and test typechecks, lint, database/schema, import-cycle, SDK, and compatibility guards.pnpm build: passed.pnpm test:docker:cron-cli: passed; real packaged Gateway startup and restart, 10-case persisted operator-authority matrix, public cron CRUD, manual run, execution history, and cleanup.autoreview --mode uncommitted: clean.AI-assisted; all fixes, live proof, and regression cases were independently reviewed and validated.