Repository navigation
perf(queue): hold organic churn longer on actively re-reviewed items - #1708
Conversation
An item that already completed EXACT_REVIEW_ACTIVE_ITEM_REVIEW_THRESHOLD (2) successful review generations within EXACT_REVIEW_ACTIVE_ITEM_WINDOW_MS (1 h) now waits EXACT_REVIEW_ACTIVE_ITEM_DEBOUNCE_MS (10 min) from its latest organic source revision before dispatch, capped at EXACT_REVIEW_ACTIVE_ITEM_DEBOUNCE_MAX_MS (15 min) from the first pending enqueue. Repeated pushes coalesce into one pending entry and are reviewed once with the latest revision instead of starting (and revoking) a full review per push. Only review-triggering GitHub item actions count as organic. Commands, publication, scheduled intake, repair follow-ups, recovery work, first reviews, items below the threshold and immediate PR openings keep their existing timing. A superseding event still revokes an in-flight lease immediately; only the next dispatch waits. The active delay never shortens the ordinary debounce. Completion history lives in an additive exact_review_queue_review_completions table keyed by item and workflow run, written best-effort after /complete, direct-publication conversion and workflow_run reconciliation, and pruned to the window. A store without history behaves exactly as before. Next-wake reads the delayed nextAttemptAt, so held items do not poll.
|
🦞👀 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 October 4, 2026, 8:44 PM ET / October 5, 2026, 00:44 UTC (Revision 8). ClawSweeper reviewWhat this changesThe review queue delays repeated automatic updates longer on frequently reviewed items, using recent completion history while preserving explicit-command and recovery timing. Merge readiness✅ Ready for maintainer review This remains useful work distinct from the merged queue fixes. The pinned patch has no actionable correctness finding, and the recorded production-delay approval covers its current behavior. Priority: P2 Review scores
Verification
How this fits togetherClawSweeper's review queue receives GitHub events and review commands, coalesces updates, and dispatches review workflows. This change adjusts dispatch timing using successful review completions stored in the queue's SQLite database. flowchart TD
A[GitHub updates and commands] --> B[Review queue]
C[Recent review completions] --> D[Active item check]
B --> D
D --> E[Ordinary or extended delay]
E --> F[Scheduled queue wake]
F --> G[Review workflow dispatch]
G --> C
Before mergeNone. Agent review detailsSecurityNone. Review metrics
Technical reviewBest possible solution: Keep one bounded pending review for active organic churn, with immediate operator commands and unchanged recovery behavior. Do we have a high-confidence way to reproduce the issue? Not applicable as an existing-behavior bug: this adds an approved queue policy; the recorded workerd comparison demonstrates the targeted churn scenario. Is this the best way to solve the issue? Yes. Extending the existing debounce at organic ingress keeps one scheduling mechanism and preserves command, publication, and recovery behavior. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against c46e375c8252. 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)
|
…erf/active-item-review-debounce # Conflicts: # CHANGELOG.md
…erf/active-item-review-debounce # Conflicts: # CHANGELOG.md
…erf/active-item-review-debounce # Conflicts: # CHANGELOG.md
# Conflicts: # CHANGELOG.md
Summary
Items that already completed two exact reviews in the last hour now coalesce their next organic push/edit for 10 minutes (capped at 15 minutes from the first pending enqueue) instead of 90 s–3 min. A churning PR gets one review of its latest revision instead of one full, often revoked, review per push. Commands, publication, scheduled intake, repair follow-ups and recovery keep their timing.
Root cause
Production (2026-09-28): in 1.5 h, 305 full exact reviews covered only 200 unique items, and 65 items were reviewed 2+ times. Part of that is legitimate churn: PRs pushed repeatedly (e.g. openclaw/openclaw#159945, openclaw/openclaw#159516 and openclaw/openclaw#159895 each had 3 heads in 1.5 h).
The queue debounce is 90 s, extended to at most 3 min. After that, every new source revision dispatches a full ~7 min review, and a later push revokes the in-flight one (
superseded_totalis 50,054 of 323,303 enqueued). Every started review also debits the scheduled review budget (at Codex generation start since #1738), so churn starves backlog coverage.Change
exactReviewQueueDebouncedAttemptgains anactiveItemmode:max(ordinary, min(now + ACTIVE_DEBOUNCE, firstPendingEnqueue + ACTIVE_DEBOUNCE_MAX)). It never shortens the ordinary debounce.EXACT_REVIEW_ACTIVE_ITEM_REVIEW_THRESHOLD(2) successful review generations withinEXACT_REVIEW_ACTIVE_ITEM_WINDOW_MS(1 h).opened,reopened,edited,synchronize,ready_for_review,converted_to_draft,unlocked,unlabeled) without command context or publication are eligible. They are checked only on the two ingress paths: a new item, and a merge into a pending or just-revoked item.branch_repaired(ordinary timing); the immediate first PRopened/ready_for_review.nextAttemptAtmoves.exact_review_queue_review_completions:(item_key, run_id, run_attempt);/complete, direct-publication receipt conversion and/reconcile;nextAttemptAt: one wake at the due time, no polling. The 15-min maximum hold stays below the 30-min soft queue-pressure age.dashboard/wrangler.tomlsetsEXACT_REVIEW_ACTIVE_ITEM_REVIEW_THRESHOLD=2,EXACT_REVIEW_ACTIVE_ITEM_WINDOW_MS=3600000,EXACT_REVIEW_ACTIVE_ITEM_DEBOUNCE_MS=600000andEXACT_REVIEW_ACTIVE_ITEM_DEBOUNCE_MAX_MS=900000.docs/limits.mddocuments the rule and overrides, andchangelog.d/1708-active-item-review-debounce.mdadds the changelog entry.Behavior proof
ExactReviewQueueDurable Object in workerd (Miniflare, SQLite DO). Real enqueue, alarm dispatch, claim, complete and stats; loopback GitHub fixture with a synthetic RSA credential; production env values.node scripts/proof-active-item-debounce.mjs c46e375c825223a7b3fbcf592794dc949065f0f8 <tools> <fresh-output-dir>c46e375c82is current main, including fix(queue): charge the review budget at Codex generation start #1738. Heade78f8bf0ecis the integrated branch with a clean tree. The pushed heada3cdbb6d5bchanges only the proof README.result.json(sha256aace6983d4776d23cb10ae21e4e44e89e7a6f7b7453ed6de2de05f57dbffe6c2) records every enqueue, wake, dispatch and completion. The table matches the earlier run against8d659e7cb9(artifact sha256b0ec8866…a9f8b).Limits: synthetic GitHub, credential, clock and queue data. The review is modeled as a 7-minute claim-to-complete lease; no workflow, inference, production state or GitHub mutation. Unit tests cover the recovery bypass, window expiry and the stale-heartbeat 409.
Maintainer decision
Peter, 2026-10-04: the active-item debounce is approved for production. After two successful reviews within an hour, the next organic event waits 10 minutes, capped at 15 minutes from the first pending enqueue, while explicit commands stay immediate.
Integration with current main
CHANGELOG.mdconflicted. Its entry now lives in achangelog.dfragment, following the repository's fragment policy.nextAttemptAtfor eligible organic events. It does not touch:source_drift_requeueloop breaker, since that action is not in the organic set;Validation
test/dashboard-worker-queue-policy.test.ts: active delay and 15-min cap with alarm timing; command/recovery/stale-window bypass; immediate revocation with a delayed successor; additive migration. Three fail on main and all pass here.test/exact-review-source-drift-loop.test.ts. They complete several reviews of one item, send an organiceditedevent, and expect an immediate dispatch. The active-item hold correctly delayed that dispatch by 10 minutes.test/dashboard-worker-harness.ts) already zeroes the ordinary dispatch debounce. It now also setsEXACT_REVIEW_ACTIVE_ITEM_WINDOW_MS: "0", so the hold is off unless a test opts in.e71e8d5555,pnpm run build:all,check:staticandlintpass. Everytest/exact-review-*,test/dashboard-*and workflow suite passes: 1,322 tests, 0 failures, 5 skipped.pnpm run checkgate covered static checks, limits, docs, dashboard strict, queue boundary, format, build, lint and changed-coverage; all passed. CI reruns it on this head. The full suite has 7009 passing and 1 pre-existing environmental failure (test/apply-drift-refresh.test.tsneeds bash ≥ 4mapfile; it fails identically on main on macOS bash 3.2 and passes with bash 5). Coverage is 87.67 / 78.34 / 90.99.OpenClaw Bay
Not affected. No public field, backoff reason, projection or control is added; held items keep the existing
dispatch_debouncebackoff reason and existing pending counts. The history table is internal to the queue DO.Risks / rollback
@clawsweeper re-reviewstill bypasses the wait. Automerge follow-ups with a command status marker stay immediate.EXACT_REVIEW_ACTIVE_ITEM_WINDOW_MS=0disables the rule. The other three vars tune the threshold and delays.Review
Codex
/review(autoreview, branch mode againstorigin/mainatc46e375c82, P0–P1 threshold): clean on heade71e8d5555(with the harness fix) and before that ona3cdbb6d5b, with no accepted or actionable findings. It was clean earlier against8d659e7cb9.