Spaces:
Paused
Paused
File size: 1,809 Bytes
a3aed04 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | /**
* TIA-∞ Resurrection Engine
* Analyzes lineage data to detect fragments, partial modules,
* abandoned structures, and missing siblings. Produces a safe,
* non-destructive proposal list for Guided Builder mode.
*/
import { LineageNode, LineageReport } from "./lineage";
export interface ResurrectionProposal {
path: string;
issue: string;
recommendedAction: string;
}
export interface ResurrectionPlan {
generatedAt: number;
proposals: ResurrectionProposal[];
}
function analyzeNode(node: LineageNode, proposals: ResurrectionProposal[]) {
// Detect empty files
if (node.anomalies?.includes("empty-file")) {
proposals.push({
path: node.path,
issue: "empty-file",
recommendedAction: "rebuild-file",
});
}
// Detect empty directories
if (node.anomalies?.includes("empty-directory")) {
proposals.push({
path: node.path,
issue: "empty-directory",
recommendedAction: "populate-directory",
});
}
// Detect missing siblings (heuristic)
if (node.inferredRole === "processing-layer" && !node.children) {
proposals.push({
path: node.path,
issue: "missing-engine-components",
recommendedAction: "reconstruct-engine-module",
});
}
// Detect suspicious naming drift
if (node.path.toLowerCase().includes("inde.x")) {
proposals.push({
path: node.path,
issue: "naming-drift",
recommendedAction: "rename-to-index.ts",
});
}
// Recurse
if (node.children) {
node.children.forEach((child) => analyzeNode(child, proposals));
}
}
export function generateResurrectionPlan(report: LineageReport): ResurrectionPlan {
const proposals: ResurrectionProposal[] = [];
analyzeNode(report.root, proposals);
return {
generatedAt: Date.now(),
proposals,
};
}
|