Skip to content

fix(cron): run jobs added during startup without downtime deferral - #192379

Merged
RomneyDa merged 2 commits into
mainfrom
fix/forward-port-1010-cron
Nov 5, 2026
Merged

RomneyDa merged 2 commits into
mainfrom
fix/forward-port-1010-cron

Conversation

@RomneyDa

@RomneyDa RomneyDa commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

Problem

Jobs accepted while the Gateway is live but before its scheduler starts are mistaken for downtime catch-up and delayed two minutes.

Solution

Carry service creation time into startup admission; clear it on stop so in-process restarts retain downtime deferral. Persisted last-run misses remain deferred.

Independent split of #191830, directly against main; no sibling PR is required. Original release provenance is preserved in commit bodies. Scope excludes every other forward-port group.

Evidence

  • Original combined-branch evidence: cron 76 tests passed; regression failed without the fix.
  • Product/test changes cherry-picked cleanly; original evidence is retained evidence, not a new split-head run.
  • Fresh node scripts/run-vitest.mjs src/cron/service.trigger-eval.test.ts --maxWorkers=1: 21/21 passed. Initial worktree runs failed dependency setup before tests; restoring matching package-local dependency links resolved that setup failure.
  • Fresh changed-file formatting, targeted oxlint --type-aware, and git diff --check: passed.
  • Local ClawSweeper committed-range review against main 34007820fa2c: complete, no actionable findings.
  • Full lint/type declaration preparation refused this worktree’s shared dependency install; no bypass used. Broad type/build proof remains with PR CI.
  • Test growth is exactly offset by this PR’s scoped allocation; the selected main base has an inherited 47-line ratchet deficit.
  • Broad type/build/CI coverage is delegated to PR CI.

Reviewed candidate: 8f47d2d2db6cb260df03f659a06e403f7c5c6ce4.

Split CI status

  • Observed CI failure is inherited from main 34007820fa2c: missing McpCatalogTool export in mcp-metadata.ts and consequent optional UI metadata errors. That file and agent-bundle-mcp-materialize.ts / agent-bundle-mcp-types.ts are byte-identical to the base; SDK declaration preparation propagates the same error into build/boundary/lint lanes.
  • Test-line ratchet retains the pre-split 47-line deficit: baseline total 6,444,916 versus ceiling 6,444,869. This split’s dedicated allocation covers its exact positive test-line delta; inflating it would violate the allocation checker.
  • Ready for review does not mean green CI or ready to merge. Remaining broad checks are still running; no merge requested.

Exact-head CI attribution audit

Audited 2026-11-04 at 8f47d2d2db6cb260df03f659a06e403f7c5c6ce4. Failed job logs were inspected individually, not inferred from their names.

The MCP failures are inherited from base 34007820fa2c: src/agents/mcp-metadata.ts, agent-bundle-mcp-materialize.ts, and agent-bundle-mcp-types.ts have identical Git blob IDs at base and PR head. The missing McpCatalogTool export and consequent optional-property errors propagate through SDK declarations into boundary/build/lint/type lanes.

The test-line ratchet is also inherited: this PR offsets its exact positive test-line delta, and its job still exceeds the adjusted ceiling by the same 47 lines already present at base (6,444,916 vs 6,444,869). No baseline increase or unrelated repair is included.

Failed check Attribution
checks-fast-baseline-ratchets Inherited 47-line test-budget deficit
check-additional-extension-package-boundary Inherited MCP declaration/type failure
check-prod-types Inherited MCP declaration/type failure
check-test-types Inherited MCP declaration/type failure
check-test-types-core-1 Inherited MCP declaration/type failure
check-test-types-core-2 Inherited MCP declaration/type failure
check-test-types-core-3 Inherited MCP declaration/type failure
check-test-types-core-4 Inherited MCP declaration/type failure
check-test-types-core-5 Inherited MCP declaration/type failure
openclaw/ci-gate Aggregate of failed or downstream-skipped prerequisite jobs above; not an independent runtime failure
openclaw/ci-gate Aggregate of failed or downstream-skipped prerequisite jobs above; not an independent runtime failure

Cancelled dispatch jobs are orchestration cancellations, not passing tests or additional source defects. CI remains red; this section explains the failures rather than claiming green.

Rebase onto current main

Rebased onto a1f99240c8367a0e012b401bed71831a3cc65026, including merged Goal-test correction #192387. New candidate: f6a7488bc5200d73522b251ef22ff196691efd18. This PR still targets main independently.

Verified the complete rebased tree equals the previous PR patch integrated with that main snapshot. No new behavior was added during rebase. Prior test and CI attribution sections remain evidence for their named old revisions; fresh CI on this head is pending, not claimed green.

@clawsweeper

clawsweeper Bot commented Nov 3, 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.

@RomneyDa
RomneyDa marked this pull request as ready for review November 3, 2026 23:36
@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. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 3, 2026
@clawsweeper

clawsweeper Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR distinguishes jobs due during service startup from downtime misses so they avoid the two-minute startup deferral.

Example: A service is created at 12:00:00, accepts a watcher due at 12:00:30, and starts scheduling at 12:00:35.

  • Before: The watcher is deferred until approximately 12:02:35.
  • After: The watcher becomes eligible during startup, subject to existing capacity limits.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused implementation appears correct and preserves existing storage formats; confidence is limited to source review and reported harness evidence, with broad CI attribution unresolved.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor proof gate; supplied cron evidence is an in-process service regression, and the four inspected screenshots concern unrelated settings navigation rather than startup scheduling.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A newly accepted watcher can wait two extra minutes for its first evaluation while the Gateway finishes startup.
