Skip to content

improve: build queue status from one census - #1130

Merged
steipete merged 1 commit into
mainfrom
steipete/read-model-single-census
Aug 12, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/read-model-single-census

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

The frequently polled exact-review queue status path repeatedly scanned and materialized the full durable queue to produce counts, lane health, admission, wake timing, and the public Bay projection. /stats also built the Bay projection twice.

Why This Change Was Made

One queue traversal now builds an internal census containing lane/state counts, oldest records, active targets, ready work, wake inputs, and Bay candidates. Existing public read-model functions consume that census without changing their signatures, and the Durable Object reuses the stats census for its priority/batch-aware Bay projection.

User Impact

There is no user-visible behavior change. Operators receive byte-identical queue and status responses with substantially less queue-size-dependent read work.

OpenClaw Bay Impact

OpenClaw Bay is unaffected. The real-Worker proof shows its queue projection remains byte-identical, and the observer-only Bay boundary gains no queue, workflow, GitHub, recovery, deploy, or rollback action.

Documentation Lifecycle

The new proof package is historical verification evidence bound to commit e94f3ca1eccfd88f497ea1934e7378ea20957c8f; it is not an active runbook. No documentation lifecycle or ownership contract changes.

Evidence

  • pnpm run check: 3,337 tests passed, 9 skipped, 0 failed; static checks, all builds, lint, formatting, and coverage thresholds passed.
  • Fixed-seed property equivalence: 72 randomized queue states matched the test-only pre-refactor implementation for stats JSON bytes, lane stats, Bay projection, admission, active counts, and next wake.
  • Measured 1,200-item /stats + customized Bay path: 12 → 1 full queue traversals, 7 → 1 Object.values materializations, and 21.250 → 1.667 equivalent queue passes.
  • Pre-commit and committed-branch Codex autoreviews both returned clean with no accepted/actionable findings.

Real Behavior Proof

Claim: Merge-base and candidate Workers return byte-identical normalized /api/exact-review-queue and /api/status responses while the candidate performs a single full census traversal.

Exercised surface: Real wrangler dev --local Worker and SQLite-backed ExactReviewQueue Durable Object at merge-base 9c7445bdca92d05b5a38317b498d7f41fc19bc2b and candidate e94f3ca1eccfd88f497ea1934e7378ea20957c8f.

Scenario and fixture: Fixed seed 1592639710; independent 0, 24, and 96-item queue populations submitted through the signed enqueue route; public responses normalized only for volatile timestamps, request/lease identifiers, and nondeterministic diagnostic error ordering. Traversal instrumentation ran only in the proof over a separate 1,200-item state.

Command and environment: Crabbox provider aws, lease cbx_4650d7912abb (amber-prawn-e3e1), run run_8fc3339ec3bc; node:24-bookworm Docker container; proof command docs/proof/single-census-read-model/run-proof.sh from an independent clone of the pushed branch.

Observable result: PROOF_RECEIPT=COMMITTED, PROOF_HEAD=e94f3ca1eccfd88f497ea1934e7378ea20957c8f, all six route/population comparisons byte-identical, PROOF_RC=0, Crabbox runStatus=succeeded, exit 0.

Artifact or trace: Crabbox artifact run_8fc3339ec3bc-artifacts.tgz contains proof-summary.json; the reproducible harness and contract are in docs/proof/single-census-read-model/.

Limits: Synthetic pending reviews and a deterministic loopback GitHub error stub only. The proof does not contact GitHub, acquire review leases, publish records, or mutate production. Randomized active, parked, publication, capacity, circuit, and wake combinations are covered by the property test.

@clawsweeper

clawsweeper Bot commented Aug 12, 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 P2 Normal priority bug or improvement with limited blast radius. 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. labels Aug 12, 2026
@clawsweeper

clawsweeper Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 12, 2026, 12:14 AM ET / 04:14 UTC.

ClawSweeper review

What this changes

The PR replaces repeated exact-review queue scans with one shared census that feeds status, admission, wake timing, and the observer-only Bay projection.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

Keep open: this is a coherent, current performance refactor not yet on main, with no actionable patch defect found and strong committed-head Worker proof.

