Files
fusion/packages/engine/src/worktree-db-hydrate.ts
gsxdsm ba1e82381e fix(FN-7952): cut runtime services over to PostgreSQL (#2109)
## Summary

Engine and dashboard traffic now stays on the authoritative PostgreSQL
layer across execution, recovery, project discovery, planning sessions,
analytics, and shutdown. The dashboard no longer presents a migration
notice for a cutover that is already mandatory.

## Design decisions

- Runtime composition requires an async data layer instead of
constructing a hidden SQLite fallback.
- Engine workflow, mission, claim, and self-healing reads await their
PostgreSQL-backed store contracts.
- Project-scoped dashboard stores retain and close their backend owner
exactly once.
- The dashboard test quarantine entry remains paired with its Vitest
exclusion, preserving the repository’s deletion-ratchet policy.

## Validation

- Core, Engine, Dashboard, CLI, and Desktop typechecks pass on the
stacked branch.
- `pnpm test:gate` passes all 478 gate tests.
- This PR changes 62 files.

## Stack

- Depends on #2108.
- CLI/desktop/ops, plugins, and docs/release follow in later PRs.

Related: #2105


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

## Summary by CodeRabbit

* **New Features**
* Project discovery now recognizes projects using the
`.fusion/project.json` marker.
* Knowledge indexing and search are more reliable across project-scoped
storage.
* **Bug Fixes**
* Improved session, audit timeline, approval, monitoring, and analytics
data consistency.
* Prevented stale planning-session updates and project-store shutdown
races.
* Ensured chat usage and CLI session status are saved before continuing.
* **UI Changes**
* Removed the storage migration notice banner now that the PostgreSQL
transition is complete.
* **Reliability**
* Improved shutdown handling, workflow execution, and worktree behavior.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-07-14 22:16:16 -07:00

39 lines
1.1 KiB
TypeScript

import type { TaskStore } from "@fusion/core";
export interface HydrateWorktreeDbParams {
rootDir: string;
worktreePath: string;
taskId: string;
store: Pick<TaskStore, "getTask">;
logger: { warn: (message: string) => void };
}
export interface HydrateWorktreeDbResult {
tasksCopied: number;
documentsCopied: number;
artifactsCopied: number;
degraded: boolean;
reason?: string;
}
/**
* FNXC:PostgresWorktreeStorage 2026-07-14-18:35:
* Executor worktrees share the project-scoped PostgreSQL store. Worktree
* acquisition must never create, open, or copy a local `.fusion/fusion.db`;
* task, document, and artifact visibility comes from the shared store and its
* project identity. The function remains as the acquisition seam so existing
* callers can record storage readiness without maintaining a SQLite fallback.
*/
export async function hydrateWorktreeDb({
rootDir,
worktreePath,
}: HydrateWorktreeDbParams): Promise<HydrateWorktreeDbResult> {
return {
tasksCopied: 0,
documentsCopied: 0,
artifactsCopied: 0,
degraded: false,
reason: rootDir === worktreePath ? "root_worktree" : "postgres_shared_store",
};
}