Repository navigation
Conversation
…te-candidate stranding
…bug proofs for clawsweeper
|
Codex review: needs real behavior proof before merge. Reviewed August 6, 2026, 10:27 AM ET / 14:27 UTC. ClawSweeper reviewWhat this changesThe PR changes weighted scheduler draining so duplicate due candidates do not stop a review batch before remaining distinct candidates are selected. Merge readiness⛔ Blocked until real behavior proof from a real setup is added - 3 items remain Keep this PR open: current main has the duplicate-drain defect and the code repair is sound, but merge should wait for required supported-environment behavior proof. Priority: P2 Review scores
Verification
How this fits togetherReview planning fetches open GitHub items into due candidates, then the scheduler selects a bounded batch across priority buckets. That batch feeds the Codex review workflow and its throughput telemetry. flowchart LR
A[Open GitHub item pages] --> B[Review planning]
B --> C[Due candidates]
C --> D[Weighted scheduler]
D --> E[Deduplicate and drain]
E --> F[Review batch]
F --> G[Codex review workflow]
Before merge
Agent review detailsSecurityNone. Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain the narrow drained-candidate repair and attach a current-head Node 24 Crabbox local-container trace that demonstrates the post-fix planner result with an injected pagination duplicate. Do we have a high-confidence way to reproduce the issue? Yes: current-main source exposes the premature no-progress break when a duplicate is shifted, and the submitted fixture places that duplicate ahead of distinct due candidates. Is this the best way to solve the issue? Yes: measuring drained queue entries preserves existing deduplication and weighted ordering while removing the premature termination condition. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against daf339e6d1d3. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
…he problems of proofing clawsweeper
|
@clawsweeper re-review |
|
🦞👀 Command router queued. I will update this comment with the next step. |
* fix(src/scheduler-policy.ts): fixing the problem of scheduler duplicate-candidate stranding * test(test/scheduler-policy.test.ts): adding some edge case tests for fixed problem * docs(docs/proof/scheduler-duplicate-candidate-stranding): adding the bug proofs for clawsweeper * docs(docs/proof/scheduler-duplicate-candidate-stranding): fixing up the problems of proofing clawsweeper
Closes #1045.
What Problem This Solves
Fixes an issue where a sweep would review fewer items than it had capacity for,
with no error and no telemetry signal, whenever the same item appeared twice in
the due list.
Duplicates are a normal GitHub pagination artifact:
GET /issuesis sorted byupdated, so an item touched between two page reads shifts pages and is returnedon both.
selectDueCandidatesalready dedupes byrepo#number— the dedup wasnever the problem. The problem was that hitting a duplicate ended selection
entirely, stranding every candidate queued behind it while capacity sat free.
Through the real
planCLI with three distinct due PRs and#1listed on fourpages, the pre-fix sweep selected
[1]where the fix selects[1, 2, 3]—dueBacklogreported 6 in both cases.The stranded items stay due, so the effect is delay and wasted capacity rather
than permanent starvation — but it compounds against the weekly-coverage SLO,
which is the outer freshness deadline for canonical records.
Reachability, precisely. A stall needs a whole weighted pass to consume
nothing but duplicates, so the threshold is per bucket. Derived by driving the
real
dueCandidate()logic against a pre-fix build:hot_pull_request,activity,recent_issuedaily_pull_requesthot_issueweekly_issueweekly_issuecannot reach it: "due" and "weekly-coverage-due" share the same6-day threshold there, so such an item is always claimed by the coverage preselect
lane, which takes candidates in a plain loop. The candidate must also be
coverage-tracked and reviewed inside the window between its cadence (1 day) and
the 6-day coverage deadline; untracked items are recovered by the final loop.
I originally wrote that a single duplicate was enough. That was wrong — it came
from a hand-built
weekly_issuecandidate the real planner never emits in adue-but-not-coverage-due state. The defect and the fix are unchanged; the
severity is narrower than I first stated, and this section is the correction.
Why This Change Was Made
take()collapses three outcomes into "nothing happened": capacity reached,bucket empty, and duplicate skipped. The weighted drain's no-progress guard then
read a pass that consumed only duplicates as "all buckets are drained" and broke
out of the loop.
The fix changes what the loop measures — candidates drained instead of
candidates selected — in the final drain loop and in
takeWeighted, which hasthe same shape. Two lines per loop.
Deliberately minimal. It does not:
duelist up front (that would change which entry wins when twocopies carry different
review/bucketfields — a larger behavioral changethan this defect calls for);
A duplicate still consumes one weighted slot in its pass; only the premature
breakis removed. Termination is unchanged in kind: each pass either drains atleast one candidate or breaks, and
dueis finite.User Impact
Sweeps fill their configured batch size when the GitHub listing returns an item
twice, instead of silently truncating. Operators see the review throughput the
capacity settings imply; no configuration change is needed.
No data-contract, workflow, or schema change. No migration.
OpenClaw Bay: not affected. This changes how many candidates a sweep selects,
not any status, lifecycle, or telemetry shape Bay renders.
dueBacklog,capacityReason, andplanSelectionTelemetrykeep their existing meanings — theselected count simply stops being wrong. No Bay update or Bay proof is needed.
Release note:
fix: stop duplicate due candidates from truncating the review batch.No
CHANGELOG.mdedit is included — happy to add one if this repo's release policywants it.
Evidence
Diff
Plus a new proof package under
docs/proof/scheduler-duplicate-candidate-stranding/.Focused tests
node --test test/scheduler-policy.test.ts→ 24/24 pass (20 pre-existing + 4 new).New tests:
duplicate due candidates do not strand the rest of the batch— contract-level,plus assertions that duplicates are still deduped and capacity is still respected.
a run of duplicates larger than the bucket weight still drains— eight entriesin the weight-4
hot_issuebucket, spanning two full passes with no newselection in the second.
duplicates across separate buckets do not stall the weighted drain— duplicatesin two buckets simultaneously.
pagination duplicates do not strand candidates the real planner produces—builds its candidate the way
dueCandidate()does, asserting the derived bucketand due-ness first, so the regression guard is pinned to a shape production
actually emits rather than a hand-built one.
Red/green
Swapped only the compiled
dist/scheduler-policy.jsfor a pre-fix build of thesame file, and re-ran with the new tests present:
All 20 pre-existing assertions were unchanged in both directions.
Real Behavior Proof
Claim.
selectDueCandidatesfills the batch to capacity from the candidates itis given, even when an item appears twice.
Exercised surface. The real
planCLI, end to end — no application functionis substituted:
Only the
ghbinary is replaced, standing in for GitHub's server. ClawSweeper'sown transport — subprocess spawn, argument construction, JSON-lines parsing,
pagination loop — runs unchanged. This addresses the previous review's finding that
the artifact "substitutes fetchOpenItemPage, so it does not exercise a real
transport client".
Scenario / fixture. Three distinct open PRs,
--batch_size 10(far above the duecount, so capacity is never the limiting factor),
--max_pages 5. The stubghreturns
#1on four consecutive pages, reproducing theupdated-sorted paginationrace in which an item touched mid-scan is listed again on later pages:
A prior report exists for each PR in the items dir, making them coverage-tracked —
the state in which the weighted drain, not the coverage preselect lane, owns
selection.
Command and environment. Executed in the supported environment — Node 24 in a
Docker-backed Crabbox
local-containerlease, on the current head:crabbox run \ --provider local-container \ --local-container-image node:24 \ --no-hydrate \ --timing-json \ --artifact-glob '.artifacts/scheduler-duplicate-proof/**' \ --script docs/proof/scheduler-duplicate-candidate-stranding/run-proof.shlocal-container(Docker/OrbStack)0.15.0node:24@sha256:934240a162082fd8b8a2f90cd5114446443f1eba1c5378f6687167ca405e6584v24.19.0(satisfiesengines.node >= 24)cbx_7c89c5c91f66(brave-lobster)run_71734de37d18.crabbox/runs/run_71734de37d18/run_71734de37d18-artifacts.tgz0Observed result. In-container, on the current head:
summary.jsonfrom the artifact tarball:{ "selected": [1,2,3], "expected": [1,2,3], "dueBacklog": 6, "scannedPages": 5, "duplicateFreeSelection": true, "pass": true }Against a pre-fix build of
dist/scheduler-policy.js, the identical fixture andCLI invocation yields
shards[0].itemNumbers = [1]—#2and#3stranded withdueBacklogstill 6.The proof also asserts the selection stays deduplicated, so the fix cannot be
satisfied by simply letting the duplicate through.
Two traps worth recording, both documented in the proof README so the next
person does not silently reintroduce a vacuous proof:
selectCandidates()callsselectDueCandidates()without anowargument, sothe scheduler uses the real
Date.now(). An earlier fixture used a fixed pastreviewedAt; every candidate then qualified as weekly-coverage-due and was takenby the plain
for (const candidate of weeklyCoverageDue) take(candidate)lane,which never reaches the weighted drain — so it passed on a pre-fix build and
proved nothing.
recovered by the final loop and nothing is stranded. The fixture therefore writes
a prior report per item; without that, the proof is also vacuous.
Artifact / trace.
docs/proof/scheduler-duplicate-candidate-stranding/containsrun-proof.sh(the Crabbox entry point),run-proof.mjs(host-only quick check),and the contract README. The lease artifact tarball holds
plan.json,summary.json,focused-tests.txt,install.log, andbuild.log.Limits. Covers batch selection only. The duplicate is injected at the
ghbinary boundary rather than produced by a real pagination race, since that race
is timing dependent and not reproducible on demand — so GitHub's own server
behavior is modeled, not exercised. No live GitHub, Worker, or queue is contacted,
and the proof performs no mutation. The lease is a local Docker container, not a
cloud host, so it proves the Linux/Node 24 runtime but not cross-host isolation.
Privacy. The fixture uses only
openclaw/openclawpublic-shaped item numbersand a synthetic
contributorlogin. No credential is present in the lease; thestub
ghmakes no network call.Repository test suite status
The proof and focused suite now run on Node 24 inside the Crabbox
local-containerlease recorded above (24/24focused tests in-container). Thenotes below concern only the full suite run on the macOS host.
engines.nodeis>=24; the newest Node available on the macOS host is v23.7.0,and
AGENTS.mdwarns about test misbehavior below Node 24.mainTwo runs of the identical branch disagree with each other —
comm -3overrun 1 and run 2 shows three tests flipping. That is direct evidence of flakiness
rather than a regression.
The two tests that appeared only on the fix branch in run 1
(
comment webhook settles duplicate fast ack comments after dispatch,webhook signature verification uses sha256 body hmac) both passed in run 2,and both pass 25/25, three runs in a row, in isolation on both the clean tree
and this branch. A module-graph walk from
dist/repair/comment-webhook.jsconfirmsscheduler-policyis not reachable from that code at all.No scheduler test failed in any run, on either tree.
Green on this branch:
local-containerprooftest/scheduler-policy.test.tspnpm run build:allpnpm run format:checkpnpm run lintPlease confirm
pnpm run checkon Node 24+ in CI before merging. The changedsurface is proven on Node 24, but I have not produced a green full-suite run and
am not claiming one.