Repository navigation
refactor(state): register agent database worker operations - #162776
Conversation
Infer business operation contracts from lazy handler tables and reuse the typed registry with the agent context and exact operation loaders. Preserve conditional transcript preparation, native admission, FIFO, receipts, incognito handling, and synchronous lifecycle commands. No schema, stored-state, configuration, or user-visible behavior change.
…agent-db-registry
|
🦞👀 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. Reviewed October 1, 2026, 11:01 AM ET / 15:01 UTC (Revision 2). ClawSweeper reviewWhat this changesThe PR moves 13 existing agent database operations into typed, lazily loaded handler tables without changing their user-visible behavior. Merge readiness✅ Ready for maintainer review This remains useful, distinct work: current main retains the agent dispatcher that this branch replaces. The source review found no actionable introduced defects, consistent with the previous review. Priority: P3 Review scores
Verification
How this fits togetherAgent database workers receive session and trajectory operations from OpenClaw’s storage callers. They prepare the required modules, check current authority, and execute reads or transactions against the agent’s SQLite database. flowchart TD
A[Session and trajectory requests] --> B[Existing worker broker]
B --> C[Lazy operation registry]
C --> D[Existing admission checks]
D --> E[Agent SQLite database]
E --> F[Results and commit receipts]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource -18, Tests +27. Total +9 across 6 files. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Use the existing typed registry for agent business dispatch while retaining native lifecycle, transaction, and admission ownership. Do we have a high-confidence way to reproduce the issue? Not applicable: this refactor reports duplicated operation declarations and dispatch, which are directly visible in the original source. Is this the best way to solve the issue? Yes: extending the existing registry removes parallel declarations and dispatch while preserving the established worker and kernel boundaries. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 78e733b7a4aa. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Merged via squash.
|
…162776) * refactor(state): register agent database worker operations Infer business operation contracts from lazy handler tables and reuse the typed registry with the agent context and exact operation loaders. Preserve conditional transcript preparation, native admission, FIFO, receipts, incognito handling, and synchronous lifecycle commands. No schema, stored-state, configuration, or user-visible behavior change. * fix(state): type worker context callbacks as function properties
Related: #162524
What Problem This Solves
Agent-database business operations duplicate their contracts across manual input/output declarations, module preparation, and command dispatch. This migrates the business dispatch deferred from the shared-state registry work.
Solution
Infer the 13 business-operation contracts from typed lazy handler tables and reuse
createWorkerOperationRegistrywith the agent context. Exact-operation loader keys preserve independent kernel loading within the sharedsession.*namespace; shared-state namespace lookup stays unchanged. Transcript loading for entry replacement remains conditional.Native database creation, WAL maintenance, and publication binding/execution/cleanup retain their lifecycle owner. Admission, writer FIFO, transaction labels, commit receipts, and incognito handling are unchanged. No broker implementation changes are needed.
Impact
No user-visible behavior change or claimed performance improvement. These operations already execute in the agent worker. For the five production files in this lane, inventory counts remain T1: 0 → 0; W: 1 → 1. The production delta is +328 / −346 / net −18. Including the test, the patch changes 703 lines across six files.
Merged
mainat6010d074f754d142ee1134416bcd9a4d5290a3db; the lane's files had no concurrent changes or conflicts. LOC is measured against that merged base (and is identical for these files against the original pinned base).Evidence
Runtime proof snapshot:
c2fbfc599b61731fbfbeb022c90f0fecf7ba4188, validated on Blacksmith Testboxtbx_01m3vtf6msntvettpb3842dtnh(run). All six changed-file SHA-256 checks passed before execution.af7f677aead1272d34f5b8a917b8dee994939254declares those callbacks as function properties, matching their supplied closures. This changes no emitted JavaScript.pnpm build: passed (1757.50s), including runtime bundles, unified declarations, plugin SDK declarations, CLI import/export checks, and UI artifacts.The boundary selection exercises real worker routing with no caller-thread SQLite, FIFO, delayed preparation, rejected/revoked authority, commit receipts, incognito ownership, archive pruning, reactions, provider review, trajectory writes, and conditional transcript initialization.
Exact final validation commands
The configured
node scripts/crabbox-wrapper.mjs run --keep --timing-json -- bash -c <payload>ran the tests and changed-check command against the hash-verified frozen source. After the declaration-only lint repair, the remaining commands ran on the final local head:Inventory was measured before edits on the pinned base and after the cutover with
node scripts/database-worker-inventory.mjs --json, filtered to the five production files. Onlyopenclaw-agent-execution.worker.tscontains a counted primitive: one worker-siderunOpenClawAgentWriteTransactioncall.Local core typechecking, the pinned-base SQLite ratchet, and the type-inclusive import-cycle check passed. The changed registry test passed both cases with
OPENCLAW_VITEST_NO_OUTPUT_TIMEOUT_MS=1800000 pnpm test src/state/openclaw-state-worker-registry.test.ts --maxWorkers=1: 21.28s wall, 557ms test time on the loaded host.The local integration run was interrupted after 565.10s. Four unchanged
openclaw-agent-worker-store.test.tscases reached the existing five-second marker deadline: successful scope preparation and pre-commit revocation with the borrowed source, plus successful single-command preparation with both borrowed and captured sources. Neighboring cases passed, and initial worker startup took 31.85s. This is retained as a local timing limitation; no fixture deadline, retry, or assertion was changed. Those cases pass unchanged in the isolated run described above.Compatibility retained
No compatibility aliases or synchronous host exports were added. Existing synchronous worker factories and lifecycle commands remain required by the broker's native creation/binding contract. The existing process-held incognito and maintenance paths are unchanged; this refactor does not claim to migrate them.
Update behavior
No schema, stored-state, retention, durability, configuration, permission, Doctor, or updater change. No migration is required.