Skip to content

fix(scheduler): scale per-cycle candidate volume - #958

Merged
steipete merged 1 commit into
mainfrom
fix/per-cycle-candidate-volume
Jul 30, 2026
Merged

steipete merged 1 commit into
mainfrom
fix/per-cycle-candidate-volume

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Problem

Coverage burn stalled even though target fanout and its canonical cursor were healthy. Live run 30540950555 showed the openclaw/openclaw planner finding 5,189 due candidates but selecting exactly 50: scheduled queue feed forced batch_size=50 and shard_count=1, so selectDueCandidates could not offer more than 50 in one cycle. Fleet fanout also assigned that same flat batch to every selected repository and treated untracked backlog as a boolean, so cursor fairness spent equal plan jobs on tiny repositories while the 3,084-item dominant gap could not absorb idle capacity.

The 120-active per-target Worker limit and the legacy 44/89 broad-review shard limits are not the limiter here. Scheduled review uses one planner shard and turns selected candidates into independent exact-review leases.

Fix

  • Read review-lane active, pending, and capacity from the public queue probe and expose capacity - active - pending as candidate capacity.
  • Size direct scheduled plans to that live free capacity, clamped by any fanout allocation and the existing 128 hard cap. The Worker remains the final 600/hour rate and backpressure owner.
  • Keep the largest untracked repository in each normal fanout cycle, reserve the rotating cursor slice for smaller repositories, dispatch that fairness slice first, and divide remaining candidate capacity by untracked backlog.
  • Skip zero-open repositories before hot fanout as well as normal fanout.
  • Emit total candidate capacity and per-repository batch allocations in fanout output.

With 128 slots and a 4.1-minute mean service time, service capacity is about 128 * 60 / 4.1 = 1,873/hour; the configured 600/hour feed is the bottleneck and needs only about 41 concurrent workers. A 3,084-item backlog therefore takes about 5.1 hours at the full feed, or 7.9 hours at the current 65% normal-backfill share (390/hour), rather than weeks.

Proof

  • node --test test/queue-pressure.test.ts test/repair/target-fanout.test.ts test/scheduler-policy.test.ts test/sweep-workflow.test.ts — 123 passed.
  • pnpm run check — build, format, static checks, all lint targets, changed coverage, and the full coverage thresholds passed; final command status was red only because five unrelated macOS containment fixtures unconditionally resolve Linux capset (test/repair/process-tree-containment.test.ts).
  • Linux Crabbox fallback was attempted with resolved provider aws; the coordinator returned HTTP 401 before lease creation, including the one permitted debug retry, so no lease ID exists.
  • ~/.claude/skills/autoreview/scripts/autoreview --mode local — clean, one pass, correctness 0.96.
  • ~/.claude/skills/autoreview/scripts/autoreview --mode branch --base origin/main — clean, one pass, correctness 0.98.

No Worker redeploy is required: this changes the workflow planner/fanout code and consumes queue fields the deployed Worker already publishes. Do not merge until the current-head CI and ClawSweeper review gates are ready.

@steipete
steipete requested a review from a team as a code owner July 30, 2026 12:18
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal priority bug or improvement with limited blast radius. merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. labels Jul 30, 2026
@clawsweeper

clawsweeper Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 30, 2026, 8:22 AM ET / 12:22 UTC.

ClawSweeper review

What this changes

This PR reads free review-queue capacity, uses it to size scheduled candidate batches, and distributes fanout candidates by untracked repository backlog while reserving a rotating fairness slice.

Merge readiness

⛔ Blocked until real behavior proof from a real setup is added - 5 items remain

Keep this PR open for normal review. The scheduler change is a focused attempt to make the configured review feed use live idle capacity, but it needs after-fix runtime proof before merge and includes a release-owned changelog edit that should be removed from the branch.

