Repository navigation
perf: reuse empty plugin state and completed Crabbox readiness - #183223
Conversation
|
🦞👀 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. What this changesThis PR preregisters measurements and acceptance criteria for reducing background plugin-state reads. Example: Measure Reef with 18 messages awaiting review.
Review scores
ProductKind: Docs · Worth it: Yes Merge readiness✅ Ready for maintainer review Keep open as a maintainer-owned draft investigation; the introduced acceptance document is coherent and has no actionable defects. Priority: P3 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherReef reconciliation reads durable plugin state through existing operation owners; the referenced workload runs an isolated Gateway against a synthetic loopback relay and records SQL statements and worker requests. flowchart LR
A[Synthetic messages] --> B[Loopback Reef relay]
B --> C[Isolated Gateway]
C --> D[Reef operation owners]
D --> E[Plugin state workers]
E --> F[SQL and request observations]
Technical reviewBest possible solution: Retain the acceptance document and let the investigation establish any remaining optimization at the existing state owner. Do we have a high-confidence way to reproduce the issue? The document specifies a credible production-path reproduction, but this draft reports no measurement and establishes no remaining runtime defect. Is this the best way to solve the issue? Preregistering owner attribution and measurable acceptance before optimization is appropriate, and the diff adds no unnecessary production machinery or test scaffolding. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against ab961d884a12. SecurityNone. EvidenceWhat I checked:
PR surfaceDocs +29. Total +29 across 1 file. Added test files: 0. View PR surface stats
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 25, 2026, 12:22 AM ET / 04:22 UTC. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
…law#183223) Reuse worker-confirmed empty SQLite plugin-state observations through the existing bounded receipt-invalidated cache, retain Reef read operations, and retain successful Crabbox legacy readiness at its manager. Keep TTL expiry, mutation settlement, first-handler validation, failure retries, generic snapshots and PostgreSQL external-write visibility. No schema or public SDK signature changes. Synthetic Gateway counts: Reef steady 21 to 17 SQL and 13 to 9 requests per minute; Crabbox 15 to 11 SQL and 10 to 6 requests per two minutes. Runtime main-thread SQL remains zero. Focused owner and SDK tests, isolated review rounds and exact-head CI including all three PostgreSQL shards pass. The retired Crabbox legacy writer was removed in openclaw#133447.
What Problem This Solves
Background Reef reconciliation repeatedly probes an empty delivery namespace, and Crabbox maintenance repeatedly counts a retired allocation namespace. Reuse the facts already established by those owners: carry a worker-confirmed empty SQLite namespace through the existing bounded receipt-invalidated cache, retain Reef's lazy read operation, and remember successful legacy readiness in the existing Crabbox manager.
User Impact
Idle background reconciliation does less database work while retaining delivery, expiry, recovery and external-writer behavior. No public SDK signature or stored-data format changes.
Why This Change Was Made
PostgreSQL keeps physical empty probes for external committed-write visibility. Generic compound read snapshots remain because handlers can perform dependent reads. No schema, SQL text, public SDK signature, generation, or cross-store transaction changes.
Acceptance rule (recorded before measurement)
Run
scripts/perf/plugin-state-polling.mtsagainst a real isolated Gateway and loopback Reef relay, using both an empty inbox (--messages 0) and pending-review workload (--messages 18), each with a 60-second steady window after startup. Usescripts/bench-ingress-polling.mts --idle-seconds 60 --sparse-events 0as the iMessage control. Count with the frozen campaign observer and keep boot and steady windows separate. Attribute namespace reads, exact-key reads, count probes, and single-statement transaction envelopes to their owners before editing.A candidate must remove recurring statements and requests in the touched flow, keep runtime main-thread SQL at zero, and preserve TTL expiry, committed writes, recovery, and final effect authority. Reuse the existing write/receipt owner; retain direct reads without a complete invalidation contract. No schema or public SDK signature change is intended.
Run three alternating baseline/candidate count pairs when load is below 64 and internal free space is at least 12 GiB; otherwise use one pair and disclose the limit. Also run a frozen warm-turn control. Timing claims require the campaign timing lock, load below 24, and at least five alternating samples per arm on the same platform. Report median, p95 and range with cold and warm separated. Any adverse 20% cell stops acceptance. Without a qualified host, report counts and per-thread CPU profiles, not latency or CPU speedups.
If current main does not reproduce a target, record the observed per-minute rate and stop that item. Direct store loops do not substitute for the Gateway flow.
Design and protected behavior
The private worker reply identifies an actual empty probe. Only a prepared operation with an explicitly selected SQLite state owner may consume the cached empty namespace; first-use module validation still executes. The existing cache owns bounds, namespace-write invalidation, unknown-settlement invalidation, and TTL filtering. Every returned shortcut value is detached. The shortcut target joins the existing earlier-mutation settlement scope even when omitted from watchStores. Admission, quarantine, read-allowed, lifecycle and session-current checks remain.
Crabbox's manager shares one successful readiness fact across maintenance and allocation. Failure remains retryable and a new manager rechecks. The legacy online writer was removed in #133447; documented migration/recovery requires stopped owners and prohibits mixed old/new writers. Concurrent initial callers may perform duplicate checks; no in-flight join is added.
The simplification pass retained these existing owners rather than adding machinery. Production is +69/-22 (net +47 lines); the growth carries the confirmed fact and preserves handler preparation/ordering. Tests are +134/-31. The new committed Crabbox workload supplies real Gateway attribution without provisioning machines.
Attribution and baseline
Synthetic isolated Gateways and loopback transports only. Baseline production source
9fe8d3e95e0d; acceptance preregistered atc0bdbd4dc242before measurement. Frozen v3.1.4 observer verified 36/36 hashes.Each baseline and candidate Reef arm performed two steady polls, with zero acknowledgments or unexpected relay requests. The target empty-delivery namespace SELECTs fall from four to zero per minute in both workloads; exact-key reads and transaction envelopes remain unchanged. Crabbox legacy count probes fall from four to zero per 120 seconds (two/minute). Per minute: four empty-delivery namespace SELECTs (target), four peer exact-key SELECTs and four BEGIN/COMMIT pairs (retained), four pairing-allowlist SELECTs (separate owner), and one placement SELECT. Crabbox reproduced four legacy count probes in 120 seconds = two/minute, matching the normalized live count family. One expected version check, no provisioning/provider operations, clean shutdown. iMessage issues two ordinary namespace reads rather than compound operations; it is a control.
Causality is recorded as background in this build, so the warm results below are phase counts rather than per-turn causal claims. Host load is above the qualified timing threshold; counts and per-thread profile attribution only, no latency or CPU-speed claim.
One baseline/candidate count pair on the same Mac under the preregistered loaded-host fallback (load roughly 70–100); each targeted median/p95/min/max equals the reported single observation. These are count savings, not latency or CPU-speed claims. Empty Reef removes 19% of steady statements and 31% of requests; Crabbox removes 27% of steady statements and 40% of requests. iMessage is a non-regression control; its lower totals are not attributed to this change.
Cold SQL/requests/MAIN: Reef empty 617/158/57 → 607/152/57; Reef pending 1133/264/57 → 1131/260/58; Crabbox 839/148/73 → 834/145/74; iMessage 813/137/74 → 816/135/74. The extra cold MAIN in pending Reef and Crabbox is the existing dynamic busy-timeout PRAGMA during admission, not a runtime query. All targeted shutdowns remain 22 SQL / 6 requests / 5 MAIN.
Adverse control cell: iMessage idle PASSIVE WAL checkpoints 2 → 3 (+50%); boot PASSIVE 2 → 2 and shutdown TRUNCATE 3 → 3. The checkpoint, admission and adapter bundle hashes match across arms. The coordinator explicitly accepted this unchanged periodic owner firing once more in the window; the raw adverse cell is retained here. Runtime MAIN remains zero throughout.
Final-head frozen warm control passed all 14 turns, cron, compaction, RPCs, restart and clean shutdown. The single baseline/candidate pair produced these counts; warm percentiles describe the ten distinct warm-turn phases, not repeated timing samples.
The adverse cells triggered a hold and were explicitly accepted by the coordinator after attribution. Across the whole run, state-lease SQL is 26→26: two seven-statement batches move from connect/first-turn into warm turns 1/2. Memory SQL is 146→146, with work moving from compaction into idle settling. Plugin-state table statements are 8→8;
pluginState.entriesstays 6 SQL / 6 requests, metadata reads 3/3, and deferred migrations 5/4. The extra two BEGIN/COMMIT pairs belong to one additionalagentDatabaseDeletion.snapshotpoll and one additionalautomationProactive.jobspoll, not plugin-state operations. Whole-run operation deltas: deletion snapshot +5 SQL, proactive jobs +3, index read −2, transcript instances −3, other worker operations +3, and the existing dynamic busy-timeout initializer +1 cold MAIN. Requests are +2 overall. Emitting-stack source audits cover 497 files at boot, 255/281 in warm turns 1/2, 109 during idle settling and 101 at restart-connect; every tracked source blob is identical between baseline and head, with no missing referenced chunks. No general warm-workload saving or latency improvement is claimed.The first final-warm attempt failed before Gateway launch: account-fixture setup rejected runtime artifacts stamped with the earlier test/comment head because service state could not be inspected. The supported final-head build then passed, followed by the valid control above. No product result was inferred from failed setup and no guard was bypassed.
Evidence
The augmented empty-receipt work-count regression fails on base (two requests, expected one). The three Crabbox readiness/retry cases also fail on base. Candidate: all 81 focused core/SDK/Reef/Crabbox tests pass, including TTL/expiry receipts, namespace-write invalidation, pending target-write ordering, first-handler validation, failed readiness/recovery, and manager replacement. Format, basic lint and diff checks pass. Two isolated Codex reviews are scoped-clean P0–P2. One additional delta-only Codex review is clean for the CI correction: remove generic test-command input narrowing and place SAFETY comments directly beside unchanged assertions. The original CI diagnosed those two static failures; no runtime behavior changed. Final-head PG semantic approval is recorded for
1fad2c8ea4c2322db4fd083a09f2e805df17aa64; runtime tokens are unchanged by its CI correction. Exact-head CI run 40163897883 passes, including all three PostgreSQL conformance shards, types, type-aware lint, source contracts/export collisions, architecture/Madge, prompt snapshots, and database/T1/dialect ratchets. The latest requiredopenclaw/ci-gateis successful. The local tsrs attempt stopped before compilation because the campaign-mandated internal virtual-store path is outside its checkout admission; the exact-head CI typechecks provide that proof. Canonical Knip 6.40.0 baseline/candidate comparisons are identical across all three configurations: production 13→13 findings, all exports 21→21, scripts 13→13, with zero additions/removals and empty diagnostic stderr. Raw scan exit 1 represents these same pre-existing findings on both arms, not a new gate failure.The refreshed overlap index has #177691 at
22ea62d40ffb, #159178 at57cd0bcdb90a9, and #135838 at07e99af58674. Base-versus-candidate merge-tree comparisons add zero conflict paths or hunks; existing conflict-path counts remain 1→1, 30→30, and 126→126 respectively.Additional count attribution workload (preregistered before execution)
Run
scripts/perf/crabbox-state-polling.mtswith a fresh synthetic state directory, bundled Crabbox provider, one profile, zero reserve workers, and a local version-only executable. Reject any provider command other than--version. After readiness and 70 seconds of settling, observe a 120-second steady window with the same frozen observer. This exercises the two existing minute-based reconciliation callers without provisioning a machine.Require a reproduced steady legacy-lease count before accepting that attribution. A successful owner-admission optimization must reduce that steady count to zero, preserve failed migration refusal and retry after explicit recovery, and keep total statements/requests and runtime MAIN from increasing. Use the same count-pair and qualified-timing rules above. The current hypothesis is a completed legacy-namespace cutover: #133447 removed its online allocation writer; supported recovery only deletes rows, and offline migration requires exclusive custody.