feat(FN-5411): add project identity recovery and identity-aware startup rea

Implements project identity tracking and recovery across the Fusion system (FN-5411), enabling persistent identity for projects across storage migrations, daemon reattaches, and CLI session management. Adds a project identity metadata API and central reattach ensure mechanism, wires identity stampin

Fusion-Task-Id: FN-5411

Co-authored-by: Fusion (runfusion.ai) <noreply@runfusion.ai>
Fusion-Task-Id: FN-5411
This commit is contained in:
gsxdsm
2026-05-23 04:11:09 -07:00
parent fe58a57a7d
commit 687237bd91
28 changed files with 1172 additions and 119 deletions

View File

@@ -221,6 +221,7 @@ function ensureProjectRegistered(opts) {
const nameLiteral = JSON.stringify(projectNameFromPackage());
const helper = `
import { CentralCore } from "./packages/core/src/central-core.ts";
import { readProjectIdentity, writeProjectIdentity } from "./packages/core/src/db.ts";
import { ensureMemoryFileWithBackend } from "./packages/core/src/project-memory.ts";
async function main() {
@@ -255,14 +256,29 @@ function ensureProjectRegistered(opts) {
name = baseName.slice(0, 64 - suffixText.length) + suffixText;
}
const project = await central.registerProject({
name,
const identity = readProjectIdentity(root);
const ensured = await central.ensureProjectForPath({
path: root,
isolationMode: "in-process",
identity: identity ? { id: identity.id, createdAt: identity.createdAt } : undefined,
name,
});
const project = ensured.project;
await central.updateProject(project.id, { status: "active" });
try {
writeProjectIdentity(root, {
id: project.id,
createdAt: project.createdAt,
firstSeenPath: root,
});
} catch {
// best effort
}
await ensureMemoryFileWithBackend(root).catch(() => false);
console.log("Registered project " + name);
if (ensured.outcome === "reattached") {
console.log("[start-local] Reattached project " + project.id + " at " + root + " using stored identity");
} else {
console.log("Registered project " + name);
}
} finally {
await central.close();
}