Skip to content

refactor(queue): extract decision policy and read model - #1124

Merged
steipete merged 6 commits into
mainfrom
steipete/queue-policy-readmodel-extraction
Aug 11, 2026
Merged

steipete merged 6 commits into
mainfrom
steipete/queue-policy-readmodel-extraction

Conversation

@steipete

@steipete steipete commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • extract exact-review decision, source-authority, supersession, publication-lineage, and command-status policy into dashboard/exact-review-decision.ts
  • extract exact-review queue statistics, admission/read model, wake calculation, and bounded Bay projection into dashboard/exact-review-read-model.ts
  • keep the Durable Object, /stats handler, mutation, lease, dead-letter, and alarm machinery in dashboard/exact-review-queue.ts
  • preserve the existing exact-review-queue.ts public surface through re-exports and a capacity compatibility wrapper

pr-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 ExactReviewQueue Durable Object for the merge base and candidate head.

Scenario: seed six synthetic pending reviews through the signed /internal/exact-review/enqueue route, then fetch /api/exact-review-queue and /api/status from 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-256 502ef4b842487f726531cb97d78168e715f65ce2844ea679408f1de505d1016d
  • /api/status: 24,197 bytes, SHA-256 4a782cd47c24c917e97576ba871b61bad2d3c055eb6844eee3f39a9e61d2e997

Artifacts: committed body-identity evidence and proof harness under docs/proof/queue-policy-readmodel-extraction/; local runtime artifacts are generated under its ignored artifacts/ 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 coverage
  • focused test/dashboard-worker.test.ts: 337 passed
  • no test files changed; compatibility is carried by queue-module re-exports
  • clean committed-branch review against origin/main: no accepted/actionable findings

OpenClaw 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 check and committed Worker proof passed from a clean --fresh-pr openclaw/clawsweeper#1124 --no-hydrate checkout of source head 50a3749343b28b045e02722010aa91893c63a9f1. The Docker-backed Crabbox run used CLI 0.38.3-5-g2a79805d, provider=local-container, image node:24-bookworm, Docker 29.4.0 via OrbStack, and lease cbx_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, and leaseStopped:true. The verbatim container proof result is PROOF_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.

@clawsweeper

clawsweeper Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@clawsweeper clawsweeper Bot added merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 11, 2026
@clawsweeper

clawsweeper Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 11, 2026, 2:48 PM ET / 18:48 UTC.

ClawSweeper review

What this changes

The 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 readiness

⚠️ Ready for maintainer review - 1 item remains

Keep 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
Reviewed head: 9fc9b349dcd203efb634eb8c223959addfa56a68

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A well-scoped refactor with strong real behavior evidence and no actionable review finding.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (linked_artifact): A committed Crabbox local-container receipt and real local Worker run show byte-identical normalized queue and status responses after the extraction.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): A committed Crabbox local-container receipt and real local Worker run show byte-identical normalized queue and status responses after the extraction.
Evidence reviewed 4 items Preserved queue boundary: The queue service imports extracted decision and read-model helpers, while re-exporting the established helper surface used by the Worker and tests.
Type-only queue dependency: The read model consumes queue state only through a type import, avoiding a new runtime import cycle with the queue service.
Real behavior proof: The committed proof runs merge-base and candidate local Wrangler Workers with independent SQLite-backed Durable Object state, seeds six signed requests, and compares normalized queue and status responses.
Findings None None.
Security None None.

How this fits together

The 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]
Loading

Before merge

  • Resolve merge risk (P1) - The proof intentionally does not exercise GitHub reads or writes, lease acquisition, or publication; byte-identical extracted bodies reduce this remaining automation-integration risk.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Runtime extraction 3 dashboard modules added; queue module +105/-1,636 lines; test files +0 The refactor is large but deliberately concentrates moved policy and read-model code outside the Durable Object mutation surface.

Merge-risk options

Maintainer options:

  1. Land with the documented proof boundary (recommended)
    Accept the bounded integration coverage because extracted function bodies and exercised queue/status responses are equivalent, while GitHub and lease paths remain intentionally out of scope.

Technical review

Best 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.

Labels

Label justifications:

  • P3: This is internal automation refactoring with no intended product behavior change.
  • merge-risk: 🚨 automation: The moved code governs exact-review admission, scheduling, and queue/status projections.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (linked_artifact): A committed Crabbox local-container receipt and real local Worker run show byte-identical normalized queue and status responses after the extraction.
  • proof: sufficient: Contributor real behavior proof is sufficient. A committed Crabbox local-container receipt and real local Worker run show byte-identical normalized queue and status responses after the extraction.

Evidence

What I checked:

Likely related people:

  • steipete: Recent main commits cover queue performance, refactoring, recovery, and observability on the central service. (role: recent area contributor; confidence: high; commits: 5439582beebe, 583947dc092c, 765644804756; files: dashboard/exact-review-queue.ts)
  • Martin Cleary: Recent main history shows direct work on branchless review durability, parked reconciliation, and publication behavior. (role: recent area contributor; confidence: high; commits: 91272a65e6ff, 3a38d3622a9b, cd4892391195; files: dashboard/exact-review-queue.ts)

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.

History

Review history (3 earlier review cycles)
  • reviewed 2026-08-11T18:09:49.194Z sha af37f11 :: needs real behavior proof before merge. :: [P2] Run the queue proof in the required Crabbox container
  • reviewed 2026-08-11T18:27:40.032Z sha 50a3749 :: needs real behavior proof before merge. :: [P2] Run the queue proof in the required Crabbox container
  • reviewed 2026-08-11T18:33:26.297Z sha 50a3749 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 11, 2026
@steipete
steipete merged commit d8471a6 into main Aug 11, 2026
13 checks passed
@steipete
steipete deleted the steipete/queue-policy-readmodel-extraction branch August 11, 2026 18:50
steipete added a commit that referenced this pull request Aug 12, 2026
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.
steipete added a commit that referenced this pull request Aug 12, 2026
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.
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. P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant