@mcp-graph-workflow/mcp-graph 5.30.0 → 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/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/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 +36 -1
- 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 +2 -2
- 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,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-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dream-types.d.ts","sourceRoot":"","sources":["../../../src/core/dream/dream-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAI3B,eAAO,MAAM,gBAAgB;;;;EAAwC,CAAC;AACtE,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAI1D,eAAO,MAAM,sBAAsB;;;;;;EAMjC,CAAC;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAItE,eAAO,MAAM,sBAAsB;;;;;;;;iBAejC,CAAC;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAEtE,eAAO,MAAM,oBAAoB,EAAE,gBAAmD,CAAC;AAIvF,eAAO,MAAM,qBAAqB;;;;;;iBAWhC,CAAC;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE,eAAO,MAAM,oBAAoB;;;;;;;iBAa/B,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE,eAAO,MAAM,qBAAqB;;;;;iBAShC,CAAC;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAIpE,eAAO,MAAM,kBAAkB;;;;;;;;;iBAS7B,CAAC;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAI9D,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAYjC,CAAC;AACH,MAAM,MAAM,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,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AG,CAAC,CAAC,CAAC;IACpC,iBAAiB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;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"}
|
|
@@ -0,0 +1,98 @@
|
|
|
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 { archiveDreamDoc } from "../dream-store.js";
|
|
12
|
+
import { decayStaleKnowledge } from "../../rag/knowledge-quality.js";
|
|
13
|
+
import { logger } from "../../utils/logger.js";
|
|
14
|
+
import { generateId } from "../../utils/id.js";
|
|
15
|
+
/**
|
|
16
|
+
* Run the NREM phase of a dream cycle.
|
|
17
|
+
*
|
|
18
|
+
* 1. Replay: refresh access timestamps on recent high-quality docs
|
|
19
|
+
* 2. Decay: proportionally downscale all quality scores
|
|
20
|
+
* 3. Prune: archive + delete docs below threshold
|
|
21
|
+
*/
|
|
22
|
+
export function runNremPhase(db, config, cycleId) {
|
|
23
|
+
const startMs = Date.now();
|
|
24
|
+
// ── 1. Memory Replay ───────────────────────────────────
|
|
25
|
+
const replayed = replayRecentDocs(db, config);
|
|
26
|
+
// ── 2. Synaptic Homeostasis (decay) ────────────────────
|
|
27
|
+
const { updated: scoresDecayed } = decayStaleKnowledge(db);
|
|
28
|
+
// ── 3. Pruning ─────────────────────────────────────────
|
|
29
|
+
const { pruned, archived } = pruneBelowThreshold(db, config, cycleId);
|
|
30
|
+
const durationMs = Date.now() - startMs;
|
|
31
|
+
logger.info("dream:nrem:complete", { replayed, scoresDecayed, pruned, archived, durationMs });
|
|
32
|
+
return { replayed, scoresDecayed, pruned, archived, durationMs };
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Memory Replay: query docs created in the last 7 days with quality >= 0.6,
|
|
36
|
+
* limited to maxReplayBatch. Update their last_accessed_at and increment
|
|
37
|
+
* usage_count to strengthen their trace.
|
|
38
|
+
*/
|
|
39
|
+
function replayRecentDocs(db, config) {
|
|
40
|
+
const sevenDaysAgo = new Date(Date.now() - 7 * 24 * 60 * 60 * 1000).toISOString();
|
|
41
|
+
const now = new Date().toISOString();
|
|
42
|
+
const docs = db
|
|
43
|
+
.prepare(`SELECT id FROM knowledge_documents
|
|
44
|
+
WHERE created_at >= ? AND quality_score >= 0.6
|
|
45
|
+
ORDER BY quality_score DESC
|
|
46
|
+
LIMIT ?`)
|
|
47
|
+
.all(sevenDaysAgo, config.maxReplayBatch);
|
|
48
|
+
if (docs.length === 0)
|
|
49
|
+
return 0;
|
|
50
|
+
const update = db.prepare("UPDATE knowledge_documents SET last_accessed_at = ?, usage_count = usage_count + 1 WHERE id = ?");
|
|
51
|
+
db.transaction(() => {
|
|
52
|
+
for (const doc of docs) {
|
|
53
|
+
update.run(now, doc.id);
|
|
54
|
+
}
|
|
55
|
+
})();
|
|
56
|
+
logger.debug("dream:nrem:replay", { count: docs.length });
|
|
57
|
+
return docs.length;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Pruning: find docs with quality_score below threshold, archive them
|
|
61
|
+
* to dream_archive, then delete from knowledge_documents.
|
|
62
|
+
* In dry-run mode, counts but does not delete.
|
|
63
|
+
*/
|
|
64
|
+
function pruneBelowThreshold(db, config, cycleId) {
|
|
65
|
+
const docs = db
|
|
66
|
+
.prepare(`SELECT id, title, source_type, quality_score, created_at
|
|
67
|
+
FROM knowledge_documents
|
|
68
|
+
WHERE quality_score IS NOT NULL AND quality_score < ?`)
|
|
69
|
+
.all(config.pruneThreshold);
|
|
70
|
+
if (docs.length === 0)
|
|
71
|
+
return { pruned: 0, archived: 0 };
|
|
72
|
+
const now = new Date().toISOString();
|
|
73
|
+
let archived = 0;
|
|
74
|
+
if (!config.dryRun) {
|
|
75
|
+
db.transaction(() => {
|
|
76
|
+
for (const doc of docs) {
|
|
77
|
+
archiveDreamDoc(db, {
|
|
78
|
+
id: generateId("darch"),
|
|
79
|
+
originalDocId: doc.id,
|
|
80
|
+
title: doc.title,
|
|
81
|
+
sourceType: doc.source_type,
|
|
82
|
+
qualityScore: doc.quality_score,
|
|
83
|
+
reason: "pruned",
|
|
84
|
+
archivedAt: now,
|
|
85
|
+
cycleId,
|
|
86
|
+
});
|
|
87
|
+
db.prepare("DELETE FROM knowledge_documents WHERE id = ?").run(doc.id);
|
|
88
|
+
archived++;
|
|
89
|
+
}
|
|
90
|
+
})();
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
archived = docs.length; // count what would be archived
|
|
94
|
+
}
|
|
95
|
+
logger.debug("dream:nrem:prune", { pruned: docs.length, archived, dryRun: config.dryRun });
|
|
96
|
+
return { pruned: docs.length, archived };
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=nrem-phase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nrem-phase.js","sourceRoot":"","sources":["../../../../src/core/dream/phases/nrem-phase.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAU/C;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAC1B,EAAqB,EACrB,MAAwB,EACxB,OAAe;IAEf,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAE3B,0DAA0D;IAC1D,MAAM,QAAQ,GAAG,gBAAgB,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;IAE9C,0DAA0D;IAC1D,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,GAAG,mBAAmB,CAAC,EAAE,CAAC,CAAC;IAE3D,0DAA0D;IAC1D,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,mBAAmB,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAEtE,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC;IACxC,MAAM,CAAC,IAAI,CAAC,qBAAqB,EAAE,EAAE,QA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— Priority Processing + Merge + Association Strengthening
|
|
3
|
+
*
|
|
4
|
+
* Biological basis:
|
|
5
|
+
* - Emotional Memory Processing (Stickgold 2005): amygdala selectively
|
|
6
|
+
* strengthens priority memories while decoupling emotional charge.
|
|
7
|
+
* - Pattern Integration (McClelland 1995): complementary learning systems
|
|
8
|
+
* merge similar representations across stores.
|
|
9
|
+
* - Theta Oscillations (Buzsáki 2002): co-accessed items get their
|
|
10
|
+
* associations strengthened via phase-coupled binding.
|
|
11
|
+
*/
|
|
12
|
+
import type Database from "better-sqlite3";
|
|
13
|
+
import type { DreamCycleConfig, RemPhaseResult } from "../dream-types.js";
|
|
14
|
+
/**
|
|
15
|
+
* Run the REM phase of a dream cycle.
|
|
16
|
+
*
|
|
17
|
+
* 1. Priority Processing: boost blocker/error docs, decay urgency
|
|
18
|
+
* 2. Merge: find and merge highly similar docs (placeholder for embedding-based merge)
|
|
19
|
+
* 3. Association: strengthen links between co-accessed docs
|
|
20
|
+
*/
|
|
21
|
+
export declare function runRemPhase(db: Database.Database, config: DreamCycleConfig, _cycleId: string): RemPhaseResult;
|
|
22
|
+
//# sourceMappingURL=rem-phase.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rem-phase.d.ts","sourceRoot":"","sources":["../../../../src/core/dream/phases/rem-phase.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAC3C,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAU1E;;;;;;GAMG;AACH,wBAAgB,WAAW,CACzB,EAAE,EAAE,QAAQ,CAAC,QAAQ,EACrB,MAAM,EAAE,gBAAgB,EACxB,QAAQ,EAAE,MAAM,GACf,cAAc,CAuBhB"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* REM Phase — Priority Processing + Merge + Association Strengthening
|
|
3
|
+
*
|
|
4
|
+
* Biological basis:
|
|
5
|
+
* - Emotional Memory Processing (Stickgold 2005): amygdala selectively
|
|
6
|
+
* strengthens priority memories while decoupling emotional charge.
|
|
7
|
+
* - Pattern Integration (McClelland 1995): complementary learning systems
|
|
8
|
+
* merge similar representations across stores.
|
|
9
|
+
* - Theta Oscillations (Buzsáki 2002): co-accessed items get their
|
|
10
|
+
* associations strengthened via phase-coupled binding.
|
|
11
|
+
*/
|
|
12
|
+
import { linkBySharedContext } from "../../rag/knowledge-linker.js";
|
|
13
|
+
import { logger } from "../../utils/logger.js";
|
|
14
|
+
/**
|
|
15
|
+
* Run the REM phase of a dream cycle.
|
|
16
|
+
*
|
|
17
|
+
* 1. Priority Processing: boost blocker/error docs, decay urgency
|
|
18
|
+
* 2. Merge: find and merge highly similar docs (placeholder for embedding-based merge)
|
|
19
|
+
* 3. Association: strengthen links between co-accessed docs
|
|
20
|
+
*/
|
|
21
|
+
export function runRemPhase(db, config, _cycleId) {
|
|
22
|
+
const startMs = Date.now();
|
|
23
|
+
// ── 1. Priority Processing ──────────────────────────────
|
|
24
|
+
const { priorityProcessed, urgencyDecayed } = processPriorityDocs(db, config);
|
|
25
|
+
// ── 2. Merge (semantic similarity — simplified without embedding store) ──
|
|
26
|
+
// Full merge requires EmbeddingStore.findSimilar() which needs loaded embeddings.
|
|
27
|
+
// For now, count 0 — will be activated when DreamEngine provides EmbeddingStore.
|
|
28
|
+
const merged = 0;
|
|
29
|
+
const clustersFormed = 0;
|
|
30
|
+
// ── 3. Association Strengthening ───────────────────────
|
|
31
|
+
let associationsCreated = 0;
|
|
32
|
+
if (!config.dryRun) {
|
|
33
|
+
const linkResult = linkBySharedContext(db);
|
|
34
|
+
associationsCreated = linkResult.relationsCreated;
|
|
35
|
+
}
|
|
36
|
+
const durationMs = Date.now() - startMs;
|
|
37
|
+
logger.info("dream:rem:complete", { priorityProcessed, urgencyDecayed, merged, associationsCreated, durationMs });
|
|
38
|
+
return { priorityProcessed, urgencyDecayed, merged, clustersFormed, associationsCreated, durationMs };
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Priority Processing: find docs with metadata.priority = "blocker" or "error".
|
|
42
|
+
* Boost their quality_score by +0.15 (capped at 1.0).
|
|
43
|
+
* Decay urgency metadata field by urgencyDecayFactor.
|
|
44
|
+
*/
|
|
45
|
+
function processPriorityDocs(db, config) {
|
|
46
|
+
const docs = db
|
|
47
|
+
.prepare("SELECT id, quality_score, metadata FROM knowledge_documents WHERE metadata IS NOT NULL")
|
|
48
|
+
.all();
|
|
49
|
+
let priorityProcessed = 0;
|
|
50
|
+
let urgencyDecayed = 0;
|
|
51
|
+
const updateScore = db.prepare("UPDATE knowledge_documents SET quality_score = ? WHERE id = ?");
|
|
52
|
+
const updateMeta = db.prepare("UPDATE knowledge_documents SET metadata = ? WHERE id = ?");
|
|
53
|
+
db.transaction(() => {
|
|
54
|
+
for (const doc of docs) {
|
|
55
|
+
if (!doc.metadata)
|
|
56
|
+
continue;
|
|
57
|
+
let meta;
|
|
58
|
+
try {
|
|
59
|
+
meta = JSON.parse(doc.metadata);
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
const priority = meta.priority;
|
|
65
|
+
// Boost quality for priority items
|
|
66
|
+
if (priority === "blocker" || priority === "error") {
|
|
67
|
+
const currentScore = doc.quality_score ?? 0.5;
|
|
68
|
+
const boostedScore = Math.min(1.0, currentScore + 0.15);
|
|
69
|
+
if (!config.dryRun) {
|
|
70
|
+
updateScore.run(boostedScore, doc.id);
|
|
71
|
+
}
|
|
72
|
+
priorityProcessed++;
|
|
73
|
+
}
|
|
74
|
+
// Decay urgency field
|
|
75
|
+
if (typeof meta.urgency === "number" && meta.urgency > 0) {
|
|
76
|
+
meta.urgency = meta.urgency * config.urgencyDecayFactor;
|
|
77
|
+
if (!config.dryRun) {
|
|
78
|
+
updateMeta.run(JSON.stringify(meta), doc.id);
|
|
79
|
+
}
|
|
80
|
+
urgencyDecayed++;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
})();
|
|
84
|
+
logger.debug("dream:rem:priority", { priorityProcessed, urgencyDecayed });
|
|
85
|
+
return { priorityProcessed, urgencyDecayed };
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=rem-phase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rem-phase.js","sourceRoot":"","sources":["../../../../src/core/dream/phases/rem-phase.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAQ/C;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CACzB,EAAqB,EACrB,MAAwB,EACxB,QAAgB;IAEhB,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAE3B,2DAA2D;IAC3D,MAAM,EAAE,iBAAiB,EAAE,cAAc,EAAE,GAAG,mBAAmB,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;IAE9E,4EAA4E;IAC5E,kFAAkF;IAClF,iFAAiF;IACjF,MAAM,MAAM,GAAG,CAAC,CAAC;IACjB,MAAM,cAAc,GAAG,CAAC,CAAC;IAEzB,0DAA0D;IAC1D,IAAI,mBAAmB,GAAG,CAAC,CAAC;IAC5B,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;QACnB,MAAM,UAAU,GAAG,mBAAmB,CAAC,EAAE,CAAC,CAAC;QAC3C,mBAAmB,GAAG,UAAU,CAAC,gBAAgB,CAAC;IACpD,CAAC;IAED,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC;IACxC,MAAM,CAAC,IAAI,CAAC,oBAAoB,EAAE,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,EAAE,mBAAmB,EAAE,UAAU,EAAE,CAAC,CAAC;IAElH,OAAO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B,CAAC;YAED,sBAAsB;YACtB,IAAI,OAAO,IAAI,CAAC,OAAO,KAAK,QAAQ,IAAI,IAAI,CAAC,OAAO,GAAG,CAAC,EAAE,CAAC;gBACzD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,kBAAkB,CAAC;gBACxD,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;oBACnB,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;gBAC/C,CAAC;gBACD,cAAc,EAAE,CAAC;YACnB,CAAC;QACH,CAAC;IACH,CAAC,CAAC,EAAE,CAAC;IAEL,MAAM,CAAC,KAAK,CAAC,oBAAoB,EAAE,EAAE,iBAAiB,EAAE,cAAc,EAAE,CAAC,CAAC;IAC1E,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,CAAC;AAC/C,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wake Ready Phase — Capacity Report + Signal-to-Noise + Generalization
|
|
3
|
+
*
|
|
4
|
+
* Biological basis:
|
|
5
|
+
* - After sleep cycles, the brain wakes with freed synaptic capacity,
|
|
6
|
+
* improved signal-to-noise, and new cross-memory generalizations
|
|
7
|
+
* formed during REM self-organization.
|
|
8
|
+
*/
|
|
9
|
+
import type Database from "better-sqlite3";
|
|
10
|
+
import type { WakeReadyResult } from "../dream-types.js";
|
|
11
|
+
interface BeforeMetrics {
|
|
12
|
+
totalDocsBefore: number;
|
|
13
|
+
avgQualityBefore: number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Run the Wake Ready phase of a dream cycle.
|
|
17
|
+
*
|
|
18
|
+
* 1. Capacity Report: count docs and estimate freed tokens
|
|
19
|
+
* 2. Signal-to-Noise: compare avg quality before vs after
|
|
20
|
+
* 3. Generalization: run synthesis to create cross-memory docs
|
|
21
|
+
*/
|
|
22
|
+
export declare function runWakeReadyPhase(db: Database.Database, before: BeforeMetrics): WakeReadyResult;
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=wake-ready-phase.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wake-ready-phase.d.ts","sourceRoot":"","sources":["../../../../src/core/dream/phases/wake-ready-phase.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAC3C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAKzD,UAAU,aAAa;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,EAAE,EAAE,QAAQ,CAAC,QAAQ,EACrB,MAAM,EAAE,aAAa,GACpB,eAAe,CA2BjB"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wake Ready Phase — Capacity Report + Signal-to-Noise + Generalization
|
|
3
|
+
*
|
|
4
|
+
* Biological basis:
|
|
5
|
+
* - After sleep cycles, the brain wakes with freed synaptic capacity,
|
|
6
|
+
* improved signal-to-noise, and new cross-memory generalizations
|
|
7
|
+
* formed during REM self-organization.
|
|
8
|
+
*/
|
|
9
|
+
import { estimateTokens } from "../../context/token-estimator.js";
|
|
10
|
+
import { runSynthesisCycle } from "../../rag/knowledge-synthesizer.js";
|
|
11
|
+
import { logger } from "../../utils/logger.js";
|
|
12
|
+
/**
|
|
13
|
+
* Run the Wake Ready phase of a dream cycle.
|
|
14
|
+
*
|
|
15
|
+
* 1. Capacity Report: count docs and estimate freed tokens
|
|
16
|
+
* 2. Signal-to-Noise: compare avg quality before vs after
|
|
17
|
+
* 3. Generalization: run synthesis to create cross-memory docs
|
|
18
|
+
*/
|
|
19
|
+
export function runWakeReadyPhase(db, before) {
|
|
20
|
+
const startMs = Date.now();
|
|
21
|
+
// ── 1. Capacity Report ──────────────────────────────────
|
|
22
|
+
const currentStats = getCurrentStats(db);
|
|
23
|
+
const docsRemoved = Math.max(0, before.totalDocsBefore - currentStats.totalDocs);
|
|
24
|
+
const freedTokens = docsRemoved > 0 ? estimateFreedTokens(db, docsRemoved) : 0;
|
|
25
|
+
// ── 2. Signal-to-Noise ─────────────────────────────────
|
|
26
|
+
let signalToNoise = 0;
|
|
27
|
+
if (before.avgQualityBefore > 0 && currentStats.avgQuality > 0) {
|
|
28
|
+
signalToNoise = currentStats.avgQuality / before.avgQualityBefore;
|
|
29
|
+
}
|
|
30
|
+
// ── 3. Generalization (synthesis) ──────────────────────
|
|
31
|
+
let newGeneralizations = 0;
|
|
32
|
+
try {
|
|
33
|
+
const synthesisResult = runSynthesisCycle(db);
|
|
34
|
+
newGeneralizations = synthesisResult.synthesized;
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
logger.debug("dream:wake:synthesis_skipped", { reason: "insufficient docs or no patterns" });
|
|
38
|
+
}
|
|
39
|
+
const durationMs = Date.now() - startMs;
|
|
40
|
+
logger.info("dream:wake:complete", { freedTokens, signalToNoise, newGeneralizations, durationMs });
|
|
41
|
+
return { freedTokens, signalToNoise, newGeneralizations, durationMs };
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Get current doc count and average quality score.
|
|
45
|
+
*/
|
|
46
|
+
function getCurrentStats(db) {
|
|
47
|
+
const row = db
|
|
48
|
+
.prepare("SELECT COUNT(*) as cnt, COALESCE(AVG(quality_score), 0) as avg_q FROM knowledge_documents")
|
|
49
|
+
.get();
|
|
50
|
+
return { totalDocs: row.cnt, avgQuality: row.avg_q };
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Estimate tokens freed by removed docs.
|
|
54
|
+
* Uses average content length * docs removed * token estimation.
|
|
55
|
+
*/
|
|
56
|
+
function estimateFreedTokens(db, docsRemoved) {
|
|
57
|
+
const row = db
|
|
58
|
+
.prepare("SELECT COALESCE(AVG(LENGTH(content)), 0) as avg_len FROM knowledge_documents")
|
|
59
|
+
.get();
|
|
60
|
+
const avgContentLength = Math.round(row.avg_len);
|
|
61
|
+
return docsRemoved * estimateTokens("x".repeat(avgContentLength));
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=wake-ready-phase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wake-ready-phase.js","sourceRoot":"","sources":["../../../../src/core/dream/phases/wake-ready-phase.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AACvE,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAO/C;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAC/B,EAAqB,EACrB,MAAqB;IAErB,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAE3B,2DAA2D;IAC3D,MAAM,YAAY,GAAG,eAAe,CAAC,EAAE,CAAC,CAAC;IACzC,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,eAAe,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC;IACjF,MAAM,WAAW,GAAG,WAAW,GAAG,CAAC,CAAC,CAAC,CAAC,mBAAmB,CAAC,EAAE,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAE/E,0DAA0D;IAC1D,IAAI,aAAa,GAAG,CAAC,CAAC;IACtB,IAAI,MAAM,CAAC,gBAAgB,GAAG,CAAC,IAAI,YAAY,CAAC,UAAU,GAAG,CAAC,EAAE,CAAC;QAC/D,aAAa,GAAG,YAAY,CAAC,UAAU,GAAG,MAAM,CAAC,gBAAgB,CAAC;IACpE,CAAC;IAED,0DAA0D;IAC1D,IAAI,kBAAkB,GAAG,CAAC,CAAC;IAC3B,IAAI,CAAC;QACH,MAAM,eAAe,GAAG,iBAAiB,CAAC,EAAE,CAAC,CAAC;QAC9C,kBAAkB,GAAG,eAAe,CAAC,WAAW,CAAC;IACnD,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,CAAC,KAAK,CAAC,8BAA8B,EAAE,EAAE,MAAM,EAAE,kCAAkC,EAAE,CAAC,CAAC;IAC/F,CAAC;IAED,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC;IACxC,MAAM,CAAC,IAAI,CAAC,qBAAqB,EAAE,EAAE,WAAW,EAAE,aAAa,EAAE,kBAAkB,EAAE,UAAU,EAAE,CAAC,CAAC;IAEnG,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,kBAAkB,EAAE,UAAU,EAAE,CAAC;AACxE,CAAC;AAED;;GAEG;AACH,SAAS,eAAe,CAAC,EAAqB;IAC5C,MAAM,GAAG,GAAG,EAAE;SACX,OAAO,CAAC,2FAA2F,CAAC;SACpG,GAAG,EAAoC,CAAC;IAC3C,OAAO,EAAE,SAAS,EAAE,GAAG,CAAC,GAAG,EAAE,UAAU,EAAE,GAAG,CAAC,KAAK,EAAE,CAAC;AACvD,CAAC;AAED;;;GAGG;AACH,SAAS,mBAAmB,CAAC,EAAqB,EAAE,WAAmB;IACrE,MAAM,GAAG,GAAG,EAAE;SACX,OAAO,CAAC,8EAA8E,CAAC;SACvF,GAAG,EAAyB,CAAC;IAChC,MAAM,gBAAgB,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACjD,OAAO,WAAW,GAAG,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC;AACpE,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type GraphEventType = "node:created" | "node:updated" | "node:deleted" | "edge:created" | "edge:deleted" | "import:completed" | "bulk:updated" | "knowledge:indexed" | "knowledge:deleted" | "knowledge:quality_updated" | "phase:transitioned" | "sprint:planned" | "validation:completed" | "code:reindexed" | "log:entry" | "error:detected" | "healing:memory_created" | "siebel:sif_imported" | "siebel:composer_action" | "siebel:objects_indexed" | "siebel:sif_generated" | "translation:job_created" | "translation:analyzed" | "translation:finalized" | "translation:error";
|
|
1
|
+
export type GraphEventType = "node:created" | "node:updated" | "node:deleted" | "edge:created" | "edge:deleted" | "import:completed" | "bulk:updated" | "knowledge:indexed" | "knowledge:deleted" | "knowledge:quality_updated" | "phase:transitioned" | "sprint:planned" | "validation:completed" | "code:reindexed" | "log:entry" | "error:detected" | "healing:memory_created" | "siebel:sif_imported" | "siebel:composer_action" | "siebel:objects_indexed" | "siebel:sif_generated" | "translation:job_created" | "translation:analyzed" | "translation:finalized" | "translation:error" | "dream:cycle_started" | "dream:phase_started" | "dream:phase_completed" | "dream:cycle_completed" | "dream:cycle_failed";
|
|
2
2
|
export interface GraphEvent {
|
|
3
3
|
type: GraphEventType;
|
|
4
4
|
timestamp: string;
|
|
@@ -197,4 +197,42 @@ export interface TranslationErrorEvent extends GraphEvent {
|
|
|
197
197
|
errorMessage: string;
|
|
198
198
|
};
|
|
199
199
|
}
|
|
200
|
+
export interface DreamCycleStartedEvent extends GraphEvent {
|
|
201
|
+
type: "dream:cycle_started";
|
|
202
|
+
payload: {
|
|
203
|
+
cycleId: string;
|
|
204
|
+
config: Record<string, unknown>;
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
export interface DreamPhaseStartedEvent extends GraphEvent {
|
|
208
|
+
type: "dream:phase_started";
|
|
209
|
+
payload: {
|
|
210
|
+
cycleId: string;
|
|
211
|
+
phase: string;
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
export interface DreamPhaseCompletedEvent extends GraphEvent {
|
|
215
|
+
type: "dream:phase_completed";
|
|
216
|
+
payload: {
|
|
217
|
+
cycleId: string;
|
|
218
|
+
phase: string;
|
|
219
|
+
durationMs: number;
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
export interface DreamCycleCompletedEvent extends GraphEvent {
|
|
223
|
+
type: "dream:cycle_completed";
|
|
224
|
+
payload: {
|
|
225
|
+
cycleId: string;
|
|
226
|
+
totalPruned: number;
|
|
227
|
+
totalMerged: number;
|
|
228
|
+
durationMs: number;
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
export interface DreamCycleFailedEvent extends GraphEvent {
|
|
232
|
+
type: "dream:cycle_failed";
|
|
233
|
+
payload: {
|
|
234
|
+
cycleId: string;
|
|
235
|
+
errorMessage: string;
|
|
236
|
+
};
|
|
237
|
+
}
|
|
200
238
|
//# sourceMappingURL=event-types.d.ts.map
|