Repository navigation
refactor(queue): extract decision policy and read model - #1124
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 11, 2026, 2:48 PM ET / 18:48 UTC. ClawSweeper reviewWhat this changesThe PR extracts exact-review decision policy and read-only queue/status projections into dashboard modules while retaining the queue service’s public exports and mutation/lease ownership. Merge readinessKeep this PR open for normal maintainer landing. The current review found no actionable correctness or security defect; the real-Worker proof is sufficient for the stated behavior-preservation claim, within its documented coverage limits. Priority: P3 Review scores
Verification
How this fits togetherThe exact-review queue accepts review work, persists and schedules it in a Durable Object, then exposes queue and status projections to operators and OpenClaw Bay. This change separates decision and read-model logic from mutation, leases, publication, and alarms. flowchart LR
A[Review events] --> B[Exact-review queue]
B --> C[Decision policy]
B --> D[Queue mutation and leases]
B --> E[Read model]
E --> F[Queue API]
E --> G[Status API]
D --> H[Review publication]
Before merge
Agent review detailsSecurityNone. Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land the ownership-only extraction with the queue service remaining the mutation boundary and retain the committed Worker equivalence proof as its regression guard. Do we have a high-confidence way to reproduce the issue? Not applicable: this is a behavior-preserving refactor. Its relevant validation is the committed local Worker equivalence scenario rather than a bug reproduction. Is this the best way to solve the issue? Yes. Extracting pure decision and read-model responsibilities while retaining queue exports and mutation ownership is the narrowest maintainable refactor path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 5439582beebe. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles)
|
The queue status read model walked the full item set repeatedly per request: twelve full traversals, seven Object.values materializations, and post-hoc sorts to find oldest entries -- O(queue-size) work multiplied per pass, on a path the dashboard polls continuously. Deferred as high-risk while the code lived inside the 15k-line Durable Object module; PR #1124's extraction to exact-review-read-model.ts made it a self-contained pure-module change. One traversal now builds a census (per-lane/state counts, oldest entries tracked during the walk, active targets, ready items, wake and Bay candidates); the public functions consume it and return byte-identical outputs with unchanged signatures. Measured: 12 -> 1 full traversals, 7 -> 1 materializations, 21.25 -> 1.67 equivalent passes. Proof: property-style equivalence against the pre-change implementation across seeded randomized queue states, plus six normalized real-Worker response comparisons (queue and status endpoints, merge-base vs head) all byte-identical, verified in a Docker-backed Crabbox container on the exact head with committed receipt.
Ports the durable command-intake pipeline for the "@clawsweeper re-review" command from the abandoned Aug-8 WIP (snapshot 4cad8de on codex/fix-command-review-publication) onto current main. Commands are now durably recorded pre-acknowledgement (intake/watermark/receipt/revision tables, 16-item intake, 15s-15m bounded retries, 30-day receipts), verified against the live comment and head, fenced through verify/enqueue/effects stages, and superseded by full version identity - including equal-timestamp edits (review-caught P1). Acknowledgement and reaction effects are idempotent; router runs that throttle mid-command now recover instead of stranding the command (live instance: openclaw/openclaw#116562 was acked then lost when both router runs throttled). Superseded snapshot pieces were dropped, not ported: retry jitter (#1076/#1077), quota headroom (#1086), retry budgets (#1089), parked reconciliation (#1111), branch guard (#962); dashboard-monolith diffs were reworked around the #1116/#1124/#1132 splits. Proof: committed receipt at this exact head (docs/proof/durable-command-intake/), real Wrangler Worker + DO comparison with durable throttled recovery, GitHub confined to loopback API; full gate 7056 passed / 0 failed; strict check green. Verdict clean (Findings: None) on 9eb957e.
Summary
dashboard/exact-review-decision.tsdashboard/exact-review-read-model.ts/statshandler, mutation, lease, dead-letter, and alarm machinery indashboard/exact-review-queue.tsexact-review-queue.tspublic surface through re-exports and a capacity compatibility wrapperpr-behavior-proof
Claim: this ownership-only extraction does not change exact-review decisions or public queue/status responses.
Exercised surface: the real local Wrangler Worker and SQLite-backed
ExactReviewQueueDurable Object for the merge base and candidate head.Scenario: seed six synthetic pending reviews through the signed
/internal/exact-review/enqueueroute, then fetch/api/exact-review-queueand/api/statusfrom both revisions.Command and environment: Node 24, pnpm 11, Wrangler 4.107.0;
docs/proof/queue-policy-readmodel-extraction/run-proof.sh.Observable result: 64 moved function bodies compare byte-identically. Both normalized JSON responses compare byte-identically:
/api/exact-review-queue: 10,746 bytes, SHA-256502ef4b842487f726531cb97d78168e715f65ce2844ea679408f1de505d1016d/api/status: 24,197 bytes, SHA-2564a782cd47c24c917e97576ba871b61bad2d3c055eb6844eee3f39a9e61d2e997Artifacts: committed body-identity evidence and proof harness under
docs/proof/queue-policy-readmodel-extraction/; local runtime artifacts are generated under its ignoredartifacts/directory.Limits: synthetic pending issue reviews only; no GitHub reads or writes, lease acquisition, record publication, or production mutation.
Validation
pnpm run check: passed, including active-surface, dashboard queue boundary, docs, limits, formatting, all three builds, lint, focused coverage, and full coveragetest/dashboard-worker.test.ts: 337 passedorigin/main: no accepted/actionable findingsOpenClaw Bay
None. Bay constants and projection logic moved byte-identically; the public observer schema and observer-only control boundary are unchanged.
Container proof
The full
pnpm run checkand committed Worker proof passed from a clean--fresh-pr openclaw/clawsweeper#1124 --no-hydratecheckout of source head50a3749343b28b045e02722010aa91893c63a9f1. The Docker-backed Crabbox run used CLI0.38.3-5-g2a79805d,provider=local-container, imagenode:24-bookworm, Docker 29.4.0 via OrbStack, and leasecbx_f28414ea4f87(coral-lobster-07c4). Corepack and checksum-verified jq 1.8.1 were installed under$HOME/.local/bin.Crabbox reported
runStatus:"succeeded",exitCode:0, sync 8,999 ms, command 299,523 ms, total 308,523 ms, andleaseStopped:true. The verbatim container proof result isPROOF_RC=0.The receipt is committed in
9fc9b349dcd203efb634eb8c223959addfa56a68: machine-readable provenance and redacted container stdout. This receipt adds clean-checkout, container, toolchain, timing, and cleanup provenance; it does not broaden the bounded run-proof limits above.