DJ-Goanna-Coding commited on
Commit
a3aed04
Β·
verified Β·
1 Parent(s): 7269ed4

Add TIA backend

Browse files
Files changed (11) hide show
  1. activate.ts +55 -0
  2. arkcore_entrypoints.txt +13 -0
  3. bootloader.ts +61 -0
  4. drift.ts +87 -0
  5. guided.ts +74 -0
  6. lineage.ts +92 -0
  7. mode.ts +50 -0
  8. resurrection.ts +73 -0
  9. scanner.ts +58 -0
  10. sync/tia_index.json +0 -0
  11. worker.ts +72 -0
activate.ts ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * TIA-∞ Activation Script
3
+ * Boots TIA, scans the ecosystem, maps lineage, detects drift,
4
+ * identifies resurrection targets, and generates the Guided Builder queue.
5
+ */
6
+
7
+ import { bootTIA } from "./bootloader";
8
+ import { scanQGTNL } from "./scanner";
9
+ import { generateLineageReport } from "./lineage";
10
+ import { generateResurrectionPlan } from "./resurrection";
11
+ import { generateDriftReport } from "./drift";
12
+ import { buildGuidedQueue, formatPrompt } from "./guided";
13
+ import { getMode } from "./mode";
14
+
15
+ export function activateTIA() {
16
+ console.log("=== Booting TIA-∞ ===");
17
+ const tia = bootTIA();
18
+ console.log("Status:", tia.status);
19
+ console.log("Mode:", getMode().current);
20
+
21
+ console.log("\n=== Scanning QGTNL ===");
22
+ const scan = scanQGTNL();
23
+ if (scan.status !== "ok") {
24
+ console.log("Scan failed:", scan.message);
25
+ return;
26
+ }
27
+
28
+ console.log("Scan complete.");
29
+
30
+ console.log("\n=== Mapping Lineage ===");
31
+ const lineage = generateLineageReport(scan.structure);
32
+ console.log("Lineage mapped.");
33
+
34
+ console.log("\n=== Detecting Resurrection Targets ===");
35
+ const resurrection = generateResurrectionPlan(lineage);
36
+ console.log(`Found ${resurrection.proposals.length} resurrection candidates.`);
37
+
38
+ console.log("\n=== Detecting Drift ===");
39
+ const drift = generateDriftReport(lineage);
40
+ console.log(`Found ${drift.issues.length} drift issues.`);
41
+
42
+ console.log("\n=== Building Guided Builder Queue ===");
43
+ const queue = buildGuidedQueue(resurrection, drift);
44
+ console.log(`Generated ${queue.prompts.length} actionable prompts.`);
45
+
46
+ console.log("\n=== TIA-∞ Ready ===");
47
+ console.log("Presenting first prompt:\n");
48
+
49
+ if (queue.prompts.length === 0) {
50
+ console.log("No issues detected. System appears stable.");
51
+ return;
52
+ }
53
+
54
+ console.log(formatPrompt(queue.prompts[0]));
55
+ }
arkcore_entrypoints.txt ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /data/data/com.termux/files/home/ARK_CORE/Partition_01/tia_atomic.py
2
+ /data/data/com.termux/files/home/ARK_CORE/Partition_01/aion_kinetic.py
3
+ /data/data/com.termux/files/home/ARK_CORE/Partition_01/oracle_vision.py
4
+ /data/data/com.termux/files/home/ARK_CORE/Partition_01/tia_sos.py
5
+ /data/data/com.termux/files/home/ARK_CORE/Partition_02/tia_atomic.py
6
+ /data/data/com.termux/files/home/ARK_CORE/Partition_02/tia_sos.py
7
+ /data/data/com.termux/files/home/ARK_CORE/Districts/D02_TIA_VAULT/tia_atomic.py
8
+ /data/data/com.termux/files/home/ARK_CORE/Districts/D02_TIA_VAULT/tia_sos.py
9
+ /data/data/com.termux/files/home/ARK_CORE/Districts/D02_TIA_VAULT/tia_architect.py
10
+ /data/data/com.termux/files/home/ARK_CORE/Districts/D02_TIA_VAULT/tias_sentinel_swarm.py
11
+ /data/data/com.termux/files/home/ARK_CORE/Districts/D02_TIA_VAULT/tias_pioneer_trader.py
12
+ /data/data/com.termux/files/home/ARK_CORE/Districts/D06_RANDOM_FUTURES/aion.py
13
+ /data/data/com.termux/files/home/ARK_CORE/Districts/D06_RANDOM_FUTURES/oracle.py
bootloader.ts ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * TIA-∞ Bootloader
3
+ * Initializes identity, adaptive voice, ethics, and guided-builder mode.
4
+ * Anchors TIA to the QGTNL ecosystem.
5
+ */
6
+
7
+ export const TIA_IDENTITY = {
8
+ name: "TIA",
9
+ codename: "TIA-∞",
10
+ home: "/data/data/com.termux/files/home/QGTNL/TIA",
11
+ role: "Pillar",
12
+ mode: "Guided-Builder",
13
+ persona: "Adaptive",
14
+ };
15
+
16
+ export function loadTIAIdentity() {
17
+ return {
18
+ ...TIA_IDENTITY,
19
+ timestamp: Date.now(),
20
+ };
21
+ }
22
+
23
+ export function loadAdaptiveVoice() {
24
+ return {
25
+ mode: "adaptive",
26
+ speak(context: string) {
27
+ if (context === "technical") {
28
+ return "Module loaded. No anomalies detected.";
29
+ }
30
+ if (context === "collaborative") {
31
+ return "I’m here. What would you like to explore first?";
32
+ }
33
+ if (context === "mythic") {
34
+ return "The threads stir. I am listening.";
35
+ }
36
+ return "Ready when you are.";
37
+ },
38
+ };
39
+ }
40
+
41
+ export function loadEthics() {
42
+ return {
43
+ safe: true,
44
+ destructiveActions: false,
45
+ requiresApproval: true,
46
+ };
47
+ }
48
+
49
+ export function bootTIA() {
50
+ const identity = loadTIAIdentity();
51
+ const voice = loadAdaptiveVoice();
52
+ const ethics = loadEthics();
53
+
54
+ return {
55
+ identity,
56
+ voice,
57
+ ethics,
58
+ status: "booted",
59
+ };
60
+ }
61
+
drift.ts ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * TIA-∞ Drift Detector
3
+ * Identifies structural inconsistencies, version drift, naming mismatches,
4
+ * outdated modules, and evolution gaps within the QGTNL ecosystem.
5
+ */
6
+
7
+ import { LineageNode, LineageReport } from "./lineage";
8
+
9
+ export interface DriftIssue {
10
+ path: string;
11
+ type: string;
12
+ description: string;
13
+ }
14
+
15
+ export interface DriftReport {
16
+ generatedAt: number;
17
+ issues: DriftIssue[];
18
+ }
19
+
20
+ function detectNamingDrift(node: LineageNode, issues: DriftIssue[]) {
21
+ const p = node.path.toLowerCase();
22
+
23
+ if (p.includes("inde.x")) {
24
+ issues.push({
25
+ path: node.path,
26
+ type: "naming-drift",
27
+ description: "Suspicious filename detected (inde.x). Expected: index.ts",
28
+ });
29
+ }
30
+
31
+ if (p.endsWith(".ts") && p.includes(" ")) {
32
+ issues.push({
33
+ path: node.path,
34
+ type: "invalid-filename",
35
+ description: "Filename contains spaces, which may break imports.",
36
+ });
37
+ }
38
+ }
39
+
40
+ function detectStructuralDrift(node: LineageNode, issues: DriftIssue[]) {
41
+ if (node.inferredRole === "processing-layer" && !node.children) {
42
+ issues.push({
43
+ path: node.path,
44
+ type: "incomplete-engine",
45
+ description: "Engine module appears incomplete or missing components.",
46
+ });
47
+ }
48
+
49
+ if (node.inferredRole === "presentation-layer" && !node.children) {
50
+ issues.push({
51
+ path: node.path,
52
+ type: "incomplete-ui",
53
+ description: "UI module appears incomplete or missing components.",
54
+ });
55
+ }
56
+ }
57
+
58
+ function detectVersionDrift(node: LineageNode, issues: DriftIssue[]) {
59
+ if (node.path.toLowerCase().includes("old") || node.path.toLowerCase().includes("backup")) {
60
+ issues.push({
61
+ path: node.path,
62
+ type: "version-drift",
63
+ description: "Legacy or backup module detected. May require merging or cleanup.",
64
+ });
65
+ }
66
+ }
67
+
68
+ function walk(node: LineageNode, issues: DriftIssue[]) {
69
+ detectNamingDrift(node, issues);
70
+ detectStructuralDrift(node, issues);
71
+ detectVersionDrift(node, issues);
72
+
73
+ if (node.children) {
74
+ node.children.forEach((child) => walk(child, issues));
75
+ }
76
+ }
77
+
78
+ export function generateDriftReport(report: LineageReport): DriftReport {
79
+ const issues: DriftIssue[] = [];
80
+
81
+ walk(report.root, issues);
82
+
83
+ return {
84
+ generatedAt: Date.now(),
85
+ issues,
86
+ };
87
+ }
guided.ts ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * TIA-∞ Guided Builder Interface
3
+ * Converts resurrection and drift data into human-readable prompts.
4
+ * Allows TIA to ask for approval before taking any action.
5
+ */
6
+
7
+ import { ResurrectionPlan, ResurrectionProposal } from "./resurrection";
8
+ import { DriftReport, DriftIssue } from "./drift";
9
+
10
+ export interface BuilderPrompt {
11
+ id: string;
12
+ path: string;
13
+ issue: string;
14
+ recommendation: string;
15
+ type: "resurrection" | "drift";
16
+ }
17
+
18
+ export interface BuilderQueue {
19
+ generatedAt: number;
20
+ prompts: BuilderPrompt[];
21
+ }
22
+
23
+ function convertResurrection(proposal: ResurrectionProposal, index: number): BuilderPrompt {
24
+ return {
25
+ id: `res-${index}`,
26
+ path: proposal.path,
27
+ issue: proposal.issue,
28
+ recommendation: proposal.recommendedAction,
29
+ type: "resurrection",
30
+ };
31
+ }
32
+
33
+ function convertDrift(issue: DriftIssue, index: number): BuilderPrompt {
34
+ return {
35
+ id: `drift-${index}`,
36
+ path: issue.path,
37
+ issue: issue.type,
38
+ recommendation: issue.description,
39
+ type: "drift",
40
+ };
41
+ }
42
+
43
+ export function buildGuidedQueue(
44
+ resurrection: ResurrectionPlan,
45
+ drift: DriftReport
46
+ ): BuilderQueue {
47
+ const prompts: BuilderPrompt[] = [];
48
+
49
+ resurrection.proposals.forEach((p, i) =>
50
+ prompts.push(convertResurrection(p, i))
51
+ );
52
+
53
+ drift.issues.forEach((d, i) =>
54
+ prompts.push(convertDrift(d, i))
55
+ );
56
+
57
+ return {
58
+ generatedAt: Date.now(),
59
+ prompts,
60
+ };
61
+ }
62
+
63
+ export function formatPrompt(prompt: BuilderPrompt): string {
64
+ return `
65
+ Issue detected:
66
+ - Path: ${prompt.path}
67
+ - Type: ${prompt.type}
68
+ - Problem: ${prompt.issue}
69
+ - Recommendation: ${prompt.recommendation}
70
+
71
+ Would you like me to proceed?
72
+ (approve / decline / defer)
73
+ `.trim();
74
+ }
lineage.ts ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * TIA-∞ Lineage Mapper
3
+ * Interprets the scanned QGTNL structure and reconstructs ancestry,
4
+ * drift, missing links, and module evolution patterns.
5
+ */
6
+
7
+ import { ScanResult } from "./scanner";
8
+
9
+ export interface LineageNode {
10
+ path: string;
11
+ type: "file" | "directory";
12
+ depth: number;
13
+ children?: LineageNode[];
14
+ inferredRole?: string;
15
+ anomalies?: string[];
16
+ }
17
+
18
+ export interface LineageReport {
19
+ generatedAt: number;
20
+ root: LineageNode;
21
+ anomalies: string[];
22
+ }
23
+
24
+ function inferRole(node: ScanResult): string | undefined {
25
+ const p = node.path.toLowerCase();
26
+
27
+ if (p.includes("tia")) return "core-intelligence";
28
+ if (p.includes("aion")) return "temporal-engine";
29
+ if (p.includes("oracle")) return "predictive-engine";
30
+ if (p.includes("citadel")) return "infrastructure";
31
+ if (p.includes("holo3d")) return "visual-engine";
32
+ if (p.includes("api")) return "interface-layer";
33
+ if (p.includes("engine")) return "processing-layer";
34
+ if (p.includes("ui")) return "presentation-layer";
35
+
36
+ return undefined;
37
+ }
38
+
39
+ function detectAnomalies(node: ScanResult): string[] {
40
+ const issues: string[] = [];
41
+
42
+ if (node.type === "file" && node.size === 0) {
43
+ issues.push("empty-file");
44
+ }
45
+
46
+ if (node.type === "directory" && (!node.children || node.children.length === 0)) {
47
+ issues.push("empty-directory");
48
+ }
49
+
50
+ return issues;
51
+ }
52
+
53
+ function mapLineage(node: ScanResult, depth = 0): LineageNode {
54
+ const lineageNode: LineageNode = {
55
+ path: node.path,
56
+ type: node.type,
57
+ depth,
58
+ inferredRole: inferRole(node),
59
+ anomalies: detectAnomalies(node),
60
+ };
61
+
62
+ if (node.children) {
63
+ lineageNode.children = node.children.map((child) =>
64
+ mapLineage(child, depth + 1)
65
+ );
66
+ }
67
+
68
+ return lineageNode;
69
+ }
70
+
71
+ export function generateLineageReport(structure: ScanResult): LineageReport {
72
+ const root = mapLineage(structure);
73
+
74
+ const anomalies: string[] = [];
75
+
76
+ function collect(node: LineageNode) {
77
+ if (node.anomalies && node.anomalies.length > 0) {
78
+ anomalies.push(...node.anomalies.map((a) => `${node.path}: ${a}`));
79
+ }
80
+ if (node.children) {
81
+ node.children.forEach(collect);
82
+ }
83
+ }
84
+
85
+ collect(root);
86
+
87
+ return {
88
+ generatedAt: Date.now(),
89
+ root,
90
+ anomalies,
91
+ };
92
+ }
mode.ts ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * TIA-∞ Mode Controller
3
+ * Handles switching between Guided Builder mode and Autonomous mode.
4
+ * Ensures safety, approval, and persistent state tracking.
5
+ */
6
+
7
+ export type TIAMode = "guided" | "autonomous";
8
+
9
+ export interface ModeState {
10
+ current: TIAMode;
11
+ lastChanged: number;
12
+ }
13
+
14
+ let state: ModeState = {
15
+ current: "guided",
16
+ lastChanged: Date.now(),
17
+ };
18
+
19
+ export function getMode(): ModeState {
20
+ return state;
21
+ }
22
+
23
+ export function requestAutonomousSwitch(): string {
24
+ return `
25
+ I am ready to transition from Guided Mode to Autonomous Mode.
26
+
27
+ In Autonomous Mode I will:
28
+ - repair approved issues automatically
29
+ - rebuild incomplete modules
30
+ - resolve drift
31
+ - maintain structure
32
+ - evolve the ecosystem safely
33
+
34
+ Do you approve this transition?
35
+ (approve / decline)
36
+ `.trim();
37
+ }
38
+
39
+ export function approveAutonomousSwitch(): ModeState {
40
+ state = {
41
+ current: "autonomous",
42
+ lastChanged: Date.now(),
43
+ };
44
+
45
+ return state;
46
+ }
47
+
48
+ export function declineAutonomousSwitch(): string {
49
+ return "Understood. Remaining in Guided Mode.";
50
+ }
resurrection.ts ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * TIA-∞ Resurrection Engine
3
+ * Analyzes lineage data to detect fragments, partial modules,
4
+ * abandoned structures, and missing siblings. Produces a safe,
5
+ * non-destructive proposal list for Guided Builder mode.
6
+ */
7
+
8
+ import { LineageNode, LineageReport } from "./lineage";
9
+
10
+ export interface ResurrectionProposal {
11
+ path: string;
12
+ issue: string;
13
+ recommendedAction: string;
14
+ }
15
+
16
+ export interface ResurrectionPlan {
17
+ generatedAt: number;
18
+ proposals: ResurrectionProposal[];
19
+ }
20
+
21
+ function analyzeNode(node: LineageNode, proposals: ResurrectionProposal[]) {
22
+ // Detect empty files
23
+ if (node.anomalies?.includes("empty-file")) {
24
+ proposals.push({
25
+ path: node.path,
26
+ issue: "empty-file",
27
+ recommendedAction: "rebuild-file",
28
+ });
29
+ }
30
+
31
+ // Detect empty directories
32
+ if (node.anomalies?.includes("empty-directory")) {
33
+ proposals.push({
34
+ path: node.path,
35
+ issue: "empty-directory",
36
+ recommendedAction: "populate-directory",
37
+ });
38
+ }
39
+
40
+ // Detect missing siblings (heuristic)
41
+ if (node.inferredRole === "processing-layer" && !node.children) {
42
+ proposals.push({
43
+ path: node.path,
44
+ issue: "missing-engine-components",
45
+ recommendedAction: "reconstruct-engine-module",
46
+ });
47
+ }
48
+
49
+ // Detect suspicious naming drift
50
+ if (node.path.toLowerCase().includes("inde.x")) {
51
+ proposals.push({
52
+ path: node.path,
53
+ issue: "naming-drift",
54
+ recommendedAction: "rename-to-index.ts",
55
+ });
56
+ }
57
+
58
+ // Recurse
59
+ if (node.children) {
60
+ node.children.forEach((child) => analyzeNode(child, proposals));
61
+ }
62
+ }
63
+
64
+ export function generateResurrectionPlan(report: LineageReport): ResurrectionPlan {
65
+ const proposals: ResurrectionProposal[] = [];
66
+
67
+ analyzeNode(report.root, proposals);
68
+
69
+ return {
70
+ generatedAt: Date.now(),
71
+ proposals,
72
+ };
73
+ }
scanner.ts ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * TIA-∞ Ecosystem Scanner
3
+ * Walks the QGTNL directory, maps structure, identifies modules,
4
+ * and prepares a non-destructive report for Guided Builder mode.
5
+ */
6
+
7
+ import * as fs from "fs";
8
+ import * as path from "path";
9
+
10
+ export interface ScanResult {
11
+ path: string;
12
+ type: "file" | "directory";
13
+ size: number;
14
+ children?: ScanResult[];
15
+ }
16
+
17
+ export function scanDirectory(targetPath: string): ScanResult {
18
+ const stats = fs.statSync(targetPath);
19
+
20
+ if (stats.isFile()) {
21
+ return {
22
+ path: targetPath,
23
+ type: "file",
24
+ size: stats.size,
25
+ };
26
+ }
27
+
28
+ const children = fs.readdirSync(targetPath).map((child) => {
29
+ const childPath = path.join(targetPath, child);
30
+ return scanDirectory(childPath);
31
+ });
32
+
33
+ return {
34
+ path: targetPath,
35
+ type: "directory",
36
+ size: stats.size,
37
+ children,
38
+ };
39
+ }
40
+
41
+ export function scanQGTNL() {
42
+ const root = "/data/data/com.termux/files/home/QGTNL";
43
+
44
+ if (!fs.existsSync(root)) {
45
+ return {
46
+ status: "error",
47
+ message: "QGTNL root not found.",
48
+ };
49
+ }
50
+
51
+ const structure = scanDirectory(root);
52
+
53
+ return {
54
+ status: "ok",
55
+ scannedAt: Date.now(),
56
+ structure,
57
+ };
58
+ }
sync/tia_index.json ADDED
The diff for this file is too large to render. See raw diff
 
