Skip to content

test(state): reuse canonical database template - #118552

Merged
steipete merged 1 commit into
mainfrom
codex/test-perf-state-db-template
Aug 3, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/test-perf-state-db-template

Conversation

@steipete

@steipete steipete commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fourteen current-schema drift and read-only tests rebuilt the complete shared SQLite schema even though their assertions begin after canonical initialization.

Why This Change Was Made

Create one canonical state database in beforeAll, close it cleanly, and copy it into each selected test state directory. Fresh initialization, every migration, WAL and hot-journal behavior, concurrent schema creation, integrity checks, and subprocess path ownership continue to use real independently created databases.

User Impact

No user-visible behavior changes. All state-database assertions remain, while repeated fixture-only DDL work and memory use are reduced; production code is unchanged.

Evidence

  • Exact main CI run 30789242864, job 91609378936: openclaw-state-db.test.ts took 29.429s.
  • Exact-head PR CI run 30792035994: the file fell to 28.187s, a 1.242s (4.2%) reduction on the warm compact large-8 runner.
  • Same-head focused benchmark: Vitest duration 29.11s to 23.10s (20.6% faster); wall time 33.91s to 27.97s; peak RSS 2.381 GB to 2.102 GB.
  • Full owner proof: 108 passed with one existing platform skip, including fresh creation, migrations, WAL, rollback-journal, concurrency, integrity, and subprocess cases.
  • Sibling proof: 28/28 legacy-backfill, schema-migration-required, corruption-recovery, and permissions tests passed.
  • Oxfmt, git diff --check, and Codex autoreview passed with no findings.
  • Production LOC delta: 0.

@steipete steipete self-assigned this Aug 3, 2026
@openclaw-barnacle openclaw-barnacle Bot added size: XS maintainer Maintainer-authored PR labels Aug 3, 2026
@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 3, 2026
@clawsweeper

clawsweeper Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 3, 2026, 3:05 AM ET / 07:05 UTC.

ClawSweeper review

What this changes

The branch creates one real canonical shared SQLite database before the state test suite and copies it into selected canonical-schema drift and read-only test directories instead of rebuilding the full schema each time.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

Keep this PR open for explicit maintainer review. The test-only optimization is coherent, preserves the fresh-create and migration cases that need independent databases, and matches an existing closed-template fixture pattern on current main; no correctness or security defect was found.

Priority: P3
Reviewed head: 08a235275dc1e7a171f25bc157d26655e7f9b22b
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, precedent-aligned test optimization with concrete performance and test evidence; it is ready for normal protected-label maintainer review.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The PR body supplies after-change focused benchmark and test-suite output, and the provided check context records a successful Real behavior proof run; no sensitive values are involved.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body supplies after-change focused benchmark and test-suite output, and the provided check context records a successful Real behavior proof run; no sensitive values are involved.
Evidence reviewed 5 items Current-main test boundary: Current main still has the helper create a new database and close it for every canonical audit fixture; the PR changes only that helper and adds one suite-level initialization, so the central performance problem remains unsolved on main.
Lifecycle isolation: The production test helper closes every cached state handle and clears terminal failure latches, so the branch creates a closed template before copying it and retains per-test cleanup after each case.
Existing canonical-template precedent: Current main already seeds agent-database tests by creating one real shared-state database, closing it, and copying it only when the selected test owns the agent schema rather than shared-state initialization.
Findings None None.
Security None None.

How this fits together

OpenClaw state-database tests create isolated SQLite files, mutate them into specific schema or integrity conditions, and then exercise the shared-state open, validation, and repair paths. This change affects only the canonical-input setup for selected audit and read-only tests; production state-database behavior remains unchanged.

flowchart LR
  A[State database test] --> B[Isolated test state directory]
  B --> C{Needs canonical current schema?}
  C -->|Yes| D[Copy closed canonical SQLite template]
  C -->|No: fresh or migration path| E[Create independent database]
  D --> F[Schema drift or read-only assertion]
  E --> F
  F --> G[State database validation or repair result]
Loading

Decision needed

