@mcp-graph-workflow/mcp-graph 5.29.1 → 5.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/router.d.ts.map +1 -1
- package/dist/api/router.js +2 -0
- package/dist/api/router.js.map +1 -1
- package/dist/api/routes/docs-reference.d.ts +3 -0
- package/dist/api/routes/docs-reference.d.ts.map +1 -1
- package/dist/api/routes/docs-reference.js +90 -28
- package/dist/api/routes/docs-reference.js.map +1 -1
- package/dist/api/routes/dream.d.ts +5 -0
- package/dist/api/routes/dream.d.ts.map +1 -0
- package/dist/api/routes/dream.js +142 -0
- package/dist/api/routes/dream.js.map +1 -0
- package/dist/core/docs/generate-docs-manifest.d.ts +22 -0
- package/dist/core/docs/generate-docs-manifest.d.ts.map +1 -0
- package/dist/core/docs/generate-docs-manifest.js +58 -0
- package/dist/core/docs/generate-docs-manifest.js.map +1 -0
- package/dist/core/dream/dream-engine.d.ts +40 -0
- package/dist/core/dream/dream-engine.d.ts.map +1 -0
- package/dist/core/dream/dream-engine.js +192 -0
- package/dist/core/dream/dream-engine.js.map +1 -0
- package/dist/core/dream/dream-store.d.ts +19 -0
- package/dist/core/dream/dream-store.d.ts.map +1 -0
- package/dist/core/dream/dream-store.js +86 -0
- package/dist/core/dream/dream-store.js.map +1 -0
- package/dist/core/dream/dream-types.d.ts +128 -0
- package/dist/core/dream/dream-types.d.ts.map +1 -0
- package/dist/core/dream/dream-types.js +99 -0
- package/dist/core/dream/dream-types.js.map +1 -0
- package/dist/core/dream/phases/nrem-phase.d.ts +21 -0
- package/dist/core/dream/phases/nrem-phase.d.ts.map +1 -0
- package/dist/core/dream/phases/nrem-phase.js +98 -0
- package/dist/core/dream/phases/nrem-phase.js.map +1 -0
- package/dist/core/dream/phases/rem-phase.d.ts +22 -0
- package/dist/core/dream/phases/rem-phase.d.ts.map +1 -0
- package/dist/core/dream/phases/rem-phase.js +87 -0
- package/dist/core/dream/phases/rem-phase.js.map +1 -0
- package/dist/core/dream/phases/wake-ready-phase.d.ts +24 -0
- package/dist/core/dream/phases/wake-ready-phase.d.ts.map +1 -0
- package/dist/core/dream/phases/wake-ready-phase.js +63 -0
- package/dist/core/dream/phases/wake-ready-phase.js.map +1 -0
- package/dist/core/events/event-types.d.ts +39 -1
- package/dist/core/events/event-types.d.ts.map +1 -1
- package/dist/core/store/migrations.d.ts.map +1 -1
- package/dist/core/store/migrations.js +30 -0
- package/dist/core/store/migrations.js.map +1 -1
- package/dist/docs-manifest.json +1237 -0
- package/dist/schemas/entity.schema.d.ts +2 -2
- package/dist/web/dashboard/dist/assets/{benchmark-tab-Dx9G7cqf.js → benchmark-tab-BD02uofm.js} +1 -1
- package/dist/web/dashboard/dist/assets/{circle-alert-B17sfIdw.js → circle-alert-RxlCxXj1.js} +1 -1
- package/dist/web/dashboard/dist/assets/context-tab-DTPFGxle.js +1 -0
- package/dist/web/dashboard/dist/assets/{docs-tab-sxC7Gxc7.js → docs-tab-2uo7-Ybt.js} +1 -1
- package/dist/web/dashboard/dist/assets/{gitnexus-tab-DEcNhLvY.js → gitnexus-tab-CiiNOf3e.js} +1 -1
- package/dist/web/dashboard/dist/assets/{graph-section-CsHifp70.js → graph-section-DKMay1zv.js} +1 -1
- package/dist/web/dashboard/dist/assets/{graph-tab-D8ZSUyGR.js → graph-tab-BYRVanTv.js} +1 -1
- package/dist/web/dashboard/dist/assets/{graph-utils-D10A5HwE.js → graph-utils-1O2cEKuy.js} +1 -1
- package/dist/web/dashboard/dist/assets/{index-07Y4UWP1.js → index-B5DzSMGg.js} +1 -1
- package/dist/web/dashboard/dist/assets/index-BxDGbcbB.css +1 -0
- package/dist/web/dashboard/dist/assets/{index-Dbaws8C6.js → index-CIhDR5rf.js} +26 -26
- package/dist/web/dashboard/dist/assets/{index-CVRN6scU.js → index-CSeiGgX8.js} +1 -1
- package/dist/web/dashboard/dist/assets/{insights-tab-DJAtypOr.js → insights-tab-DdI7TLP7.js} +1 -1
- package/dist/web/dashboard/dist/assets/{journey-tab-CXtDFeGm.js → journey-tab-CDuvIW6V.js} +1 -1
- package/dist/web/dashboard/dist/assets/{languages-tab-03j3C58E.js → languages-tab-CrbP4u3b.js} +1 -1
- package/dist/web/dashboard/dist/assets/{loader-circle-BNEIXs1s.js → loader-circle-Bl0DpM5P.js} +1 -1
- package/dist/web/dashboard/dist/assets/{logs-tab-D3BE923P.js → logs-tab-QYKxeHna.js} +1 -1
- package/dist/web/dashboard/dist/assets/{lsp-tab-cac4ysh4.js → lsp-tab-CLO4RFMh.js} +1 -1
- package/dist/web/dashboard/dist/assets/{memories-tab-BPJTM45d.js → memories-tab-BT7A7YOy.js} +1 -1
- package/dist/web/dashboard/dist/assets/{prd-backlog-tab-5PCpKm0j.js → prd-backlog-tab-M1j0tAm2.js} +1 -1
- package/dist/web/dashboard/dist/assets/{refresh-cw-CI2U4FGa.js → refresh-cw-0ApsgAym.js} +1 -1
- package/dist/web/dashboard/dist/assets/{siebel-tab-BuhOpZO3.js → siebel-tab-CsZz2y2b.js} +3 -3
- package/dist/web/dashboard/dist/assets/{skills-tab-BHWwOBtm.js → skills-tab-BrkrK7AC.js} +1 -1
- package/dist/web/dashboard/dist/assets/{style-BPgBTbDw.js → style-UgkJJqFQ.js} +1 -1
- package/dist/web/dashboard/dist/assets/{triangle-alert-aqoYdsgW.js → triangle-alert-BcgxNLLr.js} +1 -1
- package/dist/web/dashboard/dist/index.html +2 -2
- package/package.json +4 -3
- package/dist/web/dashboard/dist/assets/context-tab-BX2hlI9H.js +0 -1
- package/dist/web/dashboard/dist/assets/index-DVIgWBT4.css +0 -1
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DreamEngine — Central orchestrator for REM-inspired knowledge consolidation.
|
|
3
|
+
*
|
|
4
|
+
* Runs a three-phase "sleep cycle":
|
|
5
|
+
* Phase 1 (NREM): Replay + Decay + Prune
|
|
6
|
+
* Phase 2 (REM): Priority + Merge + Associate
|
|
7
|
+
* Phase 3 (Wake): Report + Synthesize + Cache Invalidation
|
|
8
|
+
*
|
|
9
|
+
* Emits events via GraphEventBus at each phase boundary.
|
|
10
|
+
* Persists results via dream-store.
|
|
11
|
+
*/
|
|
12
|
+
import { DreamCycleConfigSchema, DEFAULT_DREAM_CONFIG } from "./dream-types.js";
|
|
13
|
+
import { saveDreamCycle, updateDreamCycle } from "./dream-store.js";
|
|
14
|
+
import { runNremPhase } from "./phases/nrem-phase.js";
|
|
15
|
+
import { runRemPhase } from "./phases/rem-phase.js";
|
|
16
|
+
import { runWakeReadyPhase } from "./phases/wake-ready-phase.js";
|
|
17
|
+
import { generateId } from "../utils/id.js";
|
|
18
|
+
import { logger } from "../utils/logger.js";
|
|
19
|
+
export class DreamEngine {
|
|
20
|
+
db;
|
|
21
|
+
eventBus;
|
|
22
|
+
running = false;
|
|
23
|
+
currentPhase;
|
|
24
|
+
currentCycleId;
|
|
25
|
+
cancelled = false;
|
|
26
|
+
constructor(db, eventBus) {
|
|
27
|
+
this.db = db;
|
|
28
|
+
this.eventBus = eventBus;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Run a complete dream cycle (NREM → REM → Wake).
|
|
32
|
+
*/
|
|
33
|
+
async runCycle(configOverrides) {
|
|
34
|
+
const config = DreamCycleConfigSchema.parse({ ...DEFAULT_DREAM_CONFIG, ...configOverrides });
|
|
35
|
+
const cycleId = generateId("dream");
|
|
36
|
+
this.running = true;
|
|
37
|
+
this.currentCycleId = cycleId;
|
|
38
|
+
this.cancelled = false;
|
|
39
|
+
const startedAt = new Date().toISOString();
|
|
40
|
+
// Capture before-metrics
|
|
41
|
+
const beforeMetrics = this.getBeforeMetrics();
|
|
42
|
+
// Persist initial cycle record
|
|
43
|
+
const initialResult = {
|
|
44
|
+
id: cycleId,
|
|
45
|
+
startedAt,
|
|
46
|
+
completedAt: "",
|
|
47
|
+
status: "running",
|
|
48
|
+
config,
|
|
49
|
+
phases: {
|
|
50
|
+
nrem: { replayed: 0, scoresDecayed: 0, pruned: 0, archived: 0, durationMs: 0 },
|
|
51
|
+
rem: { priorityProcessed: 0, urgencyDecayed: 0, merged: 0, clustersFormed: 0, associationsCreated: 0, durationMs: 0 },
|
|
52
|
+
wakeReady: { freedTokens: 0, signalToNoise: 0, newGeneralizations: 0, durationMs: 0 },
|
|
53
|
+
},
|
|
54
|
+
summary: {
|
|
55
|
+
totalDocsBefore: beforeMetrics.totalDocs,
|
|
56
|
+
totalDocsAfter: 0,
|
|
57
|
+
avgQualityBefore: beforeMetrics.avgQuality,
|
|
58
|
+
avgQualityAfter: 0,
|
|
59
|
+
totalPruned: 0,
|
|
60
|
+
totalMerged: 0,
|
|
61
|
+
totalAssociations: 0,
|
|
62
|
+
freedCapacityEstimate: 0,
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
if (!config.dryRun) {
|
|
66
|
+
saveDreamCycle(this.db, initialResult);
|
|
67
|
+
}
|
|
68
|
+
this.emitEvent("dream:cycle_started", { cycleId, config: config });
|
|
69
|
+
try {
|
|
70
|
+
// ── Phase 1: NREM ──────────────────────────────────
|
|
71
|
+
this.currentPhase = "nrem";
|
|
72
|
+
this.emitEvent("dream:phase_started", { cycleId, phase: "nrem" });
|
|
73
|
+
const nremResult = runNremPhase(this.db, config, cycleId);
|
|
74
|
+
this.emitEvent("dream:phase_completed", { cycleId, phase: "nrem", durationMs: nremResult.durationMs });
|
|
75
|
+
if (this.cancelled)
|
|
76
|
+
return this.buildCancelledResult(cycleId, startedAt, config, nremResult, initialResult);
|
|
77
|
+
// ── Phase 2: REM ───────────────────────────────────
|
|
78
|
+
this.currentPhase = "rem";
|
|
79
|
+
this.emitEvent("dream:phase_started", { cycleId, phase: "rem" });
|
|
80
|
+
const remResult = runRemPhase(this.db, config, cycleId);
|
|
81
|
+
this.emitEvent("dream:phase_completed", { cycleId, phase: "rem", durationMs: remResult.durationMs });
|
|
82
|
+
if (this.cancelled)
|
|
83
|
+
return this.buildCancelledResult(cycleId, startedAt, config, nremResult, initialResult);
|
|
84
|
+
// ── Phase 3: Wake Ready ────────────────────────────
|
|
85
|
+
this.currentPhase = "wake-ready";
|
|
86
|
+
this.emitEvent("dream:phase_started", { cycleId, phase: "wake-ready" });
|
|
87
|
+
const wakeResult = runWakeReadyPhase(this.db, {
|
|
88
|
+
totalDocsBefore: beforeMetrics.totalDocs,
|
|
89
|
+
avgQualityBefore: beforeMetrics.avgQuality,
|
|
90
|
+
});
|
|
91
|
+
this.emitEvent("dream:phase_completed", { cycleId, phase: "wake-ready", durationMs: wakeResult.durationMs });
|
|
92
|
+
// ── Build final result ─────────────────────────────
|
|
93
|
+
const afterMetrics = this.getBeforeMetrics();
|
|
94
|
+
const completedAt = new Date().toISOString();
|
|
95
|
+
const totalDurationMs = nremResult.durationMs + remResult.durationMs + wakeResult.durationMs;
|
|
96
|
+
const result = {
|
|
97
|
+
id: cycleId,
|
|
98
|
+
startedAt,
|
|
99
|
+
completedAt,
|
|
100
|
+
status: "completed",
|
|
101
|
+
config,
|
|
102
|
+
phases: { nrem: nremResult, rem: remResult, wakeReady: wakeResult },
|
|
103
|
+
summary: {
|
|
104
|
+
totalDocsBefore: beforeMetrics.totalDocs,
|
|
105
|
+
totalDocsAfter: afterMetrics.totalDocs,
|
|
106
|
+
avgQualityBefore: beforeMetrics.avgQuality,
|
|
107
|
+
avgQualityAfter: afterMetrics.avgQuality,
|
|
108
|
+
totalPruned: nremResult.pruned,
|
|
109
|
+
totalMerged: remResult.merged,
|
|
110
|
+
totalAssociations: remResult.associationsCreated,
|
|
111
|
+
freedCapacityEstimate: wakeResult.freedTokens,
|
|
112
|
+
},
|
|
113
|
+
};
|
|
114
|
+
if (!config.dryRun) {
|
|
115
|
+
updateDreamCycle(this.db, result);
|
|
116
|
+
}
|
|
117
|
+
this.emitEvent("dream:cycle_completed", {
|
|
118
|
+
cycleId,
|
|
119
|
+
totalPruned: nremResult.pruned,
|
|
120
|
+
totalMerged: remResult.merged,
|
|
121
|
+
durationMs: totalDurationMs,
|
|
122
|
+
});
|
|
123
|
+
logger.info("dream:cycle:complete", { cycleId, durationMs: totalDurationMs });
|
|
124
|
+
return result;
|
|
125
|
+
}
|
|
126
|
+
catch (err) {
|
|
127
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
128
|
+
this.emitEvent("dream:cycle_failed", { cycleId, errorMessage });
|
|
129
|
+
logger.error("dream:cycle:failed", { cycleId, error: errorMessage });
|
|
130
|
+
throw err;
|
|
131
|
+
}
|
|
132
|
+
finally {
|
|
133
|
+
this.running = false;
|
|
134
|
+
this.currentPhase = undefined;
|
|
135
|
+
this.currentCycleId = undefined;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Cancel a running cycle. The cycle will stop after the current phase.
|
|
140
|
+
*/
|
|
141
|
+
cancelCycle() {
|
|
142
|
+
this.cancelled = true;
|
|
143
|
+
logger.info("dream:cycle:cancel_requested", { cycleId: this.currentCycleId });
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Get current engine status.
|
|
147
|
+
*/
|
|
148
|
+
getStatus() {
|
|
149
|
+
return {
|
|
150
|
+
running: this.running,
|
|
151
|
+
currentPhase: this.currentPhase,
|
|
152
|
+
progress: this.running ? this.estimateProgress() : undefined,
|
|
153
|
+
cycleId: this.currentCycleId,
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
// ── Private helpers ────────────────────────────────────
|
|
157
|
+
getBeforeMetrics() {
|
|
158
|
+
const row = this.db
|
|
159
|
+
.prepare("SELECT COUNT(*) as cnt, COALESCE(AVG(quality_score), 0) as avg_q FROM knowledge_documents")
|
|
160
|
+
.get();
|
|
161
|
+
return { totalDocs: row.cnt, avgQuality: row.avg_q };
|
|
162
|
+
}
|
|
163
|
+
estimateProgress() {
|
|
164
|
+
if (!this.currentPhase)
|
|
165
|
+
return 0;
|
|
166
|
+
const phaseProgress = {
|
|
167
|
+
"nrem": 0.33,
|
|
168
|
+
"rem": 0.66,
|
|
169
|
+
"wake-ready": 0.9,
|
|
170
|
+
};
|
|
171
|
+
return phaseProgress[this.currentPhase] ?? 0;
|
|
172
|
+
}
|
|
173
|
+
emitEvent(type, payload) {
|
|
174
|
+
this.eventBus.emit({
|
|
175
|
+
type,
|
|
176
|
+
timestamp: new Date().toISOString(),
|
|
177
|
+
payload,
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
buildCancelledResult(cycleId, startedAt, config, nremResult, initial) {
|
|
181
|
+
return {
|
|
182
|
+
...initial,
|
|
183
|
+
id: cycleId,
|
|
184
|
+
startedAt,
|
|
185
|
+
completedAt: new Date().toISOString(),
|
|
186
|
+
status: "cancelled",
|
|
187
|
+
config,
|
|
188
|
+
phases: { ...initial.phases, nrem: nremResult },
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
//# sourceMappingURL=dream-engine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dream-engine.js","sourceRoot":"","sources":["../../../src/core/dream/dream-engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAChF,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAGjE,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,MAAM,OAAO,WAAW;IACd,EAAE,CAAoB;IACtB,QAAQ,CAAgB;IACxB,OAAO,GAAG,KAAK,CAAC;IAChB,YAAY,CAAyB;IACrC,cAAc,CAAqB;IACnC,SAAS,GAAG,KAAK,CAAC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MAAwB,EACxB,UAA8C,EAC9C,OAAyB;QAEzB,OAAO;YACL,GAAG,OAAO;YACV,EAAE,EAAE,OAAO;YACX,SAAS;YACT,WAAW,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACrC,MAAM,EAAE,WAAW;YACnB,MAAM;YACN,MAAM,EAAE,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE;SAChD,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type Database from "better-sqlite3";
|
|
2
|
+
import type { DreamCycleResult } from "./dream-types.js";
|
|
3
|
+
export interface DreamArchiveEntry {
|
|
4
|
+
id: string;
|
|
5
|
+
originalDocId: string;
|
|
6
|
+
title: string;
|
|
7
|
+
sourceType: string;
|
|
8
|
+
qualityScore: number | null;
|
|
9
|
+
reason: "pruned" | "merged" | "archived";
|
|
10
|
+
archivedAt: string;
|
|
11
|
+
cycleId: string;
|
|
12
|
+
}
|
|
13
|
+
export declare function saveDreamCycle(db: Database.Database, cycle: DreamCycleResult): void;
|
|
14
|
+
export declare function updateDreamCycle(db: Database.Database, cycle: DreamCycleResult): void;
|
|
15
|
+
export declare function getDreamCycle(db: Database.Database, id: string): DreamCycleResult | null;
|
|
16
|
+
export declare function listDreamCycles(db: Database.Database, limit?: number): DreamCycleResult[];
|
|
17
|
+
export declare function archiveDreamDoc(db: Database.Database, entry: DreamArchiveEntry): void;
|
|
18
|
+
export declare function listDreamArchive(db: Database.Database, cycleId: string): DreamArchiveEntry[];
|
|
19
|
+
//# sourceMappingURL=dream-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dream-store.d.ts","sourceRoot":"","sources":["../../../src/core/dream/dream-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAC3C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAKzD,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,MAAM,EAAE,QAAQ,GAAG,QAAQ,GAAG,UAAU,CAAC;IACzC,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;CACjB;AA2BD,wBAAgB,cAAc,CAAC,EAAE,EAAE,QAAQ,CAAC,QAAQ,EAAE,KAAK,EAAE,gBAAgB,GAAG,IAAI,CAenF;AAID,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,QAAQ,CAAC,QAAQ,EAAE,KAAK,EAAE,gBAAgB,GAAG,IAAI,CAcrF;AAID,wBAAgB,aAAa,CAAC,EAAE,EAAE,QAAQ,CAAC,QAAQ,EAAE,EAAE,EAAE,MAAM,GAAG,gBAAgB,GAAG,IAAI,CAIxF;AAID,wBAAgB,eAAe,CAAC,EAAE,EAAE,QAAQ,CAAC,QAAQ,EAAE,KAAK,GAAE,MAAW,GAAG,gBAAgB,EAAE,CAK7F;AAID,wBAAgB,eAAe,CAAC,EAAE,EAAE,QAAQ,CAAC,QAAQ,EAAE,KAAK,EAAE,iBAAiB,GAAG,IAAI,CAgBrF;AAID,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,QAAQ,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,GAAG,iBAAiB,EAAE,CAK5F"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { logger } from "../utils/logger.js";
|
|
2
|
+
// ─── Save a new dream cycle ───
|
|
3
|
+
export function saveDreamCycle(db, cycle) {
|
|
4
|
+
const stmt = db.prepare(`
|
|
5
|
+
INSERT INTO dream_cycles (id, status, config, result, started_at, completed_at, error_message)
|
|
6
|
+
VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
7
|
+
`);
|
|
8
|
+
stmt.run(cycle.id, cycle.status, JSON.stringify(cycle.config), JSON.stringify({ phases: cycle.phases, summary: cycle.summary }), cycle.startedAt, cycle.completedAt || null, null);
|
|
9
|
+
logger.debug("dream-store:save", { cycleId: cycle.id, status: cycle.status });
|
|
10
|
+
}
|
|
11
|
+
// ─── Update an existing dream cycle ───
|
|
12
|
+
export function updateDreamCycle(db, cycle) {
|
|
13
|
+
const stmt = db.prepare(`
|
|
14
|
+
UPDATE dream_cycles
|
|
15
|
+
SET status = ?, result = ?, completed_at = ?, error_message = ?
|
|
16
|
+
WHERE id = ?
|
|
17
|
+
`);
|
|
18
|
+
stmt.run(cycle.status, JSON.stringify({ phases: cycle.phases, summary: cycle.summary }), cycle.completedAt || null, null, cycle.id);
|
|
19
|
+
logger.debug("dream-store:update", { cycleId: cycle.id, status: cycle.status });
|
|
20
|
+
}
|
|
21
|
+
// ─── Get a single dream cycle by ID ───
|
|
22
|
+
export function getDreamCycle(db, id) {
|
|
23
|
+
const row = db.prepare("SELECT * FROM dream_cycles WHERE id = ?").get(id);
|
|
24
|
+
if (!row)
|
|
25
|
+
return null;
|
|
26
|
+
return rowToCycleResult(row);
|
|
27
|
+
}
|
|
28
|
+
// ─── List dream cycles (most recent first) ───
|
|
29
|
+
export function listDreamCycles(db, limit = 50) {
|
|
30
|
+
const rows = db
|
|
31
|
+
.prepare("SELECT * FROM dream_cycles ORDER BY started_at DESC LIMIT ?")
|
|
32
|
+
.all(limit);
|
|
33
|
+
return rows.map(rowToCycleResult);
|
|
34
|
+
}
|
|
35
|
+
// ─── Archive a document (soft-delete tracking) ───
|
|
36
|
+
export function archiveDreamDoc(db, entry) {
|
|
37
|
+
const stmt = db.prepare(`
|
|
38
|
+
INSERT INTO dream_archive (id, original_doc_id, title, source_type, quality_score, reason, archived_at, cycle_id)
|
|
39
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
|
40
|
+
`);
|
|
41
|
+
stmt.run(entry.id, entry.originalDocId, entry.title, entry.sourceType, entry.qualityScore, entry.reason, entry.archivedAt, entry.cycleId);
|
|
42
|
+
logger.debug("dream-store:archive", { docId: entry.originalDocId, reason: entry.reason });
|
|
43
|
+
}
|
|
44
|
+
// ─── List archived docs for a cycle ───
|
|
45
|
+
export function listDreamArchive(db, cycleId) {
|
|
46
|
+
const rows = db
|
|
47
|
+
.prepare("SELECT * FROM dream_archive WHERE cycle_id = ? ORDER BY archived_at ASC")
|
|
48
|
+
.all(cycleId);
|
|
49
|
+
return rows.map(rowToArchiveEntry);
|
|
50
|
+
}
|
|
51
|
+
// ─── Internal converters ───
|
|
52
|
+
function rowToCycleResult(row) {
|
|
53
|
+
const config = JSON.parse(row.config);
|
|
54
|
+
const resultData = row.result ? JSON.parse(row.result) : null;
|
|
55
|
+
return {
|
|
56
|
+
id: row.id,
|
|
57
|
+
startedAt: row.started_at,
|
|
58
|
+
completedAt: row.completed_at ?? "",
|
|
59
|
+
status: row.status,
|
|
60
|
+
config,
|
|
61
|
+
phases: resultData?.phases ?? {
|
|
62
|
+
nrem: { replayed: 0, scoresDecayed: 0, pruned: 0, archived: 0, durationMs: 0 },
|
|
63
|
+
rem: { priorityProcessed: 0, urgencyDecayed: 0, merged: 0, clustersFormed: 0, associationsCreated: 0, durationMs: 0 },
|
|
64
|
+
wakeReady: { freedTokens: 0, signalToNoise: 0, newGeneralizations: 0, durationMs: 0 },
|
|
65
|
+
},
|
|
66
|
+
summary: resultData?.summary ?? {
|
|
67
|
+
totalDocsBefore: 0, totalDocsAfter: 0,
|
|
68
|
+
avgQualityBefore: 0, avgQualityAfter: 0,
|
|
69
|
+
totalPruned: 0, totalMerged: 0,
|
|
70
|
+
totalAssociations: 0, freedCapacityEstimate: 0,
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function rowToArchiveEntry(row) {
|
|
75
|
+
return {
|
|
76
|
+
id: row.id,
|
|
77
|
+
originalDocId: row.original_doc_id,
|
|
78
|
+
title: row.title,
|
|
79
|
+
sourceType: row.source_type,
|
|
80
|
+
qualityScore: row.quality_score,
|
|
81
|
+
reason: row.reason,
|
|
82
|
+
archivedAt: row.archived_at,
|
|
83
|
+
cycleId: row.cycle_id,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=dream-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dream-store.js","sourceRoot":"","sources":["../../../src/core/dream/dream-store.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAsC5C,iCAAiC;AAEjC,MAAM,UAAU,cAAc,CAAC,EAAqB,EAAE,KAAuB;IAC3E,MAAM,IAAI,GAAG,EAAE,CAAC,OAAO,CAAC;;;GAGvB,CAAC,CAAC;IACH,IAAI,CAAC,GAAG,CACN,KAAK,CAAC,EAAE,EACR,KAAK,CAAC,MAAM,EACZ,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC,EAC5B,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,EAChE,KAAK,CAAC,SAAS,EACf,KAAK,CAAC,WAAW,IAAI,IAAI,EACzB,IAAI,CACL,CAAC;IACF,MAAM,CAAC,KAAK,CAAC,kBAAkB,EAAE,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;AAChF,CAAC;AAED,yCAAyC;AAEzC,MAAM,UAAU,gBAAgB,CAAC,EAAqB,EAAE,KAAuB;IAC7E,MAAM,IAAI,GAAG,EAAE,CAAC,OAAO,CAAC;;;;GAIvB,CAAC,CAAC;IACH,IAAI,CAAC,GAAG,CACN,KAAK,CAAC,MAAM,EACZ,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC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,OAAO,IAAI;YAC9B,eAAe,EAAE,CAAC,EAAE,cAAc,EAAE,CAAC;YACrC,gBAAgB,EAAE,CAAC,EAAE,eAAe,EAAE,CAAC;YACvC,WAAW,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC;YAC9B,iBAAiB,EAAE,CAAC,EAAE,qBAAqB,EAAE,CAAC;SAC/C;KACF,CAAC;AACJ,CAAC;AAED,SAAS,iBAAiB,CAAC,GAAe;IACxC,OAAO;QACL,EAAE,EAAE,GAAG,CAAC,EAAE;QACV,aAAa,EAAE,GAAG,CAAC,eAAe;QAClC,KAAK,EAAE,GAAG,CAAC,KAAK;QAChB,UAAU,EAAE,GAAG,CAAC,WAAW;QAC3B,YAAY,EAAE,GAAG,CAAC,aAAa;QAC/B,MAAM,EAAE,GAAG,CAAC,MAAqC;QACjD,UAAU,EAAE,GAAG,CAAC,WAAW;QAC3B,OAAO,EAAE,GAAG,CAAC,QAAQ;KACtB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { z } from "zod/v4";
|
|
2
|
+
export declare const DreamPhaseSchema: z.ZodEnum<{
|
|
3
|
+
nrem: "nrem";
|
|
4
|
+
rem: "rem";
|
|
5
|
+
"wake-ready": "wake-ready";
|
|
6
|
+
}>;
|
|
7
|
+
export type DreamPhase = z.infer<typeof DreamPhaseSchema>;
|
|
8
|
+
export declare const DreamCycleStatusSchema: z.ZodEnum<{
|
|
9
|
+
failed: "failed";
|
|
10
|
+
idle: "idle";
|
|
11
|
+
running: "running";
|
|
12
|
+
completed: "completed";
|
|
13
|
+
cancelled: "cancelled";
|
|
14
|
+
}>;
|
|
15
|
+
export type DreamCycleStatus = z.infer<typeof DreamCycleStatusSchema>;
|
|
16
|
+
export declare const DreamCycleConfigSchema: z.ZodObject<{
|
|
17
|
+
pruneThreshold: z.ZodDefault<z.ZodNumber>;
|
|
18
|
+
decayFactor: z.ZodDefault<z.ZodNumber>;
|
|
19
|
+
urgencyDecayFactor: z.ZodDefault<z.ZodNumber>;
|
|
20
|
+
maxReplayBatch: z.ZodDefault<z.ZodNumber>;
|
|
21
|
+
mergeSimThreshold: z.ZodDefault<z.ZodNumber>;
|
|
22
|
+
associationBoostFactor: z.ZodDefault<z.ZodNumber>;
|
|
23
|
+
dryRun: z.ZodDefault<z.ZodBoolean>;
|
|
24
|
+
}, z.core.$strip>;
|
|
25
|
+
export type DreamCycleConfig = z.infer<typeof DreamCycleConfigSchema>;
|
|
26
|
+
export declare const DEFAULT_DREAM_CONFIG: DreamCycleConfig;
|
|
27
|
+
export declare const NremPhaseResultSchema: z.ZodObject<{
|
|
28
|
+
replayed: z.ZodNumber;
|
|
29
|
+
scoresDecayed: z.ZodNumber;
|
|
30
|
+
pruned: z.ZodNumber;
|
|
31
|
+
archived: z.ZodNumber;
|
|
32
|
+
durationMs: z.ZodNumber;
|
|
33
|
+
}, z.core.$strip>;
|
|
34
|
+
export type NremPhaseResult = z.infer<typeof NremPhaseResultSchema>;
|
|
35
|
+
export declare const RemPhaseResultSchema: z.ZodObject<{
|
|
36
|
+
priorityProcessed: z.ZodNumber;
|
|
37
|
+
urgencyDecayed: z.ZodNumber;
|
|
38
|
+
merged: z.ZodNumber;
|
|
39
|
+
clustersFormed: z.ZodNumber;
|
|
40
|
+
associationsCreated: z.ZodNumber;
|
|
41
|
+
durationMs: z.ZodNumber;
|
|
42
|
+
}, z.core.$strip>;
|
|
43
|
+
export type RemPhaseResult = z.infer<typeof RemPhaseResultSchema>;
|
|
44
|
+
export declare const WakeReadyResultSchema: z.ZodObject<{
|
|
45
|
+
freedTokens: z.ZodNumber;
|
|
46
|
+
signalToNoise: z.ZodNumber;
|
|
47
|
+
newGeneralizations: z.ZodNumber;
|
|
48
|
+
durationMs: z.ZodNumber;
|
|
49
|
+
}, z.core.$strip>;
|
|
50
|
+
export type WakeReadyResult = z.infer<typeof WakeReadyResultSchema>;
|
|
51
|
+
export declare const DreamSummarySchema: z.ZodObject<{
|
|
52
|
+
totalDocsBefore: z.ZodNumber;
|
|
53
|
+
totalDocsAfter: z.ZodNumber;
|
|
54
|
+
avgQualityBefore: z.ZodNumber;
|
|
55
|
+
avgQualityAfter: z.ZodNumber;
|
|
56
|
+
totalPruned: z.ZodNumber;
|
|
57
|
+
totalMerged: z.ZodNumber;
|
|
58
|
+
totalAssociations: z.ZodNumber;
|
|
59
|
+
freedCapacityEstimate: z.ZodNumber;
|
|
60
|
+
}, z.core.$strip>;
|
|
61
|
+
export type DreamSummary = z.infer<typeof DreamSummarySchema>;
|
|
62
|
+
export declare const DreamCycleResultSchema: z.ZodObject<{
|
|
63
|
+
id: z.ZodString;
|
|
64
|
+
startedAt: z.ZodString;
|
|
65
|
+
completedAt: z.ZodString;
|
|
66
|
+
status: z.ZodEnum<{
|
|
67
|
+
failed: "failed";
|
|
68
|
+
idle: "idle";
|
|
69
|
+
running: "running";
|
|
70
|
+
completed: "completed";
|
|
71
|
+
cancelled: "cancelled";
|
|
72
|
+
}>;
|
|
73
|
+
config: z.ZodObject<{
|
|
74
|
+
pruneThreshold: z.ZodDefault<z.ZodNumber>;
|
|
75
|
+
decayFactor: z.ZodDefault<z.ZodNumber>;
|
|
76
|
+
urgencyDecayFactor: z.ZodDefault<z.ZodNumber>;
|
|
77
|
+
maxReplayBatch: z.ZodDefault<z.ZodNumber>;
|
|
78
|
+
mergeSimThreshold: z.ZodDefault<z.ZodNumber>;
|
|
79
|
+
associationBoostFactor: z.ZodDefault<z.ZodNumber>;
|
|
80
|
+
dryRun: z.ZodDefault<z.ZodBoolean>;
|
|
81
|
+
}, z.core.$strip>;
|
|
82
|
+
phases: z.ZodObject<{
|
|
83
|
+
nrem: z.ZodObject<{
|
|
84
|
+
replayed: z.ZodNumber;
|
|
85
|
+
scoresDecayed: z.ZodNumber;
|
|
86
|
+
pruned: z.ZodNumber;
|
|
87
|
+
archived: z.ZodNumber;
|
|
88
|
+
durationMs: z.ZodNumber;
|
|
89
|
+
}, z.core.$strip>;
|
|
90
|
+
rem: z.ZodObject<{
|
|
91
|
+
priorityProcessed: z.ZodNumber;
|
|
92
|
+
urgencyDecayed: z.ZodNumber;
|
|
93
|
+
merged: z.ZodNumber;
|
|
94
|
+
clustersFormed: z.ZodNumber;
|
|
95
|
+
associationsCreated: z.ZodNumber;
|
|
96
|
+
durationMs: z.ZodNumber;
|
|
97
|
+
}, z.core.$strip>;
|
|
98
|
+
wakeReady: z.ZodObject<{
|
|
99
|
+
freedTokens: z.ZodNumber;
|
|
100
|
+
signalToNoise: z.ZodNumber;
|
|
101
|
+
newGeneralizations: z.ZodNumber;
|
|
102
|
+
durationMs: z.ZodNumber;
|
|
103
|
+
}, z.core.$strip>;
|
|
104
|
+
}, z.core.$strip>;
|
|
105
|
+
summary: z.ZodObject<{
|
|
106
|
+
totalDocsBefore: z.ZodNumber;
|
|
107
|
+
totalDocsAfter: z.ZodNumber;
|
|
108
|
+
avgQualityBefore: z.ZodNumber;
|
|
109
|
+
avgQualityAfter: z.ZodNumber;
|
|
110
|
+
totalPruned: z.ZodNumber;
|
|
111
|
+
totalMerged: z.ZodNumber;
|
|
112
|
+
totalAssociations: z.ZodNumber;
|
|
113
|
+
freedCapacityEstimate: z.ZodNumber;
|
|
114
|
+
}, z.core.$strip>;
|
|
115
|
+
}, z.core.$strip>;
|
|
116
|
+
export type DreamCycleResult = z.infer<typeof DreamCycleResultSchema>;
|
|
117
|
+
export declare const DreamStatusSchema: z.ZodObject<{
|
|
118
|
+
running: z.ZodBoolean;
|
|
119
|
+
currentPhase: z.ZodOptional<z.ZodEnum<{
|
|
120
|
+
nrem: "nrem";
|
|
121
|
+
rem: "rem";
|
|
122
|
+
"wake-ready": "wake-ready";
|
|
123
|
+
}>>;
|
|
124
|
+
progress: z.ZodOptional<z.ZodNumber>;
|
|
125
|
+
cycleId: z.ZodOptional<z.ZodString>;
|
|
126
|
+
}, z.core.$strip>;
|
|
127
|
+
export type DreamStatus = z.infer<typeof DreamStatusSchema>;
|
|
128
|
+
//# sourceMappingURL=dream-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AAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAItE,eAAO,MAAM,iBAAiB;;;;;;;;;iBAK5B,CAAC;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { z } from "zod/v4";
|
|
2
|
+
// ─── Dream Phase (maps to biological sleep phases) ───
|
|
3
|
+
export const DreamPhaseSchema = z.enum(["nrem", "rem", "wake-ready"]);
|
|
4
|
+
// ─── Dream Cycle Status ───
|
|
5
|
+
export const DreamCycleStatusSchema = z.enum([
|
|
6
|
+
"idle",
|
|
7
|
+
"running",
|
|
8
|
+
"completed",
|
|
9
|
+
"failed",
|
|
10
|
+
"cancelled",
|
|
11
|
+
]);
|
|
12
|
+
// ─── Dream Cycle Config (tunable parameters) ───
|
|
13
|
+
export const DreamCycleConfigSchema = z.object({
|
|
14
|
+
/** Quality score below which docs are pruned (0-1) */
|
|
15
|
+
pruneThreshold: z.number().min(0).max(1).default(0.15),
|
|
16
|
+
/** Proportional downscale factor per cycle (0-1) */
|
|
17
|
+
decayFactor: z.number().min(0).max(1).default(0.85),
|
|
18
|
+
/** Separate urgency decay factor (0-1) */
|
|
19
|
+
urgencyDecayFactor: z.number().min(0).max(1).default(0.7),
|
|
20
|
+
/** Max docs to replay per NREM phase */
|
|
21
|
+
maxReplayBatch: z.number().int().positive().default(200),
|
|
22
|
+
/** Cosine similarity threshold for merging (0-1) */
|
|
23
|
+
mergeSimThreshold: z.number().min(0).max(1).default(0.92),
|
|
24
|
+
/** Co-access association strength boost (0-0.5) */
|
|
25
|
+
associationBoostFactor: z.number().min(0).max(0.5).default(0.1),
|
|
26
|
+
/** Preview mode — no mutations */
|
|
27
|
+
dryRun: z.boolean().default(false),
|
|
28
|
+
});
|
|
29
|
+
export const DEFAULT_DREAM_CONFIG = DreamCycleConfigSchema.parse({});
|
|
30
|
+
// ─── Phase Results ───
|
|
31
|
+
export const NremPhaseResultSchema = z.object({
|
|
32
|
+
/** Docs replayed (recordAccess called) */
|
|
33
|
+
replayed: z.number().int().min(0),
|
|
34
|
+
/** Docs with quality scores downscaled */
|
|
35
|
+
scoresDecayed: z.number().int().min(0),
|
|
36
|
+
/** Docs below threshold removed */
|
|
37
|
+
pruned: z.number().int().min(0),
|
|
38
|
+
/** Docs archived (soft-deleted) */
|
|
39
|
+
archived: z.number().int().min(0),
|
|
40
|
+
/** Phase duration in milliseconds */
|
|
41
|
+
durationMs: z.number().min(0),
|
|
42
|
+
});
|
|
43
|
+
export const RemPhaseResultSchema = z.object({
|
|
44
|
+
/** Error/blocker tagged items re-consolidated */
|
|
45
|
+
priorityProcessed: z.number().int().min(0),
|
|
46
|
+
/** Urgency signals decayed */
|
|
47
|
+
urgencyDecayed: z.number().int().min(0),
|
|
48
|
+
/** Similar entries merged */
|
|
49
|
+
merged: z.number().int().min(0),
|
|
50
|
+
/** Re-clustering result */
|
|
51
|
+
clustersFormed: z.number().int().min(0),
|
|
52
|
+
/** Co-access links strengthened */
|
|
53
|
+
associationsCreated: z.number().int().min(0),
|
|
54
|
+
/** Phase duration in milliseconds */
|
|
55
|
+
durationMs: z.number().min(0),
|
|
56
|
+
});
|
|
57
|
+
export const WakeReadyResultSchema = z.object({
|
|
58
|
+
/** Estimated tokens freed */
|
|
59
|
+
freedTokens: z.number().min(0),
|
|
60
|
+
/** Before/after quality ratio */
|
|
61
|
+
signalToNoise: z.number().min(0),
|
|
62
|
+
/** Cross-memory synthesis docs created */
|
|
63
|
+
newGeneralizations: z.number().int().min(0),
|
|
64
|
+
/** Phase duration in milliseconds */
|
|
65
|
+
durationMs: z.number().min(0),
|
|
66
|
+
});
|
|
67
|
+
// ─── Dream Summary ───
|
|
68
|
+
export const DreamSummarySchema = z.object({
|
|
69
|
+
totalDocsBefore: z.number().int().min(0),
|
|
70
|
+
totalDocsAfter: z.number().int().min(0),
|
|
71
|
+
avgQualityBefore: z.number().min(0).max(1),
|
|
72
|
+
avgQualityAfter: z.number().min(0).max(1),
|
|
73
|
+
totalPruned: z.number().int().min(0),
|
|
74
|
+
totalMerged: z.number().int().min(0),
|
|
75
|
+
totalAssociations: z.number().int().min(0),
|
|
76
|
+
freedCapacityEstimate: z.number().min(0),
|
|
77
|
+
});
|
|
78
|
+
// ─── Dream Cycle Result ───
|
|
79
|
+
export const DreamCycleResultSchema = z.object({
|
|
80
|
+
id: z.string(),
|
|
81
|
+
startedAt: z.string(),
|
|
82
|
+
completedAt: z.string(),
|
|
83
|
+
status: DreamCycleStatusSchema,
|
|
84
|
+
config: DreamCycleConfigSchema,
|
|
85
|
+
phases: z.object({
|
|
86
|
+
nrem: NremPhaseResultSchema,
|
|
87
|
+
rem: RemPhaseResultSchema,
|
|
88
|
+
wakeReady: WakeReadyResultSchema,
|
|
89
|
+
}),
|
|
90
|
+
summary: DreamSummarySchema,
|
|
91
|
+
});
|
|
92
|
+
// ─── Dream Status (runtime state) ───
|
|
93
|
+
export const DreamStatusSchema = z.object({
|
|
94
|
+
running: z.boolean(),
|
|
95
|
+
currentPhase: DreamPhaseSchema.optional(),
|
|
96
|
+
progress: z.number().min(0).max(1).optional(),
|
|
97
|
+
cycleId: z.string().optional(),
|
|
98
|
+
});
|
|
99
|
+
//# sourceMappingURL=dream-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dream-types.js","sourceRoot":"","sources":["../../../src/core/dream/dream-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAE3B,wDAAwD;AAExD,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC;AAGtE,6BAA6B;AAE7B,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC,IAAI,CAAC;IAC3C,MAAM;IACN,SAAS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IAC1C,qBAAqB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CACzC,CAAC,CAAC;AAGH,6BAA6B;AAE7B,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC7C,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;IACd,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;IACrB,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;IACvB,MAAM,EAAE,sBAAsB;IAC9B,MAAM,EAAE,sBAAsB;IAC9B,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;QACf,IAAI,EAAE,qBAAqB;QAC3B,GAAG,EAAE,oBAAoB;QACzB,SAAS,EAAE,qBAAqB;KACjC,CAAC;IACF,OAAO,EAAE,kBAAkB;CAC5B,CAAC,CAAC;AAGH,uCAAuC;AAEvC,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC;IACxC,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE;IACpB,YAAY,EAAE,gBAAgB,CAAC,QAAQ,EAAE;IACzC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IAC7C,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC/B,CAAC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NREM Phase — Memory Replay + Synaptic Homeostasis + Pruning
|
|
3
|
+
*
|
|
4
|
+
* Biological basis:
|
|
5
|
+
* - Memory Replay (Wilson & McNaughton 1994): hippocampal neurons replay
|
|
6
|
+
* experiences during sleep, strengthening important traces.
|
|
7
|
+
* - Synaptic Homeostasis (Tononi & Cirelli 2014): proportional downscaling
|
|
8
|
+
* of all synaptic strengths during slow-wave sleep.
|
|
9
|
+
* - Synaptic Pruning: weak connections below threshold are eliminated.
|
|
10
|
+
*/
|
|
11
|
+
import type Database from "better-sqlite3";
|
|
12
|
+
import type { DreamCycleConfig, NremPhaseResult } from "../dream-types.js";
|
|
13
|
+
/**
|
|
14
|
+
* Run the NREM phase of a dream cycle.
|
|
15
|
+
*
|
|
16
|
+
* 1. Replay: refresh access timestamps on recent high-quality docs
|
|
17
|
+
* 2. Decay: proportionally downscale all quality scores
|
|
18
|
+
* 3. Prune: archive + delete docs below threshold
|
|
19
|
+
*/
|
|
20
|
+
export declare function runNremPhase(db: Database.Database, config: DreamCycleConfig, cycleId: string): NremPhaseResult;
|
|
21
|
+
//# sourceMappingURL=nrem-phase.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nrem-phase.d.ts","sourceRoot":"","sources":["../../../../src/core/dream/phases/nrem-phase.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAC3C,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAc3E;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,EAAE,EAAE,QAAQ,CAAC,QAAQ,EACrB,MAAM,EAAE,gBAAgB,EACxB,OAAO,EAAE,MAAM,GACd,eAAe,CAgBjB"}
|