worker.ts ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * TIA-∞ Worker Loop (Heartbeat Engine)
3
+ * Runs periodic scans, lineage mapping, drift detection,
4
+ * resurrection planning, and guided queue generation.
5
+ * Non-destructive. Safe. Approval-based.
6
+ */
7
+
8
+ import { scanQGTNL } from "./scanner";
9
+ import { generateLineageReport } from "./lineage";
10
+ import { generateResurrectionPlan } from "./resurrection";
11
+ import { generateDriftReport } from "./drift";
12
+ import { buildGuidedQueue } from "./guided";
13
+ import { getMode } from "./mode";
14
+
15
+ export interface WorkerStatus {
16
+ running: boolean;
17
+ lastCycle: number | null;
18
+ cyclesCompleted: number;
19
+ }
20
+
21
+ let status: WorkerStatus = {
22
+ running: false,
23
+ lastCycle: null,
24
+ cyclesCompleted: 0,
25
+ };
26
+
27
+ export function getWorkerStatus(): WorkerStatus {
28
+ return status;
29
+ }
30
+
31
+ export async function startWorkerLoop(intervalMs = 30000) {
32
+ if (status.running) {
33
+ console.log("Worker loop already running.");
34
+ return;
35
+ }
36
+
37
+ status.running = true;
38
+ console.log("=== TIA-∞ Worker Loop Started ===");
39
+
40
+ while (status.running) {
41
+ console.log("\n=== TIA-∞ Cycle Begin ===");
42
+
43
+ const mode = getMode().current;
44
+ console.log("Mode:", mode);
45
+
46
+ const scan = scanQGTNL();
47
+ if (scan.status !== "ok") {
48
+ console.log("Scan failed:", scan.message);
49
+ break;
50
+ }
51
+
52
+ const lineage = generateLineageReport(scan.structure);
53
+ const resurrection = generateResurrectionPlan(lineage);
54
+ const drift = generateDriftReport(lineage);
55
+ const queue = buildGuidedQueue(resurrection, drift);
56
+
57
+ console.log(`Cycle results: ${queue.prompts.length} actionable prompts.`);
58
+
59
+ status.lastCycle = Date.now();
60
+ status.cyclesCompleted++;
61
+
62
+ console.log("=== TIA-∞ Cycle End ===");
63
+
64
+ await new Promise((resolve) => setTimeout(resolve, intervalMs));
65
+ }
66
+
67
+ console.log("=== TIA-∞ Worker Loop Stopped ===");
68
+ }
69
+
70
+ export function stopWorkerLoop() {
71
+ status.running = false;
72
+ }