Question Recommendation
Should a maintainer approve landing this protected-label test-fixture optimization once the remaining required checks finish? Review and land: Accept the established closed-template pattern for only the selected canonical-schema test cases while preserving independent creation coverage elsewhere.

Why: The patch has no supported mechanical repair target, but the maintainer label requires an explicit human landing decision despite the favorable source and proof evidence.

Before merge

None.

Agent review details

Security

None.

PR surface

Tests +13. Total +13 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 17 4 +13
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 17 4 +13

Review metrics

Metric Value Why it matters
Production vs test LOC production +0, tests +13 The added code is confined to state-test setup, with no runtime, config, or persisted-schema behavior changed.

Stored data model

Persistent data-model change detected: serialized state: 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:

Land the focused test-fixture optimization after the explicit maintainer review gate, retaining independent database creation for fresh initialization, migrations, journal behavior, concurrency, integrity, and subprocess ownership coverage.

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

Not applicable: this PR improves test-fixture cost rather than fixing a user-facing failure. The stated benchmark and passing owner/sibling test evidence provide a concrete validation path for the changed behavior.

Is this the best way to solve the issue?

Yes. Reusing one real, closed canonical database for tests whose assertions begin after initialization removes duplicated setup while keeping fresh-create, migration, WAL, concurrency, integrity, and subprocess cases independent.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P3: This is a contained test-suite performance cleanup with no user-visible runtime behavior change.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body supplies after-change focused benchmark and test-suite output, and the provided check context records a successful Real behavior proof run; no sensitive values are involved.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body supplies after-change focused benchmark and test-suite output, and the provided check context records a successful Real behavior proof run; no sensitive values are involved.

Label justifications:

  • P3: This is a contained test-suite performance cleanup with no user-visible runtime behavior change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body supplies after-change focused benchmark and test-suite output, and the provided check context records a successful Real behavior proof run; no sensitive values are involved.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body supplies after-change focused benchmark and test-suite output, and the provided check context records a successful Real behavior proof run; no sensitive values are involved.

Evidence

What I checked:

  • Current-main test boundary: Current main still has the helper create a new database and close it for every canonical audit fixture; the PR changes only that helper and adds one suite-level initialization, so the central performance problem remains unsolved on main. (src/state/openclaw-state-db.test.ts:420, c6bcd935619b)
  • Lifecycle isolation: The production test helper closes every cached state handle and clears terminal failure latches, so the branch creates a closed template before copying it and retains per-test cleanup after each case. (src/state/openclaw-state-db.ts:716, c6bcd935619b)
  • Existing canonical-template precedent: Current main already seeds agent-database tests by creating one real shared-state database, closing it, and copying it only when the selected test owns the agent schema rather than shared-state initialization. (src/state/openclaw-agent-db.test.ts:78, eeb2b260af2a)
  • Branch integration and proof: The PR-head diff is confined to test setup, has no production-code delta, and its body reports a focused before/after benchmark plus 108 owner tests and 28 sibling tests passing; the supplied GitHub context also records a successful Real behavior proof check. (src/state/openclaw-state-db.test.ts:421, 08a235275dc1)
  • Recent related history: The template approach is also reinforced by the recent current-main commit reusing a worktree state-database fixture, showing this is an established test-performance direction rather than a parallel abstraction. (src/state/openclaw-agent-db.test.ts:78, 938980d51b45)

Likely related people:

  • steipete: Recent current-main SQLite performance and fixture work includes the same closed-template testing direction, in addition to substantial history in this state-test surface. (role: recent state-database test contributor; confidence: high; commits: 2cbbb00fbaf5, 938980d51b45; files: src/state/openclaw-state-db.test.ts, src/state/openclaw-agent-db.test.ts)
  • Shakker: Git blame attributes the current shared-state template helper used by agent-database tests to this contributor, making them a useful adjacent owner for the fixture-isolation pattern. (role: introduced shared-template test precedent; confidence: high; commits: eeb2b260af2a; files: src/state/openclaw-agent-db.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.

@steipete
steipete merged commit bd23864 into main Aug 3, 2026
132 of 139 checks passed
@steipete
steipete deleted the codex/test-perf-state-db-template branch August 3, 2026 07:22
@steipete

steipete commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 3, 2026
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: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS 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