Repository navigation
refactor: move shared database admission into its worker - #146172
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 real behavior proof before merge. Reviewed September 12, 2026, 3:46 PM ET / 19:46 UTC (Revision 7). ClawSweeper reviewWhat this changesMoves shared SQLite opening and repair into the database worker while preserving terminal errors and retaining connection cleanup until it finishes. Warning SQLite table change This PR modifies persisted SQLite tables in Merge readiness⛔ Blocked before merge - 5 items remain This remains useful work absent from current main. The reported exact-head upgrade qualification addresses artifact compatibility, but the previously identified canonical-worker authority proof gap remains. No discrete blocking code defect was established. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw's shared-state database stores task and flow records used by plugin runtime reads. The host admits requests and retains Gateway ownership while a worker opens the canonical database, reads records, and returns results or classified errors. flowchart TD
A[Plugin task and flow reads] --> B[Host admission and terminal failure check]
B --> C[Database worker]
D[Live Gateway coordinator] --> E[Schema authority check]
C --> E
E --> F[Canonical SQLite database]
F --> G[Results or classified errors]
C --> H[Drain operations and release connections]
Before merge
Findings
Agent review detailsSecurityNeeds attention: No concrete bypass or supply-chain regression was established; worker schema authority still needs final-effect refusal evidence. PR surfaceSource +1496, Tests +1445, Docs +12. Total +2953 across 40 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep canonical worker opening and existing synchronous APIs, with live-owner refusal and complete cleanup demonstrated through the actual database path. Do we have a high-confidence way to reproduce the issue? Yes, source inspection establishes that current main performs canonical opening on the caller thread and can reuse a worker without consulting the host terminal latch. No runtime reproduction was executed during this read-only review. Is this the best way to solve the issue? Yes, reusing the canonical opener and existing lifecycle owners is a coherent repair; the remaining qualification concerns authority refusal at actual schema effects. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 53c804f5ee18. LabelsLabel justifications:
EvidenceSecurity concerns:
What I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (6 earlier review cycles)
|
|
@clawsweeper re-review The PR body now includes completed positive published-driver upgrade, Doctor, restart, async SDK/lifecycle, backup restoration, and installed runtime/worker hash evidence. The synthetic Linux/Node run passed and its lease is released. The qualified package pins There is no persisted schema/version/row-format change. The canonical schema owner enters Whole local changed checks, build, fresh P0–P2 review, 89 focused runtime cases, the compiler inventory guard, and both affected compiler graphs passed. Startup event-loop degradation remains documented. CI is separately waiting on an unrelated Gateway compiler-root budget repair on main. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
058ce78 to
c7e9dca
Compare
c7e9dca to
179469f
Compare
|
Merged via squash.
|
What Problem This Solves
The first shared-state worker read still opened and repaired the canonical database on the calling thread. Worker-only reads could also ignore a terminal database failure recorded by the host when no host connection was cached, and failed cleanup could lose track of a native coordinator lease.
Why This Change Was Made
Open and repair shared state inside the existing physical database worker actor, carrying environment and coordinator runtime facts captured by their canonical owners. Existing
runtime.tasks.asyncreads use that context. The host retains live Gateway schema authority, validates its existing terminal failure record through worker inspection, and retains cleanup custody until native close or successful handoff to the existing idle pool.No persisted schema, schema version, or row format changes. Input/result framing and current pooling limits remain intact. Inspection failures preserve a known terminal failure; only a successful generation mismatch clears it. Public synchronous APIs remain available for compatibility. Task/flow registry restoration and runtime configuration preparation still run synchronously and are separate follow-ups.
User Impact
Canonical database opening, repair, and reads execute in the worker while shutdown and terminal database errors remain observable to callers. Existing read payloads and synchronous callers remain compatible. Plugin KV activation and bundled caller migration are separate successors.
Evidence
f1734c0f8c0ecompiled Node 24.20 SDK measurements preserved Unicode payloads and restart/reopen behavior. Four warmed public reads took 3.73 ms with all six parent SQLite method counters at zero. Bun 1.4.2 canonical cold opening/read took 343.14 ms with the same zero counters and captured default pooling. These are individual synthetic timings, not comparative benchmarks.2026.9.4synthetic task/flow rows and CLI payloads survived the real candidate update, Doctor, first Gateway startup, and restart. Actual async SDK reads and lifecycle drainage passed. The published backup was verified and restored by the candidate with identical rows. Installed runtime, lifecycle, and worker hashes matched the candidate package, and build IDs verified the artifact transition despite the unchanged package-version string. The test lease is released with zero owned containers.The final qualified package SHA-256 is
abbe9bc0003f918048203dcb7155629043caca687ec25f3dc63d888b268dff34, built from exact head179469fb205e649b092c17a7baf34ab54922d621. Its independent published-driver run passed on the first attempt. Health/readiness returned 200 and RPC succeeded. Startup telemetry still reported event-loop degradation (p99/max 23.572 seconds over a 24.013-second sample); update took 178 seconds and startup/restart took 32/30 seconds. This establishes retained-data and artifact compatibility, not whole-Gateway cold-start performance. Earlier artifact receipts remain separate.Current head
179469fb205econtains the reviewed shutdown composition on main7753ffb4753f. It preserves the landed forced-no-retention cleanup from #146160, alongside retryable failed-close custody and captured runtime facts. The complete composition passed 69 focused cases, a fresh full P0–P2 review, and the full changed-code gate. The final conflict resolution only incorporates main's native-realpath helper/tests; an independent source review confirmed no foundation ownership or retention body changed. No Windows runtime claim is inferred from the local macOS tests.Compiler routing fixes have since landed on main, so the redundant compiler commit was removed and the PR is back to 40 files. The final read-only inventory check assigns all 10,092 roots exactly once across the same 18 compiler graphs, with infra 671 and state/logging 404 roots. No test cases or caps were removed. Exact-head CI run 34711552584 is green. The final shutdown composition has its own source/runtime proof and exact-package upgrade receipt; no old artifact is being relabeled as final-head proof.
The canonical schema owner enters
withStateSchemaFencebefore its synchronous migration transaction. Captured worker context reaches the live delegate assertion at that boundary. Real create/repair tests verify the reopened index; separate canonical refusal tests cover future schema and external-manager ownership. Revoked-delegate schema effects were not live-tested; the callback-level negative fixture is not presented as that evidence. The maintainer source review accepts this bounded scope with that limitation explicit.