Priority: P2
Reviewed head: 1e9e1f34710e9d3f027581ade15adf93abadfe21

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The patch has focused coverage and a coherent operational rationale, but merge-gating real behavior proof is still absent and the release-owned changelog edit needs removal.
Proof confidence 🦪 silver shellfish (2/6) Needs real behavior proof before merge: The PR body reports unit tests, checks, and local review output, but does not include inspectable after-fix scheduler or queue behavior; attach redacted live output showing capacity-derived batch sizing and allocations before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The PR body reports unit tests, checks, and local review output, but does not include inspectable after-fix scheduler or queue behavior; attach redacted live output showing capacity-derived batch sizing and allocations before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 5 items Queue-capacity implementation: The patch extends queue-pressure parsing with active review count, capacity, and a non-negative available candidate capacity computed as capacity minus active and pending work.
Scheduler and fanout scope: The branch changes the scheduled workflow and target-fanout planner together, adding capacity-driven batch sizing and backlog-aware allocations; the supplied diff reports 10 changed files, 410 additions, and 59 deletions.
Focused regression coverage: The branch adds focused queue-pressure, target-fanout, scheduler-policy, and workflow assertions, including capacity accounting and a 128-candidate large-backlog selection case.
Findings 1 actionable finding [P3] Remove the release-owned changelog entry
Security None None.

How this fits together

The scheduled review system queries the Worker’s public queue status and signed open-item inventory, then creates candidate plans for exact item reviews. The workflow scheduler and target fanout planner decide how much idle capacity each repository receives before the Worker enforces final queue admission and rate limits.

flowchart LR
  Queue[Review queue status] --> Capacity[Free candidate capacity]
  Inventory[Open-item inventory] --> Fanout[Repository fanout planner]
  Cursor[Fairness cursor] --> Fanout
  Capacity --> Fanout
  Fanout --> Plans[Candidate review plans]
  Plans --> Worker[Exact-review queue]
  Worker --> Reviews[Item review workers]
Loading

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The PR body reports unit tests, checks, and local review output, but does not include inspectable after-fix scheduler or queue behavior; attach redacted live output showing capacity-derived batch sizing and allocations before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Remove the release-owned changelog entry (P3) - CHANGELOG.md is release-owned under the repository policy, so this normal scheduler PR should keep release context in its PR body or commit message rather than changing the release file.
  • Resolve merge risk (P1) - Merging changes the scheduled review admission volume and repository allocation policy; without after-fix live output, it remains unproven that the workflow receives the expected capacity fields and fills capacity without disrupting fairness.
  • Resolve merge risk (P1) - The branch modifies release-owned CHANGELOG.md, which can conflict with the release process and should not be landed as part of normal PR work.
  • Complete next step (P2) - The remaining blockers are contributor-owned runtime proof and removal of a release-process edit; no safe automated repair can establish the contributor’s live scheduler evidence.

Findings

  • [P3] Remove the release-owned changelog entry — CHANGELOG.md:12
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Changed surface 10 files; 410 added, 59 removed The scheduler behavior crosses workflow YAML, queue parsing, fanout planning, documentation, and four focused test surfaces.
Focused tests 4 test files; 123 reported passing The PR covers capacity parsing, allocation policy, scheduler selection, and workflow batch construction, but this remains supplemental to runtime proof.

Merge-risk options

Maintainer options:

  1. Prove live allocation before merge (recommended)
    Remove the release-owned changelog entry and add redacted after-fix scheduler or queue output showing live free capacity, selected batch size, and fairness allocations before merging.
  2. Pause for operational validation
    Hold the PR if a live scheduler run cannot be captured, because tests alone do not show the deployed queue contract and workflow planner working together.

Technical review

Best possible solution:

Keep the live-capacity and backlog-aware allocation design if a redacted after-fix scheduled run demonstrates the derived batch size and per-repository allocations, then land it without the release-owned changelog edit.

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

Yes, from source with medium confidence: the supplied PR identifies a concrete scheduled path where a one-shard plan was fixed at 50 candidates despite a larger configured review feed. The reported live run is pre-fix evidence, so an after-fix current-head reproduction has not yet been demonstrated.

