@dsh-ray/assistant-association 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/README.md +133 -2
- package/cordis.patch.yml +26 -0
- package/lib/aho-corasick.d.ts +41 -0
- package/lib/aho-corasick.d.ts.map +1 -0
- package/lib/aho-corasick.js +352 -0
- package/lib/aho-corasick.js.map +1 -0
- package/lib/bm25.d.ts +17 -0
- package/lib/bm25.d.ts.map +1 -0
- package/lib/bm25.js +73 -0
- package/lib/bm25.js.map +1 -0
- package/lib/clustering.d.ts +161 -0
- package/lib/clustering.d.ts.map +1 -0
- package/lib/clustering.js +1043 -0
- package/lib/clustering.js.map +1 -0
- package/lib/config.d.ts +67 -0
- package/lib/config.d.ts.map +1 -0
- package/lib/config.js +834 -0
- package/lib/config.js.map +1 -0
- package/lib/cues.d.ts +134 -0
- package/lib/cues.d.ts.map +1 -0
- package/lib/cues.js +793 -0
- package/lib/cues.js.map +1 -0
- package/lib/dreaming.d.ts +211 -0
- package/lib/dreaming.d.ts.map +1 -0
- package/lib/dreaming.js +1418 -0
- package/lib/dreaming.js.map +1 -0
- package/lib/entities.d.ts +18 -0
- package/lib/entities.d.ts.map +1 -0
- package/lib/entities.js +111 -0
- package/lib/entities.js.map +1 -0
- package/lib/eval-pool.d.ts +111 -0
- package/lib/eval-pool.d.ts.map +1 -0
- package/lib/eval-pool.js +392 -0
- package/lib/eval-pool.js.map +1 -0
- package/lib/hebbian.d.ts +54 -0
- package/lib/hebbian.d.ts.map +1 -0
- package/lib/hebbian.js +226 -0
- package/lib/hebbian.js.map +1 -0
- package/lib/holdout.d.ts +18 -0
- package/lib/holdout.d.ts.map +1 -0
- package/lib/holdout.js +97 -0
- package/lib/holdout.js.map +1 -0
- package/lib/hot-path.d.ts +8 -0
- package/lib/hot-path.d.ts.map +1 -0
- package/lib/hot-path.js +503 -0
- package/lib/hot-path.js.map +1 -0
- package/lib/hysteresis.d.ts +39 -0
- package/lib/hysteresis.d.ts.map +1 -0
- package/lib/hysteresis.js +297 -0
- package/lib/hysteresis.js.map +1 -0
- package/lib/index-memory.d.ts +112 -0
- package/lib/index-memory.d.ts.map +1 -0
- package/lib/index-memory.js +391 -0
- package/lib/index-memory.js.map +1 -0
- package/lib/index.d.ts +37 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +37 -0
- package/lib/index.js.map +1 -0
- package/lib/intake-signal.d.ts +158 -0
- package/lib/intake-signal.d.ts.map +1 -0
- package/lib/intake-signal.js +366 -0
- package/lib/intake-signal.js.map +1 -0
- package/lib/param-tuning.d.ts +302 -0
- package/lib/param-tuning.d.ts.map +1 -0
- package/lib/param-tuning.js +1743 -0
- package/lib/param-tuning.js.map +1 -0
- package/lib/service.d.ts +164 -0
- package/lib/service.d.ts.map +1 -0
- package/lib/service.js +2071 -0
- package/lib/service.js.map +1 -0
- package/lib/sources.d.ts +42 -0
- package/lib/sources.d.ts.map +1 -0
- package/lib/sources.js +2024 -0
- package/lib/sources.js.map +1 -0
- package/lib/sqlite.d.ts +88 -0
- package/lib/sqlite.d.ts.map +1 -0
- package/lib/sqlite.js +1815 -0
- package/lib/sqlite.js.map +1 -0
- package/lib/tokenize.d.ts +4 -0
- package/lib/tokenize.d.ts.map +1 -0
- package/lib/tokenize.js +35 -0
- package/lib/tokenize.js.map +1 -0
- package/lib/tools.d.ts +27 -0
- package/lib/tools.d.ts.map +1 -0
- package/lib/tools.js +126 -0
- package/lib/tools.js.map +1 -0
- package/lib/types.d.ts +551 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +163 -0
- package/lib/types.js.map +1 -0
- package/lib/version.d.ts +2 -0
- package/lib/version.d.ts.map +1 -0
- package/lib/version.js +2 -0
- package/lib/version.js.map +1 -0
- package/lib/web-fetch.d.ts +95 -0
- package/lib/web-fetch.d.ts.map +1 -0
- package/lib/web-fetch.js +833 -0
- package/lib/web-fetch.js.map +1 -0
- package/lib/web-learning-interests.d.ts +42 -0
- package/lib/web-learning-interests.d.ts.map +1 -0
- package/lib/web-learning-interests.js +4344 -0
- package/lib/web-learning-interests.js.map +1 -0
- package/lib/web-learning-runner.d.ts +43 -0
- package/lib/web-learning-runner.d.ts.map +1 -0
- package/lib/web-learning-runner.js +322 -0
- package/lib/web-learning-runner.js.map +1 -0
- package/lib/web-learning-worker.d.ts +75 -0
- package/lib/web-learning-worker.d.ts.map +1 -0
- package/lib/web-learning-worker.js +367 -0
- package/lib/web-learning-worker.js.map +1 -0
- package/lib/web-learning.d.ts +161 -0
- package/lib/web-learning.d.ts.map +1 -0
- package/lib/web-learning.js +912 -0
- package/lib/web-learning.js.map +1 -0
- package/lib/write-queue.d.ts +42 -0
- package/lib/write-queue.d.ts.map +1 -0
- package/lib/write-queue.js +439 -0
- package/lib/write-queue.js.map +1 -0
- package/package.json +156 -3
package/lib/config.js
ADDED
|
@@ -0,0 +1,834 @@
|
|
|
1
|
+
import { isIP } from 'node:net';
|
|
2
|
+
import { isAbsolute, resolve } from 'node:path';
|
|
3
|
+
import Schema from '@deepseek-ai/schemastery';
|
|
4
|
+
import { DEFAULT_CLUSTERING_CONFIG, normalizeClusteringConfig, } from './clustering.js';
|
|
5
|
+
import { DEFAULT_ASSOCIATION_DREAMING_CONFIG, normalizeAssociationDreamingConfig, } from './dreaming.js';
|
|
6
|
+
import { DEFAULT_HOLDOUT_RATE_BPS, MAX_HOLDOUT_RATE_BPS, MIN_HOLDOUT_RATE_BPS, } from './holdout.js';
|
|
7
|
+
import { DEFAULT_ASSOCIATION_INTAKE_SIGNAL_CONFIG, normalizeAssociationIntakeSignalConfig, } from './intake-signal.js';
|
|
8
|
+
import { DEFAULT_HEBBIAN_CONFIG, DEFAULT_PARAM_TUNING_CONFIG, DEFAULT_SOURCE_WEIGHTS, } from './types.js';
|
|
9
|
+
export const DEFAULT_ASSOCIATION_WEB_LEARNING_CONFIG = Object.freeze({
|
|
10
|
+
enabled: true,
|
|
11
|
+
allowedDomains: Object.freeze([]),
|
|
12
|
+
seedUrls: Object.freeze([]),
|
|
13
|
+
allowSubdomains: false,
|
|
14
|
+
allowIpv6: false,
|
|
15
|
+
isolationMode: 'subprocess',
|
|
16
|
+
intervalMs: 3_600_000,
|
|
17
|
+
idleMinMs: 900_000,
|
|
18
|
+
cooldownMs: 86_400_000,
|
|
19
|
+
maxInterestsPerRun: 3,
|
|
20
|
+
maxRequestsPerRun: 5,
|
|
21
|
+
maxPagesPerRun: 3,
|
|
22
|
+
maxBytesPerRequest: 524_288,
|
|
23
|
+
maxTotalBytesPerRun: 1_048_576,
|
|
24
|
+
maxRequestsPerDay: 20,
|
|
25
|
+
maxBytesPerDay: 5_242_880,
|
|
26
|
+
maxDurationMs: 30_000,
|
|
27
|
+
requestTimeoutMs: 10_000,
|
|
28
|
+
maxRedirects: 2,
|
|
29
|
+
discoverLinks: false,
|
|
30
|
+
nodeTtlMs: 14 * 86_400_000,
|
|
31
|
+
});
|
|
32
|
+
const DEFAULT_DECAY_HALF_LIFE_MS = 14 * 86_400_000;
|
|
33
|
+
const INTAKE_SOURCE_ID_RE = /^[a-z][a-z0-9-]{0,63}$/u;
|
|
34
|
+
const KNOWN_FIELDS = new Set([
|
|
35
|
+
'enabled',
|
|
36
|
+
'localOnly',
|
|
37
|
+
'databasePath',
|
|
38
|
+
'holdoutSeedPath',
|
|
39
|
+
'holdoutSeed',
|
|
40
|
+
'holdoutRateBps',
|
|
41
|
+
'hotPathBudgetMs',
|
|
42
|
+
'maxItems',
|
|
43
|
+
'minItems',
|
|
44
|
+
'maxContextTokens',
|
|
45
|
+
'maxHops',
|
|
46
|
+
'hopTopN',
|
|
47
|
+
'maxFanoutPerNode',
|
|
48
|
+
'hysteresisDelta',
|
|
49
|
+
'decayHalfLifeMs',
|
|
50
|
+
'syncIntervalMs',
|
|
51
|
+
'allowHeadlessScope',
|
|
52
|
+
'allowLowTrust',
|
|
53
|
+
'allowSensitive',
|
|
54
|
+
'hebbian',
|
|
55
|
+
'paramTuning',
|
|
56
|
+
'dreaming',
|
|
57
|
+
'intakeSignal',
|
|
58
|
+
'clustering',
|
|
59
|
+
'webLearning',
|
|
60
|
+
]);
|
|
61
|
+
const KNOWN_HEBBIAN_FIELDS = new Set([
|
|
62
|
+
'enabled',
|
|
63
|
+
'alpha',
|
|
64
|
+
'weakRatio',
|
|
65
|
+
'beta',
|
|
66
|
+
'weightMin',
|
|
67
|
+
'weightMax',
|
|
68
|
+
'initialHebbianWeight',
|
|
69
|
+
'decayHalfLifeMs',
|
|
70
|
+
'nonUseGraceMs',
|
|
71
|
+
'decayIntervalMs',
|
|
72
|
+
'correctionLookbackMs',
|
|
73
|
+
]);
|
|
74
|
+
const KNOWN_PARAM_TUNING_FIELDS = new Set([
|
|
75
|
+
'enabled',
|
|
76
|
+
'minSample',
|
|
77
|
+
'minStepSample',
|
|
78
|
+
'minHoldoutSamples',
|
|
79
|
+
'minSourceSample',
|
|
80
|
+
'maxTimeoutRatePpm',
|
|
81
|
+
'lowUsageRatePpm',
|
|
82
|
+
'healthyUsageRatePpm',
|
|
83
|
+
'highCorrectionRatePpm',
|
|
84
|
+
'noisySourceRatePpm',
|
|
85
|
+
'regressionMarginPpm',
|
|
86
|
+
'timeoutMarginPpm',
|
|
87
|
+
'maxTimeoutMarginPpm',
|
|
88
|
+
'usageDropMarginPpm',
|
|
89
|
+
'observationMs',
|
|
90
|
+
'evaluationWindowMs',
|
|
91
|
+
'relaxationReplayWindowMs',
|
|
92
|
+
'relaxationReplayEnabled',
|
|
93
|
+
'rollbackCooldownMs',
|
|
94
|
+
]);
|
|
95
|
+
const KNOWN_DREAMING_FIELDS = new Set([
|
|
96
|
+
'enabled',
|
|
97
|
+
'intervalMs',
|
|
98
|
+
'idleMinMs',
|
|
99
|
+
'maxPairsPerRun',
|
|
100
|
+
'maxAbstractionsPerRun',
|
|
101
|
+
'maxSynonymsPerRun',
|
|
102
|
+
'nodeTtlMs',
|
|
103
|
+
'allowModelSynthesis',
|
|
104
|
+
'budgetId',
|
|
105
|
+
'budgetAmount',
|
|
106
|
+
]);
|
|
107
|
+
const KNOWN_INTAKE_SIGNAL_FIELDS = new Set([
|
|
108
|
+
'enabled',
|
|
109
|
+
'minScore',
|
|
110
|
+
'maxSignalsPerHour',
|
|
111
|
+
'cooldownMs',
|
|
112
|
+
'maxSummaryBytes',
|
|
113
|
+
'sourceId',
|
|
114
|
+
'budgetId',
|
|
115
|
+
'budgetAmount',
|
|
116
|
+
]);
|
|
117
|
+
const KNOWN_CLUSTERING_FIELDS = new Set([
|
|
118
|
+
'entityWeight',
|
|
119
|
+
'toolWeight',
|
|
120
|
+
'minSimilarity',
|
|
121
|
+
'minClusterSize',
|
|
122
|
+
'reAskWindowMs',
|
|
123
|
+
'reAskMinEntityJaccard',
|
|
124
|
+
]);
|
|
125
|
+
export const KNOWN_WEB_LEARNING_FIELDS = new Set([
|
|
126
|
+
'enabled',
|
|
127
|
+
'allowedDomains',
|
|
128
|
+
'seedUrls',
|
|
129
|
+
'allowSubdomains',
|
|
130
|
+
'allowIpv6',
|
|
131
|
+
'isolationMode',
|
|
132
|
+
'intervalMs',
|
|
133
|
+
'idleMinMs',
|
|
134
|
+
'cooldownMs',
|
|
135
|
+
'maxInterestsPerRun',
|
|
136
|
+
'maxRequestsPerRun',
|
|
137
|
+
'maxPagesPerRun',
|
|
138
|
+
'maxBytesPerRequest',
|
|
139
|
+
'maxTotalBytesPerRun',
|
|
140
|
+
'maxRequestsPerDay',
|
|
141
|
+
'maxBytesPerDay',
|
|
142
|
+
'maxDurationMs',
|
|
143
|
+
'requestTimeoutMs',
|
|
144
|
+
'maxRedirects',
|
|
145
|
+
'discoverLinks',
|
|
146
|
+
'nodeTtlMs',
|
|
147
|
+
'budgetId',
|
|
148
|
+
'budgetAmount',
|
|
149
|
+
]);
|
|
150
|
+
const boundedPath = Schema.string().min(1).max(4_096);
|
|
151
|
+
const webLearningSchema = Schema.object({
|
|
152
|
+
enabled: Schema.boolean().default(DEFAULT_ASSOCIATION_WEB_LEARNING_CONFIG.enabled),
|
|
153
|
+
allowedDomains: Schema.array(Schema.string().min(1).max(253)).default([]),
|
|
154
|
+
seedUrls: Schema.array(Schema.string().min(1).max(2_048)).default([]),
|
|
155
|
+
allowSubdomains: Schema.boolean().default(DEFAULT_ASSOCIATION_WEB_LEARNING_CONFIG.allowSubdomains),
|
|
156
|
+
allowIpv6: Schema.boolean().default(DEFAULT_ASSOCIATION_WEB_LEARNING_CONFIG.allowIpv6),
|
|
157
|
+
isolationMode: Schema.union([
|
|
158
|
+
Schema.const('subprocess'),
|
|
159
|
+
Schema.const('in-process'),
|
|
160
|
+
]).default(DEFAULT_ASSOCIATION_WEB_LEARNING_CONFIG.isolationMode),
|
|
161
|
+
intervalMs: Schema.natural()
|
|
162
|
+
.min(0)
|
|
163
|
+
.max(365 * 86_400_000)
|
|
164
|
+
.default(DEFAULT_ASSOCIATION_WEB_LEARNING_CONFIG.intervalMs),
|
|
165
|
+
idleMinMs: Schema.natural()
|
|
166
|
+
.min(0)
|
|
167
|
+
.max(365 * 86_400_000)
|
|
168
|
+
.default(DEFAULT_ASSOCIATION_WEB_LEARNING_CONFIG.idleMinMs),
|
|
169
|
+
cooldownMs: Schema.natural()
|
|
170
|
+
.min(0)
|
|
171
|
+
.max(365 * 86_400_000)
|
|
172
|
+
.default(DEFAULT_ASSOCIATION_WEB_LEARNING_CONFIG.cooldownMs),
|
|
173
|
+
maxInterestsPerRun: Schema.natural()
|
|
174
|
+
.min(1)
|
|
175
|
+
.max(50)
|
|
176
|
+
.default(DEFAULT_ASSOCIATION_WEB_LEARNING_CONFIG.maxInterestsPerRun),
|
|
177
|
+
maxRequestsPerRun: Schema.natural()
|
|
178
|
+
.min(1)
|
|
179
|
+
.max(100)
|
|
180
|
+
.default(DEFAULT_ASSOCIATION_WEB_LEARNING_CONFIG.maxRequestsPerRun),
|
|
181
|
+
maxPagesPerRun: Schema.natural()
|
|
182
|
+
.min(1)
|
|
183
|
+
.max(100)
|
|
184
|
+
.default(DEFAULT_ASSOCIATION_WEB_LEARNING_CONFIG.maxPagesPerRun),
|
|
185
|
+
maxBytesPerRequest: Schema.natural()
|
|
186
|
+
.min(1)
|
|
187
|
+
.max(10 * 1024 * 1024)
|
|
188
|
+
.default(DEFAULT_ASSOCIATION_WEB_LEARNING_CONFIG.maxBytesPerRequest),
|
|
189
|
+
maxTotalBytesPerRun: Schema.natural()
|
|
190
|
+
.min(1)
|
|
191
|
+
.max(50 * 1024 * 1024)
|
|
192
|
+
.default(DEFAULT_ASSOCIATION_WEB_LEARNING_CONFIG.maxTotalBytesPerRun),
|
|
193
|
+
maxRequestsPerDay: Schema.natural()
|
|
194
|
+
.min(1)
|
|
195
|
+
.max(1_000)
|
|
196
|
+
.default(DEFAULT_ASSOCIATION_WEB_LEARNING_CONFIG.maxRequestsPerDay),
|
|
197
|
+
maxBytesPerDay: Schema.natural()
|
|
198
|
+
.min(1)
|
|
199
|
+
.max(200 * 1024 * 1024)
|
|
200
|
+
.default(DEFAULT_ASSOCIATION_WEB_LEARNING_CONFIG.maxBytesPerDay),
|
|
201
|
+
maxDurationMs: Schema.natural()
|
|
202
|
+
.min(1)
|
|
203
|
+
.max(600_000)
|
|
204
|
+
.default(DEFAULT_ASSOCIATION_WEB_LEARNING_CONFIG.maxDurationMs),
|
|
205
|
+
requestTimeoutMs: Schema.natural()
|
|
206
|
+
.min(1)
|
|
207
|
+
.max(120_000)
|
|
208
|
+
.default(DEFAULT_ASSOCIATION_WEB_LEARNING_CONFIG.requestTimeoutMs),
|
|
209
|
+
maxRedirects: Schema.natural()
|
|
210
|
+
.min(0)
|
|
211
|
+
.max(10)
|
|
212
|
+
.default(DEFAULT_ASSOCIATION_WEB_LEARNING_CONFIG.maxRedirects),
|
|
213
|
+
discoverLinks: Schema.boolean().default(DEFAULT_ASSOCIATION_WEB_LEARNING_CONFIG.discoverLinks),
|
|
214
|
+
nodeTtlMs: Schema.natural()
|
|
215
|
+
.min(0)
|
|
216
|
+
.max(3_650 * 86_400_000)
|
|
217
|
+
.default(DEFAULT_ASSOCIATION_WEB_LEARNING_CONFIG.nodeTtlMs),
|
|
218
|
+
budgetId: Schema.string().min(1).max(256),
|
|
219
|
+
budgetAmount: Schema.number().min(0).max(1_000_000),
|
|
220
|
+
}).default({
|
|
221
|
+
...DEFAULT_ASSOCIATION_WEB_LEARNING_CONFIG,
|
|
222
|
+
allowedDomains: [],
|
|
223
|
+
seedUrls: [],
|
|
224
|
+
});
|
|
225
|
+
const dreamingSchema = Schema.object({
|
|
226
|
+
enabled: Schema.boolean().default(DEFAULT_ASSOCIATION_DREAMING_CONFIG.enabled),
|
|
227
|
+
intervalMs: Schema.natural()
|
|
228
|
+
.min(0)
|
|
229
|
+
.max(365 * 86_400_000)
|
|
230
|
+
.default(DEFAULT_ASSOCIATION_DREAMING_CONFIG.intervalMs),
|
|
231
|
+
idleMinMs: Schema.natural()
|
|
232
|
+
.min(0)
|
|
233
|
+
.max(365 * 86_400_000)
|
|
234
|
+
.default(DEFAULT_ASSOCIATION_DREAMING_CONFIG.idleMinMs),
|
|
235
|
+
maxPairsPerRun: Schema.natural()
|
|
236
|
+
.min(0)
|
|
237
|
+
.max(1_000)
|
|
238
|
+
.default(DEFAULT_ASSOCIATION_DREAMING_CONFIG.maxPairsPerRun),
|
|
239
|
+
maxAbstractionsPerRun: Schema.natural()
|
|
240
|
+
.min(0)
|
|
241
|
+
.max(1_000)
|
|
242
|
+
.default(DEFAULT_ASSOCIATION_DREAMING_CONFIG.maxAbstractionsPerRun),
|
|
243
|
+
maxSynonymsPerRun: Schema.natural()
|
|
244
|
+
.min(0)
|
|
245
|
+
.max(1_000)
|
|
246
|
+
.default(DEFAULT_ASSOCIATION_DREAMING_CONFIG.maxSynonymsPerRun),
|
|
247
|
+
nodeTtlMs: Schema.natural()
|
|
248
|
+
.min(0)
|
|
249
|
+
.max(3_650 * 86_400_000)
|
|
250
|
+
.default(DEFAULT_ASSOCIATION_DREAMING_CONFIG.nodeTtlMs),
|
|
251
|
+
allowModelSynthesis: Schema.boolean().default(DEFAULT_ASSOCIATION_DREAMING_CONFIG.allowModelSynthesis),
|
|
252
|
+
budgetId: Schema.string().min(1).max(256),
|
|
253
|
+
budgetAmount: Schema.number().min(0).max(1_000_000),
|
|
254
|
+
}).default({ ...DEFAULT_ASSOCIATION_DREAMING_CONFIG });
|
|
255
|
+
const intakeSignalSchema = Schema.object({
|
|
256
|
+
enabled: Schema.boolean().default(DEFAULT_ASSOCIATION_INTAKE_SIGNAL_CONFIG.enabled),
|
|
257
|
+
minScore: Schema.number()
|
|
258
|
+
.min(0)
|
|
259
|
+
.max(100)
|
|
260
|
+
.default(DEFAULT_ASSOCIATION_INTAKE_SIGNAL_CONFIG.minScore),
|
|
261
|
+
maxSignalsPerHour: Schema.natural()
|
|
262
|
+
.min(0)
|
|
263
|
+
.max(10_000)
|
|
264
|
+
.default(DEFAULT_ASSOCIATION_INTAKE_SIGNAL_CONFIG.maxSignalsPerHour),
|
|
265
|
+
cooldownMs: Schema.natural()
|
|
266
|
+
.min(0)
|
|
267
|
+
.max(365 * 86_400_000)
|
|
268
|
+
.default(DEFAULT_ASSOCIATION_INTAKE_SIGNAL_CONFIG.cooldownMs),
|
|
269
|
+
maxSummaryBytes: Schema.natural()
|
|
270
|
+
.min(64)
|
|
271
|
+
.max(65_536)
|
|
272
|
+
.default(DEFAULT_ASSOCIATION_INTAKE_SIGNAL_CONFIG.maxSummaryBytes),
|
|
273
|
+
sourceId: Schema.string()
|
|
274
|
+
.min(1)
|
|
275
|
+
.max(64)
|
|
276
|
+
.default(DEFAULT_ASSOCIATION_INTAKE_SIGNAL_CONFIG.sourceId),
|
|
277
|
+
budgetId: Schema.string().min(1).max(256),
|
|
278
|
+
budgetAmount: Schema.number().min(0).max(1_000_000),
|
|
279
|
+
}).default({ ...DEFAULT_ASSOCIATION_INTAKE_SIGNAL_CONFIG });
|
|
280
|
+
const clusteringSchema = Schema.object({
|
|
281
|
+
entityWeight: Schema.number().min(0).max(10).default(DEFAULT_CLUSTERING_CONFIG.entityWeight),
|
|
282
|
+
toolWeight: Schema.number().min(0).max(10).default(DEFAULT_CLUSTERING_CONFIG.toolWeight),
|
|
283
|
+
minSimilarity: Schema.number().min(0).max(1).default(DEFAULT_CLUSTERING_CONFIG.minSimilarity),
|
|
284
|
+
minClusterSize: Schema.natural()
|
|
285
|
+
.min(2)
|
|
286
|
+
.max(100)
|
|
287
|
+
.default(DEFAULT_CLUSTERING_CONFIG.minClusterSize),
|
|
288
|
+
reAskWindowMs: Schema.natural()
|
|
289
|
+
.min(0)
|
|
290
|
+
.max(365 * 86_400_000)
|
|
291
|
+
.default(DEFAULT_CLUSTERING_CONFIG.reAskWindowMs),
|
|
292
|
+
reAskMinEntityJaccard: Schema.number()
|
|
293
|
+
.min(0)
|
|
294
|
+
.max(1)
|
|
295
|
+
.default(DEFAULT_CLUSTERING_CONFIG.reAskMinEntityJaccard),
|
|
296
|
+
}).default({ ...DEFAULT_CLUSTERING_CONFIG });
|
|
297
|
+
const hebbianSchema = Schema.object({
|
|
298
|
+
enabled: Schema.boolean().default(DEFAULT_HEBBIAN_CONFIG.enabled),
|
|
299
|
+
alpha: Schema.number().min(0).max(5).default(DEFAULT_HEBBIAN_CONFIG.alpha),
|
|
300
|
+
weakRatio: Schema.number().min(0).max(1).default(DEFAULT_HEBBIAN_CONFIG.weakRatio),
|
|
301
|
+
beta: Schema.number().min(0).max(5).default(DEFAULT_HEBBIAN_CONFIG.beta),
|
|
302
|
+
weightMin: Schema.number().min(0).max(10).default(DEFAULT_HEBBIAN_CONFIG.weightMin),
|
|
303
|
+
weightMax: Schema.number().min(0).max(10).default(DEFAULT_HEBBIAN_CONFIG.weightMax),
|
|
304
|
+
initialHebbianWeight: Schema.number()
|
|
305
|
+
.min(0)
|
|
306
|
+
.max(10)
|
|
307
|
+
.default(DEFAULT_HEBBIAN_CONFIG.initialHebbianWeight),
|
|
308
|
+
decayHalfLifeMs: Schema.number()
|
|
309
|
+
.min(1)
|
|
310
|
+
.max(3_650 * 86_400_000)
|
|
311
|
+
.default(DEFAULT_HEBBIAN_CONFIG.decayHalfLifeMs),
|
|
312
|
+
nonUseGraceMs: Schema.number()
|
|
313
|
+
.min(0)
|
|
314
|
+
.max(3_650 * 86_400_000)
|
|
315
|
+
.default(DEFAULT_HEBBIAN_CONFIG.nonUseGraceMs),
|
|
316
|
+
decayIntervalMs: Schema.natural()
|
|
317
|
+
.min(1_000)
|
|
318
|
+
.max(7 * 86_400_000)
|
|
319
|
+
.default(DEFAULT_HEBBIAN_CONFIG.decayIntervalMs),
|
|
320
|
+
correctionLookbackMs: Schema.number()
|
|
321
|
+
.min(0)
|
|
322
|
+
.max(365 * 86_400_000)
|
|
323
|
+
.default(DEFAULT_HEBBIAN_CONFIG.correctionLookbackMs),
|
|
324
|
+
}).default({ ...DEFAULT_HEBBIAN_CONFIG });
|
|
325
|
+
const paramTuningSchema = Schema.object({
|
|
326
|
+
enabled: Schema.boolean().default(DEFAULT_PARAM_TUNING_CONFIG.enabled),
|
|
327
|
+
minSample: Schema.natural().min(1).max(100_000).default(DEFAULT_PARAM_TUNING_CONFIG.minSample),
|
|
328
|
+
minStepSample: Schema.natural()
|
|
329
|
+
.min(1)
|
|
330
|
+
.max(100_000)
|
|
331
|
+
.default(DEFAULT_PARAM_TUNING_CONFIG.minStepSample),
|
|
332
|
+
minHoldoutSamples: Schema.natural()
|
|
333
|
+
.min(1)
|
|
334
|
+
.max(100_000)
|
|
335
|
+
.default(DEFAULT_PARAM_TUNING_CONFIG.minHoldoutSamples),
|
|
336
|
+
minSourceSample: Schema.natural()
|
|
337
|
+
.min(1)
|
|
338
|
+
.max(100_000)
|
|
339
|
+
.default(DEFAULT_PARAM_TUNING_CONFIG.minSourceSample),
|
|
340
|
+
maxTimeoutRatePpm: Schema.natural()
|
|
341
|
+
.min(0)
|
|
342
|
+
.max(1_000_000)
|
|
343
|
+
.default(DEFAULT_PARAM_TUNING_CONFIG.maxTimeoutRatePpm),
|
|
344
|
+
lowUsageRatePpm: Schema.natural()
|
|
345
|
+
.min(0)
|
|
346
|
+
.max(1_000_000)
|
|
347
|
+
.default(DEFAULT_PARAM_TUNING_CONFIG.lowUsageRatePpm),
|
|
348
|
+
healthyUsageRatePpm: Schema.natural()
|
|
349
|
+
.min(0)
|
|
350
|
+
.max(1_000_000)
|
|
351
|
+
.default(DEFAULT_PARAM_TUNING_CONFIG.healthyUsageRatePpm),
|
|
352
|
+
highCorrectionRatePpm: Schema.natural()
|
|
353
|
+
.min(0)
|
|
354
|
+
.max(1_000_000)
|
|
355
|
+
.default(DEFAULT_PARAM_TUNING_CONFIG.highCorrectionRatePpm),
|
|
356
|
+
noisySourceRatePpm: Schema.natural()
|
|
357
|
+
.min(0)
|
|
358
|
+
.max(1_000_000)
|
|
359
|
+
.default(DEFAULT_PARAM_TUNING_CONFIG.noisySourceRatePpm),
|
|
360
|
+
regressionMarginPpm: Schema.natural()
|
|
361
|
+
.min(0)
|
|
362
|
+
.max(1_000_000)
|
|
363
|
+
.default(DEFAULT_PARAM_TUNING_CONFIG.regressionMarginPpm),
|
|
364
|
+
timeoutMarginPpm: Schema.natural()
|
|
365
|
+
.min(0)
|
|
366
|
+
.max(1_000_000)
|
|
367
|
+
.default(DEFAULT_PARAM_TUNING_CONFIG.timeoutMarginPpm),
|
|
368
|
+
maxTimeoutMarginPpm: Schema.natural()
|
|
369
|
+
.min(0)
|
|
370
|
+
.max(1_000_000)
|
|
371
|
+
.default(DEFAULT_PARAM_TUNING_CONFIG.maxTimeoutMarginPpm),
|
|
372
|
+
usageDropMarginPpm: Schema.natural()
|
|
373
|
+
.min(0)
|
|
374
|
+
.max(1_000_000)
|
|
375
|
+
.default(DEFAULT_PARAM_TUNING_CONFIG.usageDropMarginPpm),
|
|
376
|
+
observationMs: Schema.natural()
|
|
377
|
+
.min(1)
|
|
378
|
+
.max(365 * 86_400_000)
|
|
379
|
+
.default(DEFAULT_PARAM_TUNING_CONFIG.observationMs),
|
|
380
|
+
evaluationWindowMs: Schema.natural()
|
|
381
|
+
.min(1)
|
|
382
|
+
.max(365 * 86_400_000)
|
|
383
|
+
.default(DEFAULT_PARAM_TUNING_CONFIG.evaluationWindowMs),
|
|
384
|
+
relaxationReplayWindowMs: Schema.natural()
|
|
385
|
+
.min(1)
|
|
386
|
+
.max(365 * 86_400_000)
|
|
387
|
+
.default(DEFAULT_PARAM_TUNING_CONFIG.relaxationReplayWindowMs),
|
|
388
|
+
relaxationReplayEnabled: Schema.boolean().default(DEFAULT_PARAM_TUNING_CONFIG.relaxationReplayEnabled),
|
|
389
|
+
rollbackCooldownMs: Schema.natural()
|
|
390
|
+
.min(0)
|
|
391
|
+
.max(365 * 86_400_000)
|
|
392
|
+
.default(DEFAULT_PARAM_TUNING_CONFIG.rollbackCooldownMs),
|
|
393
|
+
}).default({ ...DEFAULT_PARAM_TUNING_CONFIG });
|
|
394
|
+
const rawSchema = Schema.object({
|
|
395
|
+
enabled: Schema.boolean().default(true),
|
|
396
|
+
localOnly: Schema.boolean().default(true),
|
|
397
|
+
databasePath: boundedPath,
|
|
398
|
+
holdoutSeedPath: boundedPath,
|
|
399
|
+
holdoutSeed: Schema.string().min(16).max(512),
|
|
400
|
+
holdoutRateBps: Schema.natural()
|
|
401
|
+
.min(MIN_HOLDOUT_RATE_BPS)
|
|
402
|
+
.max(MAX_HOLDOUT_RATE_BPS)
|
|
403
|
+
.default(DEFAULT_HOLDOUT_RATE_BPS),
|
|
404
|
+
hotPathBudgetMs: Schema.number().min(0).max(50).default(4.5),
|
|
405
|
+
maxItems: Schema.natural().min(5).max(8).default(8),
|
|
406
|
+
minItems: Schema.natural().min(1).max(8).default(5),
|
|
407
|
+
maxContextTokens: Schema.natural().min(64).max(1_000).default(400),
|
|
408
|
+
maxHops: Schema.natural().min(1).max(2).default(2),
|
|
409
|
+
hopTopN: Schema.natural().min(4).max(128).default(32),
|
|
410
|
+
maxFanoutPerNode: Schema.natural().min(8).max(512).default(128),
|
|
411
|
+
hysteresisDelta: Schema.number().min(0).max(2).default(0.15),
|
|
412
|
+
decayHalfLifeMs: Schema.natural()
|
|
413
|
+
.min(60_000)
|
|
414
|
+
.max(365 * 86_400_000)
|
|
415
|
+
.default(DEFAULT_DECAY_HALF_LIFE_MS),
|
|
416
|
+
syncIntervalMs: Schema.natural().min(1_000).max(3_600_000).default(15_000),
|
|
417
|
+
allowHeadlessScope: Schema.boolean().default(false),
|
|
418
|
+
allowLowTrust: Schema.boolean().default(true),
|
|
419
|
+
allowSensitive: Schema.boolean().default(false),
|
|
420
|
+
hebbian: hebbianSchema,
|
|
421
|
+
paramTuning: paramTuningSchema,
|
|
422
|
+
dreaming: dreamingSchema,
|
|
423
|
+
intakeSignal: intakeSignalSchema,
|
|
424
|
+
clustering: clusteringSchema,
|
|
425
|
+
webLearning: webLearningSchema,
|
|
426
|
+
}).default({});
|
|
427
|
+
function checkKnownNestedFields(obj, known, prefix) {
|
|
428
|
+
if (obj === undefined)
|
|
429
|
+
return;
|
|
430
|
+
if (obj === null || typeof obj !== 'object' || Array.isArray(obj)) {
|
|
431
|
+
throw new Error(`assistant-association: ${prefix} must be an object`);
|
|
432
|
+
}
|
|
433
|
+
for (const key of Object.keys(obj)) {
|
|
434
|
+
if (!known.has(key)) {
|
|
435
|
+
throw new Error(`assistant-association: unknown config field: ${prefix}.${key}`);
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
export const Config = new Proxy(rawSchema, {
|
|
440
|
+
apply(target, thisArg, argumentsList) {
|
|
441
|
+
const value = argumentsList[0];
|
|
442
|
+
if (value !== undefined && (value === null || typeof value !== 'object' || Array.isArray(value))) {
|
|
443
|
+
throw new Error('assistant-association: config must be an object');
|
|
444
|
+
}
|
|
445
|
+
if (value !== undefined) {
|
|
446
|
+
const record = value;
|
|
447
|
+
for (const key of Object.keys(record)) {
|
|
448
|
+
if (!KNOWN_FIELDS.has(key)) {
|
|
449
|
+
throw new Error(`assistant-association: unknown config field: ${key}`);
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
checkKnownNestedFields(record.hebbian, KNOWN_HEBBIAN_FIELDS, 'hebbian');
|
|
453
|
+
checkKnownNestedFields(record.paramTuning, KNOWN_PARAM_TUNING_FIELDS, 'paramTuning');
|
|
454
|
+
checkKnownNestedFields(record.dreaming, KNOWN_DREAMING_FIELDS, 'dreaming');
|
|
455
|
+
checkKnownNestedFields(record.intakeSignal, KNOWN_INTAKE_SIGNAL_FIELDS, 'intakeSignal');
|
|
456
|
+
checkKnownNestedFields(record.clustering, KNOWN_CLUSTERING_FIELDS, 'clustering');
|
|
457
|
+
checkKnownNestedFields(record.webLearning, KNOWN_WEB_LEARNING_FIELDS, 'webLearning');
|
|
458
|
+
}
|
|
459
|
+
const parsed = Reflect.apply(target, thisArg, argumentsList);
|
|
460
|
+
validateCrossFieldConstraints(parsed);
|
|
461
|
+
return parsed;
|
|
462
|
+
},
|
|
463
|
+
});
|
|
464
|
+
function isCanonicalPathOrMemory(pathValue) {
|
|
465
|
+
if (pathValue === ':memory:')
|
|
466
|
+
return true;
|
|
467
|
+
return isAbsolute(pathValue) && resolve(pathValue) === pathValue;
|
|
468
|
+
}
|
|
469
|
+
function assertFiniteRange(value, label, check, message) {
|
|
470
|
+
if (!Number.isFinite(value) || !check(value)) {
|
|
471
|
+
throw new Error(`assistant-association: ${label} ${message}`);
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
const HOSTNAME_LABEL_RE = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/u;
|
|
475
|
+
function validateAndNormalizeAllowedDomain(raw) {
|
|
476
|
+
if (typeof raw !== 'string') {
|
|
477
|
+
throw new Error('assistant-association: webLearning.allowedDomains entries must be strings');
|
|
478
|
+
}
|
|
479
|
+
const domain = raw.trim().toLowerCase();
|
|
480
|
+
if (domain.length === 0 || domain.length > 253) {
|
|
481
|
+
throw new Error('assistant-association: webLearning.allowedDomains entries must be non-empty hostnames (<= 253 chars)');
|
|
482
|
+
}
|
|
483
|
+
if (domain.includes('://') ||
|
|
484
|
+
domain.includes(':') ||
|
|
485
|
+
domain.includes('/') ||
|
|
486
|
+
domain.includes('\\') ||
|
|
487
|
+
domain.includes('*') ||
|
|
488
|
+
domain.includes('?') ||
|
|
489
|
+
domain.includes('#') ||
|
|
490
|
+
domain.includes('@') ||
|
|
491
|
+
domain.includes('[') ||
|
|
492
|
+
domain.includes(']') ||
|
|
493
|
+
/\s/u.test(domain) ||
|
|
494
|
+
domain.startsWith('.') ||
|
|
495
|
+
domain.endsWith('.') ||
|
|
496
|
+
domain.includes('..')) {
|
|
497
|
+
throw new Error(`assistant-association: invalid webLearning.allowedDomains entry "${raw}": must be a plain hostname without scheme, port, path, wildcard, or trailing dot`);
|
|
498
|
+
}
|
|
499
|
+
if (isIP(domain) !== 0) {
|
|
500
|
+
throw new Error(`assistant-association: invalid webLearning.allowedDomains entry "${raw}": IP literals are not allowed`);
|
|
501
|
+
}
|
|
502
|
+
if (domain === 'localhost' ||
|
|
503
|
+
domain.endsWith('.localhost') ||
|
|
504
|
+
domain.endsWith('.local') ||
|
|
505
|
+
domain.endsWith('.internal') ||
|
|
506
|
+
domain.endsWith('.arpa')) {
|
|
507
|
+
throw new Error(`assistant-association: invalid webLearning.allowedDomains entry "${raw}": local/internal/reserved domains are not allowed`);
|
|
508
|
+
}
|
|
509
|
+
let parsedUrl;
|
|
510
|
+
try {
|
|
511
|
+
parsedUrl = new URL(`https://${domain}`);
|
|
512
|
+
}
|
|
513
|
+
catch {
|
|
514
|
+
throw new Error(`assistant-association: invalid webLearning.allowedDomains entry "${raw}": invalid hostname`);
|
|
515
|
+
}
|
|
516
|
+
if (parsedUrl.hostname.toLowerCase() !== domain ||
|
|
517
|
+
isIP(parsedUrl.hostname) !== 0 ||
|
|
518
|
+
parsedUrl.port !== '' ||
|
|
519
|
+
parsedUrl.username !== '' ||
|
|
520
|
+
parsedUrl.password !== '') {
|
|
521
|
+
throw new Error(`assistant-association: invalid webLearning.allowedDomains entry "${raw}": invalid hostname`);
|
|
522
|
+
}
|
|
523
|
+
const labels = domain.split('.');
|
|
524
|
+
if (labels.some((label) => !HOSTNAME_LABEL_RE.test(label))) {
|
|
525
|
+
throw new Error(`assistant-association: invalid webLearning.allowedDomains entry "${raw}": invalid hostname label`);
|
|
526
|
+
}
|
|
527
|
+
return domain;
|
|
528
|
+
}
|
|
529
|
+
function validateAndNormalizeSeedUrl(raw) {
|
|
530
|
+
if (typeof raw !== 'string') {
|
|
531
|
+
throw new Error('assistant-association: webLearning.seedUrls entries must be strings');
|
|
532
|
+
}
|
|
533
|
+
const trimmed = raw.trim();
|
|
534
|
+
if (trimmed.length === 0 || trimmed.length > 2_048) {
|
|
535
|
+
throw new Error('assistant-association: webLearning.seedUrls entries must be non-empty URLs (<= 2048 chars)');
|
|
536
|
+
}
|
|
537
|
+
if (!trimmed.startsWith('https://')) {
|
|
538
|
+
throw new Error(`assistant-association: invalid webLearning.seedUrls entry "${raw}": must start with https://`);
|
|
539
|
+
}
|
|
540
|
+
const authority = trimmed.slice('https://'.length).split(/[/?#]/u, 1)[0] ?? '';
|
|
541
|
+
if (authority.length === 0 || authority.includes('{query}')) {
|
|
542
|
+
throw new Error(`assistant-association: invalid webLearning.seedUrls entry "${raw}": invalid authority`);
|
|
543
|
+
}
|
|
544
|
+
const probe = trimmed.replaceAll('{query}', 'query');
|
|
545
|
+
let parsedUrl;
|
|
546
|
+
try {
|
|
547
|
+
parsedUrl = new URL(probe);
|
|
548
|
+
}
|
|
549
|
+
catch {
|
|
550
|
+
throw new Error(`assistant-association: invalid webLearning.seedUrls entry "${raw}": invalid URL syntax`);
|
|
551
|
+
}
|
|
552
|
+
if (parsedUrl.protocol !== 'https:' ||
|
|
553
|
+
parsedUrl.hostname.length === 0 ||
|
|
554
|
+
parsedUrl.username !== '' ||
|
|
555
|
+
parsedUrl.password !== '') {
|
|
556
|
+
throw new Error(`assistant-association: invalid webLearning.seedUrls entry "${raw}": must be a credential-free HTTPS URL`);
|
|
557
|
+
}
|
|
558
|
+
return trimmed;
|
|
559
|
+
}
|
|
560
|
+
export function normalizeAssociationWebLearningConfig(raw) {
|
|
561
|
+
const src = raw ?? {};
|
|
562
|
+
const dedupedDomains = [];
|
|
563
|
+
const seenDomains = new Set();
|
|
564
|
+
for (const entry of src.allowedDomains ?? DEFAULT_ASSOCIATION_WEB_LEARNING_CONFIG.allowedDomains) {
|
|
565
|
+
const normalizedDomain = validateAndNormalizeAllowedDomain(entry);
|
|
566
|
+
if (!seenDomains.has(normalizedDomain)) {
|
|
567
|
+
seenDomains.add(normalizedDomain);
|
|
568
|
+
dedupedDomains.push(normalizedDomain);
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
const normalizedSeeds = (src.seedUrls ?? DEFAULT_ASSOCIATION_WEB_LEARNING_CONFIG.seedUrls).map(validateAndNormalizeSeedUrl);
|
|
572
|
+
const intOrDefault = (val, fallback, min) => typeof val === 'number' && Number.isFinite(val) && val >= min ? Math.floor(val) : fallback;
|
|
573
|
+
const normalized = {
|
|
574
|
+
enabled: src.enabled ?? DEFAULT_ASSOCIATION_WEB_LEARNING_CONFIG.enabled,
|
|
575
|
+
allowedDomains: Object.freeze(dedupedDomains),
|
|
576
|
+
seedUrls: Object.freeze(normalizedSeeds),
|
|
577
|
+
allowSubdomains: src.allowSubdomains === true,
|
|
578
|
+
allowIpv6: src.allowIpv6 === true,
|
|
579
|
+
isolationMode: src.isolationMode === 'in-process' ? 'in-process' : DEFAULT_ASSOCIATION_WEB_LEARNING_CONFIG.isolationMode,
|
|
580
|
+
intervalMs: intOrDefault(src.intervalMs, DEFAULT_ASSOCIATION_WEB_LEARNING_CONFIG.intervalMs, 0),
|
|
581
|
+
idleMinMs: intOrDefault(src.idleMinMs, DEFAULT_ASSOCIATION_WEB_LEARNING_CONFIG.idleMinMs, 0),
|
|
582
|
+
cooldownMs: intOrDefault(src.cooldownMs, DEFAULT_ASSOCIATION_WEB_LEARNING_CONFIG.cooldownMs, 0),
|
|
583
|
+
maxInterestsPerRun: intOrDefault(src.maxInterestsPerRun, DEFAULT_ASSOCIATION_WEB_LEARNING_CONFIG.maxInterestsPerRun, 1),
|
|
584
|
+
maxRequestsPerRun: intOrDefault(src.maxRequestsPerRun, DEFAULT_ASSOCIATION_WEB_LEARNING_CONFIG.maxRequestsPerRun, 1),
|
|
585
|
+
maxPagesPerRun: intOrDefault(src.maxPagesPerRun, DEFAULT_ASSOCIATION_WEB_LEARNING_CONFIG.maxPagesPerRun, 1),
|
|
586
|
+
maxBytesPerRequest: intOrDefault(src.maxBytesPerRequest, DEFAULT_ASSOCIATION_WEB_LEARNING_CONFIG.maxBytesPerRequest, 1),
|
|
587
|
+
maxTotalBytesPerRun: intOrDefault(src.maxTotalBytesPerRun, DEFAULT_ASSOCIATION_WEB_LEARNING_CONFIG.maxTotalBytesPerRun, 1),
|
|
588
|
+
maxRequestsPerDay: intOrDefault(src.maxRequestsPerDay, DEFAULT_ASSOCIATION_WEB_LEARNING_CONFIG.maxRequestsPerDay, 1),
|
|
589
|
+
maxBytesPerDay: intOrDefault(src.maxBytesPerDay, DEFAULT_ASSOCIATION_WEB_LEARNING_CONFIG.maxBytesPerDay, 1),
|
|
590
|
+
maxDurationMs: intOrDefault(src.maxDurationMs, DEFAULT_ASSOCIATION_WEB_LEARNING_CONFIG.maxDurationMs, 1),
|
|
591
|
+
requestTimeoutMs: intOrDefault(src.requestTimeoutMs, DEFAULT_ASSOCIATION_WEB_LEARNING_CONFIG.requestTimeoutMs, 1),
|
|
592
|
+
maxRedirects: intOrDefault(src.maxRedirects, DEFAULT_ASSOCIATION_WEB_LEARNING_CONFIG.maxRedirects, 0),
|
|
593
|
+
discoverLinks: src.discoverLinks === true,
|
|
594
|
+
nodeTtlMs: intOrDefault(src.nodeTtlMs, DEFAULT_ASSOCIATION_WEB_LEARNING_CONFIG.nodeTtlMs, 0),
|
|
595
|
+
...(typeof src.budgetId === 'string' && src.budgetId.length > 0
|
|
596
|
+
? { budgetId: src.budgetId }
|
|
597
|
+
: {}),
|
|
598
|
+
...(typeof src.budgetAmount === 'number' &&
|
|
599
|
+
Number.isFinite(src.budgetAmount) &&
|
|
600
|
+
src.budgetAmount > 0
|
|
601
|
+
? { budgetAmount: src.budgetAmount }
|
|
602
|
+
: {}),
|
|
603
|
+
};
|
|
604
|
+
return Object.freeze(normalized);
|
|
605
|
+
}
|
|
606
|
+
function validateCrossFieldConstraints(parsed) {
|
|
607
|
+
const maxItems = parsed.maxItems ?? 8;
|
|
608
|
+
const minItems = parsed.minItems ?? 5;
|
|
609
|
+
if (minItems > maxItems) {
|
|
610
|
+
throw new Error(`assistant-association: minItems (${minItems}) cannot exceed maxItems (${maxItems})`);
|
|
611
|
+
}
|
|
612
|
+
if (parsed.databasePath !== undefined && !isCanonicalPathOrMemory(parsed.databasePath)) {
|
|
613
|
+
throw new Error('assistant-association: databasePath must be :memory: or a canonical absolute path');
|
|
614
|
+
}
|
|
615
|
+
if (parsed.holdoutSeedPath !== undefined &&
|
|
616
|
+
(!isAbsolute(parsed.holdoutSeedPath) || resolve(parsed.holdoutSeedPath) !== parsed.holdoutSeedPath)) {
|
|
617
|
+
throw new Error('assistant-association: holdoutSeedPath must be a canonical absolute path');
|
|
618
|
+
}
|
|
619
|
+
const heb = parsed.hebbian ?? DEFAULT_HEBBIAN_CONFIG;
|
|
620
|
+
const alpha = heb.alpha ?? DEFAULT_HEBBIAN_CONFIG.alpha;
|
|
621
|
+
const weakRatio = heb.weakRatio ?? DEFAULT_HEBBIAN_CONFIG.weakRatio;
|
|
622
|
+
const beta = heb.beta ?? DEFAULT_HEBBIAN_CONFIG.beta;
|
|
623
|
+
const weightMin = heb.weightMin ?? DEFAULT_HEBBIAN_CONFIG.weightMin;
|
|
624
|
+
const weightMax = heb.weightMax ?? DEFAULT_HEBBIAN_CONFIG.weightMax;
|
|
625
|
+
const initialHebbianWeight = heb.initialHebbianWeight ?? DEFAULT_HEBBIAN_CONFIG.initialHebbianWeight;
|
|
626
|
+
const decayHalfLifeMs = heb.decayHalfLifeMs ?? DEFAULT_HEBBIAN_CONFIG.decayHalfLifeMs;
|
|
627
|
+
const nonUseGraceMs = heb.nonUseGraceMs ?? DEFAULT_HEBBIAN_CONFIG.nonUseGraceMs;
|
|
628
|
+
const decayIntervalMs = heb.decayIntervalMs ?? DEFAULT_HEBBIAN_CONFIG.decayIntervalMs;
|
|
629
|
+
const correctionLookbackMs = heb.correctionLookbackMs ?? DEFAULT_HEBBIAN_CONFIG.correctionLookbackMs;
|
|
630
|
+
assertFiniteRange(alpha, 'hebbian.alpha', (n) => n >= 0, 'must be >= 0');
|
|
631
|
+
assertFiniteRange(weakRatio, 'hebbian.weakRatio', (n) => n >= 0 && n <= 1, 'must be in [0, 1]');
|
|
632
|
+
assertFiniteRange(beta, 'hebbian.beta', (n) => n >= 0, 'must be >= 0');
|
|
633
|
+
assertFiniteRange(weightMin, 'hebbian.weightMin', (n) => n >= 0, 'must be >= 0');
|
|
634
|
+
assertFiniteRange(weightMax, 'hebbian.weightMax', (n) => n >= 0, 'must be >= 0');
|
|
635
|
+
assertFiniteRange(initialHebbianWeight, 'hebbian.initialHebbianWeight', (n) => n >= weightMin && n <= weightMax, `must satisfy weightMin (${weightMin}) <= initialHebbianWeight <= weightMax (${weightMax})`);
|
|
636
|
+
if (weightMin > weightMax) {
|
|
637
|
+
throw new Error(`assistant-association: hebbian.weightMin (${weightMin}) cannot exceed hebbian.weightMax (${weightMax})`);
|
|
638
|
+
}
|
|
639
|
+
assertFiniteRange(decayHalfLifeMs, 'hebbian.decayHalfLifeMs', (n) => n > 0, 'must be > 0');
|
|
640
|
+
assertFiniteRange(nonUseGraceMs, 'hebbian.nonUseGraceMs', (n) => n >= 0, 'must be >= 0');
|
|
641
|
+
assertFiniteRange(decayIntervalMs, 'hebbian.decayIntervalMs', (n) => n >= 1_000, 'must be >= 1000');
|
|
642
|
+
assertFiniteRange(correctionLookbackMs, 'hebbian.correctionLookbackMs', (n) => n >= 0, 'must be >= 0');
|
|
643
|
+
const pt = parsed.paramTuning ?? DEFAULT_PARAM_TUNING_CONFIG;
|
|
644
|
+
for (const [key, val] of [
|
|
645
|
+
['minSample', pt.minSample ?? DEFAULT_PARAM_TUNING_CONFIG.minSample],
|
|
646
|
+
['minStepSample', pt.minStepSample ?? DEFAULT_PARAM_TUNING_CONFIG.minStepSample],
|
|
647
|
+
['minHoldoutSamples', pt.minHoldoutSamples ?? DEFAULT_PARAM_TUNING_CONFIG.minHoldoutSamples],
|
|
648
|
+
['minSourceSample', pt.minSourceSample ?? DEFAULT_PARAM_TUNING_CONFIG.minSourceSample],
|
|
649
|
+
['observationMs', pt.observationMs ?? DEFAULT_PARAM_TUNING_CONFIG.observationMs],
|
|
650
|
+
['evaluationWindowMs', pt.evaluationWindowMs ?? DEFAULT_PARAM_TUNING_CONFIG.evaluationWindowMs],
|
|
651
|
+
[
|
|
652
|
+
'relaxationReplayWindowMs',
|
|
653
|
+
pt.relaxationReplayWindowMs ?? DEFAULT_PARAM_TUNING_CONFIG.relaxationReplayWindowMs,
|
|
654
|
+
],
|
|
655
|
+
]) {
|
|
656
|
+
assertFiniteRange(val, `paramTuning.${key}`, (n) => n >= 1, 'must be >= 1');
|
|
657
|
+
}
|
|
658
|
+
assertFiniteRange(pt.rollbackCooldownMs ?? DEFAULT_PARAM_TUNING_CONFIG.rollbackCooldownMs, 'paramTuning.rollbackCooldownMs', (n) => n >= 0, 'must be >= 0');
|
|
659
|
+
for (const [key, val] of [
|
|
660
|
+
['maxTimeoutRatePpm', pt.maxTimeoutRatePpm ?? DEFAULT_PARAM_TUNING_CONFIG.maxTimeoutRatePpm],
|
|
661
|
+
['lowUsageRatePpm', pt.lowUsageRatePpm ?? DEFAULT_PARAM_TUNING_CONFIG.lowUsageRatePpm],
|
|
662
|
+
['healthyUsageRatePpm', pt.healthyUsageRatePpm ?? DEFAULT_PARAM_TUNING_CONFIG.healthyUsageRatePpm],
|
|
663
|
+
[
|
|
664
|
+
'highCorrectionRatePpm',
|
|
665
|
+
pt.highCorrectionRatePpm ?? DEFAULT_PARAM_TUNING_CONFIG.highCorrectionRatePpm,
|
|
666
|
+
],
|
|
667
|
+
['noisySourceRatePpm', pt.noisySourceRatePpm ?? DEFAULT_PARAM_TUNING_CONFIG.noisySourceRatePpm],
|
|
668
|
+
['regressionMarginPpm', pt.regressionMarginPpm ?? DEFAULT_PARAM_TUNING_CONFIG.regressionMarginPpm],
|
|
669
|
+
['timeoutMarginPpm', pt.timeoutMarginPpm ?? DEFAULT_PARAM_TUNING_CONFIG.timeoutMarginPpm],
|
|
670
|
+
['maxTimeoutMarginPpm', pt.maxTimeoutMarginPpm ?? DEFAULT_PARAM_TUNING_CONFIG.maxTimeoutMarginPpm],
|
|
671
|
+
['usageDropMarginPpm', pt.usageDropMarginPpm ?? DEFAULT_PARAM_TUNING_CONFIG.usageDropMarginPpm],
|
|
672
|
+
]) {
|
|
673
|
+
assertFiniteRange(val, `paramTuning.${key}`, (n) => n >= 0 && n <= 1_000_000, 'must be in [0, 1000000]');
|
|
674
|
+
}
|
|
675
|
+
const dream = parsed.dreaming ?? DEFAULT_ASSOCIATION_DREAMING_CONFIG;
|
|
676
|
+
assertFiniteRange(dream.intervalMs ?? DEFAULT_ASSOCIATION_DREAMING_CONFIG.intervalMs, 'dreaming.intervalMs', (n) => n >= 0, 'must be >= 0');
|
|
677
|
+
assertFiniteRange(dream.idleMinMs ?? DEFAULT_ASSOCIATION_DREAMING_CONFIG.idleMinMs, 'dreaming.idleMinMs', (n) => n >= 0, 'must be >= 0');
|
|
678
|
+
assertFiniteRange(dream.maxPairsPerRun ?? DEFAULT_ASSOCIATION_DREAMING_CONFIG.maxPairsPerRun, 'dreaming.maxPairsPerRun', (n) => n >= 0, 'must be >= 0');
|
|
679
|
+
assertFiniteRange(dream.maxAbstractionsPerRun ?? DEFAULT_ASSOCIATION_DREAMING_CONFIG.maxAbstractionsPerRun, 'dreaming.maxAbstractionsPerRun', (n) => n >= 0, 'must be >= 0');
|
|
680
|
+
assertFiniteRange(dream.maxSynonymsPerRun ?? DEFAULT_ASSOCIATION_DREAMING_CONFIG.maxSynonymsPerRun, 'dreaming.maxSynonymsPerRun', (n) => n >= 0, 'must be >= 0');
|
|
681
|
+
assertFiniteRange(dream.nodeTtlMs ?? DEFAULT_ASSOCIATION_DREAMING_CONFIG.nodeTtlMs, 'dreaming.nodeTtlMs', (n) => n >= 0, 'must be >= 0');
|
|
682
|
+
if (dream.budgetAmount !== undefined) {
|
|
683
|
+
assertFiniteRange(dream.budgetAmount, 'dreaming.budgetAmount', (n) => n > 0, 'must be > 0');
|
|
684
|
+
}
|
|
685
|
+
const intake = parsed.intakeSignal ?? DEFAULT_ASSOCIATION_INTAKE_SIGNAL_CONFIG;
|
|
686
|
+
assertFiniteRange(intake.minScore ?? DEFAULT_ASSOCIATION_INTAKE_SIGNAL_CONFIG.minScore, 'intakeSignal.minScore', (n) => n >= 0, 'must be >= 0');
|
|
687
|
+
assertFiniteRange(intake.maxSignalsPerHour ?? DEFAULT_ASSOCIATION_INTAKE_SIGNAL_CONFIG.maxSignalsPerHour, 'intakeSignal.maxSignalsPerHour', (n) => n >= 0, 'must be >= 0');
|
|
688
|
+
assertFiniteRange(intake.cooldownMs ?? DEFAULT_ASSOCIATION_INTAKE_SIGNAL_CONFIG.cooldownMs, 'intakeSignal.cooldownMs', (n) => n >= 0, 'must be >= 0');
|
|
689
|
+
assertFiniteRange(intake.maxSummaryBytes ?? DEFAULT_ASSOCIATION_INTAKE_SIGNAL_CONFIG.maxSummaryBytes, 'intakeSignal.maxSummaryBytes', (n) => n >= 64 && n <= 65_536, 'must be in [64, 65536]');
|
|
690
|
+
const sourceId = intake.sourceId ?? DEFAULT_ASSOCIATION_INTAKE_SIGNAL_CONFIG.sourceId;
|
|
691
|
+
if (!INTAKE_SOURCE_ID_RE.test(sourceId)) {
|
|
692
|
+
throw new Error('assistant-association: intakeSignal.sourceId must match /^[a-z][a-z0-9-]{0,63}$/u');
|
|
693
|
+
}
|
|
694
|
+
if (intake.budgetAmount !== undefined) {
|
|
695
|
+
assertFiniteRange(intake.budgetAmount, 'intakeSignal.budgetAmount', (n) => n > 0, 'must be > 0');
|
|
696
|
+
}
|
|
697
|
+
const clust = parsed.clustering ?? DEFAULT_CLUSTERING_CONFIG;
|
|
698
|
+
assertFiniteRange(clust.entityWeight ?? DEFAULT_CLUSTERING_CONFIG.entityWeight, 'clustering.entityWeight', (n) => n >= 0, 'must be >= 0');
|
|
699
|
+
assertFiniteRange(clust.toolWeight ?? DEFAULT_CLUSTERING_CONFIG.toolWeight, 'clustering.toolWeight', (n) => n >= 0, 'must be >= 0');
|
|
700
|
+
assertFiniteRange(clust.minSimilarity ?? DEFAULT_CLUSTERING_CONFIG.minSimilarity, 'clustering.minSimilarity', (n) => n >= 0 && n <= 1, 'must be in [0, 1]');
|
|
701
|
+
assertFiniteRange(clust.minClusterSize ?? DEFAULT_CLUSTERING_CONFIG.minClusterSize, 'clustering.minClusterSize', (n) => Number.isSafeInteger(n) && n >= 2, 'must be an integer >= 2');
|
|
702
|
+
assertFiniteRange(clust.reAskWindowMs ?? DEFAULT_CLUSTERING_CONFIG.reAskWindowMs, 'clustering.reAskWindowMs', (n) => n >= 0, 'must be >= 0');
|
|
703
|
+
assertFiniteRange(clust.reAskMinEntityJaccard ?? DEFAULT_CLUSTERING_CONFIG.reAskMinEntityJaccard, 'clustering.reAskMinEntityJaccard', (n) => n >= 0 && n <= 1, 'must be in [0, 1]');
|
|
704
|
+
const web = parsed.webLearning ?? DEFAULT_ASSOCIATION_WEB_LEARNING_CONFIG;
|
|
705
|
+
for (const domain of web.allowedDomains ?? DEFAULT_ASSOCIATION_WEB_LEARNING_CONFIG.allowedDomains) {
|
|
706
|
+
validateAndNormalizeAllowedDomain(domain);
|
|
707
|
+
}
|
|
708
|
+
for (const seedUrl of web.seedUrls ?? DEFAULT_ASSOCIATION_WEB_LEARNING_CONFIG.seedUrls) {
|
|
709
|
+
validateAndNormalizeSeedUrl(seedUrl);
|
|
710
|
+
}
|
|
711
|
+
const webIntervalMs = web.intervalMs ?? DEFAULT_ASSOCIATION_WEB_LEARNING_CONFIG.intervalMs;
|
|
712
|
+
const webIdleMinMs = web.idleMinMs ?? DEFAULT_ASSOCIATION_WEB_LEARNING_CONFIG.idleMinMs;
|
|
713
|
+
const webCooldownMs = web.cooldownMs ?? DEFAULT_ASSOCIATION_WEB_LEARNING_CONFIG.cooldownMs;
|
|
714
|
+
const webMaxInterestsPerRun = web.maxInterestsPerRun ?? DEFAULT_ASSOCIATION_WEB_LEARNING_CONFIG.maxInterestsPerRun;
|
|
715
|
+
const webMaxRequestsPerRun = web.maxRequestsPerRun ?? DEFAULT_ASSOCIATION_WEB_LEARNING_CONFIG.maxRequestsPerRun;
|
|
716
|
+
const webMaxPagesPerRun = web.maxPagesPerRun ?? DEFAULT_ASSOCIATION_WEB_LEARNING_CONFIG.maxPagesPerRun;
|
|
717
|
+
const webMaxBytesPerRequest = web.maxBytesPerRequest ?? DEFAULT_ASSOCIATION_WEB_LEARNING_CONFIG.maxBytesPerRequest;
|
|
718
|
+
const webMaxTotalBytesPerRun = web.maxTotalBytesPerRun ?? DEFAULT_ASSOCIATION_WEB_LEARNING_CONFIG.maxTotalBytesPerRun;
|
|
719
|
+
const webMaxRequestsPerDay = web.maxRequestsPerDay ?? DEFAULT_ASSOCIATION_WEB_LEARNING_CONFIG.maxRequestsPerDay;
|
|
720
|
+
const webMaxBytesPerDay = web.maxBytesPerDay ?? DEFAULT_ASSOCIATION_WEB_LEARNING_CONFIG.maxBytesPerDay;
|
|
721
|
+
const webMaxDurationMs = web.maxDurationMs ?? DEFAULT_ASSOCIATION_WEB_LEARNING_CONFIG.maxDurationMs;
|
|
722
|
+
const webRequestTimeoutMs = web.requestTimeoutMs ?? DEFAULT_ASSOCIATION_WEB_LEARNING_CONFIG.requestTimeoutMs;
|
|
723
|
+
const webMaxRedirects = web.maxRedirects ?? DEFAULT_ASSOCIATION_WEB_LEARNING_CONFIG.maxRedirects;
|
|
724
|
+
const webNodeTtlMs = web.nodeTtlMs ?? DEFAULT_ASSOCIATION_WEB_LEARNING_CONFIG.nodeTtlMs;
|
|
725
|
+
assertFiniteRange(webIntervalMs, 'webLearning.intervalMs', (n) => n >= 0, 'must be >= 0');
|
|
726
|
+
assertFiniteRange(webIdleMinMs, 'webLearning.idleMinMs', (n) => n >= 0, 'must be >= 0');
|
|
727
|
+
assertFiniteRange(webCooldownMs, 'webLearning.cooldownMs', (n) => n >= 0, 'must be >= 0');
|
|
728
|
+
assertFiniteRange(webMaxInterestsPerRun, 'webLearning.maxInterestsPerRun', (n) => Number.isSafeInteger(n) && n >= 1, 'must be an integer >= 1');
|
|
729
|
+
assertFiniteRange(webMaxRequestsPerRun, 'webLearning.maxRequestsPerRun', (n) => Number.isSafeInteger(n) && n >= 1, 'must be an integer >= 1');
|
|
730
|
+
assertFiniteRange(webMaxPagesPerRun, 'webLearning.maxPagesPerRun', (n) => Number.isSafeInteger(n) && n >= 1, 'must be an integer >= 1');
|
|
731
|
+
assertFiniteRange(webMaxBytesPerRequest, 'webLearning.maxBytesPerRequest', (n) => Number.isSafeInteger(n) && n >= 1, 'must be an integer >= 1');
|
|
732
|
+
assertFiniteRange(webMaxTotalBytesPerRun, 'webLearning.maxTotalBytesPerRun', (n) => Number.isSafeInteger(n) && n >= 1, 'must be an integer >= 1');
|
|
733
|
+
assertFiniteRange(webMaxRequestsPerDay, 'webLearning.maxRequestsPerDay', (n) => Number.isSafeInteger(n) && n >= 1, 'must be an integer >= 1');
|
|
734
|
+
assertFiniteRange(webMaxBytesPerDay, 'webLearning.maxBytesPerDay', (n) => Number.isSafeInteger(n) && n >= 1, 'must be an integer >= 1');
|
|
735
|
+
assertFiniteRange(webMaxDurationMs, 'webLearning.maxDurationMs', (n) => Number.isSafeInteger(n) && n >= 1, 'must be an integer >= 1');
|
|
736
|
+
assertFiniteRange(webRequestTimeoutMs, 'webLearning.requestTimeoutMs', (n) => Number.isSafeInteger(n) && n >= 1, 'must be an integer >= 1');
|
|
737
|
+
assertFiniteRange(webMaxRedirects, 'webLearning.maxRedirects', (n) => Number.isSafeInteger(n) && n >= 0, 'must be an integer >= 0');
|
|
738
|
+
assertFiniteRange(webNodeTtlMs, 'webLearning.nodeTtlMs', (n) => n >= 0, 'must be >= 0');
|
|
739
|
+
if (web.budgetAmount !== undefined) {
|
|
740
|
+
assertFiniteRange(web.budgetAmount, 'webLearning.budgetAmount', (n) => n > 0, 'must be > 0');
|
|
741
|
+
}
|
|
742
|
+
if (webMaxPagesPerRun > webMaxRequestsPerRun) {
|
|
743
|
+
throw new Error(`assistant-association: webLearning.maxPagesPerRun (${webMaxPagesPerRun}) cannot exceed webLearning.maxRequestsPerRun (${webMaxRequestsPerRun})`);
|
|
744
|
+
}
|
|
745
|
+
if (webMaxRequestsPerRun > webMaxRequestsPerDay) {
|
|
746
|
+
throw new Error(`assistant-association: webLearning.maxRequestsPerRun (${webMaxRequestsPerRun}) cannot exceed webLearning.maxRequestsPerDay (${webMaxRequestsPerDay})`);
|
|
747
|
+
}
|
|
748
|
+
if (webMaxBytesPerRequest > webMaxTotalBytesPerRun) {
|
|
749
|
+
throw new Error(`assistant-association: webLearning.maxBytesPerRequest (${webMaxBytesPerRequest}) cannot exceed webLearning.maxTotalBytesPerRun (${webMaxTotalBytesPerRun})`);
|
|
750
|
+
}
|
|
751
|
+
if (webMaxTotalBytesPerRun > webMaxBytesPerDay) {
|
|
752
|
+
throw new Error(`assistant-association: webLearning.maxTotalBytesPerRun (${webMaxTotalBytesPerRun}) cannot exceed webLearning.maxBytesPerDay (${webMaxBytesPerDay})`);
|
|
753
|
+
}
|
|
754
|
+
if (webRequestTimeoutMs > webMaxDurationMs) {
|
|
755
|
+
throw new Error(`assistant-association: webLearning.requestTimeoutMs (${webRequestTimeoutMs}) cannot exceed webLearning.maxDurationMs (${webMaxDurationMs})`);
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
export function normalizeConfig(input) {
|
|
759
|
+
const parsed = (Config(input ?? {}) ?? {});
|
|
760
|
+
const enabled = parsed.enabled ?? true;
|
|
761
|
+
const maxItems = parsed.maxItems ?? 8;
|
|
762
|
+
const minItems = parsed.minItems ?? 5;
|
|
763
|
+
const databasePath = parsed.databasePath ?? null;
|
|
764
|
+
const holdoutSeedPath = parsed.holdoutSeedPath ?? null;
|
|
765
|
+
if (enabled && databasePath === null) {
|
|
766
|
+
throw new Error('assistant-association: enabled requires databasePath');
|
|
767
|
+
}
|
|
768
|
+
const heb = parsed.hebbian ?? {};
|
|
769
|
+
const pt = parsed.paramTuning ?? {};
|
|
770
|
+
const hebbian = Object.freeze({
|
|
771
|
+
enabled: heb.enabled ?? DEFAULT_HEBBIAN_CONFIG.enabled,
|
|
772
|
+
alpha: heb.alpha ?? DEFAULT_HEBBIAN_CONFIG.alpha,
|
|
773
|
+
weakRatio: heb.weakRatio ?? DEFAULT_HEBBIAN_CONFIG.weakRatio,
|
|
774
|
+
beta: heb.beta ?? DEFAULT_HEBBIAN_CONFIG.beta,
|
|
775
|
+
weightMin: heb.weightMin ?? DEFAULT_HEBBIAN_CONFIG.weightMin,
|
|
776
|
+
weightMax: heb.weightMax ?? DEFAULT_HEBBIAN_CONFIG.weightMax,
|
|
777
|
+
initialHebbianWeight: heb.initialHebbianWeight ?? DEFAULT_HEBBIAN_CONFIG.initialHebbianWeight,
|
|
778
|
+
decayHalfLifeMs: heb.decayHalfLifeMs ?? DEFAULT_HEBBIAN_CONFIG.decayHalfLifeMs,
|
|
779
|
+
nonUseGraceMs: heb.nonUseGraceMs ?? DEFAULT_HEBBIAN_CONFIG.nonUseGraceMs,
|
|
780
|
+
decayIntervalMs: heb.decayIntervalMs ?? DEFAULT_HEBBIAN_CONFIG.decayIntervalMs,
|
|
781
|
+
correctionLookbackMs: heb.correctionLookbackMs ?? DEFAULT_HEBBIAN_CONFIG.correctionLookbackMs,
|
|
782
|
+
});
|
|
783
|
+
const paramTuning = Object.freeze({
|
|
784
|
+
enabled: pt.enabled ?? DEFAULT_PARAM_TUNING_CONFIG.enabled,
|
|
785
|
+
minSample: pt.minSample ?? DEFAULT_PARAM_TUNING_CONFIG.minSample,
|
|
786
|
+
minStepSample: pt.minStepSample ?? DEFAULT_PARAM_TUNING_CONFIG.minStepSample,
|
|
787
|
+
minHoldoutSamples: pt.minHoldoutSamples ?? DEFAULT_PARAM_TUNING_CONFIG.minHoldoutSamples,
|
|
788
|
+
minSourceSample: pt.minSourceSample ?? DEFAULT_PARAM_TUNING_CONFIG.minSourceSample,
|
|
789
|
+
maxTimeoutRatePpm: pt.maxTimeoutRatePpm ?? DEFAULT_PARAM_TUNING_CONFIG.maxTimeoutRatePpm,
|
|
790
|
+
lowUsageRatePpm: pt.lowUsageRatePpm ?? DEFAULT_PARAM_TUNING_CONFIG.lowUsageRatePpm,
|
|
791
|
+
healthyUsageRatePpm: pt.healthyUsageRatePpm ?? DEFAULT_PARAM_TUNING_CONFIG.healthyUsageRatePpm,
|
|
792
|
+
highCorrectionRatePpm: pt.highCorrectionRatePpm ?? DEFAULT_PARAM_TUNING_CONFIG.highCorrectionRatePpm,
|
|
793
|
+
noisySourceRatePpm: pt.noisySourceRatePpm ?? DEFAULT_PARAM_TUNING_CONFIG.noisySourceRatePpm,
|
|
794
|
+
regressionMarginPpm: pt.regressionMarginPpm ?? DEFAULT_PARAM_TUNING_CONFIG.regressionMarginPpm,
|
|
795
|
+
timeoutMarginPpm: pt.timeoutMarginPpm ?? DEFAULT_PARAM_TUNING_CONFIG.timeoutMarginPpm,
|
|
796
|
+
maxTimeoutMarginPpm: pt.maxTimeoutMarginPpm ?? DEFAULT_PARAM_TUNING_CONFIG.maxTimeoutMarginPpm,
|
|
797
|
+
usageDropMarginPpm: pt.usageDropMarginPpm ?? DEFAULT_PARAM_TUNING_CONFIG.usageDropMarginPpm,
|
|
798
|
+
observationMs: pt.observationMs ?? DEFAULT_PARAM_TUNING_CONFIG.observationMs,
|
|
799
|
+
evaluationWindowMs: pt.evaluationWindowMs ?? DEFAULT_PARAM_TUNING_CONFIG.evaluationWindowMs,
|
|
800
|
+
relaxationReplayWindowMs: pt.relaxationReplayWindowMs ?? DEFAULT_PARAM_TUNING_CONFIG.relaxationReplayWindowMs,
|
|
801
|
+
relaxationReplayEnabled: pt.relaxationReplayEnabled ?? DEFAULT_PARAM_TUNING_CONFIG.relaxationReplayEnabled,
|
|
802
|
+
rollbackCooldownMs: pt.rollbackCooldownMs ?? DEFAULT_PARAM_TUNING_CONFIG.rollbackCooldownMs,
|
|
803
|
+
});
|
|
804
|
+
return Object.freeze({
|
|
805
|
+
enabled,
|
|
806
|
+
localOnly: parsed.localOnly ?? true,
|
|
807
|
+
databasePath,
|
|
808
|
+
holdoutSeedPath,
|
|
809
|
+
holdoutSeed: parsed.holdoutSeed ?? null,
|
|
810
|
+
holdoutRateBps: parsed.holdoutRateBps ?? DEFAULT_HOLDOUT_RATE_BPS,
|
|
811
|
+
hotPathBudgetMs: parsed.hotPathBudgetMs ?? 4.5,
|
|
812
|
+
maxItems,
|
|
813
|
+
minItems,
|
|
814
|
+
maxContextTokens: parsed.maxContextTokens ?? 400,
|
|
815
|
+
maxHops: parsed.maxHops ?? 2,
|
|
816
|
+
hopTopN: parsed.hopTopN ?? 32,
|
|
817
|
+
maxFanoutPerNode: parsed.maxFanoutPerNode ?? 128,
|
|
818
|
+
hysteresisDelta: parsed.hysteresisDelta ?? 0.15,
|
|
819
|
+
decayHalfLifeMs: parsed.decayHalfLifeMs ?? DEFAULT_DECAY_HALF_LIFE_MS,
|
|
820
|
+
syncIntervalMs: parsed.syncIntervalMs ?? 15_000,
|
|
821
|
+
allowHeadlessScope: parsed.allowHeadlessScope ?? false,
|
|
822
|
+
allowLowTrust: parsed.allowLowTrust ?? true,
|
|
823
|
+
allowSensitive: parsed.allowSensitive ?? false,
|
|
824
|
+
sourceWeights: DEFAULT_SOURCE_WEIGHTS,
|
|
825
|
+
hebbian,
|
|
826
|
+
paramTuning,
|
|
827
|
+
dreaming: normalizeAssociationDreamingConfig(parsed.dreaming),
|
|
828
|
+
intakeSignal: normalizeAssociationIntakeSignalConfig(parsed.intakeSignal),
|
|
829
|
+
clustering: normalizeClusteringConfig(parsed.clustering),
|
|
830
|
+
webLearning: normalizeAssociationWebLearningConfig(parsed.webLearning),
|
|
831
|
+
});
|
|
832
|
+
}
|
|
833
|
+
export const normalizeAssociationConfig = normalizeConfig;
|
|
834
|
+
//# sourceMappingURL=config.js.map
|