Skip to content

[CI] perf(tests): avoid repeated persistence imports in automation fixtures - #26111

Merged
nwparker merged 6 commits into
mainfrom
nwparker/persistence-import-reuse-current
Oct 7, 2026
Merged

nwparker merged 6 commits into
mainfrom
nwparker/persistence-import-reuse-current

Conversation

@nwparker

@nwparker nwparker commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

Six automation test suites already used the persistence harness but repeatedly rebuilt its large module graph when opening a store. Reusing the harness's existing store factory makes the same 53 cases 5.80% faster in a matched four-worker comparison.

What Changed

Import the existing createStore and testState instead of maintaining six local factories that reset modules and dynamically import persistence. Every construction still creates a fresh Store and real SQLite authority. Persisted-state rewrites, flush/freeze/reopen checks, encryption mocks, assertions, timers, service shutdown and directory cleanup remain unchanged. Stock file isolation and Node runtime routing remain enabled.

Why

These suites test automation behavior and real database reloads; none asserts cold module startup. The shared factory already installs the same fake app environment, initializes the current data path and opens the same SQLite authority. Reuse avoids duplicate fixture code and repeated imports without adopting another runner, sharing evaluated state between files, or changing deadlines. Tests that intentionally exercise module identity or captured startup paths retain their resets.

Linked Issue

Maintainer-requested test performance work; no separate issue. Built on merged #26095; its independent cache measurement is not combined with this result.

Visual Proof

N/A — test fixtures only; no product UI or interaction change.

Testing

Frozen source: 80f0728952843785dad6384ba51e16ef6877d58d, with only this six-file patch differing between arms. Both arms used the same six physical files, four workers, cache explicitly disabled, existing setups/flags, actual Node runtime pool and whole pnpm test timing. Three pairs ran in alternating order; every timed sample is included.

Pair Before After Time reduction
1 10.474 s 10.213 s 2.50%
2 11.078 s 10.068 s 9.12%
3 10.773 s 10.170 s 5.60%
Mean 10.775 s 10.150 s 5.80%

All six files / 53 original named cases passed, with exact case/status and runtime-route parity, unchanged source within each invocation, and no unhandled/lifecycle errors or other observed test coordinators. Resolved isolation, setups, cache flags and worker limits were verified. AST comparison preserves the original test bodies, hooks, timers and cipher mocks. The preceding nine-case trial measured 8.451 → 8.010 s (5.21%) across three pairs; that narrower result is not added to the table above.

  • Eight files / 63 cases passed with shuffled seeds 104729 and 130363, under both Bun's coordinator and stock Node: four runs with exact case/status parity. Includes existing cross-host pane identity and layout-binding recovery regressions.
  • Reload, persisted-state drift, cron/rrule, zero-grace scheduling and completion scenarios remain covered by the original cases; fresh temporary directories and authority cleanup remain in the original hooks.
  • pnpm tc:node, changed-code quality and formatting passed locally on macOS with background launches.
  • Existing tests qualify this fixture-only change; no mirror test added.
  • Final PR CI and review.

This is a scoped suite measurement, not a full-suite or CI-wall-time claim. The requested 2× full-suite target remains unmet. Linux is qualified by PR CI; Windows is not locally measured.

Final full CI run 37586310094 tested 7b67e7c60b29 (parents 80f072895284 and final head 6d90d51802dd), with tested source bytes identical to the final head. All five actual assignment artifacts cover 11,407 physical files exactly once: 11,272 passed, 135 existing skips, zero failed/unhandled/missing/duplicated. Static/typechecking, relay integration, selection evidence and aggregate verification passed. The PR now targets main after #26095 merged; final review reports no actionable comments and zero unresolved threads. This proves correctness coverage, not a full-suite timing improvement.

Review

No production code or persistence format changes. Reuse is limited to the audited automation fixtures; shared singleton hooks remain the production implementations, with per-file isolation retained. SSH/host fences and real SQLite reload assertions are unchanged.

Agent skill upstream boundary

  • Not applicable; no upstream skill content copied.

Checklist

  • Focused change with behavior, mechanism, alternative choice and measurements explained.
  • N/A visual proof explained above.
  • Self-reviewed for correctness, test preservation and performance.
  • Cross-platform, folder workspace and SSH behavior considered; original tests retained.
  • Full CI checks pass; relevant local checks above passed.

@nwparker
nwparker changed the base branch from nwparker/vitest-transform-cache to main October 7, 2026 07:44
@coderabbitai

coderabbitai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1a7a4d70-c468-4d10-bf59-91b9db0553f8
📥 Commits

Reviewing files that changed from the base of the PR and between b6f3428 and 6d90d51.

📒 Files selected for processing (7)
  • config/vitest.config.ts
  • src/main/automations/automation-dispatch-host-fence.test.ts
  • src/main/automations/automation-skip-coalescing.test.ts
  • src/main/automations/automation-zero-grace-tick-latency.test.ts
  • src/main/automations/retained-run-reconciliation.test.ts
  • src/main/automations/run-completion-watcher.test.ts
  • src/main/automations/service.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.


📝 Walkthrough

Walkthrough

The shared Vitest options now set fsModuleCache to true. Six automation test files now use the shared persistence test harness for createStore and testState instead of defining local store setup.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 6d90d

No production behavior change or concrete test-isolation regression was established. The change is mergeable after normal CI checks.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 7 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main change: improving test performance by avoiding repeated persistence imports in automation fixtures.
Description check ✅ Passed The description covers the template’s required sections and explains the change, rationale, testing, visual-proof status, review considerations, and checklist. It states that no separate issue exists …
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nwparker
nwparker merged commit 385fe8a into main Oct 7, 2026
30 checks passed
@nwparker nwparker changed the title perf(tests): avoid repeated persistence imports in automation fixtures [CI] perf(tests): avoid repeated persistence imports in automation fixtures Oct 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant