Skip to content

fix(cron): a cron config change no longer aborts running cron jobs - #197606

Merged
obviyus merged 8 commits into
mainfrom
fix/cron-reload-keeps-runs
Nov 12, 2026
Merged

obviyus merged 8 commits into
mainfrom
fix/cron-reload-keeps-runs

Conversation

@obviyus

@obviyus obviyus commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #197591. Thanks @wupingyuan81-oss for the report and timeline.

What Problem This Solves

Changing a cron setting while the Gateway is running, for example with openclaw config set cron.skipMissedJobs true, hot-reloads cron. The reload retired the old scheduler through the shutdown drain, which aborts every cron run in progress. A run that was working normally was cut off and recorded as an error ("job interrupted by gateway restart"), even though the Gateway never stopped.

Why This Change Was Made

When cron stays enabled on the same store, a cron reload already hands its exit watchers to the replacement scheduler. Runs that are already executing are now handed over the same way:

  • Old scheduler (server-cron.ts, CronService.handOver): the handover stops scheduling and stream watchers without the shutdown drain, so it no longer aborts active cron runs. A scheduler retired this way still publishes the finished events of runs that were already executing: broadcasts, hooks, completion webhooks and announce delivery. Its delivery fence (delivery-attempt-fence.ts) accepts the handover, so the primary webhook or announce of such a run still goes out. A real stop still suppresses all of this, as before.
  • Replacement's startup recovery (run-recovery): it used to treat every receipt still marked running as abandoned. It now leaves the receipts that a same-store owner in this process still holds (its launch contexts) and will settle to that owner: a live owner, or one a reload handed over. That covers a timed-out run whose execution is still settling, so the timeout fencing from fix(cron): prevent overlapping retries after execution timeouts #189469 still holds. An owner stopped for real discards its results, so recovery still closes its receipts as before.

Unchanged:

  • A real Gateway stop or restart still aborts running jobs, including one handed over by an earlier reload.
  • A reload that turns cron off or moves the store still drains as before.
  • Non-cron reloads don't touch cron.
  • No new text, no config or stored-format change.

Evidence

  • run-recovery.test.ts adds two cases: recovery leaves a running receipt its owner still holds alone, and keeps a timed-out run's receipt until its execution settles. Both then recover as before once released. With this test file on main, the live-receipt cases fail.
  • Related suites pass at this head: run-recovery, service.restart-delivery, timer, timer.regression, timer.timeout-watchdog, service.cross-tick-admission, server-cron, server-cron-lazy and server-reload-hot.cron-lazy.
  • Types for core and the cron tests pass, and oxlint is clean.
  • Built Gateway proof: see the proof comments below.

…ent scheduler

A scheduling-only cron reload stopped the old scheduler through the shutdown drain, which aborted every in-flight cron run and recorded it as an error. The handover now stops the old owner without aborting its runs, and the replacement's startup recovery leaves jobs still running in this process to that live run.

Fixes #197591. Reported by @wupingyuan81-oss.
@clawsweeper

clawsweeper Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S labels Nov 12, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 12, 2026
@clawsweeper

clawsweeper Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Preserve running cron jobs and their result delivery when cron configuration reloads on the same store.

Example: Run a 60-second cron command and set cron.skipMissedJobs=true after 15 seconds.

  • Before: Reload aborts the command and records an error without delivering its webhook.
  • After: The command finishes once, records success, delivers one webhook, and the next scheduled slot runs normally.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Focused repair with exact-head Gateway evidence, meaningful recovery regressions, and both earlier blockers resolved.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The exact-head proof exercises a built Gateway in secretless Docker through config set, cron history, and a real local webhook: running commands survive reload and deliver once, while subsequent shutdown still aborts them.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Changing cron configuration interrupts healthy running jobs despite the Gateway remaining online.
Reason: The maintainer-authored repair restores useful automation behavior while preserving explicit disable and genuine shutdown semantics.

Merge readiness

✅ Ready for maintainer review

This PR fixes a current automation failure and resolves both prior findings; no actionable introduced defect remains.

Priority: P1
Reviewed head: 0c2fbe15553c84f562167a1c041b02ca9e6909a9

Before merge

None.

Findings

None.

Agent review details

How this fits together

Gateway config reload replaces the cron scheduler; existing launch contexts retain execution and receipt settlement while the replacement schedules future work.

