Repository navigation
fix(cron): on-exit watcher retries transient failures instead of silently dropping the watch - #120023
Conversation
|
Codex review: needs changes before merge. Reviewed August 7, 2026, 4:49 AM ET / 08:49 UTC. ClawSweeper reviewWhat this changesThe PR adds bounded retries and recorded error state when an on-exit cron watcher cannot spawn or wait for its supervised process. Merge readinessKeep this maintainer PR open: its retry design addresses the silent watcher drop, but the new cron-state bridge still converts every durable write failure into a stale-watcher no-op. Priority: P2 Review scores
Verification
How this fits togetherGateway cron creates an on-exit watcher for a process and fires the job after a known exit. The watcher records failure state through the cron service before retrying, so the service boundary must distinguish a replaced job from failed persistence. flowchart LR
Job[On-exit cron job] --> Watcher[Gateway process watcher]
Watcher --> Supervisor[Process supervisor]
Supervisor --> Outcome[Exit or transient failure]
Outcome --> State[Cron service state update]
State --> Retry[Backoff retry]
Outcome --> Fire[Fire cron job]
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +79, Tests +48. Total +127 across 3 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Represent stale watcher replacement distinctly at the cron-service boundary, rethrow all other update failures, and prove both outcomes through the Gateway service boundary. Do we have a high-confidence way to reproduce the issue? Yes, from source: make cron persistence reject after the update precondition succeeds; the current catch returns a stale-like no-op instead of allowing the watcher to log the write failure. Is this the best way to solve the issue? No. Retrying at the watcher is the right owner boundary, but stale identity needs a typed result or narrow catch; a blanket catch at the service boundary hides unrelated durable failures. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against aa7cf44c75a1. LabelsLabel justifications:
EvidenceAcceptance criteria:
What 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
HistoryReview history (3 earlier review cycles)
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
A transient supervisor failure while arming or waiting on an on-exit watch previously dropped the watch with only a log line: the job would never fire and nothing recorded why. Failures now persist lastError/consecutiveErrors on job state via the gateway cron service and re-arm with bounded backoff (1s/5s/30s/5m); cancel clears any pending retry timer.
ClawSweeper P1: an old watcher's failure write could land on a job that was edited or converted to a different schedule, pushing the replacement into failure backoff or auto-disable. Watcher-state persistence now uses the same identity precondition as persistCompletion (enabled, on-exit, updatedAtMs match) and treats a mismatch as a no-op.
3777db8 to
8d5dce0
Compare
|
Merged via squash.
|
…ntly dropping the watch (openclaw#120023) * fix(cron): retry on-exit watcher spawn/wait failures with backoff A transient supervisor failure while arming or waiting on an on-exit watch previously dropped the watch with only a log line: the job would never fire and nothing recorded why. Failures now persist lastError/consecutiveErrors on job state via the gateway cron service and re-arm with bounded backoff (1s/5s/30s/5m); cancel clears any pending retry timer. * chore: re-fire CI * fix(cron): guard watcher-state writes against replaced on-exit jobs ClawSweeper P1: an old watcher's failure write could land on a job that was edited or converted to a different schedule, pushing the replacement into failure backoff or auto-disable. Watcher-state persistence now uses the same identity precondition as persistCompletion (enabled, on-exit, updatedAtMs match) and treats a mismatch as a no-op.
What Problem This Solves
Fixes an issue where a cron
on-exitjob could silently never fire: if the process supervisor failed while spawning the watcher child orrun.wait()rejected (supervisor restart, transient resource error), the watcher slot was released with only a warn log. No state was recorded on the job, no retry happened, and the operator saw a job that just never triggered — the worst bug class per repo doctrine (action ends with no visible outcome and no recorded reason).Why This Change Was Made
The watcher is the lifecycle owner of the watch, so the repair lives there: spawn and wait failures now route through a
scheduleRetrypath that recordslastError/consecutiveErrorson the job state (persisted through the gateway cron service viacron.update) and re-arms the watch with bounded backoff (1s → 5s → 30s → 5m). Cancellation clears any pending retry timer so hot-reload/removal semantics are unchanged. Fail-closed behavior on unknown exit outcomes is preserved — retries never fire the job.User Impact
on-exitcron jobs survive transient supervisor failures instead of silently dying, andopenclaw cronstate shows the failure reason while retrying.Evidence
node scripts/run-vitest.mjs src/gateway/cron-exit-watchers— 17 tests pass, including two new regression tests: wait-rejection retries with recorded state and no fire; spawn-failure retries then stops cleanly on cancel.node scripts/run-vitest.mjs src/gateway/server-cron— 64 tests pass with theupdateWatcherStatewiring.