Skip to content

improve: make state-heavy test suites faster - #119617

Merged
steipete merged 3 commits into
mainfrom
codex/test-perf-owner-tail-2
Aug 5, 2026
Merged

steipete merged 3 commits into
mainfrom
codex/test-perf-owner-tail-2

Conversation

@steipete

@steipete steipete commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

The slow Node test tail repeatedly pays full SQLite integrity and canonical-schema validation merely to manufacture current database bytes that tests immediately close and mutate. One Claw dry-run assertion also asks Vitest to recursively compare a 1.5 MiB Buffer byte by byte.

Why This Change Was Made

Current state and agent database fixtures are created once through the production opener, verified, closed, and cloned into isolated per-test directories. Tests that own fresh creation, WAL and rollback recovery, process concurrency, path/cache behavior, pragmas, registration, and leases still use real production opens. Claw snapshot equality now uses Node's native byte-for-byte Buffer comparison.

No test declarations, shard topology, worker counts, concurrency settings, scheduling, or timeouts change.

User Impact

There is no product behavior change. Contributors and maintainers get faster test feedback while retaining the same state migration, integrity, constraint, and non-mutation coverage.

Evidence

  • AWS Crabbox cbx_afa7d336374c, run run_2554c9a8c05a: pnpm test src/state/openclaw-state-db.test.ts src/state/openclaw-agent-db.test.ts src/claws/update-plan.test.ts
  • Result: 3 files passed; 218 tests passed and 6 intentionally skipped (224 total); Vitest duration 19.71s.
  • State runtime opens: 102 to 68. Agent runtime opens: 68 to 64.
  • Test declarations unchanged: 80 state and 99 agent declarations; targeted runtime reported unchanged 107 state and 100 agent cases.
  • The 1.5 MiB snapshot assertion uses exact Buffer.equals semantics instead of recursive matcher traversal.
  • git diff --check passed.
  • Autoreview: clean, no accepted/actionable findings (gpt-5.6-sol, high reasoning).

This is an incremental step toward the frozen raw full-suite target; it does not claim normalized or final 30% success.

@steipete steipete self-assigned this Aug 5, 2026
@openclaw-barnacle openclaw-barnacle Bot added size: M maintainer Maintainer-authored PR labels Aug 5, 2026
@steipete

steipete commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. labels Aug 5, 2026
@clawsweeper

clawsweeper Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

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

ClawSweeper review

What this changes

This PR creates validated SQLite test fixtures once and clones them for isolated state tests, while using native Buffer byte equality for a large database snapshot assertion.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

Keep open for the normal human merge decision: the exact reviewed head has no actionable correctness or security finding, and current main has not absorbed this test-only optimization.

Priority: P3
Reviewed head: 3b3756191056343993a1cbdf7068a673680778e6

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused, test-only optimization with strong targeted runtime evidence and no actionable finding.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The PR body records an after-change AWS Crabbox run of all three changed suites with passing results and measured runtime improvement.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR body records an after-change AWS Crabbox run of all three changed suites with passing results and measured runtime improvement.
Evidence reviewed 7 items Production state-open boundary: The state opener performs schema-version, integrity, connection-pragmas, and schema checks before returning a database; the fixture optimization does not change this runtime path.
Fixture lifecycle and sibling coverage: Current tests create a canonical fixture through the production opener, close it with WAL maintenance, clone it only for isolated schema-drift cases, and retain direct production-open coverage for fresh creation and reopen validation.
Agent fixture invariant: The existing agent template checkpoints WAL, verifies integrity, foreign keys, schema version, and owner before exclusive-copy materialization; per-test cleanup clears cached agent and state handles.
Findings None None.
Security None None.

How this fits together

State and agent database tests normally open SQLite through production lifecycle code before exercising migrations, integrity checks, and data constraints. This change keeps production-opening coverage where it matters while reusing closed, validated current-schema fixtures for independent mutation cases.

flowchart LR
  A[Production database opener] --> B[Validated current-schema fixture]
  B --> C[Isolated test database copy]
  C --> D[Schema and migration test]
  D --> E[Production reopen assertions]
  F[Database snapshot bytes] --> G[Native byte equality check]
  G --> E
Loading

Before merge

  • Complete next step (P2) - No repair lane is needed; the exact head already has sufficient proof and no actionable finding, while the protected maintainer label reserves final merge handling for a human.
Agent review details

Security

None.

PR surface

Tests -54. Total -54 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 3 171 225 -54
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 171 225 -54

Review metrics

Metric Value Why it matters
Production versus test LOC production +0/-0, tests +171/-225 (net -54) The optimization is confined to tests and reduces test code without changing runtime, config, schema, or dependency surfaces.

Stored data model

Persistent data-model change detected: serialized state: src/claws/update-plan.test.ts, serialized state: src/state/openclaw-agent-db.test.ts, serialized state: src/state/openclaw-state-db.test.ts, unknown-data-model-change: src/state/openclaw-agent-db.test.ts, unknown-data-model-change: src/state/openclaw-state-db.test.ts. Migration or upgrade compatibility proof is recorded; maintainers should verify it before merge.

