Repository navigation
feat(queue): park source-drift review loops and alert on runaway reviews - #1732
Conversation
The exact-review queue now counts consecutive automatic source_drift_requeue generations per item in an additive SQLite table. After EXACT_REVIEW_SOURCE_DRIFT_REQUEUE_LIMIT (default 3) it parks the item as source_drift_loop instead of spending another full review; organic webhook item actions, explicit commands, manual reviews, operator recover-fresh, and scheduled offers with a newer sourceUpdatedAt reset the counter and admit the item normally. Command-context continuations are never counted or parked. Claimed review runs are recorded per item for a trailing 24 hours, and /stats plus /api/exact-review-queue expose review_runaway_health: degraded with reason review_runaway and up to five verified-public sample keys when an item exceeds EXACT_REVIEW_RUNAWAY_REVIEWS_PER_DAY (default 24). The dashboard health summary raises it amber.
# Conflicts: # dashboard/dashboard-pages.ts # dashboard/worker.ts # docs/limits.md
A scheduled offer newer than a source_drift_loop park now releases the item for exactly one review generation without resetting the consecutive counter. ClawSweeper's own post-review writes (lease-comment cleanup, label syncs) move updated_at and feed hot intake, so a resetting release would let a loop continue at hot-intake cadence. If the released review ends in another source_drift_requeue, the item re-parks immediately. Only organic webhook item actions, non-drift commands, manual review, and operator recover-fresh reset the counter.
|
🦞👀 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 1, 2026, 3:58 AM ET / 07:58 UTC (Revision 2). ClawSweeper reviewWhat this changesThe PR bounds repeated automatic reviews by parking looping items and adds a dashboard alert for excessive review activity. Merge readiness✅ Ready for maintainer review The PR remains useful and has no remaining blocking finding. The earlier expiry defect is fixed, and the persisted upgrade and rollback evidence addresses the previous compatibility concern. Priority: P2 Review scores
Verification
How this fits togetherClawSweeper's exact-review queue receives webhook events, commands, scheduled offers, and automatic requeues, then dispatches review work. Durable loop history now controls repeated admission, while claimed-review history feeds public queue health. flowchart TD
A[Events and commands] --> C[Review queue admission]
B[Automatic drift requeues] --> C
C --> D[Durable loop counter]
D --> E[Dispatch review]
D --> F[Park exhausted loop]
E --> G[Claimed review history]
G --> H[Dashboard health alert]
Before mergeNone. Agent review detailsSecurityNone. Review metrics
Technical reviewBest possible solution: Retain bounded automatic re-review, explicit recovery paths, and the observer-only runaway alert with the demonstrated persisted-state compatibility. Do we have a high-confidence way to reproduce the issue? Not applicable as a remaining bug report; the supplied real-runtime before/after receipt demonstrates the unbounded baseline loop and bounded candidate behavior. Is this the best way to solve the issue? Yes. Durable counters survive completed-item deletion, and the breaker complements the merged drift-source fixes without weakening publication freshness. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 2f777941de92. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
The loop lookup ignored updated_at, so an exhausted counter idle for more than seven days could still park the next drift requeue: admission returned from the parking branch before the pruning write ran, and parking then refreshed the old timestamp. The lookup now treats (and deletes) an expired row as absent before the limit check, parking only refreshes a live row, and a generation write restarts an expired count at one even when the bounded prune missed it.
source_drift_loop has a budget the Worker restarts on operator recovery (dashboard/exact-review-queue.ts, from #1732), so --force-unchanged must still recover it. Add an operator-to-queue test: the real operator CLI against the queue Durable Object harness over HTTP. Co-authored-by: obviyus <[email protected]>
* fix(dlq): force-unchanged recovery skips unchanged policy holds --force-unchanged exists to reset a spent retry budget. It also bypassed the source-change check for policy holds (maintainer_request_required, locked conversation, oversized PR), which have no budget: an unchanged held review only re-parks. In the 2026-11-08 drain, 52 of 100 parked rows were maintainer holds competing for the 5-per-run recovery cap, and the retry-exhausted backlog moved 51 -> 49 over four runs. Apply the override only to retry-budget reasons; holds still need a source change. Co-authored-by: obviyus <[email protected]> * fix(dlq): keep forced recovery for source-drift loop budgets source_drift_loop has a budget the Worker restarts on operator recovery (dashboard/exact-review-queue.ts, from #1732), so --force-unchanged must still recover it. Add an operator-to-queue test: the real operator CLI against the queue Durable Object harness over HTTP. Co-authored-by: obviyus <[email protected]> --------- Co-authored-by: obviyus <[email protected]>
Summary
Bound self-feeding exact-review loops and make any remaining runaway visible.
After three consecutive automatic
source_drift_requeuegenerations, the queue parks the item assource_drift_loopinstead of spending another full review.The next organic webhook event, explicit command, manual review, or operator recovery admits the item normally and restarts the count.
A scheduled offer newer than the park releases one review but keeps the count, so a loop that continues re-parks immediately.
/api/exact-review-queuegainsreview_runaway_health:degradedwith reasonreview_runaway, plus the count and up to five public sample keys, when any item claims more than 24 reviews in 24 hours. The dashboard health summary raises it amber.Root cause
openclaw/openclaw#97616 reached exact-review revision 548, and openclaw/openclaw#123774 reached 284. Each was re-reviewed about every eight minutes through
source_drift_requeuefor days, and nothing alerted.The path feeds itself. A successful review deletes its queue row, the publication finds a remote-newer tuple, and the publisher (or apply refresh) enqueues
source_drift_requeue. With no row present,/enqueueadmits a brand-new item each time, so the queue never sees that the previous generations were also automatic requeues.#1715 removed one drift source, and another lane removes a second. Any future self-inflicted drift would still cost a full Codex review per cycle, unnoticed.
Change
Breaker
exact_review_queue_source_drift_loops, counts consecutive admitted drift generations per item. It lives outside item JSON because items are deleted between generations.EXACT_REVIEW_SOURCE_DRIFT_REQUEUE_LIMIT(3;0disables), the next drift requeue writes a parkedsource_drift_looprow instead. It takes no lease, no review token, and no lifecycle admission.dedupedwithdedupe_scope: source_drift_loop, so producer jq gates still succeed.What resets the counter
recover-fresh.What does not reset it
updated_atand feed hot intake, so a reset there would let a loop continue at hot-intake cadence.source_drift_loop.Unchanged paths
recover-fresh, and the five-minute terminal check.Runaway alert
exact_review_queue_review_generations, records each newly claimed review run (best-effort at/claim). Publication and finalizer-only claims are excluded, and rows are pruned to 24 hours./statsand the strict public projection addreview_runaway_health. Samples are limited toPUBLIC_BAY_REPOS, and an absent or malformed field projects asnullwithout changing collection completeness.Configuration and docs
dashboard/wrangler.tomlsetsEXACT_REVIEW_SOURCE_DRIFT_REQUEUE_LIMIT=3andEXACT_REVIEW_RUNAWAY_REVIEWS_PER_DAY=24.Finding disposition
ClawSweeper review #1732 (comment) (head
626dd230c8):3727687379. The lookup applies the seven-day expiry before the limit check and deletes an expired row. Parking (markSourceDriftLoopParkedSync) only refreshes a live row.recordSourceDriftGenerationSyncrestarts an expired count at one even if the bounded prune missed it./enqueuepath, and the generation write. It fails on626dd230c8.docs/proof/source-drift-loop-breaker/upgrade-and-rollback.{mjs,json}. See "Persisted upgrade and rollback proof" below.2f91363b9d.Behavior proof
docs/proof/source-drift-loop-breaker/run-proof.mjsruns the real dashboard Worker andExactReviewQueueDurable Object in workerd with SQLite, a fake clock, and a loopback GitHub fixture. It compares origin/maincac974b3e1with head2f91363b9d. After every generation it sends sweep.yml's exact source-drift payload.source_drift_loop(requeue_limit_reached)item_parked, no revieweditedafter looprequeue_limit_reached), no further reviewre_reviewcommand on looping itemGET /api/exact-review-queuedegraded,review_runaway,runaway_items: 1, sampleopenclaw/openclaw#200001healthyresult.jsonSHA-256:0ade9bf73112f316d7c8fc35613a1f90cf26dc70a932a57af244958c341599a1;working_tree_dirty: false. All 11 assertions hold.Persisted upgrade and rollback proof
docs/proof/source-drift-loop-breaker/upgrade-and-rollback.mjspersists one SQLite-backedExactReviewQueueDurable Object on disk. It reopens that object with the real dashboard Worker as origin/maincac974b3e1, then the branch2f91363b9d, then origin/main again. Raw rows are read straight from SQLite before each variant's first queue request.scanner_refuseditem;source_drift_requeueitem./parked-reviews/listshows all threesource_drift_looprows, andrecover-freshreturns one to pending./statsandGET /api/exact-review-queuereturn 200 with collectioncomplete.source_drift_loop: 2appears in stats and folds into the publicunknown: 2; noreview_runaway_healthappears.source_drift_requeueleaves a parked loop parked (ignored as low-priority recovery).editedreleases one parked loop to pending, and it is dispatched and completed.re_reviewcommand releases the other to pending and dispatches it.scanner_refusedrow and the dispatched command item remain, so nothing is lost.All 14 assertions hold.
upgrade-and-rollback.jsonSHA-256:a47f5a5f0760c087b348be13a564a192f7d60fd4b945ceee92bdc2a684350d63;working_tree_dirty: false.source_drift_loop.Validation
node --test test/exact-review-source-drift-loop.test.ts: 10/10, including the expired-counter regression and a scheduled release that re-parks without spending three more generations.pnpm run checkon2f91363b9d: 7140 tests, 7102 pass, 37 skipped; coverage, static, build, and lint pass.test/review-git-acquisition.test.ts› "interrupted native unshallow cleans its lock and settles transport before retry" (a git pack-transfer timing race). Run alone, it fails 2/6 on origin/main as well. This PR touches neither that test norsrc/.OpenClaw Bay:
No Bay change.
repairingcove withqueue_disposition: parked.review_runaway_healthis a new optional, observer-only field on the queue projection. Bay does not read it, and it adds no control.Risks / rollback
failed_review_shard_recoveryloops, which the breaker deliberately does not stop.EXACT_REVIEW_SOURCE_DRIFT_REQUEUE_LIMIT=0, or revert. The persisted-state proof above shows origin/main reading every record after the branch ran, and releasing still-parked loop rows through ordinary organic events or commands.Review
Codex
/review(autoreview, branch mode againstorigin/main, P0–P1 threshold): clean on626dd230c8(0.87) and again on heade7d109cc83after the expiry fix, the upgrade/rollback proof and the main merge (0.85).