flowchart TD
  A[Configuration change] --> B[Gateway cron replacement]
  B --> C[Old scheduler handover]
  C --> D[Existing runs finish]
  B --> E[Worker startup recovery]
  E --> F[Preserve live receipts]
  D --> G[Record and deliver results]
  F --> G
Loading

Technical review

Best possible solution:

Land the focused handover repair with existing workers retaining receipt settlement and genuine shutdown retaining cancellation.

Do we have a high-confidence way to reproduce the issue?

Current-main source establishes reload → predecessor drain → active-run abort, corroborated by the reporter’s timeline and the contributor’s before/after Gateway output; no target code was executed during this review.

Is this the best way to solve the issue?

The patch addresses cancellation at its lifecycle owner, reuses existing launch contexts, and preserves worker-owned settlement without adding a competing execution path.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 02ec944de426.

Provenance checked

  • Gateway reload handover changes intended behavior with a stated reason (b951bb8: Preserve watched subprocesses across reload while retaining shutdown cancellation.)
  • Worker-owned startup recovery keeps the original intent (64400ff: Restore recorded outcomes once and interrupt uncertain abandoned runs without replaying payload or delivery.)
  • Delivery lifecycle fence changes intended behavior with a stated reason (187594c: Prevent duplicate or unauthorized completion delivery through receipt-backed attempt tracking and live execution checks.)
  • Finished-event publication changes intended behavior with a stated reason (6b48140: Finalize completed jobs without waiting for slower sibling executions; the patch distinguishes reload handover from actual stop.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source +44, Tests -1. Total +43 across 11 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 10 65 21 +44
Tests 1 17 18 -1
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 11 82 39 +43

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Root-cause cluster

Relationship: same_root_cause
Canonical: #197591
Summary: This PR repairs the reload-triggered cancellation reported in the linked issue.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P1: Routine cron configuration reloads currently abort active scheduled work and prevent its intended completion and delivery.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (2 earlier review cycles)
  • reviewed 2026-11-12T07:40:07.102Z sha 0500d7d :: blocked before merge. :: [P1] Protect execution-settlement receipts during replacement recovery | [P2] Preserve finished-event publication for retained runs
  • reviewed 2026-11-12T08:27:43.444Z sha 0500d7d :: needs changes before merge. :: [P1] Protect execution-settlement receipts during replacement recovery | [P2] Preserve finished-event publication for retained runs

Reviewed November 12, 2026, 5:09 AM ET / 10:09 UTC (Revision 3).

@obviyus

obviyus commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator Author

Proof on a built Gateway in secretless Docker (node:24.22.1).

  • main: f9fec3382546.
  • Candidate: 29c45f1c7317. The only later commit, 0500d7d56dcf, changes a test.

Setup: openclaw gateway run with one */2 * * * * command job that writes start, sleeps 60 s, then writes end. 15 s into a run, the proof changes the config. Job state comes from openclaw cron list --json and run records from openclaw cron runs --id <job> --json.

openclaw config set cron.skipMissedJobs true while the job runs

Run The run in progress Its record Next slot
main 1 killed: start 07:08:00, no end error after 17.6 s, "agent run aborted for restart"; job lastError "cron: job interrupted by gateway restart" 07:10 runs, ok
main 2 killed: start 07:14:00, no end error after 16.7 s, same messages 07:16 runs, ok
candidate 1 finishes: start 07:20:00, end 07:21:00 one record, ok, 60.0 s 07:22 runs once, ok; next 07:24
candidate 2 finishes: start 07:24:00, end 07:25:00 one record, ok, 60.1 s 07:26 runs once, ok; next 07:28

On the candidate, 10 s after the reload the job is still running with no error. Each slot has exactly one record, so there's no duplicate run after the handover.

Controls

Run Action during the run Result
candidate Gateway SIGTERM and start, 3 runs the run is aborted and recorded as an error, as on main
main Gateway SIGTERM and start, 3 runs the same
candidate cron reload, then a Gateway stop 10 s later the handed-over run is aborted at stop (error, 26.9 s); the next slot runs normally
candidate config set cron.enabled false aborted, as on main
main config set cron.enabled false aborted
candidate config set logging.level debug (not a cron reload) the run finishes ok, unchanged

Shutdown timing is the same on both. With a command run in progress, the cron run drain hits its 10 s wait on main and on the candidate alike (main runs 2 and 3, candidate runs 1 to 3). One main run finished in 84 ms.

Tests in the same container:

  • run-recovery, server-cron, server-cron-lazy and server-reload-hot.cron-lazy pass at the candidate.
  • With the updated run-recovery.test.ts on main, only the live-run case fails.
  • Types for tsconfig.core.json and the cron test config pass, and oxlint is clean.

Production code is +20/−5 across server-cron.ts, run-recovery.ts, run-recovery.worker.ts and run-recovery.types.ts. Test lines are net 0.

@obviyus

obviyus commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 12, 2026
…un results

Recovery now protects the exact receipts a same-store owner in this process still holds, including a timed-out run's execution settlement, instead of jobs with an active marker. A scheduler retired by a reload handover still publishes the finished events of runs that were already executing.
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 12, 2026
@clawsweeper clawsweeper Bot removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Nov 12, 2026
@clawsweeper clawsweeper Bot removed merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Nov 12, 2026
@obviyus

obviyus commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator Author

Proof for head 0c2fbe15553c on a built Gateway in secretless Docker (node:24.22.1). main is the same f9fec3382546 build as before.

Setup is the same as the earlier proof, with one change: the job now posts its result to a local webhook (--webhook http://127.0.0.1:9919/hook) and prints long-run done, so each finished run has something to deliver. The harness started from this rerun because the earlier job printed nothing, so it never had a webhook to send. Run records come from openclaw cron runs --id <job> --json, and webhook lines come from the local listener.

openclaw config set cron.skipMissedJobs true, 15 s into a run

Run The run in progress Its record Webhook for it Next slot
main killed: start 09:10:00, no end error after 16.3 s, "agent run aborted for restart"; delivery not-delivered none 09:12 runs ok, webhook sent
candidate 1 finishes: start 09:34:00, end 09:35:00 one record, ok, 60.1 s, delivery delivered 09:35:00.143 finished status=ok runAtMs=09:34:00.013 09:36 runs once, ok, webhook sent
candidate 2 finishes: start 09:38:00, end 09:39:00 one record, ok, 60.3 s, delivery delivered 09:39:00.326 finished status=ok runAtMs=09:38:00.014 09:40 runs once, ok, webhook sent

On the candidate, 10 s after the reload the job is still running with no error. Each slot has one record and one webhook, so there's no duplicate run or delivery after the handover.

Controls (same head)

Run Action during the run Result
candidate cron reload, then a Gateway SIGTERM and start 10 s later the handed-over run is aborted at the stop (error after 26.2 s, "agent run aborted for restart"), with no webhook; 09:44 runs ok and is delivered
candidate Gateway SIGTERM and start aborted (error after 15.4 s); the next slot is ok and delivered
main Gateway SIGTERM and start aborted (error after 15.3 s); the next slot is ok and delivered
candidate config set logging.level debug (not a cron reload) the run finishes ok and is delivered, unchanged

Shutdown looks the same on main and the candidate. SIGTERM is logged at the action, and the spawn-broker close step fails about 17 s later in all three restart runs.

Changes since the last proof:

  • The previous head failed service.restart-delivery.test.ts in CI. That test restarts an owner in the same process: recovery had left the receipt to an owner that had really been stopped, and that owner discards its results. Recovery now only skips receipts held by a live owner or by one a reload handed over.
  • The webhook run above showed that the handed-over run finished ok, but its delivery was refused with "cron delivery owner retired". This happened because the delivery fence treated the handover's generation bump as a stop. The fence now accepts a handover.

Tests in the same container at this head: run-recovery, service.restart-delivery, service.persists-delivered-status, server-cron-completion, timer, timer.regression, timer.timeout-watchdog, service.cross-tick-admission, server-cron, server-cron-lazy and server-reload-hot.cron-lazy all pass (11 files, 214 tests). pnpm tsgo:core passes, and scripts/run-oxlint.mjs is clean on the changed files.

Production code is +65/−21 across 10 files. Test lines are net −1.

@obviyus

obviyus commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 12, 2026
@obviyus
obviyus merged commit ce76ed2 into main Nov 12, 2026
149 of 150 checks passed
@obviyus
obviyus deleted the fix/cron-reload-keeps-runs branch November 12, 2026 10:12
@obviyus

obviyus commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator Author

Landed in ce76ed2. Thanks @wupingyuan81-oss for the report.

daniel-lxs added a commit to daniel-lxs/openclaw that referenced this pull request Nov 12, 2026
…load

A cron config change hands scheduling to a replacement and lets runs
already executing finish (openclaw#197606). A fired condition waiting for a run
slot ended instead: its wait followed the scheduler scope, which the
handover aborts, so the run was recorded as aborted without its payload.

- The wait ends when the run is aborted or the scheduler stops, but not
  when it is handed over. A stop wakes waiters so they see it.
- Slot waiters on a store wake on any owner's queue turn, and while a
  handed-over owner has waiters, a store wake also drains the live
  scheduler owners, so the replacement hands the waiting payload a slot.

Refs openclaw#196859
hannesrudolph pushed a commit that referenced this pull request Nov 12, 2026
…197340)

* fix(cron): queue condition checks instead of backing them off

A condition check that found all three evaluations busy was turned away
and retried on the 30s-to-5min admission backoff, even when a slot freed
at once, and a quiet (fire: false) success left the waiting episode and
its retry count in place.

- The run queue admits at most three runs that are still evaluating a
  condition. Further checks stay queued in due-time order with no
  running marker, so they hold no run slot, spend no run budget and keep
  their occurrence across a restart. The evaluator's own cap and its
  busy result are gone.
- A fired condition stops counting as a check, so the next one starts
  while the payload runs.
- A quiet check ends the waiting episode, like a payload run does.
- While any job has a condition, scheduled runs without one leave one
  run slot free.
- A queued timed occurrence survives a graceful shutdown: the host drain
  no longer activates timed work while the Gateway drains, service stop
  leaves it in the durable queue, and an activated launch the stopping
  host refuses is released for the next process instead of skipped.

Refs #196859

* fix(cron): keep checks running while a job waits for its conversation

A job that runs inside the conversation that created it waits for that
conversation to be idle before it starts. The queue activated it first,
so the wait held a run slot and, for a watcher, one of the three
condition checks: three watchers behind one long turn stopped every
other check until the turn ended.

- The host tells the queue which jobs continue a conversation that is
  busy. Their timed occurrences stay queued, the way runs whose agent is
  still preparing do, and the host drains again when the conversation
  goes idle. A waiting occurrence therefore shows as queued, not
  running, and a schedule change cancels it like any queued run.
- Requested and event runs keep their activation before the wait, and a
  turn that starts between the drain and the launch is still waited out
  at launch.
- Scheduled runs without a condition can use all eight run slots; the
  slot held back for checks is removed.

Refs #196859

* refactor(cron): drop the unused busy trigger evaluation flag

The evaluator no longer returns a busy result, so nothing sets
triggerEval.busy. Remove the field, its three readers and the tests that
set it by hand.

* fix(cron): keep condition checks off the run slots

A condition check took one of the eight run slots before it started, so
eight long runs stopped every check until one of them ended.

- A timed check counts against the three-check limit only. A run counts
  against the eight run slots once its condition fires.
- A fired condition then waits, holding neither a check nor a slot, for
  the queue drain to hand it one. The drain gives freed slots to waiting
  payloads and queued runs in due-time order, so a run due before the
  check still starts first. The payload runs on the result of that one
  check. The wait pauses the run's time budget, grants nothing while
  scheduling is paused or the Gateway drains, checks active hours again,
  and ends without a payload if the service stops. A failed request for
  the slot is retried each time the queue moves.
- Requested checks and the checks of script-payload jobs take a run slot
  at activation as before: a script payload's budget cannot pause.

Refs #196859

* fix(cron): keep a fired condition's slot wait across a cron config reload

A cron config change hands scheduling to a replacement and lets runs
already executing finish (#197606). A fired condition waiting for a run
slot ended instead: its wait followed the scheduler scope, which the
handover aborts, so the run was recorded as aborted without its payload.

- The wait ends when the run is aborted or the scheduler stops, but not
  when it is handed over. A stop wakes waiters so they see it.
- Slot waiters on a store wake on any owner's queue turn, and while a
  handed-over owner has waiters, a store wake also drains the live
  scheduler owners, so the replacement hands the waiting payload a slot.

Refs #196859
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 13, 2026
…penclaw#197606)

fix(cron): keep running cron jobs alive across a cron config reload

Changing any cron config key, for example with openclaw config set cron.skipMissedJobs true, hot-reloaded with restartCron, which retired the old scheduler through the shutdown drain and aborted in-flight cron runs, recording them as interrupted by a Gateway restart although the Gateway never stopped. A scheduling-only cron reload now hands over to the new scheduler through CronService.handOver(): runs already executing finish once, their results and delivery are still published, and the delivery fence treats the handover generation as live rather than as a stop. Startup recovery leaves receipts held by a live owner or a handed-over owner alone, so a settling run is not closed and retried, while receipts of a really stopped owner are still recovered. A real Gateway stop or restart still aborts running jobs. No text changes.

Evidence: a built Gateway with a two-minute command job that runs 60 s and posts to a completion webhook. On main, the reload aborted the running job after about 16 s with no webhook, in each run. With this change the running job finishes once with ok and is delivered, the webhook arrives one second after it ends, and the next slot runs once with no duplicate. A reload followed by a restart still aborts the handed-over run at the stop, a plain restart aborts the same way on both, and a non-cron reload leaves the run untouched. Tests are -1 net. Details: openclaw#197606 (comment).

Fixes openclaw#197591. Thanks @wupingyuan81-oss for the report.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 13, 2026
…penclaw#197340)

* fix(cron): queue condition checks instead of backing them off

A condition check that found all three evaluations busy was turned away
and retried on the 30s-to-5min admission backoff, even when a slot freed
at once, and a quiet (fire: false) success left the waiting episode and
its retry count in place.

- The run queue admits at most three runs that are still evaluating a
  condition. Further checks stay queued in due-time order with no
  running marker, so they hold no run slot, spend no run budget and keep
  their occurrence across a restart. The evaluator's own cap and its
  busy result are gone.
- A fired condition stops counting as a check, so the next one starts
  while the payload runs.
- A quiet check ends the waiting episode, like a payload run does.
- While any job has a condition, scheduled runs without one leave one
  run slot free.
- A queued timed occurrence survives a graceful shutdown: the host drain
  no longer activates timed work while the Gateway drains, service stop
  leaves it in the durable queue, and an activated launch the stopping
  host refuses is released for the next process instead of skipped.

Refs openclaw#196859

* fix(cron): keep checks running while a job waits for its conversation

A job that runs inside the conversation that created it waits for that
conversation to be idle before it starts. The queue activated it first,
so the wait held a run slot and, for a watcher, one of the three
condition checks: three watchers behind one long turn stopped every
other check until the turn ended.

- The host tells the queue which jobs continue a conversation that is
  busy. Their timed occurrences stay queued, the way runs whose agent is
  still preparing do, and the host drains again when the conversation
  goes idle. A waiting occurrence therefore shows as queued, not
  running, and a schedule change cancels it like any queued run.
- Requested and event runs keep their activation before the wait, and a
  turn that starts between the drain and the launch is still waited out
  at launch.
- Scheduled runs without a condition can use all eight run slots; the
  slot held back for checks is removed.

Refs openclaw#196859

* refactor(cron): drop the unused busy trigger evaluation flag

The evaluator no longer returns a busy result, so nothing sets
triggerEval.busy. Remove the field, its three readers and the tests that
set it by hand.

* fix(cron): keep condition checks off the run slots

A condition check took one of the eight run slots before it started, so
eight long runs stopped every check until one of them ended.

- A timed check counts against the three-check limit only. A run counts
  against the eight run slots once its condition fires.
- A fired condition then waits, holding neither a check nor a slot, for
  the queue drain to hand it one. The drain gives freed slots to waiting
  payloads and queued runs in due-time order, so a run due before the
  check still starts first. The payload runs on the result of that one
  check. The wait pauses the run's time budget, grants nothing while
  scheduling is paused or the Gateway drains, checks active hours again,
  and ends without a payload if the service stops. A failed request for
  the slot is retried each time the queue moves.
- Requested checks and the checks of script-payload jobs take a run slot
  at activation as before: a script payload's budget cannot pause.

Refs openclaw#196859

* fix(cron): keep a fired condition's slot wait across a cron config reload

A cron config change hands scheduling to a replacement and lets runs
already executing finish (openclaw#197606). A fired condition waiting for a run
slot ended instead: its wait followed the scheduler scope, which the
handover aborts, so the run was recorded as aborted without its payload.

- The wait ends when the run is aborted or the scheduler stops, but not
  when it is handed over. A stop wakes waiters so they see it.
- Slot waiters on a store wake on any owner's queue turn, and while a
  handed-over owner has waiters, a store wake also drains the live
  scheduler owners, so the replacement hands the waiting payload a slot.

Refs openclaw#196859
RomneyDa added a commit that referenced this pull request Nov 14, 2026
…197606)

fix(cron): keep running cron jobs alive across a cron config reload

Changing any cron config key, for example with openclaw config set cron.skipMissedJobs true, hot-reloaded with restartCron, which retired the old scheduler through the shutdown drain and aborted in-flight cron runs, recording them as interrupted by a Gateway restart although the Gateway never stopped. A scheduling-only cron reload now hands over to the new scheduler through CronService.handOver(): runs already executing finish once, their results and delivery are still published, and the delivery fence treats the handover generation as live rather than as a stop. Startup recovery leaves receipts held by a live owner or a handed-over owner alone, so a settling run is not closed and retried, while receipts of a really stopped owner are still recovered. A real Gateway stop or restart still aborts running jobs. No text changes.

Evidence: a built Gateway with a two-minute command job that runs 60 s and posts to a completion webhook. On main, the reload aborted the running job after about 16 s with no webhook, in each run. With this change the running job finishes once with ok and is delivered, the webhook arrives one second after it ends, and the next slot runs once with no duplicate. A reload followed by a restart still aborts the handed-over run at the stop, a plain restart aborts the same way on both, and a non-cron reload leaves the run untouched. Tests are -1 net. Details: #197606 (comment).

Fixes #197591. Thanks @wupingyuan81-oss for the report.

Co-authored-by: Ayaan Zaidi <[email protected]>

Backport: retain the release system-job reconciler and store revision APIs. Handover joins that reconciler and stream teardown without invoking the Gateway-wide execution abort drain. Preserve shutdown behavior and protect live receipts during replacement startup. Add the focused handover regression in a separate file to preserve the test-file size limit.

(cherry picked from commit ce76ed2)

Co-authored-by: RomneyDa <[email protected]>
Co-authored-by: vincentkoc <[email protected]>
(cherry picked from commit 8a9710ed5503592a6dbcee3fb13ab8ca2a2c6d9d)
RomneyDa added a commit that referenced this pull request Nov 15, 2026
Preserve the existing 2026.11.5 beta line and its pending test repairs.
Repair transcript admission, terminal SQLite iterators, binary attachment
classification, detached lifecycle calls, cron late wakes and reload handover.
Carry the explicitly requested Bonjour package-integrity fix and release guidance.

Selected backports: #188055, #198309, #190242, #198860, #198011, #197658,
#197484, #197606. #198011 is the operator-required open PR head, not a
merged-main claim. Cron tests are adapted to the existing beta runtime.

(cherry picked from commit e3064bf)
(cherry picked from commit afa871c)
(cherry picked from commit 2c0ab86)
(cherry picked from commit fee19a9)
(cherry picked from commit dbb6f39)
(cherry picked from commit 4d9f782)
(cherry picked from commit 87c10f5)
(cherry picked from commit ce76ed2)

Proof: frozen parent suite passed all 7 shards (265 tests) in 274.45s.
Separate unchanged-production baseline reproduced transcript/lifecycle,
late-wake and live-receipt failures. SQLite already passed on Node 26.12.1.
Independent review found no actionable P0/P1 defects in this snapshot.
The complete beta.4 candidate and stable-profile FRV remain pending.

Co-authored-by: jalehman <[email protected]>
Co-authored-by: vincentkoc <[email protected]>
Co-authored-by: Yun. <[email protected]>
Co-authored-by: ava-perry <[email protected]>
Co-authored-by: Alfred J Berchtold <[email protected]>
Co-authored-by: Stronggenetics <[email protected]>
Co-authored-by: Ayaan Zaidi <[email protected]>
Co-authored-by: RomneyDa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] config hot-reload aborts in-flight cron runs and records a misleading "Gateway shutting down." error

1 participant