Skip to content

fix(cron): replay jobs missed during subsecond Gateway restarts - #117797

Merged
steipete merged 1 commit into
mainfrom
codex/qa-cron-inclusive-restart-8f998
Aug 2, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/qa-cron-inclusive-restart-8f998

Conversation

@steipete

@steipete steipete commented Aug 2, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where a scheduled automation silently failed to run after Gateway restart when the missed cron slot began less than one second earlier.

Why This Change Was Made

Use the existing canonical inclusive previous-slot owner in restart catch-up, matching the adjacent recovery path and compensating for Croner's documented whole-second previous-run semantics. Delete the obsolete strict helper and its internal barrel export, and keep the real Gateway regression in its own focused test module. Preserve existing stagger, timezone, daylight-saving, activation, duplicate-suppression, and error-backoff ownership.

User Impact

A job missed during the first second of its scheduled minute now runs once after restart instead of disappearing without an execution, notification, or recorded reason.

Evidence

  • Real unchanged-parent Gateway restart regression: restart at 04:02:00.500 after a missed 04:02:00 slot invokes the scheduled job zero times instead of once.
  • Frozen candidate 9862dd38811a21e722d1d6d1a4c3db378ad2f0c2: all three complete scheduling/restart owner suites pass 124/124, including five-field and six-field boundaries, 500/999 ms offsets, stagger, restart, activation, and backoff.
  • Four independently fresh hostile reviews directly inspected pinned Croner 10.0.1 source/declarations, shipped releases, the actual Gateway startup chain, both inclusive/strict scheduling owners, and all affected sibling behaviors.
  • Genuine official gpt-5.6-sol high-reasoning P0–P3 review: zero findings, confidence 0.94; native TruffleHog 3.96.0 secret scan clean.
  • Existing canonical refactor removes 11 production lines; exact remote dead-export scans and local scoped oxlint pass. The broader remote gate stopped with an infrastructure/transport exit 255, so final complete typecheck evidence will come from this PR's exact-head hosted CI.

@openclaw-barnacle openclaw-barnacle Bot added size: XS maintainer Maintainer-authored PR labels Aug 2, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P1 High-priority user-facing bug, regression, or broken workflow. labels Aug 2, 2026
@clawsweeper

clawsweeper Bot commented Aug 2, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 2, 2026, 12:48 AM ET / 04:48 UTC.

ClawSweeper review

What this changes

Changes Gateway cron restart catch-up to include a scheduled slot already in progress during its first second, removes the unused strict helper, and adds boundary-focused regression coverage.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

This PR remains necessary: current main still takes the strict previous-slot path during Gateway restart catch-up, which excludes a cron slot that started within the current second. The candidate reuses the established inclusive helper and adds focused restart coverage; the protected maintainer label requires an explicit owner merge decision.

Priority: P1
Reviewed head: 9862dd38811a21e722d1d6d1a4c3db378ad2f0c2
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused root-cause repair with direct restart-boundary evidence and no actionable correctness finding; final merge remains subject to owner review and exact-head CI.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The PR includes an after-fix CronService restart regression at the affected boundary, reports focused scheduling-suite results, and is marked proof: sufficient; no sensitive output is present.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR includes an after-fix CronService restart regression at the affected boundary, reports focused scheduling-suite results, and is marked proof: sufficient; no sensitive output is present.
Evidence reviewed 6 items Current-main defect path: Current main calls the strict previous-slot helper from the missed-slot check; at a restart time within the first second after a boundary, that helper can return the prior occurrence rather than the slot that just began.
Existing canonical boundary owner: The existing inclusive helper explicitly compensates for Croner previous-run lookups being strict-before and second-granular, then is already used by the sibling due-slot path.
Pinned dependency contract: Croner's documented API strips milliseconds for previous-run calculations, consistent with the current inclusive helper's second-boundary compensation. citeturn1view1.
Findings None None.
Security None None.

How this fits together

Cron jobs persist their most recent and next scheduled execution times. On Gateway startup, restart catch-up decides whether a missed cron slot should run, then hands the selected job to the normal execution and state-update path.

flowchart LR
  A[Persisted cron state] --> B[Gateway restart]
  B --> C[Restart catch-up]
  C --> D[Find latest scheduled slot]
  D --> E{Missed since last run?}
  E -->|Yes| F[Run job once]
  E -->|No| G[Keep next schedule]
  F --> H[Persist outcome]
Loading

Decision needed

Question Recommendation
Should the cron-area owner approve merging this restart-catch-up switch to the existing inclusive previous-slot policy after the latest-head CI finishes? Confirm and merge: Approve the canonical inclusive-boundary repair once the remaining checks on commit 9862dd38811a21e722d1d6d1a4c3db378ad2f0c2 are green.