Priority: P2
Reviewed head: e94f3ca1eccfd88f497ea1934e7378ea20957c8f

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Strong real-runtime proof and broad equivalence coverage support a sound but substantial shared read-model refactor.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (linked_artifact): The PR body identifies a committed-head Crabbox run of real local Workers using signed ingress and reports byte-identical public responses with a linked proof artifact.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): The PR body identifies a committed-head Crabbox run of real local Workers using signed ingress and reports byte-identical public responses with a linked proof artifact.
Evidence reviewed 6 items Current main does not contain this refactor: The current-main read model still materializes queue items and performs separate filtering/scans for handoff, target, wake, lane, admission, and Bay data; the candidate commit is not an ancestor of current main.
Shared census is used by the real queue route: The candidate builds one census for stats and the Durable Object derives its priority-aware Bay projection from that same stats object.
Behavior-preservation coverage: The added fixed-seed property test compares stats bytes, Bay output, lane stats, admission, wake timing, active counts, and publication priority behavior against the extracted pre-refactor implementation.
Findings None None.
Security None None.

How this fits together

The Exact Review Durable Object reads durable queue records to build operator status and scheduling information. Those read models feed public queue/status responses and the observer-only OpenClaw Bay projection.

flowchart LR
  A[Durable queue records] --> B[Shared queue census]
  B --> C[Status read model]
  B --> D[Admission and wake logic]
  B --> E[Bay projection]
  C --> F[Queue and status responses]
  D --> F
  E --> G[Observer-only Bay]
Loading

Before merge

  • Complete next step (P2) - No discrete repair was found; retain this PR for ordinary maintainer approval once current status checks are ready.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Code and coverage delta production +506, tests +904, proof/docs +480 Most added lines are equivalence coverage and reproducible Worker proof for a shared queue read-model rewrite.

Technical review

Best possible solution:

Land the focused census refactor after normal PR status review while preserving byte-compatible queue and Bay responses.

Do we have a high-confidence way to reproduce the issue?

Not applicable: this is a performance refactor rather than a bug report; the PR supplies a committed-head local Worker comparison for the changed runtime path.

Is this the best way to solve the issue?

Yes. Reusing one census while retaining existing public read-model behavior is narrower and more maintainable than adding a parallel queue-status path.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 9c7445bdca92.

Labels

Label changes:

  • add P2: This is a bounded operator-facing queue efficiency improvement with no demonstrated user-facing regression.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body identifies a committed-head Crabbox run of real local Workers using signed ingress and reports byte-identical public responses with a linked proof artifact.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (linked_artifact): The PR body identifies a committed-head Crabbox run of real local Workers using signed ingress and reports byte-identical public responses with a linked proof artifact.

Label justifications:

  • P2: This is a bounded operator-facing queue efficiency improvement with no demonstrated user-facing regression.
  • 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): The PR body identifies a committed-head Crabbox run of real local Workers using signed ingress and reports byte-identical public responses with a linked proof artifact.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body identifies a committed-head Crabbox run of real local Workers using signed ingress and reports byte-identical public responses with a linked proof artifact.

Evidence

What I checked:

  • Current main does not contain this refactor: The current-main read model still materializes queue items and performs separate filtering/scans for handoff, target, wake, lane, admission, and Bay data; the candidate commit is not an ancestor of current main. (dashboard/exact-review-read-model.ts:465, 9c7445bdca92)
  • Shared census is used by the real queue route: The candidate builds one census for stats and the Durable Object derives its priority-aware Bay projection from that same stats object. (dashboard/exact-review-read-model.ts:941, e94f3ca1eccf)
  • Behavior-preservation coverage: The added fixed-seed property test compares stats bytes, Bay output, lane stats, admission, wake timing, active counts, and publication priority behavior against the extracted pre-refactor implementation. (test/exact-review-read-model-equivalence.test.ts:32, e94f3ca1eccf)
  • Committed-head real behavior proof: The proof contract runs merge-base and candidate local Wrangler Workers with independent SQLite-backed Durable Object state, signed ingress, and normalized response comparisons for both public routes. (docs/proof/single-census-read-model/README.md:11, e94f3ca1eccf)
  • Feature history: Blame traces the existing stats API to the prior queue read-model extraction and the census changes to this candidate commit, both authored by the same recent area contributor. (dashboard/exact-review-read-model.ts:941, d8471a64e56b)
  • Unreleased branch state: No branch or tag in the checkout contains the candidate commit; it is neither current-main behavior nor part of the listed release. (e94f3ca1eccf)

Likely related people:

  • steipete: Current-source blame attributes the prior stats API to d8471a6 and the census refactor to e94f3ca. (role: original read-model author and recent area contributor; confidence: high; commits: d8471a64e56b, e94f3ca1eccf; files: dashboard/exact-review-read-model.ts, 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.

@steipete
steipete merged commit 6bf7f48 into main Aug 12, 2026
18 checks passed
@steipete
steipete deleted the steipete/read-model-single-census branch August 12, 2026 04:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal priority bug or improvement with limited blast radius. 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