Skip to content

fix(cron): preserve future one-shots during manual runs - #114491

Merged
steipete merged 1 commit into
mainfrom
codex/cron-bug-sweep
Jul 27, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/cron-bug-sweep

Conversation

@steipete

@steipete steipete commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

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_OK

The 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

  • Reproduced all four original failure paths on main: successful, failed, skipped, and queued manual force runs.
  • Added SQLite-backed tests for all outcomes; durable reload; the actual later scheduled fire; 24 concurrently queued one-shots; and a real cron command-lane block where an accepted manual run starts only after the scheduled deadline.
  • pnpm test src/cron: 153 files, 1,696 tests passed.
  • Real gateway cron suite: 101 tests passed.
  • Public CLI suite: 131 tests passed.
  • Gateway cron protocol validators: 25 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.
  • Fresh independent autoreview --mode uncommitted: clean.
  • All hosted PR CI checks: passed.

AI-assisted; all fixes, live proof, and regression cases were independently reviewed and validated.

@openclaw-barnacle openclaw-barnacle Bot added size: M maintainer Maintainer-authored PR labels Jul 27, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. labels Jul 27, 2026
@clawsweeper

clawsweeper Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 27, 2026, 5:52 AM ET / 09:52 UTC.

ClawSweeper review

What this changes

Preserves 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 maintainer label requires an explicit ownership decision. Likely related people: steipete (recent cron change author, low confidence) and Jerry-Xin (prior root-cause investigator and overlapping implementation author, medium confidence).

Priority: P1
Reviewed head: 05003a5f9e18aad742b8394c9aca2eaa3b71265d
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The patch is focused and paired with targeted regression coverage, but it needs inspectable real behavior proof and a maintainer decision on the overlapping scheduler-ownership design.
Proof confidence 🦪 silver shellfish (2/6) Needs real behavior proof before merge: The PR body describes SQLite-backed regression tests and says Docker CLI proof is running, but it does not include inspectable after-fix terminal output, logs, recording, or linked live artifact. Please add redacted real gateway/CLI proof; after updating the PR body, a fresh review should trigger automatically, or a maintainer can request @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The PR body describes SQLite-backed regression tests and says Docker CLI proof is running, but it does not include inspectable after-fix terminal output, logs, recording, or linked live artifact. Please add redacted real gateway/CLI proof; after updating the PR body, a fresh review should trigger automatically, or a maintainer can request @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 6 items Focused schedule-ownership implementation: The proposed runtime change records the manual run's original ownership timestamp during preparation, so downstream result handling can compare it with the one-shot's persisted future slot.
Queued manual-run coverage path: The enqueue path captures the schedule-ownership timestamp before cron-lane waiting and forwards it into the manual execution, addressing the deadline-crossing case described in the PR body.
One-shot preservation condition: Result finalization preserves a future at schedule only for force runs whose recorded ownership time predates the persisted next-run time; already-due one-shots retain the existing advancing behavior.
Findings None None.
Security None None.

How this fits together

The 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]
Loading

Decision needed

Question Recommendation
Should OpenClaw adopt this narrow future-slot ownership repair, or consolidate the remaining manual-run semantics under the broader origin-based approach proposed in #83933? Adopt the narrow repair: Land this focused timestamp-based preservation path after it has attached redacted live CLI or gateway evidence for all stated manual-run outcomes.

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

  • Add real behavior proof - Needs real behavior proof before merge: The PR body describes SQLite-backed regression tests and says Docker CLI proof is running, but it does not include inspectable after-fix terminal output, logs, recording, or linked live artifact. Please add redacted real gateway/CLI proof; after updating the PR body, a fresh review should trigger automatically, or a maintainer can request @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Resolve merge risk (P1) - Manual execution is a compatibility-sensitive scheduler path: before merge, maintainers need after-fix live evidence that a future one-shot survives successful, failed, skipped, and lane-delayed manual runs while an already-due one-shot and on-exit behavior retain their existing ownership semantics.
  • Complete next step (P2) - A protected maintainer label and the unresolved overlap with the open broader implementation make this an owner-selection and proof review, not a safe automated repair task.
Agent review details

Security

None.

PR surface

Source +24, Tests +317. Total +341 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 3 30 6 +24
Tests 1 317 0 +317
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 347 6 +341

