@graphrefly/graphrefly 0.47.0 → 0.47.2
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/base/composition/index.cjs +24 -16
- package/dist/base/composition/index.cjs.map +1 -1
- package/dist/base/composition/index.js +6 -6
- package/dist/base/index.cjs +142 -86
- package/dist/base/index.cjs.map +1 -1
- package/dist/base/index.js +11 -11
- package/dist/base/io/index.cjs +114 -68
- package/dist/base/io/index.cjs.map +1 -1
- package/dist/base/io/index.js +5 -5
- package/dist/base/sources/browser/index.cjs +13 -9
- package/dist/base/sources/browser/index.cjs.map +1 -1
- package/dist/base/sources/browser/index.js +13 -9
- package/dist/base/sources/browser/index.js.map +1 -1
- package/dist/base/sources/event/index.cjs +1 -1
- package/dist/base/sources/event/index.cjs.map +1 -1
- package/dist/base/sources/event/index.js +1 -1
- package/dist/base/sources/index.cjs +21 -13
- package/dist/base/sources/index.cjs.map +1 -1
- package/dist/base/sources/index.js +3 -3
- package/dist/base/sources/node/index.cjs +43 -37
- package/dist/base/sources/node/index.cjs.map +1 -1
- package/dist/base/sources/node/index.js +43 -37
- package/dist/base/sources/node/index.js.map +1 -1
- package/dist/{chunk-VLAGJZSL.js → chunk-3O3NKZJW.js} +2 -2
- package/dist/{chunk-YJ4U2D2C.js → chunk-446I4EGD.js} +9 -7
- package/dist/chunk-446I4EGD.js.map +1 -0
- package/dist/{chunk-DKNHAICT.js → chunk-5GVURVIG.js} +14 -8
- package/dist/chunk-5GVURVIG.js.map +1 -0
- package/dist/{chunk-2OB3CEJS.js → chunk-6MRSX3YK.js} +2 -2
- package/dist/{chunk-EVYY4X5A.js → chunk-6ZLCPUXS.js} +2 -2
- package/dist/{chunk-ZVXXDWIB.js → chunk-7AVQIGF6.js} +514 -33
- package/dist/chunk-7AVQIGF6.js.map +1 -0
- package/dist/{chunk-7EGRP2VX.js → chunk-7BULJTL6.js} +2 -2
- package/dist/{chunk-7EGRP2VX.js.map → chunk-7BULJTL6.js.map} +1 -1
- package/dist/{chunk-FW23JYNQ.js → chunk-CEVNQ74M.js} +2 -2
- package/dist/{chunk-CGHORL6G.js → chunk-DDTS7F5O.js} +7 -5
- package/dist/chunk-DDTS7F5O.js.map +1 -0
- package/dist/{chunk-OCUDSN63.js → chunk-EL5VHUGK.js} +79 -47
- package/dist/chunk-EL5VHUGK.js.map +1 -0
- package/dist/{chunk-4GYMCUDZ.js → chunk-EP4WVQLX.js} +5 -5
- package/dist/{chunk-SOOKUYVM.js → chunk-F7EKHR32.js} +13 -9
- package/dist/chunk-F7EKHR32.js.map +1 -0
- package/dist/{chunk-JKTC747G.js → chunk-FQSQONOU.js} +4 -4
- package/dist/{chunk-JGFRAFDL.js → chunk-FVINAAKA.js} +3 -3
- package/dist/{chunk-RAGGHLCV.js → chunk-GUNIRPEJ.js} +8 -6
- package/dist/{chunk-RAGGHLCV.js.map → chunk-GUNIRPEJ.js.map} +1 -1
- package/dist/{chunk-BU3SEFA5.js → chunk-IOJDYUA7.js} +2 -2
- package/dist/{chunk-Y52CS6YA.js → chunk-JA67ZQG2.js} +2 -2
- package/dist/{chunk-Y52CS6YA.js.map → chunk-JA67ZQG2.js.map} +1 -1
- package/dist/{chunk-DM4OMPWK.js → chunk-KNU73RZW.js} +2 -2
- package/dist/{chunk-GWRNLJNW.js → chunk-KRFGO5QH.js} +19 -15
- package/dist/{chunk-GWRNLJNW.js.map → chunk-KRFGO5QH.js.map} +1 -1
- package/dist/{chunk-Z4YXAUDN.js → chunk-KUFXLAEY.js} +11 -7
- package/dist/{chunk-Z4YXAUDN.js.map → chunk-KUFXLAEY.js.map} +1 -1
- package/dist/{chunk-Z6EGP5D7.js → chunk-LDCSZ72P.js} +2 -2
- package/dist/{chunk-5IMMNARC.js → chunk-MS3WPRJR.js} +37 -25
- package/dist/chunk-MS3WPRJR.js.map +1 -0
- package/dist/{chunk-CXANAIZU.js → chunk-N65E26UL.js} +3 -3
- package/dist/{chunk-O3MT7DYI.js → chunk-N6MNJNHB.js} +2 -2
- package/dist/{chunk-Q3EYOCZB.js → chunk-NPRP3MCV.js} +111 -2
- package/dist/chunk-NPRP3MCV.js.map +1 -0
- package/dist/{chunk-A7KV5UK4.js → chunk-OXD5LFQP.js} +2 -2
- package/dist/{chunk-ZT4WMQW4.js → chunk-PTWADEH3.js} +9 -7
- package/dist/chunk-PTWADEH3.js.map +1 -0
- package/dist/{chunk-IHTWQEDR.js → chunk-QFE5BQH7.js} +2 -2
- package/dist/{chunk-IHTWQEDR.js.map → chunk-QFE5BQH7.js.map} +1 -1
- package/dist/{chunk-22SG74BD.js → chunk-R6ZCSXKX.js} +3 -3
- package/dist/{chunk-PZWISPIQ.js → chunk-S7HN5FHL.js} +17 -11
- package/dist/chunk-S7HN5FHL.js.map +1 -0
- package/dist/{chunk-RJOG4IJU.js → chunk-T7SP3EYR.js} +18 -12
- package/dist/chunk-T7SP3EYR.js.map +1 -0
- package/dist/{chunk-4S53H2KR.js → chunk-VAZXUK6G.js} +2 -2
- package/dist/{chunk-IJRR6YAI.js → chunk-VLDRAMP7.js} +18 -12
- package/dist/chunk-VLDRAMP7.js.map +1 -0
- package/dist/{chunk-TNX5ZGDJ.js → chunk-VNXAF2KE.js} +4 -4
- package/dist/{chunk-EHRRQ4IC.js → chunk-VP3TIUDF.js} +2 -2
- package/dist/{chunk-6XZYT4SW.js → chunk-WGDEBIP4.js} +5 -5
- package/dist/{chunk-E5OZPDIW.js → chunk-X7BA5PWG.js} +7 -5
- package/dist/chunk-X7BA5PWG.js.map +1 -0
- package/dist/compat/index.cjs +1 -1
- package/dist/compat/index.cjs.map +1 -1
- package/dist/compat/index.js +2 -2
- package/dist/compat/nestjs/index.cjs +1 -1
- package/dist/compat/nestjs/index.cjs.map +1 -1
- package/dist/compat/nestjs/index.js +2 -2
- package/dist/index.cjs +1657 -982
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +58 -36
- package/dist/index.js.map +1 -1
- package/dist/presets/ai/index.cjs +42 -26
- package/dist/presets/ai/index.cjs.map +1 -1
- package/dist/presets/ai/index.js +11 -11
- package/dist/presets/harness/index.cjs +53 -33
- package/dist/presets/harness/index.cjs.map +1 -1
- package/dist/presets/harness/index.js +22 -22
- package/dist/presets/index.cjs +76 -48
- package/dist/presets/index.cjs.map +1 -1
- package/dist/presets/index.js +28 -28
- package/dist/presets/inspect/index.cjs.map +1 -1
- package/dist/presets/inspect/index.js +4 -4
- package/dist/presets/resilience/index.cjs +35 -23
- package/dist/presets/resilience/index.cjs.map +1 -1
- package/dist/presets/resilience/index.js +5 -5
- package/dist/solutions/index.cjs +71 -45
- package/dist/solutions/index.cjs.map +1 -1
- package/dist/solutions/index.js +24 -24
- package/dist/{timeout-U5O4ESK3.js → timeout-BEABACRP.js} +2 -2
- package/dist/utils/ai/browser.cjs.map +1 -1
- package/dist/utils/ai/browser.js +9 -9
- package/dist/utils/ai/index.cjs +41 -25
- package/dist/utils/ai/index.cjs.map +1 -1
- package/dist/utils/ai/index.js +18 -18
- package/dist/utils/ai/node.js +3 -3
- package/dist/utils/domain-templates/index.cjs +1 -1
- package/dist/utils/domain-templates/index.cjs.map +1 -1
- package/dist/utils/domain-templates/index.js +2 -2
- package/dist/utils/graphspec/index.cjs +1 -1
- package/dist/utils/graphspec/index.cjs.map +1 -1
- package/dist/utils/graphspec/index.js +2 -2
- package/dist/utils/harness/index.cjs +16 -10
- package/dist/utils/harness/index.cjs.map +1 -1
- package/dist/utils/harness/index.js +1 -1
- package/dist/utils/index.cjs +1069 -452
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.d.cts +2 -2
- package/dist/utils/index.d.ts +2 -2
- package/dist/utils/index.js +45 -23
- package/dist/utils/inspect/index.cjs.map +1 -1
- package/dist/utils/inspect/index.js +2 -2
- package/dist/utils/memory/index.cjs +513 -37
- package/dist/utils/memory/index.cjs.map +1 -1
- package/dist/utils/memory/index.d.cts +641 -3
- package/dist/utils/memory/index.d.ts +641 -3
- package/dist/utils/memory/index.js +19 -1
- package/dist/utils/messaging/index.cjs +109 -0
- package/dist/utils/messaging/index.cjs.map +1 -1
- package/dist/utils/messaging/index.d.cts +115 -2
- package/dist/utils/messaging/index.d.ts +115 -2
- package/dist/utils/messaging/index.js +5 -1
- package/dist/utils/orchestration/index.cjs +5 -3
- package/dist/utils/orchestration/index.cjs.map +1 -1
- package/dist/utils/orchestration/index.js +2 -2
- package/dist/utils/process/index.js +2 -2
- package/dist/utils/reduction/index.cjs +1 -1
- package/dist/utils/reduction/index.cjs.map +1 -1
- package/dist/utils/reduction/index.js +1 -1
- package/dist/utils/resilience/index.cjs +35 -23
- package/dist/utils/resilience/index.cjs.map +1 -1
- package/dist/utils/resilience/index.js +4 -4
- package/dist/utils/surface/index.cjs +1 -1
- package/dist/utils/surface/index.cjs.map +1 -1
- package/dist/utils/surface/index.js +3 -3
- package/package.json +1 -1
- package/dist/chunk-5IMMNARC.js.map +0 -1
- package/dist/chunk-CGHORL6G.js.map +0 -1
- package/dist/chunk-DKNHAICT.js.map +0 -1
- package/dist/chunk-E5OZPDIW.js.map +0 -1
- package/dist/chunk-IJRR6YAI.js.map +0 -1
- package/dist/chunk-OCUDSN63.js.map +0 -1
- package/dist/chunk-PZWISPIQ.js.map +0 -1
- package/dist/chunk-Q3EYOCZB.js.map +0 -1
- package/dist/chunk-RJOG4IJU.js.map +0 -1
- package/dist/chunk-SOOKUYVM.js.map +0 -1
- package/dist/chunk-YJ4U2D2C.js.map +0 -1
- package/dist/chunk-ZT4WMQW4.js.map +0 -1
- package/dist/chunk-ZVXXDWIB.js.map +0 -1
- /package/dist/{chunk-VLAGJZSL.js.map → chunk-3O3NKZJW.js.map} +0 -0
- /package/dist/{chunk-2OB3CEJS.js.map → chunk-6MRSX3YK.js.map} +0 -0
- /package/dist/{chunk-EVYY4X5A.js.map → chunk-6ZLCPUXS.js.map} +0 -0
- /package/dist/{chunk-FW23JYNQ.js.map → chunk-CEVNQ74M.js.map} +0 -0
- /package/dist/{chunk-4GYMCUDZ.js.map → chunk-EP4WVQLX.js.map} +0 -0
- /package/dist/{chunk-JKTC747G.js.map → chunk-FQSQONOU.js.map} +0 -0
- /package/dist/{chunk-JGFRAFDL.js.map → chunk-FVINAAKA.js.map} +0 -0
- /package/dist/{chunk-BU3SEFA5.js.map → chunk-IOJDYUA7.js.map} +0 -0
- /package/dist/{chunk-DM4OMPWK.js.map → chunk-KNU73RZW.js.map} +0 -0
- /package/dist/{chunk-Z6EGP5D7.js.map → chunk-LDCSZ72P.js.map} +0 -0
- /package/dist/{chunk-CXANAIZU.js.map → chunk-N65E26UL.js.map} +0 -0
- /package/dist/{chunk-O3MT7DYI.js.map → chunk-N6MNJNHB.js.map} +0 -0
- /package/dist/{chunk-A7KV5UK4.js.map → chunk-OXD5LFQP.js.map} +0 -0
- /package/dist/{chunk-22SG74BD.js.map → chunk-R6ZCSXKX.js.map} +0 -0
- /package/dist/{chunk-4S53H2KR.js.map → chunk-VAZXUK6G.js.map} +0 -0
- /package/dist/{chunk-TNX5ZGDJ.js.map → chunk-VNXAF2KE.js.map} +0 -0
- /package/dist/{chunk-EHRRQ4IC.js.map → chunk-VP3TIUDF.js.map} +0 -0
- /package/dist/{chunk-6XZYT4SW.js.map → chunk-WGDEBIP4.js.map} +0 -0
- /package/dist/{timeout-U5O4ESK3.js.map → timeout-BEABACRP.js.map} +0 -0
package/dist/utils/index.cjs
CHANGED
|
@@ -43,9 +43,9 @@ function resolveReactiveOption(arg, onChange) {
|
|
|
43
43
|
if (!isNode(arg)) {
|
|
44
44
|
return { current: () => arg, unsub: () => void 0 };
|
|
45
45
|
}
|
|
46
|
-
const
|
|
47
|
-
let latest =
|
|
48
|
-
const unsub =
|
|
46
|
+
const node65 = arg;
|
|
47
|
+
let latest = node65.cache;
|
|
48
|
+
const unsub = node65.subscribe((msgs) => {
|
|
49
49
|
for (const m of msgs) {
|
|
50
50
|
if (m[0] === import_core13.DATA) {
|
|
51
51
|
latest = m[1];
|
|
@@ -318,11 +318,13 @@ function withTimeout(source, opts, extraOpts) {
|
|
|
318
318
|
if (latestOpts != null) {
|
|
319
319
|
attachSource();
|
|
320
320
|
}
|
|
321
|
-
return
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
321
|
+
return {
|
|
322
|
+
onDeactivation: () => {
|
|
323
|
+
stopped = true;
|
|
324
|
+
timer.cancel();
|
|
325
|
+
if (srcUnsub) srcUnsub();
|
|
326
|
+
if (optsUnsub) optsUnsub();
|
|
327
|
+
}
|
|
326
328
|
};
|
|
327
329
|
},
|
|
328
330
|
{
|
|
@@ -378,6 +380,7 @@ __export(utils_exports, {
|
|
|
378
380
|
JobFlowGraph: () => JobFlowGraph,
|
|
379
381
|
JobQueueGraph: () => JobQueueGraph,
|
|
380
382
|
LLMTimeoutError: () => LLMTimeoutError,
|
|
383
|
+
LogProjectorGraph: () => LogProjectorGraph,
|
|
381
384
|
MemoryRetrievalGraph: () => MemoryRetrievalGraph,
|
|
382
385
|
MemoryWithKGGraph: () => MemoryWithKGGraph,
|
|
383
386
|
MemoryWithTiersGraph: () => MemoryWithTiersGraph,
|
|
@@ -414,6 +417,7 @@ __export(utils_exports, {
|
|
|
414
417
|
actuatorExecutor: () => actuatorExecutor,
|
|
415
418
|
adaptiveRateLimiter: () => adaptiveRateLimiter,
|
|
416
419
|
admissionFilter3D: () => admissionFilter3D,
|
|
420
|
+
admissionLlmJudge: () => admissionLlmJudge,
|
|
417
421
|
admissionScored: () => admissionScored,
|
|
418
422
|
affectedTaskFilter: () => affectedTaskFilter,
|
|
419
423
|
analyzeAndMeasure: () => analyzeAndMeasure,
|
|
@@ -422,6 +426,7 @@ __export(utils_exports, {
|
|
|
422
426
|
auditTrail: () => auditTrail,
|
|
423
427
|
autoSolidify: () => autoSolidify,
|
|
424
428
|
beforeAfterCompare: () => beforeAfterCompare,
|
|
429
|
+
bitemporalQuery: () => bitemporalQuery,
|
|
425
430
|
budgetGate: () => budgetGate,
|
|
426
431
|
carveTextLineSlots: () => carveTextLineSlots,
|
|
427
432
|
cascadingLlmAdapter: () => cascadingLlmAdapter,
|
|
@@ -440,6 +445,7 @@ __export(utils_exports, {
|
|
|
440
445
|
computeLineBreaks: () => computeLineBreaks,
|
|
441
446
|
computePrice: () => computePrice,
|
|
442
447
|
computeTotalHeight: () => computeTotalHeight,
|
|
448
|
+
consolidationRem: () => consolidationRem,
|
|
443
449
|
contentGate: () => contentGate,
|
|
444
450
|
contentModerationGraph: () => contentModerationGraph,
|
|
445
451
|
cosineSimilarity: () => cosineSimilarity,
|
|
@@ -452,6 +458,7 @@ __export(utils_exports, {
|
|
|
452
458
|
createIntakeBridge: () => createIntakeBridge,
|
|
453
459
|
createPricingRegistry: () => createPricingRegistry,
|
|
454
460
|
dataQualityGraph: () => dataQualityGraph,
|
|
461
|
+
decayExponential: () => decayExponential,
|
|
455
462
|
decisionKeyOf: () => decisionKeyOf,
|
|
456
463
|
decompileSpec: () => decompileSpec,
|
|
457
464
|
defaultErrorClassifier: () => defaultErrorClassifier,
|
|
@@ -481,6 +488,8 @@ __export(utils_exports, {
|
|
|
481
488
|
healthReportEqual: () => healthReportEqual,
|
|
482
489
|
hubRemoveTopicKeyOf: () => hubRemoveTopicKeyOf,
|
|
483
490
|
humanInput: () => humanInput,
|
|
491
|
+
influenceAnalysis: () => influenceAnalysis,
|
|
492
|
+
invalidationTracer: () => invalidationTracer,
|
|
484
493
|
isRichFnEntry: () => isRichFnEntry,
|
|
485
494
|
isRichSourceEntry: () => isRichSourceEntry,
|
|
486
495
|
issueTrackerGraph: () => issueTrackerGraph,
|
|
@@ -496,6 +505,7 @@ __export(utils_exports, {
|
|
|
496
505
|
llmConsolidator: () => llmConsolidator,
|
|
497
506
|
llmExtractor: () => llmExtractor,
|
|
498
507
|
llmRefine: () => llmRefine,
|
|
508
|
+
logProjector: () => logProjector,
|
|
499
509
|
measureBlock: () => measureBlock,
|
|
500
510
|
measureBlocks: () => measureBlocks,
|
|
501
511
|
memoryRetrieval: () => memoryRetrieval,
|
|
@@ -508,6 +518,7 @@ __export(utils_exports, {
|
|
|
508
518
|
observableAdapter: () => observableAdapter,
|
|
509
519
|
openAICompatAdapter: () => openAICompatAdapter,
|
|
510
520
|
parseRateLimitFromError: () => parseRateLimitFromError,
|
|
521
|
+
persistentReactiveFactStore: () => persistentReactiveFactStore,
|
|
511
522
|
pipelineGraph: () => pipelineGraph,
|
|
512
523
|
policyGate: () => policyGate,
|
|
513
524
|
pricingFor: () => pricingFor,
|
|
@@ -533,6 +544,8 @@ __export(utils_exports, {
|
|
|
533
544
|
sagaInvocationKeyOf: () => sagaInvocationKeyOf,
|
|
534
545
|
saveSnapshot: () => saveSnapshot,
|
|
535
546
|
scorer: () => scorer,
|
|
547
|
+
scoringByOutcome: () => scoringByOutcome,
|
|
548
|
+
shardByTenant: () => shardByTenant,
|
|
536
549
|
specDiff: () => specDiff,
|
|
537
550
|
strategyKey: () => strategyKey,
|
|
538
551
|
strategyModel: () => strategyModel,
|
|
@@ -3114,9 +3127,11 @@ function _retrySource(source, opts, emitState) {
|
|
|
3114
3127
|
const merged = makeMergedOptsMirror(opts);
|
|
3115
3128
|
const getCfg = () => resolveRetryConfig(merged.current());
|
|
3116
3129
|
const inner = _runRetryStateMachine(getCfg, () => source, a, emitState);
|
|
3117
|
-
return
|
|
3118
|
-
|
|
3119
|
-
|
|
3130
|
+
return {
|
|
3131
|
+
onDeactivation: () => {
|
|
3132
|
+
inner();
|
|
3133
|
+
merged.unsub();
|
|
3134
|
+
}
|
|
3120
3135
|
};
|
|
3121
3136
|
},
|
|
3122
3137
|
{
|
|
@@ -3140,9 +3155,11 @@ function _retryFactory(factory, opts, emitState) {
|
|
|
3140
3155
|
const merged = makeMergedOptsMirror(opts);
|
|
3141
3156
|
const getCfg = () => resolveRetryConfig(merged.current());
|
|
3142
3157
|
const inner = _runRetryStateMachine(getCfg, factory, a, emitState);
|
|
3143
|
-
return
|
|
3144
|
-
|
|
3145
|
-
|
|
3158
|
+
return {
|
|
3159
|
+
onDeactivation: () => {
|
|
3160
|
+
inner();
|
|
3161
|
+
merged.unsub();
|
|
3162
|
+
}
|
|
3146
3163
|
};
|
|
3147
3164
|
},
|
|
3148
3165
|
{
|
|
@@ -3208,7 +3225,7 @@ function withStatus(src, options) {
|
|
|
3208
3225
|
} else a.down([m]);
|
|
3209
3226
|
}
|
|
3210
3227
|
});
|
|
3211
|
-
return unsub;
|
|
3228
|
+
return { onDeactivation: unsub };
|
|
3212
3229
|
},
|
|
3213
3230
|
{
|
|
3214
3231
|
...operatorOpts(),
|
|
@@ -3433,7 +3450,7 @@ function withBreaker(breaker, options) {
|
|
|
3433
3450
|
}
|
|
3434
3451
|
});
|
|
3435
3452
|
syncState();
|
|
3436
|
-
return unsub;
|
|
3453
|
+
return { onDeactivation: unsub };
|
|
3437
3454
|
},
|
|
3438
3455
|
{
|
|
3439
3456
|
...operatorOpts(),
|
|
@@ -3586,8 +3603,10 @@ function budgetGate(source, constraints, opts) {
|
|
|
3586
3603
|
})
|
|
3587
3604
|
);
|
|
3588
3605
|
}
|
|
3589
|
-
return
|
|
3590
|
-
|
|
3606
|
+
return {
|
|
3607
|
+
onDeactivation: () => {
|
|
3608
|
+
for (const u of unsubs) u();
|
|
3609
|
+
}
|
|
3591
3610
|
};
|
|
3592
3611
|
},
|
|
3593
3612
|
{
|
|
@@ -3717,9 +3736,11 @@ function fallback(source, fb, options) {
|
|
|
3717
3736
|
} else a.down([m]);
|
|
3718
3737
|
}
|
|
3719
3738
|
});
|
|
3720
|
-
return
|
|
3721
|
-
|
|
3722
|
-
|
|
3739
|
+
return {
|
|
3740
|
+
onDeactivation: () => {
|
|
3741
|
+
sourceUnsub?.();
|
|
3742
|
+
fallbackUnsub?.();
|
|
3743
|
+
}
|
|
3723
3744
|
};
|
|
3724
3745
|
},
|
|
3725
3746
|
{
|
|
@@ -4172,11 +4193,13 @@ function rateLimiter(source, opts) {
|
|
|
4172
4193
|
} else a.down([m]);
|
|
4173
4194
|
}
|
|
4174
4195
|
});
|
|
4175
|
-
return
|
|
4176
|
-
|
|
4177
|
-
|
|
4178
|
-
|
|
4179
|
-
|
|
4196
|
+
return {
|
|
4197
|
+
onDeactivation: () => {
|
|
4198
|
+
terminated = true;
|
|
4199
|
+
timer.cancel();
|
|
4200
|
+
unsub();
|
|
4201
|
+
optMirror.unsub();
|
|
4202
|
+
}
|
|
4180
4203
|
};
|
|
4181
4204
|
},
|
|
4182
4205
|
{
|
|
@@ -5299,8 +5322,10 @@ function promptNode(adapter, deps, prompt, opts) {
|
|
|
5299
5322
|
} catch (err) {
|
|
5300
5323
|
done = true;
|
|
5301
5324
|
actions.down([[import_core27.ERROR, err]]);
|
|
5302
|
-
return
|
|
5303
|
-
|
|
5325
|
+
return {
|
|
5326
|
+
onDeactivation: () => {
|
|
5327
|
+
abortDispose?.();
|
|
5328
|
+
}
|
|
5304
5329
|
};
|
|
5305
5330
|
}
|
|
5306
5331
|
const callNode = (0, import_extra19.fromAny)(invokeResult);
|
|
@@ -5358,11 +5383,13 @@ function promptNode(adapter, deps, prompt, opts) {
|
|
|
5358
5383
|
}
|
|
5359
5384
|
}
|
|
5360
5385
|
});
|
|
5361
|
-
return
|
|
5362
|
-
|
|
5363
|
-
|
|
5364
|
-
|
|
5365
|
-
|
|
5386
|
+
return {
|
|
5387
|
+
onDeactivation: () => {
|
|
5388
|
+
cancelled = true;
|
|
5389
|
+
sub();
|
|
5390
|
+
abortDispose?.();
|
|
5391
|
+
abortDispose = void 0;
|
|
5392
|
+
}
|
|
5366
5393
|
};
|
|
5367
5394
|
},
|
|
5368
5395
|
{
|
|
@@ -6079,6 +6106,113 @@ function subscription(name, topicGraph, opts) {
|
|
|
6079
6106
|
function topicBridge(name, sourceTopic, targetTopic, opts) {
|
|
6080
6107
|
return new TopicBridgeGraph(name, sourceTopic, targetTopic, opts);
|
|
6081
6108
|
}
|
|
6109
|
+
var LogProjectorGraph = class extends import_graph2.Graph {
|
|
6110
|
+
/** Reactive count of fully-projected entries (the cursor; read-only). */
|
|
6111
|
+
position;
|
|
6112
|
+
/**
|
|
6113
|
+
* Poison entries (populated when `onPoison: "deadLetter"`). A real topic —
|
|
6114
|
+
* subscribable + visible in `describe()`.
|
|
6115
|
+
*/
|
|
6116
|
+
deadLetter;
|
|
6117
|
+
_inFlight = Promise.resolve();
|
|
6118
|
+
constructor(name, source, opts) {
|
|
6119
|
+
super(name, opts.graph);
|
|
6120
|
+
const onPoison = opts.onPoison ?? "halt";
|
|
6121
|
+
const sink = opts.sink;
|
|
6122
|
+
const dl = new TopicGraph(`${name}_dead_letter`, {
|
|
6123
|
+
retainedLimit: opts.deadLetterRetainedLimit ?? DEFAULT_TOPIC_RETAINED_LIMIT
|
|
6124
|
+
});
|
|
6125
|
+
this.mount("deadLetter", dl);
|
|
6126
|
+
this.deadLetter = dl;
|
|
6127
|
+
let available;
|
|
6128
|
+
let cursorBase;
|
|
6129
|
+
let advance;
|
|
6130
|
+
if (source instanceof TopicGraph) {
|
|
6131
|
+
const sub = new SubscriptionGraph(`${name}_subscription`, source, {
|
|
6132
|
+
from: opts.from ?? "retained"
|
|
6133
|
+
});
|
|
6134
|
+
this.mount("subscription", sub);
|
|
6135
|
+
available = sub.available;
|
|
6136
|
+
this.position = sub.cursor;
|
|
6137
|
+
cursorBase = () => sub.cursor.cache;
|
|
6138
|
+
advance = (n) => {
|
|
6139
|
+
if (n > 0) sub.ack(n);
|
|
6140
|
+
};
|
|
6141
|
+
} else {
|
|
6142
|
+
const log = source;
|
|
6143
|
+
let initialCursor;
|
|
6144
|
+
if (opts.from === "now") {
|
|
6145
|
+
initialCursor = log.size;
|
|
6146
|
+
} else if (typeof opts.from === "number") {
|
|
6147
|
+
initialCursor = requireNonNegativeInt(opts.from, "logProjector from");
|
|
6148
|
+
} else {
|
|
6149
|
+
initialCursor = 0;
|
|
6150
|
+
}
|
|
6151
|
+
const cursor = this.state("cursor", initialCursor, {
|
|
6152
|
+
meta: messagingMeta("log_projector_cursor")
|
|
6153
|
+
});
|
|
6154
|
+
this.position = cursor;
|
|
6155
|
+
cursorBase = () => cursor.cache;
|
|
6156
|
+
available = log.view({ kind: "fromCursor", cursor });
|
|
6157
|
+
advance = (n) => {
|
|
6158
|
+
if (n > 0) cursor.emit(cursor.cache + n);
|
|
6159
|
+
};
|
|
6160
|
+
}
|
|
6161
|
+
let halted = false;
|
|
6162
|
+
const runDrain = async () => {
|
|
6163
|
+
if (halted) return;
|
|
6164
|
+
const snapshot = available.cache ?? [];
|
|
6165
|
+
if (snapshot.length === 0) return;
|
|
6166
|
+
let consumed = 0;
|
|
6167
|
+
for (let i = 0; i < snapshot.length; i += 1) {
|
|
6168
|
+
const item = snapshot[i];
|
|
6169
|
+
try {
|
|
6170
|
+
await sink(item);
|
|
6171
|
+
consumed += 1;
|
|
6172
|
+
} catch (e) {
|
|
6173
|
+
const error = e instanceof Error ? e.message : String(e);
|
|
6174
|
+
if (onPoison === "deadLetter") {
|
|
6175
|
+
dl.publish({ item, error, cursorPos: cursorBase() + consumed });
|
|
6176
|
+
consumed += 1;
|
|
6177
|
+
continue;
|
|
6178
|
+
}
|
|
6179
|
+
halted = true;
|
|
6180
|
+
break;
|
|
6181
|
+
}
|
|
6182
|
+
}
|
|
6183
|
+
if (consumed > 0) advance(consumed);
|
|
6184
|
+
};
|
|
6185
|
+
const schedule = () => {
|
|
6186
|
+
if (halted) return;
|
|
6187
|
+
this._inFlight = this._inFlight.then(runDrain, runDrain);
|
|
6188
|
+
};
|
|
6189
|
+
const drain = (0, import_core30.node)(
|
|
6190
|
+
[available],
|
|
6191
|
+
(batchData, _actions, ctx) => {
|
|
6192
|
+
const b = batchData[0];
|
|
6193
|
+
const snap = b != null && b.length > 0 ? b.at(-1) : ctx.prevData[0];
|
|
6194
|
+
if (snap && snap.length > 0) schedule();
|
|
6195
|
+
},
|
|
6196
|
+
{
|
|
6197
|
+
name: "drain",
|
|
6198
|
+
describeKind: "effect",
|
|
6199
|
+
meta: messagingMeta("log_projector_drain")
|
|
6200
|
+
}
|
|
6201
|
+
);
|
|
6202
|
+
this.add(drain, { name: "drain" });
|
|
6203
|
+
this.addDisposer((0, import_extra21.keepalive)(drain));
|
|
6204
|
+
}
|
|
6205
|
+
/**
|
|
6206
|
+
* Await any in-flight drain pass. **Test convenience only** — the canonical
|
|
6207
|
+
* reactive observable is {@link LogProjectorGraph.position}.
|
|
6208
|
+
*/
|
|
6209
|
+
idle() {
|
|
6210
|
+
return this._inFlight;
|
|
6211
|
+
}
|
|
6212
|
+
};
|
|
6213
|
+
function logProjector(name, source, opts) {
|
|
6214
|
+
return new LogProjectorGraph(name, source, opts);
|
|
6215
|
+
}
|
|
6082
6216
|
|
|
6083
6217
|
// src/utils/orchestration/human-input.ts
|
|
6084
6218
|
var import_core31 = require("@graphrefly/pure-ts/core");
|
|
@@ -6132,9 +6266,11 @@ function humanInput(opts) {
|
|
|
6132
6266
|
});
|
|
6133
6267
|
}
|
|
6134
6268
|
});
|
|
6135
|
-
return
|
|
6136
|
-
|
|
6137
|
-
|
|
6269
|
+
return {
|
|
6270
|
+
onDeactivation: () => {
|
|
6271
|
+
promptUnsub();
|
|
6272
|
+
respUnsub?.();
|
|
6273
|
+
}
|
|
6138
6274
|
};
|
|
6139
6275
|
},
|
|
6140
6276
|
{
|
|
@@ -7495,16 +7631,20 @@ var ToolRegistryGraph = class extends import_graph5.Graph {
|
|
|
7495
7631
|
inner = handlerResultToNode(raw, ac.signal);
|
|
7496
7632
|
} catch (err) {
|
|
7497
7633
|
actions.down([[import_core44.ERROR, err]]);
|
|
7498
|
-
return
|
|
7499
|
-
|
|
7634
|
+
return {
|
|
7635
|
+
onDeactivation: () => {
|
|
7636
|
+
ac.abort();
|
|
7637
|
+
}
|
|
7500
7638
|
};
|
|
7501
7639
|
}
|
|
7502
7640
|
const unsub = inner.subscribe((batch14) => {
|
|
7503
7641
|
actions.down(batch14);
|
|
7504
7642
|
});
|
|
7505
|
-
return
|
|
7506
|
-
|
|
7507
|
-
|
|
7643
|
+
return {
|
|
7644
|
+
onDeactivation: () => {
|
|
7645
|
+
ac.abort();
|
|
7646
|
+
unsub();
|
|
7647
|
+
}
|
|
7508
7648
|
};
|
|
7509
7649
|
},
|
|
7510
7650
|
{
|
|
@@ -7609,8 +7749,8 @@ function admissionFilter3D(opts) {
|
|
|
7609
7749
|
}
|
|
7610
7750
|
|
|
7611
7751
|
// src/utils/ai/memory/memory-composers.ts
|
|
7612
|
-
var
|
|
7613
|
-
var
|
|
7752
|
+
var import_core57 = require("@graphrefly/pure-ts/core");
|
|
7753
|
+
var import_extra40 = require("@graphrefly/pure-ts/extra");
|
|
7614
7754
|
var import_graph8 = require("@graphrefly/pure-ts/graph");
|
|
7615
7755
|
|
|
7616
7756
|
// src/base/composition/distill.ts
|
|
@@ -7640,8 +7780,8 @@ function forEach(source, fn, opts) {
|
|
|
7640
7780
|
function isNodeLike2(value) {
|
|
7641
7781
|
return typeof value === "object" && value !== null && "cache" in value && typeof value.subscribe === "function";
|
|
7642
7782
|
}
|
|
7643
|
-
function keepalive9(
|
|
7644
|
-
|
|
7783
|
+
function keepalive9(node65) {
|
|
7784
|
+
node65.subscribe(() => void 0);
|
|
7645
7785
|
}
|
|
7646
7786
|
function mapFromSnapshot(snapshot) {
|
|
7647
7787
|
if (snapshot instanceof Map) return snapshot;
|
|
@@ -7782,8 +7922,8 @@ function decay(baseScore, ageSeconds2, ratePerSecond, minScore = 0) {
|
|
|
7782
7922
|
}
|
|
7783
7923
|
|
|
7784
7924
|
// src/utils/memory/index.ts
|
|
7785
|
-
var
|
|
7786
|
-
var
|
|
7925
|
+
var import_core56 = require("@graphrefly/pure-ts/core");
|
|
7926
|
+
var import_extra39 = require("@graphrefly/pure-ts/extra");
|
|
7787
7927
|
var import_graph7 = require("@graphrefly/pure-ts/graph");
|
|
7788
7928
|
|
|
7789
7929
|
// src/utils/memory/fact-store.ts
|
|
@@ -8216,6 +8356,57 @@ function reactiveFactStore(config) {
|
|
|
8216
8356
|
);
|
|
8217
8357
|
graph.add(consolidated, { name: "consolidated" });
|
|
8218
8358
|
graph.addDisposer((0, import_extra33.keepalive)(consolidated));
|
|
8359
|
+
if (config.decayTrigger) {
|
|
8360
|
+
const decayProcessor = (0, import_core48.node)(
|
|
8361
|
+
config.decay ? [config.decayTrigger, config.decay] : [config.decayTrigger],
|
|
8362
|
+
(batchData, actions, ctx) => {
|
|
8363
|
+
const policy3 = config.decay ? lastOf(batchData[1], ctx.prevData[1]) : void 0;
|
|
8364
|
+
if (!policy3) {
|
|
8365
|
+
actions.emit([]);
|
|
8366
|
+
return;
|
|
8367
|
+
}
|
|
8368
|
+
const now = BigInt((0, import_core48.monotonicNs)());
|
|
8369
|
+
const changes = [];
|
|
8370
|
+
for (const f of allFacts().values()) {
|
|
8371
|
+
if (f.validTo !== void 0) continue;
|
|
8372
|
+
const ageNs = now - f.t_ns;
|
|
8373
|
+
const raw = policy3(f.confidence, ageNs);
|
|
8374
|
+
if (!Number.isFinite(raw)) continue;
|
|
8375
|
+
const next = raw < 0 ? 0 : raw > 1 ? 1 : raw;
|
|
8376
|
+
if (next === f.confidence) continue;
|
|
8377
|
+
changes.push({ id: f.id, next });
|
|
8378
|
+
}
|
|
8379
|
+
const decayed = [];
|
|
8380
|
+
for (const { id, next } of changes) {
|
|
8381
|
+
const idx = findShardOf(id);
|
|
8382
|
+
const fs = idx < 0 ? void 0 : shards[idx].cache;
|
|
8383
|
+
const live = fs?.byId.get(id);
|
|
8384
|
+
if (!live || live.validTo !== void 0) continue;
|
|
8385
|
+
replaceFragment(
|
|
8386
|
+
id,
|
|
8387
|
+
(prev) => prev.validTo !== void 0 ? prev : { ...prev, confidence: next }
|
|
8388
|
+
);
|
|
8389
|
+
decayed.push({ ...live, confidence: next });
|
|
8390
|
+
}
|
|
8391
|
+
if (decayed.length > 0) {
|
|
8392
|
+
events.append({
|
|
8393
|
+
action: "decay",
|
|
8394
|
+
t_ns: (0, import_core48.wallClockNs)(),
|
|
8395
|
+
seq: bumpCursor(seqCursor)
|
|
8396
|
+
});
|
|
8397
|
+
}
|
|
8398
|
+
actions.emit(decayed);
|
|
8399
|
+
},
|
|
8400
|
+
{
|
|
8401
|
+
name: "decay_processor",
|
|
8402
|
+
describeKind: "derived",
|
|
8403
|
+
initial: [],
|
|
8404
|
+
meta: factMeta("decay")
|
|
8405
|
+
}
|
|
8406
|
+
);
|
|
8407
|
+
graph.add(decayProcessor, { name: "decay_processor" });
|
|
8408
|
+
graph.addDisposer((0, import_extra33.keepalive)(decayProcessor));
|
|
8409
|
+
}
|
|
8219
8410
|
const ingestAudit = (0, import_core48.node)(
|
|
8220
8411
|
[extractOp],
|
|
8221
8412
|
(batchData, actions, ctx) => {
|
|
@@ -8270,14 +8461,430 @@ function reactiveFactStore(config) {
|
|
|
8270
8461
|
return out;
|
|
8271
8462
|
}
|
|
8272
8463
|
|
|
8464
|
+
// src/utils/memory/persistent-fact-store.ts
|
|
8465
|
+
var import_core49 = require("@graphrefly/pure-ts/core");
|
|
8466
|
+
var import_extra34 = require("@graphrefly/pure-ts/extra");
|
|
8467
|
+
function persistMeta(kind) {
|
|
8468
|
+
return domainMeta("memory", kind);
|
|
8469
|
+
}
|
|
8470
|
+
function persistentReactiveFactStore(config) {
|
|
8471
|
+
const persistName = config.persistName ?? "fact_store_ingest";
|
|
8472
|
+
const codec = config.codec ?? (0, import_extra34.bigintJsonCodecFor)();
|
|
8473
|
+
const tier2 = (0, import_extra34.appendLogStorage)(config.storage, {
|
|
8474
|
+
name: persistName,
|
|
8475
|
+
codec
|
|
8476
|
+
});
|
|
8477
|
+
const store = reactiveFactStore({ ...config, recordIngest: true });
|
|
8478
|
+
const ingestLog = store.ingestLog;
|
|
8479
|
+
async function* loadHistory() {
|
|
8480
|
+
if (typeof tier2.loadEntries !== "function") return;
|
|
8481
|
+
const page = await tier2.loadEntries();
|
|
8482
|
+
for (const f of page.entries) yield f;
|
|
8483
|
+
}
|
|
8484
|
+
const replaySource = (0, import_extra34.fromAny)(loadHistory(), {
|
|
8485
|
+
name: "_replay_source",
|
|
8486
|
+
meta: persistMeta("persist_replay_source")
|
|
8487
|
+
});
|
|
8488
|
+
store.add(replaySource, { name: "_replay_source" });
|
|
8489
|
+
let replayed = 0;
|
|
8490
|
+
const replayPump = (0, import_core49.node)(
|
|
8491
|
+
[replaySource],
|
|
8492
|
+
(batchData, actions) => {
|
|
8493
|
+
const b = batchData[0];
|
|
8494
|
+
if (b != null && b.length > 0) {
|
|
8495
|
+
for (const f of b) {
|
|
8496
|
+
config.ingest.emit(f);
|
|
8497
|
+
replayed += 1;
|
|
8498
|
+
}
|
|
8499
|
+
actions.emit(replayed);
|
|
8500
|
+
}
|
|
8501
|
+
},
|
|
8502
|
+
{
|
|
8503
|
+
name: "_replay_pump",
|
|
8504
|
+
describeKind: "derived",
|
|
8505
|
+
initial: 0,
|
|
8506
|
+
meta: persistMeta("persist_replay_pump")
|
|
8507
|
+
}
|
|
8508
|
+
);
|
|
8509
|
+
store.add(replayPump, { name: "_replay_pump" });
|
|
8510
|
+
store.addDisposer((0, import_extra34.keepalive)(replayPump));
|
|
8511
|
+
const attached = (0, import_core49.node)([], {
|
|
8512
|
+
initial: false,
|
|
8513
|
+
name: "_storage_attached",
|
|
8514
|
+
describeKind: "state",
|
|
8515
|
+
meta: persistMeta("persist_attached")
|
|
8516
|
+
});
|
|
8517
|
+
store.add(attached, { name: "_storage_attached" });
|
|
8518
|
+
store.addDisposer((0, import_extra34.keepalive)(attached));
|
|
8519
|
+
let detachStorage;
|
|
8520
|
+
const replaySub = replaySource.subscribe((msgs) => {
|
|
8521
|
+
for (const m of msgs) {
|
|
8522
|
+
if (m[0] === import_core49.COMPLETE && detachStorage === void 0) {
|
|
8523
|
+
const sizeAtAttach = ingestLog.size;
|
|
8524
|
+
detachStorage = ingestLog.attachStorage([tier2]);
|
|
8525
|
+
if (sizeAtAttach > replayed) {
|
|
8526
|
+
const slice = [];
|
|
8527
|
+
for (let i = replayed; i < sizeAtAttach; i += 1) {
|
|
8528
|
+
const v = ingestLog.at(i);
|
|
8529
|
+
if (v === void 0) {
|
|
8530
|
+
throw new Error(
|
|
8531
|
+
`persistentReactiveFactStore: ingestLog hole at index ${i} in reconciliation slice [${replayed}, ${sizeAtAttach}); pre-attach-live durability cannot be guaranteed.`
|
|
8532
|
+
);
|
|
8533
|
+
}
|
|
8534
|
+
slice.push(v);
|
|
8535
|
+
}
|
|
8536
|
+
if (slice.length > 0) {
|
|
8537
|
+
const r = tier2.appendEntries(slice);
|
|
8538
|
+
if (r instanceof Promise) r.catch(() => {
|
|
8539
|
+
});
|
|
8540
|
+
}
|
|
8541
|
+
}
|
|
8542
|
+
attached.emit(true);
|
|
8543
|
+
}
|
|
8544
|
+
}
|
|
8545
|
+
});
|
|
8546
|
+
store.addDisposer(() => {
|
|
8547
|
+
replaySub();
|
|
8548
|
+
detachStorage?.();
|
|
8549
|
+
});
|
|
8550
|
+
const position = (0, import_core49.node)(
|
|
8551
|
+
[ingestLog.entries, attached],
|
|
8552
|
+
(batchData, actions, ctx) => {
|
|
8553
|
+
const eb = batchData[0];
|
|
8554
|
+
const arr = eb != null && eb.length > 0 ? eb.at(-1) : ctx.prevData[0];
|
|
8555
|
+
const ab = batchData[1];
|
|
8556
|
+
const isAttached = ab != null && ab.length > 0 ? ab.at(-1) : ctx.prevData[1];
|
|
8557
|
+
actions.emit(isAttached === true ? arr?.length ?? 0 : 0);
|
|
8558
|
+
},
|
|
8559
|
+
{
|
|
8560
|
+
name: "_durable_position",
|
|
8561
|
+
describeKind: "derived",
|
|
8562
|
+
initial: 0,
|
|
8563
|
+
meta: persistMeta("persist_position")
|
|
8564
|
+
}
|
|
8565
|
+
);
|
|
8566
|
+
store.add(position, { name: "_durable_position" });
|
|
8567
|
+
store.addDisposer((0, import_extra34.keepalive)(position));
|
|
8568
|
+
const out = Object.assign(store, {
|
|
8569
|
+
position,
|
|
8570
|
+
replayedCount: replayPump,
|
|
8571
|
+
tier: tier2,
|
|
8572
|
+
async flush() {
|
|
8573
|
+
await tier2.flush?.();
|
|
8574
|
+
}
|
|
8575
|
+
});
|
|
8576
|
+
return out;
|
|
8577
|
+
}
|
|
8578
|
+
|
|
8579
|
+
// src/utils/memory/recipes/admission-llm-judge.ts
|
|
8580
|
+
var import_core50 = require("@graphrefly/pure-ts/core");
|
|
8581
|
+
function admissionLlmJudge(verdicts, opts = {}) {
|
|
8582
|
+
const dflt = opts.defaultVerdict ?? false;
|
|
8583
|
+
const buildFilter = (m) => (f) => m.get(f.id) ?? dflt;
|
|
8584
|
+
return (0, import_core50.node)(
|
|
8585
|
+
[verdicts],
|
|
8586
|
+
(batchData, actions, ctx) => {
|
|
8587
|
+
const m = batchData[0]?.at(-1) ?? ctx.prevData[0] ?? /* @__PURE__ */ new Map();
|
|
8588
|
+
actions.emit(buildFilter(m));
|
|
8589
|
+
},
|
|
8590
|
+
{
|
|
8591
|
+
name: opts.name ?? "admission_llm_judge",
|
|
8592
|
+
describeKind: "derived",
|
|
8593
|
+
// Before any verdict arrives, apply the default policy.
|
|
8594
|
+
initial: buildFilter(/* @__PURE__ */ new Map())
|
|
8595
|
+
}
|
|
8596
|
+
);
|
|
8597
|
+
}
|
|
8598
|
+
|
|
8599
|
+
// src/utils/memory/recipes/bitemporal-query.ts
|
|
8600
|
+
var import_core51 = require("@graphrefly/pure-ts/core");
|
|
8601
|
+
|
|
8602
|
+
// src/utils/memory/recipes/_shared.ts
|
|
8603
|
+
function lastOf2(batch14, prev) {
|
|
8604
|
+
return batch14 != null && batch14.length > 0 ? batch14.at(-1) : prev;
|
|
8605
|
+
}
|
|
8606
|
+
function validAt(f, asOf) {
|
|
8607
|
+
if (asOf === void 0) return f.validTo === void 0;
|
|
8608
|
+
if (f.validFrom !== void 0 && asOf < f.validFrom) return false;
|
|
8609
|
+
if (f.validTo !== void 0 && asOf >= f.validTo) return false;
|
|
8610
|
+
return true;
|
|
8611
|
+
}
|
|
8612
|
+
|
|
8613
|
+
// src/utils/memory/recipes/bitemporal-query.ts
|
|
8614
|
+
function bitemporalQuery(mem, asOf, opts = {}) {
|
|
8615
|
+
const asOfOrNull = (0, import_core51.node)(
|
|
8616
|
+
[asOf],
|
|
8617
|
+
(b, a, c) => a.emit(lastOf2(b[0], c.prevData[0]) ?? null),
|
|
8618
|
+
{ name: `${opts.name ?? "bitemporal_query"}_asof`, describeKind: "derived", initial: null }
|
|
8619
|
+
);
|
|
8620
|
+
return (0, import_core51.node)(
|
|
8621
|
+
[asOfOrNull, mem.factStore],
|
|
8622
|
+
(batchData, actions, ctx) => {
|
|
8623
|
+
const raw = lastOf2(batchData[0], ctx.prevData[0]);
|
|
8624
|
+
const at = raw ?? void 0;
|
|
8625
|
+
const fs = lastOf2(batchData[1], ctx.prevData[1]);
|
|
8626
|
+
if (fs == null) {
|
|
8627
|
+
actions.emit([]);
|
|
8628
|
+
return;
|
|
8629
|
+
}
|
|
8630
|
+
const results = [...fs.byId.values()].filter((f) => {
|
|
8631
|
+
if (!validAt(f, at)) return false;
|
|
8632
|
+
if (opts.tags && opts.tags.length > 0 && !opts.tags.some((t) => f.tags.includes(t))) {
|
|
8633
|
+
return false;
|
|
8634
|
+
}
|
|
8635
|
+
if (opts.minConfidence !== void 0 && f.confidence < opts.minConfidence) return false;
|
|
8636
|
+
return true;
|
|
8637
|
+
});
|
|
8638
|
+
results.sort((a, b) => b.confidence - a.confidence || Number(b.t_ns - a.t_ns));
|
|
8639
|
+
actions.emit(results);
|
|
8640
|
+
},
|
|
8641
|
+
{
|
|
8642
|
+
name: opts.name ?? "bitemporal_query",
|
|
8643
|
+
describeKind: "derived",
|
|
8644
|
+
initial: []
|
|
8645
|
+
}
|
|
8646
|
+
);
|
|
8647
|
+
}
|
|
8648
|
+
|
|
8649
|
+
// src/utils/memory/recipes/consolidation-rem.ts
|
|
8650
|
+
var import_extra35 = require("@graphrefly/pure-ts/extra");
|
|
8651
|
+
function consolidationRem(opts) {
|
|
8652
|
+
const consolidateTrigger = (0, import_extra35.fromTimer)(opts.periodMs, { period: opts.periodMs });
|
|
8653
|
+
const consolidate = (store) => {
|
|
8654
|
+
const live = [...store.values()].filter((f) => f.validTo === void 0);
|
|
8655
|
+
if (live.length === 0) return [];
|
|
8656
|
+
let pool = live;
|
|
8657
|
+
if (opts.recentWindowNs !== void 0) {
|
|
8658
|
+
const newest = live.reduce((m, f) => f.t_ns > m ? f.t_ns : m, live[0].t_ns);
|
|
8659
|
+
const cutoff = newest - opts.recentWindowNs;
|
|
8660
|
+
pool = live.filter((f) => f.t_ns >= cutoff);
|
|
8661
|
+
}
|
|
8662
|
+
pool.sort((a, b) => b.confidence - a.confidence || Number(b.t_ns - a.t_ns));
|
|
8663
|
+
const replayed = pool.slice(0, Math.max(0, opts.topK));
|
|
8664
|
+
return replayed.length > 0 ? opts.summarize(replayed) : [];
|
|
8665
|
+
};
|
|
8666
|
+
return { consolidateTrigger, consolidate };
|
|
8667
|
+
}
|
|
8668
|
+
|
|
8669
|
+
// src/utils/memory/recipes/decay-exponential.ts
|
|
8670
|
+
var import_core52 = require("@graphrefly/pure-ts/core");
|
|
8671
|
+
var import_extra36 = require("@graphrefly/pure-ts/extra");
|
|
8672
|
+
function decayExponential(mem, ingest, opts) {
|
|
8673
|
+
const floor = opts.floor ?? 0;
|
|
8674
|
+
const epsilon = Math.max(opts.epsilon ?? 1e-4, Number.EPSILON);
|
|
8675
|
+
const half = Number(opts.halfLifeNs);
|
|
8676
|
+
const lastTick = /* @__PURE__ */ new Map();
|
|
8677
|
+
const timer = (0, import_extra36.fromTimer)(opts.periodMs, { period: opts.periodMs });
|
|
8678
|
+
const driver = (0, import_core52.node)(
|
|
8679
|
+
[timer],
|
|
8680
|
+
(_batchData, actions) => {
|
|
8681
|
+
const fs = mem.factStore.cache;
|
|
8682
|
+
if (!fs) {
|
|
8683
|
+
actions.emit([]);
|
|
8684
|
+
return;
|
|
8685
|
+
}
|
|
8686
|
+
const now = BigInt((0, import_core52.wallClockNs)());
|
|
8687
|
+
const decayed = [];
|
|
8688
|
+
const liveIds = /* @__PURE__ */ new Set();
|
|
8689
|
+
for (const f of fs.byId.values()) {
|
|
8690
|
+
liveIds.add(f.id);
|
|
8691
|
+
if (f.validTo !== void 0) continue;
|
|
8692
|
+
if (f.confidence <= floor) continue;
|
|
8693
|
+
const lt = lastTick.get(f.id);
|
|
8694
|
+
const since = lt !== void 0 && lt >= f.t_ns ? lt : f.t_ns;
|
|
8695
|
+
const elapsed = Number(now - since);
|
|
8696
|
+
if (elapsed <= 0) continue;
|
|
8697
|
+
const factor = 0.5 ** (half > 0 ? elapsed / half : 0);
|
|
8698
|
+
if (!Number.isFinite(factor)) continue;
|
|
8699
|
+
let next = f.confidence * factor;
|
|
8700
|
+
if (next < floor) next = floor;
|
|
8701
|
+
if (f.confidence - next < epsilon) continue;
|
|
8702
|
+
const liveNow = mem.factStore.cache?.byId.get(f.id);
|
|
8703
|
+
if (liveNow && liveNow.validTo !== void 0) continue;
|
|
8704
|
+
lastTick.set(f.id, now);
|
|
8705
|
+
const drifted = { ...f, confidence: next };
|
|
8706
|
+
decayed.push(drifted);
|
|
8707
|
+
ingest.emit(drifted);
|
|
8708
|
+
}
|
|
8709
|
+
if (lastTick.size > liveIds.size) {
|
|
8710
|
+
for (const id of lastTick.keys()) if (!liveIds.has(id)) lastTick.delete(id);
|
|
8711
|
+
}
|
|
8712
|
+
actions.emit(decayed);
|
|
8713
|
+
},
|
|
8714
|
+
{
|
|
8715
|
+
name: opts.name ?? "decay_exponential",
|
|
8716
|
+
describeKind: "derived",
|
|
8717
|
+
initial: []
|
|
8718
|
+
}
|
|
8719
|
+
);
|
|
8720
|
+
mem.add(driver, { name: opts.name ?? "decay_exponential" });
|
|
8721
|
+
mem.addDisposer((0, import_extra36.keepalive)(timer));
|
|
8722
|
+
mem.addDisposer((0, import_extra36.keepalive)(driver));
|
|
8723
|
+
return driver;
|
|
8724
|
+
}
|
|
8725
|
+
|
|
8726
|
+
// src/utils/memory/recipes/influence-analysis.ts
|
|
8727
|
+
var import_core53 = require("@graphrefly/pure-ts/core");
|
|
8728
|
+
var import_extra37 = require("@graphrefly/pure-ts/extra");
|
|
8729
|
+
function closureOf(index, root) {
|
|
8730
|
+
const seen = /* @__PURE__ */ new Set();
|
|
8731
|
+
const queue = [root];
|
|
8732
|
+
while (queue.length > 0) {
|
|
8733
|
+
const cur = queue.shift();
|
|
8734
|
+
for (const dep of index.get(cur) ?? []) {
|
|
8735
|
+
if (seen.has(dep) || dep === root) continue;
|
|
8736
|
+
seen.add(dep);
|
|
8737
|
+
queue.push(dep);
|
|
8738
|
+
}
|
|
8739
|
+
}
|
|
8740
|
+
return [...seen];
|
|
8741
|
+
}
|
|
8742
|
+
function influenceAnalysis(mem, opts = {}) {
|
|
8743
|
+
const prefix = opts.name ?? "influence";
|
|
8744
|
+
const maxRanked = Math.max(1, opts.maxRanked ?? 64);
|
|
8745
|
+
const ranked = (0, import_core53.node)(
|
|
8746
|
+
[mem.dependentsIndex],
|
|
8747
|
+
(batchData, actions, ctx) => {
|
|
8748
|
+
const index = lastOf2(batchData[0], ctx.prevData[0]);
|
|
8749
|
+
if (index == null) {
|
|
8750
|
+
actions.emit([]);
|
|
8751
|
+
return;
|
|
8752
|
+
}
|
|
8753
|
+
const rows = [];
|
|
8754
|
+
for (const key of index.keys()) {
|
|
8755
|
+
rows.push({ factId: key, influence: closureOf(index, key).length });
|
|
8756
|
+
}
|
|
8757
|
+
rows.sort((a, b) => b.influence - a.influence);
|
|
8758
|
+
actions.emit(rows.slice(0, maxRanked));
|
|
8759
|
+
},
|
|
8760
|
+
{
|
|
8761
|
+
name: `${prefix}_ranked`,
|
|
8762
|
+
describeKind: "derived",
|
|
8763
|
+
initial: []
|
|
8764
|
+
}
|
|
8765
|
+
);
|
|
8766
|
+
mem.add(ranked, { name: `${prefix}_ranked` });
|
|
8767
|
+
mem.addDisposer((0, import_extra37.keepalive)(ranked));
|
|
8768
|
+
const builtFor = /* @__PURE__ */ new Map();
|
|
8769
|
+
function influenceOf(rootId) {
|
|
8770
|
+
const existing = builtFor.get(rootId);
|
|
8771
|
+
if (existing) return existing;
|
|
8772
|
+
const n = (0, import_core53.node)(
|
|
8773
|
+
[mem.dependentsIndex],
|
|
8774
|
+
(batchData, actions, ctx) => {
|
|
8775
|
+
const index = lastOf2(batchData[0], ctx.prevData[0]);
|
|
8776
|
+
actions.emit(index == null ? [] : closureOf(index, rootId));
|
|
8777
|
+
},
|
|
8778
|
+
{
|
|
8779
|
+
name: `${prefix}_of_${rootId}`,
|
|
8780
|
+
describeKind: "derived",
|
|
8781
|
+
initial: []
|
|
8782
|
+
}
|
|
8783
|
+
);
|
|
8784
|
+
mem.add(n, { name: `${prefix}_of_${rootId}` });
|
|
8785
|
+
mem.addDisposer((0, import_extra37.keepalive)(n));
|
|
8786
|
+
builtFor.set(rootId, n);
|
|
8787
|
+
return n;
|
|
8788
|
+
}
|
|
8789
|
+
return { influenceOf, ranked };
|
|
8790
|
+
}
|
|
8791
|
+
|
|
8792
|
+
// src/utils/memory/recipes/invalidation-tracer.ts
|
|
8793
|
+
var import_core54 = require("@graphrefly/pure-ts/core");
|
|
8794
|
+
var import_extra38 = require("@graphrefly/pure-ts/extra");
|
|
8795
|
+
function invalidationTracer(mem, opts = {}) {
|
|
8796
|
+
const limit = Math.max(1, opts.limit ?? 256);
|
|
8797
|
+
const ring = [];
|
|
8798
|
+
const push = (e) => {
|
|
8799
|
+
ring.push(e);
|
|
8800
|
+
if (ring.length > limit) ring.splice(0, ring.length - limit);
|
|
8801
|
+
};
|
|
8802
|
+
const tracer = (0, import_core54.node)(
|
|
8803
|
+
[mem.cascade, mem.cascadeOverflow],
|
|
8804
|
+
(batchData, actions) => {
|
|
8805
|
+
const cascadeWaves = batchData[0] ?? [];
|
|
8806
|
+
for (const wave of cascadeWaves) {
|
|
8807
|
+
for (const ev of wave) {
|
|
8808
|
+
push({
|
|
8809
|
+
kind: "cascade",
|
|
8810
|
+
factId: ev.factId,
|
|
8811
|
+
rootFactId: ev.rootFactId,
|
|
8812
|
+
reason: ev.reason,
|
|
8813
|
+
iteration: ev.iteration,
|
|
8814
|
+
causalReason: ev.causalReason
|
|
8815
|
+
});
|
|
8816
|
+
}
|
|
8817
|
+
}
|
|
8818
|
+
const overflows = batchData[1] ?? [];
|
|
8819
|
+
for (const ov of overflows) {
|
|
8820
|
+
if (ov == null) continue;
|
|
8821
|
+
push({
|
|
8822
|
+
kind: "overflow",
|
|
8823
|
+
factId: ov.sample[0] ?? "",
|
|
8824
|
+
rootFactId: ov.rootFactId,
|
|
8825
|
+
reason: "overflow",
|
|
8826
|
+
causalReason: `cascade overflow: ${ov.droppedCount} dropped (root ${ov.rootFactId})`
|
|
8827
|
+
});
|
|
8828
|
+
}
|
|
8829
|
+
actions.emit([...ring]);
|
|
8830
|
+
},
|
|
8831
|
+
{
|
|
8832
|
+
name: opts.name ?? "invalidation_tracer",
|
|
8833
|
+
describeKind: "derived",
|
|
8834
|
+
initial: []
|
|
8835
|
+
}
|
|
8836
|
+
);
|
|
8837
|
+
mem.add(tracer, { name: opts.name ?? "invalidation_tracer" });
|
|
8838
|
+
mem.addDisposer((0, import_extra38.keepalive)(tracer));
|
|
8839
|
+
return tracer;
|
|
8840
|
+
}
|
|
8841
|
+
|
|
8842
|
+
// src/utils/memory/recipes/scoring-by-outcome.ts
|
|
8843
|
+
var import_core55 = require("@graphrefly/pure-ts/core");
|
|
8844
|
+
var clamp01 = (n) => n < 0 ? 0 : n > 1 ? 1 : n;
|
|
8845
|
+
function scoringByOutcome(outcomes, opts = {}) {
|
|
8846
|
+
const base = opts.base ?? ((f) => f.confidence);
|
|
8847
|
+
const learningRate = opts.learningRate ?? 1;
|
|
8848
|
+
const acc = /* @__PURE__ */ new Map();
|
|
8849
|
+
const buildPolicy = () => (fragment) => clamp01(base(fragment) + learningRate * (acc.get(fragment.id) ?? 0));
|
|
8850
|
+
return (0, import_core55.node)(
|
|
8851
|
+
[outcomes],
|
|
8852
|
+
(batchData, actions) => {
|
|
8853
|
+
const wave = batchData[0] ?? [];
|
|
8854
|
+
for (const sig of wave) acc.set(sig.factId, (acc.get(sig.factId) ?? 0) + sig.reward);
|
|
8855
|
+
actions.emit(buildPolicy());
|
|
8856
|
+
},
|
|
8857
|
+
{
|
|
8858
|
+
name: opts.name ?? "scoring_by_outcome",
|
|
8859
|
+
describeKind: "derived",
|
|
8860
|
+
// Usable scorer before any outcome arrives (base-only).
|
|
8861
|
+
initial: buildPolicy()
|
|
8862
|
+
}
|
|
8863
|
+
);
|
|
8864
|
+
}
|
|
8865
|
+
|
|
8866
|
+
// src/utils/memory/recipes/shard-by-tenant.ts
|
|
8867
|
+
function shardByTenant(tenantOf, opts = {}) {
|
|
8868
|
+
if (opts.tenants && opts.tenants.length > 0) {
|
|
8869
|
+
const idx = new Map(opts.tenants.map((t, i) => [t, i]));
|
|
8870
|
+
const overflow = opts.tenants.length;
|
|
8871
|
+
return {
|
|
8872
|
+
shardBy: (f) => idx.get(tenantOf(f)) ?? overflow,
|
|
8873
|
+
shardCount: opts.tenants.length + 1
|
|
8874
|
+
};
|
|
8875
|
+
}
|
|
8876
|
+
const shardCount = Math.max(1, opts.shardCount ?? 4);
|
|
8877
|
+
return { shardBy: (f) => tenantOf(f), shardCount };
|
|
8878
|
+
}
|
|
8879
|
+
|
|
8273
8880
|
// src/utils/memory/index.ts
|
|
8274
8881
|
var NS_PER_SEC2 = 1e9;
|
|
8275
8882
|
function memoryMeta(kind, extra) {
|
|
8276
8883
|
return domainMeta("memory", kind, extra);
|
|
8277
8884
|
}
|
|
8278
8885
|
function toNode(v, name) {
|
|
8279
|
-
if (v instanceof
|
|
8280
|
-
return (0,
|
|
8886
|
+
if (v instanceof import_core56.NodeImpl) return v;
|
|
8887
|
+
return (0, import_core56.node)([], { initial: v, ...name ? { name } : void 0 });
|
|
8281
8888
|
}
|
|
8282
8889
|
function ageSeconds(now, lastNs) {
|
|
8283
8890
|
return (now - lastNs) / NS_PER_SEC2;
|
|
@@ -8331,14 +8938,14 @@ function collection(name, opts = {}) {
|
|
|
8331
8938
|
}
|
|
8332
8939
|
const scoreFnDefault = () => ranked ? 1 : 0;
|
|
8333
8940
|
const scoreInput = opts.score ?? scoreFnDefault;
|
|
8334
|
-
const scoreNode = ranked && scoreInput instanceof
|
|
8941
|
+
const scoreNode = ranked && scoreInput instanceof import_core56.NodeImpl ? scoreInput : void 0;
|
|
8335
8942
|
const readScoreFn = () => {
|
|
8336
8943
|
if (scoreNode) return scoreNode.cache ?? scoreFnDefault;
|
|
8337
8944
|
return scoreInput;
|
|
8338
8945
|
};
|
|
8339
8946
|
const graph = new import_graph7.Graph(name);
|
|
8340
|
-
const retentionScore = (_k, v) => ranked ? decay(v.baseScore, ageSeconds((0,
|
|
8341
|
-
const items = (0,
|
|
8947
|
+
const retentionScore = (_k, v) => ranked ? decay(v.baseScore, ageSeconds((0, import_core56.monotonicNs)(), v.lastAccessNs), decayRate, minScore) : v.lastAccessNs;
|
|
8948
|
+
const items = (0, import_extra39.reactiveMap)({
|
|
8342
8949
|
name: "items",
|
|
8343
8950
|
...maxSize !== void 0 ? { retention: { score: retentionScore, maxSize } } : {}
|
|
8344
8951
|
});
|
|
@@ -8346,16 +8953,16 @@ function collection(name, opts = {}) {
|
|
|
8346
8953
|
let refreshTick;
|
|
8347
8954
|
if (ranked && decayRate > 0) {
|
|
8348
8955
|
const intervalMs = opts.refreshIntervalMs ?? Math.max(1, 1e3 * Math.LN2 / (10 * decayRate));
|
|
8349
|
-
const tickCounter = (0,
|
|
8350
|
-
refreshTick = (0,
|
|
8956
|
+
const tickCounter = (0, import_extra39.fromTimer)(intervalMs, { period: intervalMs });
|
|
8957
|
+
refreshTick = (0, import_core56.node)(
|
|
8351
8958
|
[tickCounter],
|
|
8352
8959
|
(_batchData, actions) => {
|
|
8353
|
-
actions.emit((0,
|
|
8960
|
+
actions.emit((0, import_core56.monotonicNs)());
|
|
8354
8961
|
},
|
|
8355
8962
|
{
|
|
8356
8963
|
name: "refresh_tick_ns",
|
|
8357
8964
|
describeKind: "derived",
|
|
8358
|
-
initial: (0,
|
|
8965
|
+
initial: (0, import_core56.monotonicNs)(),
|
|
8359
8966
|
meta: memoryMeta("clock")
|
|
8360
8967
|
}
|
|
8361
8968
|
);
|
|
@@ -8366,7 +8973,7 @@ function collection(name, opts = {}) {
|
|
|
8366
8973
|
const rankedDeps = [items.entries];
|
|
8367
8974
|
if (refreshTick) rankedDeps.push(refreshTick);
|
|
8368
8975
|
if (scoreNode) rankedDeps.push(scoreNode);
|
|
8369
|
-
rankedNode = (0,
|
|
8976
|
+
rankedNode = (0, import_core56.node)(
|
|
8370
8977
|
rankedDeps,
|
|
8371
8978
|
(batchData, actions, ctx) => {
|
|
8372
8979
|
const values = batchData.map(
|
|
@@ -8376,9 +8983,9 @@ function collection(name, opts = {}) {
|
|
|
8376
8983
|
let now;
|
|
8377
8984
|
if (refreshTick) {
|
|
8378
8985
|
const tickValue = values[1];
|
|
8379
|
-
now = typeof tickValue === "number" ? tickValue : (0,
|
|
8986
|
+
now = typeof tickValue === "number" ? tickValue : (0, import_core56.monotonicNs)();
|
|
8380
8987
|
} else {
|
|
8381
|
-
now = (0,
|
|
8988
|
+
now = (0, import_core56.monotonicNs)();
|
|
8382
8989
|
}
|
|
8383
8990
|
if (!snapshot || snapshot.size === 0) {
|
|
8384
8991
|
actions.emit([]);
|
|
@@ -8403,7 +9010,7 @@ function collection(name, opts = {}) {
|
|
|
8403
9010
|
);
|
|
8404
9011
|
graph.add(rankedNode, { name: "ranked" });
|
|
8405
9012
|
} else {
|
|
8406
|
-
rankedNode = (0,
|
|
9013
|
+
rankedNode = (0, import_core56.node)([], {
|
|
8407
9014
|
initial: [],
|
|
8408
9015
|
name: "ranked",
|
|
8409
9016
|
describeKind: "state",
|
|
@@ -8411,7 +9018,7 @@ function collection(name, opts = {}) {
|
|
|
8411
9018
|
});
|
|
8412
9019
|
graph.add(rankedNode, { name: "ranked" });
|
|
8413
9020
|
}
|
|
8414
|
-
const size = (0,
|
|
9021
|
+
const size = (0, import_core56.node)(
|
|
8415
9022
|
[items.entries],
|
|
8416
9023
|
(batchData, actions, ctx) => {
|
|
8417
9024
|
const data = batchData.map(
|
|
@@ -8428,7 +9035,7 @@ function collection(name, opts = {}) {
|
|
|
8428
9035
|
}
|
|
8429
9036
|
);
|
|
8430
9037
|
graph.add(size, { name: "size" });
|
|
8431
|
-
graph.addDisposer((0,
|
|
9038
|
+
graph.addDisposer((0, import_extra39.keepalive)(size));
|
|
8432
9039
|
const events = createAuditLog({
|
|
8433
9040
|
name: "events",
|
|
8434
9041
|
retainedLimit: 1024,
|
|
@@ -8436,7 +9043,7 @@ function collection(name, opts = {}) {
|
|
|
8436
9043
|
});
|
|
8437
9044
|
const seqCursor = registerCursor(graph, "seq", 0);
|
|
8438
9045
|
const upsertImpl = (id, value, _opts) => {
|
|
8439
|
-
const now = (0,
|
|
9046
|
+
const now = (0, import_core56.monotonicNs)();
|
|
8440
9047
|
const prev = items.get(id);
|
|
8441
9048
|
const baseScore = _opts?.score ?? readScoreFn()(value);
|
|
8442
9049
|
items.set(id, {
|
|
@@ -8492,7 +9099,7 @@ function collection(name, opts = {}) {
|
|
|
8492
9099
|
});
|
|
8493
9100
|
function itemNode(id) {
|
|
8494
9101
|
const idN = toNode(id, "id");
|
|
8495
|
-
return (0,
|
|
9102
|
+
return (0, import_core56.node)(
|
|
8496
9103
|
[items.entries, idN],
|
|
8497
9104
|
(batchData, actions, ctx) => {
|
|
8498
9105
|
const data = batchData.map(
|
|
@@ -8510,7 +9117,7 @@ function collection(name, opts = {}) {
|
|
|
8510
9117
|
}
|
|
8511
9118
|
function hasNode(id) {
|
|
8512
9119
|
const idN = toNode(id, "id");
|
|
8513
|
-
return (0,
|
|
9120
|
+
return (0, import_core56.node)(
|
|
8514
9121
|
[items.entries, idN],
|
|
8515
9122
|
(batchData, actions, ctx) => {
|
|
8516
9123
|
const data = batchData.map(
|
|
@@ -8585,7 +9192,7 @@ function vectorIndex(opts = {}) {
|
|
|
8585
9192
|
graph
|
|
8586
9193
|
});
|
|
8587
9194
|
const seqCursor = registerCursor(graph, "seq", 0);
|
|
8588
|
-
const entries = (0,
|
|
9195
|
+
const entries = (0, import_extra39.reactiveMap)({
|
|
8589
9196
|
name: "entries",
|
|
8590
9197
|
...maxSize !== void 0 ? {
|
|
8591
9198
|
retention: {
|
|
@@ -8597,7 +9204,7 @@ function vectorIndex(opts = {}) {
|
|
|
8597
9204
|
events.append({
|
|
8598
9205
|
action: "evict",
|
|
8599
9206
|
id: key,
|
|
8600
|
-
t_ns: (0,
|
|
9207
|
+
t_ns: (0, import_core56.wallClockNs)(),
|
|
8601
9208
|
seq: bumpCursor(seqCursor)
|
|
8602
9209
|
});
|
|
8603
9210
|
}
|
|
@@ -8605,7 +9212,7 @@ function vectorIndex(opts = {}) {
|
|
|
8605
9212
|
} : {}
|
|
8606
9213
|
});
|
|
8607
9214
|
graph.add(entries.entries, { name: "entries" });
|
|
8608
|
-
graph.addDisposer((0,
|
|
9215
|
+
graph.addDisposer((0, import_extra39.keepalive)(entries.entries));
|
|
8609
9216
|
if (hnsw?.dispose) {
|
|
8610
9217
|
const disposeAdapter = hnsw.dispose.bind(hnsw);
|
|
8611
9218
|
graph.addDisposer(() => disposeAdapter());
|
|
@@ -8622,7 +9229,7 @@ function vectorIndex(opts = {}) {
|
|
|
8622
9229
|
id,
|
|
8623
9230
|
vector: [...vector],
|
|
8624
9231
|
...copiedMeta !== void 0 ? { meta: copiedMeta } : {},
|
|
8625
|
-
upsertedAtNs: (0,
|
|
9232
|
+
upsertedAtNs: (0, import_core56.monotonicNs)()
|
|
8626
9233
|
};
|
|
8627
9234
|
entries.set(id, record);
|
|
8628
9235
|
};
|
|
@@ -8678,7 +9285,7 @@ function vectorIndex(opts = {}) {
|
|
|
8678
9285
|
});
|
|
8679
9286
|
function searchNode(query, k = 5) {
|
|
8680
9287
|
const kN = toNode(k, "k");
|
|
8681
|
-
return (0,
|
|
9288
|
+
return (0, import_core56.node)(
|
|
8682
9289
|
[entries.entries, query, kN],
|
|
8683
9290
|
(batchData, actions, ctx) => {
|
|
8684
9291
|
const values = batchData.map(
|
|
@@ -8784,17 +9391,17 @@ function knowledgeGraph(name, opts = {}) {
|
|
|
8784
9391
|
throw new RangeError("knowledgeGraph: edgesMaxSize must be >= 1");
|
|
8785
9392
|
}
|
|
8786
9393
|
const graph = new import_graph7.Graph(name);
|
|
8787
|
-
const entitiesMap = (0,
|
|
9394
|
+
const entitiesMap = (0, import_extra39.reactiveMap)({
|
|
8788
9395
|
name: "entities",
|
|
8789
9396
|
...opts.entitiesMaxSize !== void 0 ? { maxSize: opts.entitiesMaxSize } : {}
|
|
8790
9397
|
});
|
|
8791
|
-
const edgesMap = (0,
|
|
9398
|
+
const edgesMap = (0, import_extra39.reactiveMap)({
|
|
8792
9399
|
name: "edges",
|
|
8793
9400
|
...opts.edgesMaxSize !== void 0 ? { maxSize: opts.edgesMaxSize } : {}
|
|
8794
9401
|
});
|
|
8795
9402
|
graph.add(entitiesMap.entries, { name: "entities" });
|
|
8796
9403
|
graph.add(edgesMap.entries, { name: "edges" });
|
|
8797
|
-
const adjacencyOut = (0,
|
|
9404
|
+
const adjacencyOut = (0, import_core56.node)(
|
|
8798
9405
|
[edgesMap.entries],
|
|
8799
9406
|
(batchData, actions, ctx) => {
|
|
8800
9407
|
const data = batchData.map(
|
|
@@ -8811,7 +9418,7 @@ function knowledgeGraph(name, opts = {}) {
|
|
|
8811
9418
|
meta: memoryMeta("adjacency_out")
|
|
8812
9419
|
}
|
|
8813
9420
|
);
|
|
8814
|
-
const adjacencyIn = (0,
|
|
9421
|
+
const adjacencyIn = (0, import_core56.node)(
|
|
8815
9422
|
[edgesMap.entries],
|
|
8816
9423
|
(batchData, actions, ctx) => {
|
|
8817
9424
|
const data = batchData.map(
|
|
@@ -8830,9 +9437,9 @@ function knowledgeGraph(name, opts = {}) {
|
|
|
8830
9437
|
);
|
|
8831
9438
|
graph.add(adjacencyOut, { name: "adjacencyOut" });
|
|
8832
9439
|
graph.add(adjacencyIn, { name: "adjacencyIn" });
|
|
8833
|
-
graph.addDisposer((0,
|
|
8834
|
-
graph.addDisposer((0,
|
|
8835
|
-
const entityCount = (0,
|
|
9440
|
+
graph.addDisposer((0, import_extra39.keepalive)(adjacencyOut));
|
|
9441
|
+
graph.addDisposer((0, import_extra39.keepalive)(adjacencyIn));
|
|
9442
|
+
const entityCount = (0, import_core56.node)(
|
|
8836
9443
|
[entitiesMap.entries],
|
|
8837
9444
|
(batchData, actions, ctx) => {
|
|
8838
9445
|
const data = batchData.map(
|
|
@@ -8843,7 +9450,7 @@ function knowledgeGraph(name, opts = {}) {
|
|
|
8843
9450
|
},
|
|
8844
9451
|
{ name: "entityCount", describeKind: "derived", initial: 0, meta: memoryMeta("entity_count") }
|
|
8845
9452
|
);
|
|
8846
|
-
const edgeCount = (0,
|
|
9453
|
+
const edgeCount = (0, import_core56.node)(
|
|
8847
9454
|
[edgesMap.entries],
|
|
8848
9455
|
(batchData, actions, ctx) => {
|
|
8849
9456
|
const data = batchData.map(
|
|
@@ -8856,8 +9463,8 @@ function knowledgeGraph(name, opts = {}) {
|
|
|
8856
9463
|
);
|
|
8857
9464
|
graph.add(entityCount, { name: "entityCount" });
|
|
8858
9465
|
graph.add(edgeCount, { name: "edgeCount" });
|
|
8859
|
-
graph.addDisposer((0,
|
|
8860
|
-
graph.addDisposer((0,
|
|
9466
|
+
graph.addDisposer((0, import_extra39.keepalive)(entityCount));
|
|
9467
|
+
graph.addDisposer((0, import_extra39.keepalive)(edgeCount));
|
|
8861
9468
|
const events = createAuditLog({
|
|
8862
9469
|
name: "events",
|
|
8863
9470
|
retainedLimit: 1024,
|
|
@@ -8880,7 +9487,7 @@ function knowledgeGraph(name, opts = {}) {
|
|
|
8880
9487
|
events.append({
|
|
8881
9488
|
action: "orphanRemove",
|
|
8882
9489
|
id: candidate,
|
|
8883
|
-
t_ns: (0,
|
|
9490
|
+
t_ns: (0, import_core56.wallClockNs)(),
|
|
8884
9491
|
seq: bumpCursor(seqCursor)
|
|
8885
9492
|
});
|
|
8886
9493
|
}
|
|
@@ -8975,7 +9582,7 @@ function knowledgeGraph(name, opts = {}) {
|
|
|
8975
9582
|
const idN = toNode(id, "id");
|
|
8976
9583
|
const relN = relation !== void 0 ? toNode(relation, "relation") : void 0;
|
|
8977
9584
|
const deps = relN ? [adjacencyOut, adjacencyIn, idN, relN] : [adjacencyOut, adjacencyIn, idN];
|
|
8978
|
-
return (0,
|
|
9585
|
+
return (0, import_core56.node)(
|
|
8979
9586
|
deps,
|
|
8980
9587
|
(batchData, actions, ctx) => {
|
|
8981
9588
|
const values = batchData.map(
|
|
@@ -9051,7 +9658,7 @@ var MemoryWithVectorsGraph = class extends import_graph8.Graph {
|
|
|
9051
9658
|
this.mount("vectorIndex", this.vectors);
|
|
9052
9659
|
const embedFn = opts.embedFn;
|
|
9053
9660
|
const vectorsRef = this.vectors;
|
|
9054
|
-
const indexer = (0,
|
|
9661
|
+
const indexer = (0, import_core57.node)(
|
|
9055
9662
|
[opts.store.store.entries],
|
|
9056
9663
|
(batchData, _actions, ctx) => {
|
|
9057
9664
|
const data = batchData.map(
|
|
@@ -9066,7 +9673,7 @@ var MemoryWithVectorsGraph = class extends import_graph8.Graph {
|
|
|
9066
9673
|
{ name: "indexer", describeKind: "effect" }
|
|
9067
9674
|
);
|
|
9068
9675
|
this.add(indexer, { name: "indexer" });
|
|
9069
|
-
this.addDisposer((0,
|
|
9676
|
+
this.addDisposer((0, import_extra40.keepalive)(indexer));
|
|
9070
9677
|
}
|
|
9071
9678
|
};
|
|
9072
9679
|
function memoryWithVectors(opts) {
|
|
@@ -9084,7 +9691,7 @@ var MemoryWithKGGraph = class extends import_graph8.Graph {
|
|
|
9084
9691
|
if (!opts.entityFn) return;
|
|
9085
9692
|
const entityFn = opts.entityFn;
|
|
9086
9693
|
const kgRef = this.kg;
|
|
9087
|
-
const indexer = (0,
|
|
9694
|
+
const indexer = (0, import_core57.node)(
|
|
9088
9695
|
[opts.store.store.entries],
|
|
9089
9696
|
(batchData, _actions, ctx) => {
|
|
9090
9697
|
const data = batchData.map(
|
|
@@ -9105,7 +9712,7 @@ var MemoryWithKGGraph = class extends import_graph8.Graph {
|
|
|
9105
9712
|
{ name: "indexer", describeKind: "effect" }
|
|
9106
9713
|
);
|
|
9107
9714
|
this.add(indexer, { name: "indexer" });
|
|
9108
|
-
this.addDisposer((0,
|
|
9715
|
+
this.addDisposer((0, import_extra40.keepalive)(indexer));
|
|
9109
9716
|
}
|
|
9110
9717
|
};
|
|
9111
9718
|
function memoryWithKG(opts) {
|
|
@@ -9127,20 +9734,20 @@ var MemoryWithTiersGraph = class extends import_graph8.Graph {
|
|
|
9127
9734
|
const permanentFilter = opts.permanentFilter ?? (() => false);
|
|
9128
9735
|
this.permanent = collection("permanent", { ranked: false });
|
|
9129
9736
|
this.mount("permanent", this.permanent);
|
|
9130
|
-
this.permanentKeys = (0,
|
|
9737
|
+
this.permanentKeys = (0, import_extra40.reactiveMap)({ name: "permanentKeys" });
|
|
9131
9738
|
this.add(this.permanentKeys.entries, { name: "permanentKeys" });
|
|
9132
|
-
this.entryCreatedAtNs = (0,
|
|
9739
|
+
this.entryCreatedAtNs = (0, import_extra40.reactiveMap)({ name: "entryCreatedAtNs" });
|
|
9133
9740
|
this.add(this.entryCreatedAtNs.entries, { name: "entryCreatedAtNs" });
|
|
9134
9741
|
let contextNode;
|
|
9135
9742
|
if (opts.context) {
|
|
9136
|
-
contextNode = (0,
|
|
9743
|
+
contextNode = (0, import_extra40.fromAny)(opts.context);
|
|
9137
9744
|
} else {
|
|
9138
|
-
contextNode = (0,
|
|
9745
|
+
contextNode = (0, import_core57.node)([], { initial: null });
|
|
9139
9746
|
this.add(contextNode, { name: "context" });
|
|
9140
9747
|
}
|
|
9141
9748
|
let latestCtx = contextNode.cache;
|
|
9142
9749
|
const ctxUnsub = contextNode.subscribe((msgs) => {
|
|
9143
|
-
for (const m of msgs) if (m[0] ===
|
|
9750
|
+
for (const m of msgs) if (m[0] === import_core57.DATA) latestCtx = m[1];
|
|
9144
9751
|
});
|
|
9145
9752
|
this.addDisposer(ctxUnsub);
|
|
9146
9753
|
const permanentKeysRef = this.permanentKeys;
|
|
@@ -9150,7 +9757,7 @@ var MemoryWithTiersGraph = class extends import_graph8.Graph {
|
|
|
9150
9757
|
score: (key, value) => {
|
|
9151
9758
|
if (permanentFilter(key, value)) return Number.POSITIVE_INFINITY;
|
|
9152
9759
|
if (permanentKeysRef.has(key)) return Number.POSITIVE_INFINITY;
|
|
9153
|
-
const nowNs = (0,
|
|
9760
|
+
const nowNs = (0, import_core57.monotonicNs)();
|
|
9154
9761
|
const createdNs = entryCreatedAtNsRef.get(key) ?? nowNs;
|
|
9155
9762
|
const ageSeconds2 = Number(nowNs - createdNs) / 1e9;
|
|
9156
9763
|
return decay(score(value, latestCtx), ageSeconds2, decayRate);
|
|
@@ -9185,20 +9792,20 @@ var MemoryWithTiersGraph = class extends import_graph8.Graph {
|
|
|
9185
9792
|
permanentKeysRef.set(key, true);
|
|
9186
9793
|
permanentRef.upsert(key, value);
|
|
9187
9794
|
};
|
|
9188
|
-
const syncCreatedAt = (0,
|
|
9795
|
+
const syncCreatedAt = (0, import_core57.node)(
|
|
9189
9796
|
[this.store.store.entries],
|
|
9190
9797
|
(batchData, _actions, ctx) => {
|
|
9191
9798
|
const data = batchData.map(
|
|
9192
9799
|
(b, i) => b != null && b.length > 0 ? b.at(-1) : ctx.prevData[i]
|
|
9193
9800
|
);
|
|
9194
9801
|
const map = data[0] ?? /* @__PURE__ */ new Map();
|
|
9195
|
-
const nowNs = (0,
|
|
9802
|
+
const nowNs = (0, import_core57.monotonicNs)();
|
|
9196
9803
|
const toAdd = [];
|
|
9197
9804
|
for (const key of map.keys()) {
|
|
9198
9805
|
if (!entryCreatedAtNsRef.has(key)) toAdd.push(key);
|
|
9199
9806
|
}
|
|
9200
9807
|
if (toAdd.length > 0) {
|
|
9201
|
-
(0,
|
|
9808
|
+
(0, import_core57.batch)(() => {
|
|
9202
9809
|
for (const key of toAdd) entryCreatedAtNsRef.set(key, nowNs);
|
|
9203
9810
|
});
|
|
9204
9811
|
}
|
|
@@ -9206,10 +9813,10 @@ var MemoryWithTiersGraph = class extends import_graph8.Graph {
|
|
|
9206
9813
|
{ name: "entryCreatedAtNs/sync", describeKind: "effect" }
|
|
9207
9814
|
);
|
|
9208
9815
|
this.add(syncCreatedAt, { name: "entryCreatedAtNs/sync" });
|
|
9209
|
-
this.addDisposer((0,
|
|
9816
|
+
this.addDisposer((0, import_extra40.keepalive)(syncCreatedAt));
|
|
9210
9817
|
const entriesUnsub = this.store.store.entries.subscribe((msgs) => {
|
|
9211
9818
|
for (const m of msgs) {
|
|
9212
|
-
if (m[0] !==
|
|
9819
|
+
if (m[0] !== import_core57.DATA) continue;
|
|
9213
9820
|
const map = m[1];
|
|
9214
9821
|
const created = entryCreatedAtNsRef.entries.cache;
|
|
9215
9822
|
if (created == null) continue;
|
|
@@ -9218,14 +9825,14 @@ var MemoryWithTiersGraph = class extends import_graph8.Graph {
|
|
|
9218
9825
|
if (!map.has(key)) toDelete.push(key);
|
|
9219
9826
|
}
|
|
9220
9827
|
if (toDelete.length > 0) {
|
|
9221
|
-
(0,
|
|
9828
|
+
(0, import_core57.batch)(() => {
|
|
9222
9829
|
for (const key of toDelete) entryCreatedAtNsRef.delete(key);
|
|
9223
9830
|
});
|
|
9224
9831
|
}
|
|
9225
9832
|
}
|
|
9226
9833
|
});
|
|
9227
9834
|
this.addDisposer(entriesUnsub);
|
|
9228
|
-
const promoter = (0,
|
|
9835
|
+
const promoter = (0, import_core57.node)(
|
|
9229
9836
|
[this.store.store.entries],
|
|
9230
9837
|
(batchData, _actions, ctx) => {
|
|
9231
9838
|
const data = batchData.map(
|
|
@@ -9235,7 +9842,7 @@ var MemoryWithTiersGraph = class extends import_graph8.Graph {
|
|
|
9235
9842
|
for (const [key, mem] of map) {
|
|
9236
9843
|
if (permanentKeysRef.has(key)) continue;
|
|
9237
9844
|
if (permanentFilter(key, mem)) {
|
|
9238
|
-
(0,
|
|
9845
|
+
(0, import_core57.batch)(() => {
|
|
9239
9846
|
markPermanent(key, mem);
|
|
9240
9847
|
});
|
|
9241
9848
|
}
|
|
@@ -9244,7 +9851,7 @@ var MemoryWithTiersGraph = class extends import_graph8.Graph {
|
|
|
9244
9851
|
{ name: "promoter", describeKind: "effect" }
|
|
9245
9852
|
);
|
|
9246
9853
|
this.add(promoter, { name: "promoter" });
|
|
9247
|
-
this.addDisposer((0,
|
|
9854
|
+
this.addDisposer((0, import_extra40.keepalive)(promoter));
|
|
9248
9855
|
let archiveHandle = null;
|
|
9249
9856
|
if (opts.archiveTier) {
|
|
9250
9857
|
archiveHandle = this.attachSnapshotStorage(
|
|
@@ -9300,7 +9907,7 @@ var MemoryRetrievalGraph = class extends import_graph8.Graph {
|
|
|
9300
9907
|
this._budget = opts.budget ?? 2e3;
|
|
9301
9908
|
this._contextWeight = opts.contextWeight ?? 0;
|
|
9302
9909
|
if (opts.context) {
|
|
9303
|
-
this._contextNode = (0,
|
|
9910
|
+
this._contextNode = (0, import_extra40.fromAny)(opts.context);
|
|
9304
9911
|
} else {
|
|
9305
9912
|
this._contextNode = this.state("_context", null);
|
|
9306
9913
|
}
|
|
@@ -9446,7 +10053,7 @@ var MemoryRetrievalGraph = class extends import_graph8.Graph {
|
|
|
9446
10053
|
const id = ++this._retrieveSeq;
|
|
9447
10054
|
const segment = `retrieve_${id}`;
|
|
9448
10055
|
const sub = new import_graph8.Graph(segment);
|
|
9449
|
-
const inputNode = (0,
|
|
10056
|
+
const inputNode = (0, import_extra40.fromAny)(queryInput);
|
|
9450
10057
|
const localContext = sub.derived(
|
|
9451
10058
|
"context",
|
|
9452
10059
|
[inputNode],
|
|
@@ -9491,7 +10098,7 @@ var MemoryRetrievalGraph = class extends import_graph8.Graph {
|
|
|
9491
10098
|
initial: { packed: [], trace: null }
|
|
9492
10099
|
}
|
|
9493
10100
|
);
|
|
9494
|
-
const projection = (0,
|
|
10101
|
+
const projection = (0, import_core57.node)(
|
|
9495
10102
|
[result],
|
|
9496
10103
|
(batchData, actions, ctx) => {
|
|
9497
10104
|
const data = batchData.map(
|
|
@@ -9531,18 +10138,18 @@ function gaugesAsContext(graph, actor, options) {
|
|
|
9531
10138
|
const separator = options?.separator ?? "\n";
|
|
9532
10139
|
const entries = [];
|
|
9533
10140
|
const sinceVersion = options?.sinceVersion;
|
|
9534
|
-
for (const [path,
|
|
9535
|
-
const meta2 =
|
|
10141
|
+
for (const [path, node65] of Object.entries(described.nodes)) {
|
|
10142
|
+
const meta2 = node65.meta ?? {};
|
|
9536
10143
|
const desc = meta2.description;
|
|
9537
10144
|
const format = meta2.format;
|
|
9538
10145
|
if (!desc && !format) continue;
|
|
9539
|
-
if (sinceVersion != null &&
|
|
10146
|
+
if (sinceVersion != null && node65.v != null) {
|
|
9540
10147
|
const lastSeen = sinceVersion.get(path);
|
|
9541
|
-
if (lastSeen != null && lastSeen.id ===
|
|
10148
|
+
if (lastSeen != null && lastSeen.id === node65.v.id && node65.v.version <= lastSeen.version)
|
|
9542
10149
|
continue;
|
|
9543
10150
|
}
|
|
9544
10151
|
const label = desc ?? path;
|
|
9545
|
-
const value =
|
|
10152
|
+
const value = node65.value;
|
|
9546
10153
|
const unit = meta2.unit;
|
|
9547
10154
|
let formatted;
|
|
9548
10155
|
if (format === "currency" && typeof value === "number") {
|
|
@@ -9564,8 +10171,8 @@ function gaugesAsContext(graph, actor, options) {
|
|
|
9564
10171
|
const tagGroups = /* @__PURE__ */ new Map();
|
|
9565
10172
|
const ungrouped = [];
|
|
9566
10173
|
for (const entry of entries) {
|
|
9567
|
-
const
|
|
9568
|
-
const tags =
|
|
10174
|
+
const node65 = described.nodes[entry.path];
|
|
10175
|
+
const tags = node65.meta?.tags;
|
|
9569
10176
|
if (tags && tags.length > 0) {
|
|
9570
10177
|
const tag = tags[0];
|
|
9571
10178
|
let group = tagGroups.get(tag);
|
|
@@ -9596,18 +10203,18 @@ function gaugesAsContext(graph, actor, options) {
|
|
|
9596
10203
|
}
|
|
9597
10204
|
|
|
9598
10205
|
// src/utils/ai/graph-integration/graph-from-spec.ts
|
|
9599
|
-
var
|
|
9600
|
-
var
|
|
10206
|
+
var import_core60 = require("@graphrefly/pure-ts/core");
|
|
10207
|
+
var import_extra43 = require("@graphrefly/pure-ts/extra");
|
|
9601
10208
|
|
|
9602
10209
|
// src/utils/graphspec/index.ts
|
|
9603
|
-
var
|
|
10210
|
+
var import_core59 = require("@graphrefly/pure-ts/core");
|
|
9604
10211
|
var import_graph10 = require("@graphrefly/pure-ts/graph");
|
|
9605
10212
|
|
|
9606
10213
|
// src/utils/reduction/index.ts
|
|
9607
|
-
var
|
|
9608
|
-
var
|
|
10214
|
+
var import_core58 = require("@graphrefly/pure-ts/core");
|
|
10215
|
+
var import_extra41 = require("@graphrefly/pure-ts/extra");
|
|
9609
10216
|
var import_graph9 = require("@graphrefly/pure-ts/graph");
|
|
9610
|
-
var
|
|
10217
|
+
var import_extra42 = require("@graphrefly/pure-ts/extra");
|
|
9611
10218
|
function baseMeta(kind, meta2) {
|
|
9612
10219
|
return domainMeta("reduction", kind, meta2);
|
|
9613
10220
|
}
|
|
@@ -9615,7 +10222,7 @@ function funnel(name, sources, stages, opts) {
|
|
|
9615
10222
|
if (sources.length === 0) throw new RangeError("funnel requires at least one source");
|
|
9616
10223
|
if (stages.length === 0) throw new RangeError("funnel requires at least one stage");
|
|
9617
10224
|
const g = new import_graph9.Graph(name, opts);
|
|
9618
|
-
const merged = sources.length === 1 ? sources[0] : (0,
|
|
10225
|
+
const merged = sources.length === 1 ? sources[0] : (0, import_extra41.merge)(...sources);
|
|
9619
10226
|
g.add(merged, { name: "merged" });
|
|
9620
10227
|
let prevOutputPath = "merged";
|
|
9621
10228
|
for (let i = 0; i < stages.length; i++) {
|
|
@@ -9637,7 +10244,7 @@ function funnel(name, sources, stages, opts) {
|
|
|
9637
10244
|
const stageInputPath = `${stage.name}::input`;
|
|
9638
10245
|
const stageInput = g.resolve(stageInputPath);
|
|
9639
10246
|
const bridgeName = `__bridge_${prevOutputPath}\u2192${stage.name}_input`;
|
|
9640
|
-
const br = (0,
|
|
10247
|
+
const br = (0, import_core58.node)(
|
|
9641
10248
|
[prevNode],
|
|
9642
10249
|
(batchData, _actions, ctx) => {
|
|
9643
10250
|
const data = batchData.map(
|
|
@@ -9649,7 +10256,7 @@ function funnel(name, sources, stages, opts) {
|
|
|
9649
10256
|
{ describeKind: "effect", name: bridgeName }
|
|
9650
10257
|
);
|
|
9651
10258
|
g.add(br, { name: bridgeName });
|
|
9652
|
-
g.addDisposer((0,
|
|
10259
|
+
g.addDisposer((0, import_extra42.keepalive)(br));
|
|
9653
10260
|
prevOutputPath = `${stage.name}::output`;
|
|
9654
10261
|
}
|
|
9655
10262
|
return g;
|
|
@@ -9657,7 +10264,7 @@ function funnel(name, sources, stages, opts) {
|
|
|
9657
10264
|
function feedback(graph, condition, reentry, opts) {
|
|
9658
10265
|
const maxIter = opts?.maxIterations ?? 10;
|
|
9659
10266
|
const counterName = `__feedback_${condition}`;
|
|
9660
|
-
const counter = (0,
|
|
10267
|
+
const counter = (0, import_core58.node)([], {
|
|
9661
10268
|
...{
|
|
9662
10269
|
meta: baseMeta("feedback_counter", {
|
|
9663
10270
|
maxIterations: maxIter,
|
|
@@ -9671,27 +10278,27 @@ function feedback(graph, condition, reentry, opts) {
|
|
|
9671
10278
|
const condNode = graph.resolve(condition);
|
|
9672
10279
|
const reentryNode = graph.resolve(reentry);
|
|
9673
10280
|
const feedbackEffectName = `__feedback_effect_${condition}`;
|
|
9674
|
-
const feedbackEffect = (0,
|
|
10281
|
+
const feedbackEffect = (0, import_core58.node)(
|
|
9675
10282
|
[],
|
|
9676
10283
|
(_data, _feedbackActions) => {
|
|
9677
10284
|
const unsub = condNode.subscribe((msgs) => {
|
|
9678
10285
|
for (const msg of msgs) {
|
|
9679
10286
|
const t = msg[0];
|
|
9680
|
-
if (t ===
|
|
10287
|
+
if (t === import_core58.DATA) {
|
|
9681
10288
|
const condValue = msg[1];
|
|
9682
10289
|
if (condValue == null) return;
|
|
9683
|
-
(0,
|
|
10290
|
+
(0, import_core58.batch)(() => {
|
|
9684
10291
|
if (tryIncrementBounded(counter, maxIter)) {
|
|
9685
10292
|
reentryNode.emit(condValue);
|
|
9686
10293
|
}
|
|
9687
10294
|
});
|
|
9688
|
-
} else if (t ===
|
|
9689
|
-
const terminal = t ===
|
|
10295
|
+
} else if (t === import_core58.COMPLETE || t === import_core58.ERROR) {
|
|
10296
|
+
const terminal = t === import_core58.ERROR && msg.length > 1 ? [import_core58.ERROR, msg[1]] : [t];
|
|
9690
10297
|
counter.down([terminal]);
|
|
9691
10298
|
}
|
|
9692
10299
|
}
|
|
9693
10300
|
});
|
|
9694
|
-
return () => unsub();
|
|
10301
|
+
return { onDeactivation: () => unsub() };
|
|
9695
10302
|
},
|
|
9696
10303
|
{
|
|
9697
10304
|
name: feedbackEffectName,
|
|
@@ -9706,7 +10313,7 @@ function feedback(graph, condition, reentry, opts) {
|
|
|
9706
10313
|
}
|
|
9707
10314
|
);
|
|
9708
10315
|
graph.add(feedbackEffect, { name: feedbackEffectName });
|
|
9709
|
-
graph.addDisposer((0,
|
|
10316
|
+
graph.addDisposer((0, import_extra42.keepalive)(feedbackEffect));
|
|
9710
10317
|
return graph;
|
|
9711
10318
|
}
|
|
9712
10319
|
function scorer(sources, weights, opts) {
|
|
@@ -9717,7 +10324,7 @@ function scorer(sources, weights, opts) {
|
|
|
9717
10324
|
const allDeps = [...sources, ...weights];
|
|
9718
10325
|
const n = sources.length;
|
|
9719
10326
|
const scoreFns = opts?.scoreFns;
|
|
9720
|
-
return (0,
|
|
10327
|
+
return (0, import_core58.node)(
|
|
9721
10328
|
allDeps,
|
|
9722
10329
|
(batchData, actions, ctx) => {
|
|
9723
10330
|
const vals = batchData.map(
|
|
@@ -9754,18 +10361,18 @@ function scorer(sources, weights, opts) {
|
|
|
9754
10361
|
}
|
|
9755
10362
|
|
|
9756
10363
|
// src/utils/graphspec/index.ts
|
|
9757
|
-
function readFactory(
|
|
9758
|
-
const f =
|
|
10364
|
+
function readFactory(node65) {
|
|
10365
|
+
const f = node65.meta?.factory;
|
|
9759
10366
|
return typeof f === "string" ? f : void 0;
|
|
9760
10367
|
}
|
|
9761
|
-
function readFactoryArgs(
|
|
9762
|
-
const a =
|
|
10368
|
+
function readFactoryArgs(node65) {
|
|
10369
|
+
const a = node65.meta?.factoryArgs;
|
|
9763
10370
|
return a != null && typeof a === "object" ? a : {};
|
|
9764
10371
|
}
|
|
9765
|
-
function readStateInitial(
|
|
9766
|
-
const args = readFactoryArgs(
|
|
10372
|
+
function readStateInitial(node65) {
|
|
10373
|
+
const args = readFactoryArgs(node65);
|
|
9767
10374
|
if ("initial" in args) return args.initial;
|
|
9768
|
-
return
|
|
10375
|
+
return node65.value;
|
|
9769
10376
|
}
|
|
9770
10377
|
function isRichFnEntry(entry) {
|
|
9771
10378
|
return typeof entry === "object" && entry !== null && "factory" in entry;
|
|
@@ -9838,11 +10445,11 @@ function validateSpecAgainstCatalog(spec, catalog) {
|
|
|
9838
10445
|
const sourceNames = new Set(Object.keys(catalog.sources ?? {}));
|
|
9839
10446
|
for (const [nodeName, nodeRaw] of Object.entries(spec.nodes)) {
|
|
9840
10447
|
if (nodeRaw.type === "template") continue;
|
|
9841
|
-
const
|
|
9842
|
-
const factoryName = readFactory(
|
|
10448
|
+
const node65 = nodeRaw;
|
|
10449
|
+
const factoryName = readFactory(node65);
|
|
9843
10450
|
if (factoryName == null) continue;
|
|
9844
|
-
const isProducer =
|
|
9845
|
-
if (
|
|
10451
|
+
const isProducer = node65.type === "producer";
|
|
10452
|
+
if (node65.type === "state" && factoryName === "state") continue;
|
|
9846
10453
|
if (isProducer) {
|
|
9847
10454
|
const inSources = sourceNames.has(factoryName);
|
|
9848
10455
|
const inFns = fnNames.has(factoryName);
|
|
@@ -9866,7 +10473,7 @@ function validateSpecAgainstCatalog(spec, catalog) {
|
|
|
9866
10473
|
}
|
|
9867
10474
|
}
|
|
9868
10475
|
}
|
|
9869
|
-
const factoryArgs = readFactoryArgs(
|
|
10476
|
+
const factoryArgs = readFactoryArgs(node65);
|
|
9870
10477
|
if (!isProducer && catalog.fns?.[factoryName]) {
|
|
9871
10478
|
const entry = catalog.fns[factoryName];
|
|
9872
10479
|
if (isRichFnEntry(entry) && entry.configSchema) {
|
|
@@ -9906,11 +10513,11 @@ function validateSpecAgainstCatalog(spec, catalog) {
|
|
|
9906
10513
|
}
|
|
9907
10514
|
if (spec.templates) {
|
|
9908
10515
|
for (const [tName, template] of Object.entries(spec.templates)) {
|
|
9909
|
-
for (const [nodeName,
|
|
9910
|
-
const factoryName = readFactory(
|
|
10516
|
+
for (const [nodeName, node65] of Object.entries(template.nodes)) {
|
|
10517
|
+
const factoryName = readFactory(node65);
|
|
9911
10518
|
if (factoryName == null) continue;
|
|
9912
|
-
if (
|
|
9913
|
-
if (
|
|
10519
|
+
if (node65.type === "state" && factoryName === "state") continue;
|
|
10520
|
+
if (node65.type === "producer") continue;
|
|
9914
10521
|
if (fnNames.size > 0 && !fnNames.has(factoryName)) {
|
|
9915
10522
|
const suggestion = findClosest(factoryName, fnNames);
|
|
9916
10523
|
errors.push(
|
|
@@ -10125,8 +10732,8 @@ function validateSpec(spec) {
|
|
|
10125
10732
|
warnings
|
|
10126
10733
|
};
|
|
10127
10734
|
}
|
|
10128
|
-
function readOwner(
|
|
10129
|
-
const o =
|
|
10735
|
+
function readOwner(node65) {
|
|
10736
|
+
const o = node65.meta?.owner;
|
|
10130
10737
|
return typeof o === "string" && o.length > 0 ? o : void 0;
|
|
10131
10738
|
}
|
|
10132
10739
|
var OVERRIDE_OWNER_TRAILER = /^\s*override-owner\s*:\s*(.+?)\s*$/im;
|
|
@@ -10225,7 +10832,7 @@ ${catalogValidation.errors.join("\n")}`
|
|
|
10225
10832
|
const factoryArgs = readFactoryArgs(n);
|
|
10226
10833
|
if (n.type === "state") {
|
|
10227
10834
|
const initial = readStateInitial(n);
|
|
10228
|
-
const nd = (0,
|
|
10835
|
+
const nd = (0, import_core59.node)([], {
|
|
10229
10836
|
name,
|
|
10230
10837
|
initial,
|
|
10231
10838
|
meta: stripFactoryMeta(n.meta)
|
|
@@ -10245,7 +10852,7 @@ ${catalogValidation.errors.join("\n")}`
|
|
|
10245
10852
|
created.set(name, nd);
|
|
10246
10853
|
} else {
|
|
10247
10854
|
if (factoryName) recordMissing(name, "source", factoryName);
|
|
10248
|
-
const nd = (0,
|
|
10855
|
+
const nd = (0, import_core59.node)([], () => {
|
|
10249
10856
|
}, {
|
|
10250
10857
|
name,
|
|
10251
10858
|
describeKind: "producer",
|
|
@@ -10274,11 +10881,11 @@ ${catalogValidation.errors.join("\n")}`
|
|
|
10274
10881
|
nd = fnFactory(resolvedDeps, factoryArgs);
|
|
10275
10882
|
} else if (n.type === "effect") {
|
|
10276
10883
|
if (factoryName) recordMissing(name, "fn", factoryName);
|
|
10277
|
-
nd = (0,
|
|
10884
|
+
nd = (0, import_core59.node)(resolvedDeps, () => {
|
|
10278
10885
|
}, { describeKind: "effect" });
|
|
10279
10886
|
} else {
|
|
10280
10887
|
if (factoryName) recordMissing(name, "fn", factoryName);
|
|
10281
|
-
nd = (0,
|
|
10888
|
+
nd = (0, import_core59.node)(
|
|
10282
10889
|
resolvedDeps,
|
|
10283
10890
|
(batchData, actions, ctx) => {
|
|
10284
10891
|
const data = batchData.map(
|
|
@@ -10318,7 +10925,7 @@ ${catalogValidation.errors.join("\n")}`
|
|
|
10318
10925
|
const factoryArgs = readFactoryArgs(nSpec);
|
|
10319
10926
|
if (nSpec.type === "state") {
|
|
10320
10927
|
const initial = readStateInitial(nSpec);
|
|
10321
|
-
const nd = (0,
|
|
10928
|
+
const nd = (0, import_core59.node)([], {
|
|
10322
10929
|
name: nName,
|
|
10323
10930
|
initial,
|
|
10324
10931
|
meta: stripFactoryMeta(nSpec.meta)
|
|
@@ -10338,7 +10945,7 @@ ${catalogValidation.errors.join("\n")}`
|
|
|
10338
10945
|
subCreated.set(nName, nd);
|
|
10339
10946
|
} else {
|
|
10340
10947
|
if (factoryName) recordMissing(`${name}.${nName}`, "source", factoryName);
|
|
10341
|
-
const nd = (0,
|
|
10948
|
+
const nd = (0, import_core59.node)([], () => {
|
|
10342
10949
|
}, {
|
|
10343
10950
|
name: nName,
|
|
10344
10951
|
describeKind: "producer",
|
|
@@ -10368,11 +10975,11 @@ ${catalogValidation.errors.join("\n")}`
|
|
|
10368
10975
|
nd = fnFactory(resolvedDeps, factoryArgs);
|
|
10369
10976
|
} else if (nSpec.type === "effect") {
|
|
10370
10977
|
if (factoryName) recordMissing(`${name}.${nName}`, "fn", factoryName);
|
|
10371
|
-
nd = (0,
|
|
10978
|
+
nd = (0, import_core59.node)(resolvedDeps, () => {
|
|
10372
10979
|
}, { describeKind: "effect" });
|
|
10373
10980
|
} else {
|
|
10374
10981
|
if (factoryName) recordMissing(`${name}.${nName}`, "fn", factoryName);
|
|
10375
|
-
nd = (0,
|
|
10982
|
+
nd = (0, import_core59.node)(
|
|
10376
10983
|
resolvedDeps,
|
|
10377
10984
|
(batchData, actions, ctx) => {
|
|
10378
10985
|
const data = batchData.map(
|
|
@@ -10859,12 +11466,12 @@ ${opts.systemPromptExtra}` : GRAPH_FROM_SPEC_SYSTEM_PROMPT;
|
|
|
10859
11466
|
return compileSpec(parsed, { catalog: opts?.catalog });
|
|
10860
11467
|
}
|
|
10861
11468
|
function graphFromSpecReactive(input, adapter, opts) {
|
|
10862
|
-
const inputNode = (0,
|
|
10863
|
-
return (0,
|
|
11469
|
+
const inputNode = (0, import_extra43.fromAny)(input);
|
|
11470
|
+
return (0, import_extra43.switchMap)(inputNode, (nl) => {
|
|
10864
11471
|
if (!nl || typeof nl !== "string" || nl.trim().length === 0) {
|
|
10865
|
-
return (0,
|
|
11472
|
+
return (0, import_core60.node)([], { initial: null });
|
|
10866
11473
|
}
|
|
10867
|
-
return (0,
|
|
11474
|
+
return (0, import_core60.node)(
|
|
10868
11475
|
(_data, actions) => {
|
|
10869
11476
|
const controller = new AbortController();
|
|
10870
11477
|
let cancelled = false;
|
|
@@ -10874,14 +11481,16 @@ function graphFromSpecReactive(input, adapter, opts) {
|
|
|
10874
11481
|
return;
|
|
10875
11482
|
}
|
|
10876
11483
|
actions.emit(g);
|
|
10877
|
-
actions.down([[
|
|
11484
|
+
actions.down([[import_core60.COMPLETE]]);
|
|
10878
11485
|
}).catch((err) => {
|
|
10879
11486
|
if (cancelled) return;
|
|
10880
|
-
actions.down([[
|
|
11487
|
+
actions.down([[import_core60.ERROR, err]]);
|
|
10881
11488
|
});
|
|
10882
|
-
return
|
|
10883
|
-
|
|
10884
|
-
|
|
11489
|
+
return {
|
|
11490
|
+
onDeactivation: () => {
|
|
11491
|
+
cancelled = true;
|
|
11492
|
+
controller.abort();
|
|
11493
|
+
}
|
|
10885
11494
|
};
|
|
10886
11495
|
},
|
|
10887
11496
|
{ describeKind: "producer", ...{ name: "graphFromSpec::call" } }
|
|
@@ -10928,11 +11537,11 @@ function knobsAsTools(graph, actor) {
|
|
|
10928
11537
|
const openai = [];
|
|
10929
11538
|
const mcp = [];
|
|
10930
11539
|
const definitions = [];
|
|
10931
|
-
for (const [path,
|
|
10932
|
-
if (
|
|
11540
|
+
for (const [path, node65] of Object.entries(described.nodes)) {
|
|
11541
|
+
if (node65.type !== "state") continue;
|
|
10933
11542
|
if (path.includes("::__meta__::")) continue;
|
|
10934
|
-
if (
|
|
10935
|
-
const meta2 =
|
|
11543
|
+
if (node65.status === "completed" || node65.status === "errored") continue;
|
|
11544
|
+
const meta2 = node65.meta ?? {};
|
|
10936
11545
|
const access = meta2.access;
|
|
10937
11546
|
if (access === "human" || access === "system") continue;
|
|
10938
11547
|
const description = meta2.description ?? `Set the value of ${path}`;
|
|
@@ -10961,7 +11570,7 @@ function knobsAsTools(graph, actor) {
|
|
|
10961
11570
|
});
|
|
10962
11571
|
const graphRef = graph;
|
|
10963
11572
|
const actorRef = actor;
|
|
10964
|
-
const nv =
|
|
11573
|
+
const nv = node65.v;
|
|
10965
11574
|
definitions.push({
|
|
10966
11575
|
name: path,
|
|
10967
11576
|
description,
|
|
@@ -10977,8 +11586,8 @@ function knobsAsTools(graph, actor) {
|
|
|
10977
11586
|
}
|
|
10978
11587
|
|
|
10979
11588
|
// src/utils/ai/graph-integration/suggest-strategy.ts
|
|
10980
|
-
var
|
|
10981
|
-
var
|
|
11589
|
+
var import_core61 = require("@graphrefly/pure-ts/core");
|
|
11590
|
+
var import_extra44 = require("@graphrefly/pure-ts/extra");
|
|
10982
11591
|
var SUGGEST_STRATEGY_SYSTEM_PROMPT = `You are a reactive graph optimizer for GraphReFly.
|
|
10983
11592
|
|
|
10984
11593
|
Given a graph's current structure (from describe()) and a problem statement, suggest topology and parameter changes to solve the problem.
|
|
@@ -11047,30 +11656,32 @@ async function suggestStrategy(graph, problem, adapter, opts) {
|
|
|
11047
11656
|
};
|
|
11048
11657
|
}
|
|
11049
11658
|
function suggestStrategyReactive(graph, problem, adapter, opts) {
|
|
11050
|
-
const problemNode = (0,
|
|
11051
|
-
const paired = (0,
|
|
11052
|
-
return (0,
|
|
11053
|
-
if (pair == null) return (0,
|
|
11659
|
+
const problemNode = (0, import_extra44.fromAny)(problem);
|
|
11660
|
+
const paired = (0, import_extra44.withLatestFrom)(problemNode, graph);
|
|
11661
|
+
return (0, import_extra44.switchMap)(paired, (pair) => {
|
|
11662
|
+
if (pair == null) return (0, import_core61.node)([], { initial: null });
|
|
11054
11663
|
const [pText, g] = pair;
|
|
11055
11664
|
if (!g || !pText || typeof pText !== "string" || pText.trim().length === 0) {
|
|
11056
|
-
return (0,
|
|
11665
|
+
return (0, import_core61.node)([], { initial: null });
|
|
11057
11666
|
}
|
|
11058
|
-
if (g.destroyed) return (0,
|
|
11059
|
-
return (0,
|
|
11667
|
+
if (g.destroyed) return (0, import_core61.node)([], { initial: null });
|
|
11668
|
+
return (0, import_core61.node)(
|
|
11060
11669
|
(_data, actions) => {
|
|
11061
11670
|
const controller = new AbortController();
|
|
11062
11671
|
let cancelled = false;
|
|
11063
11672
|
suggestStrategy(g, pText, adapter, { ...opts, signal: controller.signal }).then((plan) => {
|
|
11064
11673
|
if (cancelled) return;
|
|
11065
11674
|
actions.emit(plan);
|
|
11066
|
-
actions.down([[
|
|
11675
|
+
actions.down([[import_core61.COMPLETE]]);
|
|
11067
11676
|
}).catch((err) => {
|
|
11068
11677
|
if (cancelled) return;
|
|
11069
|
-
actions.down([[
|
|
11678
|
+
actions.down([[import_core61.ERROR, err]]);
|
|
11070
11679
|
});
|
|
11071
|
-
return
|
|
11072
|
-
|
|
11073
|
-
|
|
11680
|
+
return {
|
|
11681
|
+
onDeactivation: () => {
|
|
11682
|
+
cancelled = true;
|
|
11683
|
+
controller.abort();
|
|
11684
|
+
}
|
|
11074
11685
|
};
|
|
11075
11686
|
},
|
|
11076
11687
|
{ describeKind: "producer", ...{ name: "suggestStrategy::call" } }
|
|
@@ -11099,14 +11710,14 @@ function validateGraphDef(def) {
|
|
|
11099
11710
|
errors.push(`Node "${name}": must be an object`);
|
|
11100
11711
|
continue;
|
|
11101
11712
|
}
|
|
11102
|
-
const
|
|
11103
|
-
if (typeof
|
|
11713
|
+
const node65 = raw;
|
|
11714
|
+
if (typeof node65.type !== "string" || !VALID_NODE_TYPES2.has(node65.type)) {
|
|
11104
11715
|
errors.push(
|
|
11105
|
-
`Node "${name}": invalid type "${String(
|
|
11716
|
+
`Node "${name}": invalid type "${String(node65.type)}" (expected: ${[...VALID_NODE_TYPES2].join(", ")})`
|
|
11106
11717
|
);
|
|
11107
11718
|
}
|
|
11108
|
-
if (Array.isArray(
|
|
11109
|
-
for (const dep of
|
|
11719
|
+
if (Array.isArray(node65.deps)) {
|
|
11720
|
+
for (const dep of node65.deps) {
|
|
11110
11721
|
if (typeof dep === "string" && !nodeNames.has(dep)) {
|
|
11111
11722
|
errors.push(`Node "${name}": dep "${dep}" does not reference an existing node`);
|
|
11112
11723
|
}
|
|
@@ -11143,21 +11754,21 @@ function validateGraphDef(def) {
|
|
|
11143
11754
|
}
|
|
11144
11755
|
|
|
11145
11756
|
// src/utils/cqrs/index.ts
|
|
11146
|
-
var
|
|
11147
|
-
var
|
|
11757
|
+
var import_core62 = require("@graphrefly/pure-ts/core");
|
|
11758
|
+
var import_extra45 = require("@graphrefly/pure-ts/extra");
|
|
11148
11759
|
var import_graph11 = require("@graphrefly/pure-ts/graph");
|
|
11149
|
-
var
|
|
11150
|
-
var COMMAND_GUARD = (0,
|
|
11760
|
+
var import_extra46 = require("@graphrefly/pure-ts/extra");
|
|
11761
|
+
var COMMAND_GUARD = (0, import_core62.policy)((allow, deny) => {
|
|
11151
11762
|
allow("write");
|
|
11152
11763
|
allow("signal");
|
|
11153
11764
|
deny("observe");
|
|
11154
11765
|
});
|
|
11155
|
-
var PROJECTION_GUARD = (0,
|
|
11766
|
+
var PROJECTION_GUARD = (0, import_core62.policy)((allow, deny) => {
|
|
11156
11767
|
allow("observe");
|
|
11157
11768
|
allow("signal");
|
|
11158
11769
|
deny("write");
|
|
11159
11770
|
});
|
|
11160
|
-
var EVENT_GUARD = (0,
|
|
11771
|
+
var EVENT_GUARD = (0, import_core62.policy)((allow, deny) => {
|
|
11161
11772
|
allow("observe");
|
|
11162
11773
|
allow("signal");
|
|
11163
11774
|
deny("write");
|
|
@@ -11267,7 +11878,7 @@ var CqrsGraph = class extends import_graph11.Graph {
|
|
|
11267
11878
|
aggregateId,
|
|
11268
11879
|
type,
|
|
11269
11880
|
lastVersion,
|
|
11270
|
-
t_ns: (0,
|
|
11881
|
+
t_ns: (0, import_core62.wallClockNs)()
|
|
11271
11882
|
});
|
|
11272
11883
|
}
|
|
11273
11884
|
}
|
|
@@ -11328,7 +11939,7 @@ var CqrsGraph = class extends import_graph11.Graph {
|
|
|
11328
11939
|
}
|
|
11329
11940
|
const existing = this._eventLogs.get(name);
|
|
11330
11941
|
if (existing) return existing.node;
|
|
11331
|
-
const log = (0,
|
|
11942
|
+
const log = (0, import_extra45.reactiveLog)([], {
|
|
11332
11943
|
name,
|
|
11333
11944
|
versioning: 0,
|
|
11334
11945
|
maxSize: this._retainedLimit
|
|
@@ -11348,7 +11959,7 @@ var CqrsGraph = class extends import_graph11.Graph {
|
|
|
11348
11959
|
initial: entries.cache
|
|
11349
11960
|
}
|
|
11350
11961
|
);
|
|
11351
|
-
this.addDisposer((0,
|
|
11962
|
+
this.addDisposer((0, import_extra46.keepalive)(guarded));
|
|
11352
11963
|
this._eventLogs.set(name, { log, node: guarded });
|
|
11353
11964
|
this._autoWireStreamStorage(name, log);
|
|
11354
11965
|
return guarded;
|
|
@@ -11370,7 +11981,7 @@ var CqrsGraph = class extends import_graph11.Graph {
|
|
|
11370
11981
|
const existing = byType.get(aggregateId);
|
|
11371
11982
|
if (existing) return existing;
|
|
11372
11983
|
const nodeName = `${type}_${aggregateId.replace(/[^a-zA-Z0-9_-]/g, "_")}`;
|
|
11373
|
-
const log = (0,
|
|
11984
|
+
const log = (0, import_extra45.reactiveLog)([], {
|
|
11374
11985
|
name: nodeName,
|
|
11375
11986
|
versioning: 0,
|
|
11376
11987
|
maxSize: this._retainedLimit
|
|
@@ -11402,7 +12013,7 @@ var CqrsGraph = class extends import_graph11.Graph {
|
|
|
11402
12013
|
}
|
|
11403
12014
|
);
|
|
11404
12015
|
} catch {
|
|
11405
|
-
guarded = (0,
|
|
12016
|
+
guarded = (0, import_core62.node)(
|
|
11406
12017
|
[entries],
|
|
11407
12018
|
(batchData, actions, ctx) => {
|
|
11408
12019
|
const latest = batchData[0] != null && batchData[0].length > 0 ? batchData[0].at(-1) : ctx.prevData[0];
|
|
@@ -11420,7 +12031,7 @@ var CqrsGraph = class extends import_graph11.Graph {
|
|
|
11420
12031
|
}
|
|
11421
12032
|
);
|
|
11422
12033
|
}
|
|
11423
|
-
this.addDisposer((0,
|
|
12034
|
+
this.addDisposer((0, import_extra46.keepalive)(guarded));
|
|
11424
12035
|
const entry = { log, node: guarded };
|
|
11425
12036
|
byType.set(aggregateId, entry);
|
|
11426
12037
|
this._autoWireStreamStorage(`${type}::${aggregateId}`, log);
|
|
@@ -11460,7 +12071,7 @@ var CqrsGraph = class extends import_graph11.Graph {
|
|
|
11460
12071
|
const evt = {
|
|
11461
12072
|
type: eventName,
|
|
11462
12073
|
payload: frozenPayload,
|
|
11463
|
-
timestampNs: (0,
|
|
12074
|
+
timestampNs: (0, import_core62.wallClockNs)(),
|
|
11464
12075
|
seq: ++this._seq,
|
|
11465
12076
|
...extra?.aggregateId !== void 0 ? { aggregateId: extra.aggregateId } : {},
|
|
11466
12077
|
...aggregateVersion !== void 0 ? { aggregateVersion } : {},
|
|
@@ -11708,7 +12319,7 @@ var CqrsGraph = class extends import_graph11.Graph {
|
|
|
11708
12319
|
initial: seedState
|
|
11709
12320
|
}
|
|
11710
12321
|
);
|
|
11711
|
-
this.addDisposer((0,
|
|
12322
|
+
this.addDisposer((0, import_extra46.keepalive)(projNode));
|
|
11712
12323
|
this.addDisposer(() => {
|
|
11713
12324
|
if (saveTimer !== void 0) {
|
|
11714
12325
|
clearTimeout(saveTimer);
|
|
@@ -11818,7 +12429,7 @@ var CqrsGraph = class extends import_graph11.Graph {
|
|
|
11818
12429
|
const cursor = cursors[eName];
|
|
11819
12430
|
latestCursors.set(eName, cursor.cache ?? 0);
|
|
11820
12431
|
const sub = cursor.subscribe((msgs) => {
|
|
11821
|
-
for (const m of msgs) if (m[0] ===
|
|
12432
|
+
for (const m of msgs) if (m[0] === import_core62.DATA) latestCursors.set(eName, m[1]);
|
|
11822
12433
|
});
|
|
11823
12434
|
this.addDisposer(sub);
|
|
11824
12435
|
}
|
|
@@ -11898,7 +12509,7 @@ var CqrsGraph = class extends import_graph11.Graph {
|
|
|
11898
12509
|
}
|
|
11899
12510
|
);
|
|
11900
12511
|
sagaRef.n = sagaNode;
|
|
11901
|
-
this.addDisposer((0,
|
|
12512
|
+
this.addDisposer((0, import_extra46.keepalive)(sagaNode));
|
|
11902
12513
|
this._sagas.add(name);
|
|
11903
12514
|
return {
|
|
11904
12515
|
node: sagaNode,
|
|
@@ -11911,12 +12522,12 @@ var CqrsGraph = class extends import_graph11.Graph {
|
|
|
11911
12522
|
function cqrs(name, opts) {
|
|
11912
12523
|
const g = new CqrsGraph(name, opts);
|
|
11913
12524
|
const { factory: _f, factoryArgs: _fa, ...tagArgs } = opts ?? {};
|
|
11914
|
-
g.tagFactory("cqrs", (0,
|
|
12525
|
+
g.tagFactory("cqrs", (0, import_core62.placeholderArgs)(tagArgs));
|
|
11915
12526
|
return g;
|
|
11916
12527
|
}
|
|
11917
12528
|
|
|
11918
12529
|
// src/utils/demo-shell/index.ts
|
|
11919
|
-
var
|
|
12530
|
+
var import_core65 = require("@graphrefly/pure-ts/core");
|
|
11920
12531
|
var import_graph13 = require("@graphrefly/pure-ts/graph");
|
|
11921
12532
|
|
|
11922
12533
|
// src/base/render/_ascii-width.ts
|
|
@@ -12539,14 +13150,14 @@ function graphSpecToMermaid(g, opts) {
|
|
|
12539
13150
|
}
|
|
12540
13151
|
|
|
12541
13152
|
// src/utils/reactive-layout/reactive-layout.ts
|
|
12542
|
-
var
|
|
13153
|
+
var import_core64 = require("@graphrefly/pure-ts/core");
|
|
12543
13154
|
var import_graph12 = require("@graphrefly/pure-ts/graph");
|
|
12544
13155
|
|
|
12545
13156
|
// src/base/meta/emit-to-meta.ts
|
|
12546
|
-
var
|
|
13157
|
+
var import_core63 = require("@graphrefly/pure-ts/core");
|
|
12547
13158
|
function emitToMeta(metaNode, value) {
|
|
12548
13159
|
if (metaNode == null) return;
|
|
12549
|
-
(0,
|
|
13160
|
+
(0, import_core63.downWithBatch)((msgs) => metaNode.down(msgs), [[import_core63.DATA, value]], import_core63.defaultConfig.tierOf);
|
|
12550
13161
|
}
|
|
12551
13162
|
|
|
12552
13163
|
// src/utils/reactive-layout/reactive-layout.ts
|
|
@@ -13247,16 +13858,16 @@ function reactiveLayout(opts) {
|
|
|
13247
13858
|
const { adapter, name = "reactive-layout" } = opts;
|
|
13248
13859
|
const g = new import_graph12.Graph(name);
|
|
13249
13860
|
const measureCache = /* @__PURE__ */ new Map();
|
|
13250
|
-
const textNode = (0,
|
|
13251
|
-
const fontNode = (0,
|
|
13861
|
+
const textNode = (0, import_core64.node)([], { name: "text", initial: opts.text ?? "" });
|
|
13862
|
+
const fontNode = (0, import_core64.node)([], {
|
|
13252
13863
|
name: "font",
|
|
13253
13864
|
initial: opts.font ?? "16px sans-serif"
|
|
13254
13865
|
});
|
|
13255
|
-
const lineHeightNode = (0,
|
|
13866
|
+
const lineHeightNode = (0, import_core64.node)([], {
|
|
13256
13867
|
name: "line-height",
|
|
13257
13868
|
initial: opts.lineHeight ?? 20
|
|
13258
13869
|
});
|
|
13259
|
-
const maxWidthNode = (0,
|
|
13870
|
+
const maxWidthNode = (0, import_core64.node)([], {
|
|
13260
13871
|
name: "max-width",
|
|
13261
13872
|
initial: Math.max(0, opts.maxWidth ?? 800)
|
|
13262
13873
|
});
|
|
@@ -13268,14 +13879,14 @@ function reactiveLayout(opts) {
|
|
|
13268
13879
|
}
|
|
13269
13880
|
return true;
|
|
13270
13881
|
}
|
|
13271
|
-
const segmentsNode = (0,
|
|
13882
|
+
const segmentsNode = (0, import_core64.node)(
|
|
13272
13883
|
[textNode, fontNode],
|
|
13273
13884
|
(data, actions, ctx) => {
|
|
13274
13885
|
const b0 = data[0];
|
|
13275
13886
|
const textVal = b0 != null && b0.length > 0 ? b0.at(-1) : ctx.prevData[0];
|
|
13276
13887
|
const b1 = data[1];
|
|
13277
13888
|
const fontVal = b1 != null && b1.length > 0 ? b1.at(-1) : ctx.prevData[1];
|
|
13278
|
-
const t0 = (0,
|
|
13889
|
+
const t0 = (0, import_core64.monotonicNs)();
|
|
13279
13890
|
const measureStats = { hits: 0, misses: 0 };
|
|
13280
13891
|
const result = analyzeAndMeasure(
|
|
13281
13892
|
textVal,
|
|
@@ -13284,7 +13895,7 @@ function reactiveLayout(opts) {
|
|
|
13284
13895
|
measureCache,
|
|
13285
13896
|
measureStats
|
|
13286
13897
|
);
|
|
13287
|
-
const elapsed = (0,
|
|
13898
|
+
const elapsed = (0, import_core64.monotonicNs)() - t0;
|
|
13288
13899
|
const lookups = measureStats.hits + measureStats.misses;
|
|
13289
13900
|
const hitRate = lookups === 0 ? 1 : measureStats.hits / lookups;
|
|
13290
13901
|
const meta2 = segmentsNode.meta;
|
|
@@ -13323,7 +13934,7 @@ function reactiveLayout(opts) {
|
|
|
13323
13934
|
}
|
|
13324
13935
|
}
|
|
13325
13936
|
);
|
|
13326
|
-
const lineBreaksNode = (0,
|
|
13937
|
+
const lineBreaksNode = (0, import_core64.node)(
|
|
13327
13938
|
[segmentsNode, maxWidthNode, fontNode],
|
|
13328
13939
|
(batchData, actions, ctx) => {
|
|
13329
13940
|
const data = batchData.map(
|
|
@@ -13357,7 +13968,7 @@ function reactiveLayout(opts) {
|
|
|
13357
13968
|
}
|
|
13358
13969
|
}
|
|
13359
13970
|
);
|
|
13360
|
-
const heightNode = (0,
|
|
13971
|
+
const heightNode = (0, import_core64.node)(
|
|
13361
13972
|
[lineBreaksNode, lineHeightNode],
|
|
13362
13973
|
(batchData, actions, ctx) => {
|
|
13363
13974
|
const data = batchData.map(
|
|
@@ -13367,7 +13978,7 @@ function reactiveLayout(opts) {
|
|
|
13367
13978
|
},
|
|
13368
13979
|
{ describeKind: "derived", name: "height" }
|
|
13369
13980
|
);
|
|
13370
|
-
const charPositionsNode = (0,
|
|
13981
|
+
const charPositionsNode = (0, import_core64.node)(
|
|
13371
13982
|
[lineBreaksNode, segmentsNode, lineHeightNode],
|
|
13372
13983
|
(batchData, actions, ctx) => {
|
|
13373
13984
|
const data = batchData.map(
|
|
@@ -13419,32 +14030,32 @@ function reactiveLayout(opts) {
|
|
|
13419
14030
|
}
|
|
13420
14031
|
|
|
13421
14032
|
// src/utils/demo-shell/index.ts
|
|
13422
|
-
function
|
|
14033
|
+
function clamp012(v) {
|
|
13423
14034
|
return Math.max(0, Math.min(1, v));
|
|
13424
14035
|
}
|
|
13425
14036
|
function demoShell(opts) {
|
|
13426
|
-
const mainRatioInit =
|
|
13427
|
-
const sideSplitInit =
|
|
14037
|
+
const mainRatioInit = clamp012(opts?.mainRatio ?? 0.65);
|
|
14038
|
+
const sideSplitInit = clamp012(opts?.sideSplit ?? 0.5);
|
|
13428
14039
|
const viewportInit = Math.max(0, opts?.viewportWidth ?? 1280);
|
|
13429
14040
|
const registry = opts?.nodeRegistry ?? /* @__PURE__ */ new Map();
|
|
13430
14041
|
const adapter = opts?.adapter ?? null;
|
|
13431
14042
|
const layoutFont = opts?.layoutFont ?? "14px monospace";
|
|
13432
14043
|
const onHighlight = opts?.onHighlight;
|
|
13433
14044
|
const g = new import_graph13.Graph("demo-shell");
|
|
13434
|
-
const paneMainRatio = (0,
|
|
13435
|
-
const paneSideSplit = (0,
|
|
13436
|
-
const paneFullscreen = (0,
|
|
14045
|
+
const paneMainRatio = (0, import_core65.node)([], { ...{ name: "pane/main-ratio" }, initial: mainRatioInit });
|
|
14046
|
+
const paneSideSplit = (0, import_core65.node)([], { ...{ name: "pane/side-split" }, initial: sideSplitInit });
|
|
14047
|
+
const paneFullscreen = (0, import_core65.node)([], {
|
|
13437
14048
|
...{
|
|
13438
14049
|
name: "pane/fullscreen"
|
|
13439
14050
|
},
|
|
13440
14051
|
initial: null
|
|
13441
14052
|
});
|
|
13442
|
-
const viewportWidth = (0,
|
|
14053
|
+
const viewportWidth = (0, import_core65.node)([], { ...{ name: "viewport/width" }, initial: viewportInit });
|
|
13443
14054
|
g.add(paneMainRatio, { name: "pane/main-ratio" });
|
|
13444
14055
|
g.add(paneSideSplit, { name: "pane/side-split" });
|
|
13445
14056
|
g.add(paneFullscreen, { name: "pane/fullscreen" });
|
|
13446
14057
|
g.add(viewportWidth, { name: "viewport/width" });
|
|
13447
|
-
const paneMainWidth = (0,
|
|
14058
|
+
const paneMainWidth = (0, import_core65.node)(
|
|
13448
14059
|
[paneMainRatio, viewportWidth, paneFullscreen],
|
|
13449
14060
|
(batchData, actions, ctx) => {
|
|
13450
14061
|
const data = batchData.map(
|
|
@@ -13459,7 +14070,7 @@ function demoShell(opts) {
|
|
|
13459
14070
|
},
|
|
13460
14071
|
{ describeKind: "derived", ...{ name: "pane/main-width" } }
|
|
13461
14072
|
);
|
|
13462
|
-
const paneSideWidth = (0,
|
|
14073
|
+
const paneSideWidth = (0, import_core65.node)(
|
|
13463
14074
|
[paneMainWidth, viewportWidth, paneFullscreen],
|
|
13464
14075
|
(batchData, actions, ctx) => {
|
|
13465
14076
|
const data = batchData.map(
|
|
@@ -13474,7 +14085,7 @@ function demoShell(opts) {
|
|
|
13474
14085
|
},
|
|
13475
14086
|
{ describeKind: "derived", ...{ name: "pane/side-width" } }
|
|
13476
14087
|
);
|
|
13477
|
-
const paneGraphHeight = (0,
|
|
14088
|
+
const paneGraphHeight = (0, import_core65.node)(
|
|
13478
14089
|
[paneSideSplit, paneFullscreen],
|
|
13479
14090
|
(batchData, actions, ctx) => {
|
|
13480
14091
|
const data = batchData.map(
|
|
@@ -13485,11 +14096,11 @@ function demoShell(opts) {
|
|
|
13485
14096
|
if (fullscreen === "graph") actions.emit(1);
|
|
13486
14097
|
else if (fullscreen === "code") actions.emit(0);
|
|
13487
14098
|
else if (fullscreen === "main") actions.emit(0);
|
|
13488
|
-
else actions.emit(
|
|
14099
|
+
else actions.emit(clamp012(split));
|
|
13489
14100
|
},
|
|
13490
14101
|
{ describeKind: "derived", ...{ name: "pane/graph-height-ratio" } }
|
|
13491
14102
|
);
|
|
13492
|
-
const paneCodeHeight = (0,
|
|
14103
|
+
const paneCodeHeight = (0, import_core65.node)(
|
|
13493
14104
|
[paneGraphHeight, paneFullscreen],
|
|
13494
14105
|
(batchData, actions, ctx) => {
|
|
13495
14106
|
const data = batchData.map(
|
|
@@ -13507,16 +14118,16 @@ function demoShell(opts) {
|
|
|
13507
14118
|
g.add(paneSideWidth, { name: "pane/side-width" });
|
|
13508
14119
|
g.add(paneGraphHeight, { name: "pane/graph-height-ratio" });
|
|
13509
14120
|
g.add(paneCodeHeight, { name: "pane/code-height-ratio" });
|
|
13510
|
-
const demoGraphRef = (0,
|
|
14121
|
+
const demoGraphRef = (0, import_core65.node)([], {
|
|
13511
14122
|
...{
|
|
13512
14123
|
name: "demo/graph-ref"
|
|
13513
14124
|
},
|
|
13514
14125
|
initial: null
|
|
13515
14126
|
});
|
|
13516
|
-
const demoGraphTick = (0,
|
|
14127
|
+
const demoGraphTick = (0, import_core65.node)([], { ...{ name: "demo/graph-tick" }, initial: 0 });
|
|
13517
14128
|
g.add(demoGraphRef, { name: "demo/graph-ref" });
|
|
13518
14129
|
g.add(demoGraphTick, { name: "demo/graph-tick" });
|
|
13519
|
-
const graphMermaid = (0,
|
|
14130
|
+
const graphMermaid = (0, import_core65.node)(
|
|
13520
14131
|
[demoGraphRef, demoGraphTick],
|
|
13521
14132
|
(batchData, actions, ctx) => {
|
|
13522
14133
|
const data = batchData.map(
|
|
@@ -13527,7 +14138,7 @@ function demoShell(opts) {
|
|
|
13527
14138
|
},
|
|
13528
14139
|
{ describeKind: "derived", ...{ name: "graph/mermaid" } }
|
|
13529
14140
|
);
|
|
13530
|
-
const graphDescribe = (0,
|
|
14141
|
+
const graphDescribe = (0, import_core65.node)(
|
|
13531
14142
|
[demoGraphRef, demoGraphTick],
|
|
13532
14143
|
(batchData, actions, ctx) => {
|
|
13533
14144
|
const data = batchData.map(
|
|
@@ -13545,9 +14156,9 @@ function demoShell(opts) {
|
|
|
13545
14156
|
);
|
|
13546
14157
|
g.add(graphMermaid, { name: "graph/mermaid" });
|
|
13547
14158
|
g.add(graphDescribe, { name: "graph/describe" });
|
|
13548
|
-
const hoverTarget = (0,
|
|
14159
|
+
const hoverTarget = (0, import_core65.node)([], { ...{ name: "hover/target" }, initial: null });
|
|
13549
14160
|
g.add(hoverTarget, { name: "hover/target" });
|
|
13550
|
-
const highlightCodeScroll = (0,
|
|
14161
|
+
const highlightCodeScroll = (0, import_core65.node)(
|
|
13551
14162
|
[hoverTarget],
|
|
13552
14163
|
(batchData, actions, ctx) => {
|
|
13553
14164
|
const data = batchData.map(
|
|
@@ -13563,7 +14174,7 @@ function demoShell(opts) {
|
|
|
13563
14174
|
},
|
|
13564
14175
|
{ describeKind: "derived", ...{ name: "highlight/code-scroll" } }
|
|
13565
14176
|
);
|
|
13566
|
-
const highlightVisual = (0,
|
|
14177
|
+
const highlightVisual = (0, import_core65.node)(
|
|
13567
14178
|
[hoverTarget],
|
|
13568
14179
|
(batchData, actions, ctx) => {
|
|
13569
14180
|
const data = batchData.map(
|
|
@@ -13579,7 +14190,7 @@ function demoShell(opts) {
|
|
|
13579
14190
|
},
|
|
13580
14191
|
{ describeKind: "derived", ...{ name: "highlight/visual" } }
|
|
13581
14192
|
);
|
|
13582
|
-
const highlightGraph = (0,
|
|
14193
|
+
const highlightGraph = (0, import_core65.node)(
|
|
13583
14194
|
[hoverTarget],
|
|
13584
14195
|
(batchData, actions, ctx) => {
|
|
13585
14196
|
const data = batchData.map(
|
|
@@ -13595,7 +14206,7 @@ function demoShell(opts) {
|
|
|
13595
14206
|
g.add(highlightGraph, { name: "highlight/graph" });
|
|
13596
14207
|
if (onHighlight?.codeScroll) {
|
|
13597
14208
|
const cb = onHighlight.codeScroll;
|
|
13598
|
-
const applyCodeScroll = (0,
|
|
14209
|
+
const applyCodeScroll = (0, import_core65.node)(
|
|
13599
14210
|
[highlightCodeScroll],
|
|
13600
14211
|
(batchData, _actions, ctx) => {
|
|
13601
14212
|
const data = batchData.map(
|
|
@@ -13609,7 +14220,7 @@ function demoShell(opts) {
|
|
|
13609
14220
|
}
|
|
13610
14221
|
if (onHighlight?.visual) {
|
|
13611
14222
|
const cb = onHighlight.visual;
|
|
13612
|
-
const applyVisual = (0,
|
|
14223
|
+
const applyVisual = (0, import_core65.node)(
|
|
13613
14224
|
[highlightVisual],
|
|
13614
14225
|
(batchData, _actions, ctx) => {
|
|
13615
14226
|
const data = batchData.map(
|
|
@@ -13623,7 +14234,7 @@ function demoShell(opts) {
|
|
|
13623
14234
|
}
|
|
13624
14235
|
if (onHighlight?.graph) {
|
|
13625
14236
|
const cb = onHighlight.graph;
|
|
13626
|
-
const applyGraph = (0,
|
|
14237
|
+
const applyGraph = (0, import_core65.node)(
|
|
13627
14238
|
[highlightGraph],
|
|
13628
14239
|
(batchData, _actions, ctx) => {
|
|
13629
14240
|
const data = batchData.map(
|
|
@@ -13635,14 +14246,14 @@ function demoShell(opts) {
|
|
|
13635
14246
|
);
|
|
13636
14247
|
g.add(applyGraph, { name: "highlight/apply-graph" });
|
|
13637
14248
|
}
|
|
13638
|
-
const inspectSelected = (0,
|
|
14249
|
+
const inspectSelected = (0, import_core65.node)([], {
|
|
13639
14250
|
...{
|
|
13640
14251
|
name: "inspect/selected-node"
|
|
13641
14252
|
},
|
|
13642
14253
|
initial: null
|
|
13643
14254
|
});
|
|
13644
14255
|
g.add(inspectSelected, { name: "inspect/selected-node" });
|
|
13645
|
-
const inspectNodeDetail = (0,
|
|
14256
|
+
const inspectNodeDetail = (0, import_core65.node)(
|
|
13646
14257
|
[inspectSelected, demoGraphRef, demoGraphTick],
|
|
13647
14258
|
(batchData, actions, ctx) => {
|
|
13648
14259
|
const data = batchData.map(
|
|
@@ -13668,7 +14279,7 @@ function demoShell(opts) {
|
|
|
13668
14279
|
},
|
|
13669
14280
|
{ describeKind: "derived", ...{ name: "inspect/node-detail" } }
|
|
13670
14281
|
);
|
|
13671
|
-
const inspectTraceLog = (0,
|
|
14282
|
+
const inspectTraceLog = (0, import_core65.node)(
|
|
13672
14283
|
[demoGraphRef, demoGraphTick],
|
|
13673
14284
|
(batchData, actions, ctx) => {
|
|
13674
14285
|
const data = batchData.map(
|
|
@@ -13681,9 +14292,9 @@ function demoShell(opts) {
|
|
|
13681
14292
|
);
|
|
13682
14293
|
g.add(inspectNodeDetail, { name: "inspect/node-detail" });
|
|
13683
14294
|
g.add(inspectTraceLog, { name: "inspect/trace-log" });
|
|
13684
|
-
const metaDebug = (0,
|
|
14295
|
+
const metaDebug = (0, import_core65.node)([], { ...{ name: "meta/debug" }, initial: false });
|
|
13685
14296
|
g.add(metaDebug, { name: "meta/debug" });
|
|
13686
|
-
const metaShellMermaid = (0,
|
|
14297
|
+
const metaShellMermaid = (0, import_core65.node)(
|
|
13687
14298
|
[metaDebug, demoGraphTick],
|
|
13688
14299
|
(batchData, actions, ctx) => {
|
|
13689
14300
|
const data = batchData.map(
|
|
@@ -13694,11 +14305,11 @@ function demoShell(opts) {
|
|
|
13694
14305
|
{ describeKind: "derived", ...{ name: "meta/shell-mermaid" } }
|
|
13695
14306
|
);
|
|
13696
14307
|
g.add(metaShellMermaid, { name: "meta/shell-mermaid" });
|
|
13697
|
-
const codeTextNode = (0,
|
|
14308
|
+
const codeTextNode = (0, import_core65.node)([], { ...{ name: "layout/code-text" }, initial: "" });
|
|
13698
14309
|
g.add(codeTextNode, { name: "layout/code-text" });
|
|
13699
14310
|
if (adapter) {
|
|
13700
14311
|
const measureCache = /* @__PURE__ */ new Map();
|
|
13701
|
-
const graphLabels = (0,
|
|
14312
|
+
const graphLabels = (0, import_core65.node)(
|
|
13702
14313
|
[graphDescribe],
|
|
13703
14314
|
(batchData, actions, ctx) => {
|
|
13704
14315
|
const data = batchData.map(
|
|
@@ -13737,7 +14348,7 @@ function demoShell(opts) {
|
|
|
13737
14348
|
}
|
|
13738
14349
|
}
|
|
13739
14350
|
);
|
|
13740
|
-
const codeLines = (0,
|
|
14351
|
+
const codeLines = (0, import_core65.node)(
|
|
13741
14352
|
[codeTextNode, paneSideWidth],
|
|
13742
14353
|
(batchData, actions, ctx) => {
|
|
13743
14354
|
const data = batchData.map(
|
|
@@ -13756,7 +14367,7 @@ function demoShell(opts) {
|
|
|
13756
14367
|
},
|
|
13757
14368
|
{ describeKind: "derived", name: "layout/code-lines" }
|
|
13758
14369
|
);
|
|
13759
|
-
const sideWidthHint = (0,
|
|
14370
|
+
const sideWidthHint = (0, import_core65.node)(
|
|
13760
14371
|
[graphLabels],
|
|
13761
14372
|
(batchData, actions, ctx) => {
|
|
13762
14373
|
const data = batchData.map(
|
|
@@ -13783,10 +14394,10 @@ function demoShell(opts) {
|
|
|
13783
14394
|
return {
|
|
13784
14395
|
graph: g,
|
|
13785
14396
|
setMainRatio(ratio) {
|
|
13786
|
-
g.set("pane/main-ratio",
|
|
14397
|
+
g.set("pane/main-ratio", clamp012(ratio));
|
|
13787
14398
|
},
|
|
13788
14399
|
setSideSplit(ratio) {
|
|
13789
|
-
g.set("pane/side-split",
|
|
14400
|
+
g.set("pane/side-split", clamp012(ratio));
|
|
13790
14401
|
},
|
|
13791
14402
|
setFullscreen(pane) {
|
|
13792
14403
|
g.set("pane/fullscreen", pane);
|
|
@@ -13813,7 +14424,7 @@ function demoShell(opts) {
|
|
|
13813
14424
|
g.set("layout/code-text", text);
|
|
13814
14425
|
},
|
|
13815
14426
|
batch(fn) {
|
|
13816
|
-
(0,
|
|
14427
|
+
(0, import_core65.batch)(fn);
|
|
13817
14428
|
},
|
|
13818
14429
|
destroy() {
|
|
13819
14430
|
g.destroy();
|
|
@@ -13822,10 +14433,10 @@ function demoShell(opts) {
|
|
|
13822
14433
|
}
|
|
13823
14434
|
|
|
13824
14435
|
// src/utils/domain-templates/index.ts
|
|
13825
|
-
var
|
|
13826
|
-
var
|
|
14436
|
+
var import_core66 = require("@graphrefly/pure-ts/core");
|
|
14437
|
+
var import_extra47 = require("@graphrefly/pure-ts/extra");
|
|
13827
14438
|
var import_graph14 = require("@graphrefly/pure-ts/graph");
|
|
13828
|
-
var
|
|
14439
|
+
var import_extra48 = require("@graphrefly/pure-ts/extra");
|
|
13829
14440
|
function baseMeta2(kind, extra) {
|
|
13830
14441
|
return domainMeta("domain_template", kind, extra);
|
|
13831
14442
|
}
|
|
@@ -13842,12 +14453,12 @@ function observabilityGraph(name, opts) {
|
|
|
13842
14453
|
name: b.name,
|
|
13843
14454
|
classify: b.classify
|
|
13844
14455
|
}));
|
|
13845
|
-
const strat = (0,
|
|
14456
|
+
const strat = (0, import_extra47.stratify)("stratify", opts.source, rules);
|
|
13846
14457
|
g.mount("stratify", strat);
|
|
13847
14458
|
const branchNodes = branches.map((b) => {
|
|
13848
14459
|
try {
|
|
13849
14460
|
const raw = g.resolve(`stratify::branch/${b.name}`);
|
|
13850
|
-
return (0,
|
|
14461
|
+
return (0, import_core66.node)(
|
|
13851
14462
|
[raw],
|
|
13852
14463
|
(batchData, actions, ctx) => {
|
|
13853
14464
|
const data = batchData.map(
|
|
@@ -13858,11 +14469,11 @@ function observabilityGraph(name, opts) {
|
|
|
13858
14469
|
{ initial: null, describeKind: "derived" }
|
|
13859
14470
|
);
|
|
13860
14471
|
} catch {
|
|
13861
|
-
return (0,
|
|
14472
|
+
return (0, import_core66.node)([], { initial: null });
|
|
13862
14473
|
}
|
|
13863
14474
|
});
|
|
13864
14475
|
const correlateFn = opts.correlate ?? ((vals) => vals);
|
|
13865
|
-
const correlateNode = (0,
|
|
14476
|
+
const correlateNode = (0, import_core66.node)(
|
|
13866
14477
|
branchNodes,
|
|
13867
14478
|
(batchData, actions, ctx) => {
|
|
13868
14479
|
const vals = batchData.map(
|
|
@@ -13877,7 +14488,7 @@ function observabilityGraph(name, opts) {
|
|
|
13877
14488
|
);
|
|
13878
14489
|
g.add(correlateNode, { name: "correlate" });
|
|
13879
14490
|
const sloCheckFn = opts.sloCheck ?? (() => ({ pass: true }));
|
|
13880
|
-
const sloValue = (0,
|
|
14491
|
+
const sloValue = (0, import_core66.node)(
|
|
13881
14492
|
[correlateNode],
|
|
13882
14493
|
(batchData, actions, ctx) => {
|
|
13883
14494
|
const data = batchData.map(
|
|
@@ -13890,7 +14501,7 @@ function observabilityGraph(name, opts) {
|
|
|
13890
14501
|
meta: baseMeta2("observability", { stage: "slo_value" })
|
|
13891
14502
|
}
|
|
13892
14503
|
);
|
|
13893
|
-
const sloVerified = (0,
|
|
14504
|
+
const sloVerified = (0, import_core66.node)(
|
|
13894
14505
|
[sloValue],
|
|
13895
14506
|
(batchData, actions, ctx) => {
|
|
13896
14507
|
const data = batchData.map(
|
|
@@ -13907,7 +14518,7 @@ function observabilityGraph(name, opts) {
|
|
|
13907
14518
|
g.add(sloVerified, { name: "slo_verified" });
|
|
13908
14519
|
const weightValues = opts.weights ?? branches.map(() => 1);
|
|
13909
14520
|
const signalNodes = branchNodes.map(
|
|
13910
|
-
(bn) => (0,
|
|
14521
|
+
(bn) => (0, import_core66.node)(
|
|
13911
14522
|
[bn],
|
|
13912
14523
|
(batchData, actions, ctx) => {
|
|
13913
14524
|
const data = batchData.map(
|
|
@@ -13918,7 +14529,7 @@ function observabilityGraph(name, opts) {
|
|
|
13918
14529
|
{ describeKind: "derived" }
|
|
13919
14530
|
)
|
|
13920
14531
|
);
|
|
13921
|
-
const weightNodes = weightValues.map((w) => (0,
|
|
14532
|
+
const weightNodes = weightValues.map((w) => (0, import_core66.node)([], { initial: w }));
|
|
13922
14533
|
for (let i = 0; i < signalNodes.length; i++) {
|
|
13923
14534
|
g.add(signalNodes[i], { name: `__signal_${i}` });
|
|
13924
14535
|
g.add(weightNodes[i], { name: `__weight_${i}` });
|
|
@@ -13928,7 +14539,7 @@ function observabilityGraph(name, opts) {
|
|
|
13928
14539
|
weightNodes
|
|
13929
14540
|
);
|
|
13930
14541
|
g.add(alerts, { name: "alerts" });
|
|
13931
|
-
const output = (0,
|
|
14542
|
+
const output = (0, import_core66.node)(
|
|
13932
14543
|
[alerts, sloVerified],
|
|
13933
14544
|
(batchData, actions, ctx) => {
|
|
13934
14545
|
const vals = batchData.map(
|
|
@@ -13945,12 +14556,12 @@ function observabilityGraph(name, opts) {
|
|
|
13945
14556
|
}
|
|
13946
14557
|
);
|
|
13947
14558
|
g.add(output, { name: "output" });
|
|
13948
|
-
const fbReentry = (0,
|
|
14559
|
+
const fbReentry = (0, import_core66.node)([], {
|
|
13949
14560
|
initial: null,
|
|
13950
14561
|
meta: baseMeta2("observability", { stage: "feedback_reentry" })
|
|
13951
14562
|
});
|
|
13952
14563
|
g.add(fbReentry, { name: "feedback_reentry" });
|
|
13953
|
-
const fbCondition = (0,
|
|
14564
|
+
const fbCondition = (0, import_core66.node)(
|
|
13954
14565
|
[sloVerified],
|
|
13955
14566
|
(batchData, actions, ctx) => {
|
|
13956
14567
|
const data = batchData.map(
|
|
@@ -13982,7 +14593,7 @@ function issueTrackerGraph(name, opts) {
|
|
|
13982
14593
|
raw
|
|
13983
14594
|
});
|
|
13984
14595
|
const extractFn = opts.extract ?? defaultExtract;
|
|
13985
|
-
const extractNode = (0,
|
|
14596
|
+
const extractNode = (0, import_core66.node)(
|
|
13986
14597
|
[opts.source],
|
|
13987
14598
|
(batchData, actions, ctx) => {
|
|
13988
14599
|
const data = batchData.map(
|
|
@@ -13997,7 +14608,7 @@ function issueTrackerGraph(name, opts) {
|
|
|
13997
14608
|
);
|
|
13998
14609
|
g.add(extractNode, { name: "extract" });
|
|
13999
14610
|
const verifyFn = opts.verify ?? (() => ({ valid: true }));
|
|
14000
|
-
const verifyNode = (0,
|
|
14611
|
+
const verifyNode = (0, import_core66.node)(
|
|
14001
14612
|
[extractNode],
|
|
14002
14613
|
(batchData, actions, ctx) => {
|
|
14003
14614
|
const data = batchData.map(
|
|
@@ -14012,13 +14623,13 @@ function issueTrackerGraph(name, opts) {
|
|
|
14012
14623
|
}
|
|
14013
14624
|
);
|
|
14014
14625
|
g.add(verifyNode, { name: "verify" });
|
|
14015
|
-
const knownPatterns = (0,
|
|
14626
|
+
const knownPatterns = (0, import_core66.node)([], {
|
|
14016
14627
|
initial: [],
|
|
14017
14628
|
meta: baseMeta2("issue_tracker", { stage: "known_patterns" })
|
|
14018
14629
|
});
|
|
14019
14630
|
g.add(knownPatterns, { name: "known_patterns" });
|
|
14020
14631
|
const detectFn = opts.detectRegression ?? (() => ({ regression: false }));
|
|
14021
|
-
const regressionNode = (0,
|
|
14632
|
+
const regressionNode = (0, import_core66.node)(
|
|
14022
14633
|
[extractNode, knownPatterns],
|
|
14023
14634
|
(batchData, actions, ctx) => {
|
|
14024
14635
|
const data = batchData.map(
|
|
@@ -14031,7 +14642,7 @@ function issueTrackerGraph(name, opts) {
|
|
|
14031
14642
|
{ describeKind: "derived", meta: baseMeta2("issue_tracker", { stage: "regression" }) }
|
|
14032
14643
|
);
|
|
14033
14644
|
g.add(regressionNode, { name: "regression" });
|
|
14034
|
-
const severitySignal = (0,
|
|
14645
|
+
const severitySignal = (0, import_core66.node)(
|
|
14035
14646
|
[extractNode],
|
|
14036
14647
|
(batchData, actions, ctx) => {
|
|
14037
14648
|
const data = batchData.map(
|
|
@@ -14042,7 +14653,7 @@ function issueTrackerGraph(name, opts) {
|
|
|
14042
14653
|
},
|
|
14043
14654
|
{ describeKind: "derived" }
|
|
14044
14655
|
);
|
|
14045
|
-
const regressionSignal = (0,
|
|
14656
|
+
const regressionSignal = (0, import_core66.node)(
|
|
14046
14657
|
[regressionNode],
|
|
14047
14658
|
(batchData, actions, ctx) => {
|
|
14048
14659
|
const data = batchData.map(
|
|
@@ -14055,13 +14666,13 @@ function issueTrackerGraph(name, opts) {
|
|
|
14055
14666
|
);
|
|
14056
14667
|
g.add(severitySignal, { name: "__severity_signal" });
|
|
14057
14668
|
g.add(regressionSignal, { name: "__regression_signal" });
|
|
14058
|
-
const severityWeight = (0,
|
|
14059
|
-
const regressionWeight = (0,
|
|
14669
|
+
const severityWeight = (0, import_core66.node)([], { initial: 1 });
|
|
14670
|
+
const regressionWeight = (0, import_core66.node)([], { initial: 1.5 });
|
|
14060
14671
|
g.add(severityWeight, { name: "__severity_weight" });
|
|
14061
14672
|
g.add(regressionWeight, { name: "__regression_weight" });
|
|
14062
14673
|
const priority = scorer([severitySignal, regressionSignal], [severityWeight, regressionWeight]);
|
|
14063
14674
|
g.add(priority, { name: "priority" });
|
|
14064
|
-
const output = (0,
|
|
14675
|
+
const output = (0, import_core66.node)(
|
|
14065
14676
|
[verifyNode, regressionNode, priority],
|
|
14066
14677
|
(batchData, actions, ctx) => {
|
|
14067
14678
|
const vals = batchData.map(
|
|
@@ -14076,12 +14687,12 @@ function issueTrackerGraph(name, opts) {
|
|
|
14076
14687
|
{ describeKind: "derived", meta: baseMeta2("issue_tracker", { stage: "output" }) }
|
|
14077
14688
|
);
|
|
14078
14689
|
g.add(output, { name: "output" });
|
|
14079
|
-
const fbReentry = (0,
|
|
14690
|
+
const fbReentry = (0, import_core66.node)([], {
|
|
14080
14691
|
initial: null,
|
|
14081
14692
|
meta: baseMeta2("issue_tracker", { stage: "feedback_reentry" })
|
|
14082
14693
|
});
|
|
14083
14694
|
g.add(fbReentry, { name: "feedback_reentry" });
|
|
14084
|
-
const fbCondition = (0,
|
|
14695
|
+
const fbCondition = (0, import_core66.node)(
|
|
14085
14696
|
[verifyNode],
|
|
14086
14697
|
(batchData, actions, ctx) => {
|
|
14087
14698
|
const data = batchData.map(
|
|
@@ -14117,7 +14728,7 @@ function contentModerationGraph(name, opts) {
|
|
|
14117
14728
|
original: content
|
|
14118
14729
|
});
|
|
14119
14730
|
const classifyFn = opts.classify ?? defaultClassify;
|
|
14120
|
-
const classifyNode = (0,
|
|
14731
|
+
const classifyNode = (0, import_core66.node)(
|
|
14121
14732
|
[opts.source],
|
|
14122
14733
|
(batchData, actions, ctx) => {
|
|
14123
14734
|
const data = batchData.map(
|
|
@@ -14131,13 +14742,13 @@ function contentModerationGraph(name, opts) {
|
|
|
14131
14742
|
}
|
|
14132
14743
|
);
|
|
14133
14744
|
g.add(classifyNode, { name: "classify" });
|
|
14134
|
-
const strat = (0,
|
|
14745
|
+
const strat = (0, import_extra47.stratify)("stratify", classifyNode, [
|
|
14135
14746
|
{ name: "safe", classify: (v) => v.label === "safe" },
|
|
14136
14747
|
{ name: "review", classify: (v) => v.label === "review" },
|
|
14137
14748
|
{ name: "block", classify: (v) => v.label === "block" }
|
|
14138
14749
|
]);
|
|
14139
14750
|
g.mount("stratify", strat);
|
|
14140
|
-
const reviewLog = (0,
|
|
14751
|
+
const reviewLog = (0, import_extra47.reactiveLog)([], {
|
|
14141
14752
|
name: "review_queue",
|
|
14142
14753
|
maxSize: opts.maxQueueSize
|
|
14143
14754
|
});
|
|
@@ -14146,10 +14757,10 @@ function contentModerationGraph(name, opts) {
|
|
|
14146
14757
|
try {
|
|
14147
14758
|
reviewBranch = g.resolve("stratify::branch/review");
|
|
14148
14759
|
} catch {
|
|
14149
|
-
reviewBranch = (0,
|
|
14760
|
+
reviewBranch = (0, import_core66.node)([], { initial: null });
|
|
14150
14761
|
g.add(reviewBranch, { name: "__review_fallback" });
|
|
14151
14762
|
}
|
|
14152
|
-
const reviewAccumulator = (0,
|
|
14763
|
+
const reviewAccumulator = (0, import_core66.node)(
|
|
14153
14764
|
[reviewBranch],
|
|
14154
14765
|
(batchData, _actions, ctx) => {
|
|
14155
14766
|
const data = batchData.map(
|
|
@@ -14163,11 +14774,11 @@ function contentModerationGraph(name, opts) {
|
|
|
14163
14774
|
{ describeKind: "effect" }
|
|
14164
14775
|
);
|
|
14165
14776
|
g.add(reviewAccumulator, { name: "__review_accumulator" });
|
|
14166
|
-
g.addDisposer((0,
|
|
14777
|
+
g.addDisposer((0, import_extra48.keepalive)(reviewAccumulator));
|
|
14167
14778
|
try {
|
|
14168
14779
|
} catch {
|
|
14169
14780
|
}
|
|
14170
|
-
const policy3 = (0,
|
|
14781
|
+
const policy3 = (0, import_core66.node)([], {
|
|
14171
14782
|
initial: {},
|
|
14172
14783
|
meta: baseMeta2("content_moderation", {
|
|
14173
14784
|
stage: "policy",
|
|
@@ -14177,7 +14788,7 @@ function contentModerationGraph(name, opts) {
|
|
|
14177
14788
|
});
|
|
14178
14789
|
g.add(policy3, { name: "policy" });
|
|
14179
14790
|
const weights = opts.weights ?? [0.1, 1, 2];
|
|
14180
|
-
const confidenceSignal = (0,
|
|
14791
|
+
const confidenceSignal = (0, import_core66.node)(
|
|
14181
14792
|
[classifyNode],
|
|
14182
14793
|
(batchData, actions, ctx) => {
|
|
14183
14794
|
const data = batchData.map(
|
|
@@ -14188,7 +14799,7 @@ function contentModerationGraph(name, opts) {
|
|
|
14188
14799
|
},
|
|
14189
14800
|
{ describeKind: "derived" }
|
|
14190
14801
|
);
|
|
14191
|
-
const severitySignal = (0,
|
|
14802
|
+
const severitySignal = (0, import_core66.node)(
|
|
14192
14803
|
[classifyNode],
|
|
14193
14804
|
(batchData, actions, ctx) => {
|
|
14194
14805
|
const data = batchData.map(
|
|
@@ -14207,13 +14818,13 @@ function contentModerationGraph(name, opts) {
|
|
|
14207
14818
|
);
|
|
14208
14819
|
g.add(confidenceSignal, { name: "__confidence_signal" });
|
|
14209
14820
|
g.add(severitySignal, { name: "__severity_signal" });
|
|
14210
|
-
const wConfidence = (0,
|
|
14211
|
-
const wSeverity = (0,
|
|
14821
|
+
const wConfidence = (0, import_core66.node)([], { initial: 1 });
|
|
14822
|
+
const wSeverity = (0, import_core66.node)([], { initial: 1 });
|
|
14212
14823
|
g.add(wConfidence, { name: "__w_confidence" });
|
|
14213
14824
|
g.add(wSeverity, { name: "__w_severity" });
|
|
14214
14825
|
const priority = scorer([confidenceSignal, severitySignal], [wConfidence, wSeverity]);
|
|
14215
14826
|
g.add(priority, { name: "priority" });
|
|
14216
|
-
const output = (0,
|
|
14827
|
+
const output = (0, import_core66.node)(
|
|
14217
14828
|
[classifyNode, priority],
|
|
14218
14829
|
(batchData, actions, ctx) => {
|
|
14219
14830
|
const vals = batchData.map(
|
|
@@ -14227,7 +14838,7 @@ function contentModerationGraph(name, opts) {
|
|
|
14227
14838
|
{ describeKind: "derived", meta: baseMeta2("content_moderation", { stage: "output" }) }
|
|
14228
14839
|
);
|
|
14229
14840
|
g.add(output, { name: "output" });
|
|
14230
|
-
const fbCondition = (0,
|
|
14841
|
+
const fbCondition = (0, import_core66.node)(
|
|
14231
14842
|
[reviewLog.entries, policy3],
|
|
14232
14843
|
(batchData, actions, ctx) => {
|
|
14233
14844
|
const vals = batchData.map(
|
|
@@ -14262,7 +14873,7 @@ function dataQualityGraph(name, opts) {
|
|
|
14262
14873
|
errors: [],
|
|
14263
14874
|
record
|
|
14264
14875
|
}));
|
|
14265
|
-
const validateNode = (0,
|
|
14876
|
+
const validateNode = (0, import_core66.node)(
|
|
14266
14877
|
[opts.source],
|
|
14267
14878
|
(batchData, actions, ctx) => {
|
|
14268
14879
|
const data = batchData.map(
|
|
@@ -14278,7 +14889,7 @@ function dataQualityGraph(name, opts) {
|
|
|
14278
14889
|
score: 0,
|
|
14279
14890
|
record
|
|
14280
14891
|
}));
|
|
14281
|
-
const anomalyNode = (0,
|
|
14892
|
+
const anomalyNode = (0, import_core66.node)(
|
|
14282
14893
|
[opts.source],
|
|
14283
14894
|
(batchData, actions, ctx) => {
|
|
14284
14895
|
const data = batchData.map(
|
|
@@ -14289,7 +14900,7 @@ function dataQualityGraph(name, opts) {
|
|
|
14289
14900
|
{ describeKind: "derived", meta: baseMeta2("data_quality", { stage: "anomaly" }) }
|
|
14290
14901
|
);
|
|
14291
14902
|
g.add(anomalyNode, { name: "anomaly" });
|
|
14292
|
-
const baseline = (0,
|
|
14903
|
+
const baseline = (0, import_core66.node)([], {
|
|
14293
14904
|
initial: null,
|
|
14294
14905
|
meta: baseMeta2("data_quality", {
|
|
14295
14906
|
stage: "baseline",
|
|
@@ -14297,7 +14908,7 @@ function dataQualityGraph(name, opts) {
|
|
|
14297
14908
|
})
|
|
14298
14909
|
});
|
|
14299
14910
|
g.add(baseline, { name: "baseline" });
|
|
14300
|
-
const baselineUpdater = (0,
|
|
14911
|
+
const baselineUpdater = (0, import_core66.node)(
|
|
14301
14912
|
[validateNode],
|
|
14302
14913
|
(batchData, _actions, ctx) => {
|
|
14303
14914
|
const data = batchData.map(
|
|
@@ -14305,7 +14916,7 @@ function dataQualityGraph(name, opts) {
|
|
|
14305
14916
|
);
|
|
14306
14917
|
const result = data[0];
|
|
14307
14918
|
if (result?.valid) {
|
|
14308
|
-
(0,
|
|
14919
|
+
(0, import_core66.batch)(() => {
|
|
14309
14920
|
baseline.emit(result.record);
|
|
14310
14921
|
});
|
|
14311
14922
|
}
|
|
@@ -14313,9 +14924,9 @@ function dataQualityGraph(name, opts) {
|
|
|
14313
14924
|
{ describeKind: "effect" }
|
|
14314
14925
|
);
|
|
14315
14926
|
g.add(baselineUpdater, { name: "__baseline_updater" });
|
|
14316
|
-
(0,
|
|
14927
|
+
(0, import_extra48.keepalive)(baselineUpdater);
|
|
14317
14928
|
const detectDriftFn = opts.detectDrift ?? (() => ({ drift: false }));
|
|
14318
|
-
const driftNode = (0,
|
|
14929
|
+
const driftNode = (0, import_core66.node)(
|
|
14319
14930
|
[opts.source, baseline],
|
|
14320
14931
|
(batchData, actions, ctx) => {
|
|
14321
14932
|
const data = batchData.map(
|
|
@@ -14327,7 +14938,7 @@ function dataQualityGraph(name, opts) {
|
|
|
14327
14938
|
);
|
|
14328
14939
|
g.add(driftNode, { name: "drift" });
|
|
14329
14940
|
const suggestFn = opts.suggest ?? (() => null);
|
|
14330
|
-
const remediateNode = (0,
|
|
14941
|
+
const remediateNode = (0, import_core66.node)(
|
|
14331
14942
|
[validateNode, anomalyNode],
|
|
14332
14943
|
(batchData, actions, ctx) => {
|
|
14333
14944
|
const data = batchData.map(
|
|
@@ -14343,7 +14954,7 @@ function dataQualityGraph(name, opts) {
|
|
|
14343
14954
|
{ describeKind: "derived", meta: baseMeta2("data_quality", { stage: "remediate" }) }
|
|
14344
14955
|
);
|
|
14345
14956
|
g.add(remediateNode, { name: "remediate" });
|
|
14346
|
-
const output = (0,
|
|
14957
|
+
const output = (0, import_core66.node)(
|
|
14347
14958
|
[validateNode, anomalyNode, driftNode, remediateNode],
|
|
14348
14959
|
(batchData, actions, ctx) => {
|
|
14349
14960
|
const vals = batchData.map(
|
|
@@ -14359,12 +14970,12 @@ function dataQualityGraph(name, opts) {
|
|
|
14359
14970
|
{ describeKind: "derived", meta: baseMeta2("data_quality", { stage: "output" }) }
|
|
14360
14971
|
);
|
|
14361
14972
|
g.add(output, { name: "output" });
|
|
14362
|
-
const validationRules = (0,
|
|
14973
|
+
const validationRules = (0, import_core66.node)([], {
|
|
14363
14974
|
initial: [],
|
|
14364
14975
|
meta: baseMeta2("data_quality", { stage: "validation_rules" })
|
|
14365
14976
|
});
|
|
14366
14977
|
g.add(validationRules, { name: "validation_rules" });
|
|
14367
|
-
const fbCondition = (0,
|
|
14978
|
+
const fbCondition = (0, import_core66.node)(
|
|
14368
14979
|
[anomalyNode],
|
|
14369
14980
|
(batchData, actions, ctx) => {
|
|
14370
14981
|
const data = batchData.map(
|
|
@@ -14391,8 +15002,8 @@ function isTagged(value, tag) {
|
|
|
14391
15002
|
}
|
|
14392
15003
|
|
|
14393
15004
|
// src/utils/harness/actuator-executor.ts
|
|
14394
|
-
var
|
|
14395
|
-
var
|
|
15005
|
+
var import_core67 = require("@graphrefly/pure-ts/core");
|
|
15006
|
+
var import_extra49 = require("@graphrefly/pure-ts/extra");
|
|
14396
15007
|
function defaultToOutput(record, item) {
|
|
14397
15008
|
return {
|
|
14398
15009
|
outcome: "success",
|
|
@@ -14426,7 +15037,7 @@ function actuatorExecutor(config) {
|
|
|
14426
15037
|
execution: { item, outcome: "failure", detail: skipDetail(item) }
|
|
14427
15038
|
};
|
|
14428
15039
|
}
|
|
14429
|
-
return (0,
|
|
15040
|
+
return (0, import_core67.node)(
|
|
14430
15041
|
[],
|
|
14431
15042
|
(_data, actions) => {
|
|
14432
15043
|
const ac = new AbortController();
|
|
@@ -14447,8 +15058,8 @@ function actuatorExecutor(config) {
|
|
|
14447
15058
|
if (captured) return;
|
|
14448
15059
|
captured = true;
|
|
14449
15060
|
actions.down([
|
|
14450
|
-
[
|
|
14451
|
-
[
|
|
15061
|
+
[import_core67.DATA, { ...job.payload, execution: { item, ...out } }],
|
|
15062
|
+
[import_core67.COMPLETE]
|
|
14452
15063
|
]);
|
|
14453
15064
|
unsub?.();
|
|
14454
15065
|
unsub = null;
|
|
@@ -14456,26 +15067,28 @@ function actuatorExecutor(config) {
|
|
|
14456
15067
|
let inner;
|
|
14457
15068
|
try {
|
|
14458
15069
|
const rawResult = config.apply(item, { signal: ac.signal });
|
|
14459
|
-
inner = (0,
|
|
15070
|
+
inner = (0, import_extra49.fromAny)(rawResult, { signal: ac.signal });
|
|
14460
15071
|
} catch (err) {
|
|
14461
15072
|
emitOnce(onError(err, item));
|
|
14462
|
-
return
|
|
14463
|
-
|
|
14464
|
-
|
|
15073
|
+
return {
|
|
15074
|
+
onDeactivation: () => {
|
|
15075
|
+
unlinkParent();
|
|
15076
|
+
ac.abort();
|
|
15077
|
+
}
|
|
14465
15078
|
};
|
|
14466
15079
|
}
|
|
14467
15080
|
unsub = inner.subscribe((batch14) => {
|
|
14468
15081
|
for (const m of batch14) {
|
|
14469
15082
|
if (captured) return;
|
|
14470
|
-
if (m[0] ===
|
|
15083
|
+
if (m[0] === import_core67.DATA) {
|
|
14471
15084
|
emitOnce(toOutput(m[1], item));
|
|
14472
15085
|
return;
|
|
14473
15086
|
}
|
|
14474
|
-
if (m[0] ===
|
|
15087
|
+
if (m[0] === import_core67.ERROR) {
|
|
14475
15088
|
emitOnce(onError(m[1], item));
|
|
14476
15089
|
return;
|
|
14477
15090
|
}
|
|
14478
|
-
if (m[0] ===
|
|
15091
|
+
if (m[0] === import_core67.COMPLETE) {
|
|
14479
15092
|
emitOnce(onError(new Error("actuator inner completed without emitting DATA"), item));
|
|
14480
15093
|
return;
|
|
14481
15094
|
}
|
|
@@ -14485,11 +15098,13 @@ function actuatorExecutor(config) {
|
|
|
14485
15098
|
unsub();
|
|
14486
15099
|
unsub = null;
|
|
14487
15100
|
}
|
|
14488
|
-
return
|
|
14489
|
-
|
|
14490
|
-
|
|
14491
|
-
|
|
14492
|
-
|
|
15101
|
+
return {
|
|
15102
|
+
onDeactivation: () => {
|
|
15103
|
+
unlinkParent();
|
|
15104
|
+
ac.abort();
|
|
15105
|
+
unsub?.();
|
|
15106
|
+
unsub = null;
|
|
15107
|
+
}
|
|
14493
15108
|
};
|
|
14494
15109
|
},
|
|
14495
15110
|
{ name: `${name}/inner`, describeKind: "producer" }
|
|
@@ -14515,12 +15130,12 @@ function dispatchActuator(config) {
|
|
|
14515
15130
|
}
|
|
14516
15131
|
|
|
14517
15132
|
// src/utils/harness/auto-solidify.ts
|
|
14518
|
-
var
|
|
15133
|
+
var import_core68 = require("@graphrefly/pure-ts/core");
|
|
14519
15134
|
function autoSolidify(config) {
|
|
14520
15135
|
const name = config.name ?? "auto-solidify";
|
|
14521
15136
|
const extract = config.extract ?? ((vr) => vr.execution.artifact ?? null);
|
|
14522
15137
|
const predicate = config.predicate ?? (() => true);
|
|
14523
|
-
return (0,
|
|
15138
|
+
return (0, import_core68.node)(
|
|
14524
15139
|
[],
|
|
14525
15140
|
(_data, actions) => {
|
|
14526
15141
|
let unsub = null;
|
|
@@ -14533,16 +15148,16 @@ function autoSolidify(config) {
|
|
|
14533
15148
|
};
|
|
14534
15149
|
const emitTerminalError = (err) => {
|
|
14535
15150
|
if (terminated) return;
|
|
14536
|
-
actions.down([[
|
|
15151
|
+
actions.down([[import_core68.ERROR, err]]);
|
|
14537
15152
|
tearDown();
|
|
14538
15153
|
};
|
|
14539
15154
|
unsub = config.verifyResults.subscribe((batch14) => {
|
|
14540
15155
|
if (terminated) return;
|
|
14541
15156
|
for (const m of batch14) {
|
|
14542
15157
|
if (terminated) return;
|
|
14543
|
-
if (m[0] !==
|
|
14544
|
-
if (m[0] ===
|
|
14545
|
-
actions.down([[
|
|
15158
|
+
if (m[0] !== import_core68.DATA) {
|
|
15159
|
+
if (m[0] === import_core68.COMPLETE) {
|
|
15160
|
+
actions.down([[import_core68.COMPLETE]]);
|
|
14546
15161
|
tearDown();
|
|
14547
15162
|
return;
|
|
14548
15163
|
}
|
|
@@ -14573,15 +15188,17 @@ function autoSolidify(config) {
|
|
|
14573
15188
|
emitTerminalError(err);
|
|
14574
15189
|
return;
|
|
14575
15190
|
}
|
|
14576
|
-
actions.down([[
|
|
15191
|
+
actions.down([[import_core68.DATA, artifact]]);
|
|
14577
15192
|
}
|
|
14578
15193
|
});
|
|
14579
15194
|
if (terminated && unsub) {
|
|
14580
15195
|
unsub();
|
|
14581
15196
|
unsub = null;
|
|
14582
15197
|
}
|
|
14583
|
-
return
|
|
14584
|
-
|
|
15198
|
+
return {
|
|
15199
|
+
onDeactivation: () => {
|
|
15200
|
+
tearDown();
|
|
15201
|
+
}
|
|
14585
15202
|
};
|
|
14586
15203
|
},
|
|
14587
15204
|
{ name, describeKind: "producer" }
|
|
@@ -14589,11 +15206,11 @@ function autoSolidify(config) {
|
|
|
14589
15206
|
}
|
|
14590
15207
|
|
|
14591
15208
|
// src/utils/harness/bridge.ts
|
|
14592
|
-
var
|
|
14593
|
-
var
|
|
15209
|
+
var import_core69 = require("@graphrefly/pure-ts/core");
|
|
15210
|
+
var import_extra50 = require("@graphrefly/pure-ts/extra");
|
|
14594
15211
|
function createIntakeBridge(opts) {
|
|
14595
15212
|
const { graph, source, intakeTopic, parser, name = "intake-bridge" } = opts;
|
|
14596
|
-
const eff = (0,
|
|
15213
|
+
const eff = (0, import_core69.node)(
|
|
14597
15214
|
[source],
|
|
14598
15215
|
(batchData, _actions, ctx) => {
|
|
14599
15216
|
const data = batchData.map(
|
|
@@ -14619,7 +15236,7 @@ function evalIntakeBridge(opts) {
|
|
|
14619
15236
|
name = "eval-intake-bridge",
|
|
14620
15237
|
defaultSeverity = "medium"
|
|
14621
15238
|
} = opts;
|
|
14622
|
-
const eff = (0,
|
|
15239
|
+
const eff = (0, import_core69.node)(
|
|
14623
15240
|
[source],
|
|
14624
15241
|
(batchData, _actions, ctx) => {
|
|
14625
15242
|
const data = batchData.map(
|
|
@@ -14664,11 +15281,11 @@ function evalIntakeBridge(opts) {
|
|
|
14664
15281
|
return eff;
|
|
14665
15282
|
}
|
|
14666
15283
|
function evalSource(trigger, runner) {
|
|
14667
|
-
return (0,
|
|
15284
|
+
return (0, import_extra50.switchMap)(trigger, () => (0, import_extra50.fromAny)(runner()));
|
|
14668
15285
|
}
|
|
14669
15286
|
function beforeAfterCompare(opts) {
|
|
14670
15287
|
const { graph, before, after, name = "eval-delta" } = opts;
|
|
14671
|
-
const der = (0,
|
|
15288
|
+
const der = (0, import_core69.node)(
|
|
14672
15289
|
[before, after],
|
|
14673
15290
|
(batchData, actions, ctx) => {
|
|
14674
15291
|
const data = batchData.map(
|
|
@@ -14711,7 +15328,7 @@ function affectedTaskFilter(opts) {
|
|
|
14711
15328
|
let taskSetNode = null;
|
|
14712
15329
|
if (fullTaskSet != null) {
|
|
14713
15330
|
if (Array.isArray(fullTaskSet)) {
|
|
14714
|
-
const inlineSet = (0,
|
|
15331
|
+
const inlineSet = (0, import_core69.node)([], { initial: fullTaskSet });
|
|
14715
15332
|
graph.add(inlineSet, { name: `${name}/fullTaskSet` });
|
|
14716
15333
|
taskSetNode = inlineSet;
|
|
14717
15334
|
} else {
|
|
@@ -14720,7 +15337,7 @@ function affectedTaskFilter(opts) {
|
|
|
14720
15337
|
}
|
|
14721
15338
|
const deps = [issues];
|
|
14722
15339
|
if (taskSetNode) deps.push(taskSetNode);
|
|
14723
|
-
const der = (0,
|
|
15340
|
+
const der = (0, import_core69.node)(
|
|
14724
15341
|
deps,
|
|
14725
15342
|
(batchData, actions, ctx) => {
|
|
14726
15343
|
const data = batchData.map(
|
|
@@ -14774,7 +15391,7 @@ function codeChangeBridge(opts) {
|
|
|
14774
15391
|
return items;
|
|
14775
15392
|
}
|
|
14776
15393
|
const resolve = parser ?? defaultParser;
|
|
14777
|
-
const eff = (0,
|
|
15394
|
+
const eff = (0, import_core69.node)(
|
|
14778
15395
|
[source],
|
|
14779
15396
|
(batchData, _actions, ctx) => {
|
|
14780
15397
|
const data = batchData.map(
|
|
@@ -14793,7 +15410,7 @@ function codeChangeBridge(opts) {
|
|
|
14793
15410
|
}
|
|
14794
15411
|
function notifyEffect(opts) {
|
|
14795
15412
|
const { graph, topic: topic2, transport, name = "notify-effect" } = opts;
|
|
14796
|
-
const eff = (0,
|
|
15413
|
+
const eff = (0, import_core69.node)(
|
|
14797
15414
|
[topic2.latest],
|
|
14798
15415
|
(batchData, _actions, ctx) => {
|
|
14799
15416
|
const data = batchData.map(
|
|
@@ -14886,10 +15503,10 @@ function resolvePromptFn(raw, fallbackTemplate, substitute) {
|
|
|
14886
15503
|
}
|
|
14887
15504
|
|
|
14888
15505
|
// src/utils/harness/strategy.ts
|
|
14889
|
-
var
|
|
15506
|
+
var import_core70 = require("@graphrefly/pure-ts/core");
|
|
14890
15507
|
|
|
14891
15508
|
// src/utils/orchestration/audited-success-tracker.ts
|
|
14892
|
-
var
|
|
15509
|
+
var import_extra51 = require("@graphrefly/pure-ts/extra");
|
|
14893
15510
|
var import_graph15 = require("@graphrefly/pure-ts/graph");
|
|
14894
15511
|
var AuditedSuccessTrackerGraph = class extends import_graph15.Graph {
|
|
14895
15512
|
/** Reactive entries — `Node<ReadonlyMap<TKey, TEntry>>`, fresh map per mutation. */
|
|
@@ -14897,10 +15514,10 @@ var AuditedSuccessTrackerGraph = class extends import_graph15.Graph {
|
|
|
14897
15514
|
_map;
|
|
14898
15515
|
constructor(opts) {
|
|
14899
15516
|
super(opts?.name ?? "audited-success-tracker", opts?.graph);
|
|
14900
|
-
this._map = (0,
|
|
15517
|
+
this._map = (0, import_extra51.reactiveMap)({ name: "entries" });
|
|
14901
15518
|
this.entries = this._map.entries;
|
|
14902
15519
|
this.add(this.entries, { name: "entries" });
|
|
14903
|
-
this.addDisposer((0,
|
|
15520
|
+
this.addDisposer((0, import_extra51.keepalive)(this.entries));
|
|
14904
15521
|
this.addDisposer(() => this._map.dispose());
|
|
14905
15522
|
}
|
|
14906
15523
|
/**
|
|
@@ -14963,7 +15580,7 @@ function priorityScore(item, strategy, lastInteractionNs, urgency, signals) {
|
|
|
14963
15580
|
const effectivenessBoost = signals?.effectivenessBoost ?? 15;
|
|
14964
15581
|
const deps = [item, strategy, lastInteractionNs];
|
|
14965
15582
|
if (urgency) deps.push(urgency);
|
|
14966
|
-
return (0,
|
|
15583
|
+
return (0, import_core70.node)(
|
|
14967
15584
|
deps,
|
|
14968
15585
|
(batchData, actions, ctx) => {
|
|
14969
15586
|
const values = batchData.map(
|
|
@@ -14974,7 +15591,7 @@ function priorityScore(item, strategy, lastInteractionNs, urgency, signals) {
|
|
|
14974
15591
|
const lastNs = values[2];
|
|
14975
15592
|
const urg = urgency ? values[3] : 0;
|
|
14976
15593
|
const baseWeight = severityWeights[itm.severity ?? "medium"];
|
|
14977
|
-
const ageSeconds2 = ((0,
|
|
15594
|
+
const ageSeconds2 = ((0, import_core70.monotonicNs)() - lastNs) / 1e9;
|
|
14978
15595
|
let score = decay(baseWeight, ageSeconds2, decayRate, 0);
|
|
14979
15596
|
const key = strategyKey(DEFAULT_PRESET_ID, itm.rootCause, itm.intervention);
|
|
14980
15597
|
const entry = strat.get(key);
|
|
@@ -14989,8 +15606,8 @@ function priorityScore(item, strategy, lastInteractionNs, urgency, signals) {
|
|
|
14989
15606
|
}
|
|
14990
15607
|
|
|
14991
15608
|
// src/utils/inspect/audit.ts
|
|
14992
|
-
var
|
|
14993
|
-
var
|
|
15609
|
+
var import_core71 = require("@graphrefly/pure-ts/core");
|
|
15610
|
+
var import_extra52 = require("@graphrefly/pure-ts/extra");
|
|
14994
15611
|
var import_graph16 = require("@graphrefly/pure-ts/graph");
|
|
14995
15612
|
function auditMeta(kind, extra) {
|
|
14996
15613
|
return domainMeta("audit", kind, extra);
|
|
@@ -15028,7 +15645,7 @@ var AuditTrailGraph = class extends import_graph16.Graph {
|
|
|
15028
15645
|
constructor(target, opts) {
|
|
15029
15646
|
super(opts.name ?? `${target.name}_audit`, opts.graph);
|
|
15030
15647
|
this._target = target;
|
|
15031
|
-
this._log = (0,
|
|
15648
|
+
this._log = (0, import_extra52.reactiveLog)([], {
|
|
15032
15649
|
name: "entries",
|
|
15033
15650
|
...opts.maxSize != null ? { maxSize: opts.maxSize } : {}
|
|
15034
15651
|
});
|
|
@@ -15045,7 +15662,7 @@ var AuditTrailGraph = class extends import_graph16.Graph {
|
|
|
15045
15662
|
},
|
|
15046
15663
|
{ meta: auditMeta("count") }
|
|
15047
15664
|
);
|
|
15048
|
-
this.addDisposer((0,
|
|
15665
|
+
this.addDisposer((0, import_extra52.keepalive)(this.count));
|
|
15049
15666
|
const includeTypes = opts.includeTypes != null ? new Set(opts.includeTypes) : new Set(DEFAULT_INCLUDE_TYPES);
|
|
15050
15667
|
this.includeTypes = includeTypes;
|
|
15051
15668
|
const filter2 = opts.filter;
|
|
@@ -15058,13 +15675,13 @@ var AuditTrailGraph = class extends import_graph16.Graph {
|
|
|
15058
15675
|
const path = event.path ?? "";
|
|
15059
15676
|
const entry = {
|
|
15060
15677
|
seq: seq++,
|
|
15061
|
-
timestamp_ns: event.timestamp_ns ?? (0,
|
|
15062
|
-
wall_clock_ns: (0,
|
|
15678
|
+
timestamp_ns: event.timestamp_ns ?? (0, import_core71.monotonicNs)(),
|
|
15679
|
+
wall_clock_ns: (0, import_core71.wallClockNs)(),
|
|
15063
15680
|
path,
|
|
15064
15681
|
type
|
|
15065
15682
|
};
|
|
15066
|
-
const
|
|
15067
|
-
const lastMutation =
|
|
15683
|
+
const node65 = path ? safeNode(target, path) : void 0;
|
|
15684
|
+
const lastMutation = node65?.lastMutation;
|
|
15068
15685
|
if (lastMutation != null) entry.actor = lastMutation.actor;
|
|
15069
15686
|
if (type === "data") entry.value = event.data;
|
|
15070
15687
|
if (type === "error") entry.error = event.data;
|
|
@@ -15125,7 +15742,7 @@ var PolicyGateGraph = class extends import_graph16.Graph {
|
|
|
15125
15742
|
super(opts.name ?? `${target.name}_policy`, opts.graph);
|
|
15126
15743
|
this._target = target;
|
|
15127
15744
|
this._mode = opts.mode ?? "audit";
|
|
15128
|
-
const policiesNode = isNode2(policies) ? policies : (0,
|
|
15745
|
+
const policiesNode = isNode2(policies) ? policies : (0, import_core71.node)([], { name: "policies", initial: policies });
|
|
15129
15746
|
this.policies = policiesNode;
|
|
15130
15747
|
this.add(this.policies, { name: "policies" });
|
|
15131
15748
|
this.violations = new TopicGraph("violations", {
|
|
@@ -15145,15 +15762,15 @@ var PolicyGateGraph = class extends import_graph16.Graph {
|
|
|
15145
15762
|
meta: auditMeta("policy_violation_count")
|
|
15146
15763
|
}
|
|
15147
15764
|
);
|
|
15148
|
-
this.addDisposer((0,
|
|
15765
|
+
this.addDisposer((0, import_extra52.keepalive)(this.violationCount));
|
|
15149
15766
|
const initialRules = policiesNode.cache ?? [];
|
|
15150
15767
|
let latestRules = initialRules;
|
|
15151
|
-
this._currentGuard = (0,
|
|
15768
|
+
this._currentGuard = (0, import_core71.policyFromRules)(latestRules);
|
|
15152
15769
|
const offPolicies = policiesNode.subscribe((msgs) => {
|
|
15153
15770
|
for (const m of msgs) {
|
|
15154
|
-
if (m[0] ===
|
|
15771
|
+
if (m[0] === import_core71.DATA) {
|
|
15155
15772
|
latestRules = m[1] ?? [];
|
|
15156
|
-
this._currentGuard = (0,
|
|
15773
|
+
this._currentGuard = (0, import_core71.policyFromRules)(latestRules);
|
|
15157
15774
|
}
|
|
15158
15775
|
}
|
|
15159
15776
|
});
|
|
@@ -15167,7 +15784,7 @@ var PolicyGateGraph = class extends import_graph16.Graph {
|
|
|
15167
15784
|
if (this._mode !== "enforce" && pathsNode != null) {
|
|
15168
15785
|
const offAuditPaths = pathsNode.subscribe((msgs) => {
|
|
15169
15786
|
for (const m of msgs) {
|
|
15170
|
-
if (m[0] !==
|
|
15787
|
+
if (m[0] !== import_core71.DATA) continue;
|
|
15171
15788
|
latestPaths = m[1] ?? [];
|
|
15172
15789
|
}
|
|
15173
15790
|
});
|
|
@@ -15177,8 +15794,8 @@ var PolicyGateGraph = class extends import_graph16.Graph {
|
|
|
15177
15794
|
const restorers = /* @__PURE__ */ new Map();
|
|
15178
15795
|
const wrapAndPush = (path) => {
|
|
15179
15796
|
if (restorers.has(path)) return;
|
|
15180
|
-
const
|
|
15181
|
-
if (!(
|
|
15797
|
+
const node65 = safeNode(target, path);
|
|
15798
|
+
if (!(node65 instanceof import_core71.NodeImpl)) return;
|
|
15182
15799
|
const pathGuard = (actor, action) => {
|
|
15183
15800
|
const ok = this._currentGuard(actor, action);
|
|
15184
15801
|
if (!ok) {
|
|
@@ -15186,17 +15803,17 @@ var PolicyGateGraph = class extends import_graph16.Graph {
|
|
|
15186
15803
|
}
|
|
15187
15804
|
return ok;
|
|
15188
15805
|
};
|
|
15189
|
-
restorers.set(path,
|
|
15806
|
+
restorers.set(path, node65._pushGuard(pathGuard));
|
|
15190
15807
|
};
|
|
15191
15808
|
for (const path of paths) wrapAndPush(path);
|
|
15192
15809
|
if (pathsNode != null) {
|
|
15193
15810
|
const offReactivePaths = pathsNode.subscribe((msgs) => {
|
|
15194
15811
|
for (const m of msgs) {
|
|
15195
|
-
if (m[0] !==
|
|
15812
|
+
if (m[0] !== import_core71.DATA) continue;
|
|
15196
15813
|
const next = m[1] ?? [];
|
|
15197
15814
|
const nextSet = new Set(next);
|
|
15198
15815
|
const prevSet = new Set(latestPaths ?? []);
|
|
15199
|
-
(0,
|
|
15816
|
+
(0, import_core71.batch)(() => {
|
|
15200
15817
|
for (const p of prevSet) {
|
|
15201
15818
|
if (nextSet.has(p)) continue;
|
|
15202
15819
|
const r = restorers.get(p);
|
|
@@ -15255,7 +15872,7 @@ var PolicyGateGraph = class extends import_graph16.Graph {
|
|
|
15255
15872
|
} else {
|
|
15256
15873
|
const offCleanup = target.topology.subscribe((msgs) => {
|
|
15257
15874
|
for (const m of msgs) {
|
|
15258
|
-
if (m[0] !==
|
|
15875
|
+
if (m[0] !== import_core71.DATA) continue;
|
|
15259
15876
|
const event = m[1];
|
|
15260
15877
|
if (event.kind !== "removed" || event.nodeKind !== "node") continue;
|
|
15261
15878
|
const r = restorers.get(event.name);
|
|
@@ -15292,8 +15909,8 @@ var PolicyGateGraph = class extends import_graph16.Graph {
|
|
|
15292
15909
|
}
|
|
15293
15910
|
_publishViolation(actor, action, path, result) {
|
|
15294
15911
|
this.violations.publish({
|
|
15295
|
-
timestamp_ns: (0,
|
|
15296
|
-
wall_clock_ns: (0,
|
|
15912
|
+
timestamp_ns: (0, import_core71.monotonicNs)(),
|
|
15913
|
+
wall_clock_ns: (0, import_core71.wallClockNs)(),
|
|
15297
15914
|
path,
|
|
15298
15915
|
actor,
|
|
15299
15916
|
action,
|
|
@@ -15314,14 +15931,14 @@ var PolicyGateGraph = class extends import_graph16.Graph {
|
|
|
15314
15931
|
};
|
|
15315
15932
|
function policyGate(target, policies, opts = {}) {
|
|
15316
15933
|
const g = new PolicyGateGraph(target, policies, opts);
|
|
15317
|
-
g.tagFactory("policyGate", (0,
|
|
15934
|
+
g.tagFactory("policyGate", (0, import_core71.placeholderArgs)(opts));
|
|
15318
15935
|
return g;
|
|
15319
15936
|
}
|
|
15320
15937
|
function complianceSnapshot(target, opts = {}) {
|
|
15321
15938
|
const result = {
|
|
15322
15939
|
format_version: 1,
|
|
15323
|
-
timestamp_ns: (0,
|
|
15324
|
-
wall_clock_ns: (0,
|
|
15940
|
+
timestamp_ns: (0, import_core71.monotonicNs)(),
|
|
15941
|
+
wall_clock_ns: (0, import_core71.wallClockNs)(),
|
|
15325
15942
|
graph: target.snapshot()
|
|
15326
15943
|
};
|
|
15327
15944
|
if (opts.actor != null) result.actor = opts.actor;
|
|
@@ -15362,7 +15979,7 @@ function collectPaths(target) {
|
|
|
15362
15979
|
return Object.keys(described.nodes);
|
|
15363
15980
|
}
|
|
15364
15981
|
function computeFingerprint(value) {
|
|
15365
|
-
return (0,
|
|
15982
|
+
return (0, import_core71.defaultHash)(JSON.stringify(canonicalize(value)));
|
|
15366
15983
|
}
|
|
15367
15984
|
function canonicalize(value) {
|
|
15368
15985
|
const stack = /* @__PURE__ */ new Set();
|
|
@@ -15415,8 +16032,8 @@ function canonicalize(value) {
|
|
|
15415
16032
|
}
|
|
15416
16033
|
|
|
15417
16034
|
// src/utils/inspect/lens.ts
|
|
15418
|
-
var
|
|
15419
|
-
var
|
|
16035
|
+
var import_core72 = require("@graphrefly/pure-ts/core");
|
|
16036
|
+
var import_extra53 = require("@graphrefly/pure-ts/extra");
|
|
15420
16037
|
var import_graph17 = require("@graphrefly/pure-ts/graph");
|
|
15421
16038
|
var import_graph18 = require("@graphrefly/pure-ts/graph");
|
|
15422
16039
|
function computeHealthReport(described) {
|
|
@@ -15456,7 +16073,7 @@ function graphLens(target) {
|
|
|
15456
16073
|
reactiveName: "graphLens.topology"
|
|
15457
16074
|
});
|
|
15458
16075
|
const topology = topologyHandle.node;
|
|
15459
|
-
const health = (0,
|
|
16076
|
+
const health = (0, import_core72.node)(
|
|
15460
16077
|
[topology],
|
|
15461
16078
|
(batchData, actions, ctx) => {
|
|
15462
16079
|
const data = batchData.map(
|
|
@@ -15471,11 +16088,11 @@ function graphLens(target) {
|
|
|
15471
16088
|
meta: domainMeta("lens", "health")
|
|
15472
16089
|
}
|
|
15473
16090
|
);
|
|
15474
|
-
const stopHealthKeep = (0,
|
|
16091
|
+
const stopHealthKeep = (0, import_extra53.keepalive)(health);
|
|
15475
16092
|
const flowMap = /* @__PURE__ */ new Map();
|
|
15476
16093
|
let lastAppliedFlush_ns = -1;
|
|
15477
16094
|
const dataFlow = target.observe({ reactive: true, tiers: ["data"] });
|
|
15478
|
-
const flow = (0,
|
|
16095
|
+
const flow = (0, import_core72.node)(
|
|
15479
16096
|
[dataFlow, topology],
|
|
15480
16097
|
(batchData, actions, ctx) => {
|
|
15481
16098
|
const data = batchData.map(
|
|
@@ -15513,7 +16130,7 @@ function graphLens(target) {
|
|
|
15513
16130
|
meta: domainMeta("lens", "flow")
|
|
15514
16131
|
}
|
|
15515
16132
|
);
|
|
15516
|
-
const stopFlowKeep = (0,
|
|
16133
|
+
const stopFlowKeep = (0, import_extra53.keepalive)(flow);
|
|
15517
16134
|
let disposed = false;
|
|
15518
16135
|
return {
|
|
15519
16136
|
topology,
|
|
@@ -15530,8 +16147,8 @@ function graphLens(target) {
|
|
|
15530
16147
|
}
|
|
15531
16148
|
|
|
15532
16149
|
// src/utils/job-queue/index.ts
|
|
15533
|
-
var
|
|
15534
|
-
var
|
|
16150
|
+
var import_core73 = require("@graphrefly/pure-ts/core");
|
|
16151
|
+
var import_extra54 = require("@graphrefly/pure-ts/extra");
|
|
15535
16152
|
var import_graph19 = require("@graphrefly/pure-ts/graph");
|
|
15536
16153
|
var DEFAULT_MAX_PER_PUMP2 = 256;
|
|
15537
16154
|
var DEFAULT_COMPLETED_RETAINED_LIMIT = 1024;
|
|
@@ -15567,13 +16184,13 @@ var JobQueueGraph = class extends import_graph19.Graph {
|
|
|
15567
16184
|
_removeByIdImpl;
|
|
15568
16185
|
constructor(name, opts = {}) {
|
|
15569
16186
|
super(name, opts.graph);
|
|
15570
|
-
this._pending = (0,
|
|
15571
|
-
this._jobs = (0,
|
|
16187
|
+
this._pending = (0, import_extra54.reactiveList)([], { name: "pending" });
|
|
16188
|
+
this._jobs = (0, import_extra54.reactiveMap)({ name: "jobs" });
|
|
15572
16189
|
this.pending = this._pending.items;
|
|
15573
16190
|
this.jobs = this._jobs.entries;
|
|
15574
16191
|
this.add(this.pending, { name: "pending" });
|
|
15575
16192
|
this.add(this.jobs, { name: "jobs" });
|
|
15576
|
-
this.depth = (0,
|
|
16193
|
+
this.depth = (0, import_core73.node)(
|
|
15577
16194
|
[this.pending],
|
|
15578
16195
|
(batchData, actions, ctx) => {
|
|
15579
16196
|
const data = batchData.map(
|
|
@@ -15589,7 +16206,7 @@ var JobQueueGraph = class extends import_graph19.Graph {
|
|
|
15589
16206
|
}
|
|
15590
16207
|
);
|
|
15591
16208
|
this.add(this.depth, { name: "depth" });
|
|
15592
|
-
this.addDisposer((0,
|
|
16209
|
+
this.addDisposer((0, import_extra54.keepalive)(this.depth));
|
|
15593
16210
|
this.events = createAuditLog({
|
|
15594
16211
|
name: "events",
|
|
15595
16212
|
retainedLimit: 1024,
|
|
@@ -15726,7 +16343,7 @@ var JobQueueGraph = class extends import_graph19.Graph {
|
|
|
15726
16343
|
action: "claim",
|
|
15727
16344
|
id,
|
|
15728
16345
|
attempts: inflight.attempts,
|
|
15729
|
-
t_ns: (0,
|
|
16346
|
+
t_ns: (0, import_core73.wallClockNs)(),
|
|
15730
16347
|
seq: bumpCursor(this._seqCursor)
|
|
15731
16348
|
});
|
|
15732
16349
|
}
|
|
@@ -15777,7 +16394,7 @@ var JobQueueGraph = class extends import_graph19.Graph {
|
|
|
15777
16394
|
consumeFrom(source, opts) {
|
|
15778
16395
|
return source.subscribe((msgs) => {
|
|
15779
16396
|
for (const m of msgs) {
|
|
15780
|
-
if (m[0] !==
|
|
16397
|
+
if (m[0] !== import_core73.DATA) continue;
|
|
15781
16398
|
const payload = m[1];
|
|
15782
16399
|
this.enqueue(payload, opts ? { metadata: opts.metadata } : void 0);
|
|
15783
16400
|
}
|
|
@@ -15837,13 +16454,13 @@ var JobFlowGraph = class extends import_graph19.Graph {
|
|
|
15837
16454
|
this._queues.set(stage, q);
|
|
15838
16455
|
this.mount(stage, q);
|
|
15839
16456
|
}
|
|
15840
|
-
this._completed = (0,
|
|
16457
|
+
this._completed = (0, import_extra54.reactiveLog)([], {
|
|
15841
16458
|
name: "completed",
|
|
15842
16459
|
maxSize: DEFAULT_COMPLETED_RETAINED_LIMIT
|
|
15843
16460
|
});
|
|
15844
16461
|
this.completed = this._completed.entries;
|
|
15845
16462
|
this.add(this.completed, { name: "completed" });
|
|
15846
|
-
this.completedCount = (0,
|
|
16463
|
+
this.completedCount = (0, import_core73.node)(
|
|
15847
16464
|
[this.completed],
|
|
15848
16465
|
(batchData, actions, ctx) => {
|
|
15849
16466
|
const data = batchData.map(
|
|
@@ -15859,7 +16476,7 @@ var JobFlowGraph = class extends import_graph19.Graph {
|
|
|
15859
16476
|
}
|
|
15860
16477
|
);
|
|
15861
16478
|
this.add(this.completedCount, { name: "completedCount" });
|
|
15862
|
-
this.addDisposer((0,
|
|
16479
|
+
this.addDisposer((0, import_extra54.keepalive)(this.completedCount));
|
|
15863
16480
|
const defaultMaxPerPump = Math.max(
|
|
15864
16481
|
1,
|
|
15865
16482
|
requireNonNegativeInt2(opts.maxPerPump ?? DEFAULT_MAX_PER_PUMP2, "job flow maxPerPump")
|
|
@@ -15871,14 +16488,14 @@ var JobFlowGraph = class extends import_graph19.Graph {
|
|
|
15871
16488
|
const workFn = this._stageWorkFns.get(stage);
|
|
15872
16489
|
const stagePerPump = stageMaxPerPump.get(stage) ?? defaultMaxPerPump;
|
|
15873
16490
|
const stageMaxInflightCap = stageMaxInflight.get(stage);
|
|
15874
|
-
const inflightCounter = stageMaxInflightCap !== void 0 ? (0,
|
|
16491
|
+
const inflightCounter = stageMaxInflightCap !== void 0 ? (0, import_core73.node)([], { name: `__inflight__/${stage}`, initial: 0 }) : null;
|
|
15875
16492
|
if (inflightCounter) {
|
|
15876
16493
|
this.add(inflightCounter, { name: `__inflight__/${stage}` });
|
|
15877
16494
|
}
|
|
15878
16495
|
const isTerminal = next === null;
|
|
15879
16496
|
if (workFn) {
|
|
15880
16497
|
const pumpDeps = inflightCounter != null ? [current.pending, inflightCounter] : [current.pending];
|
|
15881
|
-
const pump = (0,
|
|
16498
|
+
const pump = (0, import_core73.node)(
|
|
15882
16499
|
pumpDeps,
|
|
15883
16500
|
(_data, _actions, ctx) => {
|
|
15884
16501
|
if (!("inflight" in ctx.store)) {
|
|
@@ -15914,7 +16531,7 @@ var JobFlowGraph = class extends import_graph19.Graph {
|
|
|
15914
16531
|
processed += 1;
|
|
15915
16532
|
continue;
|
|
15916
16533
|
}
|
|
15917
|
-
const resultNode = (0,
|
|
16534
|
+
const resultNode = (0, import_extra54.fromAny)(result);
|
|
15918
16535
|
let settled = false;
|
|
15919
16536
|
let unsub;
|
|
15920
16537
|
const cleanupSub = () => {
|
|
@@ -15931,7 +16548,7 @@ var JobFlowGraph = class extends import_graph19.Graph {
|
|
|
15931
16548
|
unsub = resultNode.subscribe((msgs) => {
|
|
15932
16549
|
if (settled) return;
|
|
15933
16550
|
for (const m of msgs) {
|
|
15934
|
-
if (m[0] ===
|
|
16551
|
+
if (m[0] === import_core73.DATA) {
|
|
15935
16552
|
settled = true;
|
|
15936
16553
|
cleanupSub();
|
|
15937
16554
|
const newPayload = m[1];
|
|
@@ -15945,12 +16562,12 @@ var JobFlowGraph = class extends import_graph19.Graph {
|
|
|
15945
16562
|
payload: newPayload,
|
|
15946
16563
|
metadata: Object.freeze(newMetadata)
|
|
15947
16564
|
};
|
|
15948
|
-
(0,
|
|
16565
|
+
(0, import_core73.batch)(() => {
|
|
15949
16566
|
current.ack(job.id);
|
|
15950
16567
|
this._completed.append(completedJob);
|
|
15951
16568
|
});
|
|
15952
16569
|
} else {
|
|
15953
|
-
(0,
|
|
16570
|
+
(0, import_core73.batch)(() => {
|
|
15954
16571
|
current.ack(job.id);
|
|
15955
16572
|
next.enqueue(newPayload, {
|
|
15956
16573
|
metadata: newMetadata
|
|
@@ -15958,7 +16575,7 @@ var JobFlowGraph = class extends import_graph19.Graph {
|
|
|
15958
16575
|
});
|
|
15959
16576
|
}
|
|
15960
16577
|
return;
|
|
15961
|
-
} else if (m[0] ===
|
|
16578
|
+
} else if (m[0] === import_core73.ERROR) {
|
|
15962
16579
|
settled = true;
|
|
15963
16580
|
cleanupSub();
|
|
15964
16581
|
current.nack(job.id, { requeue: false });
|
|
@@ -15991,7 +16608,7 @@ var JobFlowGraph = class extends import_graph19.Graph {
|
|
|
15991
16608
|
meta: jobQueueMeta("job_flow_pump", { stage, has_work: true })
|
|
15992
16609
|
}
|
|
15993
16610
|
);
|
|
15994
|
-
this.addDisposer((0,
|
|
16611
|
+
this.addDisposer((0, import_extra54.keepalive)(pump));
|
|
15995
16612
|
} else {
|
|
15996
16613
|
const pump = this.effect(
|
|
15997
16614
|
`pump_${stage}`,
|
|
@@ -16011,12 +16628,12 @@ var JobFlowGraph = class extends import_graph19.Graph {
|
|
|
16011
16628
|
...job,
|
|
16012
16629
|
metadata: Object.freeze(newMetadata)
|
|
16013
16630
|
};
|
|
16014
|
-
(0,
|
|
16631
|
+
(0, import_core73.batch)(() => {
|
|
16015
16632
|
current.ack(job.id);
|
|
16016
16633
|
this._completed.append(completedJob);
|
|
16017
16634
|
});
|
|
16018
16635
|
} else {
|
|
16019
|
-
(0,
|
|
16636
|
+
(0, import_core73.batch)(() => {
|
|
16020
16637
|
current.ack(job.id);
|
|
16021
16638
|
next.enqueue(job.payload, {
|
|
16022
16639
|
metadata: newMetadata
|
|
@@ -16030,7 +16647,7 @@ var JobFlowGraph = class extends import_graph19.Graph {
|
|
|
16030
16647
|
meta: jobQueueMeta("job_flow_pump", { stage, has_work: false })
|
|
16031
16648
|
}
|
|
16032
16649
|
);
|
|
16033
|
-
this.addDisposer((0,
|
|
16650
|
+
this.addDisposer((0, import_extra54.keepalive)(pump));
|
|
16034
16651
|
}
|
|
16035
16652
|
}
|
|
16036
16653
|
}
|
|
@@ -16055,19 +16672,19 @@ function jobQueue(name, opts) {
|
|
|
16055
16672
|
function jobFlow(name, opts) {
|
|
16056
16673
|
const g = new JobFlowGraph(name, opts);
|
|
16057
16674
|
const { factory: _f, factoryArgs: _fa, ...tagArgs } = opts ?? {};
|
|
16058
|
-
g.tagFactory("jobFlow", (0,
|
|
16675
|
+
g.tagFactory("jobFlow", (0, import_core73.placeholderArgs)(tagArgs));
|
|
16059
16676
|
return g;
|
|
16060
16677
|
}
|
|
16061
16678
|
|
|
16062
16679
|
// src/utils/process/index.ts
|
|
16063
|
-
var
|
|
16064
|
-
var
|
|
16680
|
+
var import_core74 = require("@graphrefly/pure-ts/core");
|
|
16681
|
+
var import_extra55 = require("@graphrefly/pure-ts/extra");
|
|
16065
16682
|
var import_graph20 = require("@graphrefly/pure-ts/graph");
|
|
16066
16683
|
var processInstanceKeyOf = (i) => i.correlationId;
|
|
16067
16684
|
var processStateKeyOf = (s) => s.correlationId;
|
|
16068
16685
|
function toPromise(input) {
|
|
16069
16686
|
if (input == null) return Promise.resolve(void 0);
|
|
16070
|
-
const n = (0,
|
|
16687
|
+
const n = (0, import_extra55.fromAny)(input);
|
|
16071
16688
|
return new Promise((resolve, reject) => {
|
|
16072
16689
|
let settled = false;
|
|
16073
16690
|
let unsub;
|
|
@@ -16079,19 +16696,19 @@ function toPromise(input) {
|
|
|
16079
16696
|
unsub = n.subscribe((msgs) => {
|
|
16080
16697
|
if (settled) return;
|
|
16081
16698
|
for (const m of msgs) {
|
|
16082
|
-
if (m[0] ===
|
|
16699
|
+
if (m[0] === import_core74.DATA) {
|
|
16083
16700
|
settled = true;
|
|
16084
16701
|
Promise.resolve().then(cleanup);
|
|
16085
16702
|
resolve(m[1]);
|
|
16086
16703
|
return;
|
|
16087
16704
|
}
|
|
16088
|
-
if (m[0] ===
|
|
16705
|
+
if (m[0] === import_core74.ERROR) {
|
|
16089
16706
|
settled = true;
|
|
16090
16707
|
Promise.resolve().then(cleanup);
|
|
16091
16708
|
reject(m[1]);
|
|
16092
16709
|
return;
|
|
16093
16710
|
}
|
|
16094
|
-
if (m[0] ===
|
|
16711
|
+
if (m[0] === import_core74.COMPLETE) {
|
|
16095
16712
|
settled = true;
|
|
16096
16713
|
Promise.resolve().then(cleanup);
|
|
16097
16714
|
resolve(void 0);
|
|
@@ -16172,8 +16789,8 @@ function processManager(cqrsGraph, name, opts) {
|
|
|
16172
16789
|
correlationId,
|
|
16173
16790
|
state: stateValue,
|
|
16174
16791
|
status,
|
|
16175
|
-
startedAt: startedAt.get(correlationId) ?? (0,
|
|
16176
|
-
updatedAt: (0,
|
|
16792
|
+
startedAt: startedAt.get(correlationId) ?? (0, import_core74.wallClockNs)(),
|
|
16793
|
+
updatedAt: (0, import_core74.wallClockNs)(),
|
|
16177
16794
|
...opts.handlerVersion !== void 0 ? { handlerVersion: opts.handlerVersion } : {}
|
|
16178
16795
|
};
|
|
16179
16796
|
};
|
|
@@ -16271,10 +16888,10 @@ function processManager(cqrsGraph, name, opts) {
|
|
|
16271
16888
|
if (result.schedule) {
|
|
16272
16889
|
const { afterMs, eventType } = result.schedule;
|
|
16273
16890
|
let timerUnsub;
|
|
16274
|
-
const timerNode = (0,
|
|
16891
|
+
const timerNode = (0, import_extra55.fromTimer)(afterMs);
|
|
16275
16892
|
const timerCb = (msgs) => {
|
|
16276
16893
|
for (const m of msgs) {
|
|
16277
|
-
if (m[0] ===
|
|
16894
|
+
if (m[0] === import_core74.DATA) {
|
|
16278
16895
|
if (timerUnsub) {
|
|
16279
16896
|
timerUnsub();
|
|
16280
16897
|
} else {
|
|
@@ -16291,7 +16908,7 @@ function processManager(cqrsGraph, name, opts) {
|
|
|
16291
16908
|
// seq: Number.NaN — sentinel for synthetic events that do not
|
|
16292
16909
|
// participate in cross-event ordering.
|
|
16293
16910
|
payload: null,
|
|
16294
|
-
timestampNs: (0,
|
|
16911
|
+
timestampNs: (0, import_core74.wallClockNs)(),
|
|
16295
16912
|
seq: Number.NaN,
|
|
16296
16913
|
correlationId,
|
|
16297
16914
|
aggregateId: correlationId
|
|
@@ -16352,13 +16969,13 @@ function processManager(cqrsGraph, name, opts) {
|
|
|
16352
16969
|
});
|
|
16353
16970
|
}
|
|
16354
16971
|
let _disposed = false;
|
|
16355
|
-
const restoreState = (0,
|
|
16972
|
+
const restoreState = (0, import_core74.node)([], {
|
|
16356
16973
|
initial: "pending",
|
|
16357
16974
|
name: "restoreState",
|
|
16358
16975
|
describeKind: "state"
|
|
16359
16976
|
});
|
|
16360
16977
|
subgraph.add(restoreState, { name: "restoreState" });
|
|
16361
|
-
const gateOpen = (0,
|
|
16978
|
+
const gateOpen = (0, import_core74.node)(
|
|
16362
16979
|
[restoreState],
|
|
16363
16980
|
(data, a, ctx) => {
|
|
16364
16981
|
const batch0 = data[0];
|
|
@@ -16371,11 +16988,11 @@ function processManager(cqrsGraph, name, opts) {
|
|
|
16371
16988
|
const watchDisposers = [];
|
|
16372
16989
|
for (const eventType of opts.watching) {
|
|
16373
16990
|
const eventNode = cqrsGraph.event(eventType);
|
|
16374
|
-
const gated = (0,
|
|
16991
|
+
const gated = (0, import_extra55.valve)(eventNode, gateOpen, { name: `gatedEvent:${eventType}` });
|
|
16375
16992
|
let lastCount = 0;
|
|
16376
16993
|
const unsub = gated.subscribe((msgs) => {
|
|
16377
16994
|
for (const m of msgs) {
|
|
16378
|
-
if (m[0] !==
|
|
16995
|
+
if (m[0] !== import_core74.DATA) continue;
|
|
16379
16996
|
const events = m[1];
|
|
16380
16997
|
if (events.length <= lastCount) continue;
|
|
16381
16998
|
const newEvents = events.slice(lastCount);
|
|
@@ -16400,7 +17017,7 @@ function processManager(cqrsGraph, name, opts) {
|
|
|
16400
17017
|
correlationId,
|
|
16401
17018
|
aggregateId: correlationId
|
|
16402
17019
|
});
|
|
16403
|
-
startedAt.set(correlationId, (0,
|
|
17020
|
+
startedAt.set(correlationId, (0, import_core74.wallClockNs)());
|
|
16404
17021
|
instanceStates.set(correlationId, opts.initial);
|
|
16405
17022
|
activeInstances.add(correlationId);
|
|
16406
17023
|
persistStateThrowing(correlationId, "running");
|
|
@@ -16452,21 +17069,21 @@ function processManager(cqrsGraph, name, opts) {
|
|
|
16452
17069
|
}
|
|
16453
17070
|
const tierLoad = tier2.load.bind(tier2);
|
|
16454
17071
|
const tierList = tier2.list.bind(tier2);
|
|
16455
|
-
const listSource = (0,
|
|
16456
|
-
const flattened = (0,
|
|
17072
|
+
const listSource = (0, import_extra55.fromAny)(tierList());
|
|
17073
|
+
const flattened = (0, import_extra55.mergeMap)(listSource, (keys) => {
|
|
16457
17074
|
if (keys.length === 0) {
|
|
16458
|
-
return (0,
|
|
17075
|
+
return (0, import_extra55.fromIter)([]);
|
|
16459
17076
|
}
|
|
16460
|
-
return (0,
|
|
16461
|
-
(0,
|
|
16462
|
-
(key) => (0,
|
|
17077
|
+
return (0, import_extra55.mergeMap)(
|
|
17078
|
+
(0, import_extra55.fromIter)(keys),
|
|
17079
|
+
(key) => (0, import_extra55.fromAny)(tierLoad(key)),
|
|
16463
17080
|
// Bound concurrent in-flight loads (D2, 2026-05-01) so a
|
|
16464
17081
|
// large persisted-instance count doesn't exhaust file
|
|
16465
17082
|
// handles / connection pools on the storage backend.
|
|
16466
17083
|
{ concurrent: opts.restoreConcurrency ?? 8 }
|
|
16467
17084
|
);
|
|
16468
17085
|
});
|
|
16469
|
-
const restoreEffect = (0,
|
|
17086
|
+
const restoreEffect = (0, import_core74.node)(
|
|
16470
17087
|
[flattened],
|
|
16471
17088
|
(data, _a, ctx) => {
|
|
16472
17089
|
if (_disposed) return;
|
|
@@ -16474,7 +17091,7 @@ function processManager(cqrsGraph, name, opts) {
|
|
|
16474
17091
|
const hasSnapshots = batch0 != null && batch0.length > 0;
|
|
16475
17092
|
const allDone = ctx.terminalDeps[0] === true;
|
|
16476
17093
|
if (!hasSnapshots && !allDone) return;
|
|
16477
|
-
(0,
|
|
17094
|
+
(0, import_core74.batch)(() => {
|
|
16478
17095
|
if (hasSnapshots) {
|
|
16479
17096
|
for (const snap of batch0) {
|
|
16480
17097
|
if (snap == null) continue;
|
|
@@ -16702,7 +17319,7 @@ var ImageSizeAdapter = class {
|
|
|
16702
17319
|
};
|
|
16703
17320
|
|
|
16704
17321
|
// src/utils/reactive-layout/reactive-block-layout.ts
|
|
16705
|
-
var
|
|
17322
|
+
var import_core75 = require("@graphrefly/pure-ts/core");
|
|
16706
17323
|
var import_graph21 = require("@graphrefly/pure-ts/graph");
|
|
16707
17324
|
function measureBlock(block, maxWidth, adapters, measureCache, defaultFont, defaultLineHeight, index) {
|
|
16708
17325
|
switch (block.type) {
|
|
@@ -16798,18 +17415,18 @@ function reactiveBlockLayout(opts) {
|
|
|
16798
17415
|
} = opts;
|
|
16799
17416
|
const g = new import_graph21.Graph(name);
|
|
16800
17417
|
const measureCache = /* @__PURE__ */ new Map();
|
|
16801
|
-
const blocksNode = (0,
|
|
16802
|
-
const maxWidthNode = (0,
|
|
17418
|
+
const blocksNode = (0, import_core75.node)([], { name: "blocks", initial: opts.blocks ?? [] });
|
|
17419
|
+
const maxWidthNode = (0, import_core75.node)([], {
|
|
16803
17420
|
name: "max-width",
|
|
16804
17421
|
initial: Math.max(0, opts.maxWidth ?? 800)
|
|
16805
17422
|
});
|
|
16806
|
-
const gapNode = (0,
|
|
16807
|
-
const measuredBlocksNode = (0,
|
|
17423
|
+
const gapNode = (0, import_core75.node)([], { name: "gap", initial: opts.gap ?? 0 });
|
|
17424
|
+
const measuredBlocksNode = (0, import_core75.node)(
|
|
16808
17425
|
[blocksNode, maxWidthNode],
|
|
16809
17426
|
(data, actions, ctx) => {
|
|
16810
17427
|
const blocksVal = data[0] != null && data[0].length > 0 ? data[0].at(-1) : ctx.prevData[0];
|
|
16811
17428
|
const mwVal = data[1] != null && data[1].length > 0 ? data[1].at(-1) : ctx.prevData[1];
|
|
16812
|
-
const t0 = (0,
|
|
17429
|
+
const t0 = (0, import_core75.monotonicNs)();
|
|
16813
17430
|
const result = measureBlocks(
|
|
16814
17431
|
blocksVal,
|
|
16815
17432
|
mwVal,
|
|
@@ -16818,7 +17435,7 @@ function reactiveBlockLayout(opts) {
|
|
|
16818
17435
|
defaultFont,
|
|
16819
17436
|
defaultLineHeight
|
|
16820
17437
|
);
|
|
16821
|
-
const elapsed = (0,
|
|
17438
|
+
const elapsed = (0, import_core75.monotonicNs)() - t0;
|
|
16822
17439
|
const meta2 = measuredBlocksNode.meta;
|
|
16823
17440
|
if (meta2) {
|
|
16824
17441
|
emitToMeta(meta2["block-count"], result.length);
|
|
@@ -16850,7 +17467,7 @@ function reactiveBlockLayout(opts) {
|
|
|
16850
17467
|
}
|
|
16851
17468
|
}
|
|
16852
17469
|
);
|
|
16853
|
-
const blockFlowNode = (0,
|
|
17470
|
+
const blockFlowNode = (0, import_core75.node)(
|
|
16854
17471
|
[measuredBlocksNode, gapNode],
|
|
16855
17472
|
(batchData, actions, ctx) => {
|
|
16856
17473
|
const data = batchData.map(
|
|
@@ -16876,7 +17493,7 @@ function reactiveBlockLayout(opts) {
|
|
|
16876
17493
|
}
|
|
16877
17494
|
}
|
|
16878
17495
|
);
|
|
16879
|
-
const totalHeightNode = (0,
|
|
17496
|
+
const totalHeightNode = (0, import_core75.node)(
|
|
16880
17497
|
[blockFlowNode],
|
|
16881
17498
|
(batchData, actions, ctx) => {
|
|
16882
17499
|
const data = batchData.map(
|
|
@@ -16904,7 +17521,7 @@ function reactiveBlockLayout(opts) {
|
|
|
16904
17521
|
}
|
|
16905
17522
|
|
|
16906
17523
|
// src/utils/reactive-layout/reactive-flow-layout.ts
|
|
16907
|
-
var
|
|
17524
|
+
var import_core76 = require("@graphrefly/pure-ts/core");
|
|
16908
17525
|
var import_graph22 = require("@graphrefly/pure-ts/graph");
|
|
16909
17526
|
function circleIntervalForBand(o, bandTop, bandBottom) {
|
|
16910
17527
|
const hPad = o.hPad ?? 0;
|
|
@@ -16996,23 +17613,23 @@ function reactiveFlowLayout(opts) {
|
|
|
16996
17613
|
const { adapter, name = "reactive-flow-layout", minSlotWidth = 20 } = opts;
|
|
16997
17614
|
const g = new import_graph22.Graph(name);
|
|
16998
17615
|
const measureCache = /* @__PURE__ */ new Map();
|
|
16999
|
-
const textNode = (0,
|
|
17000
|
-
const fontNode = (0,
|
|
17001
|
-
const lineHeightNode = (0,
|
|
17002
|
-
const containerNode = (0,
|
|
17616
|
+
const textNode = (0, import_core76.node)([], { name: "text", initial: opts.text ?? "" });
|
|
17617
|
+
const fontNode = (0, import_core76.node)([], { name: "font", initial: opts.font ?? "16px sans-serif" });
|
|
17618
|
+
const lineHeightNode = (0, import_core76.node)([], { name: "line-height", initial: opts.lineHeight ?? 20 });
|
|
17619
|
+
const containerNode = (0, import_core76.node)([], {
|
|
17003
17620
|
name: "container",
|
|
17004
17621
|
initial: opts.container ?? { width: 800, height: 600, paddingX: 0, paddingY: 0 }
|
|
17005
17622
|
});
|
|
17006
|
-
const columnsNode = (0,
|
|
17623
|
+
const columnsNode = (0, import_core76.node)([], {
|
|
17007
17624
|
name: "columns",
|
|
17008
17625
|
initial: opts.columns ?? { count: 1, gap: 0 }
|
|
17009
17626
|
});
|
|
17010
|
-
const obstaclesNode = (0,
|
|
17011
|
-
const paragraphSpacingNode = (0,
|
|
17627
|
+
const obstaclesNode = (0, import_core76.node)([], { name: "obstacles", initial: opts.obstacles ?? [] });
|
|
17628
|
+
const paragraphSpacingNode = (0, import_core76.node)([], {
|
|
17012
17629
|
name: "paragraph-spacing",
|
|
17013
17630
|
initial: opts.paragraphSpacing ?? null
|
|
17014
17631
|
});
|
|
17015
|
-
const segmentsNode = (0,
|
|
17632
|
+
const segmentsNode = (0, import_core76.node)(
|
|
17016
17633
|
[textNode, fontNode],
|
|
17017
17634
|
(data, actions, ctx) => {
|
|
17018
17635
|
const b0 = data[0];
|
|
@@ -17029,14 +17646,14 @@ function reactiveFlowLayout(opts) {
|
|
|
17029
17646
|
},
|
|
17030
17647
|
{ name: "segments", describeKind: "derived" }
|
|
17031
17648
|
);
|
|
17032
|
-
const flowLinesNode = (0,
|
|
17649
|
+
const flowLinesNode = (0, import_core76.node)(
|
|
17033
17650
|
[segmentsNode, containerNode, columnsNode, obstaclesNode, lineHeightNode, paragraphSpacingNode],
|
|
17034
17651
|
(batchData, actions, ctx) => {
|
|
17035
17652
|
const data = batchData.map(
|
|
17036
17653
|
(batch14, i) => batch14 != null && batch14.length > 0 ? batch14.at(-1) : ctx.prevData[i]
|
|
17037
17654
|
);
|
|
17038
17655
|
const segments = data[0];
|
|
17039
|
-
const t0 = (0,
|
|
17656
|
+
const t0 = (0, import_core76.monotonicNs)();
|
|
17040
17657
|
const effectiveSpacing = data[5] ?? data[4];
|
|
17041
17658
|
const { lines: result, cursor } = computeFlowLines(
|
|
17042
17659
|
segments,
|
|
@@ -17047,7 +17664,7 @@ function reactiveFlowLayout(opts) {
|
|
|
17047
17664
|
minSlotWidth,
|
|
17048
17665
|
{ paragraphSpacing: effectiveSpacing }
|
|
17049
17666
|
);
|
|
17050
|
-
const elapsed = (0,
|
|
17667
|
+
const elapsed = (0, import_core76.monotonicNs)() - t0;
|
|
17051
17668
|
const overflow = Math.max(0, segments.length - cursor.segmentIndex);
|
|
17052
17669
|
const meta2 = flowLinesNode.meta;
|
|
17053
17670
|
if (meta2) {
|
|
@@ -17171,7 +17788,7 @@ ${catalogValidation.errors.join("\n")}`,
|
|
|
17171
17788
|
}
|
|
17172
17789
|
|
|
17173
17790
|
// src/utils/surface/reduce.ts
|
|
17174
|
-
var
|
|
17791
|
+
var import_core77 = require("@graphrefly/pure-ts/core");
|
|
17175
17792
|
var DEFAULT_TIMEOUT_MS2 = 3e4;
|
|
17176
17793
|
async function runReduction(spec, input, opts) {
|
|
17177
17794
|
const inputPath = opts?.inputPath ?? "input";
|
|
@@ -17222,16 +17839,16 @@ async function runReduction(spec, input, opts) {
|
|
|
17222
17839
|
for (const m of msgs) {
|
|
17223
17840
|
if (settled) return;
|
|
17224
17841
|
if (!primed) continue;
|
|
17225
|
-
if (m[0] ===
|
|
17842
|
+
if (m[0] === import_core77.DATA) {
|
|
17226
17843
|
finish(() => resolve(m[1]));
|
|
17227
17844
|
return;
|
|
17228
17845
|
}
|
|
17229
|
-
if (m[0] ===
|
|
17846
|
+
if (m[0] === import_core77.RESOLVED) {
|
|
17230
17847
|
const cached = outputNode.cache;
|
|
17231
17848
|
finish(() => resolve(cached));
|
|
17232
17849
|
return;
|
|
17233
17850
|
}
|
|
17234
|
-
if (m[0] ===
|
|
17851
|
+
if (m[0] === import_core77.ERROR) {
|
|
17235
17852
|
const payload = m[1];
|
|
17236
17853
|
const message = payload instanceof Error ? payload.message : String(payload);
|
|
17237
17854
|
const cause = payload instanceof Error ? payload : void 0;
|
|
@@ -17246,7 +17863,7 @@ async function runReduction(spec, input, opts) {
|
|
|
17246
17863
|
);
|
|
17247
17864
|
return;
|
|
17248
17865
|
}
|
|
17249
|
-
if (m[0] ===
|
|
17866
|
+
if (m[0] === import_core77.COMPLETE) {
|
|
17250
17867
|
finish(
|
|
17251
17868
|
() => reject(
|
|
17252
17869
|
new SurfaceError(
|
|
@@ -17301,7 +17918,7 @@ async function runReduction(spec, input, opts) {
|
|
|
17301
17918
|
}
|
|
17302
17919
|
|
|
17303
17920
|
// src/utils/surface/snapshot.ts
|
|
17304
|
-
var
|
|
17921
|
+
var import_core78 = require("@graphrefly/pure-ts/core");
|
|
17305
17922
|
var import_graph23 = require("@graphrefly/pure-ts/graph");
|
|
17306
17923
|
var SNAPSHOT_WIRE_VERSION = import_graph23.SNAPSHOT_VERSION;
|
|
17307
17924
|
var SNAPSHOT_KEY_PREFIX = "snapshot:";
|
|
@@ -17370,7 +17987,7 @@ async function saveSnapshot(graph, snapshotId, tier2) {
|
|
|
17370
17987
|
name: graph.name,
|
|
17371
17988
|
mode: "full",
|
|
17372
17989
|
seq: 0,
|
|
17373
|
-
timestamp_ns: (0,
|
|
17990
|
+
timestamp_ns: (0, import_core78.wallClockNs)(),
|
|
17374
17991
|
format_version: SNAPSHOT_WIRE_VERSION,
|
|
17375
17992
|
snapshot
|
|
17376
17993
|
};
|