Reason: The maintainer-authored direction fixes an observable scheduling delay while preserving the existing downtime catch-up policy.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR addresses a current scheduling defect with a focused change and no concrete introduced bug found; failing CI still needs attribution before landing.

Priority: P2
Reviewed head: 8f47d2d2db6cb260df03f659a06e403f7c5c6ce4

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: No supplied shipped-Gateway trace demonstrates immediate startup evaluation alongside retained downtime and stop/start deferral; the reported pre-fix failure belongs to the original combined branch.
Agent review details

How this fits together

The cron service passes lifecycle timing to the SQLite scheduler worker, which classifies due jobs and returns committed requests for the existing execution queue.

flowchart LR
  A[Gateway job admission] --> B[Cron service]
  B --> C[Scheduler worker]
  D[Persisted jobs] --> C
  C --> E[Run queue]
  E --> F[Trigger or payload execution]
Loading

Technical review

Best possible solution:

Keep startup classification in the existing worker, using the transient service timestamp while retaining downtime deferral and existing queue limits.

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

Current-main source deterministically defers a newly accepted agent job whose first deadline passes before scheduler start; the committed regression exercises that service path, but no target code was run during this read-only review.

Is this the best way to solve the issue?

The patch is a small, coherent repair: one transient timestamp supplies the missing lifecycle fact to the existing classification owner, preserves future-deadline history-based misses, and resets on stop.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 44eaed3d95d7.

Provenance checked

  • Worker-owned catch-up classification changes intended behavior with a stated reason (b943945: Move timers, bounded catch-up, durable deferral, and schedule decisions into one worker actor; the later c6558f6 refactor retained those semantics while reducing reads.)
  • Service lifecycle and readiness keeps the original intent (543dd39: Let agent readiness wake queued cron work without consuming custody or capacity; the new timestamp leaves those admission and readiness owners intact.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit c6558f6 adds src/cron/store/scheduler-actor.worker.ts:344 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: c6558f6a60f8; files: src/cron/store/scheduler-actor.worker.ts)

PR surface

Source +25, Tests +31, Other +2. Total +58 across 7 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 5 31 6 +25
Tests 1 31 0 +31
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 0 +2
Total 7 64 6 +58

Review metrics

Metric Value Why it matters
Production versus regression growth Production +31/-6; tests +31/-0 The growth carries one lifecycle fact through existing owners and adds one distinct startup regression without new modules or test-only production hooks.

Labels

Label changes:

  • add P2: Jobs accepted during slow startup incur an unnecessary two-minute delay, with limited scheduling impact rather than lost execution.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: Jobs accepted during slow startup incur an unnecessary two-minute delay, with limited scheduling impact rather than lost execution.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rank-up moves

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

  • Add a redacted Gateway trace showing a watcher accepted before scheduler start evaluating without the two-minute deferral.

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 (1 earlier review cycle)
  • reviewed 2026-11-04T00:00:00.203Z sha 8f47d2d :: needs maintainer review before merge. :: none

Reviewed November 4, 2026, 5:11 PM ET / 22:11 UTC (Revision 2).

@RomneyDa

RomneyDa commented Nov 4, 2026

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 4, 2026
…rral

The Gateway accepts cron.add while its cron scheduler start is still
pending. On a slow host the new job's first slot passes before start,
so startup catch-up classified it as missed downtime work and deferred
main-session and agent jobs by the 2-minute startup delay. A new
condition watcher therefore had no first evaluation for two minutes.

Only defer agent work whose due slot predates this cron service's
creation; slots that came due while the process was live run as late
work. Adapted to main: misses detected from persisted lastRun state
(future nextRunAtMs) stay downtime catch-up, and stop() clears the live
window so an in-process scheduler restart keeps the startup deferral.

Forward-port of db5b6d3 from release/2026.10.10.
@RomneyDa
RomneyDa force-pushed the fix/forward-port-1010-cron branch from 8f47d2d to f6a7488 Compare November 5, 2026 01:49
@RomneyDa
RomneyDa merged commit e7e8234 into main Nov 5, 2026
127 checks passed
@RomneyDa
RomneyDa deleted the fix/forward-port-1010-cron branch November 5, 2026 03:00
RomneyDa added a commit that referenced this pull request Nov 5, 2026
Carry the final reviewed changes from #191830, #192378, #192379,
#192380, #192383, #192385, and #192386. Preserve #191838's existing
file-transfer import fix. Adapt Gateway readiness to the release owner
and include the narrow SQLite cold-admission prerequisite from #192586.

Do not carry #192387: its Goal expectation depends on main-only
Stop-to-paused behavior absent from this release.

Retain regression allocations without changing the shared baseline.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 5, 2026
…penclaw#192379)

* fix(cron): run jobs added before scheduler start without startup deferral

The Gateway accepts cron.add while its cron scheduler start is still
pending. On a slow host the new job's first slot passes before start,
so startup catch-up classified it as missed downtime work and deferred
main-session and agent jobs by the 2-minute startup delay. A new
condition watcher therefore had no first evaluation for two minutes.

Only defer agent work whose due slot predates this cron service's
creation; slots that came due while the process was live run as late
work. Adapted to main: misses detected from persisted lastRun state
(future nextRunAtMs) stay downtime catch-up, and stop() clears the live
window so an in-process scheduler restart keeps the startup deferral.

Forward-port of db5b6d3 from release/2026.10.10.

* test(ci): scope cron forward-port regression allocation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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