Review metrics

None.

Merge-risk options

Maintainer options:

  1. Attach live preservation proof before selecting the implementation (recommended)
    Show a redacted real gateway or CLI transcript proving that each future one-shot remains scheduled after manual success, error, skip, and lane delay, while the later timer run still consumes it exactly once.
  2. Consolidate the overlapping designs first
    If maintainers prefer the explicit run-origin boundary, pause this narrower patch and fold its queue-deadline coverage into the chosen implementation.

Technical review

Best 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.

Labels

Label changes:

  • add P1: The reported current-main behavior can silently destroy a user’s future one-shot cron occurrence when an operator manually verifies it.
  • add merge-risk: 🚨 session-state: The patch changes persisted one-shot scheduling ownership and result finalization, so an incorrect boundary could strand, disable, or consume scheduled work.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body describes SQLite-backed regression tests and says Docker CLI proof is running, but it does not include inspectable after-fix terminal output, logs, recording, or linked live artifact. Please add redacted real gateway/CLI proof; after updating the PR body, a fresh review should trigger automatically, or a maintainer can request @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Label justifications:

  • P1: The reported current-main behavior can silently destroy a user’s future one-shot cron occurrence when an operator manually verifies it.
  • merge-risk: 🚨 session-state: The patch changes persisted one-shot scheduling ownership and result finalization, so an incorrect boundary could strand, disable, or consume scheduled work.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body describes SQLite-backed regression tests and says Docker CLI proof is running, but it does not include inspectable after-fix terminal output, logs, recording, or linked live artifact. Please add redacted real gateway/CLI proof; after updating the PR body, a fresh review should trigger automatically, or a maintainer can request @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

  • Focused schedule-ownership implementation: The proposed runtime change records the manual run's original ownership timestamp during preparation, so downstream result handling can compare it with the one-shot's persisted future slot. (src/cron/service/ops-run-preparation.ts:52, 05003a5f9e18)
  • Queued manual-run coverage path: The enqueue path captures the schedule-ownership timestamp before cron-lane waiting and forwards it into the manual execution, addressing the deadline-crossing case described in the PR body. (src/cron/service/ops-run.ts:342, 05003a5f9e18)
  • One-shot preservation condition: Result finalization preserves a future at schedule only for force runs whose recorded ownership time predates the persisted next-run time; already-due one-shots retain the existing advancing behavior. (src/cron/service/timer-outcomes.ts:140, 05003a5f9e18)
  • Regression coverage added: The branch adds SQLite-backed coverage for successful, failed, skipped, queued, reload, and later scheduled-execution cases, as described by the new dedicated ownership test file. (src/cron/service.one-shot-schedule-ownership.test.ts:1, 05003a5f9e18)
  • Related root-cause work: The open related implementation fix(cron): skip deleteAfterRun and preserve counters for manual runs (#83538) #83933 documents the same manual-one-shot loss but proposes a broader run-origin model; this PR is overlapping rather than proven to supersede every behavior in that branch.
  • Main/release status: The PR is based on current main 2bd485825215d91a8de2db0ff7e5cdbb34a1e82e, and its body says the failure paths reproduce there; no merge or released fix provenance is available because this PR remains open. (2bd485825215)

Likely related people:

  • Jerry-Xin: The related open implementation documents the shared manual-run/one-shot ownership failure in depth and carries the broader overlapping repair approach. (role: prior root-cause investigator and adjacent implementation author; confidence: medium; commits: 74f2385748ea; files: src/cron/service/timer-outcomes.ts, src/cron/service/ops-run.ts)
  • steipete: Authored the current focused patch and its new regression coverage for manual runs that wait past a future one-shot deadline. (role: recent cron change author; confidence: low; commits: 05003a5f9e18; files: src/cron/service/ops-run-preparation.ts, src/cron/service/ops-run.ts, src/cron/service/timer-outcomes.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete
steipete merged commit da9ed01 into main Jul 27, 2026
134 of 142 checks passed
@steipete
steipete deleted the codex/cron-bug-sweep branch July 27, 2026 10:10
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 28, 2026
steipete added a commit that referenced this pull request Sep 18, 2026
* 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.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 19, 2026
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: M status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cron: deleteAfterRun fires on manual run even when no run executes (silent data loss)

1 participant