## Summary Fusion’s core runtime now treats PostgreSQL as the authoritative metadata store without leaving current CLI, dashboard, desktop, or engine composition roots uncompilable between stack layers. This is the 99-file foundation for the larger cutover: subsequent PRs migrate the remaining consumers, plugins, and operator surfaces. ## Design decisions - Runtime store construction fails closed when an asynchronous PostgreSQL layer is unavailable; SQLite remains readable only at explicit migration and identity-recovery boundaries. - Project ownership is enforced across active, archived, workflow, mission, analytics, and plugin-schema data. - The small set of cross-package files in this layer are compatibility-critical call sites required for a green intermediate commit, not the complete consumer migration. - Schema migration 0008 remains assigned to session-advisor state from current `main`; mission lineage idempotency advances to 0009 so neither invariant can be skipped. ## Validation - All affected package typechecks pass: Core, Engine, Dashboard, CLI, and Desktop. - `pnpm test:gate` passes: 478 tests across the engine gate, PostgreSQL core gate, and CLI workflow shape. - The PR changes exactly 99 files. ## Stack This is the base PR. Engine/dashboard, CLI/desktop/ops, plugins, and docs/release follow as stacked PRs, each below 100 changed files. Related: #2105 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * PostgreSQL is now the standard runtime backend, with embedded PostgreSQL enabled by default. * Added project-scoped storage for tasks, archives, chat sessions, missions, knowledge pages, and operational data. * Improved archived-task search, filtering, pagination, and restoration. * Added safer plugin schema initialization with validation and project isolation. * Added PostgreSQL-backed workflow, mission, validator, and dashboard capabilities. * **Bug Fixes** * Improved startup timeout cancellation and resource cleanup. * Prevented cross-project data access and phantom reservation cleanup errors. * Ensured archived tasks remain read-only and asynchronous writes complete reliably. * Retired SQLite opt-out settings with clear startup errors. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
import { existsSync, statSync } from "node:fs";
|
|
import { DatabaseSync } from "./sqlite-adapter.js";
|
|
|
|
/**
|
|
* Validate that a path points to a SQLite database file that can be opened.
|
|
*
|
|
* This legacy-migration probe is read-only. A zero-byte bootstrap file remains
|
|
* a valid migration signal, while non-existent, unreadable, or malformed files
|
|
* return false. PostgreSQL-era startup never creates or upgrades a SQLite file
|
|
* as a side effect of project discovery.
|
|
*/
|
|
export function isValidSqliteDatabaseFile(dbPath: string): boolean {
|
|
if (!existsSync(dbPath)) {
|
|
return false;
|
|
}
|
|
|
|
try {
|
|
if (!statSync(dbPath).isFile()) {
|
|
return false;
|
|
}
|
|
} catch {
|
|
return false;
|
|
}
|
|
|
|
let db: DatabaseSync | null = null;
|
|
try {
|
|
// FNXC:LegacySqliteBoundary 2026-07-14-18:42: validation may inspect a legacy migration input but must never mutate it.
|
|
db = new DatabaseSync(dbPath, { readOnly: true });
|
|
db.prepare("PRAGMA schema_version").get();
|
|
return true;
|
|
} catch {
|
|
return false;
|
|
} finally {
|
|
try {
|
|
db?.close();
|
|
} catch {
|
|
// Best-effort close only.
|
|
}
|
|
}
|
|
}
|