Why: The patch is narrowly source-supported, but it changes a protected maintainer-owned Gateway recovery path that decides whether scheduled work runs after restart.

Before merge

  • Resolve merge risk (P1) - Restart catch-up controls whether persisted scheduled work is replayed or skipped; merge should wait for exact-head CI and cron-owner confirmation that the inclusive boundary remains consistent with duplicate suppression and error-backoff behavior.
Agent review details

Security

None.

PR surface

Source -11, Tests +65. Total +54 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 3 1 12 -11
Tests 2 67 2 +65
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 68 14 +54

Review metrics

None.

Stored data model

Persistent data-model change detected: serialized state: src/cron/service.restart-catchup-subsecond.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Confirm and merge after exact-head CI (recommended)
    Have a cron-area owner confirm that the inclusive helper is the restart policy, then merge after the remaining current-head checks pass.
  2. Pause for an operator restart trace
    Keep this PR open if maintainers require an additional production-like restart trace to validate replay and duplicate suppression together.

Technical review

Best possible solution:

Keep the single inclusive previous-slot policy, land this focused restart-catch-up change after exact-head CI is green, and retain the new five-field, six-field, staggered, and startup-boundary regression coverage.

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

Yes—current-main source shows the strict previous-slot calculation in the restart missed-slot path, while the existing inclusive helper covers the same boundary. The candidate adds a focused CronService startup case at 500 ms after the scheduled minute; this read-only review did not execute it.

Is this the best way to solve the issue?

Yes—the branch removes the duplicate strict policy and routes restart catch-up through the already-established inclusive scheduling owner instead of adding a new fallback or configuration surface.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 4f707d15d8fa.

Labels

Label changes:

  • add merge-risk: 🚨 availability: The changed recovery decision determines whether a scheduled cron job is executed or skipped after Gateway startup.

Label justifications:

  • P1: A Gateway restart can silently skip an established scheduled automation run, affecting a core operator workflow.
  • merge-risk: 🚨 availability: The changed recovery decision determines whether a scheduled cron job is executed or skipped after Gateway startup.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR includes an after-fix CronService restart regression at the affected boundary, reports focused scheduling-suite results, and is marked proof: sufficient; no sensitive output is present.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR includes an after-fix CronService restart regression at the affected boundary, reports focused scheduling-suite results, and is marked proof: sufficient; no sensitive output is present.

Evidence

What I checked:

  • Current-main defect path: Current main calls the strict previous-slot helper from the missed-slot check; at a restart time within the first second after a boundary, that helper can return the prior occurrence rather than the slot that just began. (src/cron/service/timer-runnable.ts:21, 4f707d15d8fa)
  • Existing canonical boundary owner: The existing inclusive helper explicitly compensates for Croner previous-run lookups being strict-before and second-granular, then is already used by the sibling due-slot path. (src/cron/service/jobs-scheduling.ts:169, 4f707d15d8fa)
  • Pinned dependency contract: Croner's documented API strips milliseconds for previous-run calculations, consistent with the current inclusive helper's second-boundary compensation. citeturn1view1. (package.json:1961, 4f707d15d8fa)
  • Candidate repair and regression proof: The proposed head switches only the restart missed-slot check to the existing inclusive helper and adds a CronService startup regression at 04:02:00.500Z with the persisted next run already advanced. (src/cron/service.restart-catchup-subsecond.test.ts:11, 9862dd38811a)
  • Current-main and release check: The candidate commit is not an ancestor of checked-out main and no local release tag contains it, so the fix is neither implemented on current main nor shipped. (9862dd38811a)
  • Area provenance: Current-file blame attributes the central restart missed-slot and prior-occurrence helpers to the same recent cron-area contribution, making it the best available routing signal. (src/cron/service/timer-runnable.ts:21, 34692256bef3)

Likely related people:

  • zengLingbiao: Current blame attributes the restart missed-slot predicate and the strict/inclusive prior-occurrence helpers to this contributor's recent cron-area history. (role: recent area contributor; confidence: low; commits: 34692256bef3; files: src/cron/service/timer-runnable.ts, src/cron/service/jobs-scheduling.ts)

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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-08-02T04:20:24.991Z sha 8f998aa4b6dcbc2f6fea9698bc44d6899cafddf8 :: needs maintainer review before merge. :: none

@steipete
steipete force-pushed the codex/qa-cron-inclusive-restart-8f998 branch from 8f998aa to 9862dd3 Compare August 2, 2026 04:42
@steipete
steipete requested a review from a team as a code owner August 2, 2026 04:42
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. label Aug 2, 2026
@steipete
steipete merged commit d4c6ed4 into main Aug 2, 2026
198 of 204 checks passed
@steipete
steipete deleted the codex/qa-cron-inclusive-restart-8f998 branch August 2, 2026 04:58
@steipete

steipete commented Aug 2, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary 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.

1 participant