Is this the best way to solve the issue?

Yes, provisionally: deriving scheduled plan volume from the Worker-published free review capacity and allocating the remaining fanout by backlog directly addresses the observed fixed-50 bottleneck while retaining a cursor fairness slice. The solution still needs live contract proof before it is the safest merge choice.

Full review comments:

  • [P3] Remove the release-owned changelog entry — CHANGELOG.md:12
    CHANGELOG.md is release-owned under the repository policy, so this normal scheduler PR should keep release context in its PR body or commit message rather than changing the release file.
    Confidence: 0.98

Overall correctness: patch is correct
Overall confidence: 0.68

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: This is a bounded operational scheduler improvement with meaningful review-throughput impact but no demonstrated immediate user-facing outage.
  • add merge-risk: 🚨 automation: The branch changes scheduled workflow planning and queue-fed dispatch volume, so a deployment mismatch could alter review automation throughput or fairness.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body reports unit tests, checks, and local review output, but does not include inspectable after-fix scheduler or queue behavior; attach redacted live output showing capacity-derived batch sizing and allocations before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Label justifications:

  • P2: This is a bounded operational scheduler improvement with meaningful review-throughput impact but no demonstrated immediate user-facing outage.
  • merge-risk: 🚨 automation: The branch changes scheduled workflow planning and queue-fed dispatch volume, so a deployment mismatch could alter review automation throughput or fairness.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body reports unit tests, checks, and local review output, but does not include inspectable after-fix scheduler or queue behavior; attach redacted live output showing capacity-derived batch sizing and allocations before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

  • Queue-capacity implementation: The patch extends queue-pressure parsing with active review count, capacity, and a non-negative available candidate capacity computed as capacity minus active and pending work. (src/queue-pressure.ts:53, 1e9e1f34710e)
  • Scheduler and fanout scope: The branch changes the scheduled workflow and target-fanout planner together, adding capacity-driven batch sizing and backlog-aware allocations; the supplied diff reports 10 changed files, 410 additions, and 59 deletions. (src/repair/target-fanout.ts:165, 1e9e1f34710e)
  • Focused regression coverage: The branch adds focused queue-pressure, target-fanout, scheduler-policy, and workflow assertions, including capacity accounting and a 128-candidate large-backlog selection case. (test/repair/target-fanout.test.ts:101, 1e9e1f34710e)
  • Release-note policy conflict: The repository policy states that CHANGELOG.md is release-owned and normal PRs should not edit it, while this branch adds a scheduler release-note entry. (CHANGELOG.md:12, 1e9e1f34710e)
  • Proof supplied in PR body: The PR body reports focused tests and static checks, but its only cited live run establishes the pre-fix 50-candidate problem; the attempted Crabbox validation did not obtain a lease and no after-fix scheduler or queue output is attached. (1e9e1f34710e)

Likely related people:

  • steipete: The PR body provides the concrete queue-capacity model, observed production symptom, and intended fanout behavior; no independent current-main ownership trail was available in the supplied review material. (role: scheduler change sponsor; confidence: low; commits: 1e9e1f34710e; files: .github/workflows/sweep.yml, src/queue-pressure.ts, src/repair/target-fanout.ts)

Rank-up moves

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

  • Remove the CHANGELOG.md edit.
  • Add redacted after-fix scheduler or queue output showing free capacity, requested batch size, and per-repository allocations.
  • After updating the PR body with proof, obtain a fresh ClawSweeper review; a maintainer can request @clawsweeper re-review if it does not trigger automatically.

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.

@steipete
steipete merged commit c5c8ddf into main Jul 30, 2026
19 checks passed
@steipete
steipete deleted the fix/per-cycle-candidate-volume branch July 30, 2026 12:26
azaj01 pushed a commit to azaj01/clawsweeper that referenced this pull request Sep 21, 2026
Co-authored-by: clawsweeper <274271284+clawsweeper[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. P2 Normal priority bug or improvement with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant