Repository navigation
perf(queue): charge organic executions and let scheduled backfill use its review budget - #1710
Conversation
… its review budget Scheduled normal backfill delivered ~4 reviews/hour against the ~56/hour needed to hold 7-day coverage on openclaw/openclaw. The organic-first admission bucket did not actually account for organic work: stored debt was clamped to zero on every read, and only brand-new queue keys were charged, so supersedes and source-drift requeues ran uncounted. The 35/65 lane split applied to the total rather than the remainder, letting hot intake (offered every 5 minutes) take what little budget was left. - Carry organic debt on the global scheduled bucket down to -burst; lane buckets stay non-negative. - Debit the global bucket for every organic execution: a new key, a superseding revision that revokes a dispatching/leased owner, and a completion requeue for new review input (requeue_latest or a changed desired revision). Pending coalesces, dedupes, publications and same-revision retries are not charged. - Production budget 60/h -> 220/h, burst 6 -> 24; new optional EXACT_REVIEW_HOT_INTAKE_RATE_PER_HOUR (production 30; unset keeps 35%), normal backfill receives total minus hot. - Offer openclaw/openclaw normal backfill every 20 minutes: direct planner 1 * * * * -> 9/20 * * * *, fleet normal fanout 41 * * * * -> 14/20 * * * *. Hot containment and the 32-slot scheduled cap are unchanged. - Update limits/scheduler/README docs, documentation-sync claims, tests.
Drives the real ExactReviewQueue in workerd with a fake clock: organic new items, supersedes and requeue_latest completions, scheduled hot/normal offers at each revision's sweep.yml cadence, dispatch, claim, completion and a GitHub throttle signal, comparing a base ref with the working tree.
Pins the simulated-hour proof to 15fcdf6 with the harness and result sha256, the restated organic-debt gate, and the per-hour organic/hot/normal table for origin/main versus this branch.
|
🦞👀 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. Reviewed September 30, 2026, 11:25 PM ET / October 1, 2026, 03:25 UTC (Revision 8). ClawSweeper reviewWhat this changesThe branch charges organic review admissions and successors against scheduled capacity, raises the scheduled budget, increases normal backfill frequency, and adds runtime proof and regression coverage. Merge readiness✅ Ready for maintainer review The PR remains useful: current main lacks these accounting corrections and operating settings. No actionable patch defect remains, the runtime and persistence evidence is sufficient, and the recorded maintainer decision resolves the previous rollout blocker. Priority: P2 Review scores
Verification
How this fits togetherClawSweeper’s durable review queue receives webhook requests and scheduled candidates, then admits and dispatches review workflows. Shared credit, lane limits, and throttle feedback control scheduled work while organic requests retain priority. flowchart TD
A[Organic requests] --> C[Durable review queue]
B[Scheduled candidates] --> C
C --> D[Shared credit and lane budgets]
E[Throttle feedback] --> D
D --> F[Review workflow dispatch]
F --> G[Completion and reconciliation]
G --> C
Before mergeNone. Agent review detailsSecurityNone. Review metrics
Technical reviewBest possible solution: Keep accurate admission accounting and the approved operating settings, with the documented rollout monitoring and configuration rollback thresholds. Do we have a high-confidence way to reproduce the issue? Yes: main’s bucket read discards negative credit and its successor paths omit the new debits; the supplied workerd receipts demonstrate the before/after behavior. This read-only review did not execute the harness. Is this the best way to solve the issue? Yes: the branch extends the existing shared admission budget, preserves organic priority and throttle handling, and verifies existing-state compatibility without introducing a parallel scheduler. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 65f9c3a30576. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (7 earlier review cycles)
|
# Conflicts: # CHANGELOG.md
…ganic spike The harness recursively replaces its output directory, so it now refuses any path that is not strictly inside the checkout's .artifacts/ directory and any existing non-empty directory without its own marker file, before loading tooling. Adds a 130/300/130 organic-per-hour scenario and per-hour minimum global balance, and asserts the balance never drops below -burst.
…organic Organic work is always admitted and debt beyond -burst is dropped at the floor, so total executions stay within max(rate, organic rate) + burst over time and scheduled admission falls to nearly zero while organic runs at or above the rate. Adds a regression test for sustained above-rate organic load: scheduled stays shed, the balance floors at -burst, and scheduled resumes only after the debt is repaid.
… proof Re-runs the scheduled budget proof on the clean head 85d38e6 against main 1b2c262: scheduled admission is bounded, organic work is unbounded, and total executions stay within max(rate, organic rate) + burst. Adds the 130/300/130 organic spike row: scheduled admission falls to 11 during the spike with the balance at the -24 floor, then recovers. Updates the head SHA and harness/result/source hashes.
…erf/scheduled-backfill-budget # Conflicts: # CHANGELOG.md
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
…ll-budget # Conflicts: # CHANGELOG.md
# Conflicts: # CHANGELOG.md
|
Post-merge rollout record (merge
Finding: the organic charge is applied at admission. Roughly half of admitted organic items never run a review (superseded or coalesced before dispatch, or finished as a no-op), so charged organic work sits at or above the 220/hour budget and scheduled backfill stays mostly shed. A follow-up will charge the budget for reviews that actually run, so that 220/hour means executed reviews. No rollback was needed. |
…1736) * fix(queue): charge the review budget when a review lease is claimed Production after #1710 admitted ~215 organic items/hour and charged each one at admission, but only ~111/hour ever started a review: the rest were closed before the dispatch-time live check, superseded while still dispatching, coalesced, or deduped. The charged organic rate sat at or above the 220/hour budget, the global balance stayed at the -burst floor, and every scheduled hot/normal offer was shed. Meter executions instead of admissions. Every new claim generation of a review lease (a workflow run that actually starts) debits one global token in the same synchronous turn that grants the lease; same-attempt claim retries take the idempotent early return and are not charged again. Organic admission, superseding revisions, and completion/reconciliation requeues no longer debit; their next claim does. Publications and acknowledgement-only finalizers are never charged. Scheduled admission still debits at admission, where it is gated, and marks the new item reviewBudgetPrepaid so its first claim is not charged a second time, including after an organic event coalesces into it or supersedes it before claim. Later claims of the same item are charged like organic ones. Organic is always admitted, scheduled spends only positive balance, the debt floor stays -burst, throttle feedback still pauses scheduled admission, and the hot cap and lane buckets are unchanged. The new item field is additive; the base ignores and preserves it on rollback. Extend scripts/proof-scheduled-budget.mjs with a production_2026_10_01 scenario (closed-before-dispatch items, supersede of dispatching owners), per-hour claimed executions, a variant-neutral reconciliation proof, and an upgrade/rollback proof against the #1710 accounting. * docs(proof): record claim-time review budget charging proof Runs scripts/proof-scheduled-budget.mjs on the clean head 3febf5e against main cac974b (#1710) in workerd/SQLite. In the production_2026_10_01 scenario (~215 new organic items/hour, ~110/hour executed) the base sheds every scheduled offer with the balance at -24, while the head admits 98-115 scheduled reviews/hour and runs 214-225 executions/hour (rolling max 236 of 244). The #1710 scenarios, throttle pause, reconciliation exactly-once and persisted upgrade/rollback are recorded alongside. Marks the #1710 proof as historical.
Problem and status
Normal backfill was reported at roughly 4 reviews/hour against the roughly 56/hour needed for seven-day coverage. The scheduled admission bucket discarded organic debt on reads and missed some successor admissions, so its accounting did not describe the work being admitted.
Operating-policy decision: approved on 2026-10-01 (see "Maintainer decision" below). This branch still contains the proposed 220/hour target, 24-item burst, 30/hour hot-lane rate, and 20-minute normal planner cadence. Those production settings are not approved by this proof. The accounting corrections can be retained with the existing 60/hour, six-item-burst settings and current cadence; that conservative variant will not by itself meet the proposed coverage goal.
Accounting and proof fixes
.and parent-directory cases.Behavior proof
Claim and surface: the production ExactReviewQueue in workerd/SQLite retains bounded organic debt, admits organic overload without pretending it is a hard total cap, preserves throttle behavior, and charges a new-input successor recovered by reconciliation once. The filesystem control verifies that the actual proof CLI preserves existing operator files.
Scenario and environment: current main
c1a83a00a73a800f45ff67ef5c7677ba4f17a8daversus the candidate source identified by recorded hashes, through real enqueue, alarm, claim, completion, requeue, reconciliation and replay calls. The full combined simulation includes normal load, superseding/requeued input, changing hourly load, sustained 400/hour organic traffic, a 400-item spike, and throttle feedback. GitHub, credentials, clock and workload are synthetic. No live inference, production state, or GitHub mutation is involved.Current combined proof: https://crabbox.openclaw.ai/portal/runs/run_4d793e62c284e7a30488619c875b7dbc. Full check: https://crabbox.openclaw.ai/portal/runs/run_a14a6d8392e7fb1ae21d98056daca775.
Provider
aws, leasecbx_3cb5de4e8f4c, imageami-0461d919be7deb53c, Node 24.18.1, workerd 1.20260701.1, Miniflare 4.20260701.0. Runtime source hashes are recorded in the result; the post-commit files at4c1feb68dfd108d752c4a842a8c29ff563b80551match the tested source. The earlier isolated receipt and reproducible commands are in the proof document.Both variants admit all 31 organic arrivals during the throttle cooldown. Candidate scheduled concurrency remains at or below 32. The preserved 130→300→130 scenario admits 226, 331 and 192 items across its three hours, while separately recording actual dispatches. The spike and sustained-load results demonstrate that 244 is not a total-admission ceiling.
The combined runtime harness passed. That job then stopped on the docs check because the validation checkout had not indexed the new linked receipt; indexing it and rerunning the full check passed. The earlier independent fixes also passed a full check before the author/main integration. No failing application assertion was waived.
The candidate runtime input SHA-256 values match the published files:
dashboard/exact-review-queue.ts:e06feaec95029a7f2c1810e11ccf5c754a953be1626bc77718ccf17226b45f0bdashboard/wrangler.toml:90db5d9b3093c7edc647b3329ffde989603d1c8b9fe68d76058336b6289ed673.github/workflows/sweep.yml:33ca5969022cf5b268e7a405db2f535056a2de64c3baa5c81941a44c4e0ebd2eLimits: seeded simulation and unlimited candidate supply do not establish live GitHub quota headroom, inference cost, or Actions scheduling behavior. This proof does not approve a production rate increase. The advertised budget is an admission target with bounded organic debt, not a total-work ceiling.
Persisted upgrade and rollback proof
The additional review request is addressed with eight real workerd/SQLite restart cases. Each begins on the deployed 60/hour, burst-six implementation, then reopens the same Durable Object with the candidate and finally the baseline. Both retaining 60/6 and proposing 220/24 are covered, each with a partially spent balance, exhausted balance, legacy persisted
-1, and populated hot/normal lane buckets.Upgrade preserves all bucket, item and delivery records exactly and does not mint a fresh burst. Candidate organic admissions reach the appropriate debt floor. Rollback preserves the same records but restores the old debt-forgiving interpretation: it displays negative credit as zero, sheds an immediate scheduled offer, and admits a different item one minute later. This proves storage compatibility, not preservation of the new debt-repayment delay during rollback.
All eight cases passed, along with the throttle and reconciliation controls, on AWS lease
cbx_36bc5d811d57, imageami-0461d919be7deb53c, Node 24.18.1. Run: https://crabbox.openclaw.ai/portal/runs/run_e83abfd93218638403762c9fb6d856af. The checked-indocs/proof/scheduled-budget/upgrade-and-rollback.jsonrecords runtime and harness hashes, row digests and limits. Runtime files match4c1feb68dfd108d752c4a842a8c29ff563b80551; the proof harness was an uncommitted overlay on that head. The proof-only follow-up isd26aeb7774e7dd8531cf4ddf4382f47bb679366eand changes only the harness, documentation and receipt.Validation and finding disposition
pnpm run checkat the runtime-source head4c1feb68df: 7,057 tests: 7,038 passed, 19 skipped, zero failures, plus 13 changed-coverage tests.pnpm run check:docsand formatting checks pass. The reproduction command now uses the documented tool path directly.4c1feb68dfare clean. The additional persistence harness and receipt also passed a fresh isolated local review with no accepted/actionable findings.OpenClaw Bay and rollout
Bay's schema and observer-only role are unchanged. If the proposed settings are approved,
scheduled_feed.target_rate_per_hourchanges value. The higher target and extra planner offers can increase GitHub and inference demand; live quota headroom remains an operator decision. Keep this PR unmerged until that scope is chosen. Restoring the current rate/burst/hot defaults and crons is a configuration rollback; the accounting fixes require no new store or schema.Maintainer decision
On 2026-10-01, in the maintainer's agent session, Peter Steinberger instructed: "land 1710". That approves the proposed scope as written: a 220/hour target, a 24-item burst, a 30/hour hot-lane rate, and normal backfill every 20 minutes. It also accepts the documented rollback pacing, where rollback forgives negative credit.
Context at the time of the decision: seven-day coverage on openclaw/openclaw was 32.2%, with 3,880 stale, 1,509 unreviewed and 1,248 expired records, and normal backfill ran 61 reviews in 24 hours.
Rollout watch for the first 2 hours after deploy, then daily:
/api/exact-review-queue:scheduled_feed,lanes.review.backoff_reasons.throttle_retry, shed reasons;/api/github-egress-observability: 403/429 on thetarget_apppool;/api/review-coverage.Roll back if
throttle_retrystays above 0 for 15 minutes, or iftarget_app403/429 exceeds 1% of wire attempts in a 30-minute window. Rollback meansEXACT_REVIEW_TARGET_RATE_PER_HOUR = "60",EXACT_REVIEW_TARGET_BURST = "6"and unsetting the hot rate. That is a Worker var redeploy; the accounting stays.This head merges current main (
b67d265eae); the CHANGELOG diff against main is exactly this PR's one entry. Codex/review(autoreview, branch mode againstorigin/main) runs on this head before merge.