Repository navigation
perf(state): prepare plugin-state commands independently - #157333
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. Reviewed September 24, 2026, 10:58 AM ET / 14:58 UTC. ClawSweeper reviewWhat this changesThe PR prepares plugin-state commands through their own module in the shared SQLite worker and adds a cold-read regression test. Merge readiness✅ Ready for maintainer review Current main still prepares plugin-state commands through the broad state runtime. This focused PR addresses that boundary, and the source review found no actionable correctness or security defect. The reported timing benefit is limited to tests; production latency was not measured. Priority: P3 Review scores
Verification
How this fits togetherPlugins send keyed-state operations to OpenClaw’s shared SQLite worker. The worker prepares the relevant command module, then executes reads or writes against the state database. flowchart LR
A[Plugin keyed-state call] --> B[Shared SQLite worker]
B --> C{Command family}
C --> D[Plugin-state module]
C --> E[Other state runtime]
D --> F[Admission and execution]
E --> F
F --> G[State database]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +13, Tests +35. Total +48 across 4 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep one plugin-state executor behind command-specific preparation while preserving the shared worker’s admission and database behavior. Do we have a high-confidence way to reproduce the issue? Yes, from source: current main loads the broad runtime when preparing a plugin-state command. This read-only review did not execute that path. Is this the best way to solve the issue? Yes. The patch moves preparation to the existing state-worker owner and retains the plugin-state executor and its database arguments. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 481045d44bee. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
What Problem This Solves
The first plugin-state operation loads unrelated shared-state command handlers, adding startup work to otherwise narrow storage operations and their tests.
User Impact
Plugin-state operations keep the same executor and storage/authority behavior while preparing their command module independently. The measured benefit is lower reported test execution time; production latency was not benchmarked.
Why This Change Was Made
The shared-state backend already prepares narrow command families separately. Put plugin-state preparation and dispatch there, reusing the existing executor, and remove its old broad-runtime dispatch and obsolete argument. Preserve the captured per-command environment, database ownership, retained-database error classification, and synchronous execution.
The regression exercises cold preparation and an absent-state lookup with the unrelated runtime unavailable, and verifies that no database is created. No new production test seam or storage contract is introduced.
Evidence
A natural A–B–B–A of the unchanged 106-case Feishu suite ran on one configured Crabbox/Blacksmith Testbox, Linux Node 24.19.0, pnpm 12.4.2 and Vitest 5.0.1. Both arms use frozen base
1ffe47bf5e3ac930e1e00b7fb968c00c6590aee1; only this four-file patch differs.Command:
pnpm test extensions/feishu/src/bot.test.ts --maxWorkers=1, with stock verbose/JSON reporters and default caches. All 106 ordered cases passed in every arm, including duplicate display names. Real per-case state-database closure remains unchanged. The archive, 37 payloads, 81 source bindings, source/index restoration, and natural settlement were independently verified.Both candidate runs reduced summed reported test durations versus warm A2 by 19.59–37.61%; 92 and 94 of the 106 individual cases were faster. Whole-command results are mixed: B1 was 0.84% slower than warm A2, and B2 was 19.47% faster. A1 was colder. The data does not establish a consistent whole-file, whole-suite, production, or memory improvement.
The comparison Testbox host and qualification Testbox host both have terminal workflow conclusion
cancelled: the leases were intentionally stopped after the archived commands settled. These host workflow statuses are not passing CI results. The command exit codes, test counts, source bindings, and natural process settlement come from the independently verified archived receipts. The qualification commands passed all 97 cases across seven files, the full build (1591.583 s), and all 31 selected core/coreTests checks (2029.968 s), including all 25 core test type graphs. Independent source review is clean. The regression's historical pre-fix failure and candidate pass remain separately bound to their recorded source.The changed imports test passed both cases in a 27.587 s one-worker command: 15.938 s was worker preparation, the existing static import-closure case took 2.420 s, and the new cold-preparation regression took 59.54 ms. All source checks and natural process-settlement checks passed. The evidence collector initially counted 30 of 31 successful checks because its whitespace parser missed the unpadded 1452.64 s typecheck row; inspection of the unchanged archive confirmed all planned checks passed, without rerunning any command. Exact-head CI passed with 135 successful jobs and 17 selected skips; the canonical watcher confirmed a green full check rollup. It tested merge
3ce0fca92d1385d16cd8a35eff390402ddc58924, with parents main1b32a8b3c7fc0793978c6a1cb2248a6e6c51c8b1and PR head321239dc1d23e1261f99a0f8d0a0b1a355a9728d. This is separate current integration proof from the archived frozen-base comparison.The hosted test job ran Linux Node 24.19.0, pnpm 12.4.2 and Vitest 5.0.1. Both imports cases passed: the existing static check took 2.261 s and the added cold-preparation regression took 0.012 s. Their enclosing 54-file, 732-case group passed in 60.39 s reported Vitest duration (62.34 s wrapper wall); the composite job took 484 s, including a 449.01 s test command covering additional groups. These enclosing costs are not isolated file timings. The worker and test blobs exactly match the PR head; the merged contract/runtime also preserve main's additive worktree-retirement command. The completed ClawSweeper review found no actionable correctness or security defect at
321239dc1d23e1261f99a0f8d0a0b1a355a9728d.