Technical review

Best possible solution:

Merge the focused test-only optimization after the designated maintainer performs the final normal PR review; retain production-open coverage for fresh creation, recovery, and lifecycle tests.

Do we have a high-confidence way to reproduce the issue?

Not applicable: this PR improves test execution rather than fixing a user-facing failure; its changed behavior is directly covered by the recorded focused suite run.

Is this the best way to solve the issue?

Yes. Reusing the existing validated-fixture pattern avoids repeated expensive opens while retaining fresh-open, integrity, migration, WAL, and recovery tests on the production path.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 1b4a60be15a1.

Labels

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.

Label justifications:

  • P3: This is a low-risk test-feedback performance improvement with no product behavior change.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body records an after-change AWS Crabbox run of all three changed suites with passing results and measured runtime improvement.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body records an after-change AWS Crabbox run of all three changed suites with passing results and measured runtime improvement.

Evidence

What I checked:

  • Production state-open boundary: The state opener performs schema-version, integrity, connection-pragmas, and schema checks before returning a database; the fixture optimization does not change this runtime path. (src/state/openclaw-state-db.ts:587, 1b4a60be15a1)
  • Fixture lifecycle and sibling coverage: Current tests create a canonical fixture through the production opener, close it with WAL maintenance, clone it only for isolated schema-drift cases, and retain direct production-open coverage for fresh creation and reopen validation. (src/state/openclaw-state-db.test.ts:431, 1b4a60be15a1)
  • Agent fixture invariant: The existing agent template checkpoints WAL, verifies integrity, foreign keys, schema version, and owner before exclusive-copy materialization; per-test cleanup clears cached agent and state handles. (src/state/openclaw-agent-db.test.ts:105, 1b4a60be15a1)
  • Exact-head diff and current-main check: The reviewed head is not on current main: the reverse diff shows main still uses repeated fresh opens and recursive Buffer comparison, while the PR contains only the three test-file optimizations. (src/state/openclaw-state-db.test.ts:431, 3b3756191056)
  • Byte-comparison contract: Node 24.13.0 Buffer.equals rejects unequal lengths and otherwise performs native byte comparison, preserving the assertion's intended semantics for two readFile Buffers. (src/claws/update-plan.test.ts:169, 3b3756191056)
  • Real test evidence: The PR body records an AWS Crabbox run of the three changed suites: 218 passed, 6 intentionally skipped, with a 19.71s Vitest duration; supplied exact-head CI and security checks are successful. (3b3756191056)

Likely related people:

  • steipete: Current-file blame attributes the fixture baseline and related test paths to this contributor; the PR head is also their follow-up optimization. (role: recent state and Claw test-surface contributor; confidence: high; commits: 57122c965c65, 359d8d867b67; files: src/state/openclaw-state-db.test.ts, src/state/openclaw-agent-db.test.ts, src/claws/update-plan.test.ts)

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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-08-05T14:15:07.791Z sha 3b37561 :: needs maintainer review before merge. :: none

@steipete
steipete merged commit f391563 into main Aug 5, 2026
125 checks passed
@steipete
steipete deleted the codex/test-perf-owner-tail-2 branch August 5, 2026 14:24
@steipete

steipete commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 5, 2026
vincentkoc added a commit to VACInc/openclaw that referenced this pull request Aug 5, 2026
* origin/main: (130 commits)
  refactor(qa): consolidate scenario runtime helpers (openclaw#119623)
  fix(telegram): bind Mini App auth to dashboard launches
  refactor(agent-core): unify session projection and compaction summaries (openclaw#119639)
  fix(codex): allow natural reactions in the current conversation (openclaw#119649)
  refactor(providers): deduplicate bundled model catalogs (openclaw#119627)
  fix(ui): observe the active service worker after asset refresh (openclaw#119622)
  fix(agents): strip echoed base64 image payloads so photo-heavy turns no longer hit the per-turn output cap (openclaw#119488)
  improve: make state-heavy test suites faster (openclaw#119617)
  perf(agents): add concurrency benchmark (openclaw#119569)
  fix(browser): visibly report failed pairing and tab-sharing actions (openclaw#119526)
  refactor(lobster): consolidate embedded workflow execution (openclaw#119630)
  fix(plugin-sdk): stabilize tuple-derived API baseline ordering (openclaw#119635)
  docs(skills): make full-authority maintainer runs unattended (openclaw#119629)
  fix(managed-child): honor process groups that vanish before cleanup (openclaw#119614)
  fix(ci): stop label-driven automation churn (openclaw#119610)
  fix(media): keep the ttl sweep out of the managed outgoing tree (openclaw#119127)
  fix(claws): remove owner-qualified skills (openclaw#119606)
  fix(clawrouter): show stable error for malformed usage responses (openclaw#119580)
  fix(gateway): claim malformed plugin icon routes (openclaw#119559)
  fix(telegram): preserve truthful empty-content delivery (openclaw#88810)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 6, 2026
* test(state): reuse current database fixtures

* test(claws): compare database snapshots directly

* test(state): remove obsolete fixture options

---------

Co-authored-by: Peter Steinberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: M 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