@graphrefly/graphrefly 0.47.0 → 0.47.1
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/{chunk-CGHORL6G.js → chunk-7ADWWI2T.js} +2 -2
- package/dist/{chunk-TNX5ZGDJ.js → chunk-B4AKFXGE.js} +4 -4
- package/dist/{chunk-FW23JYNQ.js → chunk-CEVNQ74M.js} +2 -2
- package/dist/{chunk-JGFRAFDL.js → chunk-FVINAAKA.js} +3 -3
- package/dist/{chunk-22SG74BD.js → chunk-J5WFUEO4.js} +2 -2
- package/dist/{chunk-GWRNLJNW.js → chunk-K7PDZYQE.js} +4 -4
- package/dist/{chunk-Z6EGP5D7.js → chunk-LDCSZ72P.js} +2 -2
- package/dist/{chunk-EHRRQ4IC.js → chunk-MTTRCEJT.js} +2 -2
- package/dist/{chunk-Q3EYOCZB.js → chunk-NPRP3MCV.js} +111 -2
- package/dist/chunk-NPRP3MCV.js.map +1 -0
- package/dist/{chunk-JKTC747G.js → chunk-RGMTUZCL.js} +3 -3
- package/dist/{chunk-ZVXXDWIB.js → chunk-U225SKB4.js} +455 -25
- package/dist/chunk-U225SKB4.js.map +1 -0
- package/dist/{chunk-ZT4WMQW4.js → chunk-V4Y3TM7U.js} +5 -5
- package/dist/{chunk-5IMMNARC.js → chunk-YXCPV26R.js} +2 -2
- package/dist/index.cjs +1374 -840
- 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 +35 -13
- package/dist/index.js.map +1 -1
- package/dist/presets/ai/index.cjs.map +1 -1
- package/dist/presets/ai/index.js +6 -6
- package/dist/presets/harness/index.cjs.map +1 -1
- package/dist/presets/harness/index.js +9 -9
- package/dist/presets/index.cjs.map +1 -1
- package/dist/presets/index.js +13 -13
- package/dist/presets/inspect/index.cjs.map +1 -1
- package/dist/presets/inspect/index.js +4 -4
- package/dist/solutions/index.cjs.map +1 -1
- package/dist/solutions/index.js +10 -10
- package/dist/utils/ai/index.cjs.map +1 -1
- package/dist/utils/ai/index.js +5 -5
- package/dist/utils/index.cjs +931 -397
- 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 +28 -6
- package/dist/utils/inspect/index.cjs.map +1 -1
- package/dist/utils/inspect/index.js +2 -2
- package/dist/utils/memory/index.cjs +462 -37
- package/dist/utils/memory/index.cjs.map +1 -1
- package/dist/utils/memory/index.d.cts +591 -2
- package/dist/utils/memory/index.d.ts +591 -2
- 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.map +1 -1
- package/dist/utils/orchestration/index.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-Q3EYOCZB.js.map +0 -1
- package/dist/chunk-ZVXXDWIB.js.map +0 -1
- /package/dist/{chunk-CGHORL6G.js.map → chunk-7ADWWI2T.js.map} +0 -0
- /package/dist/{chunk-TNX5ZGDJ.js.map → chunk-B4AKFXGE.js.map} +0 -0
- /package/dist/{chunk-FW23JYNQ.js.map → chunk-CEVNQ74M.js.map} +0 -0
- /package/dist/{chunk-JGFRAFDL.js.map → chunk-FVINAAKA.js.map} +0 -0
- /package/dist/{chunk-22SG74BD.js.map → chunk-J5WFUEO4.js.map} +0 -0
- /package/dist/{chunk-GWRNLJNW.js.map → chunk-K7PDZYQE.js.map} +0 -0
- /package/dist/{chunk-Z6EGP5D7.js.map → chunk-LDCSZ72P.js.map} +0 -0
- /package/dist/{chunk-EHRRQ4IC.js.map → chunk-MTTRCEJT.js.map} +0 -0
- /package/dist/{chunk-JKTC747G.js.map → chunk-RGMTUZCL.js.map} +0 -0
- /package/dist/{chunk-ZT4WMQW4.js.map → chunk-V4Y3TM7U.js.map} +0 -0
- /package/dist/{chunk-5IMMNARC.js.map → chunk-YXCPV26R.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];
|
|
@@ -378,6 +378,7 @@ __export(utils_exports, {
|
|
|
378
378
|
JobFlowGraph: () => JobFlowGraph,
|
|
379
379
|
JobQueueGraph: () => JobQueueGraph,
|
|
380
380
|
LLMTimeoutError: () => LLMTimeoutError,
|
|
381
|
+
LogProjectorGraph: () => LogProjectorGraph,
|
|
381
382
|
MemoryRetrievalGraph: () => MemoryRetrievalGraph,
|
|
382
383
|
MemoryWithKGGraph: () => MemoryWithKGGraph,
|
|
383
384
|
MemoryWithTiersGraph: () => MemoryWithTiersGraph,
|
|
@@ -414,6 +415,7 @@ __export(utils_exports, {
|
|
|
414
415
|
actuatorExecutor: () => actuatorExecutor,
|
|
415
416
|
adaptiveRateLimiter: () => adaptiveRateLimiter,
|
|
416
417
|
admissionFilter3D: () => admissionFilter3D,
|
|
418
|
+
admissionLlmJudge: () => admissionLlmJudge,
|
|
417
419
|
admissionScored: () => admissionScored,
|
|
418
420
|
affectedTaskFilter: () => affectedTaskFilter,
|
|
419
421
|
analyzeAndMeasure: () => analyzeAndMeasure,
|
|
@@ -422,6 +424,7 @@ __export(utils_exports, {
|
|
|
422
424
|
auditTrail: () => auditTrail,
|
|
423
425
|
autoSolidify: () => autoSolidify,
|
|
424
426
|
beforeAfterCompare: () => beforeAfterCompare,
|
|
427
|
+
bitemporalQuery: () => bitemporalQuery,
|
|
425
428
|
budgetGate: () => budgetGate,
|
|
426
429
|
carveTextLineSlots: () => carveTextLineSlots,
|
|
427
430
|
cascadingLlmAdapter: () => cascadingLlmAdapter,
|
|
@@ -440,6 +443,7 @@ __export(utils_exports, {
|
|
|
440
443
|
computeLineBreaks: () => computeLineBreaks,
|
|
441
444
|
computePrice: () => computePrice,
|
|
442
445
|
computeTotalHeight: () => computeTotalHeight,
|
|
446
|
+
consolidationRem: () => consolidationRem,
|
|
443
447
|
contentGate: () => contentGate,
|
|
444
448
|
contentModerationGraph: () => contentModerationGraph,
|
|
445
449
|
cosineSimilarity: () => cosineSimilarity,
|
|
@@ -452,6 +456,7 @@ __export(utils_exports, {
|
|
|
452
456
|
createIntakeBridge: () => createIntakeBridge,
|
|
453
457
|
createPricingRegistry: () => createPricingRegistry,
|
|
454
458
|
dataQualityGraph: () => dataQualityGraph,
|
|
459
|
+
decayExponential: () => decayExponential,
|
|
455
460
|
decisionKeyOf: () => decisionKeyOf,
|
|
456
461
|
decompileSpec: () => decompileSpec,
|
|
457
462
|
defaultErrorClassifier: () => defaultErrorClassifier,
|
|
@@ -481,6 +486,8 @@ __export(utils_exports, {
|
|
|
481
486
|
healthReportEqual: () => healthReportEqual,
|
|
482
487
|
hubRemoveTopicKeyOf: () => hubRemoveTopicKeyOf,
|
|
483
488
|
humanInput: () => humanInput,
|
|
489
|
+
influenceAnalysis: () => influenceAnalysis,
|
|
490
|
+
invalidationTracer: () => invalidationTracer,
|
|
484
491
|
isRichFnEntry: () => isRichFnEntry,
|
|
485
492
|
isRichSourceEntry: () => isRichSourceEntry,
|
|
486
493
|
issueTrackerGraph: () => issueTrackerGraph,
|
|
@@ -496,6 +503,7 @@ __export(utils_exports, {
|
|
|
496
503
|
llmConsolidator: () => llmConsolidator,
|
|
497
504
|
llmExtractor: () => llmExtractor,
|
|
498
505
|
llmRefine: () => llmRefine,
|
|
506
|
+
logProjector: () => logProjector,
|
|
499
507
|
measureBlock: () => measureBlock,
|
|
500
508
|
measureBlocks: () => measureBlocks,
|
|
501
509
|
memoryRetrieval: () => memoryRetrieval,
|
|
@@ -508,6 +516,7 @@ __export(utils_exports, {
|
|
|
508
516
|
observableAdapter: () => observableAdapter,
|
|
509
517
|
openAICompatAdapter: () => openAICompatAdapter,
|
|
510
518
|
parseRateLimitFromError: () => parseRateLimitFromError,
|
|
519
|
+
persistentReactiveFactStore: () => persistentReactiveFactStore,
|
|
511
520
|
pipelineGraph: () => pipelineGraph,
|
|
512
521
|
policyGate: () => policyGate,
|
|
513
522
|
pricingFor: () => pricingFor,
|
|
@@ -533,6 +542,8 @@ __export(utils_exports, {
|
|
|
533
542
|
sagaInvocationKeyOf: () => sagaInvocationKeyOf,
|
|
534
543
|
saveSnapshot: () => saveSnapshot,
|
|
535
544
|
scorer: () => scorer,
|
|
545
|
+
scoringByOutcome: () => scoringByOutcome,
|
|
546
|
+
shardByTenant: () => shardByTenant,
|
|
536
547
|
specDiff: () => specDiff,
|
|
537
548
|
strategyKey: () => strategyKey,
|
|
538
549
|
strategyModel: () => strategyModel,
|
|
@@ -6079,6 +6090,113 @@ function subscription(name, topicGraph, opts) {
|
|
|
6079
6090
|
function topicBridge(name, sourceTopic, targetTopic, opts) {
|
|
6080
6091
|
return new TopicBridgeGraph(name, sourceTopic, targetTopic, opts);
|
|
6081
6092
|
}
|
|
6093
|
+
var LogProjectorGraph = class extends import_graph2.Graph {
|
|
6094
|
+
/** Reactive count of fully-projected entries (the cursor; read-only). */
|
|
6095
|
+
position;
|
|
6096
|
+
/**
|
|
6097
|
+
* Poison entries (populated when `onPoison: "deadLetter"`). A real topic —
|
|
6098
|
+
* subscribable + visible in `describe()`.
|
|
6099
|
+
*/
|
|
6100
|
+
deadLetter;
|
|
6101
|
+
_inFlight = Promise.resolve();
|
|
6102
|
+
constructor(name, source, opts) {
|
|
6103
|
+
super(name, opts.graph);
|
|
6104
|
+
const onPoison = opts.onPoison ?? "halt";
|
|
6105
|
+
const sink = opts.sink;
|
|
6106
|
+
const dl = new TopicGraph(`${name}_dead_letter`, {
|
|
6107
|
+
retainedLimit: opts.deadLetterRetainedLimit ?? DEFAULT_TOPIC_RETAINED_LIMIT
|
|
6108
|
+
});
|
|
6109
|
+
this.mount("deadLetter", dl);
|
|
6110
|
+
this.deadLetter = dl;
|
|
6111
|
+
let available;
|
|
6112
|
+
let cursorBase;
|
|
6113
|
+
let advance;
|
|
6114
|
+
if (source instanceof TopicGraph) {
|
|
6115
|
+
const sub = new SubscriptionGraph(`${name}_subscription`, source, {
|
|
6116
|
+
from: opts.from ?? "retained"
|
|
6117
|
+
});
|
|
6118
|
+
this.mount("subscription", sub);
|
|
6119
|
+
available = sub.available;
|
|
6120
|
+
this.position = sub.cursor;
|
|
6121
|
+
cursorBase = () => sub.cursor.cache;
|
|
6122
|
+
advance = (n) => {
|
|
6123
|
+
if (n > 0) sub.ack(n);
|
|
6124
|
+
};
|
|
6125
|
+
} else {
|
|
6126
|
+
const log = source;
|
|
6127
|
+
let initialCursor;
|
|
6128
|
+
if (opts.from === "now") {
|
|
6129
|
+
initialCursor = log.size;
|
|
6130
|
+
} else if (typeof opts.from === "number") {
|
|
6131
|
+
initialCursor = requireNonNegativeInt(opts.from, "logProjector from");
|
|
6132
|
+
} else {
|
|
6133
|
+
initialCursor = 0;
|
|
6134
|
+
}
|
|
6135
|
+
const cursor = this.state("cursor", initialCursor, {
|
|
6136
|
+
meta: messagingMeta("log_projector_cursor")
|
|
6137
|
+
});
|
|
6138
|
+
this.position = cursor;
|
|
6139
|
+
cursorBase = () => cursor.cache;
|
|
6140
|
+
available = log.view({ kind: "fromCursor", cursor });
|
|
6141
|
+
advance = (n) => {
|
|
6142
|
+
if (n > 0) cursor.emit(cursor.cache + n);
|
|
6143
|
+
};
|
|
6144
|
+
}
|
|
6145
|
+
let halted = false;
|
|
6146
|
+
const runDrain = async () => {
|
|
6147
|
+
if (halted) return;
|
|
6148
|
+
const snapshot = available.cache ?? [];
|
|
6149
|
+
if (snapshot.length === 0) return;
|
|
6150
|
+
let consumed = 0;
|
|
6151
|
+
for (let i = 0; i < snapshot.length; i += 1) {
|
|
6152
|
+
const item = snapshot[i];
|
|
6153
|
+
try {
|
|
6154
|
+
await sink(item);
|
|
6155
|
+
consumed += 1;
|
|
6156
|
+
} catch (e) {
|
|
6157
|
+
const error = e instanceof Error ? e.message : String(e);
|
|
6158
|
+
if (onPoison === "deadLetter") {
|
|
6159
|
+
dl.publish({ item, error, cursorPos: cursorBase() + consumed });
|
|
6160
|
+
consumed += 1;
|
|
6161
|
+
continue;
|
|
6162
|
+
}
|
|
6163
|
+
halted = true;
|
|
6164
|
+
break;
|
|
6165
|
+
}
|
|
6166
|
+
}
|
|
6167
|
+
if (consumed > 0) advance(consumed);
|
|
6168
|
+
};
|
|
6169
|
+
const schedule = () => {
|
|
6170
|
+
if (halted) return;
|
|
6171
|
+
this._inFlight = this._inFlight.then(runDrain, runDrain);
|
|
6172
|
+
};
|
|
6173
|
+
const drain = (0, import_core30.node)(
|
|
6174
|
+
[available],
|
|
6175
|
+
(batchData, _actions, ctx) => {
|
|
6176
|
+
const b = batchData[0];
|
|
6177
|
+
const snap = b != null && b.length > 0 ? b.at(-1) : ctx.prevData[0];
|
|
6178
|
+
if (snap && snap.length > 0) schedule();
|
|
6179
|
+
},
|
|
6180
|
+
{
|
|
6181
|
+
name: "drain",
|
|
6182
|
+
describeKind: "effect",
|
|
6183
|
+
meta: messagingMeta("log_projector_drain")
|
|
6184
|
+
}
|
|
6185
|
+
);
|
|
6186
|
+
this.add(drain, { name: "drain" });
|
|
6187
|
+
this.addDisposer((0, import_extra21.keepalive)(drain));
|
|
6188
|
+
}
|
|
6189
|
+
/**
|
|
6190
|
+
* Await any in-flight drain pass. **Test convenience only** — the canonical
|
|
6191
|
+
* reactive observable is {@link LogProjectorGraph.position}.
|
|
6192
|
+
*/
|
|
6193
|
+
idle() {
|
|
6194
|
+
return this._inFlight;
|
|
6195
|
+
}
|
|
6196
|
+
};
|
|
6197
|
+
function logProjector(name, source, opts) {
|
|
6198
|
+
return new LogProjectorGraph(name, source, opts);
|
|
6199
|
+
}
|
|
6082
6200
|
|
|
6083
6201
|
// src/utils/orchestration/human-input.ts
|
|
6084
6202
|
var import_core31 = require("@graphrefly/pure-ts/core");
|
|
@@ -7609,8 +7727,8 @@ function admissionFilter3D(opts) {
|
|
|
7609
7727
|
}
|
|
7610
7728
|
|
|
7611
7729
|
// src/utils/ai/memory/memory-composers.ts
|
|
7612
|
-
var
|
|
7613
|
-
var
|
|
7730
|
+
var import_core57 = require("@graphrefly/pure-ts/core");
|
|
7731
|
+
var import_extra40 = require("@graphrefly/pure-ts/extra");
|
|
7614
7732
|
var import_graph8 = require("@graphrefly/pure-ts/graph");
|
|
7615
7733
|
|
|
7616
7734
|
// src/base/composition/distill.ts
|
|
@@ -7640,8 +7758,8 @@ function forEach(source, fn, opts) {
|
|
|
7640
7758
|
function isNodeLike2(value) {
|
|
7641
7759
|
return typeof value === "object" && value !== null && "cache" in value && typeof value.subscribe === "function";
|
|
7642
7760
|
}
|
|
7643
|
-
function keepalive9(
|
|
7644
|
-
|
|
7761
|
+
function keepalive9(node65) {
|
|
7762
|
+
node65.subscribe(() => void 0);
|
|
7645
7763
|
}
|
|
7646
7764
|
function mapFromSnapshot(snapshot) {
|
|
7647
7765
|
if (snapshot instanceof Map) return snapshot;
|
|
@@ -7782,8 +7900,8 @@ function decay(baseScore, ageSeconds2, ratePerSecond, minScore = 0) {
|
|
|
7782
7900
|
}
|
|
7783
7901
|
|
|
7784
7902
|
// src/utils/memory/index.ts
|
|
7785
|
-
var
|
|
7786
|
-
var
|
|
7903
|
+
var import_core56 = require("@graphrefly/pure-ts/core");
|
|
7904
|
+
var import_extra39 = require("@graphrefly/pure-ts/extra");
|
|
7787
7905
|
var import_graph7 = require("@graphrefly/pure-ts/graph");
|
|
7788
7906
|
|
|
7789
7907
|
// src/utils/memory/fact-store.ts
|
|
@@ -8270,14 +8388,430 @@ function reactiveFactStore(config) {
|
|
|
8270
8388
|
return out;
|
|
8271
8389
|
}
|
|
8272
8390
|
|
|
8391
|
+
// src/utils/memory/persistent-fact-store.ts
|
|
8392
|
+
var import_core49 = require("@graphrefly/pure-ts/core");
|
|
8393
|
+
var import_extra34 = require("@graphrefly/pure-ts/extra");
|
|
8394
|
+
function persistMeta(kind) {
|
|
8395
|
+
return domainMeta("memory", kind);
|
|
8396
|
+
}
|
|
8397
|
+
function persistentReactiveFactStore(config) {
|
|
8398
|
+
const persistName = config.persistName ?? "fact_store_ingest";
|
|
8399
|
+
const codec = config.codec ?? (0, import_extra34.bigintJsonCodecFor)();
|
|
8400
|
+
const tier2 = (0, import_extra34.appendLogStorage)(config.storage, {
|
|
8401
|
+
name: persistName,
|
|
8402
|
+
codec
|
|
8403
|
+
});
|
|
8404
|
+
const store = reactiveFactStore({ ...config, recordIngest: true });
|
|
8405
|
+
const ingestLog = store.ingestLog;
|
|
8406
|
+
async function* loadHistory() {
|
|
8407
|
+
if (typeof tier2.loadEntries !== "function") return;
|
|
8408
|
+
const page = await tier2.loadEntries();
|
|
8409
|
+
for (const f of page.entries) yield f;
|
|
8410
|
+
}
|
|
8411
|
+
const replaySource = (0, import_extra34.fromAny)(loadHistory(), {
|
|
8412
|
+
name: "_replay_source",
|
|
8413
|
+
meta: persistMeta("persist_replay_source")
|
|
8414
|
+
});
|
|
8415
|
+
store.add(replaySource, { name: "_replay_source" });
|
|
8416
|
+
let replayed = 0;
|
|
8417
|
+
const replayPump = (0, import_core49.node)(
|
|
8418
|
+
[replaySource],
|
|
8419
|
+
(batchData, actions) => {
|
|
8420
|
+
const b = batchData[0];
|
|
8421
|
+
if (b != null && b.length > 0) {
|
|
8422
|
+
for (const f of b) {
|
|
8423
|
+
config.ingest.emit(f);
|
|
8424
|
+
replayed += 1;
|
|
8425
|
+
}
|
|
8426
|
+
actions.emit(replayed);
|
|
8427
|
+
}
|
|
8428
|
+
},
|
|
8429
|
+
{
|
|
8430
|
+
name: "_replay_pump",
|
|
8431
|
+
describeKind: "derived",
|
|
8432
|
+
initial: 0,
|
|
8433
|
+
meta: persistMeta("persist_replay_pump")
|
|
8434
|
+
}
|
|
8435
|
+
);
|
|
8436
|
+
store.add(replayPump, { name: "_replay_pump" });
|
|
8437
|
+
store.addDisposer((0, import_extra34.keepalive)(replayPump));
|
|
8438
|
+
const attached = (0, import_core49.node)([], {
|
|
8439
|
+
initial: false,
|
|
8440
|
+
name: "_storage_attached",
|
|
8441
|
+
describeKind: "state",
|
|
8442
|
+
meta: persistMeta("persist_attached")
|
|
8443
|
+
});
|
|
8444
|
+
store.add(attached, { name: "_storage_attached" });
|
|
8445
|
+
store.addDisposer((0, import_extra34.keepalive)(attached));
|
|
8446
|
+
let detachStorage;
|
|
8447
|
+
const replaySub = replaySource.subscribe((msgs) => {
|
|
8448
|
+
for (const m of msgs) {
|
|
8449
|
+
if (m[0] === import_core49.COMPLETE && detachStorage === void 0) {
|
|
8450
|
+
const sizeAtAttach = ingestLog.size;
|
|
8451
|
+
detachStorage = ingestLog.attachStorage([tier2]);
|
|
8452
|
+
if (sizeAtAttach > replayed) {
|
|
8453
|
+
const slice = [];
|
|
8454
|
+
for (let i = replayed; i < sizeAtAttach; i += 1) {
|
|
8455
|
+
const v = ingestLog.at(i);
|
|
8456
|
+
if (v === void 0) {
|
|
8457
|
+
throw new Error(
|
|
8458
|
+
`persistentReactiveFactStore: ingestLog hole at index ${i} in reconciliation slice [${replayed}, ${sizeAtAttach}); pre-attach-live durability cannot be guaranteed.`
|
|
8459
|
+
);
|
|
8460
|
+
}
|
|
8461
|
+
slice.push(v);
|
|
8462
|
+
}
|
|
8463
|
+
if (slice.length > 0) {
|
|
8464
|
+
const r = tier2.appendEntries(slice);
|
|
8465
|
+
if (r instanceof Promise) r.catch(() => {
|
|
8466
|
+
});
|
|
8467
|
+
}
|
|
8468
|
+
}
|
|
8469
|
+
attached.emit(true);
|
|
8470
|
+
}
|
|
8471
|
+
}
|
|
8472
|
+
});
|
|
8473
|
+
store.addDisposer(() => {
|
|
8474
|
+
replaySub();
|
|
8475
|
+
detachStorage?.();
|
|
8476
|
+
});
|
|
8477
|
+
const position = (0, import_core49.node)(
|
|
8478
|
+
[ingestLog.entries, attached],
|
|
8479
|
+
(batchData, actions, ctx) => {
|
|
8480
|
+
const eb = batchData[0];
|
|
8481
|
+
const arr = eb != null && eb.length > 0 ? eb.at(-1) : ctx.prevData[0];
|
|
8482
|
+
const ab = batchData[1];
|
|
8483
|
+
const isAttached = ab != null && ab.length > 0 ? ab.at(-1) : ctx.prevData[1];
|
|
8484
|
+
actions.emit(isAttached === true ? arr?.length ?? 0 : 0);
|
|
8485
|
+
},
|
|
8486
|
+
{
|
|
8487
|
+
name: "_durable_position",
|
|
8488
|
+
describeKind: "derived",
|
|
8489
|
+
initial: 0,
|
|
8490
|
+
meta: persistMeta("persist_position")
|
|
8491
|
+
}
|
|
8492
|
+
);
|
|
8493
|
+
store.add(position, { name: "_durable_position" });
|
|
8494
|
+
store.addDisposer((0, import_extra34.keepalive)(position));
|
|
8495
|
+
const out = Object.assign(store, {
|
|
8496
|
+
position,
|
|
8497
|
+
replayedCount: replayPump,
|
|
8498
|
+
tier: tier2,
|
|
8499
|
+
async flush() {
|
|
8500
|
+
await tier2.flush?.();
|
|
8501
|
+
}
|
|
8502
|
+
});
|
|
8503
|
+
return out;
|
|
8504
|
+
}
|
|
8505
|
+
|
|
8506
|
+
// src/utils/memory/recipes/admission-llm-judge.ts
|
|
8507
|
+
var import_core50 = require("@graphrefly/pure-ts/core");
|
|
8508
|
+
function admissionLlmJudge(verdicts, opts = {}) {
|
|
8509
|
+
const dflt = opts.defaultVerdict ?? false;
|
|
8510
|
+
const buildFilter = (m) => (f) => m.get(f.id) ?? dflt;
|
|
8511
|
+
return (0, import_core50.node)(
|
|
8512
|
+
[verdicts],
|
|
8513
|
+
(batchData, actions, ctx) => {
|
|
8514
|
+
const m = batchData[0]?.at(-1) ?? ctx.prevData[0] ?? /* @__PURE__ */ new Map();
|
|
8515
|
+
actions.emit(buildFilter(m));
|
|
8516
|
+
},
|
|
8517
|
+
{
|
|
8518
|
+
name: opts.name ?? "admission_llm_judge",
|
|
8519
|
+
describeKind: "derived",
|
|
8520
|
+
// Before any verdict arrives, apply the default policy.
|
|
8521
|
+
initial: buildFilter(/* @__PURE__ */ new Map())
|
|
8522
|
+
}
|
|
8523
|
+
);
|
|
8524
|
+
}
|
|
8525
|
+
|
|
8526
|
+
// src/utils/memory/recipes/bitemporal-query.ts
|
|
8527
|
+
var import_core51 = require("@graphrefly/pure-ts/core");
|
|
8528
|
+
|
|
8529
|
+
// src/utils/memory/recipes/_shared.ts
|
|
8530
|
+
function lastOf2(batch14, prev) {
|
|
8531
|
+
return batch14 != null && batch14.length > 0 ? batch14.at(-1) : prev;
|
|
8532
|
+
}
|
|
8533
|
+
function validAt(f, asOf) {
|
|
8534
|
+
if (asOf === void 0) return f.validTo === void 0;
|
|
8535
|
+
if (f.validFrom !== void 0 && asOf < f.validFrom) return false;
|
|
8536
|
+
if (f.validTo !== void 0 && asOf >= f.validTo) return false;
|
|
8537
|
+
return true;
|
|
8538
|
+
}
|
|
8539
|
+
|
|
8540
|
+
// src/utils/memory/recipes/bitemporal-query.ts
|
|
8541
|
+
function bitemporalQuery(mem, asOf, opts = {}) {
|
|
8542
|
+
const asOfOrNull = (0, import_core51.node)(
|
|
8543
|
+
[asOf],
|
|
8544
|
+
(b, a, c) => a.emit(lastOf2(b[0], c.prevData[0]) ?? null),
|
|
8545
|
+
{ name: `${opts.name ?? "bitemporal_query"}_asof`, describeKind: "derived", initial: null }
|
|
8546
|
+
);
|
|
8547
|
+
return (0, import_core51.node)(
|
|
8548
|
+
[asOfOrNull, mem.factStore],
|
|
8549
|
+
(batchData, actions, ctx) => {
|
|
8550
|
+
const raw = lastOf2(batchData[0], ctx.prevData[0]);
|
|
8551
|
+
const at = raw ?? void 0;
|
|
8552
|
+
const fs = lastOf2(batchData[1], ctx.prevData[1]);
|
|
8553
|
+
if (fs == null) {
|
|
8554
|
+
actions.emit([]);
|
|
8555
|
+
return;
|
|
8556
|
+
}
|
|
8557
|
+
const results = [...fs.byId.values()].filter((f) => {
|
|
8558
|
+
if (!validAt(f, at)) return false;
|
|
8559
|
+
if (opts.tags && opts.tags.length > 0 && !opts.tags.some((t) => f.tags.includes(t))) {
|
|
8560
|
+
return false;
|
|
8561
|
+
}
|
|
8562
|
+
if (opts.minConfidence !== void 0 && f.confidence < opts.minConfidence) return false;
|
|
8563
|
+
return true;
|
|
8564
|
+
});
|
|
8565
|
+
results.sort((a, b) => b.confidence - a.confidence || Number(b.t_ns - a.t_ns));
|
|
8566
|
+
actions.emit(results);
|
|
8567
|
+
},
|
|
8568
|
+
{
|
|
8569
|
+
name: opts.name ?? "bitemporal_query",
|
|
8570
|
+
describeKind: "derived",
|
|
8571
|
+
initial: []
|
|
8572
|
+
}
|
|
8573
|
+
);
|
|
8574
|
+
}
|
|
8575
|
+
|
|
8576
|
+
// src/utils/memory/recipes/consolidation-rem.ts
|
|
8577
|
+
var import_extra35 = require("@graphrefly/pure-ts/extra");
|
|
8578
|
+
function consolidationRem(opts) {
|
|
8579
|
+
const consolidateTrigger = (0, import_extra35.fromTimer)(opts.periodMs, { period: opts.periodMs });
|
|
8580
|
+
const consolidate = (store) => {
|
|
8581
|
+
const live = [...store.values()].filter((f) => f.validTo === void 0);
|
|
8582
|
+
if (live.length === 0) return [];
|
|
8583
|
+
let pool = live;
|
|
8584
|
+
if (opts.recentWindowNs !== void 0) {
|
|
8585
|
+
const newest = live.reduce((m, f) => f.t_ns > m ? f.t_ns : m, live[0].t_ns);
|
|
8586
|
+
const cutoff = newest - opts.recentWindowNs;
|
|
8587
|
+
pool = live.filter((f) => f.t_ns >= cutoff);
|
|
8588
|
+
}
|
|
8589
|
+
pool.sort((a, b) => b.confidence - a.confidence || Number(b.t_ns - a.t_ns));
|
|
8590
|
+
const replayed = pool.slice(0, Math.max(0, opts.topK));
|
|
8591
|
+
return replayed.length > 0 ? opts.summarize(replayed) : [];
|
|
8592
|
+
};
|
|
8593
|
+
return { consolidateTrigger, consolidate };
|
|
8594
|
+
}
|
|
8595
|
+
|
|
8596
|
+
// src/utils/memory/recipes/decay-exponential.ts
|
|
8597
|
+
var import_core52 = require("@graphrefly/pure-ts/core");
|
|
8598
|
+
var import_extra36 = require("@graphrefly/pure-ts/extra");
|
|
8599
|
+
function decayExponential(mem, ingest, opts) {
|
|
8600
|
+
const floor = opts.floor ?? 0;
|
|
8601
|
+
const epsilon = Math.max(opts.epsilon ?? 1e-4, Number.EPSILON);
|
|
8602
|
+
const half = Number(opts.halfLifeNs);
|
|
8603
|
+
const lastTick = /* @__PURE__ */ new Map();
|
|
8604
|
+
const timer = (0, import_extra36.fromTimer)(opts.periodMs, { period: opts.periodMs });
|
|
8605
|
+
const driver = (0, import_core52.node)(
|
|
8606
|
+
[timer],
|
|
8607
|
+
(_batchData, actions) => {
|
|
8608
|
+
const fs = mem.factStore.cache;
|
|
8609
|
+
if (!fs) {
|
|
8610
|
+
actions.emit([]);
|
|
8611
|
+
return;
|
|
8612
|
+
}
|
|
8613
|
+
const now = BigInt((0, import_core52.wallClockNs)());
|
|
8614
|
+
const decayed = [];
|
|
8615
|
+
const liveIds = /* @__PURE__ */ new Set();
|
|
8616
|
+
for (const f of fs.byId.values()) {
|
|
8617
|
+
liveIds.add(f.id);
|
|
8618
|
+
if (f.validTo !== void 0) continue;
|
|
8619
|
+
if (f.confidence <= floor) continue;
|
|
8620
|
+
const lt = lastTick.get(f.id);
|
|
8621
|
+
const since = lt !== void 0 && lt >= f.t_ns ? lt : f.t_ns;
|
|
8622
|
+
const elapsed = Number(now - since);
|
|
8623
|
+
if (elapsed <= 0) continue;
|
|
8624
|
+
const factor = 0.5 ** (half > 0 ? elapsed / half : 0);
|
|
8625
|
+
if (!Number.isFinite(factor)) continue;
|
|
8626
|
+
let next = f.confidence * factor;
|
|
8627
|
+
if (next < floor) next = floor;
|
|
8628
|
+
if (f.confidence - next < epsilon) continue;
|
|
8629
|
+
const liveNow = mem.factStore.cache?.byId.get(f.id);
|
|
8630
|
+
if (liveNow && liveNow.validTo !== void 0) continue;
|
|
8631
|
+
lastTick.set(f.id, now);
|
|
8632
|
+
const drifted = { ...f, confidence: next };
|
|
8633
|
+
decayed.push(drifted);
|
|
8634
|
+
ingest.emit(drifted);
|
|
8635
|
+
}
|
|
8636
|
+
if (lastTick.size > liveIds.size) {
|
|
8637
|
+
for (const id of lastTick.keys()) if (!liveIds.has(id)) lastTick.delete(id);
|
|
8638
|
+
}
|
|
8639
|
+
actions.emit(decayed);
|
|
8640
|
+
},
|
|
8641
|
+
{
|
|
8642
|
+
name: opts.name ?? "decay_exponential",
|
|
8643
|
+
describeKind: "derived",
|
|
8644
|
+
initial: []
|
|
8645
|
+
}
|
|
8646
|
+
);
|
|
8647
|
+
mem.add(driver, { name: opts.name ?? "decay_exponential" });
|
|
8648
|
+
mem.addDisposer((0, import_extra36.keepalive)(timer));
|
|
8649
|
+
mem.addDisposer((0, import_extra36.keepalive)(driver));
|
|
8650
|
+
return driver;
|
|
8651
|
+
}
|
|
8652
|
+
|
|
8653
|
+
// src/utils/memory/recipes/influence-analysis.ts
|
|
8654
|
+
var import_core53 = require("@graphrefly/pure-ts/core");
|
|
8655
|
+
var import_extra37 = require("@graphrefly/pure-ts/extra");
|
|
8656
|
+
function closureOf(index, root) {
|
|
8657
|
+
const seen = /* @__PURE__ */ new Set();
|
|
8658
|
+
const queue = [root];
|
|
8659
|
+
while (queue.length > 0) {
|
|
8660
|
+
const cur = queue.shift();
|
|
8661
|
+
for (const dep of index.get(cur) ?? []) {
|
|
8662
|
+
if (seen.has(dep) || dep === root) continue;
|
|
8663
|
+
seen.add(dep);
|
|
8664
|
+
queue.push(dep);
|
|
8665
|
+
}
|
|
8666
|
+
}
|
|
8667
|
+
return [...seen];
|
|
8668
|
+
}
|
|
8669
|
+
function influenceAnalysis(mem, opts = {}) {
|
|
8670
|
+
const prefix = opts.name ?? "influence";
|
|
8671
|
+
const maxRanked = Math.max(1, opts.maxRanked ?? 64);
|
|
8672
|
+
const ranked = (0, import_core53.node)(
|
|
8673
|
+
[mem.dependentsIndex],
|
|
8674
|
+
(batchData, actions, ctx) => {
|
|
8675
|
+
const index = lastOf2(batchData[0], ctx.prevData[0]);
|
|
8676
|
+
if (index == null) {
|
|
8677
|
+
actions.emit([]);
|
|
8678
|
+
return;
|
|
8679
|
+
}
|
|
8680
|
+
const rows = [];
|
|
8681
|
+
for (const key of index.keys()) {
|
|
8682
|
+
rows.push({ factId: key, influence: closureOf(index, key).length });
|
|
8683
|
+
}
|
|
8684
|
+
rows.sort((a, b) => b.influence - a.influence);
|
|
8685
|
+
actions.emit(rows.slice(0, maxRanked));
|
|
8686
|
+
},
|
|
8687
|
+
{
|
|
8688
|
+
name: `${prefix}_ranked`,
|
|
8689
|
+
describeKind: "derived",
|
|
8690
|
+
initial: []
|
|
8691
|
+
}
|
|
8692
|
+
);
|
|
8693
|
+
mem.add(ranked, { name: `${prefix}_ranked` });
|
|
8694
|
+
mem.addDisposer((0, import_extra37.keepalive)(ranked));
|
|
8695
|
+
const builtFor = /* @__PURE__ */ new Map();
|
|
8696
|
+
function influenceOf(rootId) {
|
|
8697
|
+
const existing = builtFor.get(rootId);
|
|
8698
|
+
if (existing) return existing;
|
|
8699
|
+
const n = (0, import_core53.node)(
|
|
8700
|
+
[mem.dependentsIndex],
|
|
8701
|
+
(batchData, actions, ctx) => {
|
|
8702
|
+
const index = lastOf2(batchData[0], ctx.prevData[0]);
|
|
8703
|
+
actions.emit(index == null ? [] : closureOf(index, rootId));
|
|
8704
|
+
},
|
|
8705
|
+
{
|
|
8706
|
+
name: `${prefix}_of_${rootId}`,
|
|
8707
|
+
describeKind: "derived",
|
|
8708
|
+
initial: []
|
|
8709
|
+
}
|
|
8710
|
+
);
|
|
8711
|
+
mem.add(n, { name: `${prefix}_of_${rootId}` });
|
|
8712
|
+
mem.addDisposer((0, import_extra37.keepalive)(n));
|
|
8713
|
+
builtFor.set(rootId, n);
|
|
8714
|
+
return n;
|
|
8715
|
+
}
|
|
8716
|
+
return { influenceOf, ranked };
|
|
8717
|
+
}
|
|
8718
|
+
|
|
8719
|
+
// src/utils/memory/recipes/invalidation-tracer.ts
|
|
8720
|
+
var import_core54 = require("@graphrefly/pure-ts/core");
|
|
8721
|
+
var import_extra38 = require("@graphrefly/pure-ts/extra");
|
|
8722
|
+
function invalidationTracer(mem, opts = {}) {
|
|
8723
|
+
const limit = Math.max(1, opts.limit ?? 256);
|
|
8724
|
+
const ring = [];
|
|
8725
|
+
const push = (e) => {
|
|
8726
|
+
ring.push(e);
|
|
8727
|
+
if (ring.length > limit) ring.splice(0, ring.length - limit);
|
|
8728
|
+
};
|
|
8729
|
+
const tracer = (0, import_core54.node)(
|
|
8730
|
+
[mem.cascade, mem.cascadeOverflow],
|
|
8731
|
+
(batchData, actions) => {
|
|
8732
|
+
const cascadeWaves = batchData[0] ?? [];
|
|
8733
|
+
for (const wave of cascadeWaves) {
|
|
8734
|
+
for (const ev of wave) {
|
|
8735
|
+
push({
|
|
8736
|
+
kind: "cascade",
|
|
8737
|
+
factId: ev.factId,
|
|
8738
|
+
rootFactId: ev.rootFactId,
|
|
8739
|
+
reason: ev.reason,
|
|
8740
|
+
iteration: ev.iteration,
|
|
8741
|
+
causalReason: ev.causalReason
|
|
8742
|
+
});
|
|
8743
|
+
}
|
|
8744
|
+
}
|
|
8745
|
+
const overflows = batchData[1] ?? [];
|
|
8746
|
+
for (const ov of overflows) {
|
|
8747
|
+
if (ov == null) continue;
|
|
8748
|
+
push({
|
|
8749
|
+
kind: "overflow",
|
|
8750
|
+
factId: ov.sample[0] ?? "",
|
|
8751
|
+
rootFactId: ov.rootFactId,
|
|
8752
|
+
reason: "overflow",
|
|
8753
|
+
causalReason: `cascade overflow: ${ov.droppedCount} dropped (root ${ov.rootFactId})`
|
|
8754
|
+
});
|
|
8755
|
+
}
|
|
8756
|
+
actions.emit([...ring]);
|
|
8757
|
+
},
|
|
8758
|
+
{
|
|
8759
|
+
name: opts.name ?? "invalidation_tracer",
|
|
8760
|
+
describeKind: "derived",
|
|
8761
|
+
initial: []
|
|
8762
|
+
}
|
|
8763
|
+
);
|
|
8764
|
+
mem.add(tracer, { name: opts.name ?? "invalidation_tracer" });
|
|
8765
|
+
mem.addDisposer((0, import_extra38.keepalive)(tracer));
|
|
8766
|
+
return tracer;
|
|
8767
|
+
}
|
|
8768
|
+
|
|
8769
|
+
// src/utils/memory/recipes/scoring-by-outcome.ts
|
|
8770
|
+
var import_core55 = require("@graphrefly/pure-ts/core");
|
|
8771
|
+
var clamp01 = (n) => n < 0 ? 0 : n > 1 ? 1 : n;
|
|
8772
|
+
function scoringByOutcome(outcomes, opts = {}) {
|
|
8773
|
+
const base = opts.base ?? ((f) => f.confidence);
|
|
8774
|
+
const learningRate = opts.learningRate ?? 1;
|
|
8775
|
+
const acc = /* @__PURE__ */ new Map();
|
|
8776
|
+
const buildPolicy = () => (fragment) => clamp01(base(fragment) + learningRate * (acc.get(fragment.id) ?? 0));
|
|
8777
|
+
return (0, import_core55.node)(
|
|
8778
|
+
[outcomes],
|
|
8779
|
+
(batchData, actions) => {
|
|
8780
|
+
const wave = batchData[0] ?? [];
|
|
8781
|
+
for (const sig of wave) acc.set(sig.factId, (acc.get(sig.factId) ?? 0) + sig.reward);
|
|
8782
|
+
actions.emit(buildPolicy());
|
|
8783
|
+
},
|
|
8784
|
+
{
|
|
8785
|
+
name: opts.name ?? "scoring_by_outcome",
|
|
8786
|
+
describeKind: "derived",
|
|
8787
|
+
// Usable scorer before any outcome arrives (base-only).
|
|
8788
|
+
initial: buildPolicy()
|
|
8789
|
+
}
|
|
8790
|
+
);
|
|
8791
|
+
}
|
|
8792
|
+
|
|
8793
|
+
// src/utils/memory/recipes/shard-by-tenant.ts
|
|
8794
|
+
function shardByTenant(tenantOf, opts = {}) {
|
|
8795
|
+
if (opts.tenants && opts.tenants.length > 0) {
|
|
8796
|
+
const idx = new Map(opts.tenants.map((t, i) => [t, i]));
|
|
8797
|
+
const overflow = opts.tenants.length;
|
|
8798
|
+
return {
|
|
8799
|
+
shardBy: (f) => idx.get(tenantOf(f)) ?? overflow,
|
|
8800
|
+
shardCount: opts.tenants.length + 1
|
|
8801
|
+
};
|
|
8802
|
+
}
|
|
8803
|
+
const shardCount = Math.max(1, opts.shardCount ?? 4);
|
|
8804
|
+
return { shardBy: (f) => tenantOf(f), shardCount };
|
|
8805
|
+
}
|
|
8806
|
+
|
|
8273
8807
|
// src/utils/memory/index.ts
|
|
8274
8808
|
var NS_PER_SEC2 = 1e9;
|
|
8275
8809
|
function memoryMeta(kind, extra) {
|
|
8276
8810
|
return domainMeta("memory", kind, extra);
|
|
8277
8811
|
}
|
|
8278
8812
|
function toNode(v, name) {
|
|
8279
|
-
if (v instanceof
|
|
8280
|
-
return (0,
|
|
8813
|
+
if (v instanceof import_core56.NodeImpl) return v;
|
|
8814
|
+
return (0, import_core56.node)([], { initial: v, ...name ? { name } : void 0 });
|
|
8281
8815
|
}
|
|
8282
8816
|
function ageSeconds(now, lastNs) {
|
|
8283
8817
|
return (now - lastNs) / NS_PER_SEC2;
|
|
@@ -8331,14 +8865,14 @@ function collection(name, opts = {}) {
|
|
|
8331
8865
|
}
|
|
8332
8866
|
const scoreFnDefault = () => ranked ? 1 : 0;
|
|
8333
8867
|
const scoreInput = opts.score ?? scoreFnDefault;
|
|
8334
|
-
const scoreNode = ranked && scoreInput instanceof
|
|
8868
|
+
const scoreNode = ranked && scoreInput instanceof import_core56.NodeImpl ? scoreInput : void 0;
|
|
8335
8869
|
const readScoreFn = () => {
|
|
8336
8870
|
if (scoreNode) return scoreNode.cache ?? scoreFnDefault;
|
|
8337
8871
|
return scoreInput;
|
|
8338
8872
|
};
|
|
8339
8873
|
const graph = new import_graph7.Graph(name);
|
|
8340
|
-
const retentionScore = (_k, v) => ranked ? decay(v.baseScore, ageSeconds((0,
|
|
8341
|
-
const items = (0,
|
|
8874
|
+
const retentionScore = (_k, v) => ranked ? decay(v.baseScore, ageSeconds((0, import_core56.monotonicNs)(), v.lastAccessNs), decayRate, minScore) : v.lastAccessNs;
|
|
8875
|
+
const items = (0, import_extra39.reactiveMap)({
|
|
8342
8876
|
name: "items",
|
|
8343
8877
|
...maxSize !== void 0 ? { retention: { score: retentionScore, maxSize } } : {}
|
|
8344
8878
|
});
|
|
@@ -8346,16 +8880,16 @@ function collection(name, opts = {}) {
|
|
|
8346
8880
|
let refreshTick;
|
|
8347
8881
|
if (ranked && decayRate > 0) {
|
|
8348
8882
|
const intervalMs = opts.refreshIntervalMs ?? Math.max(1, 1e3 * Math.LN2 / (10 * decayRate));
|
|
8349
|
-
const tickCounter = (0,
|
|
8350
|
-
refreshTick = (0,
|
|
8883
|
+
const tickCounter = (0, import_extra39.fromTimer)(intervalMs, { period: intervalMs });
|
|
8884
|
+
refreshTick = (0, import_core56.node)(
|
|
8351
8885
|
[tickCounter],
|
|
8352
8886
|
(_batchData, actions) => {
|
|
8353
|
-
actions.emit((0,
|
|
8887
|
+
actions.emit((0, import_core56.monotonicNs)());
|
|
8354
8888
|
},
|
|
8355
8889
|
{
|
|
8356
8890
|
name: "refresh_tick_ns",
|
|
8357
8891
|
describeKind: "derived",
|
|
8358
|
-
initial: (0,
|
|
8892
|
+
initial: (0, import_core56.monotonicNs)(),
|
|
8359
8893
|
meta: memoryMeta("clock")
|
|
8360
8894
|
}
|
|
8361
8895
|
);
|
|
@@ -8366,7 +8900,7 @@ function collection(name, opts = {}) {
|
|
|
8366
8900
|
const rankedDeps = [items.entries];
|
|
8367
8901
|
if (refreshTick) rankedDeps.push(refreshTick);
|
|
8368
8902
|
if (scoreNode) rankedDeps.push(scoreNode);
|
|
8369
|
-
rankedNode = (0,
|
|
8903
|
+
rankedNode = (0, import_core56.node)(
|
|
8370
8904
|
rankedDeps,
|
|
8371
8905
|
(batchData, actions, ctx) => {
|
|
8372
8906
|
const values = batchData.map(
|
|
@@ -8376,9 +8910,9 @@ function collection(name, opts = {}) {
|
|
|
8376
8910
|
let now;
|
|
8377
8911
|
if (refreshTick) {
|
|
8378
8912
|
const tickValue = values[1];
|
|
8379
|
-
now = typeof tickValue === "number" ? tickValue : (0,
|
|
8913
|
+
now = typeof tickValue === "number" ? tickValue : (0, import_core56.monotonicNs)();
|
|
8380
8914
|
} else {
|
|
8381
|
-
now = (0,
|
|
8915
|
+
now = (0, import_core56.monotonicNs)();
|
|
8382
8916
|
}
|
|
8383
8917
|
if (!snapshot || snapshot.size === 0) {
|
|
8384
8918
|
actions.emit([]);
|
|
@@ -8403,7 +8937,7 @@ function collection(name, opts = {}) {
|
|
|
8403
8937
|
);
|
|
8404
8938
|
graph.add(rankedNode, { name: "ranked" });
|
|
8405
8939
|
} else {
|
|
8406
|
-
rankedNode = (0,
|
|
8940
|
+
rankedNode = (0, import_core56.node)([], {
|
|
8407
8941
|
initial: [],
|
|
8408
8942
|
name: "ranked",
|
|
8409
8943
|
describeKind: "state",
|
|
@@ -8411,7 +8945,7 @@ function collection(name, opts = {}) {
|
|
|
8411
8945
|
});
|
|
8412
8946
|
graph.add(rankedNode, { name: "ranked" });
|
|
8413
8947
|
}
|
|
8414
|
-
const size = (0,
|
|
8948
|
+
const size = (0, import_core56.node)(
|
|
8415
8949
|
[items.entries],
|
|
8416
8950
|
(batchData, actions, ctx) => {
|
|
8417
8951
|
const data = batchData.map(
|
|
@@ -8428,7 +8962,7 @@ function collection(name, opts = {}) {
|
|
|
8428
8962
|
}
|
|
8429
8963
|
);
|
|
8430
8964
|
graph.add(size, { name: "size" });
|
|
8431
|
-
graph.addDisposer((0,
|
|
8965
|
+
graph.addDisposer((0, import_extra39.keepalive)(size));
|
|
8432
8966
|
const events = createAuditLog({
|
|
8433
8967
|
name: "events",
|
|
8434
8968
|
retainedLimit: 1024,
|
|
@@ -8436,7 +8970,7 @@ function collection(name, opts = {}) {
|
|
|
8436
8970
|
});
|
|
8437
8971
|
const seqCursor = registerCursor(graph, "seq", 0);
|
|
8438
8972
|
const upsertImpl = (id, value, _opts) => {
|
|
8439
|
-
const now = (0,
|
|
8973
|
+
const now = (0, import_core56.monotonicNs)();
|
|
8440
8974
|
const prev = items.get(id);
|
|
8441
8975
|
const baseScore = _opts?.score ?? readScoreFn()(value);
|
|
8442
8976
|
items.set(id, {
|
|
@@ -8492,7 +9026,7 @@ function collection(name, opts = {}) {
|
|
|
8492
9026
|
});
|
|
8493
9027
|
function itemNode(id) {
|
|
8494
9028
|
const idN = toNode(id, "id");
|
|
8495
|
-
return (0,
|
|
9029
|
+
return (0, import_core56.node)(
|
|
8496
9030
|
[items.entries, idN],
|
|
8497
9031
|
(batchData, actions, ctx) => {
|
|
8498
9032
|
const data = batchData.map(
|
|
@@ -8510,7 +9044,7 @@ function collection(name, opts = {}) {
|
|
|
8510
9044
|
}
|
|
8511
9045
|
function hasNode(id) {
|
|
8512
9046
|
const idN = toNode(id, "id");
|
|
8513
|
-
return (0,
|
|
9047
|
+
return (0, import_core56.node)(
|
|
8514
9048
|
[items.entries, idN],
|
|
8515
9049
|
(batchData, actions, ctx) => {
|
|
8516
9050
|
const data = batchData.map(
|
|
@@ -8585,7 +9119,7 @@ function vectorIndex(opts = {}) {
|
|
|
8585
9119
|
graph
|
|
8586
9120
|
});
|
|
8587
9121
|
const seqCursor = registerCursor(graph, "seq", 0);
|
|
8588
|
-
const entries = (0,
|
|
9122
|
+
const entries = (0, import_extra39.reactiveMap)({
|
|
8589
9123
|
name: "entries",
|
|
8590
9124
|
...maxSize !== void 0 ? {
|
|
8591
9125
|
retention: {
|
|
@@ -8597,7 +9131,7 @@ function vectorIndex(opts = {}) {
|
|
|
8597
9131
|
events.append({
|
|
8598
9132
|
action: "evict",
|
|
8599
9133
|
id: key,
|
|
8600
|
-
t_ns: (0,
|
|
9134
|
+
t_ns: (0, import_core56.wallClockNs)(),
|
|
8601
9135
|
seq: bumpCursor(seqCursor)
|
|
8602
9136
|
});
|
|
8603
9137
|
}
|
|
@@ -8605,7 +9139,7 @@ function vectorIndex(opts = {}) {
|
|
|
8605
9139
|
} : {}
|
|
8606
9140
|
});
|
|
8607
9141
|
graph.add(entries.entries, { name: "entries" });
|
|
8608
|
-
graph.addDisposer((0,
|
|
9142
|
+
graph.addDisposer((0, import_extra39.keepalive)(entries.entries));
|
|
8609
9143
|
if (hnsw?.dispose) {
|
|
8610
9144
|
const disposeAdapter = hnsw.dispose.bind(hnsw);
|
|
8611
9145
|
graph.addDisposer(() => disposeAdapter());
|
|
@@ -8622,7 +9156,7 @@ function vectorIndex(opts = {}) {
|
|
|
8622
9156
|
id,
|
|
8623
9157
|
vector: [...vector],
|
|
8624
9158
|
...copiedMeta !== void 0 ? { meta: copiedMeta } : {},
|
|
8625
|
-
upsertedAtNs: (0,
|
|
9159
|
+
upsertedAtNs: (0, import_core56.monotonicNs)()
|
|
8626
9160
|
};
|
|
8627
9161
|
entries.set(id, record);
|
|
8628
9162
|
};
|
|
@@ -8678,7 +9212,7 @@ function vectorIndex(opts = {}) {
|
|
|
8678
9212
|
});
|
|
8679
9213
|
function searchNode(query, k = 5) {
|
|
8680
9214
|
const kN = toNode(k, "k");
|
|
8681
|
-
return (0,
|
|
9215
|
+
return (0, import_core56.node)(
|
|
8682
9216
|
[entries.entries, query, kN],
|
|
8683
9217
|
(batchData, actions, ctx) => {
|
|
8684
9218
|
const values = batchData.map(
|
|
@@ -8784,17 +9318,17 @@ function knowledgeGraph(name, opts = {}) {
|
|
|
8784
9318
|
throw new RangeError("knowledgeGraph: edgesMaxSize must be >= 1");
|
|
8785
9319
|
}
|
|
8786
9320
|
const graph = new import_graph7.Graph(name);
|
|
8787
|
-
const entitiesMap = (0,
|
|
9321
|
+
const entitiesMap = (0, import_extra39.reactiveMap)({
|
|
8788
9322
|
name: "entities",
|
|
8789
9323
|
...opts.entitiesMaxSize !== void 0 ? { maxSize: opts.entitiesMaxSize } : {}
|
|
8790
9324
|
});
|
|
8791
|
-
const edgesMap = (0,
|
|
9325
|
+
const edgesMap = (0, import_extra39.reactiveMap)({
|
|
8792
9326
|
name: "edges",
|
|
8793
9327
|
...opts.edgesMaxSize !== void 0 ? { maxSize: opts.edgesMaxSize } : {}
|
|
8794
9328
|
});
|
|
8795
9329
|
graph.add(entitiesMap.entries, { name: "entities" });
|
|
8796
9330
|
graph.add(edgesMap.entries, { name: "edges" });
|
|
8797
|
-
const adjacencyOut = (0,
|
|
9331
|
+
const adjacencyOut = (0, import_core56.node)(
|
|
8798
9332
|
[edgesMap.entries],
|
|
8799
9333
|
(batchData, actions, ctx) => {
|
|
8800
9334
|
const data = batchData.map(
|
|
@@ -8811,7 +9345,7 @@ function knowledgeGraph(name, opts = {}) {
|
|
|
8811
9345
|
meta: memoryMeta("adjacency_out")
|
|
8812
9346
|
}
|
|
8813
9347
|
);
|
|
8814
|
-
const adjacencyIn = (0,
|
|
9348
|
+
const adjacencyIn = (0, import_core56.node)(
|
|
8815
9349
|
[edgesMap.entries],
|
|
8816
9350
|
(batchData, actions, ctx) => {
|
|
8817
9351
|
const data = batchData.map(
|
|
@@ -8830,9 +9364,9 @@ function knowledgeGraph(name, opts = {}) {
|
|
|
8830
9364
|
);
|
|
8831
9365
|
graph.add(adjacencyOut, { name: "adjacencyOut" });
|
|
8832
9366
|
graph.add(adjacencyIn, { name: "adjacencyIn" });
|
|
8833
|
-
graph.addDisposer((0,
|
|
8834
|
-
graph.addDisposer((0,
|
|
8835
|
-
const entityCount = (0,
|
|
9367
|
+
graph.addDisposer((0, import_extra39.keepalive)(adjacencyOut));
|
|
9368
|
+
graph.addDisposer((0, import_extra39.keepalive)(adjacencyIn));
|
|
9369
|
+
const entityCount = (0, import_core56.node)(
|
|
8836
9370
|
[entitiesMap.entries],
|
|
8837
9371
|
(batchData, actions, ctx) => {
|
|
8838
9372
|
const data = batchData.map(
|
|
@@ -8843,7 +9377,7 @@ function knowledgeGraph(name, opts = {}) {
|
|
|
8843
9377
|
},
|
|
8844
9378
|
{ name: "entityCount", describeKind: "derived", initial: 0, meta: memoryMeta("entity_count") }
|
|
8845
9379
|
);
|
|
8846
|
-
const edgeCount = (0,
|
|
9380
|
+
const edgeCount = (0, import_core56.node)(
|
|
8847
9381
|
[edgesMap.entries],
|
|
8848
9382
|
(batchData, actions, ctx) => {
|
|
8849
9383
|
const data = batchData.map(
|
|
@@ -8856,8 +9390,8 @@ function knowledgeGraph(name, opts = {}) {
|
|
|
8856
9390
|
);
|
|
8857
9391
|
graph.add(entityCount, { name: "entityCount" });
|
|
8858
9392
|
graph.add(edgeCount, { name: "edgeCount" });
|
|
8859
|
-
graph.addDisposer((0,
|
|
8860
|
-
graph.addDisposer((0,
|
|
9393
|
+
graph.addDisposer((0, import_extra39.keepalive)(entityCount));
|
|
9394
|
+
graph.addDisposer((0, import_extra39.keepalive)(edgeCount));
|
|
8861
9395
|
const events = createAuditLog({
|
|
8862
9396
|
name: "events",
|
|
8863
9397
|
retainedLimit: 1024,
|
|
@@ -8880,7 +9414,7 @@ function knowledgeGraph(name, opts = {}) {
|
|
|
8880
9414
|
events.append({
|
|
8881
9415
|
action: "orphanRemove",
|
|
8882
9416
|
id: candidate,
|
|
8883
|
-
t_ns: (0,
|
|
9417
|
+
t_ns: (0, import_core56.wallClockNs)(),
|
|
8884
9418
|
seq: bumpCursor(seqCursor)
|
|
8885
9419
|
});
|
|
8886
9420
|
}
|
|
@@ -8975,7 +9509,7 @@ function knowledgeGraph(name, opts = {}) {
|
|
|
8975
9509
|
const idN = toNode(id, "id");
|
|
8976
9510
|
const relN = relation !== void 0 ? toNode(relation, "relation") : void 0;
|
|
8977
9511
|
const deps = relN ? [adjacencyOut, adjacencyIn, idN, relN] : [adjacencyOut, adjacencyIn, idN];
|
|
8978
|
-
return (0,
|
|
9512
|
+
return (0, import_core56.node)(
|
|
8979
9513
|
deps,
|
|
8980
9514
|
(batchData, actions, ctx) => {
|
|
8981
9515
|
const values = batchData.map(
|
|
@@ -9051,7 +9585,7 @@ var MemoryWithVectorsGraph = class extends import_graph8.Graph {
|
|
|
9051
9585
|
this.mount("vectorIndex", this.vectors);
|
|
9052
9586
|
const embedFn = opts.embedFn;
|
|
9053
9587
|
const vectorsRef = this.vectors;
|
|
9054
|
-
const indexer = (0,
|
|
9588
|
+
const indexer = (0, import_core57.node)(
|
|
9055
9589
|
[opts.store.store.entries],
|
|
9056
9590
|
(batchData, _actions, ctx) => {
|
|
9057
9591
|
const data = batchData.map(
|
|
@@ -9066,7 +9600,7 @@ var MemoryWithVectorsGraph = class extends import_graph8.Graph {
|
|
|
9066
9600
|
{ name: "indexer", describeKind: "effect" }
|
|
9067
9601
|
);
|
|
9068
9602
|
this.add(indexer, { name: "indexer" });
|
|
9069
|
-
this.addDisposer((0,
|
|
9603
|
+
this.addDisposer((0, import_extra40.keepalive)(indexer));
|
|
9070
9604
|
}
|
|
9071
9605
|
};
|
|
9072
9606
|
function memoryWithVectors(opts) {
|
|
@@ -9084,7 +9618,7 @@ var MemoryWithKGGraph = class extends import_graph8.Graph {
|
|
|
9084
9618
|
if (!opts.entityFn) return;
|
|
9085
9619
|
const entityFn = opts.entityFn;
|
|
9086
9620
|
const kgRef = this.kg;
|
|
9087
|
-
const indexer = (0,
|
|
9621
|
+
const indexer = (0, import_core57.node)(
|
|
9088
9622
|
[opts.store.store.entries],
|
|
9089
9623
|
(batchData, _actions, ctx) => {
|
|
9090
9624
|
const data = batchData.map(
|
|
@@ -9105,7 +9639,7 @@ var MemoryWithKGGraph = class extends import_graph8.Graph {
|
|
|
9105
9639
|
{ name: "indexer", describeKind: "effect" }
|
|
9106
9640
|
);
|
|
9107
9641
|
this.add(indexer, { name: "indexer" });
|
|
9108
|
-
this.addDisposer((0,
|
|
9642
|
+
this.addDisposer((0, import_extra40.keepalive)(indexer));
|
|
9109
9643
|
}
|
|
9110
9644
|
};
|
|
9111
9645
|
function memoryWithKG(opts) {
|
|
@@ -9127,20 +9661,20 @@ var MemoryWithTiersGraph = class extends import_graph8.Graph {
|
|
|
9127
9661
|
const permanentFilter = opts.permanentFilter ?? (() => false);
|
|
9128
9662
|
this.permanent = collection("permanent", { ranked: false });
|
|
9129
9663
|
this.mount("permanent", this.permanent);
|
|
9130
|
-
this.permanentKeys = (0,
|
|
9664
|
+
this.permanentKeys = (0, import_extra40.reactiveMap)({ name: "permanentKeys" });
|
|
9131
9665
|
this.add(this.permanentKeys.entries, { name: "permanentKeys" });
|
|
9132
|
-
this.entryCreatedAtNs = (0,
|
|
9666
|
+
this.entryCreatedAtNs = (0, import_extra40.reactiveMap)({ name: "entryCreatedAtNs" });
|
|
9133
9667
|
this.add(this.entryCreatedAtNs.entries, { name: "entryCreatedAtNs" });
|
|
9134
9668
|
let contextNode;
|
|
9135
9669
|
if (opts.context) {
|
|
9136
|
-
contextNode = (0,
|
|
9670
|
+
contextNode = (0, import_extra40.fromAny)(opts.context);
|
|
9137
9671
|
} else {
|
|
9138
|
-
contextNode = (0,
|
|
9672
|
+
contextNode = (0, import_core57.node)([], { initial: null });
|
|
9139
9673
|
this.add(contextNode, { name: "context" });
|
|
9140
9674
|
}
|
|
9141
9675
|
let latestCtx = contextNode.cache;
|
|
9142
9676
|
const ctxUnsub = contextNode.subscribe((msgs) => {
|
|
9143
|
-
for (const m of msgs) if (m[0] ===
|
|
9677
|
+
for (const m of msgs) if (m[0] === import_core57.DATA) latestCtx = m[1];
|
|
9144
9678
|
});
|
|
9145
9679
|
this.addDisposer(ctxUnsub);
|
|
9146
9680
|
const permanentKeysRef = this.permanentKeys;
|
|
@@ -9150,7 +9684,7 @@ var MemoryWithTiersGraph = class extends import_graph8.Graph {
|
|
|
9150
9684
|
score: (key, value) => {
|
|
9151
9685
|
if (permanentFilter(key, value)) return Number.POSITIVE_INFINITY;
|
|
9152
9686
|
if (permanentKeysRef.has(key)) return Number.POSITIVE_INFINITY;
|
|
9153
|
-
const nowNs = (0,
|
|
9687
|
+
const nowNs = (0, import_core57.monotonicNs)();
|
|
9154
9688
|
const createdNs = entryCreatedAtNsRef.get(key) ?? nowNs;
|
|
9155
9689
|
const ageSeconds2 = Number(nowNs - createdNs) / 1e9;
|
|
9156
9690
|
return decay(score(value, latestCtx), ageSeconds2, decayRate);
|
|
@@ -9185,20 +9719,20 @@ var MemoryWithTiersGraph = class extends import_graph8.Graph {
|
|
|
9185
9719
|
permanentKeysRef.set(key, true);
|
|
9186
9720
|
permanentRef.upsert(key, value);
|
|
9187
9721
|
};
|
|
9188
|
-
const syncCreatedAt = (0,
|
|
9722
|
+
const syncCreatedAt = (0, import_core57.node)(
|
|
9189
9723
|
[this.store.store.entries],
|
|
9190
9724
|
(batchData, _actions, ctx) => {
|
|
9191
9725
|
const data = batchData.map(
|
|
9192
9726
|
(b, i) => b != null && b.length > 0 ? b.at(-1) : ctx.prevData[i]
|
|
9193
9727
|
);
|
|
9194
9728
|
const map = data[0] ?? /* @__PURE__ */ new Map();
|
|
9195
|
-
const nowNs = (0,
|
|
9729
|
+
const nowNs = (0, import_core57.monotonicNs)();
|
|
9196
9730
|
const toAdd = [];
|
|
9197
9731
|
for (const key of map.keys()) {
|
|
9198
9732
|
if (!entryCreatedAtNsRef.has(key)) toAdd.push(key);
|
|
9199
9733
|
}
|
|
9200
9734
|
if (toAdd.length > 0) {
|
|
9201
|
-
(0,
|
|
9735
|
+
(0, import_core57.batch)(() => {
|
|
9202
9736
|
for (const key of toAdd) entryCreatedAtNsRef.set(key, nowNs);
|
|
9203
9737
|
});
|
|
9204
9738
|
}
|
|
@@ -9206,10 +9740,10 @@ var MemoryWithTiersGraph = class extends import_graph8.Graph {
|
|
|
9206
9740
|
{ name: "entryCreatedAtNs/sync", describeKind: "effect" }
|
|
9207
9741
|
);
|
|
9208
9742
|
this.add(syncCreatedAt, { name: "entryCreatedAtNs/sync" });
|
|
9209
|
-
this.addDisposer((0,
|
|
9743
|
+
this.addDisposer((0, import_extra40.keepalive)(syncCreatedAt));
|
|
9210
9744
|
const entriesUnsub = this.store.store.entries.subscribe((msgs) => {
|
|
9211
9745
|
for (const m of msgs) {
|
|
9212
|
-
if (m[0] !==
|
|
9746
|
+
if (m[0] !== import_core57.DATA) continue;
|
|
9213
9747
|
const map = m[1];
|
|
9214
9748
|
const created = entryCreatedAtNsRef.entries.cache;
|
|
9215
9749
|
if (created == null) continue;
|
|
@@ -9218,14 +9752,14 @@ var MemoryWithTiersGraph = class extends import_graph8.Graph {
|
|
|
9218
9752
|
if (!map.has(key)) toDelete.push(key);
|
|
9219
9753
|
}
|
|
9220
9754
|
if (toDelete.length > 0) {
|
|
9221
|
-
(0,
|
|
9755
|
+
(0, import_core57.batch)(() => {
|
|
9222
9756
|
for (const key of toDelete) entryCreatedAtNsRef.delete(key);
|
|
9223
9757
|
});
|
|
9224
9758
|
}
|
|
9225
9759
|
}
|
|
9226
9760
|
});
|
|
9227
9761
|
this.addDisposer(entriesUnsub);
|
|
9228
|
-
const promoter = (0,
|
|
9762
|
+
const promoter = (0, import_core57.node)(
|
|
9229
9763
|
[this.store.store.entries],
|
|
9230
9764
|
(batchData, _actions, ctx) => {
|
|
9231
9765
|
const data = batchData.map(
|
|
@@ -9235,7 +9769,7 @@ var MemoryWithTiersGraph = class extends import_graph8.Graph {
|
|
|
9235
9769
|
for (const [key, mem] of map) {
|
|
9236
9770
|
if (permanentKeysRef.has(key)) continue;
|
|
9237
9771
|
if (permanentFilter(key, mem)) {
|
|
9238
|
-
(0,
|
|
9772
|
+
(0, import_core57.batch)(() => {
|
|
9239
9773
|
markPermanent(key, mem);
|
|
9240
9774
|
});
|
|
9241
9775
|
}
|
|
@@ -9244,7 +9778,7 @@ var MemoryWithTiersGraph = class extends import_graph8.Graph {
|
|
|
9244
9778
|
{ name: "promoter", describeKind: "effect" }
|
|
9245
9779
|
);
|
|
9246
9780
|
this.add(promoter, { name: "promoter" });
|
|
9247
|
-
this.addDisposer((0,
|
|
9781
|
+
this.addDisposer((0, import_extra40.keepalive)(promoter));
|
|
9248
9782
|
let archiveHandle = null;
|
|
9249
9783
|
if (opts.archiveTier) {
|
|
9250
9784
|
archiveHandle = this.attachSnapshotStorage(
|
|
@@ -9300,7 +9834,7 @@ var MemoryRetrievalGraph = class extends import_graph8.Graph {
|
|
|
9300
9834
|
this._budget = opts.budget ?? 2e3;
|
|
9301
9835
|
this._contextWeight = opts.contextWeight ?? 0;
|
|
9302
9836
|
if (opts.context) {
|
|
9303
|
-
this._contextNode = (0,
|
|
9837
|
+
this._contextNode = (0, import_extra40.fromAny)(opts.context);
|
|
9304
9838
|
} else {
|
|
9305
9839
|
this._contextNode = this.state("_context", null);
|
|
9306
9840
|
}
|
|
@@ -9446,7 +9980,7 @@ var MemoryRetrievalGraph = class extends import_graph8.Graph {
|
|
|
9446
9980
|
const id = ++this._retrieveSeq;
|
|
9447
9981
|
const segment = `retrieve_${id}`;
|
|
9448
9982
|
const sub = new import_graph8.Graph(segment);
|
|
9449
|
-
const inputNode = (0,
|
|
9983
|
+
const inputNode = (0, import_extra40.fromAny)(queryInput);
|
|
9450
9984
|
const localContext = sub.derived(
|
|
9451
9985
|
"context",
|
|
9452
9986
|
[inputNode],
|
|
@@ -9491,7 +10025,7 @@ var MemoryRetrievalGraph = class extends import_graph8.Graph {
|
|
|
9491
10025
|
initial: { packed: [], trace: null }
|
|
9492
10026
|
}
|
|
9493
10027
|
);
|
|
9494
|
-
const projection = (0,
|
|
10028
|
+
const projection = (0, import_core57.node)(
|
|
9495
10029
|
[result],
|
|
9496
10030
|
(batchData, actions, ctx) => {
|
|
9497
10031
|
const data = batchData.map(
|
|
@@ -9531,18 +10065,18 @@ function gaugesAsContext(graph, actor, options) {
|
|
|
9531
10065
|
const separator = options?.separator ?? "\n";
|
|
9532
10066
|
const entries = [];
|
|
9533
10067
|
const sinceVersion = options?.sinceVersion;
|
|
9534
|
-
for (const [path,
|
|
9535
|
-
const meta2 =
|
|
10068
|
+
for (const [path, node65] of Object.entries(described.nodes)) {
|
|
10069
|
+
const meta2 = node65.meta ?? {};
|
|
9536
10070
|
const desc = meta2.description;
|
|
9537
10071
|
const format = meta2.format;
|
|
9538
10072
|
if (!desc && !format) continue;
|
|
9539
|
-
if (sinceVersion != null &&
|
|
10073
|
+
if (sinceVersion != null && node65.v != null) {
|
|
9540
10074
|
const lastSeen = sinceVersion.get(path);
|
|
9541
|
-
if (lastSeen != null && lastSeen.id ===
|
|
10075
|
+
if (lastSeen != null && lastSeen.id === node65.v.id && node65.v.version <= lastSeen.version)
|
|
9542
10076
|
continue;
|
|
9543
10077
|
}
|
|
9544
10078
|
const label = desc ?? path;
|
|
9545
|
-
const value =
|
|
10079
|
+
const value = node65.value;
|
|
9546
10080
|
const unit = meta2.unit;
|
|
9547
10081
|
let formatted;
|
|
9548
10082
|
if (format === "currency" && typeof value === "number") {
|
|
@@ -9564,8 +10098,8 @@ function gaugesAsContext(graph, actor, options) {
|
|
|
9564
10098
|
const tagGroups = /* @__PURE__ */ new Map();
|
|
9565
10099
|
const ungrouped = [];
|
|
9566
10100
|
for (const entry of entries) {
|
|
9567
|
-
const
|
|
9568
|
-
const tags =
|
|
10101
|
+
const node65 = described.nodes[entry.path];
|
|
10102
|
+
const tags = node65.meta?.tags;
|
|
9569
10103
|
if (tags && tags.length > 0) {
|
|
9570
10104
|
const tag = tags[0];
|
|
9571
10105
|
let group = tagGroups.get(tag);
|
|
@@ -9596,18 +10130,18 @@ function gaugesAsContext(graph, actor, options) {
|
|
|
9596
10130
|
}
|
|
9597
10131
|
|
|
9598
10132
|
// src/utils/ai/graph-integration/graph-from-spec.ts
|
|
9599
|
-
var
|
|
9600
|
-
var
|
|
10133
|
+
var import_core60 = require("@graphrefly/pure-ts/core");
|
|
10134
|
+
var import_extra43 = require("@graphrefly/pure-ts/extra");
|
|
9601
10135
|
|
|
9602
10136
|
// src/utils/graphspec/index.ts
|
|
9603
|
-
var
|
|
10137
|
+
var import_core59 = require("@graphrefly/pure-ts/core");
|
|
9604
10138
|
var import_graph10 = require("@graphrefly/pure-ts/graph");
|
|
9605
10139
|
|
|
9606
10140
|
// src/utils/reduction/index.ts
|
|
9607
|
-
var
|
|
9608
|
-
var
|
|
10141
|
+
var import_core58 = require("@graphrefly/pure-ts/core");
|
|
10142
|
+
var import_extra41 = require("@graphrefly/pure-ts/extra");
|
|
9609
10143
|
var import_graph9 = require("@graphrefly/pure-ts/graph");
|
|
9610
|
-
var
|
|
10144
|
+
var import_extra42 = require("@graphrefly/pure-ts/extra");
|
|
9611
10145
|
function baseMeta(kind, meta2) {
|
|
9612
10146
|
return domainMeta("reduction", kind, meta2);
|
|
9613
10147
|
}
|
|
@@ -9615,7 +10149,7 @@ function funnel(name, sources, stages, opts) {
|
|
|
9615
10149
|
if (sources.length === 0) throw new RangeError("funnel requires at least one source");
|
|
9616
10150
|
if (stages.length === 0) throw new RangeError("funnel requires at least one stage");
|
|
9617
10151
|
const g = new import_graph9.Graph(name, opts);
|
|
9618
|
-
const merged = sources.length === 1 ? sources[0] : (0,
|
|
10152
|
+
const merged = sources.length === 1 ? sources[0] : (0, import_extra41.merge)(...sources);
|
|
9619
10153
|
g.add(merged, { name: "merged" });
|
|
9620
10154
|
let prevOutputPath = "merged";
|
|
9621
10155
|
for (let i = 0; i < stages.length; i++) {
|
|
@@ -9637,7 +10171,7 @@ function funnel(name, sources, stages, opts) {
|
|
|
9637
10171
|
const stageInputPath = `${stage.name}::input`;
|
|
9638
10172
|
const stageInput = g.resolve(stageInputPath);
|
|
9639
10173
|
const bridgeName = `__bridge_${prevOutputPath}\u2192${stage.name}_input`;
|
|
9640
|
-
const br = (0,
|
|
10174
|
+
const br = (0, import_core58.node)(
|
|
9641
10175
|
[prevNode],
|
|
9642
10176
|
(batchData, _actions, ctx) => {
|
|
9643
10177
|
const data = batchData.map(
|
|
@@ -9649,7 +10183,7 @@ function funnel(name, sources, stages, opts) {
|
|
|
9649
10183
|
{ describeKind: "effect", name: bridgeName }
|
|
9650
10184
|
);
|
|
9651
10185
|
g.add(br, { name: bridgeName });
|
|
9652
|
-
g.addDisposer((0,
|
|
10186
|
+
g.addDisposer((0, import_extra42.keepalive)(br));
|
|
9653
10187
|
prevOutputPath = `${stage.name}::output`;
|
|
9654
10188
|
}
|
|
9655
10189
|
return g;
|
|
@@ -9657,7 +10191,7 @@ function funnel(name, sources, stages, opts) {
|
|
|
9657
10191
|
function feedback(graph, condition, reentry, opts) {
|
|
9658
10192
|
const maxIter = opts?.maxIterations ?? 10;
|
|
9659
10193
|
const counterName = `__feedback_${condition}`;
|
|
9660
|
-
const counter = (0,
|
|
10194
|
+
const counter = (0, import_core58.node)([], {
|
|
9661
10195
|
...{
|
|
9662
10196
|
meta: baseMeta("feedback_counter", {
|
|
9663
10197
|
maxIterations: maxIter,
|
|
@@ -9671,22 +10205,22 @@ function feedback(graph, condition, reentry, opts) {
|
|
|
9671
10205
|
const condNode = graph.resolve(condition);
|
|
9672
10206
|
const reentryNode = graph.resolve(reentry);
|
|
9673
10207
|
const feedbackEffectName = `__feedback_effect_${condition}`;
|
|
9674
|
-
const feedbackEffect = (0,
|
|
10208
|
+
const feedbackEffect = (0, import_core58.node)(
|
|
9675
10209
|
[],
|
|
9676
10210
|
(_data, _feedbackActions) => {
|
|
9677
10211
|
const unsub = condNode.subscribe((msgs) => {
|
|
9678
10212
|
for (const msg of msgs) {
|
|
9679
10213
|
const t = msg[0];
|
|
9680
|
-
if (t ===
|
|
10214
|
+
if (t === import_core58.DATA) {
|
|
9681
10215
|
const condValue = msg[1];
|
|
9682
10216
|
if (condValue == null) return;
|
|
9683
|
-
(0,
|
|
10217
|
+
(0, import_core58.batch)(() => {
|
|
9684
10218
|
if (tryIncrementBounded(counter, maxIter)) {
|
|
9685
10219
|
reentryNode.emit(condValue);
|
|
9686
10220
|
}
|
|
9687
10221
|
});
|
|
9688
|
-
} else if (t ===
|
|
9689
|
-
const terminal = t ===
|
|
10222
|
+
} else if (t === import_core58.COMPLETE || t === import_core58.ERROR) {
|
|
10223
|
+
const terminal = t === import_core58.ERROR && msg.length > 1 ? [import_core58.ERROR, msg[1]] : [t];
|
|
9690
10224
|
counter.down([terminal]);
|
|
9691
10225
|
}
|
|
9692
10226
|
}
|
|
@@ -9706,7 +10240,7 @@ function feedback(graph, condition, reentry, opts) {
|
|
|
9706
10240
|
}
|
|
9707
10241
|
);
|
|
9708
10242
|
graph.add(feedbackEffect, { name: feedbackEffectName });
|
|
9709
|
-
graph.addDisposer((0,
|
|
10243
|
+
graph.addDisposer((0, import_extra42.keepalive)(feedbackEffect));
|
|
9710
10244
|
return graph;
|
|
9711
10245
|
}
|
|
9712
10246
|
function scorer(sources, weights, opts) {
|
|
@@ -9717,7 +10251,7 @@ function scorer(sources, weights, opts) {
|
|
|
9717
10251
|
const allDeps = [...sources, ...weights];
|
|
9718
10252
|
const n = sources.length;
|
|
9719
10253
|
const scoreFns = opts?.scoreFns;
|
|
9720
|
-
return (0,
|
|
10254
|
+
return (0, import_core58.node)(
|
|
9721
10255
|
allDeps,
|
|
9722
10256
|
(batchData, actions, ctx) => {
|
|
9723
10257
|
const vals = batchData.map(
|
|
@@ -9754,18 +10288,18 @@ function scorer(sources, weights, opts) {
|
|
|
9754
10288
|
}
|
|
9755
10289
|
|
|
9756
10290
|
// src/utils/graphspec/index.ts
|
|
9757
|
-
function readFactory(
|
|
9758
|
-
const f =
|
|
10291
|
+
function readFactory(node65) {
|
|
10292
|
+
const f = node65.meta?.factory;
|
|
9759
10293
|
return typeof f === "string" ? f : void 0;
|
|
9760
10294
|
}
|
|
9761
|
-
function readFactoryArgs(
|
|
9762
|
-
const a =
|
|
10295
|
+
function readFactoryArgs(node65) {
|
|
10296
|
+
const a = node65.meta?.factoryArgs;
|
|
9763
10297
|
return a != null && typeof a === "object" ? a : {};
|
|
9764
10298
|
}
|
|
9765
|
-
function readStateInitial(
|
|
9766
|
-
const args = readFactoryArgs(
|
|
10299
|
+
function readStateInitial(node65) {
|
|
10300
|
+
const args = readFactoryArgs(node65);
|
|
9767
10301
|
if ("initial" in args) return args.initial;
|
|
9768
|
-
return
|
|
10302
|
+
return node65.value;
|
|
9769
10303
|
}
|
|
9770
10304
|
function isRichFnEntry(entry) {
|
|
9771
10305
|
return typeof entry === "object" && entry !== null && "factory" in entry;
|
|
@@ -9838,11 +10372,11 @@ function validateSpecAgainstCatalog(spec, catalog) {
|
|
|
9838
10372
|
const sourceNames = new Set(Object.keys(catalog.sources ?? {}));
|
|
9839
10373
|
for (const [nodeName, nodeRaw] of Object.entries(spec.nodes)) {
|
|
9840
10374
|
if (nodeRaw.type === "template") continue;
|
|
9841
|
-
const
|
|
9842
|
-
const factoryName = readFactory(
|
|
10375
|
+
const node65 = nodeRaw;
|
|
10376
|
+
const factoryName = readFactory(node65);
|
|
9843
10377
|
if (factoryName == null) continue;
|
|
9844
|
-
const isProducer =
|
|
9845
|
-
if (
|
|
10378
|
+
const isProducer = node65.type === "producer";
|
|
10379
|
+
if (node65.type === "state" && factoryName === "state") continue;
|
|
9846
10380
|
if (isProducer) {
|
|
9847
10381
|
const inSources = sourceNames.has(factoryName);
|
|
9848
10382
|
const inFns = fnNames.has(factoryName);
|
|
@@ -9866,7 +10400,7 @@ function validateSpecAgainstCatalog(spec, catalog) {
|
|
|
9866
10400
|
}
|
|
9867
10401
|
}
|
|
9868
10402
|
}
|
|
9869
|
-
const factoryArgs = readFactoryArgs(
|
|
10403
|
+
const factoryArgs = readFactoryArgs(node65);
|
|
9870
10404
|
if (!isProducer && catalog.fns?.[factoryName]) {
|
|
9871
10405
|
const entry = catalog.fns[factoryName];
|
|
9872
10406
|
if (isRichFnEntry(entry) && entry.configSchema) {
|
|
@@ -9906,11 +10440,11 @@ function validateSpecAgainstCatalog(spec, catalog) {
|
|
|
9906
10440
|
}
|
|
9907
10441
|
if (spec.templates) {
|
|
9908
10442
|
for (const [tName, template] of Object.entries(spec.templates)) {
|
|
9909
|
-
for (const [nodeName,
|
|
9910
|
-
const factoryName = readFactory(
|
|
10443
|
+
for (const [nodeName, node65] of Object.entries(template.nodes)) {
|
|
10444
|
+
const factoryName = readFactory(node65);
|
|
9911
10445
|
if (factoryName == null) continue;
|
|
9912
|
-
if (
|
|
9913
|
-
if (
|
|
10446
|
+
if (node65.type === "state" && factoryName === "state") continue;
|
|
10447
|
+
if (node65.type === "producer") continue;
|
|
9914
10448
|
if (fnNames.size > 0 && !fnNames.has(factoryName)) {
|
|
9915
10449
|
const suggestion = findClosest(factoryName, fnNames);
|
|
9916
10450
|
errors.push(
|
|
@@ -10125,8 +10659,8 @@ function validateSpec(spec) {
|
|
|
10125
10659
|
warnings
|
|
10126
10660
|
};
|
|
10127
10661
|
}
|
|
10128
|
-
function readOwner(
|
|
10129
|
-
const o =
|
|
10662
|
+
function readOwner(node65) {
|
|
10663
|
+
const o = node65.meta?.owner;
|
|
10130
10664
|
return typeof o === "string" && o.length > 0 ? o : void 0;
|
|
10131
10665
|
}
|
|
10132
10666
|
var OVERRIDE_OWNER_TRAILER = /^\s*override-owner\s*:\s*(.+?)\s*$/im;
|
|
@@ -10225,7 +10759,7 @@ ${catalogValidation.errors.join("\n")}`
|
|
|
10225
10759
|
const factoryArgs = readFactoryArgs(n);
|
|
10226
10760
|
if (n.type === "state") {
|
|
10227
10761
|
const initial = readStateInitial(n);
|
|
10228
|
-
const nd = (0,
|
|
10762
|
+
const nd = (0, import_core59.node)([], {
|
|
10229
10763
|
name,
|
|
10230
10764
|
initial,
|
|
10231
10765
|
meta: stripFactoryMeta(n.meta)
|
|
@@ -10245,7 +10779,7 @@ ${catalogValidation.errors.join("\n")}`
|
|
|
10245
10779
|
created.set(name, nd);
|
|
10246
10780
|
} else {
|
|
10247
10781
|
if (factoryName) recordMissing(name, "source", factoryName);
|
|
10248
|
-
const nd = (0,
|
|
10782
|
+
const nd = (0, import_core59.node)([], () => {
|
|
10249
10783
|
}, {
|
|
10250
10784
|
name,
|
|
10251
10785
|
describeKind: "producer",
|
|
@@ -10274,11 +10808,11 @@ ${catalogValidation.errors.join("\n")}`
|
|
|
10274
10808
|
nd = fnFactory(resolvedDeps, factoryArgs);
|
|
10275
10809
|
} else if (n.type === "effect") {
|
|
10276
10810
|
if (factoryName) recordMissing(name, "fn", factoryName);
|
|
10277
|
-
nd = (0,
|
|
10811
|
+
nd = (0, import_core59.node)(resolvedDeps, () => {
|
|
10278
10812
|
}, { describeKind: "effect" });
|
|
10279
10813
|
} else {
|
|
10280
10814
|
if (factoryName) recordMissing(name, "fn", factoryName);
|
|
10281
|
-
nd = (0,
|
|
10815
|
+
nd = (0, import_core59.node)(
|
|
10282
10816
|
resolvedDeps,
|
|
10283
10817
|
(batchData, actions, ctx) => {
|
|
10284
10818
|
const data = batchData.map(
|
|
@@ -10318,7 +10852,7 @@ ${catalogValidation.errors.join("\n")}`
|
|
|
10318
10852
|
const factoryArgs = readFactoryArgs(nSpec);
|
|
10319
10853
|
if (nSpec.type === "state") {
|
|
10320
10854
|
const initial = readStateInitial(nSpec);
|
|
10321
|
-
const nd = (0,
|
|
10855
|
+
const nd = (0, import_core59.node)([], {
|
|
10322
10856
|
name: nName,
|
|
10323
10857
|
initial,
|
|
10324
10858
|
meta: stripFactoryMeta(nSpec.meta)
|
|
@@ -10338,7 +10872,7 @@ ${catalogValidation.errors.join("\n")}`
|
|
|
10338
10872
|
subCreated.set(nName, nd);
|
|
10339
10873
|
} else {
|
|
10340
10874
|
if (factoryName) recordMissing(`${name}.${nName}`, "source", factoryName);
|
|
10341
|
-
const nd = (0,
|
|
10875
|
+
const nd = (0, import_core59.node)([], () => {
|
|
10342
10876
|
}, {
|
|
10343
10877
|
name: nName,
|
|
10344
10878
|
describeKind: "producer",
|
|
@@ -10368,11 +10902,11 @@ ${catalogValidation.errors.join("\n")}`
|
|
|
10368
10902
|
nd = fnFactory(resolvedDeps, factoryArgs);
|
|
10369
10903
|
} else if (nSpec.type === "effect") {
|
|
10370
10904
|
if (factoryName) recordMissing(`${name}.${nName}`, "fn", factoryName);
|
|
10371
|
-
nd = (0,
|
|
10905
|
+
nd = (0, import_core59.node)(resolvedDeps, () => {
|
|
10372
10906
|
}, { describeKind: "effect" });
|
|
10373
10907
|
} else {
|
|
10374
10908
|
if (factoryName) recordMissing(`${name}.${nName}`, "fn", factoryName);
|
|
10375
|
-
nd = (0,
|
|
10909
|
+
nd = (0, import_core59.node)(
|
|
10376
10910
|
resolvedDeps,
|
|
10377
10911
|
(batchData, actions, ctx) => {
|
|
10378
10912
|
const data = batchData.map(
|
|
@@ -10859,12 +11393,12 @@ ${opts.systemPromptExtra}` : GRAPH_FROM_SPEC_SYSTEM_PROMPT;
|
|
|
10859
11393
|
return compileSpec(parsed, { catalog: opts?.catalog });
|
|
10860
11394
|
}
|
|
10861
11395
|
function graphFromSpecReactive(input, adapter, opts) {
|
|
10862
|
-
const inputNode = (0,
|
|
10863
|
-
return (0,
|
|
11396
|
+
const inputNode = (0, import_extra43.fromAny)(input);
|
|
11397
|
+
return (0, import_extra43.switchMap)(inputNode, (nl) => {
|
|
10864
11398
|
if (!nl || typeof nl !== "string" || nl.trim().length === 0) {
|
|
10865
|
-
return (0,
|
|
11399
|
+
return (0, import_core60.node)([], { initial: null });
|
|
10866
11400
|
}
|
|
10867
|
-
return (0,
|
|
11401
|
+
return (0, import_core60.node)(
|
|
10868
11402
|
(_data, actions) => {
|
|
10869
11403
|
const controller = new AbortController();
|
|
10870
11404
|
let cancelled = false;
|
|
@@ -10874,10 +11408,10 @@ function graphFromSpecReactive(input, adapter, opts) {
|
|
|
10874
11408
|
return;
|
|
10875
11409
|
}
|
|
10876
11410
|
actions.emit(g);
|
|
10877
|
-
actions.down([[
|
|
11411
|
+
actions.down([[import_core60.COMPLETE]]);
|
|
10878
11412
|
}).catch((err) => {
|
|
10879
11413
|
if (cancelled) return;
|
|
10880
|
-
actions.down([[
|
|
11414
|
+
actions.down([[import_core60.ERROR, err]]);
|
|
10881
11415
|
});
|
|
10882
11416
|
return () => {
|
|
10883
11417
|
cancelled = true;
|
|
@@ -10928,11 +11462,11 @@ function knobsAsTools(graph, actor) {
|
|
|
10928
11462
|
const openai = [];
|
|
10929
11463
|
const mcp = [];
|
|
10930
11464
|
const definitions = [];
|
|
10931
|
-
for (const [path,
|
|
10932
|
-
if (
|
|
11465
|
+
for (const [path, node65] of Object.entries(described.nodes)) {
|
|
11466
|
+
if (node65.type !== "state") continue;
|
|
10933
11467
|
if (path.includes("::__meta__::")) continue;
|
|
10934
|
-
if (
|
|
10935
|
-
const meta2 =
|
|
11468
|
+
if (node65.status === "completed" || node65.status === "errored") continue;
|
|
11469
|
+
const meta2 = node65.meta ?? {};
|
|
10936
11470
|
const access = meta2.access;
|
|
10937
11471
|
if (access === "human" || access === "system") continue;
|
|
10938
11472
|
const description = meta2.description ?? `Set the value of ${path}`;
|
|
@@ -10961,7 +11495,7 @@ function knobsAsTools(graph, actor) {
|
|
|
10961
11495
|
});
|
|
10962
11496
|
const graphRef = graph;
|
|
10963
11497
|
const actorRef = actor;
|
|
10964
|
-
const nv =
|
|
11498
|
+
const nv = node65.v;
|
|
10965
11499
|
definitions.push({
|
|
10966
11500
|
name: path,
|
|
10967
11501
|
description,
|
|
@@ -10977,8 +11511,8 @@ function knobsAsTools(graph, actor) {
|
|
|
10977
11511
|
}
|
|
10978
11512
|
|
|
10979
11513
|
// src/utils/ai/graph-integration/suggest-strategy.ts
|
|
10980
|
-
var
|
|
10981
|
-
var
|
|
11514
|
+
var import_core61 = require("@graphrefly/pure-ts/core");
|
|
11515
|
+
var import_extra44 = require("@graphrefly/pure-ts/extra");
|
|
10982
11516
|
var SUGGEST_STRATEGY_SYSTEM_PROMPT = `You are a reactive graph optimizer for GraphReFly.
|
|
10983
11517
|
|
|
10984
11518
|
Given a graph's current structure (from describe()) and a problem statement, suggest topology and parameter changes to solve the problem.
|
|
@@ -11047,26 +11581,26 @@ async function suggestStrategy(graph, problem, adapter, opts) {
|
|
|
11047
11581
|
};
|
|
11048
11582
|
}
|
|
11049
11583
|
function suggestStrategyReactive(graph, problem, adapter, opts) {
|
|
11050
|
-
const problemNode = (0,
|
|
11051
|
-
const paired = (0,
|
|
11052
|
-
return (0,
|
|
11053
|
-
if (pair == null) return (0,
|
|
11584
|
+
const problemNode = (0, import_extra44.fromAny)(problem);
|
|
11585
|
+
const paired = (0, import_extra44.withLatestFrom)(problemNode, graph);
|
|
11586
|
+
return (0, import_extra44.switchMap)(paired, (pair) => {
|
|
11587
|
+
if (pair == null) return (0, import_core61.node)([], { initial: null });
|
|
11054
11588
|
const [pText, g] = pair;
|
|
11055
11589
|
if (!g || !pText || typeof pText !== "string" || pText.trim().length === 0) {
|
|
11056
|
-
return (0,
|
|
11590
|
+
return (0, import_core61.node)([], { initial: null });
|
|
11057
11591
|
}
|
|
11058
|
-
if (g.destroyed) return (0,
|
|
11059
|
-
return (0,
|
|
11592
|
+
if (g.destroyed) return (0, import_core61.node)([], { initial: null });
|
|
11593
|
+
return (0, import_core61.node)(
|
|
11060
11594
|
(_data, actions) => {
|
|
11061
11595
|
const controller = new AbortController();
|
|
11062
11596
|
let cancelled = false;
|
|
11063
11597
|
suggestStrategy(g, pText, adapter, { ...opts, signal: controller.signal }).then((plan) => {
|
|
11064
11598
|
if (cancelled) return;
|
|
11065
11599
|
actions.emit(plan);
|
|
11066
|
-
actions.down([[
|
|
11600
|
+
actions.down([[import_core61.COMPLETE]]);
|
|
11067
11601
|
}).catch((err) => {
|
|
11068
11602
|
if (cancelled) return;
|
|
11069
|
-
actions.down([[
|
|
11603
|
+
actions.down([[import_core61.ERROR, err]]);
|
|
11070
11604
|
});
|
|
11071
11605
|
return () => {
|
|
11072
11606
|
cancelled = true;
|
|
@@ -11099,14 +11633,14 @@ function validateGraphDef(def) {
|
|
|
11099
11633
|
errors.push(`Node "${name}": must be an object`);
|
|
11100
11634
|
continue;
|
|
11101
11635
|
}
|
|
11102
|
-
const
|
|
11103
|
-
if (typeof
|
|
11636
|
+
const node65 = raw;
|
|
11637
|
+
if (typeof node65.type !== "string" || !VALID_NODE_TYPES2.has(node65.type)) {
|
|
11104
11638
|
errors.push(
|
|
11105
|
-
`Node "${name}": invalid type "${String(
|
|
11639
|
+
`Node "${name}": invalid type "${String(node65.type)}" (expected: ${[...VALID_NODE_TYPES2].join(", ")})`
|
|
11106
11640
|
);
|
|
11107
11641
|
}
|
|
11108
|
-
if (Array.isArray(
|
|
11109
|
-
for (const dep of
|
|
11642
|
+
if (Array.isArray(node65.deps)) {
|
|
11643
|
+
for (const dep of node65.deps) {
|
|
11110
11644
|
if (typeof dep === "string" && !nodeNames.has(dep)) {
|
|
11111
11645
|
errors.push(`Node "${name}": dep "${dep}" does not reference an existing node`);
|
|
11112
11646
|
}
|
|
@@ -11143,21 +11677,21 @@ function validateGraphDef(def) {
|
|
|
11143
11677
|
}
|
|
11144
11678
|
|
|
11145
11679
|
// src/utils/cqrs/index.ts
|
|
11146
|
-
var
|
|
11147
|
-
var
|
|
11680
|
+
var import_core62 = require("@graphrefly/pure-ts/core");
|
|
11681
|
+
var import_extra45 = require("@graphrefly/pure-ts/extra");
|
|
11148
11682
|
var import_graph11 = require("@graphrefly/pure-ts/graph");
|
|
11149
|
-
var
|
|
11150
|
-
var COMMAND_GUARD = (0,
|
|
11683
|
+
var import_extra46 = require("@graphrefly/pure-ts/extra");
|
|
11684
|
+
var COMMAND_GUARD = (0, import_core62.policy)((allow, deny) => {
|
|
11151
11685
|
allow("write");
|
|
11152
11686
|
allow("signal");
|
|
11153
11687
|
deny("observe");
|
|
11154
11688
|
});
|
|
11155
|
-
var PROJECTION_GUARD = (0,
|
|
11689
|
+
var PROJECTION_GUARD = (0, import_core62.policy)((allow, deny) => {
|
|
11156
11690
|
allow("observe");
|
|
11157
11691
|
allow("signal");
|
|
11158
11692
|
deny("write");
|
|
11159
11693
|
});
|
|
11160
|
-
var EVENT_GUARD = (0,
|
|
11694
|
+
var EVENT_GUARD = (0, import_core62.policy)((allow, deny) => {
|
|
11161
11695
|
allow("observe");
|
|
11162
11696
|
allow("signal");
|
|
11163
11697
|
deny("write");
|
|
@@ -11267,7 +11801,7 @@ var CqrsGraph = class extends import_graph11.Graph {
|
|
|
11267
11801
|
aggregateId,
|
|
11268
11802
|
type,
|
|
11269
11803
|
lastVersion,
|
|
11270
|
-
t_ns: (0,
|
|
11804
|
+
t_ns: (0, import_core62.wallClockNs)()
|
|
11271
11805
|
});
|
|
11272
11806
|
}
|
|
11273
11807
|
}
|
|
@@ -11328,7 +11862,7 @@ var CqrsGraph = class extends import_graph11.Graph {
|
|
|
11328
11862
|
}
|
|
11329
11863
|
const existing = this._eventLogs.get(name);
|
|
11330
11864
|
if (existing) return existing.node;
|
|
11331
|
-
const log = (0,
|
|
11865
|
+
const log = (0, import_extra45.reactiveLog)([], {
|
|
11332
11866
|
name,
|
|
11333
11867
|
versioning: 0,
|
|
11334
11868
|
maxSize: this._retainedLimit
|
|
@@ -11348,7 +11882,7 @@ var CqrsGraph = class extends import_graph11.Graph {
|
|
|
11348
11882
|
initial: entries.cache
|
|
11349
11883
|
}
|
|
11350
11884
|
);
|
|
11351
|
-
this.addDisposer((0,
|
|
11885
|
+
this.addDisposer((0, import_extra46.keepalive)(guarded));
|
|
11352
11886
|
this._eventLogs.set(name, { log, node: guarded });
|
|
11353
11887
|
this._autoWireStreamStorage(name, log);
|
|
11354
11888
|
return guarded;
|
|
@@ -11370,7 +11904,7 @@ var CqrsGraph = class extends import_graph11.Graph {
|
|
|
11370
11904
|
const existing = byType.get(aggregateId);
|
|
11371
11905
|
if (existing) return existing;
|
|
11372
11906
|
const nodeName = `${type}_${aggregateId.replace(/[^a-zA-Z0-9_-]/g, "_")}`;
|
|
11373
|
-
const log = (0,
|
|
11907
|
+
const log = (0, import_extra45.reactiveLog)([], {
|
|
11374
11908
|
name: nodeName,
|
|
11375
11909
|
versioning: 0,
|
|
11376
11910
|
maxSize: this._retainedLimit
|
|
@@ -11402,7 +11936,7 @@ var CqrsGraph = class extends import_graph11.Graph {
|
|
|
11402
11936
|
}
|
|
11403
11937
|
);
|
|
11404
11938
|
} catch {
|
|
11405
|
-
guarded = (0,
|
|
11939
|
+
guarded = (0, import_core62.node)(
|
|
11406
11940
|
[entries],
|
|
11407
11941
|
(batchData, actions, ctx) => {
|
|
11408
11942
|
const latest = batchData[0] != null && batchData[0].length > 0 ? batchData[0].at(-1) : ctx.prevData[0];
|
|
@@ -11420,7 +11954,7 @@ var CqrsGraph = class extends import_graph11.Graph {
|
|
|
11420
11954
|
}
|
|
11421
11955
|
);
|
|
11422
11956
|
}
|
|
11423
|
-
this.addDisposer((0,
|
|
11957
|
+
this.addDisposer((0, import_extra46.keepalive)(guarded));
|
|
11424
11958
|
const entry = { log, node: guarded };
|
|
11425
11959
|
byType.set(aggregateId, entry);
|
|
11426
11960
|
this._autoWireStreamStorage(`${type}::${aggregateId}`, log);
|
|
@@ -11460,7 +11994,7 @@ var CqrsGraph = class extends import_graph11.Graph {
|
|
|
11460
11994
|
const evt = {
|
|
11461
11995
|
type: eventName,
|
|
11462
11996
|
payload: frozenPayload,
|
|
11463
|
-
timestampNs: (0,
|
|
11997
|
+
timestampNs: (0, import_core62.wallClockNs)(),
|
|
11464
11998
|
seq: ++this._seq,
|
|
11465
11999
|
...extra?.aggregateId !== void 0 ? { aggregateId: extra.aggregateId } : {},
|
|
11466
12000
|
...aggregateVersion !== void 0 ? { aggregateVersion } : {},
|
|
@@ -11708,7 +12242,7 @@ var CqrsGraph = class extends import_graph11.Graph {
|
|
|
11708
12242
|
initial: seedState
|
|
11709
12243
|
}
|
|
11710
12244
|
);
|
|
11711
|
-
this.addDisposer((0,
|
|
12245
|
+
this.addDisposer((0, import_extra46.keepalive)(projNode));
|
|
11712
12246
|
this.addDisposer(() => {
|
|
11713
12247
|
if (saveTimer !== void 0) {
|
|
11714
12248
|
clearTimeout(saveTimer);
|
|
@@ -11818,7 +12352,7 @@ var CqrsGraph = class extends import_graph11.Graph {
|
|
|
11818
12352
|
const cursor = cursors[eName];
|
|
11819
12353
|
latestCursors.set(eName, cursor.cache ?? 0);
|
|
11820
12354
|
const sub = cursor.subscribe((msgs) => {
|
|
11821
|
-
for (const m of msgs) if (m[0] ===
|
|
12355
|
+
for (const m of msgs) if (m[0] === import_core62.DATA) latestCursors.set(eName, m[1]);
|
|
11822
12356
|
});
|
|
11823
12357
|
this.addDisposer(sub);
|
|
11824
12358
|
}
|
|
@@ -11898,7 +12432,7 @@ var CqrsGraph = class extends import_graph11.Graph {
|
|
|
11898
12432
|
}
|
|
11899
12433
|
);
|
|
11900
12434
|
sagaRef.n = sagaNode;
|
|
11901
|
-
this.addDisposer((0,
|
|
12435
|
+
this.addDisposer((0, import_extra46.keepalive)(sagaNode));
|
|
11902
12436
|
this._sagas.add(name);
|
|
11903
12437
|
return {
|
|
11904
12438
|
node: sagaNode,
|
|
@@ -11911,12 +12445,12 @@ var CqrsGraph = class extends import_graph11.Graph {
|
|
|
11911
12445
|
function cqrs(name, opts) {
|
|
11912
12446
|
const g = new CqrsGraph(name, opts);
|
|
11913
12447
|
const { factory: _f, factoryArgs: _fa, ...tagArgs } = opts ?? {};
|
|
11914
|
-
g.tagFactory("cqrs", (0,
|
|
12448
|
+
g.tagFactory("cqrs", (0, import_core62.placeholderArgs)(tagArgs));
|
|
11915
12449
|
return g;
|
|
11916
12450
|
}
|
|
11917
12451
|
|
|
11918
12452
|
// src/utils/demo-shell/index.ts
|
|
11919
|
-
var
|
|
12453
|
+
var import_core65 = require("@graphrefly/pure-ts/core");
|
|
11920
12454
|
var import_graph13 = require("@graphrefly/pure-ts/graph");
|
|
11921
12455
|
|
|
11922
12456
|
// src/base/render/_ascii-width.ts
|
|
@@ -12539,14 +13073,14 @@ function graphSpecToMermaid(g, opts) {
|
|
|
12539
13073
|
}
|
|
12540
13074
|
|
|
12541
13075
|
// src/utils/reactive-layout/reactive-layout.ts
|
|
12542
|
-
var
|
|
13076
|
+
var import_core64 = require("@graphrefly/pure-ts/core");
|
|
12543
13077
|
var import_graph12 = require("@graphrefly/pure-ts/graph");
|
|
12544
13078
|
|
|
12545
13079
|
// src/base/meta/emit-to-meta.ts
|
|
12546
|
-
var
|
|
13080
|
+
var import_core63 = require("@graphrefly/pure-ts/core");
|
|
12547
13081
|
function emitToMeta(metaNode, value) {
|
|
12548
13082
|
if (metaNode == null) return;
|
|
12549
|
-
(0,
|
|
13083
|
+
(0, import_core63.downWithBatch)((msgs) => metaNode.down(msgs), [[import_core63.DATA, value]], import_core63.defaultConfig.tierOf);
|
|
12550
13084
|
}
|
|
12551
13085
|
|
|
12552
13086
|
// src/utils/reactive-layout/reactive-layout.ts
|
|
@@ -13247,16 +13781,16 @@ function reactiveLayout(opts) {
|
|
|
13247
13781
|
const { adapter, name = "reactive-layout" } = opts;
|
|
13248
13782
|
const g = new import_graph12.Graph(name);
|
|
13249
13783
|
const measureCache = /* @__PURE__ */ new Map();
|
|
13250
|
-
const textNode = (0,
|
|
13251
|
-
const fontNode = (0,
|
|
13784
|
+
const textNode = (0, import_core64.node)([], { name: "text", initial: opts.text ?? "" });
|
|
13785
|
+
const fontNode = (0, import_core64.node)([], {
|
|
13252
13786
|
name: "font",
|
|
13253
13787
|
initial: opts.font ?? "16px sans-serif"
|
|
13254
13788
|
});
|
|
13255
|
-
const lineHeightNode = (0,
|
|
13789
|
+
const lineHeightNode = (0, import_core64.node)([], {
|
|
13256
13790
|
name: "line-height",
|
|
13257
13791
|
initial: opts.lineHeight ?? 20
|
|
13258
13792
|
});
|
|
13259
|
-
const maxWidthNode = (0,
|
|
13793
|
+
const maxWidthNode = (0, import_core64.node)([], {
|
|
13260
13794
|
name: "max-width",
|
|
13261
13795
|
initial: Math.max(0, opts.maxWidth ?? 800)
|
|
13262
13796
|
});
|
|
@@ -13268,14 +13802,14 @@ function reactiveLayout(opts) {
|
|
|
13268
13802
|
}
|
|
13269
13803
|
return true;
|
|
13270
13804
|
}
|
|
13271
|
-
const segmentsNode = (0,
|
|
13805
|
+
const segmentsNode = (0, import_core64.node)(
|
|
13272
13806
|
[textNode, fontNode],
|
|
13273
13807
|
(data, actions, ctx) => {
|
|
13274
13808
|
const b0 = data[0];
|
|
13275
13809
|
const textVal = b0 != null && b0.length > 0 ? b0.at(-1) : ctx.prevData[0];
|
|
13276
13810
|
const b1 = data[1];
|
|
13277
13811
|
const fontVal = b1 != null && b1.length > 0 ? b1.at(-1) : ctx.prevData[1];
|
|
13278
|
-
const t0 = (0,
|
|
13812
|
+
const t0 = (0, import_core64.monotonicNs)();
|
|
13279
13813
|
const measureStats = { hits: 0, misses: 0 };
|
|
13280
13814
|
const result = analyzeAndMeasure(
|
|
13281
13815
|
textVal,
|
|
@@ -13284,7 +13818,7 @@ function reactiveLayout(opts) {
|
|
|
13284
13818
|
measureCache,
|
|
13285
13819
|
measureStats
|
|
13286
13820
|
);
|
|
13287
|
-
const elapsed = (0,
|
|
13821
|
+
const elapsed = (0, import_core64.monotonicNs)() - t0;
|
|
13288
13822
|
const lookups = measureStats.hits + measureStats.misses;
|
|
13289
13823
|
const hitRate = lookups === 0 ? 1 : measureStats.hits / lookups;
|
|
13290
13824
|
const meta2 = segmentsNode.meta;
|
|
@@ -13323,7 +13857,7 @@ function reactiveLayout(opts) {
|
|
|
13323
13857
|
}
|
|
13324
13858
|
}
|
|
13325
13859
|
);
|
|
13326
|
-
const lineBreaksNode = (0,
|
|
13860
|
+
const lineBreaksNode = (0, import_core64.node)(
|
|
13327
13861
|
[segmentsNode, maxWidthNode, fontNode],
|
|
13328
13862
|
(batchData, actions, ctx) => {
|
|
13329
13863
|
const data = batchData.map(
|
|
@@ -13357,7 +13891,7 @@ function reactiveLayout(opts) {
|
|
|
13357
13891
|
}
|
|
13358
13892
|
}
|
|
13359
13893
|
);
|
|
13360
|
-
const heightNode = (0,
|
|
13894
|
+
const heightNode = (0, import_core64.node)(
|
|
13361
13895
|
[lineBreaksNode, lineHeightNode],
|
|
13362
13896
|
(batchData, actions, ctx) => {
|
|
13363
13897
|
const data = batchData.map(
|
|
@@ -13367,7 +13901,7 @@ function reactiveLayout(opts) {
|
|
|
13367
13901
|
},
|
|
13368
13902
|
{ describeKind: "derived", name: "height" }
|
|
13369
13903
|
);
|
|
13370
|
-
const charPositionsNode = (0,
|
|
13904
|
+
const charPositionsNode = (0, import_core64.node)(
|
|
13371
13905
|
[lineBreaksNode, segmentsNode, lineHeightNode],
|
|
13372
13906
|
(batchData, actions, ctx) => {
|
|
13373
13907
|
const data = batchData.map(
|
|
@@ -13419,32 +13953,32 @@ function reactiveLayout(opts) {
|
|
|
13419
13953
|
}
|
|
13420
13954
|
|
|
13421
13955
|
// src/utils/demo-shell/index.ts
|
|
13422
|
-
function
|
|
13956
|
+
function clamp012(v) {
|
|
13423
13957
|
return Math.max(0, Math.min(1, v));
|
|
13424
13958
|
}
|
|
13425
13959
|
function demoShell(opts) {
|
|
13426
|
-
const mainRatioInit =
|
|
13427
|
-
const sideSplitInit =
|
|
13960
|
+
const mainRatioInit = clamp012(opts?.mainRatio ?? 0.65);
|
|
13961
|
+
const sideSplitInit = clamp012(opts?.sideSplit ?? 0.5);
|
|
13428
13962
|
const viewportInit = Math.max(0, opts?.viewportWidth ?? 1280);
|
|
13429
13963
|
const registry = opts?.nodeRegistry ?? /* @__PURE__ */ new Map();
|
|
13430
13964
|
const adapter = opts?.adapter ?? null;
|
|
13431
13965
|
const layoutFont = opts?.layoutFont ?? "14px monospace";
|
|
13432
13966
|
const onHighlight = opts?.onHighlight;
|
|
13433
13967
|
const g = new import_graph13.Graph("demo-shell");
|
|
13434
|
-
const paneMainRatio = (0,
|
|
13435
|
-
const paneSideSplit = (0,
|
|
13436
|
-
const paneFullscreen = (0,
|
|
13968
|
+
const paneMainRatio = (0, import_core65.node)([], { ...{ name: "pane/main-ratio" }, initial: mainRatioInit });
|
|
13969
|
+
const paneSideSplit = (0, import_core65.node)([], { ...{ name: "pane/side-split" }, initial: sideSplitInit });
|
|
13970
|
+
const paneFullscreen = (0, import_core65.node)([], {
|
|
13437
13971
|
...{
|
|
13438
13972
|
name: "pane/fullscreen"
|
|
13439
13973
|
},
|
|
13440
13974
|
initial: null
|
|
13441
13975
|
});
|
|
13442
|
-
const viewportWidth = (0,
|
|
13976
|
+
const viewportWidth = (0, import_core65.node)([], { ...{ name: "viewport/width" }, initial: viewportInit });
|
|
13443
13977
|
g.add(paneMainRatio, { name: "pane/main-ratio" });
|
|
13444
13978
|
g.add(paneSideSplit, { name: "pane/side-split" });
|
|
13445
13979
|
g.add(paneFullscreen, { name: "pane/fullscreen" });
|
|
13446
13980
|
g.add(viewportWidth, { name: "viewport/width" });
|
|
13447
|
-
const paneMainWidth = (0,
|
|
13981
|
+
const paneMainWidth = (0, import_core65.node)(
|
|
13448
13982
|
[paneMainRatio, viewportWidth, paneFullscreen],
|
|
13449
13983
|
(batchData, actions, ctx) => {
|
|
13450
13984
|
const data = batchData.map(
|
|
@@ -13459,7 +13993,7 @@ function demoShell(opts) {
|
|
|
13459
13993
|
},
|
|
13460
13994
|
{ describeKind: "derived", ...{ name: "pane/main-width" } }
|
|
13461
13995
|
);
|
|
13462
|
-
const paneSideWidth = (0,
|
|
13996
|
+
const paneSideWidth = (0, import_core65.node)(
|
|
13463
13997
|
[paneMainWidth, viewportWidth, paneFullscreen],
|
|
13464
13998
|
(batchData, actions, ctx) => {
|
|
13465
13999
|
const data = batchData.map(
|
|
@@ -13474,7 +14008,7 @@ function demoShell(opts) {
|
|
|
13474
14008
|
},
|
|
13475
14009
|
{ describeKind: "derived", ...{ name: "pane/side-width" } }
|
|
13476
14010
|
);
|
|
13477
|
-
const paneGraphHeight = (0,
|
|
14011
|
+
const paneGraphHeight = (0, import_core65.node)(
|
|
13478
14012
|
[paneSideSplit, paneFullscreen],
|
|
13479
14013
|
(batchData, actions, ctx) => {
|
|
13480
14014
|
const data = batchData.map(
|
|
@@ -13485,11 +14019,11 @@ function demoShell(opts) {
|
|
|
13485
14019
|
if (fullscreen === "graph") actions.emit(1);
|
|
13486
14020
|
else if (fullscreen === "code") actions.emit(0);
|
|
13487
14021
|
else if (fullscreen === "main") actions.emit(0);
|
|
13488
|
-
else actions.emit(
|
|
14022
|
+
else actions.emit(clamp012(split));
|
|
13489
14023
|
},
|
|
13490
14024
|
{ describeKind: "derived", ...{ name: "pane/graph-height-ratio" } }
|
|
13491
14025
|
);
|
|
13492
|
-
const paneCodeHeight = (0,
|
|
14026
|
+
const paneCodeHeight = (0, import_core65.node)(
|
|
13493
14027
|
[paneGraphHeight, paneFullscreen],
|
|
13494
14028
|
(batchData, actions, ctx) => {
|
|
13495
14029
|
const data = batchData.map(
|
|
@@ -13507,16 +14041,16 @@ function demoShell(opts) {
|
|
|
13507
14041
|
g.add(paneSideWidth, { name: "pane/side-width" });
|
|
13508
14042
|
g.add(paneGraphHeight, { name: "pane/graph-height-ratio" });
|
|
13509
14043
|
g.add(paneCodeHeight, { name: "pane/code-height-ratio" });
|
|
13510
|
-
const demoGraphRef = (0,
|
|
14044
|
+
const demoGraphRef = (0, import_core65.node)([], {
|
|
13511
14045
|
...{
|
|
13512
14046
|
name: "demo/graph-ref"
|
|
13513
14047
|
},
|
|
13514
14048
|
initial: null
|
|
13515
14049
|
});
|
|
13516
|
-
const demoGraphTick = (0,
|
|
14050
|
+
const demoGraphTick = (0, import_core65.node)([], { ...{ name: "demo/graph-tick" }, initial: 0 });
|
|
13517
14051
|
g.add(demoGraphRef, { name: "demo/graph-ref" });
|
|
13518
14052
|
g.add(demoGraphTick, { name: "demo/graph-tick" });
|
|
13519
|
-
const graphMermaid = (0,
|
|
14053
|
+
const graphMermaid = (0, import_core65.node)(
|
|
13520
14054
|
[demoGraphRef, demoGraphTick],
|
|
13521
14055
|
(batchData, actions, ctx) => {
|
|
13522
14056
|
const data = batchData.map(
|
|
@@ -13527,7 +14061,7 @@ function demoShell(opts) {
|
|
|
13527
14061
|
},
|
|
13528
14062
|
{ describeKind: "derived", ...{ name: "graph/mermaid" } }
|
|
13529
14063
|
);
|
|
13530
|
-
const graphDescribe = (0,
|
|
14064
|
+
const graphDescribe = (0, import_core65.node)(
|
|
13531
14065
|
[demoGraphRef, demoGraphTick],
|
|
13532
14066
|
(batchData, actions, ctx) => {
|
|
13533
14067
|
const data = batchData.map(
|
|
@@ -13545,9 +14079,9 @@ function demoShell(opts) {
|
|
|
13545
14079
|
);
|
|
13546
14080
|
g.add(graphMermaid, { name: "graph/mermaid" });
|
|
13547
14081
|
g.add(graphDescribe, { name: "graph/describe" });
|
|
13548
|
-
const hoverTarget = (0,
|
|
14082
|
+
const hoverTarget = (0, import_core65.node)([], { ...{ name: "hover/target" }, initial: null });
|
|
13549
14083
|
g.add(hoverTarget, { name: "hover/target" });
|
|
13550
|
-
const highlightCodeScroll = (0,
|
|
14084
|
+
const highlightCodeScroll = (0, import_core65.node)(
|
|
13551
14085
|
[hoverTarget],
|
|
13552
14086
|
(batchData, actions, ctx) => {
|
|
13553
14087
|
const data = batchData.map(
|
|
@@ -13563,7 +14097,7 @@ function demoShell(opts) {
|
|
|
13563
14097
|
},
|
|
13564
14098
|
{ describeKind: "derived", ...{ name: "highlight/code-scroll" } }
|
|
13565
14099
|
);
|
|
13566
|
-
const highlightVisual = (0,
|
|
14100
|
+
const highlightVisual = (0, import_core65.node)(
|
|
13567
14101
|
[hoverTarget],
|
|
13568
14102
|
(batchData, actions, ctx) => {
|
|
13569
14103
|
const data = batchData.map(
|
|
@@ -13579,7 +14113,7 @@ function demoShell(opts) {
|
|
|
13579
14113
|
},
|
|
13580
14114
|
{ describeKind: "derived", ...{ name: "highlight/visual" } }
|
|
13581
14115
|
);
|
|
13582
|
-
const highlightGraph = (0,
|
|
14116
|
+
const highlightGraph = (0, import_core65.node)(
|
|
13583
14117
|
[hoverTarget],
|
|
13584
14118
|
(batchData, actions, ctx) => {
|
|
13585
14119
|
const data = batchData.map(
|
|
@@ -13595,7 +14129,7 @@ function demoShell(opts) {
|
|
|
13595
14129
|
g.add(highlightGraph, { name: "highlight/graph" });
|
|
13596
14130
|
if (onHighlight?.codeScroll) {
|
|
13597
14131
|
const cb = onHighlight.codeScroll;
|
|
13598
|
-
const applyCodeScroll = (0,
|
|
14132
|
+
const applyCodeScroll = (0, import_core65.node)(
|
|
13599
14133
|
[highlightCodeScroll],
|
|
13600
14134
|
(batchData, _actions, ctx) => {
|
|
13601
14135
|
const data = batchData.map(
|
|
@@ -13609,7 +14143,7 @@ function demoShell(opts) {
|
|
|
13609
14143
|
}
|
|
13610
14144
|
if (onHighlight?.visual) {
|
|
13611
14145
|
const cb = onHighlight.visual;
|
|
13612
|
-
const applyVisual = (0,
|
|
14146
|
+
const applyVisual = (0, import_core65.node)(
|
|
13613
14147
|
[highlightVisual],
|
|
13614
14148
|
(batchData, _actions, ctx) => {
|
|
13615
14149
|
const data = batchData.map(
|
|
@@ -13623,7 +14157,7 @@ function demoShell(opts) {
|
|
|
13623
14157
|
}
|
|
13624
14158
|
if (onHighlight?.graph) {
|
|
13625
14159
|
const cb = onHighlight.graph;
|
|
13626
|
-
const applyGraph = (0,
|
|
14160
|
+
const applyGraph = (0, import_core65.node)(
|
|
13627
14161
|
[highlightGraph],
|
|
13628
14162
|
(batchData, _actions, ctx) => {
|
|
13629
14163
|
const data = batchData.map(
|
|
@@ -13635,14 +14169,14 @@ function demoShell(opts) {
|
|
|
13635
14169
|
);
|
|
13636
14170
|
g.add(applyGraph, { name: "highlight/apply-graph" });
|
|
13637
14171
|
}
|
|
13638
|
-
const inspectSelected = (0,
|
|
14172
|
+
const inspectSelected = (0, import_core65.node)([], {
|
|
13639
14173
|
...{
|
|
13640
14174
|
name: "inspect/selected-node"
|
|
13641
14175
|
},
|
|
13642
14176
|
initial: null
|
|
13643
14177
|
});
|
|
13644
14178
|
g.add(inspectSelected, { name: "inspect/selected-node" });
|
|
13645
|
-
const inspectNodeDetail = (0,
|
|
14179
|
+
const inspectNodeDetail = (0, import_core65.node)(
|
|
13646
14180
|
[inspectSelected, demoGraphRef, demoGraphTick],
|
|
13647
14181
|
(batchData, actions, ctx) => {
|
|
13648
14182
|
const data = batchData.map(
|
|
@@ -13668,7 +14202,7 @@ function demoShell(opts) {
|
|
|
13668
14202
|
},
|
|
13669
14203
|
{ describeKind: "derived", ...{ name: "inspect/node-detail" } }
|
|
13670
14204
|
);
|
|
13671
|
-
const inspectTraceLog = (0,
|
|
14205
|
+
const inspectTraceLog = (0, import_core65.node)(
|
|
13672
14206
|
[demoGraphRef, demoGraphTick],
|
|
13673
14207
|
(batchData, actions, ctx) => {
|
|
13674
14208
|
const data = batchData.map(
|
|
@@ -13681,9 +14215,9 @@ function demoShell(opts) {
|
|
|
13681
14215
|
);
|
|
13682
14216
|
g.add(inspectNodeDetail, { name: "inspect/node-detail" });
|
|
13683
14217
|
g.add(inspectTraceLog, { name: "inspect/trace-log" });
|
|
13684
|
-
const metaDebug = (0,
|
|
14218
|
+
const metaDebug = (0, import_core65.node)([], { ...{ name: "meta/debug" }, initial: false });
|
|
13685
14219
|
g.add(metaDebug, { name: "meta/debug" });
|
|
13686
|
-
const metaShellMermaid = (0,
|
|
14220
|
+
const metaShellMermaid = (0, import_core65.node)(
|
|
13687
14221
|
[metaDebug, demoGraphTick],
|
|
13688
14222
|
(batchData, actions, ctx) => {
|
|
13689
14223
|
const data = batchData.map(
|
|
@@ -13694,11 +14228,11 @@ function demoShell(opts) {
|
|
|
13694
14228
|
{ describeKind: "derived", ...{ name: "meta/shell-mermaid" } }
|
|
13695
14229
|
);
|
|
13696
14230
|
g.add(metaShellMermaid, { name: "meta/shell-mermaid" });
|
|
13697
|
-
const codeTextNode = (0,
|
|
14231
|
+
const codeTextNode = (0, import_core65.node)([], { ...{ name: "layout/code-text" }, initial: "" });
|
|
13698
14232
|
g.add(codeTextNode, { name: "layout/code-text" });
|
|
13699
14233
|
if (adapter) {
|
|
13700
14234
|
const measureCache = /* @__PURE__ */ new Map();
|
|
13701
|
-
const graphLabels = (0,
|
|
14235
|
+
const graphLabels = (0, import_core65.node)(
|
|
13702
14236
|
[graphDescribe],
|
|
13703
14237
|
(batchData, actions, ctx) => {
|
|
13704
14238
|
const data = batchData.map(
|
|
@@ -13737,7 +14271,7 @@ function demoShell(opts) {
|
|
|
13737
14271
|
}
|
|
13738
14272
|
}
|
|
13739
14273
|
);
|
|
13740
|
-
const codeLines = (0,
|
|
14274
|
+
const codeLines = (0, import_core65.node)(
|
|
13741
14275
|
[codeTextNode, paneSideWidth],
|
|
13742
14276
|
(batchData, actions, ctx) => {
|
|
13743
14277
|
const data = batchData.map(
|
|
@@ -13756,7 +14290,7 @@ function demoShell(opts) {
|
|
|
13756
14290
|
},
|
|
13757
14291
|
{ describeKind: "derived", name: "layout/code-lines" }
|
|
13758
14292
|
);
|
|
13759
|
-
const sideWidthHint = (0,
|
|
14293
|
+
const sideWidthHint = (0, import_core65.node)(
|
|
13760
14294
|
[graphLabels],
|
|
13761
14295
|
(batchData, actions, ctx) => {
|
|
13762
14296
|
const data = batchData.map(
|
|
@@ -13783,10 +14317,10 @@ function demoShell(opts) {
|
|
|
13783
14317
|
return {
|
|
13784
14318
|
graph: g,
|
|
13785
14319
|
setMainRatio(ratio) {
|
|
13786
|
-
g.set("pane/main-ratio",
|
|
14320
|
+
g.set("pane/main-ratio", clamp012(ratio));
|
|
13787
14321
|
},
|
|
13788
14322
|
setSideSplit(ratio) {
|
|
13789
|
-
g.set("pane/side-split",
|
|
14323
|
+
g.set("pane/side-split", clamp012(ratio));
|
|
13790
14324
|
},
|
|
13791
14325
|
setFullscreen(pane) {
|
|
13792
14326
|
g.set("pane/fullscreen", pane);
|
|
@@ -13813,7 +14347,7 @@ function demoShell(opts) {
|
|
|
13813
14347
|
g.set("layout/code-text", text);
|
|
13814
14348
|
},
|
|
13815
14349
|
batch(fn) {
|
|
13816
|
-
(0,
|
|
14350
|
+
(0, import_core65.batch)(fn);
|
|
13817
14351
|
},
|
|
13818
14352
|
destroy() {
|
|
13819
14353
|
g.destroy();
|
|
@@ -13822,10 +14356,10 @@ function demoShell(opts) {
|
|
|
13822
14356
|
}
|
|
13823
14357
|
|
|
13824
14358
|
// src/utils/domain-templates/index.ts
|
|
13825
|
-
var
|
|
13826
|
-
var
|
|
14359
|
+
var import_core66 = require("@graphrefly/pure-ts/core");
|
|
14360
|
+
var import_extra47 = require("@graphrefly/pure-ts/extra");
|
|
13827
14361
|
var import_graph14 = require("@graphrefly/pure-ts/graph");
|
|
13828
|
-
var
|
|
14362
|
+
var import_extra48 = require("@graphrefly/pure-ts/extra");
|
|
13829
14363
|
function baseMeta2(kind, extra) {
|
|
13830
14364
|
return domainMeta("domain_template", kind, extra);
|
|
13831
14365
|
}
|
|
@@ -13842,12 +14376,12 @@ function observabilityGraph(name, opts) {
|
|
|
13842
14376
|
name: b.name,
|
|
13843
14377
|
classify: b.classify
|
|
13844
14378
|
}));
|
|
13845
|
-
const strat = (0,
|
|
14379
|
+
const strat = (0, import_extra47.stratify)("stratify", opts.source, rules);
|
|
13846
14380
|
g.mount("stratify", strat);
|
|
13847
14381
|
const branchNodes = branches.map((b) => {
|
|
13848
14382
|
try {
|
|
13849
14383
|
const raw = g.resolve(`stratify::branch/${b.name}`);
|
|
13850
|
-
return (0,
|
|
14384
|
+
return (0, import_core66.node)(
|
|
13851
14385
|
[raw],
|
|
13852
14386
|
(batchData, actions, ctx) => {
|
|
13853
14387
|
const data = batchData.map(
|
|
@@ -13858,11 +14392,11 @@ function observabilityGraph(name, opts) {
|
|
|
13858
14392
|
{ initial: null, describeKind: "derived" }
|
|
13859
14393
|
);
|
|
13860
14394
|
} catch {
|
|
13861
|
-
return (0,
|
|
14395
|
+
return (0, import_core66.node)([], { initial: null });
|
|
13862
14396
|
}
|
|
13863
14397
|
});
|
|
13864
14398
|
const correlateFn = opts.correlate ?? ((vals) => vals);
|
|
13865
|
-
const correlateNode = (0,
|
|
14399
|
+
const correlateNode = (0, import_core66.node)(
|
|
13866
14400
|
branchNodes,
|
|
13867
14401
|
(batchData, actions, ctx) => {
|
|
13868
14402
|
const vals = batchData.map(
|
|
@@ -13877,7 +14411,7 @@ function observabilityGraph(name, opts) {
|
|
|
13877
14411
|
);
|
|
13878
14412
|
g.add(correlateNode, { name: "correlate" });
|
|
13879
14413
|
const sloCheckFn = opts.sloCheck ?? (() => ({ pass: true }));
|
|
13880
|
-
const sloValue = (0,
|
|
14414
|
+
const sloValue = (0, import_core66.node)(
|
|
13881
14415
|
[correlateNode],
|
|
13882
14416
|
(batchData, actions, ctx) => {
|
|
13883
14417
|
const data = batchData.map(
|
|
@@ -13890,7 +14424,7 @@ function observabilityGraph(name, opts) {
|
|
|
13890
14424
|
meta: baseMeta2("observability", { stage: "slo_value" })
|
|
13891
14425
|
}
|
|
13892
14426
|
);
|
|
13893
|
-
const sloVerified = (0,
|
|
14427
|
+
const sloVerified = (0, import_core66.node)(
|
|
13894
14428
|
[sloValue],
|
|
13895
14429
|
(batchData, actions, ctx) => {
|
|
13896
14430
|
const data = batchData.map(
|
|
@@ -13907,7 +14441,7 @@ function observabilityGraph(name, opts) {
|
|
|
13907
14441
|
g.add(sloVerified, { name: "slo_verified" });
|
|
13908
14442
|
const weightValues = opts.weights ?? branches.map(() => 1);
|
|
13909
14443
|
const signalNodes = branchNodes.map(
|
|
13910
|
-
(bn) => (0,
|
|
14444
|
+
(bn) => (0, import_core66.node)(
|
|
13911
14445
|
[bn],
|
|
13912
14446
|
(batchData, actions, ctx) => {
|
|
13913
14447
|
const data = batchData.map(
|
|
@@ -13918,7 +14452,7 @@ function observabilityGraph(name, opts) {
|
|
|
13918
14452
|
{ describeKind: "derived" }
|
|
13919
14453
|
)
|
|
13920
14454
|
);
|
|
13921
|
-
const weightNodes = weightValues.map((w) => (0,
|
|
14455
|
+
const weightNodes = weightValues.map((w) => (0, import_core66.node)([], { initial: w }));
|
|
13922
14456
|
for (let i = 0; i < signalNodes.length; i++) {
|
|
13923
14457
|
g.add(signalNodes[i], { name: `__signal_${i}` });
|
|
13924
14458
|
g.add(weightNodes[i], { name: `__weight_${i}` });
|
|
@@ -13928,7 +14462,7 @@ function observabilityGraph(name, opts) {
|
|
|
13928
14462
|
weightNodes
|
|
13929
14463
|
);
|
|
13930
14464
|
g.add(alerts, { name: "alerts" });
|
|
13931
|
-
const output = (0,
|
|
14465
|
+
const output = (0, import_core66.node)(
|
|
13932
14466
|
[alerts, sloVerified],
|
|
13933
14467
|
(batchData, actions, ctx) => {
|
|
13934
14468
|
const vals = batchData.map(
|
|
@@ -13945,12 +14479,12 @@ function observabilityGraph(name, opts) {
|
|
|
13945
14479
|
}
|
|
13946
14480
|
);
|
|
13947
14481
|
g.add(output, { name: "output" });
|
|
13948
|
-
const fbReentry = (0,
|
|
14482
|
+
const fbReentry = (0, import_core66.node)([], {
|
|
13949
14483
|
initial: null,
|
|
13950
14484
|
meta: baseMeta2("observability", { stage: "feedback_reentry" })
|
|
13951
14485
|
});
|
|
13952
14486
|
g.add(fbReentry, { name: "feedback_reentry" });
|
|
13953
|
-
const fbCondition = (0,
|
|
14487
|
+
const fbCondition = (0, import_core66.node)(
|
|
13954
14488
|
[sloVerified],
|
|
13955
14489
|
(batchData, actions, ctx) => {
|
|
13956
14490
|
const data = batchData.map(
|
|
@@ -13982,7 +14516,7 @@ function issueTrackerGraph(name, opts) {
|
|
|
13982
14516
|
raw
|
|
13983
14517
|
});
|
|
13984
14518
|
const extractFn = opts.extract ?? defaultExtract;
|
|
13985
|
-
const extractNode = (0,
|
|
14519
|
+
const extractNode = (0, import_core66.node)(
|
|
13986
14520
|
[opts.source],
|
|
13987
14521
|
(batchData, actions, ctx) => {
|
|
13988
14522
|
const data = batchData.map(
|
|
@@ -13997,7 +14531,7 @@ function issueTrackerGraph(name, opts) {
|
|
|
13997
14531
|
);
|
|
13998
14532
|
g.add(extractNode, { name: "extract" });
|
|
13999
14533
|
const verifyFn = opts.verify ?? (() => ({ valid: true }));
|
|
14000
|
-
const verifyNode = (0,
|
|
14534
|
+
const verifyNode = (0, import_core66.node)(
|
|
14001
14535
|
[extractNode],
|
|
14002
14536
|
(batchData, actions, ctx) => {
|
|
14003
14537
|
const data = batchData.map(
|
|
@@ -14012,13 +14546,13 @@ function issueTrackerGraph(name, opts) {
|
|
|
14012
14546
|
}
|
|
14013
14547
|
);
|
|
14014
14548
|
g.add(verifyNode, { name: "verify" });
|
|
14015
|
-
const knownPatterns = (0,
|
|
14549
|
+
const knownPatterns = (0, import_core66.node)([], {
|
|
14016
14550
|
initial: [],
|
|
14017
14551
|
meta: baseMeta2("issue_tracker", { stage: "known_patterns" })
|
|
14018
14552
|
});
|
|
14019
14553
|
g.add(knownPatterns, { name: "known_patterns" });
|
|
14020
14554
|
const detectFn = opts.detectRegression ?? (() => ({ regression: false }));
|
|
14021
|
-
const regressionNode = (0,
|
|
14555
|
+
const regressionNode = (0, import_core66.node)(
|
|
14022
14556
|
[extractNode, knownPatterns],
|
|
14023
14557
|
(batchData, actions, ctx) => {
|
|
14024
14558
|
const data = batchData.map(
|
|
@@ -14031,7 +14565,7 @@ function issueTrackerGraph(name, opts) {
|
|
|
14031
14565
|
{ describeKind: "derived", meta: baseMeta2("issue_tracker", { stage: "regression" }) }
|
|
14032
14566
|
);
|
|
14033
14567
|
g.add(regressionNode, { name: "regression" });
|
|
14034
|
-
const severitySignal = (0,
|
|
14568
|
+
const severitySignal = (0, import_core66.node)(
|
|
14035
14569
|
[extractNode],
|
|
14036
14570
|
(batchData, actions, ctx) => {
|
|
14037
14571
|
const data = batchData.map(
|
|
@@ -14042,7 +14576,7 @@ function issueTrackerGraph(name, opts) {
|
|
|
14042
14576
|
},
|
|
14043
14577
|
{ describeKind: "derived" }
|
|
14044
14578
|
);
|
|
14045
|
-
const regressionSignal = (0,
|
|
14579
|
+
const regressionSignal = (0, import_core66.node)(
|
|
14046
14580
|
[regressionNode],
|
|
14047
14581
|
(batchData, actions, ctx) => {
|
|
14048
14582
|
const data = batchData.map(
|
|
@@ -14055,13 +14589,13 @@ function issueTrackerGraph(name, opts) {
|
|
|
14055
14589
|
);
|
|
14056
14590
|
g.add(severitySignal, { name: "__severity_signal" });
|
|
14057
14591
|
g.add(regressionSignal, { name: "__regression_signal" });
|
|
14058
|
-
const severityWeight = (0,
|
|
14059
|
-
const regressionWeight = (0,
|
|
14592
|
+
const severityWeight = (0, import_core66.node)([], { initial: 1 });
|
|
14593
|
+
const regressionWeight = (0, import_core66.node)([], { initial: 1.5 });
|
|
14060
14594
|
g.add(severityWeight, { name: "__severity_weight" });
|
|
14061
14595
|
g.add(regressionWeight, { name: "__regression_weight" });
|
|
14062
14596
|
const priority = scorer([severitySignal, regressionSignal], [severityWeight, regressionWeight]);
|
|
14063
14597
|
g.add(priority, { name: "priority" });
|
|
14064
|
-
const output = (0,
|
|
14598
|
+
const output = (0, import_core66.node)(
|
|
14065
14599
|
[verifyNode, regressionNode, priority],
|
|
14066
14600
|
(batchData, actions, ctx) => {
|
|
14067
14601
|
const vals = batchData.map(
|
|
@@ -14076,12 +14610,12 @@ function issueTrackerGraph(name, opts) {
|
|
|
14076
14610
|
{ describeKind: "derived", meta: baseMeta2("issue_tracker", { stage: "output" }) }
|
|
14077
14611
|
);
|
|
14078
14612
|
g.add(output, { name: "output" });
|
|
14079
|
-
const fbReentry = (0,
|
|
14613
|
+
const fbReentry = (0, import_core66.node)([], {
|
|
14080
14614
|
initial: null,
|
|
14081
14615
|
meta: baseMeta2("issue_tracker", { stage: "feedback_reentry" })
|
|
14082
14616
|
});
|
|
14083
14617
|
g.add(fbReentry, { name: "feedback_reentry" });
|
|
14084
|
-
const fbCondition = (0,
|
|
14618
|
+
const fbCondition = (0, import_core66.node)(
|
|
14085
14619
|
[verifyNode],
|
|
14086
14620
|
(batchData, actions, ctx) => {
|
|
14087
14621
|
const data = batchData.map(
|
|
@@ -14117,7 +14651,7 @@ function contentModerationGraph(name, opts) {
|
|
|
14117
14651
|
original: content
|
|
14118
14652
|
});
|
|
14119
14653
|
const classifyFn = opts.classify ?? defaultClassify;
|
|
14120
|
-
const classifyNode = (0,
|
|
14654
|
+
const classifyNode = (0, import_core66.node)(
|
|
14121
14655
|
[opts.source],
|
|
14122
14656
|
(batchData, actions, ctx) => {
|
|
14123
14657
|
const data = batchData.map(
|
|
@@ -14131,13 +14665,13 @@ function contentModerationGraph(name, opts) {
|
|
|
14131
14665
|
}
|
|
14132
14666
|
);
|
|
14133
14667
|
g.add(classifyNode, { name: "classify" });
|
|
14134
|
-
const strat = (0,
|
|
14668
|
+
const strat = (0, import_extra47.stratify)("stratify", classifyNode, [
|
|
14135
14669
|
{ name: "safe", classify: (v) => v.label === "safe" },
|
|
14136
14670
|
{ name: "review", classify: (v) => v.label === "review" },
|
|
14137
14671
|
{ name: "block", classify: (v) => v.label === "block" }
|
|
14138
14672
|
]);
|
|
14139
14673
|
g.mount("stratify", strat);
|
|
14140
|
-
const reviewLog = (0,
|
|
14674
|
+
const reviewLog = (0, import_extra47.reactiveLog)([], {
|
|
14141
14675
|
name: "review_queue",
|
|
14142
14676
|
maxSize: opts.maxQueueSize
|
|
14143
14677
|
});
|
|
@@ -14146,10 +14680,10 @@ function contentModerationGraph(name, opts) {
|
|
|
14146
14680
|
try {
|
|
14147
14681
|
reviewBranch = g.resolve("stratify::branch/review");
|
|
14148
14682
|
} catch {
|
|
14149
|
-
reviewBranch = (0,
|
|
14683
|
+
reviewBranch = (0, import_core66.node)([], { initial: null });
|
|
14150
14684
|
g.add(reviewBranch, { name: "__review_fallback" });
|
|
14151
14685
|
}
|
|
14152
|
-
const reviewAccumulator = (0,
|
|
14686
|
+
const reviewAccumulator = (0, import_core66.node)(
|
|
14153
14687
|
[reviewBranch],
|
|
14154
14688
|
(batchData, _actions, ctx) => {
|
|
14155
14689
|
const data = batchData.map(
|
|
@@ -14163,11 +14697,11 @@ function contentModerationGraph(name, opts) {
|
|
|
14163
14697
|
{ describeKind: "effect" }
|
|
14164
14698
|
);
|
|
14165
14699
|
g.add(reviewAccumulator, { name: "__review_accumulator" });
|
|
14166
|
-
g.addDisposer((0,
|
|
14700
|
+
g.addDisposer((0, import_extra48.keepalive)(reviewAccumulator));
|
|
14167
14701
|
try {
|
|
14168
14702
|
} catch {
|
|
14169
14703
|
}
|
|
14170
|
-
const policy3 = (0,
|
|
14704
|
+
const policy3 = (0, import_core66.node)([], {
|
|
14171
14705
|
initial: {},
|
|
14172
14706
|
meta: baseMeta2("content_moderation", {
|
|
14173
14707
|
stage: "policy",
|
|
@@ -14177,7 +14711,7 @@ function contentModerationGraph(name, opts) {
|
|
|
14177
14711
|
});
|
|
14178
14712
|
g.add(policy3, { name: "policy" });
|
|
14179
14713
|
const weights = opts.weights ?? [0.1, 1, 2];
|
|
14180
|
-
const confidenceSignal = (0,
|
|
14714
|
+
const confidenceSignal = (0, import_core66.node)(
|
|
14181
14715
|
[classifyNode],
|
|
14182
14716
|
(batchData, actions, ctx) => {
|
|
14183
14717
|
const data = batchData.map(
|
|
@@ -14188,7 +14722,7 @@ function contentModerationGraph(name, opts) {
|
|
|
14188
14722
|
},
|
|
14189
14723
|
{ describeKind: "derived" }
|
|
14190
14724
|
);
|
|
14191
|
-
const severitySignal = (0,
|
|
14725
|
+
const severitySignal = (0, import_core66.node)(
|
|
14192
14726
|
[classifyNode],
|
|
14193
14727
|
(batchData, actions, ctx) => {
|
|
14194
14728
|
const data = batchData.map(
|
|
@@ -14207,13 +14741,13 @@ function contentModerationGraph(name, opts) {
|
|
|
14207
14741
|
);
|
|
14208
14742
|
g.add(confidenceSignal, { name: "__confidence_signal" });
|
|
14209
14743
|
g.add(severitySignal, { name: "__severity_signal" });
|
|
14210
|
-
const wConfidence = (0,
|
|
14211
|
-
const wSeverity = (0,
|
|
14744
|
+
const wConfidence = (0, import_core66.node)([], { initial: 1 });
|
|
14745
|
+
const wSeverity = (0, import_core66.node)([], { initial: 1 });
|
|
14212
14746
|
g.add(wConfidence, { name: "__w_confidence" });
|
|
14213
14747
|
g.add(wSeverity, { name: "__w_severity" });
|
|
14214
14748
|
const priority = scorer([confidenceSignal, severitySignal], [wConfidence, wSeverity]);
|
|
14215
14749
|
g.add(priority, { name: "priority" });
|
|
14216
|
-
const output = (0,
|
|
14750
|
+
const output = (0, import_core66.node)(
|
|
14217
14751
|
[classifyNode, priority],
|
|
14218
14752
|
(batchData, actions, ctx) => {
|
|
14219
14753
|
const vals = batchData.map(
|
|
@@ -14227,7 +14761,7 @@ function contentModerationGraph(name, opts) {
|
|
|
14227
14761
|
{ describeKind: "derived", meta: baseMeta2("content_moderation", { stage: "output" }) }
|
|
14228
14762
|
);
|
|
14229
14763
|
g.add(output, { name: "output" });
|
|
14230
|
-
const fbCondition = (0,
|
|
14764
|
+
const fbCondition = (0, import_core66.node)(
|
|
14231
14765
|
[reviewLog.entries, policy3],
|
|
14232
14766
|
(batchData, actions, ctx) => {
|
|
14233
14767
|
const vals = batchData.map(
|
|
@@ -14262,7 +14796,7 @@ function dataQualityGraph(name, opts) {
|
|
|
14262
14796
|
errors: [],
|
|
14263
14797
|
record
|
|
14264
14798
|
}));
|
|
14265
|
-
const validateNode = (0,
|
|
14799
|
+
const validateNode = (0, import_core66.node)(
|
|
14266
14800
|
[opts.source],
|
|
14267
14801
|
(batchData, actions, ctx) => {
|
|
14268
14802
|
const data = batchData.map(
|
|
@@ -14278,7 +14812,7 @@ function dataQualityGraph(name, opts) {
|
|
|
14278
14812
|
score: 0,
|
|
14279
14813
|
record
|
|
14280
14814
|
}));
|
|
14281
|
-
const anomalyNode = (0,
|
|
14815
|
+
const anomalyNode = (0, import_core66.node)(
|
|
14282
14816
|
[opts.source],
|
|
14283
14817
|
(batchData, actions, ctx) => {
|
|
14284
14818
|
const data = batchData.map(
|
|
@@ -14289,7 +14823,7 @@ function dataQualityGraph(name, opts) {
|
|
|
14289
14823
|
{ describeKind: "derived", meta: baseMeta2("data_quality", { stage: "anomaly" }) }
|
|
14290
14824
|
);
|
|
14291
14825
|
g.add(anomalyNode, { name: "anomaly" });
|
|
14292
|
-
const baseline = (0,
|
|
14826
|
+
const baseline = (0, import_core66.node)([], {
|
|
14293
14827
|
initial: null,
|
|
14294
14828
|
meta: baseMeta2("data_quality", {
|
|
14295
14829
|
stage: "baseline",
|
|
@@ -14297,7 +14831,7 @@ function dataQualityGraph(name, opts) {
|
|
|
14297
14831
|
})
|
|
14298
14832
|
});
|
|
14299
14833
|
g.add(baseline, { name: "baseline" });
|
|
14300
|
-
const baselineUpdater = (0,
|
|
14834
|
+
const baselineUpdater = (0, import_core66.node)(
|
|
14301
14835
|
[validateNode],
|
|
14302
14836
|
(batchData, _actions, ctx) => {
|
|
14303
14837
|
const data = batchData.map(
|
|
@@ -14305,7 +14839,7 @@ function dataQualityGraph(name, opts) {
|
|
|
14305
14839
|
);
|
|
14306
14840
|
const result = data[0];
|
|
14307
14841
|
if (result?.valid) {
|
|
14308
|
-
(0,
|
|
14842
|
+
(0, import_core66.batch)(() => {
|
|
14309
14843
|
baseline.emit(result.record);
|
|
14310
14844
|
});
|
|
14311
14845
|
}
|
|
@@ -14313,9 +14847,9 @@ function dataQualityGraph(name, opts) {
|
|
|
14313
14847
|
{ describeKind: "effect" }
|
|
14314
14848
|
);
|
|
14315
14849
|
g.add(baselineUpdater, { name: "__baseline_updater" });
|
|
14316
|
-
(0,
|
|
14850
|
+
(0, import_extra48.keepalive)(baselineUpdater);
|
|
14317
14851
|
const detectDriftFn = opts.detectDrift ?? (() => ({ drift: false }));
|
|
14318
|
-
const driftNode = (0,
|
|
14852
|
+
const driftNode = (0, import_core66.node)(
|
|
14319
14853
|
[opts.source, baseline],
|
|
14320
14854
|
(batchData, actions, ctx) => {
|
|
14321
14855
|
const data = batchData.map(
|
|
@@ -14327,7 +14861,7 @@ function dataQualityGraph(name, opts) {
|
|
|
14327
14861
|
);
|
|
14328
14862
|
g.add(driftNode, { name: "drift" });
|
|
14329
14863
|
const suggestFn = opts.suggest ?? (() => null);
|
|
14330
|
-
const remediateNode = (0,
|
|
14864
|
+
const remediateNode = (0, import_core66.node)(
|
|
14331
14865
|
[validateNode, anomalyNode],
|
|
14332
14866
|
(batchData, actions, ctx) => {
|
|
14333
14867
|
const data = batchData.map(
|
|
@@ -14343,7 +14877,7 @@ function dataQualityGraph(name, opts) {
|
|
|
14343
14877
|
{ describeKind: "derived", meta: baseMeta2("data_quality", { stage: "remediate" }) }
|
|
14344
14878
|
);
|
|
14345
14879
|
g.add(remediateNode, { name: "remediate" });
|
|
14346
|
-
const output = (0,
|
|
14880
|
+
const output = (0, import_core66.node)(
|
|
14347
14881
|
[validateNode, anomalyNode, driftNode, remediateNode],
|
|
14348
14882
|
(batchData, actions, ctx) => {
|
|
14349
14883
|
const vals = batchData.map(
|
|
@@ -14359,12 +14893,12 @@ function dataQualityGraph(name, opts) {
|
|
|
14359
14893
|
{ describeKind: "derived", meta: baseMeta2("data_quality", { stage: "output" }) }
|
|
14360
14894
|
);
|
|
14361
14895
|
g.add(output, { name: "output" });
|
|
14362
|
-
const validationRules = (0,
|
|
14896
|
+
const validationRules = (0, import_core66.node)([], {
|
|
14363
14897
|
initial: [],
|
|
14364
14898
|
meta: baseMeta2("data_quality", { stage: "validation_rules" })
|
|
14365
14899
|
});
|
|
14366
14900
|
g.add(validationRules, { name: "validation_rules" });
|
|
14367
|
-
const fbCondition = (0,
|
|
14901
|
+
const fbCondition = (0, import_core66.node)(
|
|
14368
14902
|
[anomalyNode],
|
|
14369
14903
|
(batchData, actions, ctx) => {
|
|
14370
14904
|
const data = batchData.map(
|
|
@@ -14391,8 +14925,8 @@ function isTagged(value, tag) {
|
|
|
14391
14925
|
}
|
|
14392
14926
|
|
|
14393
14927
|
// src/utils/harness/actuator-executor.ts
|
|
14394
|
-
var
|
|
14395
|
-
var
|
|
14928
|
+
var import_core67 = require("@graphrefly/pure-ts/core");
|
|
14929
|
+
var import_extra49 = require("@graphrefly/pure-ts/extra");
|
|
14396
14930
|
function defaultToOutput(record, item) {
|
|
14397
14931
|
return {
|
|
14398
14932
|
outcome: "success",
|
|
@@ -14426,7 +14960,7 @@ function actuatorExecutor(config) {
|
|
|
14426
14960
|
execution: { item, outcome: "failure", detail: skipDetail(item) }
|
|
14427
14961
|
};
|
|
14428
14962
|
}
|
|
14429
|
-
return (0,
|
|
14963
|
+
return (0, import_core67.node)(
|
|
14430
14964
|
[],
|
|
14431
14965
|
(_data, actions) => {
|
|
14432
14966
|
const ac = new AbortController();
|
|
@@ -14447,8 +14981,8 @@ function actuatorExecutor(config) {
|
|
|
14447
14981
|
if (captured) return;
|
|
14448
14982
|
captured = true;
|
|
14449
14983
|
actions.down([
|
|
14450
|
-
[
|
|
14451
|
-
[
|
|
14984
|
+
[import_core67.DATA, { ...job.payload, execution: { item, ...out } }],
|
|
14985
|
+
[import_core67.COMPLETE]
|
|
14452
14986
|
]);
|
|
14453
14987
|
unsub?.();
|
|
14454
14988
|
unsub = null;
|
|
@@ -14456,7 +14990,7 @@ function actuatorExecutor(config) {
|
|
|
14456
14990
|
let inner;
|
|
14457
14991
|
try {
|
|
14458
14992
|
const rawResult = config.apply(item, { signal: ac.signal });
|
|
14459
|
-
inner = (0,
|
|
14993
|
+
inner = (0, import_extra49.fromAny)(rawResult, { signal: ac.signal });
|
|
14460
14994
|
} catch (err) {
|
|
14461
14995
|
emitOnce(onError(err, item));
|
|
14462
14996
|
return () => {
|
|
@@ -14467,15 +15001,15 @@ function actuatorExecutor(config) {
|
|
|
14467
15001
|
unsub = inner.subscribe((batch14) => {
|
|
14468
15002
|
for (const m of batch14) {
|
|
14469
15003
|
if (captured) return;
|
|
14470
|
-
if (m[0] ===
|
|
15004
|
+
if (m[0] === import_core67.DATA) {
|
|
14471
15005
|
emitOnce(toOutput(m[1], item));
|
|
14472
15006
|
return;
|
|
14473
15007
|
}
|
|
14474
|
-
if (m[0] ===
|
|
15008
|
+
if (m[0] === import_core67.ERROR) {
|
|
14475
15009
|
emitOnce(onError(m[1], item));
|
|
14476
15010
|
return;
|
|
14477
15011
|
}
|
|
14478
|
-
if (m[0] ===
|
|
15012
|
+
if (m[0] === import_core67.COMPLETE) {
|
|
14479
15013
|
emitOnce(onError(new Error("actuator inner completed without emitting DATA"), item));
|
|
14480
15014
|
return;
|
|
14481
15015
|
}
|
|
@@ -14515,12 +15049,12 @@ function dispatchActuator(config) {
|
|
|
14515
15049
|
}
|
|
14516
15050
|
|
|
14517
15051
|
// src/utils/harness/auto-solidify.ts
|
|
14518
|
-
var
|
|
15052
|
+
var import_core68 = require("@graphrefly/pure-ts/core");
|
|
14519
15053
|
function autoSolidify(config) {
|
|
14520
15054
|
const name = config.name ?? "auto-solidify";
|
|
14521
15055
|
const extract = config.extract ?? ((vr) => vr.execution.artifact ?? null);
|
|
14522
15056
|
const predicate = config.predicate ?? (() => true);
|
|
14523
|
-
return (0,
|
|
15057
|
+
return (0, import_core68.node)(
|
|
14524
15058
|
[],
|
|
14525
15059
|
(_data, actions) => {
|
|
14526
15060
|
let unsub = null;
|
|
@@ -14533,16 +15067,16 @@ function autoSolidify(config) {
|
|
|
14533
15067
|
};
|
|
14534
15068
|
const emitTerminalError = (err) => {
|
|
14535
15069
|
if (terminated) return;
|
|
14536
|
-
actions.down([[
|
|
15070
|
+
actions.down([[import_core68.ERROR, err]]);
|
|
14537
15071
|
tearDown();
|
|
14538
15072
|
};
|
|
14539
15073
|
unsub = config.verifyResults.subscribe((batch14) => {
|
|
14540
15074
|
if (terminated) return;
|
|
14541
15075
|
for (const m of batch14) {
|
|
14542
15076
|
if (terminated) return;
|
|
14543
|
-
if (m[0] !==
|
|
14544
|
-
if (m[0] ===
|
|
14545
|
-
actions.down([[
|
|
15077
|
+
if (m[0] !== import_core68.DATA) {
|
|
15078
|
+
if (m[0] === import_core68.COMPLETE) {
|
|
15079
|
+
actions.down([[import_core68.COMPLETE]]);
|
|
14546
15080
|
tearDown();
|
|
14547
15081
|
return;
|
|
14548
15082
|
}
|
|
@@ -14573,7 +15107,7 @@ function autoSolidify(config) {
|
|
|
14573
15107
|
emitTerminalError(err);
|
|
14574
15108
|
return;
|
|
14575
15109
|
}
|
|
14576
|
-
actions.down([[
|
|
15110
|
+
actions.down([[import_core68.DATA, artifact]]);
|
|
14577
15111
|
}
|
|
14578
15112
|
});
|
|
14579
15113
|
if (terminated && unsub) {
|
|
@@ -14589,11 +15123,11 @@ function autoSolidify(config) {
|
|
|
14589
15123
|
}
|
|
14590
15124
|
|
|
14591
15125
|
// src/utils/harness/bridge.ts
|
|
14592
|
-
var
|
|
14593
|
-
var
|
|
15126
|
+
var import_core69 = require("@graphrefly/pure-ts/core");
|
|
15127
|
+
var import_extra50 = require("@graphrefly/pure-ts/extra");
|
|
14594
15128
|
function createIntakeBridge(opts) {
|
|
14595
15129
|
const { graph, source, intakeTopic, parser, name = "intake-bridge" } = opts;
|
|
14596
|
-
const eff = (0,
|
|
15130
|
+
const eff = (0, import_core69.node)(
|
|
14597
15131
|
[source],
|
|
14598
15132
|
(batchData, _actions, ctx) => {
|
|
14599
15133
|
const data = batchData.map(
|
|
@@ -14619,7 +15153,7 @@ function evalIntakeBridge(opts) {
|
|
|
14619
15153
|
name = "eval-intake-bridge",
|
|
14620
15154
|
defaultSeverity = "medium"
|
|
14621
15155
|
} = opts;
|
|
14622
|
-
const eff = (0,
|
|
15156
|
+
const eff = (0, import_core69.node)(
|
|
14623
15157
|
[source],
|
|
14624
15158
|
(batchData, _actions, ctx) => {
|
|
14625
15159
|
const data = batchData.map(
|
|
@@ -14664,11 +15198,11 @@ function evalIntakeBridge(opts) {
|
|
|
14664
15198
|
return eff;
|
|
14665
15199
|
}
|
|
14666
15200
|
function evalSource(trigger, runner) {
|
|
14667
|
-
return (0,
|
|
15201
|
+
return (0, import_extra50.switchMap)(trigger, () => (0, import_extra50.fromAny)(runner()));
|
|
14668
15202
|
}
|
|
14669
15203
|
function beforeAfterCompare(opts) {
|
|
14670
15204
|
const { graph, before, after, name = "eval-delta" } = opts;
|
|
14671
|
-
const der = (0,
|
|
15205
|
+
const der = (0, import_core69.node)(
|
|
14672
15206
|
[before, after],
|
|
14673
15207
|
(batchData, actions, ctx) => {
|
|
14674
15208
|
const data = batchData.map(
|
|
@@ -14711,7 +15245,7 @@ function affectedTaskFilter(opts) {
|
|
|
14711
15245
|
let taskSetNode = null;
|
|
14712
15246
|
if (fullTaskSet != null) {
|
|
14713
15247
|
if (Array.isArray(fullTaskSet)) {
|
|
14714
|
-
const inlineSet = (0,
|
|
15248
|
+
const inlineSet = (0, import_core69.node)([], { initial: fullTaskSet });
|
|
14715
15249
|
graph.add(inlineSet, { name: `${name}/fullTaskSet` });
|
|
14716
15250
|
taskSetNode = inlineSet;
|
|
14717
15251
|
} else {
|
|
@@ -14720,7 +15254,7 @@ function affectedTaskFilter(opts) {
|
|
|
14720
15254
|
}
|
|
14721
15255
|
const deps = [issues];
|
|
14722
15256
|
if (taskSetNode) deps.push(taskSetNode);
|
|
14723
|
-
const der = (0,
|
|
15257
|
+
const der = (0, import_core69.node)(
|
|
14724
15258
|
deps,
|
|
14725
15259
|
(batchData, actions, ctx) => {
|
|
14726
15260
|
const data = batchData.map(
|
|
@@ -14774,7 +15308,7 @@ function codeChangeBridge(opts) {
|
|
|
14774
15308
|
return items;
|
|
14775
15309
|
}
|
|
14776
15310
|
const resolve = parser ?? defaultParser;
|
|
14777
|
-
const eff = (0,
|
|
15311
|
+
const eff = (0, import_core69.node)(
|
|
14778
15312
|
[source],
|
|
14779
15313
|
(batchData, _actions, ctx) => {
|
|
14780
15314
|
const data = batchData.map(
|
|
@@ -14793,7 +15327,7 @@ function codeChangeBridge(opts) {
|
|
|
14793
15327
|
}
|
|
14794
15328
|
function notifyEffect(opts) {
|
|
14795
15329
|
const { graph, topic: topic2, transport, name = "notify-effect" } = opts;
|
|
14796
|
-
const eff = (0,
|
|
15330
|
+
const eff = (0, import_core69.node)(
|
|
14797
15331
|
[topic2.latest],
|
|
14798
15332
|
(batchData, _actions, ctx) => {
|
|
14799
15333
|
const data = batchData.map(
|
|
@@ -14886,10 +15420,10 @@ function resolvePromptFn(raw, fallbackTemplate, substitute) {
|
|
|
14886
15420
|
}
|
|
14887
15421
|
|
|
14888
15422
|
// src/utils/harness/strategy.ts
|
|
14889
|
-
var
|
|
15423
|
+
var import_core70 = require("@graphrefly/pure-ts/core");
|
|
14890
15424
|
|
|
14891
15425
|
// src/utils/orchestration/audited-success-tracker.ts
|
|
14892
|
-
var
|
|
15426
|
+
var import_extra51 = require("@graphrefly/pure-ts/extra");
|
|
14893
15427
|
var import_graph15 = require("@graphrefly/pure-ts/graph");
|
|
14894
15428
|
var AuditedSuccessTrackerGraph = class extends import_graph15.Graph {
|
|
14895
15429
|
/** Reactive entries — `Node<ReadonlyMap<TKey, TEntry>>`, fresh map per mutation. */
|
|
@@ -14897,10 +15431,10 @@ var AuditedSuccessTrackerGraph = class extends import_graph15.Graph {
|
|
|
14897
15431
|
_map;
|
|
14898
15432
|
constructor(opts) {
|
|
14899
15433
|
super(opts?.name ?? "audited-success-tracker", opts?.graph);
|
|
14900
|
-
this._map = (0,
|
|
15434
|
+
this._map = (0, import_extra51.reactiveMap)({ name: "entries" });
|
|
14901
15435
|
this.entries = this._map.entries;
|
|
14902
15436
|
this.add(this.entries, { name: "entries" });
|
|
14903
|
-
this.addDisposer((0,
|
|
15437
|
+
this.addDisposer((0, import_extra51.keepalive)(this.entries));
|
|
14904
15438
|
this.addDisposer(() => this._map.dispose());
|
|
14905
15439
|
}
|
|
14906
15440
|
/**
|
|
@@ -14963,7 +15497,7 @@ function priorityScore(item, strategy, lastInteractionNs, urgency, signals) {
|
|
|
14963
15497
|
const effectivenessBoost = signals?.effectivenessBoost ?? 15;
|
|
14964
15498
|
const deps = [item, strategy, lastInteractionNs];
|
|
14965
15499
|
if (urgency) deps.push(urgency);
|
|
14966
|
-
return (0,
|
|
15500
|
+
return (0, import_core70.node)(
|
|
14967
15501
|
deps,
|
|
14968
15502
|
(batchData, actions, ctx) => {
|
|
14969
15503
|
const values = batchData.map(
|
|
@@ -14974,7 +15508,7 @@ function priorityScore(item, strategy, lastInteractionNs, urgency, signals) {
|
|
|
14974
15508
|
const lastNs = values[2];
|
|
14975
15509
|
const urg = urgency ? values[3] : 0;
|
|
14976
15510
|
const baseWeight = severityWeights[itm.severity ?? "medium"];
|
|
14977
|
-
const ageSeconds2 = ((0,
|
|
15511
|
+
const ageSeconds2 = ((0, import_core70.monotonicNs)() - lastNs) / 1e9;
|
|
14978
15512
|
let score = decay(baseWeight, ageSeconds2, decayRate, 0);
|
|
14979
15513
|
const key = strategyKey(DEFAULT_PRESET_ID, itm.rootCause, itm.intervention);
|
|
14980
15514
|
const entry = strat.get(key);
|
|
@@ -14989,8 +15523,8 @@ function priorityScore(item, strategy, lastInteractionNs, urgency, signals) {
|
|
|
14989
15523
|
}
|
|
14990
15524
|
|
|
14991
15525
|
// src/utils/inspect/audit.ts
|
|
14992
|
-
var
|
|
14993
|
-
var
|
|
15526
|
+
var import_core71 = require("@graphrefly/pure-ts/core");
|
|
15527
|
+
var import_extra52 = require("@graphrefly/pure-ts/extra");
|
|
14994
15528
|
var import_graph16 = require("@graphrefly/pure-ts/graph");
|
|
14995
15529
|
function auditMeta(kind, extra) {
|
|
14996
15530
|
return domainMeta("audit", kind, extra);
|
|
@@ -15028,7 +15562,7 @@ var AuditTrailGraph = class extends import_graph16.Graph {
|
|
|
15028
15562
|
constructor(target, opts) {
|
|
15029
15563
|
super(opts.name ?? `${target.name}_audit`, opts.graph);
|
|
15030
15564
|
this._target = target;
|
|
15031
|
-
this._log = (0,
|
|
15565
|
+
this._log = (0, import_extra52.reactiveLog)([], {
|
|
15032
15566
|
name: "entries",
|
|
15033
15567
|
...opts.maxSize != null ? { maxSize: opts.maxSize } : {}
|
|
15034
15568
|
});
|
|
@@ -15045,7 +15579,7 @@ var AuditTrailGraph = class extends import_graph16.Graph {
|
|
|
15045
15579
|
},
|
|
15046
15580
|
{ meta: auditMeta("count") }
|
|
15047
15581
|
);
|
|
15048
|
-
this.addDisposer((0,
|
|
15582
|
+
this.addDisposer((0, import_extra52.keepalive)(this.count));
|
|
15049
15583
|
const includeTypes = opts.includeTypes != null ? new Set(opts.includeTypes) : new Set(DEFAULT_INCLUDE_TYPES);
|
|
15050
15584
|
this.includeTypes = includeTypes;
|
|
15051
15585
|
const filter2 = opts.filter;
|
|
@@ -15058,13 +15592,13 @@ var AuditTrailGraph = class extends import_graph16.Graph {
|
|
|
15058
15592
|
const path = event.path ?? "";
|
|
15059
15593
|
const entry = {
|
|
15060
15594
|
seq: seq++,
|
|
15061
|
-
timestamp_ns: event.timestamp_ns ?? (0,
|
|
15062
|
-
wall_clock_ns: (0,
|
|
15595
|
+
timestamp_ns: event.timestamp_ns ?? (0, import_core71.monotonicNs)(),
|
|
15596
|
+
wall_clock_ns: (0, import_core71.wallClockNs)(),
|
|
15063
15597
|
path,
|
|
15064
15598
|
type
|
|
15065
15599
|
};
|
|
15066
|
-
const
|
|
15067
|
-
const lastMutation =
|
|
15600
|
+
const node65 = path ? safeNode(target, path) : void 0;
|
|
15601
|
+
const lastMutation = node65?.lastMutation;
|
|
15068
15602
|
if (lastMutation != null) entry.actor = lastMutation.actor;
|
|
15069
15603
|
if (type === "data") entry.value = event.data;
|
|
15070
15604
|
if (type === "error") entry.error = event.data;
|
|
@@ -15125,7 +15659,7 @@ var PolicyGateGraph = class extends import_graph16.Graph {
|
|
|
15125
15659
|
super(opts.name ?? `${target.name}_policy`, opts.graph);
|
|
15126
15660
|
this._target = target;
|
|
15127
15661
|
this._mode = opts.mode ?? "audit";
|
|
15128
|
-
const policiesNode = isNode2(policies) ? policies : (0,
|
|
15662
|
+
const policiesNode = isNode2(policies) ? policies : (0, import_core71.node)([], { name: "policies", initial: policies });
|
|
15129
15663
|
this.policies = policiesNode;
|
|
15130
15664
|
this.add(this.policies, { name: "policies" });
|
|
15131
15665
|
this.violations = new TopicGraph("violations", {
|
|
@@ -15145,15 +15679,15 @@ var PolicyGateGraph = class extends import_graph16.Graph {
|
|
|
15145
15679
|
meta: auditMeta("policy_violation_count")
|
|
15146
15680
|
}
|
|
15147
15681
|
);
|
|
15148
|
-
this.addDisposer((0,
|
|
15682
|
+
this.addDisposer((0, import_extra52.keepalive)(this.violationCount));
|
|
15149
15683
|
const initialRules = policiesNode.cache ?? [];
|
|
15150
15684
|
let latestRules = initialRules;
|
|
15151
|
-
this._currentGuard = (0,
|
|
15685
|
+
this._currentGuard = (0, import_core71.policyFromRules)(latestRules);
|
|
15152
15686
|
const offPolicies = policiesNode.subscribe((msgs) => {
|
|
15153
15687
|
for (const m of msgs) {
|
|
15154
|
-
if (m[0] ===
|
|
15688
|
+
if (m[0] === import_core71.DATA) {
|
|
15155
15689
|
latestRules = m[1] ?? [];
|
|
15156
|
-
this._currentGuard = (0,
|
|
15690
|
+
this._currentGuard = (0, import_core71.policyFromRules)(latestRules);
|
|
15157
15691
|
}
|
|
15158
15692
|
}
|
|
15159
15693
|
});
|
|
@@ -15167,7 +15701,7 @@ var PolicyGateGraph = class extends import_graph16.Graph {
|
|
|
15167
15701
|
if (this._mode !== "enforce" && pathsNode != null) {
|
|
15168
15702
|
const offAuditPaths = pathsNode.subscribe((msgs) => {
|
|
15169
15703
|
for (const m of msgs) {
|
|
15170
|
-
if (m[0] !==
|
|
15704
|
+
if (m[0] !== import_core71.DATA) continue;
|
|
15171
15705
|
latestPaths = m[1] ?? [];
|
|
15172
15706
|
}
|
|
15173
15707
|
});
|
|
@@ -15177,8 +15711,8 @@ var PolicyGateGraph = class extends import_graph16.Graph {
|
|
|
15177
15711
|
const restorers = /* @__PURE__ */ new Map();
|
|
15178
15712
|
const wrapAndPush = (path) => {
|
|
15179
15713
|
if (restorers.has(path)) return;
|
|
15180
|
-
const
|
|
15181
|
-
if (!(
|
|
15714
|
+
const node65 = safeNode(target, path);
|
|
15715
|
+
if (!(node65 instanceof import_core71.NodeImpl)) return;
|
|
15182
15716
|
const pathGuard = (actor, action) => {
|
|
15183
15717
|
const ok = this._currentGuard(actor, action);
|
|
15184
15718
|
if (!ok) {
|
|
@@ -15186,17 +15720,17 @@ var PolicyGateGraph = class extends import_graph16.Graph {
|
|
|
15186
15720
|
}
|
|
15187
15721
|
return ok;
|
|
15188
15722
|
};
|
|
15189
|
-
restorers.set(path,
|
|
15723
|
+
restorers.set(path, node65._pushGuard(pathGuard));
|
|
15190
15724
|
};
|
|
15191
15725
|
for (const path of paths) wrapAndPush(path);
|
|
15192
15726
|
if (pathsNode != null) {
|
|
15193
15727
|
const offReactivePaths = pathsNode.subscribe((msgs) => {
|
|
15194
15728
|
for (const m of msgs) {
|
|
15195
|
-
if (m[0] !==
|
|
15729
|
+
if (m[0] !== import_core71.DATA) continue;
|
|
15196
15730
|
const next = m[1] ?? [];
|
|
15197
15731
|
const nextSet = new Set(next);
|
|
15198
15732
|
const prevSet = new Set(latestPaths ?? []);
|
|
15199
|
-
(0,
|
|
15733
|
+
(0, import_core71.batch)(() => {
|
|
15200
15734
|
for (const p of prevSet) {
|
|
15201
15735
|
if (nextSet.has(p)) continue;
|
|
15202
15736
|
const r = restorers.get(p);
|
|
@@ -15255,7 +15789,7 @@ var PolicyGateGraph = class extends import_graph16.Graph {
|
|
|
15255
15789
|
} else {
|
|
15256
15790
|
const offCleanup = target.topology.subscribe((msgs) => {
|
|
15257
15791
|
for (const m of msgs) {
|
|
15258
|
-
if (m[0] !==
|
|
15792
|
+
if (m[0] !== import_core71.DATA) continue;
|
|
15259
15793
|
const event = m[1];
|
|
15260
15794
|
if (event.kind !== "removed" || event.nodeKind !== "node") continue;
|
|
15261
15795
|
const r = restorers.get(event.name);
|
|
@@ -15292,8 +15826,8 @@ var PolicyGateGraph = class extends import_graph16.Graph {
|
|
|
15292
15826
|
}
|
|
15293
15827
|
_publishViolation(actor, action, path, result) {
|
|
15294
15828
|
this.violations.publish({
|
|
15295
|
-
timestamp_ns: (0,
|
|
15296
|
-
wall_clock_ns: (0,
|
|
15829
|
+
timestamp_ns: (0, import_core71.monotonicNs)(),
|
|
15830
|
+
wall_clock_ns: (0, import_core71.wallClockNs)(),
|
|
15297
15831
|
path,
|
|
15298
15832
|
actor,
|
|
15299
15833
|
action,
|
|
@@ -15314,14 +15848,14 @@ var PolicyGateGraph = class extends import_graph16.Graph {
|
|
|
15314
15848
|
};
|
|
15315
15849
|
function policyGate(target, policies, opts = {}) {
|
|
15316
15850
|
const g = new PolicyGateGraph(target, policies, opts);
|
|
15317
|
-
g.tagFactory("policyGate", (0,
|
|
15851
|
+
g.tagFactory("policyGate", (0, import_core71.placeholderArgs)(opts));
|
|
15318
15852
|
return g;
|
|
15319
15853
|
}
|
|
15320
15854
|
function complianceSnapshot(target, opts = {}) {
|
|
15321
15855
|
const result = {
|
|
15322
15856
|
format_version: 1,
|
|
15323
|
-
timestamp_ns: (0,
|
|
15324
|
-
wall_clock_ns: (0,
|
|
15857
|
+
timestamp_ns: (0, import_core71.monotonicNs)(),
|
|
15858
|
+
wall_clock_ns: (0, import_core71.wallClockNs)(),
|
|
15325
15859
|
graph: target.snapshot()
|
|
15326
15860
|
};
|
|
15327
15861
|
if (opts.actor != null) result.actor = opts.actor;
|
|
@@ -15362,7 +15896,7 @@ function collectPaths(target) {
|
|
|
15362
15896
|
return Object.keys(described.nodes);
|
|
15363
15897
|
}
|
|
15364
15898
|
function computeFingerprint(value) {
|
|
15365
|
-
return (0,
|
|
15899
|
+
return (0, import_core71.defaultHash)(JSON.stringify(canonicalize(value)));
|
|
15366
15900
|
}
|
|
15367
15901
|
function canonicalize(value) {
|
|
15368
15902
|
const stack = /* @__PURE__ */ new Set();
|
|
@@ -15415,8 +15949,8 @@ function canonicalize(value) {
|
|
|
15415
15949
|
}
|
|
15416
15950
|
|
|
15417
15951
|
// src/utils/inspect/lens.ts
|
|
15418
|
-
var
|
|
15419
|
-
var
|
|
15952
|
+
var import_core72 = require("@graphrefly/pure-ts/core");
|
|
15953
|
+
var import_extra53 = require("@graphrefly/pure-ts/extra");
|
|
15420
15954
|
var import_graph17 = require("@graphrefly/pure-ts/graph");
|
|
15421
15955
|
var import_graph18 = require("@graphrefly/pure-ts/graph");
|
|
15422
15956
|
function computeHealthReport(described) {
|
|
@@ -15456,7 +15990,7 @@ function graphLens(target) {
|
|
|
15456
15990
|
reactiveName: "graphLens.topology"
|
|
15457
15991
|
});
|
|
15458
15992
|
const topology = topologyHandle.node;
|
|
15459
|
-
const health = (0,
|
|
15993
|
+
const health = (0, import_core72.node)(
|
|
15460
15994
|
[topology],
|
|
15461
15995
|
(batchData, actions, ctx) => {
|
|
15462
15996
|
const data = batchData.map(
|
|
@@ -15471,11 +16005,11 @@ function graphLens(target) {
|
|
|
15471
16005
|
meta: domainMeta("lens", "health")
|
|
15472
16006
|
}
|
|
15473
16007
|
);
|
|
15474
|
-
const stopHealthKeep = (0,
|
|
16008
|
+
const stopHealthKeep = (0, import_extra53.keepalive)(health);
|
|
15475
16009
|
const flowMap = /* @__PURE__ */ new Map();
|
|
15476
16010
|
let lastAppliedFlush_ns = -1;
|
|
15477
16011
|
const dataFlow = target.observe({ reactive: true, tiers: ["data"] });
|
|
15478
|
-
const flow = (0,
|
|
16012
|
+
const flow = (0, import_core72.node)(
|
|
15479
16013
|
[dataFlow, topology],
|
|
15480
16014
|
(batchData, actions, ctx) => {
|
|
15481
16015
|
const data = batchData.map(
|
|
@@ -15513,7 +16047,7 @@ function graphLens(target) {
|
|
|
15513
16047
|
meta: domainMeta("lens", "flow")
|
|
15514
16048
|
}
|
|
15515
16049
|
);
|
|
15516
|
-
const stopFlowKeep = (0,
|
|
16050
|
+
const stopFlowKeep = (0, import_extra53.keepalive)(flow);
|
|
15517
16051
|
let disposed = false;
|
|
15518
16052
|
return {
|
|
15519
16053
|
topology,
|
|
@@ -15530,8 +16064,8 @@ function graphLens(target) {
|
|
|
15530
16064
|
}
|
|
15531
16065
|
|
|
15532
16066
|
// src/utils/job-queue/index.ts
|
|
15533
|
-
var
|
|
15534
|
-
var
|
|
16067
|
+
var import_core73 = require("@graphrefly/pure-ts/core");
|
|
16068
|
+
var import_extra54 = require("@graphrefly/pure-ts/extra");
|
|
15535
16069
|
var import_graph19 = require("@graphrefly/pure-ts/graph");
|
|
15536
16070
|
var DEFAULT_MAX_PER_PUMP2 = 256;
|
|
15537
16071
|
var DEFAULT_COMPLETED_RETAINED_LIMIT = 1024;
|
|
@@ -15567,13 +16101,13 @@ var JobQueueGraph = class extends import_graph19.Graph {
|
|
|
15567
16101
|
_removeByIdImpl;
|
|
15568
16102
|
constructor(name, opts = {}) {
|
|
15569
16103
|
super(name, opts.graph);
|
|
15570
|
-
this._pending = (0,
|
|
15571
|
-
this._jobs = (0,
|
|
16104
|
+
this._pending = (0, import_extra54.reactiveList)([], { name: "pending" });
|
|
16105
|
+
this._jobs = (0, import_extra54.reactiveMap)({ name: "jobs" });
|
|
15572
16106
|
this.pending = this._pending.items;
|
|
15573
16107
|
this.jobs = this._jobs.entries;
|
|
15574
16108
|
this.add(this.pending, { name: "pending" });
|
|
15575
16109
|
this.add(this.jobs, { name: "jobs" });
|
|
15576
|
-
this.depth = (0,
|
|
16110
|
+
this.depth = (0, import_core73.node)(
|
|
15577
16111
|
[this.pending],
|
|
15578
16112
|
(batchData, actions, ctx) => {
|
|
15579
16113
|
const data = batchData.map(
|
|
@@ -15589,7 +16123,7 @@ var JobQueueGraph = class extends import_graph19.Graph {
|
|
|
15589
16123
|
}
|
|
15590
16124
|
);
|
|
15591
16125
|
this.add(this.depth, { name: "depth" });
|
|
15592
|
-
this.addDisposer((0,
|
|
16126
|
+
this.addDisposer((0, import_extra54.keepalive)(this.depth));
|
|
15593
16127
|
this.events = createAuditLog({
|
|
15594
16128
|
name: "events",
|
|
15595
16129
|
retainedLimit: 1024,
|
|
@@ -15726,7 +16260,7 @@ var JobQueueGraph = class extends import_graph19.Graph {
|
|
|
15726
16260
|
action: "claim",
|
|
15727
16261
|
id,
|
|
15728
16262
|
attempts: inflight.attempts,
|
|
15729
|
-
t_ns: (0,
|
|
16263
|
+
t_ns: (0, import_core73.wallClockNs)(),
|
|
15730
16264
|
seq: bumpCursor(this._seqCursor)
|
|
15731
16265
|
});
|
|
15732
16266
|
}
|
|
@@ -15777,7 +16311,7 @@ var JobQueueGraph = class extends import_graph19.Graph {
|
|
|
15777
16311
|
consumeFrom(source, opts) {
|
|
15778
16312
|
return source.subscribe((msgs) => {
|
|
15779
16313
|
for (const m of msgs) {
|
|
15780
|
-
if (m[0] !==
|
|
16314
|
+
if (m[0] !== import_core73.DATA) continue;
|
|
15781
16315
|
const payload = m[1];
|
|
15782
16316
|
this.enqueue(payload, opts ? { metadata: opts.metadata } : void 0);
|
|
15783
16317
|
}
|
|
@@ -15837,13 +16371,13 @@ var JobFlowGraph = class extends import_graph19.Graph {
|
|
|
15837
16371
|
this._queues.set(stage, q);
|
|
15838
16372
|
this.mount(stage, q);
|
|
15839
16373
|
}
|
|
15840
|
-
this._completed = (0,
|
|
16374
|
+
this._completed = (0, import_extra54.reactiveLog)([], {
|
|
15841
16375
|
name: "completed",
|
|
15842
16376
|
maxSize: DEFAULT_COMPLETED_RETAINED_LIMIT
|
|
15843
16377
|
});
|
|
15844
16378
|
this.completed = this._completed.entries;
|
|
15845
16379
|
this.add(this.completed, { name: "completed" });
|
|
15846
|
-
this.completedCount = (0,
|
|
16380
|
+
this.completedCount = (0, import_core73.node)(
|
|
15847
16381
|
[this.completed],
|
|
15848
16382
|
(batchData, actions, ctx) => {
|
|
15849
16383
|
const data = batchData.map(
|
|
@@ -15859,7 +16393,7 @@ var JobFlowGraph = class extends import_graph19.Graph {
|
|
|
15859
16393
|
}
|
|
15860
16394
|
);
|
|
15861
16395
|
this.add(this.completedCount, { name: "completedCount" });
|
|
15862
|
-
this.addDisposer((0,
|
|
16396
|
+
this.addDisposer((0, import_extra54.keepalive)(this.completedCount));
|
|
15863
16397
|
const defaultMaxPerPump = Math.max(
|
|
15864
16398
|
1,
|
|
15865
16399
|
requireNonNegativeInt2(opts.maxPerPump ?? DEFAULT_MAX_PER_PUMP2, "job flow maxPerPump")
|
|
@@ -15871,14 +16405,14 @@ var JobFlowGraph = class extends import_graph19.Graph {
|
|
|
15871
16405
|
const workFn = this._stageWorkFns.get(stage);
|
|
15872
16406
|
const stagePerPump = stageMaxPerPump.get(stage) ?? defaultMaxPerPump;
|
|
15873
16407
|
const stageMaxInflightCap = stageMaxInflight.get(stage);
|
|
15874
|
-
const inflightCounter = stageMaxInflightCap !== void 0 ? (0,
|
|
16408
|
+
const inflightCounter = stageMaxInflightCap !== void 0 ? (0, import_core73.node)([], { name: `__inflight__/${stage}`, initial: 0 }) : null;
|
|
15875
16409
|
if (inflightCounter) {
|
|
15876
16410
|
this.add(inflightCounter, { name: `__inflight__/${stage}` });
|
|
15877
16411
|
}
|
|
15878
16412
|
const isTerminal = next === null;
|
|
15879
16413
|
if (workFn) {
|
|
15880
16414
|
const pumpDeps = inflightCounter != null ? [current.pending, inflightCounter] : [current.pending];
|
|
15881
|
-
const pump = (0,
|
|
16415
|
+
const pump = (0, import_core73.node)(
|
|
15882
16416
|
pumpDeps,
|
|
15883
16417
|
(_data, _actions, ctx) => {
|
|
15884
16418
|
if (!("inflight" in ctx.store)) {
|
|
@@ -15914,7 +16448,7 @@ var JobFlowGraph = class extends import_graph19.Graph {
|
|
|
15914
16448
|
processed += 1;
|
|
15915
16449
|
continue;
|
|
15916
16450
|
}
|
|
15917
|
-
const resultNode = (0,
|
|
16451
|
+
const resultNode = (0, import_extra54.fromAny)(result);
|
|
15918
16452
|
let settled = false;
|
|
15919
16453
|
let unsub;
|
|
15920
16454
|
const cleanupSub = () => {
|
|
@@ -15931,7 +16465,7 @@ var JobFlowGraph = class extends import_graph19.Graph {
|
|
|
15931
16465
|
unsub = resultNode.subscribe((msgs) => {
|
|
15932
16466
|
if (settled) return;
|
|
15933
16467
|
for (const m of msgs) {
|
|
15934
|
-
if (m[0] ===
|
|
16468
|
+
if (m[0] === import_core73.DATA) {
|
|
15935
16469
|
settled = true;
|
|
15936
16470
|
cleanupSub();
|
|
15937
16471
|
const newPayload = m[1];
|
|
@@ -15945,12 +16479,12 @@ var JobFlowGraph = class extends import_graph19.Graph {
|
|
|
15945
16479
|
payload: newPayload,
|
|
15946
16480
|
metadata: Object.freeze(newMetadata)
|
|
15947
16481
|
};
|
|
15948
|
-
(0,
|
|
16482
|
+
(0, import_core73.batch)(() => {
|
|
15949
16483
|
current.ack(job.id);
|
|
15950
16484
|
this._completed.append(completedJob);
|
|
15951
16485
|
});
|
|
15952
16486
|
} else {
|
|
15953
|
-
(0,
|
|
16487
|
+
(0, import_core73.batch)(() => {
|
|
15954
16488
|
current.ack(job.id);
|
|
15955
16489
|
next.enqueue(newPayload, {
|
|
15956
16490
|
metadata: newMetadata
|
|
@@ -15958,7 +16492,7 @@ var JobFlowGraph = class extends import_graph19.Graph {
|
|
|
15958
16492
|
});
|
|
15959
16493
|
}
|
|
15960
16494
|
return;
|
|
15961
|
-
} else if (m[0] ===
|
|
16495
|
+
} else if (m[0] === import_core73.ERROR) {
|
|
15962
16496
|
settled = true;
|
|
15963
16497
|
cleanupSub();
|
|
15964
16498
|
current.nack(job.id, { requeue: false });
|
|
@@ -15991,7 +16525,7 @@ var JobFlowGraph = class extends import_graph19.Graph {
|
|
|
15991
16525
|
meta: jobQueueMeta("job_flow_pump", { stage, has_work: true })
|
|
15992
16526
|
}
|
|
15993
16527
|
);
|
|
15994
|
-
this.addDisposer((0,
|
|
16528
|
+
this.addDisposer((0, import_extra54.keepalive)(pump));
|
|
15995
16529
|
} else {
|
|
15996
16530
|
const pump = this.effect(
|
|
15997
16531
|
`pump_${stage}`,
|
|
@@ -16011,12 +16545,12 @@ var JobFlowGraph = class extends import_graph19.Graph {
|
|
|
16011
16545
|
...job,
|
|
16012
16546
|
metadata: Object.freeze(newMetadata)
|
|
16013
16547
|
};
|
|
16014
|
-
(0,
|
|
16548
|
+
(0, import_core73.batch)(() => {
|
|
16015
16549
|
current.ack(job.id);
|
|
16016
16550
|
this._completed.append(completedJob);
|
|
16017
16551
|
});
|
|
16018
16552
|
} else {
|
|
16019
|
-
(0,
|
|
16553
|
+
(0, import_core73.batch)(() => {
|
|
16020
16554
|
current.ack(job.id);
|
|
16021
16555
|
next.enqueue(job.payload, {
|
|
16022
16556
|
metadata: newMetadata
|
|
@@ -16030,7 +16564,7 @@ var JobFlowGraph = class extends import_graph19.Graph {
|
|
|
16030
16564
|
meta: jobQueueMeta("job_flow_pump", { stage, has_work: false })
|
|
16031
16565
|
}
|
|
16032
16566
|
);
|
|
16033
|
-
this.addDisposer((0,
|
|
16567
|
+
this.addDisposer((0, import_extra54.keepalive)(pump));
|
|
16034
16568
|
}
|
|
16035
16569
|
}
|
|
16036
16570
|
}
|
|
@@ -16055,19 +16589,19 @@ function jobQueue(name, opts) {
|
|
|
16055
16589
|
function jobFlow(name, opts) {
|
|
16056
16590
|
const g = new JobFlowGraph(name, opts);
|
|
16057
16591
|
const { factory: _f, factoryArgs: _fa, ...tagArgs } = opts ?? {};
|
|
16058
|
-
g.tagFactory("jobFlow", (0,
|
|
16592
|
+
g.tagFactory("jobFlow", (0, import_core73.placeholderArgs)(tagArgs));
|
|
16059
16593
|
return g;
|
|
16060
16594
|
}
|
|
16061
16595
|
|
|
16062
16596
|
// src/utils/process/index.ts
|
|
16063
|
-
var
|
|
16064
|
-
var
|
|
16597
|
+
var import_core74 = require("@graphrefly/pure-ts/core");
|
|
16598
|
+
var import_extra55 = require("@graphrefly/pure-ts/extra");
|
|
16065
16599
|
var import_graph20 = require("@graphrefly/pure-ts/graph");
|
|
16066
16600
|
var processInstanceKeyOf = (i) => i.correlationId;
|
|
16067
16601
|
var processStateKeyOf = (s) => s.correlationId;
|
|
16068
16602
|
function toPromise(input) {
|
|
16069
16603
|
if (input == null) return Promise.resolve(void 0);
|
|
16070
|
-
const n = (0,
|
|
16604
|
+
const n = (0, import_extra55.fromAny)(input);
|
|
16071
16605
|
return new Promise((resolve, reject) => {
|
|
16072
16606
|
let settled = false;
|
|
16073
16607
|
let unsub;
|
|
@@ -16079,19 +16613,19 @@ function toPromise(input) {
|
|
|
16079
16613
|
unsub = n.subscribe((msgs) => {
|
|
16080
16614
|
if (settled) return;
|
|
16081
16615
|
for (const m of msgs) {
|
|
16082
|
-
if (m[0] ===
|
|
16616
|
+
if (m[0] === import_core74.DATA) {
|
|
16083
16617
|
settled = true;
|
|
16084
16618
|
Promise.resolve().then(cleanup);
|
|
16085
16619
|
resolve(m[1]);
|
|
16086
16620
|
return;
|
|
16087
16621
|
}
|
|
16088
|
-
if (m[0] ===
|
|
16622
|
+
if (m[0] === import_core74.ERROR) {
|
|
16089
16623
|
settled = true;
|
|
16090
16624
|
Promise.resolve().then(cleanup);
|
|
16091
16625
|
reject(m[1]);
|
|
16092
16626
|
return;
|
|
16093
16627
|
}
|
|
16094
|
-
if (m[0] ===
|
|
16628
|
+
if (m[0] === import_core74.COMPLETE) {
|
|
16095
16629
|
settled = true;
|
|
16096
16630
|
Promise.resolve().then(cleanup);
|
|
16097
16631
|
resolve(void 0);
|
|
@@ -16172,8 +16706,8 @@ function processManager(cqrsGraph, name, opts) {
|
|
|
16172
16706
|
correlationId,
|
|
16173
16707
|
state: stateValue,
|
|
16174
16708
|
status,
|
|
16175
|
-
startedAt: startedAt.get(correlationId) ?? (0,
|
|
16176
|
-
updatedAt: (0,
|
|
16709
|
+
startedAt: startedAt.get(correlationId) ?? (0, import_core74.wallClockNs)(),
|
|
16710
|
+
updatedAt: (0, import_core74.wallClockNs)(),
|
|
16177
16711
|
...opts.handlerVersion !== void 0 ? { handlerVersion: opts.handlerVersion } : {}
|
|
16178
16712
|
};
|
|
16179
16713
|
};
|
|
@@ -16271,10 +16805,10 @@ function processManager(cqrsGraph, name, opts) {
|
|
|
16271
16805
|
if (result.schedule) {
|
|
16272
16806
|
const { afterMs, eventType } = result.schedule;
|
|
16273
16807
|
let timerUnsub;
|
|
16274
|
-
const timerNode = (0,
|
|
16808
|
+
const timerNode = (0, import_extra55.fromTimer)(afterMs);
|
|
16275
16809
|
const timerCb = (msgs) => {
|
|
16276
16810
|
for (const m of msgs) {
|
|
16277
|
-
if (m[0] ===
|
|
16811
|
+
if (m[0] === import_core74.DATA) {
|
|
16278
16812
|
if (timerUnsub) {
|
|
16279
16813
|
timerUnsub();
|
|
16280
16814
|
} else {
|
|
@@ -16291,7 +16825,7 @@ function processManager(cqrsGraph, name, opts) {
|
|
|
16291
16825
|
// seq: Number.NaN — sentinel for synthetic events that do not
|
|
16292
16826
|
// participate in cross-event ordering.
|
|
16293
16827
|
payload: null,
|
|
16294
|
-
timestampNs: (0,
|
|
16828
|
+
timestampNs: (0, import_core74.wallClockNs)(),
|
|
16295
16829
|
seq: Number.NaN,
|
|
16296
16830
|
correlationId,
|
|
16297
16831
|
aggregateId: correlationId
|
|
@@ -16352,13 +16886,13 @@ function processManager(cqrsGraph, name, opts) {
|
|
|
16352
16886
|
});
|
|
16353
16887
|
}
|
|
16354
16888
|
let _disposed = false;
|
|
16355
|
-
const restoreState = (0,
|
|
16889
|
+
const restoreState = (0, import_core74.node)([], {
|
|
16356
16890
|
initial: "pending",
|
|
16357
16891
|
name: "restoreState",
|
|
16358
16892
|
describeKind: "state"
|
|
16359
16893
|
});
|
|
16360
16894
|
subgraph.add(restoreState, { name: "restoreState" });
|
|
16361
|
-
const gateOpen = (0,
|
|
16895
|
+
const gateOpen = (0, import_core74.node)(
|
|
16362
16896
|
[restoreState],
|
|
16363
16897
|
(data, a, ctx) => {
|
|
16364
16898
|
const batch0 = data[0];
|
|
@@ -16371,11 +16905,11 @@ function processManager(cqrsGraph, name, opts) {
|
|
|
16371
16905
|
const watchDisposers = [];
|
|
16372
16906
|
for (const eventType of opts.watching) {
|
|
16373
16907
|
const eventNode = cqrsGraph.event(eventType);
|
|
16374
|
-
const gated = (0,
|
|
16908
|
+
const gated = (0, import_extra55.valve)(eventNode, gateOpen, { name: `gatedEvent:${eventType}` });
|
|
16375
16909
|
let lastCount = 0;
|
|
16376
16910
|
const unsub = gated.subscribe((msgs) => {
|
|
16377
16911
|
for (const m of msgs) {
|
|
16378
|
-
if (m[0] !==
|
|
16912
|
+
if (m[0] !== import_core74.DATA) continue;
|
|
16379
16913
|
const events = m[1];
|
|
16380
16914
|
if (events.length <= lastCount) continue;
|
|
16381
16915
|
const newEvents = events.slice(lastCount);
|
|
@@ -16400,7 +16934,7 @@ function processManager(cqrsGraph, name, opts) {
|
|
|
16400
16934
|
correlationId,
|
|
16401
16935
|
aggregateId: correlationId
|
|
16402
16936
|
});
|
|
16403
|
-
startedAt.set(correlationId, (0,
|
|
16937
|
+
startedAt.set(correlationId, (0, import_core74.wallClockNs)());
|
|
16404
16938
|
instanceStates.set(correlationId, opts.initial);
|
|
16405
16939
|
activeInstances.add(correlationId);
|
|
16406
16940
|
persistStateThrowing(correlationId, "running");
|
|
@@ -16452,21 +16986,21 @@ function processManager(cqrsGraph, name, opts) {
|
|
|
16452
16986
|
}
|
|
16453
16987
|
const tierLoad = tier2.load.bind(tier2);
|
|
16454
16988
|
const tierList = tier2.list.bind(tier2);
|
|
16455
|
-
const listSource = (0,
|
|
16456
|
-
const flattened = (0,
|
|
16989
|
+
const listSource = (0, import_extra55.fromAny)(tierList());
|
|
16990
|
+
const flattened = (0, import_extra55.mergeMap)(listSource, (keys) => {
|
|
16457
16991
|
if (keys.length === 0) {
|
|
16458
|
-
return (0,
|
|
16992
|
+
return (0, import_extra55.fromIter)([]);
|
|
16459
16993
|
}
|
|
16460
|
-
return (0,
|
|
16461
|
-
(0,
|
|
16462
|
-
(key) => (0,
|
|
16994
|
+
return (0, import_extra55.mergeMap)(
|
|
16995
|
+
(0, import_extra55.fromIter)(keys),
|
|
16996
|
+
(key) => (0, import_extra55.fromAny)(tierLoad(key)),
|
|
16463
16997
|
// Bound concurrent in-flight loads (D2, 2026-05-01) so a
|
|
16464
16998
|
// large persisted-instance count doesn't exhaust file
|
|
16465
16999
|
// handles / connection pools on the storage backend.
|
|
16466
17000
|
{ concurrent: opts.restoreConcurrency ?? 8 }
|
|
16467
17001
|
);
|
|
16468
17002
|
});
|
|
16469
|
-
const restoreEffect = (0,
|
|
17003
|
+
const restoreEffect = (0, import_core74.node)(
|
|
16470
17004
|
[flattened],
|
|
16471
17005
|
(data, _a, ctx) => {
|
|
16472
17006
|
if (_disposed) return;
|
|
@@ -16474,7 +17008,7 @@ function processManager(cqrsGraph, name, opts) {
|
|
|
16474
17008
|
const hasSnapshots = batch0 != null && batch0.length > 0;
|
|
16475
17009
|
const allDone = ctx.terminalDeps[0] === true;
|
|
16476
17010
|
if (!hasSnapshots && !allDone) return;
|
|
16477
|
-
(0,
|
|
17011
|
+
(0, import_core74.batch)(() => {
|
|
16478
17012
|
if (hasSnapshots) {
|
|
16479
17013
|
for (const snap of batch0) {
|
|
16480
17014
|
if (snap == null) continue;
|
|
@@ -16702,7 +17236,7 @@ var ImageSizeAdapter = class {
|
|
|
16702
17236
|
};
|
|
16703
17237
|
|
|
16704
17238
|
// src/utils/reactive-layout/reactive-block-layout.ts
|
|
16705
|
-
var
|
|
17239
|
+
var import_core75 = require("@graphrefly/pure-ts/core");
|
|
16706
17240
|
var import_graph21 = require("@graphrefly/pure-ts/graph");
|
|
16707
17241
|
function measureBlock(block, maxWidth, adapters, measureCache, defaultFont, defaultLineHeight, index) {
|
|
16708
17242
|
switch (block.type) {
|
|
@@ -16798,18 +17332,18 @@ function reactiveBlockLayout(opts) {
|
|
|
16798
17332
|
} = opts;
|
|
16799
17333
|
const g = new import_graph21.Graph(name);
|
|
16800
17334
|
const measureCache = /* @__PURE__ */ new Map();
|
|
16801
|
-
const blocksNode = (0,
|
|
16802
|
-
const maxWidthNode = (0,
|
|
17335
|
+
const blocksNode = (0, import_core75.node)([], { name: "blocks", initial: opts.blocks ?? [] });
|
|
17336
|
+
const maxWidthNode = (0, import_core75.node)([], {
|
|
16803
17337
|
name: "max-width",
|
|
16804
17338
|
initial: Math.max(0, opts.maxWidth ?? 800)
|
|
16805
17339
|
});
|
|
16806
|
-
const gapNode = (0,
|
|
16807
|
-
const measuredBlocksNode = (0,
|
|
17340
|
+
const gapNode = (0, import_core75.node)([], { name: "gap", initial: opts.gap ?? 0 });
|
|
17341
|
+
const measuredBlocksNode = (0, import_core75.node)(
|
|
16808
17342
|
[blocksNode, maxWidthNode],
|
|
16809
17343
|
(data, actions, ctx) => {
|
|
16810
17344
|
const blocksVal = data[0] != null && data[0].length > 0 ? data[0].at(-1) : ctx.prevData[0];
|
|
16811
17345
|
const mwVal = data[1] != null && data[1].length > 0 ? data[1].at(-1) : ctx.prevData[1];
|
|
16812
|
-
const t0 = (0,
|
|
17346
|
+
const t0 = (0, import_core75.monotonicNs)();
|
|
16813
17347
|
const result = measureBlocks(
|
|
16814
17348
|
blocksVal,
|
|
16815
17349
|
mwVal,
|
|
@@ -16818,7 +17352,7 @@ function reactiveBlockLayout(opts) {
|
|
|
16818
17352
|
defaultFont,
|
|
16819
17353
|
defaultLineHeight
|
|
16820
17354
|
);
|
|
16821
|
-
const elapsed = (0,
|
|
17355
|
+
const elapsed = (0, import_core75.monotonicNs)() - t0;
|
|
16822
17356
|
const meta2 = measuredBlocksNode.meta;
|
|
16823
17357
|
if (meta2) {
|
|
16824
17358
|
emitToMeta(meta2["block-count"], result.length);
|
|
@@ -16850,7 +17384,7 @@ function reactiveBlockLayout(opts) {
|
|
|
16850
17384
|
}
|
|
16851
17385
|
}
|
|
16852
17386
|
);
|
|
16853
|
-
const blockFlowNode = (0,
|
|
17387
|
+
const blockFlowNode = (0, import_core75.node)(
|
|
16854
17388
|
[measuredBlocksNode, gapNode],
|
|
16855
17389
|
(batchData, actions, ctx) => {
|
|
16856
17390
|
const data = batchData.map(
|
|
@@ -16876,7 +17410,7 @@ function reactiveBlockLayout(opts) {
|
|
|
16876
17410
|
}
|
|
16877
17411
|
}
|
|
16878
17412
|
);
|
|
16879
|
-
const totalHeightNode = (0,
|
|
17413
|
+
const totalHeightNode = (0, import_core75.node)(
|
|
16880
17414
|
[blockFlowNode],
|
|
16881
17415
|
(batchData, actions, ctx) => {
|
|
16882
17416
|
const data = batchData.map(
|
|
@@ -16904,7 +17438,7 @@ function reactiveBlockLayout(opts) {
|
|
|
16904
17438
|
}
|
|
16905
17439
|
|
|
16906
17440
|
// src/utils/reactive-layout/reactive-flow-layout.ts
|
|
16907
|
-
var
|
|
17441
|
+
var import_core76 = require("@graphrefly/pure-ts/core");
|
|
16908
17442
|
var import_graph22 = require("@graphrefly/pure-ts/graph");
|
|
16909
17443
|
function circleIntervalForBand(o, bandTop, bandBottom) {
|
|
16910
17444
|
const hPad = o.hPad ?? 0;
|
|
@@ -16996,23 +17530,23 @@ function reactiveFlowLayout(opts) {
|
|
|
16996
17530
|
const { adapter, name = "reactive-flow-layout", minSlotWidth = 20 } = opts;
|
|
16997
17531
|
const g = new import_graph22.Graph(name);
|
|
16998
17532
|
const measureCache = /* @__PURE__ */ new Map();
|
|
16999
|
-
const textNode = (0,
|
|
17000
|
-
const fontNode = (0,
|
|
17001
|
-
const lineHeightNode = (0,
|
|
17002
|
-
const containerNode = (0,
|
|
17533
|
+
const textNode = (0, import_core76.node)([], { name: "text", initial: opts.text ?? "" });
|
|
17534
|
+
const fontNode = (0, import_core76.node)([], { name: "font", initial: opts.font ?? "16px sans-serif" });
|
|
17535
|
+
const lineHeightNode = (0, import_core76.node)([], { name: "line-height", initial: opts.lineHeight ?? 20 });
|
|
17536
|
+
const containerNode = (0, import_core76.node)([], {
|
|
17003
17537
|
name: "container",
|
|
17004
17538
|
initial: opts.container ?? { width: 800, height: 600, paddingX: 0, paddingY: 0 }
|
|
17005
17539
|
});
|
|
17006
|
-
const columnsNode = (0,
|
|
17540
|
+
const columnsNode = (0, import_core76.node)([], {
|
|
17007
17541
|
name: "columns",
|
|
17008
17542
|
initial: opts.columns ?? { count: 1, gap: 0 }
|
|
17009
17543
|
});
|
|
17010
|
-
const obstaclesNode = (0,
|
|
17011
|
-
const paragraphSpacingNode = (0,
|
|
17544
|
+
const obstaclesNode = (0, import_core76.node)([], { name: "obstacles", initial: opts.obstacles ?? [] });
|
|
17545
|
+
const paragraphSpacingNode = (0, import_core76.node)([], {
|
|
17012
17546
|
name: "paragraph-spacing",
|
|
17013
17547
|
initial: opts.paragraphSpacing ?? null
|
|
17014
17548
|
});
|
|
17015
|
-
const segmentsNode = (0,
|
|
17549
|
+
const segmentsNode = (0, import_core76.node)(
|
|
17016
17550
|
[textNode, fontNode],
|
|
17017
17551
|
(data, actions, ctx) => {
|
|
17018
17552
|
const b0 = data[0];
|
|
@@ -17029,14 +17563,14 @@ function reactiveFlowLayout(opts) {
|
|
|
17029
17563
|
},
|
|
17030
17564
|
{ name: "segments", describeKind: "derived" }
|
|
17031
17565
|
);
|
|
17032
|
-
const flowLinesNode = (0,
|
|
17566
|
+
const flowLinesNode = (0, import_core76.node)(
|
|
17033
17567
|
[segmentsNode, containerNode, columnsNode, obstaclesNode, lineHeightNode, paragraphSpacingNode],
|
|
17034
17568
|
(batchData, actions, ctx) => {
|
|
17035
17569
|
const data = batchData.map(
|
|
17036
17570
|
(batch14, i) => batch14 != null && batch14.length > 0 ? batch14.at(-1) : ctx.prevData[i]
|
|
17037
17571
|
);
|
|
17038
17572
|
const segments = data[0];
|
|
17039
|
-
const t0 = (0,
|
|
17573
|
+
const t0 = (0, import_core76.monotonicNs)();
|
|
17040
17574
|
const effectiveSpacing = data[5] ?? data[4];
|
|
17041
17575
|
const { lines: result, cursor } = computeFlowLines(
|
|
17042
17576
|
segments,
|
|
@@ -17047,7 +17581,7 @@ function reactiveFlowLayout(opts) {
|
|
|
17047
17581
|
minSlotWidth,
|
|
17048
17582
|
{ paragraphSpacing: effectiveSpacing }
|
|
17049
17583
|
);
|
|
17050
|
-
const elapsed = (0,
|
|
17584
|
+
const elapsed = (0, import_core76.monotonicNs)() - t0;
|
|
17051
17585
|
const overflow = Math.max(0, segments.length - cursor.segmentIndex);
|
|
17052
17586
|
const meta2 = flowLinesNode.meta;
|
|
17053
17587
|
if (meta2) {
|
|
@@ -17171,7 +17705,7 @@ ${catalogValidation.errors.join("\n")}`,
|
|
|
17171
17705
|
}
|
|
17172
17706
|
|
|
17173
17707
|
// src/utils/surface/reduce.ts
|
|
17174
|
-
var
|
|
17708
|
+
var import_core77 = require("@graphrefly/pure-ts/core");
|
|
17175
17709
|
var DEFAULT_TIMEOUT_MS2 = 3e4;
|
|
17176
17710
|
async function runReduction(spec, input, opts) {
|
|
17177
17711
|
const inputPath = opts?.inputPath ?? "input";
|
|
@@ -17222,16 +17756,16 @@ async function runReduction(spec, input, opts) {
|
|
|
17222
17756
|
for (const m of msgs) {
|
|
17223
17757
|
if (settled) return;
|
|
17224
17758
|
if (!primed) continue;
|
|
17225
|
-
if (m[0] ===
|
|
17759
|
+
if (m[0] === import_core77.DATA) {
|
|
17226
17760
|
finish(() => resolve(m[1]));
|
|
17227
17761
|
return;
|
|
17228
17762
|
}
|
|
17229
|
-
if (m[0] ===
|
|
17763
|
+
if (m[0] === import_core77.RESOLVED) {
|
|
17230
17764
|
const cached = outputNode.cache;
|
|
17231
17765
|
finish(() => resolve(cached));
|
|
17232
17766
|
return;
|
|
17233
17767
|
}
|
|
17234
|
-
if (m[0] ===
|
|
17768
|
+
if (m[0] === import_core77.ERROR) {
|
|
17235
17769
|
const payload = m[1];
|
|
17236
17770
|
const message = payload instanceof Error ? payload.message : String(payload);
|
|
17237
17771
|
const cause = payload instanceof Error ? payload : void 0;
|
|
@@ -17246,7 +17780,7 @@ async function runReduction(spec, input, opts) {
|
|
|
17246
17780
|
);
|
|
17247
17781
|
return;
|
|
17248
17782
|
}
|
|
17249
|
-
if (m[0] ===
|
|
17783
|
+
if (m[0] === import_core77.COMPLETE) {
|
|
17250
17784
|
finish(
|
|
17251
17785
|
() => reject(
|
|
17252
17786
|
new SurfaceError(
|
|
@@ -17301,7 +17835,7 @@ async function runReduction(spec, input, opts) {
|
|
|
17301
17835
|
}
|
|
17302
17836
|
|
|
17303
17837
|
// src/utils/surface/snapshot.ts
|
|
17304
|
-
var
|
|
17838
|
+
var import_core78 = require("@graphrefly/pure-ts/core");
|
|
17305
17839
|
var import_graph23 = require("@graphrefly/pure-ts/graph");
|
|
17306
17840
|
var SNAPSHOT_WIRE_VERSION = import_graph23.SNAPSHOT_VERSION;
|
|
17307
17841
|
var SNAPSHOT_KEY_PREFIX = "snapshot:";
|
|
@@ -17370,7 +17904,7 @@ async function saveSnapshot(graph, snapshotId, tier2) {
|
|
|
17370
17904
|
name: graph.name,
|
|
17371
17905
|
mode: "full",
|
|
17372
17906
|
seq: 0,
|
|
17373
|
-
timestamp_ns: (0,
|
|
17907
|
+
timestamp_ns: (0, import_core78.wallClockNs)(),
|
|
17374
17908
|
format_version: SNAPSHOT_WIRE_VERSION,
|
|
17375
17909
|
snapshot
|
|
17376
17910
|
};
|