Repository navigation
fix(cron): run jobs added during startup without downtime deferral - #192379
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis 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.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete 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 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe 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]
Technical reviewBest 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
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +25, Tests +31, Other +2. Total +58 across 7 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
Reviewed November 4, 2026, 5:11 PM ET / 22:11 UTC (Revision 2). |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
…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.
8f47d2d to
f6a7488
Compare
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.
…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
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
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.oxlint --type-aware, andgit diff --check: passed.34007820fa2c: complete, no actionable findings.Reviewed candidate:
8f47d2d2db6cb260df03f659a06e403f7c5c6ce4.Split CI status
34007820fa2c: missingMcpCatalogToolexport inmcp-metadata.tsand consequent optional UI metadata errors. That file andagent-bundle-mcp-materialize.ts/agent-bundle-mcp-types.tsare byte-identical to the base; SDK declaration preparation propagates the same error into build/boundary/lint lanes.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, andagent-bundle-mcp-types.tshave identical Git blob IDs at base and PR head. The missingMcpCatalogToolexport 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.
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.