Files
fusion/packages/core/vitest.config.ts
gsxdsm c25f8b796d Harden PostgreSQL migration foundation (#2088)
## Summary

- make SQLite-to-PostgreSQL cutover retryable, fail-closed, versioned,
and transactionally serialized
- isolate migration sessions from runtime traffic and apply schema
upgrades through `0002`
- enforce tenant ownership across automations, analytics, activity,
usage, agent runs, evals, and todos
- replace expired SQLite-only coverage with PostgreSQL parity and
concurrency coverage

This is PR 1 of 2. The stacked follow-up restores PostgreSQL parity for
CLI, engine, dashboard, and bundled integrations.

## Verification

- `pnpm check:changesets --strict`
- `pnpm --filter @fusion/core typecheck`
- migration schema, connection, and SQLite cutover suite: 57 tests
passed
- `pnpm test:gate`: 463 tests passed

## Post-Deploy Monitoring & Validation

- take a restorable PostgreSQL backup before deploy
- confirm `fusion_schema_migrations` contains `0002`
- confirm each expected project has a complete
`fusion_sqlite_migrations` row
- verify no null or empty tenant ownership in automations, activity
logs, agent runs, and usage events
- monitor for ownership inference failures, cutover verification
failures, and migration session errors
- restore the backup for data rollback; do not downgrade the
tenant-isolation schema in place

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* PostgreSQL-backed analytics and live dashboard metrics are now
project-scoped (activity, tools, monitor, signals, and live snapshots).
* Evaluation runs and scheduled eval batches received lifecycle
improvements (ordering, updates, and execution flow).
* Todo list changes now emit events; WhatsApp persistence and
project-scoped roadmap data are supported.

* **Bug Fixes**
* SQLite-to-PostgreSQL cutovers now fail safely with stronger
verification, serialized cutover handling, and safer project ownership.
* PostgreSQL backend writes and reads are now strictly project-isolated
and fail closed when project context is missing.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-07-14 08:16:42 -07:00

54 lines
2.1 KiB
TypeScript

import { defineConfig } from "vitest/config";
import { resolve } from "node:path";
import { computeMaxWorkers } from "./src/__test-utils__/vitest-workers";
const maxWorkers = computeMaxWorkers();
/*
FNXC:CoreTestInventory 2026-07-13-22:38:
Core test exclusions must exactly mirror the dated quarantine ledger. The PostgreSQL cutover removed the SQLite runtime and the expired 2026-07-10 exclusions no longer have ledger authority; keep this list empty and preserve behavior through active PostgreSQL counterparts.
*/
const quarantinedCoreTests: string[] = [];
export default defineConfig({
resolve: {
alias: {
"@fusion/core": resolve(__dirname, "./src/index.ts"),
"@fusion/test-utils": resolve(__dirname, "./src/__test-utils__/workspace.ts"),
"@fusion/plugin-sdk": resolve(__dirname, "../plugin-sdk/src/index.ts"),
},
},
test: {
include: ["src/**/*.test.ts"],
exclude: quarantinedCoreTests,
setupFiles: [
"./src/__test-utils__/vitest-setup.ts",
],
globalSetup: ["./src/__test-utils__/vitest-teardown.ts"],
// Must stay "forks". Two thread-unsafe patterns block migration to "threads":
//
// 1. vitest-setup.ts:123 — `process.chdir(workerTempDir)` is gated by
// `isMainThread`, which is `false` in worker_threads, so each thread
// worker never gets its isolated cwd. Tests that rely on cwd being a
// disposable temp dir would silently operate in the repo root.
//
// 2. Some suites rely on fork-level process/env isolation for setup side effects,
// and cannot safely share mutable process state under worker_threads.
pool: "forks",
maxWorkers,
minWorkers: 1,
fileParallelism: true,
// Core runs a large SQLite-heavy suite while other workspace packages test concurrently.
// Use a slightly higher timeout to reduce nondeterministic slow-machine flakes.
testTimeout: 15_000,
hookTimeout: 15_000,
coverage: {
enabled: false,
reporter: ["text", "html", "json"],
reportsDirectory: "./coverage",
include: ["src/**/*.ts"],
exclude: ["**/*.test.ts", "**/*.d.ts", "dist/**"],
},
},
});