Repository navigation
refactor(cron): reduce catch-up and receipt-binding reads - #172665
Merged
Merged
Conversation
Reuse the scheduler command-owned jobs through catch-up and keep execution authority at queue admission. Remove the receipt-existence read before first-link-wins diagnostic binding; a delayed callback after pruning may leave a harmless diagnostic link.
Contributor
|
ClawSweeper reviews are opt-in for maintainers. If a review is required, finish the work and validation first, then comment |
Contributor
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Oct 15, 2026
…aw#172665) Reuse the scheduler command-owned jobs through startup and clock-jump catch-up, removing duplicate row and runtime-authority reads. Keep exactly-once claim admission, persisted future retries, and settlement merging of current operator edits. Bind execution diagnostics through the existing first-link-wins insert without rereading receipt existence. A callback delayed past receipt pruning may leave an orphan diagnostic link; that metadata grants no execution or delivery authority. The changed owners remain entirely in workers (cron T1 0 to 0). Focused scheduler, queue, and settlement tests and exact-head PR CI passed. Knip findings match the same files and rules on current main; see the PR for proof and the inherited-static-failure exception.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Problem This Solves
Cron startup and clock-jump catch-up reread the jobs already loaded by the scheduler command, and execution diagnostic binding checks receipt existence before its conflict-safe insert.
User Impact
Reduces cron database work without changing schedules, exactly-once claims, persisted future retries, or delivery authorization. No schema change, migration, or operator action.
Why This Change Was Made
The synchronous worker command owns catch-up from load through mutation. Pass its jobs map into catch-up and persist changed runtime rows directly, removing the ID-only load, second row load, and duplicate runtime-authority read. Queue admission retains execution authority. Diagnostic binding writes directly through the existing first-link-wins owner.
Removed checks and accepted edges:
Claim uniqueness, receipt settlement, finalization's merge with current operator edits, and final external-effect authority checks remain intact. The superseded catch-up mutation path is deleted.
Evidence
Formatting, changed-file oxlint and
git diff --checkpassed. Candidate CI, at synthetic merge0bba905882799954fdedd38ddd7799754ec9ad65for candidatec78d82422886bc29cb85d2ec0a519e7cbd4a29f6, passed all 30 selected jobs, including production/test types, type-aware lint, source contracts/export collisions, Madge (0 cycles), and T1/dialect ratchets. Scheduler tests passed 20/20 and queue tests 10/10, including preceding in-process edits, overflow/restart behavior and binding retries. Finalization's concurrent-edit/idempotent-settlement regression passed. Codex autoreview found no actionable P0–P2 findings.Candidate Knip reported seven production and six full-tree export findings, all matched by file and rule on scheduled main. None concerns a changed cron file. Script exports and unused-file scans passed. The inherited-static-failure exception was recorded for follow-up. Two local Knip attempts timed out; a queued Testbox was stopped before proof ran. Local
check:changedhit a Corepack launcher failure; the completed CI jobs provide the static proof.Remaining proof gap: the separately named
gateway-cron-startup-recovery.e2e.test.tswas not selected by that CI run. One local attempt hit the worker-compilation watchdog; after worker-cache preparation, the unchanged test timed out during Gateway startup imports, before its recovery assertions. This is neither passing persisted-future-retry proof nor a demonstrated cron regression. No timeout or assertion was changed. A later immediate remote-capacity probe created no lease and ran no test because the available source capsules were incomplete. The fresh scheduled-run fixture below does not close this gap.Cron T1 call sites remain 0 → 0; both changed production owners already run in workers. Whole-repository T1 remains live 223 → 223, deprecated-only 12 → 12. No SDK, schema, update/Doctor, plugin-loading or service-lifecycle change. Net LOC: production −14, tests +34, documentation +4.
SQL and request measurements
Values are median [min–max] across three alternating base/candidate pairs. SQL includes all threads; requests are logical worker dispatches.
Measurement interpretation
The direct measured saving is two startup catch-up SELECTs: the whole-workload scheduler group is 16 → 14 SQL and 6 → 6 requests in every pair. The fixture starts with an empty cron store; source inspection establishes one additional removed runtime-authority SELECT for populated catch-up. The command still loads current rows once before catch-up, and the new regression proves preceding in-process edits survive the mutation. Diagnostic binding is not exercised by this harness; its one-SELECT saving is source/test evidence, not a measured zero or measured improvement.
The larger raw changes are not attributed to this patch. Warmed SQL is 146.8 → 143.4 and requests 46.0 → 44.3 per turn; causal warmed counts are nearly unchanged (117.9 → 117.8 SQL, 34.6 → 34.5 requests). The cron window drops 447 → 394 SQL and 132 → 103 requests, but includes job setup, polling, session work and background maintenance. Scheduled activation/claim remains 9 SQL / 3 requests, and terminal settlement remains 8 SQL / 1 request in every run.
Whole-workload SQL increases 4735 → 4743 (+8, +0.17%) while requests fall 1129 → 1111. The first-turn median increases 1387 → 1415 SQL (+28) and 170 → 181 requests (+11). Known positive first-turn groups are:
prepared-model-catalog-worker.tsand auth-profile JSON reads; absent in the base traces.session-cost-usage-worker-scope.tsandsession-cost-usage-cache.sqlite.ts; whole-workload counts also rise, so this is not just window movement.These are independently calculated group medians and do not sum to the net +28/+11. The cause of the extra catalog/cache work is unproven. No caching, invalidation, replica or worker-routing change is present in this patch; touched scheduler operations consistently do less work. Under the campaign's attribution-over-raw rule, the unexplained increases are disclosed rather than labeled a cron regression or an across-the-board saving.
All six runs have the same 13 successful background
state_leasesexpiry SELECTs from plugin lifecycle ownership checks across first-turn plus warmed windows. Their timing changes: warmed raw MAIN is 1.3 → 0.4 per turn, but the patch removes none of those reads. Causal warmed MAIN and cron-window MAIN remain zero. No latency claim: host load varied roughly 62–111 on 32 CPUs.Three exact alternating base/candidate pairs completed successfully with ten warmed turns each, successful scheduled-run receipts, no failed SQL executions/prepares, and no fixture children left running. The task-local harness copy uses an allocated Gateway port, a synthetic stored OpenAI profile and current subagent result parsing; setup runs before tracing, all six harness hashes match, and the shared harness was not edited. This stored-account workload differs from the historical campaign workload; compare the paired runs here, not the earlier 82-SQL census.
The additive cron-window ledger accounts for every observed statement and request. Terminal settlement's eight statements are BEGIN, current jobs, conditional receipt completion, retention candidates, existing history, history insert, runtime update and COMMIT. The receipt CAS preserves idempotency; current-job/receipt-marker checks preserve operator edits, deletion and another active run. Existing-history handling preserves cancellations and incompatible committed outcomes; it is diagnostic, not authorization. Those retained reads are not claimed to be universally minimal. Fresh fixtures do not exercise pruning DELETEs, populated startup recovery or startup-batch settlement. Delivery is
none, so the run does not prove an external send.Six-run results, phase totals and additive cron ledger
Raw warmed medians do not regress (SQL 146.8 → 143.4, Δ -3.4; requests 46 → 44.3, Δ -1.7; MAIN 1.3 → 0.4, Δ -0.9 per turn); touched-owner regression status is unproven for diagnostic receipt binding (not attributed in 6/6 runs).
Base:
d25a316fc7c3. Candidate:c78d82422886. Three alternating base/candidate pairs; ten warmed turns per run. Values are median [min–max]; deltas are candidate minus base.SQL includes all threads. MAIN is Gateway main-thread SQL. Requests are distinct logical worker dispatches. An observed increase remains an increase; this report does not classify unexplained changes as noise or make wall-time claims.
Warmed turns
These raw counts include all SQL executions and worker dispatches in the ten warmed phase windows, including background work, divided by ten. MAIN counts Gateway main-thread executions in those same windows.
Causal attribution is shown separately:
Whole workload and cron window
Phase totals
Phase totals include concurrent background work. The warmed aggregate is reported above.
Six raw runs
d25a316fc7c3c78d82422886d25a316fc7c3c78d82422886d25a316fc7c3c78d82422886Touched owners across the whole workload
These whole-workload categories include cold work outside the cron window. The scheduler category also includes activation, tick and refresh work; it is not a startup-only measure.
Additive cron-window ledger
cron.runs)Within each run, source-attributed operations plus the unattributed remainder equal the window total; independently calculated medians need not add. The subtotal and total are summary rows, not additional work. Each request has one primary source operation, including requests that execute no SQL. Statements inherit that operation or use their own source when the request is unresolved. Setup and polling are included above as separate operations.
History polling RPCs: base 4 [3–5], candidate 3 [3–4] (Δ -1). RPC counts are separate from worker requests.
Startup read evidence
boundedCatchupSQL frame:loadCronRowsstartCronSchedulerorigin:loadCronRowsloadCronRowsloadCronRowsOnly successful SELECT/WITH executions with named read functions count here; authority schema metadata reads are separate from authority-row reads. Evidence classes are exclusive. A
startCronSchedulerorigin is call-site evidence, not a captured command payload. Generic scheduler frames and unscoped reads do not prove startup. Read-class request counts can overlap; they must not be summed.Read classes absent from the table had zero observed matching statements.
boundedCatchupSQL framestartCronScheduleroriginZero named reads does not show whether catch-up was exercised. Marker coverage above makes that limit explicit;
boundedCatchupcan also run after a later clock discontinuity.Scope and attribution limits
Spill request counts are coverage of those sets, not additional dispatches. Whole-workload, cron-window and dispatch-cohort scopes overlap and must not be added. The cron window contains job creation, scheduled execution, polling and maintenance; it is not a scheduled-run causal identity. Stacks do not include SQL bindings or command payloads, nested requests have no parent ID, and SQL events have no timestamp. This ledger is not an exact execution timeline.
Failed executions are excluded from successful SQL; a failed multi-statement exec counts as one failure. Fresh fixtures do not prove persisted startup-retry recovery or history/receipt overflow. Delivery mode is
none; external sends are not exercised. Those behaviors require their separate focused regression proof.