Skip to content

perf(state): prepare plugin-state commands independently - #157333

Merged
steipete merged 1 commit into
mainfrom
codex/testperf-plugin-state-lazy-1ffe47bf
Sep 24, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/testperf-plugin-state-lazy-1ffe47bf

Conversation

@steipete

@steipete steipete commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

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.

Arm Command wall Summed reported test duration Worker preparation CPU time Peak command RSS
A1 130.192 s 72.697 s 20.007 s 216.65 s 2,918,148 KiB
B1 80.775 s 47.059 s 21.212 s 140.90 s 3,050,936 KiB
B2 64.505 s 36.508 s 18.326 s 113.20 s 3,054,532 KiB
A2 80.102 s 58.521 s 13.562 s 141.94 s 3,086,024 KiB

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 main 1b32a8b3c7fc0793978c6a1cb2248a6e6c51c8b1 and PR head 321239dc1d23e1261f99a0f8d0a0b1a355a9728d. 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.

@clawsweeper

clawsweeper Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@steipete
steipete marked this pull request as ready for review September 24, 2026 14:51
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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 Sep 24, 2026
@clawsweeper

clawsweeper Bot commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 24, 2026, 10:58 AM ET / 14:58 UTC.

ClawSweeper review

What this changes

The 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
Reviewed head: 321239dc1d23e1261f99a0f8d0a0b1a355a9728d

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level patch has a direct cold-path regression and relevant reported timing data, with no identified merge defect.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: The supplied Repository State classifies the author as MEMBER, so the external-contributor proof gate does not apply. The added cold-backend test exercises plugin-state lookup and observes an absent value without creating a database while the broad runtime is mocked to fail; the linked Testbox workflows ended cancelled, and production latency was not measured. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied Repository State classifies the author as MEMBER, so the external-contributor proof gate does not apply. The added cold-backend test exercises plugin-state lookup and observes an absent value without creating a database while the broad runtime is mocked to fail; the linked Testbox workflows ended cancelled, and production latency was not measured. No stored-data contract changes.
Evidence reviewed 10 items Current main still uses broad preparation: At fetched main, plugin-state commands fall through to loading the shared command runtime; the runtime then dispatches them to the plugin-state executor.
Current-main plugin-state dispatch: The broad runtime still contains the plugin-state dispatch on current main, so the central change is not already implemented there.
Introduced command-specific preparation: The introduced patch selects the existing plugin-state command family for separate lazy preparation and calls the existing executor with the captured environment, database opener, and retained-handle flag.
Findings None None.
Security None None.

How this fits together

Plugins 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]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +13, Tests +35. Total +48 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 3 34 21 +13
Tests 1 36 1 +35
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 70 22 +48

Review metrics

Metric Value Why it matters
Reported timing comparison 2 candidate runs; 92 and 94 of 106 cases faster Whole-command wall time was mixed, so the measured benefit remains limited to reported test timing.
Regression cost 1 new case: 59.54 ms test time; 27.587 s file command wall The PR reports the new case’s cost separately from worker and command startup.

Technical review

Best 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.

Labels

Label changes:

  • add P3: This is an internal preparation improvement without an established production latency regression.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The supplied Repository State classifies the author as MEMBER, so the external-contributor proof gate does not apply. The added cold-backend test exercises plugin-state lookup and observes an absent value without creating a database while the broad runtime is mocked to fail; the linked Testbox workflows ended cancelled, and production latency was not measured. No stored-data contract changes.

Label justifications:

  • P3: This is an internal preparation improvement without an established production latency regression.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The supplied Repository State classifies the author as MEMBER, so the external-contributor proof gate does not apply. The added cold-backend test exercises plugin-state lookup and observes an absent value without creating a database while the broad runtime is mocked to fail; the linked Testbox workflows ended cancelled, and production latency was not measured. No stored-data contract changes.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Shakker: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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 8868811 into main Sep 24, 2026
280 checks passed
@steipete
steipete deleted the codex/testperf-plugin-state-lazy-1ffe47bf branch September 24, 2026 15:52
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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