@graphrefly/graphrefly 0.46.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.
Files changed (99) hide show
  1. package/dist/base/composition/index.cjs +69 -15
  2. package/dist/base/composition/index.cjs.map +1 -1
  3. package/dist/base/composition/index.d.cts +1 -2
  4. package/dist/base/composition/index.d.ts +1 -2
  5. package/dist/base/composition/index.js +1 -1
  6. package/dist/base/index.cjs +69 -15
  7. package/dist/base/index.cjs.map +1 -1
  8. package/dist/base/index.d.cts +1 -2
  9. package/dist/base/index.d.ts +1 -2
  10. package/dist/base/index.js +1 -1
  11. package/dist/{chunk-CGHORL6G.js → chunk-7ADWWI2T.js} +2 -2
  12. package/dist/{chunk-RGL53X5G.js → chunk-B4AKFXGE.js} +4 -4
  13. package/dist/{chunk-FW23JYNQ.js → chunk-CEVNQ74M.js} +2 -2
  14. package/dist/{chunk-JGFRAFDL.js → chunk-FVINAAKA.js} +3 -3
  15. package/dist/{chunk-WKSWLSCX.js → chunk-J5WFUEO4.js} +2 -2
  16. package/dist/{chunk-HULCUY35.js → chunk-K7PDZYQE.js} +4 -4
  17. package/dist/{chunk-Z6EGP5D7.js → chunk-LDCSZ72P.js} +2 -2
  18. package/dist/{chunk-KIIXR252.js → chunk-MTTRCEJT.js} +2 -2
  19. package/dist/{chunk-Q3EYOCZB.js → chunk-NPRP3MCV.js} +111 -2
  20. package/dist/chunk-NPRP3MCV.js.map +1 -0
  21. package/dist/{chunk-5THCXDWY.js → chunk-RGMTUZCL.js} +3 -3
  22. package/dist/{chunk-FR6RGA3B.js → chunk-U225SKB4.js} +472 -37
  23. package/dist/chunk-U225SKB4.js.map +1 -0
  24. package/dist/{chunk-GBCENOLN.js → chunk-V4Y3TM7U.js} +5 -5
  25. package/dist/{chunk-LBAJK24K.js → chunk-VLAGJZSL.js} +11 -3
  26. package/dist/chunk-VLAGJZSL.js.map +1 -0
  27. package/dist/{chunk-OO5BM6CJ.js → chunk-YXCPV26R.js} +2 -2
  28. package/dist/chunk-Z65DVDEQ.js +146 -0
  29. package/dist/chunk-Z65DVDEQ.js.map +1 -0
  30. package/dist/compat/index.cjs +156 -93
  31. package/dist/compat/index.cjs.map +1 -1
  32. package/dist/compat/index.d.cts +3 -3
  33. package/dist/compat/index.d.ts +3 -3
  34. package/dist/compat/index.js +2 -2
  35. package/dist/compat/nestjs/index.cjs +156 -93
  36. package/dist/compat/nestjs/index.cjs.map +1 -1
  37. package/dist/compat/nestjs/index.d.cts +4 -4
  38. package/dist/compat/nestjs/index.d.ts +4 -4
  39. package/dist/compat/nestjs/index.js +4 -5
  40. package/dist/{index-5SU_O78r.d.cts → index-B_p8tnvf.d.cts} +19 -3
  41. package/dist/{index-CEXCtYYJ.d.ts → index-_HDSmPyp.d.ts} +19 -3
  42. package/dist/index.cjs +1449 -856
  43. package/dist/index.cjs.map +1 -1
  44. package/dist/index.d.cts +3 -4
  45. package/dist/index.d.ts +3 -4
  46. package/dist/index.js +36 -14
  47. package/dist/index.js.map +1 -1
  48. package/dist/observable-B25XqCbZ.d.cts +59 -0
  49. package/dist/observable-B25XqCbZ.d.ts +59 -0
  50. package/dist/presets/ai/index.cjs.map +1 -1
  51. package/dist/presets/ai/index.js +6 -6
  52. package/dist/presets/harness/index.cjs.map +1 -1
  53. package/dist/presets/harness/index.js +9 -9
  54. package/dist/presets/index.cjs.map +1 -1
  55. package/dist/presets/index.js +13 -13
  56. package/dist/presets/inspect/index.cjs.map +1 -1
  57. package/dist/presets/inspect/index.js +4 -4
  58. package/dist/solutions/index.cjs.map +1 -1
  59. package/dist/solutions/index.js +10 -10
  60. package/dist/utils/ai/index.cjs.map +1 -1
  61. package/dist/utils/ai/index.js +5 -5
  62. package/dist/utils/index.cjs +939 -400
  63. package/dist/utils/index.cjs.map +1 -1
  64. package/dist/utils/index.d.cts +2 -2
  65. package/dist/utils/index.d.ts +2 -2
  66. package/dist/utils/index.js +28 -6
  67. package/dist/utils/inspect/index.cjs.map +1 -1
  68. package/dist/utils/inspect/index.js +2 -2
  69. package/dist/utils/memory/index.cjs +470 -40
  70. package/dist/utils/memory/index.cjs.map +1 -1
  71. package/dist/utils/memory/index.d.cts +669 -2
  72. package/dist/utils/memory/index.d.ts +669 -2
  73. package/dist/utils/memory/index.js +19 -1
  74. package/dist/utils/messaging/index.cjs +109 -0
  75. package/dist/utils/messaging/index.cjs.map +1 -1
  76. package/dist/utils/messaging/index.d.cts +115 -2
  77. package/dist/utils/messaging/index.d.ts +115 -2
  78. package/dist/utils/messaging/index.js +5 -1
  79. package/dist/utils/orchestration/index.cjs.map +1 -1
  80. package/dist/utils/orchestration/index.js +2 -2
  81. package/package.json +1 -5
  82. package/dist/chunk-3QZY5BI7.js +0 -92
  83. package/dist/chunk-3QZY5BI7.js.map +0 -1
  84. package/dist/chunk-FR6RGA3B.js.map +0 -1
  85. package/dist/chunk-LBAJK24K.js.map +0 -1
  86. package/dist/chunk-Q3EYOCZB.js.map +0 -1
  87. package/dist/observable-BXQoW1P-.d.cts +0 -36
  88. package/dist/observable-BXQoW1P-.d.ts +0 -36
  89. /package/dist/{chunk-CGHORL6G.js.map → chunk-7ADWWI2T.js.map} +0 -0
  90. /package/dist/{chunk-RGL53X5G.js.map → chunk-B4AKFXGE.js.map} +0 -0
  91. /package/dist/{chunk-FW23JYNQ.js.map → chunk-CEVNQ74M.js.map} +0 -0
  92. /package/dist/{chunk-JGFRAFDL.js.map → chunk-FVINAAKA.js.map} +0 -0
  93. /package/dist/{chunk-WKSWLSCX.js.map → chunk-J5WFUEO4.js.map} +0 -0
  94. /package/dist/{chunk-HULCUY35.js.map → chunk-K7PDZYQE.js.map} +0 -0
  95. /package/dist/{chunk-Z6EGP5D7.js.map → chunk-LDCSZ72P.js.map} +0 -0
  96. /package/dist/{chunk-KIIXR252.js.map → chunk-MTTRCEJT.js.map} +0 -0
  97. /package/dist/{chunk-5THCXDWY.js.map → chunk-RGMTUZCL.js.map} +0 -0
  98. /package/dist/{chunk-GBCENOLN.js.map → chunk-V4Y3TM7U.js.map} +0 -0
  99. /package/dist/{chunk-OO5BM6CJ.js.map → chunk-YXCPV26R.js.map} +0 -0
@@ -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 node58 = arg;
47
- let latest = node58.cache;
48
- const unsub = node58.subscribe((msgs) => {
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 import_core50 = require("@graphrefly/pure-ts/core");
7613
- var import_extra35 = require("@graphrefly/pure-ts/extra");
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(node58) {
7644
- node58.subscribe(() => void 0);
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 import_core49 = require("@graphrefly/pure-ts/core");
7786
- var import_extra34 = require("@graphrefly/pure-ts/extra");
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
@@ -7835,6 +7953,8 @@ function reactiveFactStore(config) {
7835
7953
  graph
7836
7954
  });
7837
7955
  const seqCursor = registerCursor(graph, "seq", 0);
7956
+ const ingestLog = config.recordIngest ? (0, import_extra33.reactiveLog)([], { name: "ingest_log" }) : void 0;
7957
+ if (ingestLog) graph.addDisposer(() => ingestLog.dispose());
7838
7958
  const emptyStore = () => ({ byId: /* @__PURE__ */ new Map() });
7839
7959
  const shards = [];
7840
7960
  for (let s = 0; s < shardCount; s += 1) {
@@ -7990,6 +8110,8 @@ function reactiveFactStore(config) {
7990
8110
  factId: dep,
7991
8111
  rootFactId: f.id,
7992
8112
  reason: "obsolete",
8113
+ // `obsolete` guard above guarantees `f.validTo` is set.
8114
+ rootValidTo: f.validTo,
7993
8115
  iteration: cascadeIteration + 1,
7994
8116
  causalReason: `dependentsIndex[${f.id}] \u2192 ${dep} (obsolete: validTo set)`
7995
8117
  });
@@ -8062,11 +8184,10 @@ function reactiveFactStore(config) {
8062
8184
  actions.emit([]);
8063
8185
  return;
8064
8186
  }
8065
- const now = (0, import_core48.monotonicNs)();
8066
- for (const [id] of byId) {
8187
+ for (const [id, e] of byId) {
8067
8188
  replaceFragment(
8068
8189
  id,
8069
- (prev) => prev.validTo !== void 0 ? prev : { ...prev, validTo: BigInt(now) }
8190
+ (prev) => prev.validTo !== void 0 ? prev : { ...prev, validTo: e.rootValidTo }
8070
8191
  );
8071
8192
  }
8072
8193
  actions.emit([...byId.values()]);
@@ -8224,6 +8345,7 @@ function reactiveFactStore(config) {
8224
8345
  t_ns: (0, import_core48.wallClockNs)(),
8225
8346
  seq: bumpCursor(seqCursor)
8226
8347
  });
8348
+ ingestLog?.append(f);
8227
8349
  }
8228
8350
  actions.emit(f ?? null);
8229
8351
  },
@@ -8260,19 +8382,436 @@ function reactiveFactStore(config) {
8260
8382
  review,
8261
8383
  consolidated,
8262
8384
  events,
8385
+ ...ingestLog ? { ingestLog } : {},
8263
8386
  itemNode
8264
8387
  });
8265
8388
  return out;
8266
8389
  }
8267
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
+
8268
8807
  // src/utils/memory/index.ts
8269
8808
  var NS_PER_SEC2 = 1e9;
8270
8809
  function memoryMeta(kind, extra) {
8271
8810
  return domainMeta("memory", kind, extra);
8272
8811
  }
8273
8812
  function toNode(v, name) {
8274
- if (v instanceof import_core49.NodeImpl) return v;
8275
- return (0, import_core49.node)([], { initial: v, ...name ? { name } : void 0 });
8813
+ if (v instanceof import_core56.NodeImpl) return v;
8814
+ return (0, import_core56.node)([], { initial: v, ...name ? { name } : void 0 });
8276
8815
  }
8277
8816
  function ageSeconds(now, lastNs) {
8278
8817
  return (now - lastNs) / NS_PER_SEC2;
@@ -8326,14 +8865,14 @@ function collection(name, opts = {}) {
8326
8865
  }
8327
8866
  const scoreFnDefault = () => ranked ? 1 : 0;
8328
8867
  const scoreInput = opts.score ?? scoreFnDefault;
8329
- const scoreNode = ranked && scoreInput instanceof import_core49.NodeImpl ? scoreInput : void 0;
8868
+ const scoreNode = ranked && scoreInput instanceof import_core56.NodeImpl ? scoreInput : void 0;
8330
8869
  const readScoreFn = () => {
8331
8870
  if (scoreNode) return scoreNode.cache ?? scoreFnDefault;
8332
8871
  return scoreInput;
8333
8872
  };
8334
8873
  const graph = new import_graph7.Graph(name);
8335
- const retentionScore = (_k, v) => ranked ? decay(v.baseScore, ageSeconds((0, import_core49.monotonicNs)(), v.lastAccessNs), decayRate, minScore) : v.lastAccessNs;
8336
- const items = (0, import_extra34.reactiveMap)({
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)({
8337
8876
  name: "items",
8338
8877
  ...maxSize !== void 0 ? { retention: { score: retentionScore, maxSize } } : {}
8339
8878
  });
@@ -8341,16 +8880,16 @@ function collection(name, opts = {}) {
8341
8880
  let refreshTick;
8342
8881
  if (ranked && decayRate > 0) {
8343
8882
  const intervalMs = opts.refreshIntervalMs ?? Math.max(1, 1e3 * Math.LN2 / (10 * decayRate));
8344
- const tickCounter = (0, import_extra34.fromTimer)(intervalMs, { period: intervalMs });
8345
- refreshTick = (0, import_core49.node)(
8883
+ const tickCounter = (0, import_extra39.fromTimer)(intervalMs, { period: intervalMs });
8884
+ refreshTick = (0, import_core56.node)(
8346
8885
  [tickCounter],
8347
8886
  (_batchData, actions) => {
8348
- actions.emit((0, import_core49.monotonicNs)());
8887
+ actions.emit((0, import_core56.monotonicNs)());
8349
8888
  },
8350
8889
  {
8351
8890
  name: "refresh_tick_ns",
8352
8891
  describeKind: "derived",
8353
- initial: (0, import_core49.monotonicNs)(),
8892
+ initial: (0, import_core56.monotonicNs)(),
8354
8893
  meta: memoryMeta("clock")
8355
8894
  }
8356
8895
  );
@@ -8361,7 +8900,7 @@ function collection(name, opts = {}) {
8361
8900
  const rankedDeps = [items.entries];
8362
8901
  if (refreshTick) rankedDeps.push(refreshTick);
8363
8902
  if (scoreNode) rankedDeps.push(scoreNode);
8364
- rankedNode = (0, import_core49.node)(
8903
+ rankedNode = (0, import_core56.node)(
8365
8904
  rankedDeps,
8366
8905
  (batchData, actions, ctx) => {
8367
8906
  const values = batchData.map(
@@ -8371,9 +8910,9 @@ function collection(name, opts = {}) {
8371
8910
  let now;
8372
8911
  if (refreshTick) {
8373
8912
  const tickValue = values[1];
8374
- now = typeof tickValue === "number" ? tickValue : (0, import_core49.monotonicNs)();
8913
+ now = typeof tickValue === "number" ? tickValue : (0, import_core56.monotonicNs)();
8375
8914
  } else {
8376
- now = (0, import_core49.monotonicNs)();
8915
+ now = (0, import_core56.monotonicNs)();
8377
8916
  }
8378
8917
  if (!snapshot || snapshot.size === 0) {
8379
8918
  actions.emit([]);
@@ -8398,7 +8937,7 @@ function collection(name, opts = {}) {
8398
8937
  );
8399
8938
  graph.add(rankedNode, { name: "ranked" });
8400
8939
  } else {
8401
- rankedNode = (0, import_core49.node)([], {
8940
+ rankedNode = (0, import_core56.node)([], {
8402
8941
  initial: [],
8403
8942
  name: "ranked",
8404
8943
  describeKind: "state",
@@ -8406,7 +8945,7 @@ function collection(name, opts = {}) {
8406
8945
  });
8407
8946
  graph.add(rankedNode, { name: "ranked" });
8408
8947
  }
8409
- const size = (0, import_core49.node)(
8948
+ const size = (0, import_core56.node)(
8410
8949
  [items.entries],
8411
8950
  (batchData, actions, ctx) => {
8412
8951
  const data = batchData.map(
@@ -8423,7 +8962,7 @@ function collection(name, opts = {}) {
8423
8962
  }
8424
8963
  );
8425
8964
  graph.add(size, { name: "size" });
8426
- graph.addDisposer((0, import_extra34.keepalive)(size));
8965
+ graph.addDisposer((0, import_extra39.keepalive)(size));
8427
8966
  const events = createAuditLog({
8428
8967
  name: "events",
8429
8968
  retainedLimit: 1024,
@@ -8431,7 +8970,7 @@ function collection(name, opts = {}) {
8431
8970
  });
8432
8971
  const seqCursor = registerCursor(graph, "seq", 0);
8433
8972
  const upsertImpl = (id, value, _opts) => {
8434
- const now = (0, import_core49.monotonicNs)();
8973
+ const now = (0, import_core56.monotonicNs)();
8435
8974
  const prev = items.get(id);
8436
8975
  const baseScore = _opts?.score ?? readScoreFn()(value);
8437
8976
  items.set(id, {
@@ -8487,7 +9026,7 @@ function collection(name, opts = {}) {
8487
9026
  });
8488
9027
  function itemNode(id) {
8489
9028
  const idN = toNode(id, "id");
8490
- return (0, import_core49.node)(
9029
+ return (0, import_core56.node)(
8491
9030
  [items.entries, idN],
8492
9031
  (batchData, actions, ctx) => {
8493
9032
  const data = batchData.map(
@@ -8505,7 +9044,7 @@ function collection(name, opts = {}) {
8505
9044
  }
8506
9045
  function hasNode(id) {
8507
9046
  const idN = toNode(id, "id");
8508
- return (0, import_core49.node)(
9047
+ return (0, import_core56.node)(
8509
9048
  [items.entries, idN],
8510
9049
  (batchData, actions, ctx) => {
8511
9050
  const data = batchData.map(
@@ -8580,7 +9119,7 @@ function vectorIndex(opts = {}) {
8580
9119
  graph
8581
9120
  });
8582
9121
  const seqCursor = registerCursor(graph, "seq", 0);
8583
- const entries = (0, import_extra34.reactiveMap)({
9122
+ const entries = (0, import_extra39.reactiveMap)({
8584
9123
  name: "entries",
8585
9124
  ...maxSize !== void 0 ? {
8586
9125
  retention: {
@@ -8592,7 +9131,7 @@ function vectorIndex(opts = {}) {
8592
9131
  events.append({
8593
9132
  action: "evict",
8594
9133
  id: key,
8595
- t_ns: (0, import_core49.wallClockNs)(),
9134
+ t_ns: (0, import_core56.wallClockNs)(),
8596
9135
  seq: bumpCursor(seqCursor)
8597
9136
  });
8598
9137
  }
@@ -8600,7 +9139,7 @@ function vectorIndex(opts = {}) {
8600
9139
  } : {}
8601
9140
  });
8602
9141
  graph.add(entries.entries, { name: "entries" });
8603
- graph.addDisposer((0, import_extra34.keepalive)(entries.entries));
9142
+ graph.addDisposer((0, import_extra39.keepalive)(entries.entries));
8604
9143
  if (hnsw?.dispose) {
8605
9144
  const disposeAdapter = hnsw.dispose.bind(hnsw);
8606
9145
  graph.addDisposer(() => disposeAdapter());
@@ -8617,7 +9156,7 @@ function vectorIndex(opts = {}) {
8617
9156
  id,
8618
9157
  vector: [...vector],
8619
9158
  ...copiedMeta !== void 0 ? { meta: copiedMeta } : {},
8620
- upsertedAtNs: (0, import_core49.monotonicNs)()
9159
+ upsertedAtNs: (0, import_core56.monotonicNs)()
8621
9160
  };
8622
9161
  entries.set(id, record);
8623
9162
  };
@@ -8673,7 +9212,7 @@ function vectorIndex(opts = {}) {
8673
9212
  });
8674
9213
  function searchNode(query, k = 5) {
8675
9214
  const kN = toNode(k, "k");
8676
- return (0, import_core49.node)(
9215
+ return (0, import_core56.node)(
8677
9216
  [entries.entries, query, kN],
8678
9217
  (batchData, actions, ctx) => {
8679
9218
  const values = batchData.map(
@@ -8779,17 +9318,17 @@ function knowledgeGraph(name, opts = {}) {
8779
9318
  throw new RangeError("knowledgeGraph: edgesMaxSize must be >= 1");
8780
9319
  }
8781
9320
  const graph = new import_graph7.Graph(name);
8782
- const entitiesMap = (0, import_extra34.reactiveMap)({
9321
+ const entitiesMap = (0, import_extra39.reactiveMap)({
8783
9322
  name: "entities",
8784
9323
  ...opts.entitiesMaxSize !== void 0 ? { maxSize: opts.entitiesMaxSize } : {}
8785
9324
  });
8786
- const edgesMap = (0, import_extra34.reactiveMap)({
9325
+ const edgesMap = (0, import_extra39.reactiveMap)({
8787
9326
  name: "edges",
8788
9327
  ...opts.edgesMaxSize !== void 0 ? { maxSize: opts.edgesMaxSize } : {}
8789
9328
  });
8790
9329
  graph.add(entitiesMap.entries, { name: "entities" });
8791
9330
  graph.add(edgesMap.entries, { name: "edges" });
8792
- const adjacencyOut = (0, import_core49.node)(
9331
+ const adjacencyOut = (0, import_core56.node)(
8793
9332
  [edgesMap.entries],
8794
9333
  (batchData, actions, ctx) => {
8795
9334
  const data = batchData.map(
@@ -8806,7 +9345,7 @@ function knowledgeGraph(name, opts = {}) {
8806
9345
  meta: memoryMeta("adjacency_out")
8807
9346
  }
8808
9347
  );
8809
- const adjacencyIn = (0, import_core49.node)(
9348
+ const adjacencyIn = (0, import_core56.node)(
8810
9349
  [edgesMap.entries],
8811
9350
  (batchData, actions, ctx) => {
8812
9351
  const data = batchData.map(
@@ -8825,9 +9364,9 @@ function knowledgeGraph(name, opts = {}) {
8825
9364
  );
8826
9365
  graph.add(adjacencyOut, { name: "adjacencyOut" });
8827
9366
  graph.add(adjacencyIn, { name: "adjacencyIn" });
8828
- graph.addDisposer((0, import_extra34.keepalive)(adjacencyOut));
8829
- graph.addDisposer((0, import_extra34.keepalive)(adjacencyIn));
8830
- const entityCount = (0, import_core49.node)(
9367
+ graph.addDisposer((0, import_extra39.keepalive)(adjacencyOut));
9368
+ graph.addDisposer((0, import_extra39.keepalive)(adjacencyIn));
9369
+ const entityCount = (0, import_core56.node)(
8831
9370
  [entitiesMap.entries],
8832
9371
  (batchData, actions, ctx) => {
8833
9372
  const data = batchData.map(
@@ -8838,7 +9377,7 @@ function knowledgeGraph(name, opts = {}) {
8838
9377
  },
8839
9378
  { name: "entityCount", describeKind: "derived", initial: 0, meta: memoryMeta("entity_count") }
8840
9379
  );
8841
- const edgeCount = (0, import_core49.node)(
9380
+ const edgeCount = (0, import_core56.node)(
8842
9381
  [edgesMap.entries],
8843
9382
  (batchData, actions, ctx) => {
8844
9383
  const data = batchData.map(
@@ -8851,8 +9390,8 @@ function knowledgeGraph(name, opts = {}) {
8851
9390
  );
8852
9391
  graph.add(entityCount, { name: "entityCount" });
8853
9392
  graph.add(edgeCount, { name: "edgeCount" });
8854
- graph.addDisposer((0, import_extra34.keepalive)(entityCount));
8855
- graph.addDisposer((0, import_extra34.keepalive)(edgeCount));
9393
+ graph.addDisposer((0, import_extra39.keepalive)(entityCount));
9394
+ graph.addDisposer((0, import_extra39.keepalive)(edgeCount));
8856
9395
  const events = createAuditLog({
8857
9396
  name: "events",
8858
9397
  retainedLimit: 1024,
@@ -8875,7 +9414,7 @@ function knowledgeGraph(name, opts = {}) {
8875
9414
  events.append({
8876
9415
  action: "orphanRemove",
8877
9416
  id: candidate,
8878
- t_ns: (0, import_core49.wallClockNs)(),
9417
+ t_ns: (0, import_core56.wallClockNs)(),
8879
9418
  seq: bumpCursor(seqCursor)
8880
9419
  });
8881
9420
  }
@@ -8970,7 +9509,7 @@ function knowledgeGraph(name, opts = {}) {
8970
9509
  const idN = toNode(id, "id");
8971
9510
  const relN = relation !== void 0 ? toNode(relation, "relation") : void 0;
8972
9511
  const deps = relN ? [adjacencyOut, adjacencyIn, idN, relN] : [adjacencyOut, adjacencyIn, idN];
8973
- return (0, import_core49.node)(
9512
+ return (0, import_core56.node)(
8974
9513
  deps,
8975
9514
  (batchData, actions, ctx) => {
8976
9515
  const values = batchData.map(
@@ -9046,7 +9585,7 @@ var MemoryWithVectorsGraph = class extends import_graph8.Graph {
9046
9585
  this.mount("vectorIndex", this.vectors);
9047
9586
  const embedFn = opts.embedFn;
9048
9587
  const vectorsRef = this.vectors;
9049
- const indexer = (0, import_core50.node)(
9588
+ const indexer = (0, import_core57.node)(
9050
9589
  [opts.store.store.entries],
9051
9590
  (batchData, _actions, ctx) => {
9052
9591
  const data = batchData.map(
@@ -9061,7 +9600,7 @@ var MemoryWithVectorsGraph = class extends import_graph8.Graph {
9061
9600
  { name: "indexer", describeKind: "effect" }
9062
9601
  );
9063
9602
  this.add(indexer, { name: "indexer" });
9064
- this.addDisposer((0, import_extra35.keepalive)(indexer));
9603
+ this.addDisposer((0, import_extra40.keepalive)(indexer));
9065
9604
  }
9066
9605
  };
9067
9606
  function memoryWithVectors(opts) {
@@ -9079,7 +9618,7 @@ var MemoryWithKGGraph = class extends import_graph8.Graph {
9079
9618
  if (!opts.entityFn) return;
9080
9619
  const entityFn = opts.entityFn;
9081
9620
  const kgRef = this.kg;
9082
- const indexer = (0, import_core50.node)(
9621
+ const indexer = (0, import_core57.node)(
9083
9622
  [opts.store.store.entries],
9084
9623
  (batchData, _actions, ctx) => {
9085
9624
  const data = batchData.map(
@@ -9100,7 +9639,7 @@ var MemoryWithKGGraph = class extends import_graph8.Graph {
9100
9639
  { name: "indexer", describeKind: "effect" }
9101
9640
  );
9102
9641
  this.add(indexer, { name: "indexer" });
9103
- this.addDisposer((0, import_extra35.keepalive)(indexer));
9642
+ this.addDisposer((0, import_extra40.keepalive)(indexer));
9104
9643
  }
9105
9644
  };
9106
9645
  function memoryWithKG(opts) {
@@ -9122,20 +9661,20 @@ var MemoryWithTiersGraph = class extends import_graph8.Graph {
9122
9661
  const permanentFilter = opts.permanentFilter ?? (() => false);
9123
9662
  this.permanent = collection("permanent", { ranked: false });
9124
9663
  this.mount("permanent", this.permanent);
9125
- this.permanentKeys = (0, import_extra35.reactiveMap)({ name: "permanentKeys" });
9664
+ this.permanentKeys = (0, import_extra40.reactiveMap)({ name: "permanentKeys" });
9126
9665
  this.add(this.permanentKeys.entries, { name: "permanentKeys" });
9127
- this.entryCreatedAtNs = (0, import_extra35.reactiveMap)({ name: "entryCreatedAtNs" });
9666
+ this.entryCreatedAtNs = (0, import_extra40.reactiveMap)({ name: "entryCreatedAtNs" });
9128
9667
  this.add(this.entryCreatedAtNs.entries, { name: "entryCreatedAtNs" });
9129
9668
  let contextNode;
9130
9669
  if (opts.context) {
9131
- contextNode = (0, import_extra35.fromAny)(opts.context);
9670
+ contextNode = (0, import_extra40.fromAny)(opts.context);
9132
9671
  } else {
9133
- contextNode = (0, import_core50.node)([], { initial: null });
9672
+ contextNode = (0, import_core57.node)([], { initial: null });
9134
9673
  this.add(contextNode, { name: "context" });
9135
9674
  }
9136
9675
  let latestCtx = contextNode.cache;
9137
9676
  const ctxUnsub = contextNode.subscribe((msgs) => {
9138
- for (const m of msgs) if (m[0] === import_core50.DATA) latestCtx = m[1];
9677
+ for (const m of msgs) if (m[0] === import_core57.DATA) latestCtx = m[1];
9139
9678
  });
9140
9679
  this.addDisposer(ctxUnsub);
9141
9680
  const permanentKeysRef = this.permanentKeys;
@@ -9145,7 +9684,7 @@ var MemoryWithTiersGraph = class extends import_graph8.Graph {
9145
9684
  score: (key, value) => {
9146
9685
  if (permanentFilter(key, value)) return Number.POSITIVE_INFINITY;
9147
9686
  if (permanentKeysRef.has(key)) return Number.POSITIVE_INFINITY;
9148
- const nowNs = (0, import_core50.monotonicNs)();
9687
+ const nowNs = (0, import_core57.monotonicNs)();
9149
9688
  const createdNs = entryCreatedAtNsRef.get(key) ?? nowNs;
9150
9689
  const ageSeconds2 = Number(nowNs - createdNs) / 1e9;
9151
9690
  return decay(score(value, latestCtx), ageSeconds2, decayRate);
@@ -9180,20 +9719,20 @@ var MemoryWithTiersGraph = class extends import_graph8.Graph {
9180
9719
  permanentKeysRef.set(key, true);
9181
9720
  permanentRef.upsert(key, value);
9182
9721
  };
9183
- const syncCreatedAt = (0, import_core50.node)(
9722
+ const syncCreatedAt = (0, import_core57.node)(
9184
9723
  [this.store.store.entries],
9185
9724
  (batchData, _actions, ctx) => {
9186
9725
  const data = batchData.map(
9187
9726
  (b, i) => b != null && b.length > 0 ? b.at(-1) : ctx.prevData[i]
9188
9727
  );
9189
9728
  const map = data[0] ?? /* @__PURE__ */ new Map();
9190
- const nowNs = (0, import_core50.monotonicNs)();
9729
+ const nowNs = (0, import_core57.monotonicNs)();
9191
9730
  const toAdd = [];
9192
9731
  for (const key of map.keys()) {
9193
9732
  if (!entryCreatedAtNsRef.has(key)) toAdd.push(key);
9194
9733
  }
9195
9734
  if (toAdd.length > 0) {
9196
- (0, import_core50.batch)(() => {
9735
+ (0, import_core57.batch)(() => {
9197
9736
  for (const key of toAdd) entryCreatedAtNsRef.set(key, nowNs);
9198
9737
  });
9199
9738
  }
@@ -9201,10 +9740,10 @@ var MemoryWithTiersGraph = class extends import_graph8.Graph {
9201
9740
  { name: "entryCreatedAtNs/sync", describeKind: "effect" }
9202
9741
  );
9203
9742
  this.add(syncCreatedAt, { name: "entryCreatedAtNs/sync" });
9204
- this.addDisposer((0, import_extra35.keepalive)(syncCreatedAt));
9743
+ this.addDisposer((0, import_extra40.keepalive)(syncCreatedAt));
9205
9744
  const entriesUnsub = this.store.store.entries.subscribe((msgs) => {
9206
9745
  for (const m of msgs) {
9207
- if (m[0] !== import_core50.DATA) continue;
9746
+ if (m[0] !== import_core57.DATA) continue;
9208
9747
  const map = m[1];
9209
9748
  const created = entryCreatedAtNsRef.entries.cache;
9210
9749
  if (created == null) continue;
@@ -9213,14 +9752,14 @@ var MemoryWithTiersGraph = class extends import_graph8.Graph {
9213
9752
  if (!map.has(key)) toDelete.push(key);
9214
9753
  }
9215
9754
  if (toDelete.length > 0) {
9216
- (0, import_core50.batch)(() => {
9755
+ (0, import_core57.batch)(() => {
9217
9756
  for (const key of toDelete) entryCreatedAtNsRef.delete(key);
9218
9757
  });
9219
9758
  }
9220
9759
  }
9221
9760
  });
9222
9761
  this.addDisposer(entriesUnsub);
9223
- const promoter = (0, import_core50.node)(
9762
+ const promoter = (0, import_core57.node)(
9224
9763
  [this.store.store.entries],
9225
9764
  (batchData, _actions, ctx) => {
9226
9765
  const data = batchData.map(
@@ -9230,7 +9769,7 @@ var MemoryWithTiersGraph = class extends import_graph8.Graph {
9230
9769
  for (const [key, mem] of map) {
9231
9770
  if (permanentKeysRef.has(key)) continue;
9232
9771
  if (permanentFilter(key, mem)) {
9233
- (0, import_core50.batch)(() => {
9772
+ (0, import_core57.batch)(() => {
9234
9773
  markPermanent(key, mem);
9235
9774
  });
9236
9775
  }
@@ -9239,7 +9778,7 @@ var MemoryWithTiersGraph = class extends import_graph8.Graph {
9239
9778
  { name: "promoter", describeKind: "effect" }
9240
9779
  );
9241
9780
  this.add(promoter, { name: "promoter" });
9242
- this.addDisposer((0, import_extra35.keepalive)(promoter));
9781
+ this.addDisposer((0, import_extra40.keepalive)(promoter));
9243
9782
  let archiveHandle = null;
9244
9783
  if (opts.archiveTier) {
9245
9784
  archiveHandle = this.attachSnapshotStorage(
@@ -9295,7 +9834,7 @@ var MemoryRetrievalGraph = class extends import_graph8.Graph {
9295
9834
  this._budget = opts.budget ?? 2e3;
9296
9835
  this._contextWeight = opts.contextWeight ?? 0;
9297
9836
  if (opts.context) {
9298
- this._contextNode = (0, import_extra35.fromAny)(opts.context);
9837
+ this._contextNode = (0, import_extra40.fromAny)(opts.context);
9299
9838
  } else {
9300
9839
  this._contextNode = this.state("_context", null);
9301
9840
  }
@@ -9441,7 +9980,7 @@ var MemoryRetrievalGraph = class extends import_graph8.Graph {
9441
9980
  const id = ++this._retrieveSeq;
9442
9981
  const segment = `retrieve_${id}`;
9443
9982
  const sub = new import_graph8.Graph(segment);
9444
- const inputNode = (0, import_extra35.fromAny)(queryInput);
9983
+ const inputNode = (0, import_extra40.fromAny)(queryInput);
9445
9984
  const localContext = sub.derived(
9446
9985
  "context",
9447
9986
  [inputNode],
@@ -9486,7 +10025,7 @@ var MemoryRetrievalGraph = class extends import_graph8.Graph {
9486
10025
  initial: { packed: [], trace: null }
9487
10026
  }
9488
10027
  );
9489
- const projection = (0, import_core50.node)(
10028
+ const projection = (0, import_core57.node)(
9490
10029
  [result],
9491
10030
  (batchData, actions, ctx) => {
9492
10031
  const data = batchData.map(
@@ -9526,18 +10065,18 @@ function gaugesAsContext(graph, actor, options) {
9526
10065
  const separator = options?.separator ?? "\n";
9527
10066
  const entries = [];
9528
10067
  const sinceVersion = options?.sinceVersion;
9529
- for (const [path, node58] of Object.entries(described.nodes)) {
9530
- const meta2 = node58.meta ?? {};
10068
+ for (const [path, node65] of Object.entries(described.nodes)) {
10069
+ const meta2 = node65.meta ?? {};
9531
10070
  const desc = meta2.description;
9532
10071
  const format = meta2.format;
9533
10072
  if (!desc && !format) continue;
9534
- if (sinceVersion != null && node58.v != null) {
10073
+ if (sinceVersion != null && node65.v != null) {
9535
10074
  const lastSeen = sinceVersion.get(path);
9536
- if (lastSeen != null && lastSeen.id === node58.v.id && node58.v.version <= lastSeen.version)
10075
+ if (lastSeen != null && lastSeen.id === node65.v.id && node65.v.version <= lastSeen.version)
9537
10076
  continue;
9538
10077
  }
9539
10078
  const label = desc ?? path;
9540
- const value = node58.value;
10079
+ const value = node65.value;
9541
10080
  const unit = meta2.unit;
9542
10081
  let formatted;
9543
10082
  if (format === "currency" && typeof value === "number") {
@@ -9559,8 +10098,8 @@ function gaugesAsContext(graph, actor, options) {
9559
10098
  const tagGroups = /* @__PURE__ */ new Map();
9560
10099
  const ungrouped = [];
9561
10100
  for (const entry of entries) {
9562
- const node58 = described.nodes[entry.path];
9563
- const tags = node58.meta?.tags;
10101
+ const node65 = described.nodes[entry.path];
10102
+ const tags = node65.meta?.tags;
9564
10103
  if (tags && tags.length > 0) {
9565
10104
  const tag = tags[0];
9566
10105
  let group = tagGroups.get(tag);
@@ -9591,18 +10130,18 @@ function gaugesAsContext(graph, actor, options) {
9591
10130
  }
9592
10131
 
9593
10132
  // src/utils/ai/graph-integration/graph-from-spec.ts
9594
- var import_core53 = require("@graphrefly/pure-ts/core");
9595
- var import_extra38 = require("@graphrefly/pure-ts/extra");
10133
+ var import_core60 = require("@graphrefly/pure-ts/core");
10134
+ var import_extra43 = require("@graphrefly/pure-ts/extra");
9596
10135
 
9597
10136
  // src/utils/graphspec/index.ts
9598
- var import_core52 = require("@graphrefly/pure-ts/core");
10137
+ var import_core59 = require("@graphrefly/pure-ts/core");
9599
10138
  var import_graph10 = require("@graphrefly/pure-ts/graph");
9600
10139
 
9601
10140
  // src/utils/reduction/index.ts
9602
- var import_core51 = require("@graphrefly/pure-ts/core");
9603
- var import_extra36 = require("@graphrefly/pure-ts/extra");
10141
+ var import_core58 = require("@graphrefly/pure-ts/core");
10142
+ var import_extra41 = require("@graphrefly/pure-ts/extra");
9604
10143
  var import_graph9 = require("@graphrefly/pure-ts/graph");
9605
- var import_extra37 = require("@graphrefly/pure-ts/extra");
10144
+ var import_extra42 = require("@graphrefly/pure-ts/extra");
9606
10145
  function baseMeta(kind, meta2) {
9607
10146
  return domainMeta("reduction", kind, meta2);
9608
10147
  }
@@ -9610,7 +10149,7 @@ function funnel(name, sources, stages, opts) {
9610
10149
  if (sources.length === 0) throw new RangeError("funnel requires at least one source");
9611
10150
  if (stages.length === 0) throw new RangeError("funnel requires at least one stage");
9612
10151
  const g = new import_graph9.Graph(name, opts);
9613
- const merged = sources.length === 1 ? sources[0] : (0, import_extra36.merge)(...sources);
10152
+ const merged = sources.length === 1 ? sources[0] : (0, import_extra41.merge)(...sources);
9614
10153
  g.add(merged, { name: "merged" });
9615
10154
  let prevOutputPath = "merged";
9616
10155
  for (let i = 0; i < stages.length; i++) {
@@ -9632,7 +10171,7 @@ function funnel(name, sources, stages, opts) {
9632
10171
  const stageInputPath = `${stage.name}::input`;
9633
10172
  const stageInput = g.resolve(stageInputPath);
9634
10173
  const bridgeName = `__bridge_${prevOutputPath}\u2192${stage.name}_input`;
9635
- const br = (0, import_core51.node)(
10174
+ const br = (0, import_core58.node)(
9636
10175
  [prevNode],
9637
10176
  (batchData, _actions, ctx) => {
9638
10177
  const data = batchData.map(
@@ -9644,7 +10183,7 @@ function funnel(name, sources, stages, opts) {
9644
10183
  { describeKind: "effect", name: bridgeName }
9645
10184
  );
9646
10185
  g.add(br, { name: bridgeName });
9647
- g.addDisposer((0, import_extra37.keepalive)(br));
10186
+ g.addDisposer((0, import_extra42.keepalive)(br));
9648
10187
  prevOutputPath = `${stage.name}::output`;
9649
10188
  }
9650
10189
  return g;
@@ -9652,7 +10191,7 @@ function funnel(name, sources, stages, opts) {
9652
10191
  function feedback(graph, condition, reentry, opts) {
9653
10192
  const maxIter = opts?.maxIterations ?? 10;
9654
10193
  const counterName = `__feedback_${condition}`;
9655
- const counter = (0, import_core51.node)([], {
10194
+ const counter = (0, import_core58.node)([], {
9656
10195
  ...{
9657
10196
  meta: baseMeta("feedback_counter", {
9658
10197
  maxIterations: maxIter,
@@ -9666,22 +10205,22 @@ function feedback(graph, condition, reentry, opts) {
9666
10205
  const condNode = graph.resolve(condition);
9667
10206
  const reentryNode = graph.resolve(reentry);
9668
10207
  const feedbackEffectName = `__feedback_effect_${condition}`;
9669
- const feedbackEffect = (0, import_core51.node)(
10208
+ const feedbackEffect = (0, import_core58.node)(
9670
10209
  [],
9671
10210
  (_data, _feedbackActions) => {
9672
10211
  const unsub = condNode.subscribe((msgs) => {
9673
10212
  for (const msg of msgs) {
9674
10213
  const t = msg[0];
9675
- if (t === import_core51.DATA) {
10214
+ if (t === import_core58.DATA) {
9676
10215
  const condValue = msg[1];
9677
10216
  if (condValue == null) return;
9678
- (0, import_core51.batch)(() => {
10217
+ (0, import_core58.batch)(() => {
9679
10218
  if (tryIncrementBounded(counter, maxIter)) {
9680
10219
  reentryNode.emit(condValue);
9681
10220
  }
9682
10221
  });
9683
- } else if (t === import_core51.COMPLETE || t === import_core51.ERROR) {
9684
- const terminal = t === import_core51.ERROR && msg.length > 1 ? [import_core51.ERROR, msg[1]] : [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];
9685
10224
  counter.down([terminal]);
9686
10225
  }
9687
10226
  }
@@ -9701,7 +10240,7 @@ function feedback(graph, condition, reentry, opts) {
9701
10240
  }
9702
10241
  );
9703
10242
  graph.add(feedbackEffect, { name: feedbackEffectName });
9704
- graph.addDisposer((0, import_extra37.keepalive)(feedbackEffect));
10243
+ graph.addDisposer((0, import_extra42.keepalive)(feedbackEffect));
9705
10244
  return graph;
9706
10245
  }
9707
10246
  function scorer(sources, weights, opts) {
@@ -9712,7 +10251,7 @@ function scorer(sources, weights, opts) {
9712
10251
  const allDeps = [...sources, ...weights];
9713
10252
  const n = sources.length;
9714
10253
  const scoreFns = opts?.scoreFns;
9715
- return (0, import_core51.node)(
10254
+ return (0, import_core58.node)(
9716
10255
  allDeps,
9717
10256
  (batchData, actions, ctx) => {
9718
10257
  const vals = batchData.map(
@@ -9749,18 +10288,18 @@ function scorer(sources, weights, opts) {
9749
10288
  }
9750
10289
 
9751
10290
  // src/utils/graphspec/index.ts
9752
- function readFactory(node58) {
9753
- const f = node58.meta?.factory;
10291
+ function readFactory(node65) {
10292
+ const f = node65.meta?.factory;
9754
10293
  return typeof f === "string" ? f : void 0;
9755
10294
  }
9756
- function readFactoryArgs(node58) {
9757
- const a = node58.meta?.factoryArgs;
10295
+ function readFactoryArgs(node65) {
10296
+ const a = node65.meta?.factoryArgs;
9758
10297
  return a != null && typeof a === "object" ? a : {};
9759
10298
  }
9760
- function readStateInitial(node58) {
9761
- const args = readFactoryArgs(node58);
10299
+ function readStateInitial(node65) {
10300
+ const args = readFactoryArgs(node65);
9762
10301
  if ("initial" in args) return args.initial;
9763
- return node58.value;
10302
+ return node65.value;
9764
10303
  }
9765
10304
  function isRichFnEntry(entry) {
9766
10305
  return typeof entry === "object" && entry !== null && "factory" in entry;
@@ -9833,11 +10372,11 @@ function validateSpecAgainstCatalog(spec, catalog) {
9833
10372
  const sourceNames = new Set(Object.keys(catalog.sources ?? {}));
9834
10373
  for (const [nodeName, nodeRaw] of Object.entries(spec.nodes)) {
9835
10374
  if (nodeRaw.type === "template") continue;
9836
- const node58 = nodeRaw;
9837
- const factoryName = readFactory(node58);
10375
+ const node65 = nodeRaw;
10376
+ const factoryName = readFactory(node65);
9838
10377
  if (factoryName == null) continue;
9839
- const isProducer = node58.type === "producer";
9840
- if (node58.type === "state" && factoryName === "state") continue;
10378
+ const isProducer = node65.type === "producer";
10379
+ if (node65.type === "state" && factoryName === "state") continue;
9841
10380
  if (isProducer) {
9842
10381
  const inSources = sourceNames.has(factoryName);
9843
10382
  const inFns = fnNames.has(factoryName);
@@ -9861,7 +10400,7 @@ function validateSpecAgainstCatalog(spec, catalog) {
9861
10400
  }
9862
10401
  }
9863
10402
  }
9864
- const factoryArgs = readFactoryArgs(node58);
10403
+ const factoryArgs = readFactoryArgs(node65);
9865
10404
  if (!isProducer && catalog.fns?.[factoryName]) {
9866
10405
  const entry = catalog.fns[factoryName];
9867
10406
  if (isRichFnEntry(entry) && entry.configSchema) {
@@ -9901,11 +10440,11 @@ function validateSpecAgainstCatalog(spec, catalog) {
9901
10440
  }
9902
10441
  if (spec.templates) {
9903
10442
  for (const [tName, template] of Object.entries(spec.templates)) {
9904
- for (const [nodeName, node58] of Object.entries(template.nodes)) {
9905
- const factoryName = readFactory(node58);
10443
+ for (const [nodeName, node65] of Object.entries(template.nodes)) {
10444
+ const factoryName = readFactory(node65);
9906
10445
  if (factoryName == null) continue;
9907
- if (node58.type === "state" && factoryName === "state") continue;
9908
- if (node58.type === "producer") continue;
10446
+ if (node65.type === "state" && factoryName === "state") continue;
10447
+ if (node65.type === "producer") continue;
9909
10448
  if (fnNames.size > 0 && !fnNames.has(factoryName)) {
9910
10449
  const suggestion = findClosest(factoryName, fnNames);
9911
10450
  errors.push(
@@ -10120,8 +10659,8 @@ function validateSpec(spec) {
10120
10659
  warnings
10121
10660
  };
10122
10661
  }
10123
- function readOwner(node58) {
10124
- const o = node58.meta?.owner;
10662
+ function readOwner(node65) {
10663
+ const o = node65.meta?.owner;
10125
10664
  return typeof o === "string" && o.length > 0 ? o : void 0;
10126
10665
  }
10127
10666
  var OVERRIDE_OWNER_TRAILER = /^\s*override-owner\s*:\s*(.+?)\s*$/im;
@@ -10220,7 +10759,7 @@ ${catalogValidation.errors.join("\n")}`
10220
10759
  const factoryArgs = readFactoryArgs(n);
10221
10760
  if (n.type === "state") {
10222
10761
  const initial = readStateInitial(n);
10223
- const nd = (0, import_core52.node)([], {
10762
+ const nd = (0, import_core59.node)([], {
10224
10763
  name,
10225
10764
  initial,
10226
10765
  meta: stripFactoryMeta(n.meta)
@@ -10240,7 +10779,7 @@ ${catalogValidation.errors.join("\n")}`
10240
10779
  created.set(name, nd);
10241
10780
  } else {
10242
10781
  if (factoryName) recordMissing(name, "source", factoryName);
10243
- const nd = (0, import_core52.node)([], () => {
10782
+ const nd = (0, import_core59.node)([], () => {
10244
10783
  }, {
10245
10784
  name,
10246
10785
  describeKind: "producer",
@@ -10269,11 +10808,11 @@ ${catalogValidation.errors.join("\n")}`
10269
10808
  nd = fnFactory(resolvedDeps, factoryArgs);
10270
10809
  } else if (n.type === "effect") {
10271
10810
  if (factoryName) recordMissing(name, "fn", factoryName);
10272
- nd = (0, import_core52.node)(resolvedDeps, () => {
10811
+ nd = (0, import_core59.node)(resolvedDeps, () => {
10273
10812
  }, { describeKind: "effect" });
10274
10813
  } else {
10275
10814
  if (factoryName) recordMissing(name, "fn", factoryName);
10276
- nd = (0, import_core52.node)(
10815
+ nd = (0, import_core59.node)(
10277
10816
  resolvedDeps,
10278
10817
  (batchData, actions, ctx) => {
10279
10818
  const data = batchData.map(
@@ -10313,7 +10852,7 @@ ${catalogValidation.errors.join("\n")}`
10313
10852
  const factoryArgs = readFactoryArgs(nSpec);
10314
10853
  if (nSpec.type === "state") {
10315
10854
  const initial = readStateInitial(nSpec);
10316
- const nd = (0, import_core52.node)([], {
10855
+ const nd = (0, import_core59.node)([], {
10317
10856
  name: nName,
10318
10857
  initial,
10319
10858
  meta: stripFactoryMeta(nSpec.meta)
@@ -10333,7 +10872,7 @@ ${catalogValidation.errors.join("\n")}`
10333
10872
  subCreated.set(nName, nd);
10334
10873
  } else {
10335
10874
  if (factoryName) recordMissing(`${name}.${nName}`, "source", factoryName);
10336
- const nd = (0, import_core52.node)([], () => {
10875
+ const nd = (0, import_core59.node)([], () => {
10337
10876
  }, {
10338
10877
  name: nName,
10339
10878
  describeKind: "producer",
@@ -10363,11 +10902,11 @@ ${catalogValidation.errors.join("\n")}`
10363
10902
  nd = fnFactory(resolvedDeps, factoryArgs);
10364
10903
  } else if (nSpec.type === "effect") {
10365
10904
  if (factoryName) recordMissing(`${name}.${nName}`, "fn", factoryName);
10366
- nd = (0, import_core52.node)(resolvedDeps, () => {
10905
+ nd = (0, import_core59.node)(resolvedDeps, () => {
10367
10906
  }, { describeKind: "effect" });
10368
10907
  } else {
10369
10908
  if (factoryName) recordMissing(`${name}.${nName}`, "fn", factoryName);
10370
- nd = (0, import_core52.node)(
10909
+ nd = (0, import_core59.node)(
10371
10910
  resolvedDeps,
10372
10911
  (batchData, actions, ctx) => {
10373
10912
  const data = batchData.map(
@@ -10854,12 +11393,12 @@ ${opts.systemPromptExtra}` : GRAPH_FROM_SPEC_SYSTEM_PROMPT;
10854
11393
  return compileSpec(parsed, { catalog: opts?.catalog });
10855
11394
  }
10856
11395
  function graphFromSpecReactive(input, adapter, opts) {
10857
- const inputNode = (0, import_extra38.fromAny)(input);
10858
- return (0, import_extra38.switchMap)(inputNode, (nl) => {
11396
+ const inputNode = (0, import_extra43.fromAny)(input);
11397
+ return (0, import_extra43.switchMap)(inputNode, (nl) => {
10859
11398
  if (!nl || typeof nl !== "string" || nl.trim().length === 0) {
10860
- return (0, import_core53.node)([], { initial: null });
11399
+ return (0, import_core60.node)([], { initial: null });
10861
11400
  }
10862
- return (0, import_core53.node)(
11401
+ return (0, import_core60.node)(
10863
11402
  (_data, actions) => {
10864
11403
  const controller = new AbortController();
10865
11404
  let cancelled = false;
@@ -10869,10 +11408,10 @@ function graphFromSpecReactive(input, adapter, opts) {
10869
11408
  return;
10870
11409
  }
10871
11410
  actions.emit(g);
10872
- actions.down([[import_core53.COMPLETE]]);
11411
+ actions.down([[import_core60.COMPLETE]]);
10873
11412
  }).catch((err) => {
10874
11413
  if (cancelled) return;
10875
- actions.down([[import_core53.ERROR, err]]);
11414
+ actions.down([[import_core60.ERROR, err]]);
10876
11415
  });
10877
11416
  return () => {
10878
11417
  cancelled = true;
@@ -10923,11 +11462,11 @@ function knobsAsTools(graph, actor) {
10923
11462
  const openai = [];
10924
11463
  const mcp = [];
10925
11464
  const definitions = [];
10926
- for (const [path, node58] of Object.entries(described.nodes)) {
10927
- if (node58.type !== "state") continue;
11465
+ for (const [path, node65] of Object.entries(described.nodes)) {
11466
+ if (node65.type !== "state") continue;
10928
11467
  if (path.includes("::__meta__::")) continue;
10929
- if (node58.status === "completed" || node58.status === "errored") continue;
10930
- const meta2 = node58.meta ?? {};
11468
+ if (node65.status === "completed" || node65.status === "errored") continue;
11469
+ const meta2 = node65.meta ?? {};
10931
11470
  const access = meta2.access;
10932
11471
  if (access === "human" || access === "system") continue;
10933
11472
  const description = meta2.description ?? `Set the value of ${path}`;
@@ -10956,7 +11495,7 @@ function knobsAsTools(graph, actor) {
10956
11495
  });
10957
11496
  const graphRef = graph;
10958
11497
  const actorRef = actor;
10959
- const nv = node58.v;
11498
+ const nv = node65.v;
10960
11499
  definitions.push({
10961
11500
  name: path,
10962
11501
  description,
@@ -10972,8 +11511,8 @@ function knobsAsTools(graph, actor) {
10972
11511
  }
10973
11512
 
10974
11513
  // src/utils/ai/graph-integration/suggest-strategy.ts
10975
- var import_core54 = require("@graphrefly/pure-ts/core");
10976
- var import_extra39 = require("@graphrefly/pure-ts/extra");
11514
+ var import_core61 = require("@graphrefly/pure-ts/core");
11515
+ var import_extra44 = require("@graphrefly/pure-ts/extra");
10977
11516
  var SUGGEST_STRATEGY_SYSTEM_PROMPT = `You are a reactive graph optimizer for GraphReFly.
10978
11517
 
10979
11518
  Given a graph's current structure (from describe()) and a problem statement, suggest topology and parameter changes to solve the problem.
@@ -11042,26 +11581,26 @@ async function suggestStrategy(graph, problem, adapter, opts) {
11042
11581
  };
11043
11582
  }
11044
11583
  function suggestStrategyReactive(graph, problem, adapter, opts) {
11045
- const problemNode = (0, import_extra39.fromAny)(problem);
11046
- const paired = (0, import_extra39.withLatestFrom)(problemNode, graph);
11047
- return (0, import_extra39.switchMap)(paired, (pair) => {
11048
- if (pair == null) return (0, import_core54.node)([], { initial: null });
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 });
11049
11588
  const [pText, g] = pair;
11050
11589
  if (!g || !pText || typeof pText !== "string" || pText.trim().length === 0) {
11051
- return (0, import_core54.node)([], { initial: null });
11590
+ return (0, import_core61.node)([], { initial: null });
11052
11591
  }
11053
- if (g.destroyed) return (0, import_core54.node)([], { initial: null });
11054
- return (0, import_core54.node)(
11592
+ if (g.destroyed) return (0, import_core61.node)([], { initial: null });
11593
+ return (0, import_core61.node)(
11055
11594
  (_data, actions) => {
11056
11595
  const controller = new AbortController();
11057
11596
  let cancelled = false;
11058
11597
  suggestStrategy(g, pText, adapter, { ...opts, signal: controller.signal }).then((plan) => {
11059
11598
  if (cancelled) return;
11060
11599
  actions.emit(plan);
11061
- actions.down([[import_core54.COMPLETE]]);
11600
+ actions.down([[import_core61.COMPLETE]]);
11062
11601
  }).catch((err) => {
11063
11602
  if (cancelled) return;
11064
- actions.down([[import_core54.ERROR, err]]);
11603
+ actions.down([[import_core61.ERROR, err]]);
11065
11604
  });
11066
11605
  return () => {
11067
11606
  cancelled = true;
@@ -11094,14 +11633,14 @@ function validateGraphDef(def) {
11094
11633
  errors.push(`Node "${name}": must be an object`);
11095
11634
  continue;
11096
11635
  }
11097
- const node58 = raw;
11098
- if (typeof node58.type !== "string" || !VALID_NODE_TYPES2.has(node58.type)) {
11636
+ const node65 = raw;
11637
+ if (typeof node65.type !== "string" || !VALID_NODE_TYPES2.has(node65.type)) {
11099
11638
  errors.push(
11100
- `Node "${name}": invalid type "${String(node58.type)}" (expected: ${[...VALID_NODE_TYPES2].join(", ")})`
11639
+ `Node "${name}": invalid type "${String(node65.type)}" (expected: ${[...VALID_NODE_TYPES2].join(", ")})`
11101
11640
  );
11102
11641
  }
11103
- if (Array.isArray(node58.deps)) {
11104
- for (const dep of node58.deps) {
11642
+ if (Array.isArray(node65.deps)) {
11643
+ for (const dep of node65.deps) {
11105
11644
  if (typeof dep === "string" && !nodeNames.has(dep)) {
11106
11645
  errors.push(`Node "${name}": dep "${dep}" does not reference an existing node`);
11107
11646
  }
@@ -11138,21 +11677,21 @@ function validateGraphDef(def) {
11138
11677
  }
11139
11678
 
11140
11679
  // src/utils/cqrs/index.ts
11141
- var import_core55 = require("@graphrefly/pure-ts/core");
11142
- var import_extra40 = require("@graphrefly/pure-ts/extra");
11680
+ var import_core62 = require("@graphrefly/pure-ts/core");
11681
+ var import_extra45 = require("@graphrefly/pure-ts/extra");
11143
11682
  var import_graph11 = require("@graphrefly/pure-ts/graph");
11144
- var import_extra41 = require("@graphrefly/pure-ts/extra");
11145
- var COMMAND_GUARD = (0, import_core55.policy)((allow, deny) => {
11683
+ var import_extra46 = require("@graphrefly/pure-ts/extra");
11684
+ var COMMAND_GUARD = (0, import_core62.policy)((allow, deny) => {
11146
11685
  allow("write");
11147
11686
  allow("signal");
11148
11687
  deny("observe");
11149
11688
  });
11150
- var PROJECTION_GUARD = (0, import_core55.policy)((allow, deny) => {
11689
+ var PROJECTION_GUARD = (0, import_core62.policy)((allow, deny) => {
11151
11690
  allow("observe");
11152
11691
  allow("signal");
11153
11692
  deny("write");
11154
11693
  });
11155
- var EVENT_GUARD = (0, import_core55.policy)((allow, deny) => {
11694
+ var EVENT_GUARD = (0, import_core62.policy)((allow, deny) => {
11156
11695
  allow("observe");
11157
11696
  allow("signal");
11158
11697
  deny("write");
@@ -11262,7 +11801,7 @@ var CqrsGraph = class extends import_graph11.Graph {
11262
11801
  aggregateId,
11263
11802
  type,
11264
11803
  lastVersion,
11265
- t_ns: (0, import_core55.wallClockNs)()
11804
+ t_ns: (0, import_core62.wallClockNs)()
11266
11805
  });
11267
11806
  }
11268
11807
  }
@@ -11323,7 +11862,7 @@ var CqrsGraph = class extends import_graph11.Graph {
11323
11862
  }
11324
11863
  const existing = this._eventLogs.get(name);
11325
11864
  if (existing) return existing.node;
11326
- const log = (0, import_extra40.reactiveLog)([], {
11865
+ const log = (0, import_extra45.reactiveLog)([], {
11327
11866
  name,
11328
11867
  versioning: 0,
11329
11868
  maxSize: this._retainedLimit
@@ -11343,7 +11882,7 @@ var CqrsGraph = class extends import_graph11.Graph {
11343
11882
  initial: entries.cache
11344
11883
  }
11345
11884
  );
11346
- this.addDisposer((0, import_extra41.keepalive)(guarded));
11885
+ this.addDisposer((0, import_extra46.keepalive)(guarded));
11347
11886
  this._eventLogs.set(name, { log, node: guarded });
11348
11887
  this._autoWireStreamStorage(name, log);
11349
11888
  return guarded;
@@ -11365,7 +11904,7 @@ var CqrsGraph = class extends import_graph11.Graph {
11365
11904
  const existing = byType.get(aggregateId);
11366
11905
  if (existing) return existing;
11367
11906
  const nodeName = `${type}_${aggregateId.replace(/[^a-zA-Z0-9_-]/g, "_")}`;
11368
- const log = (0, import_extra40.reactiveLog)([], {
11907
+ const log = (0, import_extra45.reactiveLog)([], {
11369
11908
  name: nodeName,
11370
11909
  versioning: 0,
11371
11910
  maxSize: this._retainedLimit
@@ -11397,7 +11936,7 @@ var CqrsGraph = class extends import_graph11.Graph {
11397
11936
  }
11398
11937
  );
11399
11938
  } catch {
11400
- guarded = (0, import_core55.node)(
11939
+ guarded = (0, import_core62.node)(
11401
11940
  [entries],
11402
11941
  (batchData, actions, ctx) => {
11403
11942
  const latest = batchData[0] != null && batchData[0].length > 0 ? batchData[0].at(-1) : ctx.prevData[0];
@@ -11415,7 +11954,7 @@ var CqrsGraph = class extends import_graph11.Graph {
11415
11954
  }
11416
11955
  );
11417
11956
  }
11418
- this.addDisposer((0, import_extra41.keepalive)(guarded));
11957
+ this.addDisposer((0, import_extra46.keepalive)(guarded));
11419
11958
  const entry = { log, node: guarded };
11420
11959
  byType.set(aggregateId, entry);
11421
11960
  this._autoWireStreamStorage(`${type}::${aggregateId}`, log);
@@ -11455,7 +11994,7 @@ var CqrsGraph = class extends import_graph11.Graph {
11455
11994
  const evt = {
11456
11995
  type: eventName,
11457
11996
  payload: frozenPayload,
11458
- timestampNs: (0, import_core55.wallClockNs)(),
11997
+ timestampNs: (0, import_core62.wallClockNs)(),
11459
11998
  seq: ++this._seq,
11460
11999
  ...extra?.aggregateId !== void 0 ? { aggregateId: extra.aggregateId } : {},
11461
12000
  ...aggregateVersion !== void 0 ? { aggregateVersion } : {},
@@ -11703,7 +12242,7 @@ var CqrsGraph = class extends import_graph11.Graph {
11703
12242
  initial: seedState
11704
12243
  }
11705
12244
  );
11706
- this.addDisposer((0, import_extra41.keepalive)(projNode));
12245
+ this.addDisposer((0, import_extra46.keepalive)(projNode));
11707
12246
  this.addDisposer(() => {
11708
12247
  if (saveTimer !== void 0) {
11709
12248
  clearTimeout(saveTimer);
@@ -11813,7 +12352,7 @@ var CqrsGraph = class extends import_graph11.Graph {
11813
12352
  const cursor = cursors[eName];
11814
12353
  latestCursors.set(eName, cursor.cache ?? 0);
11815
12354
  const sub = cursor.subscribe((msgs) => {
11816
- for (const m of msgs) if (m[0] === import_core55.DATA) latestCursors.set(eName, m[1]);
12355
+ for (const m of msgs) if (m[0] === import_core62.DATA) latestCursors.set(eName, m[1]);
11817
12356
  });
11818
12357
  this.addDisposer(sub);
11819
12358
  }
@@ -11893,7 +12432,7 @@ var CqrsGraph = class extends import_graph11.Graph {
11893
12432
  }
11894
12433
  );
11895
12434
  sagaRef.n = sagaNode;
11896
- this.addDisposer((0, import_extra41.keepalive)(sagaNode));
12435
+ this.addDisposer((0, import_extra46.keepalive)(sagaNode));
11897
12436
  this._sagas.add(name);
11898
12437
  return {
11899
12438
  node: sagaNode,
@@ -11906,12 +12445,12 @@ var CqrsGraph = class extends import_graph11.Graph {
11906
12445
  function cqrs(name, opts) {
11907
12446
  const g = new CqrsGraph(name, opts);
11908
12447
  const { factory: _f, factoryArgs: _fa, ...tagArgs } = opts ?? {};
11909
- g.tagFactory("cqrs", (0, import_core55.placeholderArgs)(tagArgs));
12448
+ g.tagFactory("cqrs", (0, import_core62.placeholderArgs)(tagArgs));
11910
12449
  return g;
11911
12450
  }
11912
12451
 
11913
12452
  // src/utils/demo-shell/index.ts
11914
- var import_core58 = require("@graphrefly/pure-ts/core");
12453
+ var import_core65 = require("@graphrefly/pure-ts/core");
11915
12454
  var import_graph13 = require("@graphrefly/pure-ts/graph");
11916
12455
 
11917
12456
  // src/base/render/_ascii-width.ts
@@ -12534,14 +13073,14 @@ function graphSpecToMermaid(g, opts) {
12534
13073
  }
12535
13074
 
12536
13075
  // src/utils/reactive-layout/reactive-layout.ts
12537
- var import_core57 = require("@graphrefly/pure-ts/core");
13076
+ var import_core64 = require("@graphrefly/pure-ts/core");
12538
13077
  var import_graph12 = require("@graphrefly/pure-ts/graph");
12539
13078
 
12540
13079
  // src/base/meta/emit-to-meta.ts
12541
- var import_core56 = require("@graphrefly/pure-ts/core");
13080
+ var import_core63 = require("@graphrefly/pure-ts/core");
12542
13081
  function emitToMeta(metaNode, value) {
12543
13082
  if (metaNode == null) return;
12544
- (0, import_core56.downWithBatch)((msgs) => metaNode.down(msgs), [[import_core56.DATA, value]], import_core56.defaultConfig.tierOf);
13083
+ (0, import_core63.downWithBatch)((msgs) => metaNode.down(msgs), [[import_core63.DATA, value]], import_core63.defaultConfig.tierOf);
12545
13084
  }
12546
13085
 
12547
13086
  // src/utils/reactive-layout/reactive-layout.ts
@@ -13242,16 +13781,16 @@ function reactiveLayout(opts) {
13242
13781
  const { adapter, name = "reactive-layout" } = opts;
13243
13782
  const g = new import_graph12.Graph(name);
13244
13783
  const measureCache = /* @__PURE__ */ new Map();
13245
- const textNode = (0, import_core57.node)([], { name: "text", initial: opts.text ?? "" });
13246
- const fontNode = (0, import_core57.node)([], {
13784
+ const textNode = (0, import_core64.node)([], { name: "text", initial: opts.text ?? "" });
13785
+ const fontNode = (0, import_core64.node)([], {
13247
13786
  name: "font",
13248
13787
  initial: opts.font ?? "16px sans-serif"
13249
13788
  });
13250
- const lineHeightNode = (0, import_core57.node)([], {
13789
+ const lineHeightNode = (0, import_core64.node)([], {
13251
13790
  name: "line-height",
13252
13791
  initial: opts.lineHeight ?? 20
13253
13792
  });
13254
- const maxWidthNode = (0, import_core57.node)([], {
13793
+ const maxWidthNode = (0, import_core64.node)([], {
13255
13794
  name: "max-width",
13256
13795
  initial: Math.max(0, opts.maxWidth ?? 800)
13257
13796
  });
@@ -13263,14 +13802,14 @@ function reactiveLayout(opts) {
13263
13802
  }
13264
13803
  return true;
13265
13804
  }
13266
- const segmentsNode = (0, import_core57.node)(
13805
+ const segmentsNode = (0, import_core64.node)(
13267
13806
  [textNode, fontNode],
13268
13807
  (data, actions, ctx) => {
13269
13808
  const b0 = data[0];
13270
13809
  const textVal = b0 != null && b0.length > 0 ? b0.at(-1) : ctx.prevData[0];
13271
13810
  const b1 = data[1];
13272
13811
  const fontVal = b1 != null && b1.length > 0 ? b1.at(-1) : ctx.prevData[1];
13273
- const t0 = (0, import_core57.monotonicNs)();
13812
+ const t0 = (0, import_core64.monotonicNs)();
13274
13813
  const measureStats = { hits: 0, misses: 0 };
13275
13814
  const result = analyzeAndMeasure(
13276
13815
  textVal,
@@ -13279,7 +13818,7 @@ function reactiveLayout(opts) {
13279
13818
  measureCache,
13280
13819
  measureStats
13281
13820
  );
13282
- const elapsed = (0, import_core57.monotonicNs)() - t0;
13821
+ const elapsed = (0, import_core64.monotonicNs)() - t0;
13283
13822
  const lookups = measureStats.hits + measureStats.misses;
13284
13823
  const hitRate = lookups === 0 ? 1 : measureStats.hits / lookups;
13285
13824
  const meta2 = segmentsNode.meta;
@@ -13318,7 +13857,7 @@ function reactiveLayout(opts) {
13318
13857
  }
13319
13858
  }
13320
13859
  );
13321
- const lineBreaksNode = (0, import_core57.node)(
13860
+ const lineBreaksNode = (0, import_core64.node)(
13322
13861
  [segmentsNode, maxWidthNode, fontNode],
13323
13862
  (batchData, actions, ctx) => {
13324
13863
  const data = batchData.map(
@@ -13352,7 +13891,7 @@ function reactiveLayout(opts) {
13352
13891
  }
13353
13892
  }
13354
13893
  );
13355
- const heightNode = (0, import_core57.node)(
13894
+ const heightNode = (0, import_core64.node)(
13356
13895
  [lineBreaksNode, lineHeightNode],
13357
13896
  (batchData, actions, ctx) => {
13358
13897
  const data = batchData.map(
@@ -13362,7 +13901,7 @@ function reactiveLayout(opts) {
13362
13901
  },
13363
13902
  { describeKind: "derived", name: "height" }
13364
13903
  );
13365
- const charPositionsNode = (0, import_core57.node)(
13904
+ const charPositionsNode = (0, import_core64.node)(
13366
13905
  [lineBreaksNode, segmentsNode, lineHeightNode],
13367
13906
  (batchData, actions, ctx) => {
13368
13907
  const data = batchData.map(
@@ -13414,32 +13953,32 @@ function reactiveLayout(opts) {
13414
13953
  }
13415
13954
 
13416
13955
  // src/utils/demo-shell/index.ts
13417
- function clamp01(v) {
13956
+ function clamp012(v) {
13418
13957
  return Math.max(0, Math.min(1, v));
13419
13958
  }
13420
13959
  function demoShell(opts) {
13421
- const mainRatioInit = clamp01(opts?.mainRatio ?? 0.65);
13422
- const sideSplitInit = clamp01(opts?.sideSplit ?? 0.5);
13960
+ const mainRatioInit = clamp012(opts?.mainRatio ?? 0.65);
13961
+ const sideSplitInit = clamp012(opts?.sideSplit ?? 0.5);
13423
13962
  const viewportInit = Math.max(0, opts?.viewportWidth ?? 1280);
13424
13963
  const registry = opts?.nodeRegistry ?? /* @__PURE__ */ new Map();
13425
13964
  const adapter = opts?.adapter ?? null;
13426
13965
  const layoutFont = opts?.layoutFont ?? "14px monospace";
13427
13966
  const onHighlight = opts?.onHighlight;
13428
13967
  const g = new import_graph13.Graph("demo-shell");
13429
- const paneMainRatio = (0, import_core58.node)([], { ...{ name: "pane/main-ratio" }, initial: mainRatioInit });
13430
- const paneSideSplit = (0, import_core58.node)([], { ...{ name: "pane/side-split" }, initial: sideSplitInit });
13431
- const paneFullscreen = (0, import_core58.node)([], {
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)([], {
13432
13971
  ...{
13433
13972
  name: "pane/fullscreen"
13434
13973
  },
13435
13974
  initial: null
13436
13975
  });
13437
- const viewportWidth = (0, import_core58.node)([], { ...{ name: "viewport/width" }, initial: viewportInit });
13976
+ const viewportWidth = (0, import_core65.node)([], { ...{ name: "viewport/width" }, initial: viewportInit });
13438
13977
  g.add(paneMainRatio, { name: "pane/main-ratio" });
13439
13978
  g.add(paneSideSplit, { name: "pane/side-split" });
13440
13979
  g.add(paneFullscreen, { name: "pane/fullscreen" });
13441
13980
  g.add(viewportWidth, { name: "viewport/width" });
13442
- const paneMainWidth = (0, import_core58.node)(
13981
+ const paneMainWidth = (0, import_core65.node)(
13443
13982
  [paneMainRatio, viewportWidth, paneFullscreen],
13444
13983
  (batchData, actions, ctx) => {
13445
13984
  const data = batchData.map(
@@ -13454,7 +13993,7 @@ function demoShell(opts) {
13454
13993
  },
13455
13994
  { describeKind: "derived", ...{ name: "pane/main-width" } }
13456
13995
  );
13457
- const paneSideWidth = (0, import_core58.node)(
13996
+ const paneSideWidth = (0, import_core65.node)(
13458
13997
  [paneMainWidth, viewportWidth, paneFullscreen],
13459
13998
  (batchData, actions, ctx) => {
13460
13999
  const data = batchData.map(
@@ -13469,7 +14008,7 @@ function demoShell(opts) {
13469
14008
  },
13470
14009
  { describeKind: "derived", ...{ name: "pane/side-width" } }
13471
14010
  );
13472
- const paneGraphHeight = (0, import_core58.node)(
14011
+ const paneGraphHeight = (0, import_core65.node)(
13473
14012
  [paneSideSplit, paneFullscreen],
13474
14013
  (batchData, actions, ctx) => {
13475
14014
  const data = batchData.map(
@@ -13480,11 +14019,11 @@ function demoShell(opts) {
13480
14019
  if (fullscreen === "graph") actions.emit(1);
13481
14020
  else if (fullscreen === "code") actions.emit(0);
13482
14021
  else if (fullscreen === "main") actions.emit(0);
13483
- else actions.emit(clamp01(split));
14022
+ else actions.emit(clamp012(split));
13484
14023
  },
13485
14024
  { describeKind: "derived", ...{ name: "pane/graph-height-ratio" } }
13486
14025
  );
13487
- const paneCodeHeight = (0, import_core58.node)(
14026
+ const paneCodeHeight = (0, import_core65.node)(
13488
14027
  [paneGraphHeight, paneFullscreen],
13489
14028
  (batchData, actions, ctx) => {
13490
14029
  const data = batchData.map(
@@ -13502,16 +14041,16 @@ function demoShell(opts) {
13502
14041
  g.add(paneSideWidth, { name: "pane/side-width" });
13503
14042
  g.add(paneGraphHeight, { name: "pane/graph-height-ratio" });
13504
14043
  g.add(paneCodeHeight, { name: "pane/code-height-ratio" });
13505
- const demoGraphRef = (0, import_core58.node)([], {
14044
+ const demoGraphRef = (0, import_core65.node)([], {
13506
14045
  ...{
13507
14046
  name: "demo/graph-ref"
13508
14047
  },
13509
14048
  initial: null
13510
14049
  });
13511
- const demoGraphTick = (0, import_core58.node)([], { ...{ name: "demo/graph-tick" }, initial: 0 });
14050
+ const demoGraphTick = (0, import_core65.node)([], { ...{ name: "demo/graph-tick" }, initial: 0 });
13512
14051
  g.add(demoGraphRef, { name: "demo/graph-ref" });
13513
14052
  g.add(demoGraphTick, { name: "demo/graph-tick" });
13514
- const graphMermaid = (0, import_core58.node)(
14053
+ const graphMermaid = (0, import_core65.node)(
13515
14054
  [demoGraphRef, demoGraphTick],
13516
14055
  (batchData, actions, ctx) => {
13517
14056
  const data = batchData.map(
@@ -13522,7 +14061,7 @@ function demoShell(opts) {
13522
14061
  },
13523
14062
  { describeKind: "derived", ...{ name: "graph/mermaid" } }
13524
14063
  );
13525
- const graphDescribe = (0, import_core58.node)(
14064
+ const graphDescribe = (0, import_core65.node)(
13526
14065
  [demoGraphRef, demoGraphTick],
13527
14066
  (batchData, actions, ctx) => {
13528
14067
  const data = batchData.map(
@@ -13540,9 +14079,9 @@ function demoShell(opts) {
13540
14079
  );
13541
14080
  g.add(graphMermaid, { name: "graph/mermaid" });
13542
14081
  g.add(graphDescribe, { name: "graph/describe" });
13543
- const hoverTarget = (0, import_core58.node)([], { ...{ name: "hover/target" }, initial: null });
14082
+ const hoverTarget = (0, import_core65.node)([], { ...{ name: "hover/target" }, initial: null });
13544
14083
  g.add(hoverTarget, { name: "hover/target" });
13545
- const highlightCodeScroll = (0, import_core58.node)(
14084
+ const highlightCodeScroll = (0, import_core65.node)(
13546
14085
  [hoverTarget],
13547
14086
  (batchData, actions, ctx) => {
13548
14087
  const data = batchData.map(
@@ -13558,7 +14097,7 @@ function demoShell(opts) {
13558
14097
  },
13559
14098
  { describeKind: "derived", ...{ name: "highlight/code-scroll" } }
13560
14099
  );
13561
- const highlightVisual = (0, import_core58.node)(
14100
+ const highlightVisual = (0, import_core65.node)(
13562
14101
  [hoverTarget],
13563
14102
  (batchData, actions, ctx) => {
13564
14103
  const data = batchData.map(
@@ -13574,7 +14113,7 @@ function demoShell(opts) {
13574
14113
  },
13575
14114
  { describeKind: "derived", ...{ name: "highlight/visual" } }
13576
14115
  );
13577
- const highlightGraph = (0, import_core58.node)(
14116
+ const highlightGraph = (0, import_core65.node)(
13578
14117
  [hoverTarget],
13579
14118
  (batchData, actions, ctx) => {
13580
14119
  const data = batchData.map(
@@ -13590,7 +14129,7 @@ function demoShell(opts) {
13590
14129
  g.add(highlightGraph, { name: "highlight/graph" });
13591
14130
  if (onHighlight?.codeScroll) {
13592
14131
  const cb = onHighlight.codeScroll;
13593
- const applyCodeScroll = (0, import_core58.node)(
14132
+ const applyCodeScroll = (0, import_core65.node)(
13594
14133
  [highlightCodeScroll],
13595
14134
  (batchData, _actions, ctx) => {
13596
14135
  const data = batchData.map(
@@ -13604,7 +14143,7 @@ function demoShell(opts) {
13604
14143
  }
13605
14144
  if (onHighlight?.visual) {
13606
14145
  const cb = onHighlight.visual;
13607
- const applyVisual = (0, import_core58.node)(
14146
+ const applyVisual = (0, import_core65.node)(
13608
14147
  [highlightVisual],
13609
14148
  (batchData, _actions, ctx) => {
13610
14149
  const data = batchData.map(
@@ -13618,7 +14157,7 @@ function demoShell(opts) {
13618
14157
  }
13619
14158
  if (onHighlight?.graph) {
13620
14159
  const cb = onHighlight.graph;
13621
- const applyGraph = (0, import_core58.node)(
14160
+ const applyGraph = (0, import_core65.node)(
13622
14161
  [highlightGraph],
13623
14162
  (batchData, _actions, ctx) => {
13624
14163
  const data = batchData.map(
@@ -13630,14 +14169,14 @@ function demoShell(opts) {
13630
14169
  );
13631
14170
  g.add(applyGraph, { name: "highlight/apply-graph" });
13632
14171
  }
13633
- const inspectSelected = (0, import_core58.node)([], {
14172
+ const inspectSelected = (0, import_core65.node)([], {
13634
14173
  ...{
13635
14174
  name: "inspect/selected-node"
13636
14175
  },
13637
14176
  initial: null
13638
14177
  });
13639
14178
  g.add(inspectSelected, { name: "inspect/selected-node" });
13640
- const inspectNodeDetail = (0, import_core58.node)(
14179
+ const inspectNodeDetail = (0, import_core65.node)(
13641
14180
  [inspectSelected, demoGraphRef, demoGraphTick],
13642
14181
  (batchData, actions, ctx) => {
13643
14182
  const data = batchData.map(
@@ -13663,7 +14202,7 @@ function demoShell(opts) {
13663
14202
  },
13664
14203
  { describeKind: "derived", ...{ name: "inspect/node-detail" } }
13665
14204
  );
13666
- const inspectTraceLog = (0, import_core58.node)(
14205
+ const inspectTraceLog = (0, import_core65.node)(
13667
14206
  [demoGraphRef, demoGraphTick],
13668
14207
  (batchData, actions, ctx) => {
13669
14208
  const data = batchData.map(
@@ -13676,9 +14215,9 @@ function demoShell(opts) {
13676
14215
  );
13677
14216
  g.add(inspectNodeDetail, { name: "inspect/node-detail" });
13678
14217
  g.add(inspectTraceLog, { name: "inspect/trace-log" });
13679
- const metaDebug = (0, import_core58.node)([], { ...{ name: "meta/debug" }, initial: false });
14218
+ const metaDebug = (0, import_core65.node)([], { ...{ name: "meta/debug" }, initial: false });
13680
14219
  g.add(metaDebug, { name: "meta/debug" });
13681
- const metaShellMermaid = (0, import_core58.node)(
14220
+ const metaShellMermaid = (0, import_core65.node)(
13682
14221
  [metaDebug, demoGraphTick],
13683
14222
  (batchData, actions, ctx) => {
13684
14223
  const data = batchData.map(
@@ -13689,11 +14228,11 @@ function demoShell(opts) {
13689
14228
  { describeKind: "derived", ...{ name: "meta/shell-mermaid" } }
13690
14229
  );
13691
14230
  g.add(metaShellMermaid, { name: "meta/shell-mermaid" });
13692
- const codeTextNode = (0, import_core58.node)([], { ...{ name: "layout/code-text" }, initial: "" });
14231
+ const codeTextNode = (0, import_core65.node)([], { ...{ name: "layout/code-text" }, initial: "" });
13693
14232
  g.add(codeTextNode, { name: "layout/code-text" });
13694
14233
  if (adapter) {
13695
14234
  const measureCache = /* @__PURE__ */ new Map();
13696
- const graphLabels = (0, import_core58.node)(
14235
+ const graphLabels = (0, import_core65.node)(
13697
14236
  [graphDescribe],
13698
14237
  (batchData, actions, ctx) => {
13699
14238
  const data = batchData.map(
@@ -13732,7 +14271,7 @@ function demoShell(opts) {
13732
14271
  }
13733
14272
  }
13734
14273
  );
13735
- const codeLines = (0, import_core58.node)(
14274
+ const codeLines = (0, import_core65.node)(
13736
14275
  [codeTextNode, paneSideWidth],
13737
14276
  (batchData, actions, ctx) => {
13738
14277
  const data = batchData.map(
@@ -13751,7 +14290,7 @@ function demoShell(opts) {
13751
14290
  },
13752
14291
  { describeKind: "derived", name: "layout/code-lines" }
13753
14292
  );
13754
- const sideWidthHint = (0, import_core58.node)(
14293
+ const sideWidthHint = (0, import_core65.node)(
13755
14294
  [graphLabels],
13756
14295
  (batchData, actions, ctx) => {
13757
14296
  const data = batchData.map(
@@ -13778,10 +14317,10 @@ function demoShell(opts) {
13778
14317
  return {
13779
14318
  graph: g,
13780
14319
  setMainRatio(ratio) {
13781
- g.set("pane/main-ratio", clamp01(ratio));
14320
+ g.set("pane/main-ratio", clamp012(ratio));
13782
14321
  },
13783
14322
  setSideSplit(ratio) {
13784
- g.set("pane/side-split", clamp01(ratio));
14323
+ g.set("pane/side-split", clamp012(ratio));
13785
14324
  },
13786
14325
  setFullscreen(pane) {
13787
14326
  g.set("pane/fullscreen", pane);
@@ -13808,7 +14347,7 @@ function demoShell(opts) {
13808
14347
  g.set("layout/code-text", text);
13809
14348
  },
13810
14349
  batch(fn) {
13811
- (0, import_core58.batch)(fn);
14350
+ (0, import_core65.batch)(fn);
13812
14351
  },
13813
14352
  destroy() {
13814
14353
  g.destroy();
@@ -13817,10 +14356,10 @@ function demoShell(opts) {
13817
14356
  }
13818
14357
 
13819
14358
  // src/utils/domain-templates/index.ts
13820
- var import_core59 = require("@graphrefly/pure-ts/core");
13821
- var import_extra42 = require("@graphrefly/pure-ts/extra");
14359
+ var import_core66 = require("@graphrefly/pure-ts/core");
14360
+ var import_extra47 = require("@graphrefly/pure-ts/extra");
13822
14361
  var import_graph14 = require("@graphrefly/pure-ts/graph");
13823
- var import_extra43 = require("@graphrefly/pure-ts/extra");
14362
+ var import_extra48 = require("@graphrefly/pure-ts/extra");
13824
14363
  function baseMeta2(kind, extra) {
13825
14364
  return domainMeta("domain_template", kind, extra);
13826
14365
  }
@@ -13837,12 +14376,12 @@ function observabilityGraph(name, opts) {
13837
14376
  name: b.name,
13838
14377
  classify: b.classify
13839
14378
  }));
13840
- const strat = (0, import_extra42.stratify)("stratify", opts.source, rules);
14379
+ const strat = (0, import_extra47.stratify)("stratify", opts.source, rules);
13841
14380
  g.mount("stratify", strat);
13842
14381
  const branchNodes = branches.map((b) => {
13843
14382
  try {
13844
14383
  const raw = g.resolve(`stratify::branch/${b.name}`);
13845
- return (0, import_core59.node)(
14384
+ return (0, import_core66.node)(
13846
14385
  [raw],
13847
14386
  (batchData, actions, ctx) => {
13848
14387
  const data = batchData.map(
@@ -13853,11 +14392,11 @@ function observabilityGraph(name, opts) {
13853
14392
  { initial: null, describeKind: "derived" }
13854
14393
  );
13855
14394
  } catch {
13856
- return (0, import_core59.node)([], { initial: null });
14395
+ return (0, import_core66.node)([], { initial: null });
13857
14396
  }
13858
14397
  });
13859
14398
  const correlateFn = opts.correlate ?? ((vals) => vals);
13860
- const correlateNode = (0, import_core59.node)(
14399
+ const correlateNode = (0, import_core66.node)(
13861
14400
  branchNodes,
13862
14401
  (batchData, actions, ctx) => {
13863
14402
  const vals = batchData.map(
@@ -13872,7 +14411,7 @@ function observabilityGraph(name, opts) {
13872
14411
  );
13873
14412
  g.add(correlateNode, { name: "correlate" });
13874
14413
  const sloCheckFn = opts.sloCheck ?? (() => ({ pass: true }));
13875
- const sloValue = (0, import_core59.node)(
14414
+ const sloValue = (0, import_core66.node)(
13876
14415
  [correlateNode],
13877
14416
  (batchData, actions, ctx) => {
13878
14417
  const data = batchData.map(
@@ -13885,7 +14424,7 @@ function observabilityGraph(name, opts) {
13885
14424
  meta: baseMeta2("observability", { stage: "slo_value" })
13886
14425
  }
13887
14426
  );
13888
- const sloVerified = (0, import_core59.node)(
14427
+ const sloVerified = (0, import_core66.node)(
13889
14428
  [sloValue],
13890
14429
  (batchData, actions, ctx) => {
13891
14430
  const data = batchData.map(
@@ -13902,7 +14441,7 @@ function observabilityGraph(name, opts) {
13902
14441
  g.add(sloVerified, { name: "slo_verified" });
13903
14442
  const weightValues = opts.weights ?? branches.map(() => 1);
13904
14443
  const signalNodes = branchNodes.map(
13905
- (bn) => (0, import_core59.node)(
14444
+ (bn) => (0, import_core66.node)(
13906
14445
  [bn],
13907
14446
  (batchData, actions, ctx) => {
13908
14447
  const data = batchData.map(
@@ -13913,7 +14452,7 @@ function observabilityGraph(name, opts) {
13913
14452
  { describeKind: "derived" }
13914
14453
  )
13915
14454
  );
13916
- const weightNodes = weightValues.map((w) => (0, import_core59.node)([], { initial: w }));
14455
+ const weightNodes = weightValues.map((w) => (0, import_core66.node)([], { initial: w }));
13917
14456
  for (let i = 0; i < signalNodes.length; i++) {
13918
14457
  g.add(signalNodes[i], { name: `__signal_${i}` });
13919
14458
  g.add(weightNodes[i], { name: `__weight_${i}` });
@@ -13923,7 +14462,7 @@ function observabilityGraph(name, opts) {
13923
14462
  weightNodes
13924
14463
  );
13925
14464
  g.add(alerts, { name: "alerts" });
13926
- const output = (0, import_core59.node)(
14465
+ const output = (0, import_core66.node)(
13927
14466
  [alerts, sloVerified],
13928
14467
  (batchData, actions, ctx) => {
13929
14468
  const vals = batchData.map(
@@ -13940,12 +14479,12 @@ function observabilityGraph(name, opts) {
13940
14479
  }
13941
14480
  );
13942
14481
  g.add(output, { name: "output" });
13943
- const fbReentry = (0, import_core59.node)([], {
14482
+ const fbReentry = (0, import_core66.node)([], {
13944
14483
  initial: null,
13945
14484
  meta: baseMeta2("observability", { stage: "feedback_reentry" })
13946
14485
  });
13947
14486
  g.add(fbReentry, { name: "feedback_reentry" });
13948
- const fbCondition = (0, import_core59.node)(
14487
+ const fbCondition = (0, import_core66.node)(
13949
14488
  [sloVerified],
13950
14489
  (batchData, actions, ctx) => {
13951
14490
  const data = batchData.map(
@@ -13977,7 +14516,7 @@ function issueTrackerGraph(name, opts) {
13977
14516
  raw
13978
14517
  });
13979
14518
  const extractFn = opts.extract ?? defaultExtract;
13980
- const extractNode = (0, import_core59.node)(
14519
+ const extractNode = (0, import_core66.node)(
13981
14520
  [opts.source],
13982
14521
  (batchData, actions, ctx) => {
13983
14522
  const data = batchData.map(
@@ -13992,7 +14531,7 @@ function issueTrackerGraph(name, opts) {
13992
14531
  );
13993
14532
  g.add(extractNode, { name: "extract" });
13994
14533
  const verifyFn = opts.verify ?? (() => ({ valid: true }));
13995
- const verifyNode = (0, import_core59.node)(
14534
+ const verifyNode = (0, import_core66.node)(
13996
14535
  [extractNode],
13997
14536
  (batchData, actions, ctx) => {
13998
14537
  const data = batchData.map(
@@ -14007,13 +14546,13 @@ function issueTrackerGraph(name, opts) {
14007
14546
  }
14008
14547
  );
14009
14548
  g.add(verifyNode, { name: "verify" });
14010
- const knownPatterns = (0, import_core59.node)([], {
14549
+ const knownPatterns = (0, import_core66.node)([], {
14011
14550
  initial: [],
14012
14551
  meta: baseMeta2("issue_tracker", { stage: "known_patterns" })
14013
14552
  });
14014
14553
  g.add(knownPatterns, { name: "known_patterns" });
14015
14554
  const detectFn = opts.detectRegression ?? (() => ({ regression: false }));
14016
- const regressionNode = (0, import_core59.node)(
14555
+ const regressionNode = (0, import_core66.node)(
14017
14556
  [extractNode, knownPatterns],
14018
14557
  (batchData, actions, ctx) => {
14019
14558
  const data = batchData.map(
@@ -14026,7 +14565,7 @@ function issueTrackerGraph(name, opts) {
14026
14565
  { describeKind: "derived", meta: baseMeta2("issue_tracker", { stage: "regression" }) }
14027
14566
  );
14028
14567
  g.add(regressionNode, { name: "regression" });
14029
- const severitySignal = (0, import_core59.node)(
14568
+ const severitySignal = (0, import_core66.node)(
14030
14569
  [extractNode],
14031
14570
  (batchData, actions, ctx) => {
14032
14571
  const data = batchData.map(
@@ -14037,7 +14576,7 @@ function issueTrackerGraph(name, opts) {
14037
14576
  },
14038
14577
  { describeKind: "derived" }
14039
14578
  );
14040
- const regressionSignal = (0, import_core59.node)(
14579
+ const regressionSignal = (0, import_core66.node)(
14041
14580
  [regressionNode],
14042
14581
  (batchData, actions, ctx) => {
14043
14582
  const data = batchData.map(
@@ -14050,13 +14589,13 @@ function issueTrackerGraph(name, opts) {
14050
14589
  );
14051
14590
  g.add(severitySignal, { name: "__severity_signal" });
14052
14591
  g.add(regressionSignal, { name: "__regression_signal" });
14053
- const severityWeight = (0, import_core59.node)([], { initial: 1 });
14054
- const regressionWeight = (0, import_core59.node)([], { initial: 1.5 });
14592
+ const severityWeight = (0, import_core66.node)([], { initial: 1 });
14593
+ const regressionWeight = (0, import_core66.node)([], { initial: 1.5 });
14055
14594
  g.add(severityWeight, { name: "__severity_weight" });
14056
14595
  g.add(regressionWeight, { name: "__regression_weight" });
14057
14596
  const priority = scorer([severitySignal, regressionSignal], [severityWeight, regressionWeight]);
14058
14597
  g.add(priority, { name: "priority" });
14059
- const output = (0, import_core59.node)(
14598
+ const output = (0, import_core66.node)(
14060
14599
  [verifyNode, regressionNode, priority],
14061
14600
  (batchData, actions, ctx) => {
14062
14601
  const vals = batchData.map(
@@ -14071,12 +14610,12 @@ function issueTrackerGraph(name, opts) {
14071
14610
  { describeKind: "derived", meta: baseMeta2("issue_tracker", { stage: "output" }) }
14072
14611
  );
14073
14612
  g.add(output, { name: "output" });
14074
- const fbReentry = (0, import_core59.node)([], {
14613
+ const fbReentry = (0, import_core66.node)([], {
14075
14614
  initial: null,
14076
14615
  meta: baseMeta2("issue_tracker", { stage: "feedback_reentry" })
14077
14616
  });
14078
14617
  g.add(fbReentry, { name: "feedback_reentry" });
14079
- const fbCondition = (0, import_core59.node)(
14618
+ const fbCondition = (0, import_core66.node)(
14080
14619
  [verifyNode],
14081
14620
  (batchData, actions, ctx) => {
14082
14621
  const data = batchData.map(
@@ -14112,7 +14651,7 @@ function contentModerationGraph(name, opts) {
14112
14651
  original: content
14113
14652
  });
14114
14653
  const classifyFn = opts.classify ?? defaultClassify;
14115
- const classifyNode = (0, import_core59.node)(
14654
+ const classifyNode = (0, import_core66.node)(
14116
14655
  [opts.source],
14117
14656
  (batchData, actions, ctx) => {
14118
14657
  const data = batchData.map(
@@ -14126,13 +14665,13 @@ function contentModerationGraph(name, opts) {
14126
14665
  }
14127
14666
  );
14128
14667
  g.add(classifyNode, { name: "classify" });
14129
- const strat = (0, import_extra42.stratify)("stratify", classifyNode, [
14668
+ const strat = (0, import_extra47.stratify)("stratify", classifyNode, [
14130
14669
  { name: "safe", classify: (v) => v.label === "safe" },
14131
14670
  { name: "review", classify: (v) => v.label === "review" },
14132
14671
  { name: "block", classify: (v) => v.label === "block" }
14133
14672
  ]);
14134
14673
  g.mount("stratify", strat);
14135
- const reviewLog = (0, import_extra42.reactiveLog)([], {
14674
+ const reviewLog = (0, import_extra47.reactiveLog)([], {
14136
14675
  name: "review_queue",
14137
14676
  maxSize: opts.maxQueueSize
14138
14677
  });
@@ -14141,10 +14680,10 @@ function contentModerationGraph(name, opts) {
14141
14680
  try {
14142
14681
  reviewBranch = g.resolve("stratify::branch/review");
14143
14682
  } catch {
14144
- reviewBranch = (0, import_core59.node)([], { initial: null });
14683
+ reviewBranch = (0, import_core66.node)([], { initial: null });
14145
14684
  g.add(reviewBranch, { name: "__review_fallback" });
14146
14685
  }
14147
- const reviewAccumulator = (0, import_core59.node)(
14686
+ const reviewAccumulator = (0, import_core66.node)(
14148
14687
  [reviewBranch],
14149
14688
  (batchData, _actions, ctx) => {
14150
14689
  const data = batchData.map(
@@ -14158,11 +14697,11 @@ function contentModerationGraph(name, opts) {
14158
14697
  { describeKind: "effect" }
14159
14698
  );
14160
14699
  g.add(reviewAccumulator, { name: "__review_accumulator" });
14161
- g.addDisposer((0, import_extra43.keepalive)(reviewAccumulator));
14700
+ g.addDisposer((0, import_extra48.keepalive)(reviewAccumulator));
14162
14701
  try {
14163
14702
  } catch {
14164
14703
  }
14165
- const policy3 = (0, import_core59.node)([], {
14704
+ const policy3 = (0, import_core66.node)([], {
14166
14705
  initial: {},
14167
14706
  meta: baseMeta2("content_moderation", {
14168
14707
  stage: "policy",
@@ -14172,7 +14711,7 @@ function contentModerationGraph(name, opts) {
14172
14711
  });
14173
14712
  g.add(policy3, { name: "policy" });
14174
14713
  const weights = opts.weights ?? [0.1, 1, 2];
14175
- const confidenceSignal = (0, import_core59.node)(
14714
+ const confidenceSignal = (0, import_core66.node)(
14176
14715
  [classifyNode],
14177
14716
  (batchData, actions, ctx) => {
14178
14717
  const data = batchData.map(
@@ -14183,7 +14722,7 @@ function contentModerationGraph(name, opts) {
14183
14722
  },
14184
14723
  { describeKind: "derived" }
14185
14724
  );
14186
- const severitySignal = (0, import_core59.node)(
14725
+ const severitySignal = (0, import_core66.node)(
14187
14726
  [classifyNode],
14188
14727
  (batchData, actions, ctx) => {
14189
14728
  const data = batchData.map(
@@ -14202,13 +14741,13 @@ function contentModerationGraph(name, opts) {
14202
14741
  );
14203
14742
  g.add(confidenceSignal, { name: "__confidence_signal" });
14204
14743
  g.add(severitySignal, { name: "__severity_signal" });
14205
- const wConfidence = (0, import_core59.node)([], { initial: 1 });
14206
- const wSeverity = (0, import_core59.node)([], { initial: 1 });
14744
+ const wConfidence = (0, import_core66.node)([], { initial: 1 });
14745
+ const wSeverity = (0, import_core66.node)([], { initial: 1 });
14207
14746
  g.add(wConfidence, { name: "__w_confidence" });
14208
14747
  g.add(wSeverity, { name: "__w_severity" });
14209
14748
  const priority = scorer([confidenceSignal, severitySignal], [wConfidence, wSeverity]);
14210
14749
  g.add(priority, { name: "priority" });
14211
- const output = (0, import_core59.node)(
14750
+ const output = (0, import_core66.node)(
14212
14751
  [classifyNode, priority],
14213
14752
  (batchData, actions, ctx) => {
14214
14753
  const vals = batchData.map(
@@ -14222,7 +14761,7 @@ function contentModerationGraph(name, opts) {
14222
14761
  { describeKind: "derived", meta: baseMeta2("content_moderation", { stage: "output" }) }
14223
14762
  );
14224
14763
  g.add(output, { name: "output" });
14225
- const fbCondition = (0, import_core59.node)(
14764
+ const fbCondition = (0, import_core66.node)(
14226
14765
  [reviewLog.entries, policy3],
14227
14766
  (batchData, actions, ctx) => {
14228
14767
  const vals = batchData.map(
@@ -14257,7 +14796,7 @@ function dataQualityGraph(name, opts) {
14257
14796
  errors: [],
14258
14797
  record
14259
14798
  }));
14260
- const validateNode = (0, import_core59.node)(
14799
+ const validateNode = (0, import_core66.node)(
14261
14800
  [opts.source],
14262
14801
  (batchData, actions, ctx) => {
14263
14802
  const data = batchData.map(
@@ -14273,7 +14812,7 @@ function dataQualityGraph(name, opts) {
14273
14812
  score: 0,
14274
14813
  record
14275
14814
  }));
14276
- const anomalyNode = (0, import_core59.node)(
14815
+ const anomalyNode = (0, import_core66.node)(
14277
14816
  [opts.source],
14278
14817
  (batchData, actions, ctx) => {
14279
14818
  const data = batchData.map(
@@ -14284,7 +14823,7 @@ function dataQualityGraph(name, opts) {
14284
14823
  { describeKind: "derived", meta: baseMeta2("data_quality", { stage: "anomaly" }) }
14285
14824
  );
14286
14825
  g.add(anomalyNode, { name: "anomaly" });
14287
- const baseline = (0, import_core59.node)([], {
14826
+ const baseline = (0, import_core66.node)([], {
14288
14827
  initial: null,
14289
14828
  meta: baseMeta2("data_quality", {
14290
14829
  stage: "baseline",
@@ -14292,7 +14831,7 @@ function dataQualityGraph(name, opts) {
14292
14831
  })
14293
14832
  });
14294
14833
  g.add(baseline, { name: "baseline" });
14295
- const baselineUpdater = (0, import_core59.node)(
14834
+ const baselineUpdater = (0, import_core66.node)(
14296
14835
  [validateNode],
14297
14836
  (batchData, _actions, ctx) => {
14298
14837
  const data = batchData.map(
@@ -14300,7 +14839,7 @@ function dataQualityGraph(name, opts) {
14300
14839
  );
14301
14840
  const result = data[0];
14302
14841
  if (result?.valid) {
14303
- (0, import_core59.batch)(() => {
14842
+ (0, import_core66.batch)(() => {
14304
14843
  baseline.emit(result.record);
14305
14844
  });
14306
14845
  }
@@ -14308,9 +14847,9 @@ function dataQualityGraph(name, opts) {
14308
14847
  { describeKind: "effect" }
14309
14848
  );
14310
14849
  g.add(baselineUpdater, { name: "__baseline_updater" });
14311
- (0, import_extra43.keepalive)(baselineUpdater);
14850
+ (0, import_extra48.keepalive)(baselineUpdater);
14312
14851
  const detectDriftFn = opts.detectDrift ?? (() => ({ drift: false }));
14313
- const driftNode = (0, import_core59.node)(
14852
+ const driftNode = (0, import_core66.node)(
14314
14853
  [opts.source, baseline],
14315
14854
  (batchData, actions, ctx) => {
14316
14855
  const data = batchData.map(
@@ -14322,7 +14861,7 @@ function dataQualityGraph(name, opts) {
14322
14861
  );
14323
14862
  g.add(driftNode, { name: "drift" });
14324
14863
  const suggestFn = opts.suggest ?? (() => null);
14325
- const remediateNode = (0, import_core59.node)(
14864
+ const remediateNode = (0, import_core66.node)(
14326
14865
  [validateNode, anomalyNode],
14327
14866
  (batchData, actions, ctx) => {
14328
14867
  const data = batchData.map(
@@ -14338,7 +14877,7 @@ function dataQualityGraph(name, opts) {
14338
14877
  { describeKind: "derived", meta: baseMeta2("data_quality", { stage: "remediate" }) }
14339
14878
  );
14340
14879
  g.add(remediateNode, { name: "remediate" });
14341
- const output = (0, import_core59.node)(
14880
+ const output = (0, import_core66.node)(
14342
14881
  [validateNode, anomalyNode, driftNode, remediateNode],
14343
14882
  (batchData, actions, ctx) => {
14344
14883
  const vals = batchData.map(
@@ -14354,12 +14893,12 @@ function dataQualityGraph(name, opts) {
14354
14893
  { describeKind: "derived", meta: baseMeta2("data_quality", { stage: "output" }) }
14355
14894
  );
14356
14895
  g.add(output, { name: "output" });
14357
- const validationRules = (0, import_core59.node)([], {
14896
+ const validationRules = (0, import_core66.node)([], {
14358
14897
  initial: [],
14359
14898
  meta: baseMeta2("data_quality", { stage: "validation_rules" })
14360
14899
  });
14361
14900
  g.add(validationRules, { name: "validation_rules" });
14362
- const fbCondition = (0, import_core59.node)(
14901
+ const fbCondition = (0, import_core66.node)(
14363
14902
  [anomalyNode],
14364
14903
  (batchData, actions, ctx) => {
14365
14904
  const data = batchData.map(
@@ -14386,8 +14925,8 @@ function isTagged(value, tag) {
14386
14925
  }
14387
14926
 
14388
14927
  // src/utils/harness/actuator-executor.ts
14389
- var import_core60 = require("@graphrefly/pure-ts/core");
14390
- var import_extra44 = require("@graphrefly/pure-ts/extra");
14928
+ var import_core67 = require("@graphrefly/pure-ts/core");
14929
+ var import_extra49 = require("@graphrefly/pure-ts/extra");
14391
14930
  function defaultToOutput(record, item) {
14392
14931
  return {
14393
14932
  outcome: "success",
@@ -14421,7 +14960,7 @@ function actuatorExecutor(config) {
14421
14960
  execution: { item, outcome: "failure", detail: skipDetail(item) }
14422
14961
  };
14423
14962
  }
14424
- return (0, import_core60.node)(
14963
+ return (0, import_core67.node)(
14425
14964
  [],
14426
14965
  (_data, actions) => {
14427
14966
  const ac = new AbortController();
@@ -14442,8 +14981,8 @@ function actuatorExecutor(config) {
14442
14981
  if (captured) return;
14443
14982
  captured = true;
14444
14983
  actions.down([
14445
- [import_core60.DATA, { ...job.payload, execution: { item, ...out } }],
14446
- [import_core60.COMPLETE]
14984
+ [import_core67.DATA, { ...job.payload, execution: { item, ...out } }],
14985
+ [import_core67.COMPLETE]
14447
14986
  ]);
14448
14987
  unsub?.();
14449
14988
  unsub = null;
@@ -14451,7 +14990,7 @@ function actuatorExecutor(config) {
14451
14990
  let inner;
14452
14991
  try {
14453
14992
  const rawResult = config.apply(item, { signal: ac.signal });
14454
- inner = (0, import_extra44.fromAny)(rawResult, { signal: ac.signal });
14993
+ inner = (0, import_extra49.fromAny)(rawResult, { signal: ac.signal });
14455
14994
  } catch (err) {
14456
14995
  emitOnce(onError(err, item));
14457
14996
  return () => {
@@ -14462,15 +15001,15 @@ function actuatorExecutor(config) {
14462
15001
  unsub = inner.subscribe((batch14) => {
14463
15002
  for (const m of batch14) {
14464
15003
  if (captured) return;
14465
- if (m[0] === import_core60.DATA) {
15004
+ if (m[0] === import_core67.DATA) {
14466
15005
  emitOnce(toOutput(m[1], item));
14467
15006
  return;
14468
15007
  }
14469
- if (m[0] === import_core60.ERROR) {
15008
+ if (m[0] === import_core67.ERROR) {
14470
15009
  emitOnce(onError(m[1], item));
14471
15010
  return;
14472
15011
  }
14473
- if (m[0] === import_core60.COMPLETE) {
15012
+ if (m[0] === import_core67.COMPLETE) {
14474
15013
  emitOnce(onError(new Error("actuator inner completed without emitting DATA"), item));
14475
15014
  return;
14476
15015
  }
@@ -14510,12 +15049,12 @@ function dispatchActuator(config) {
14510
15049
  }
14511
15050
 
14512
15051
  // src/utils/harness/auto-solidify.ts
14513
- var import_core61 = require("@graphrefly/pure-ts/core");
15052
+ var import_core68 = require("@graphrefly/pure-ts/core");
14514
15053
  function autoSolidify(config) {
14515
15054
  const name = config.name ?? "auto-solidify";
14516
15055
  const extract = config.extract ?? ((vr) => vr.execution.artifact ?? null);
14517
15056
  const predicate = config.predicate ?? (() => true);
14518
- return (0, import_core61.node)(
15057
+ return (0, import_core68.node)(
14519
15058
  [],
14520
15059
  (_data, actions) => {
14521
15060
  let unsub = null;
@@ -14528,16 +15067,16 @@ function autoSolidify(config) {
14528
15067
  };
14529
15068
  const emitTerminalError = (err) => {
14530
15069
  if (terminated) return;
14531
- actions.down([[import_core61.ERROR, err]]);
15070
+ actions.down([[import_core68.ERROR, err]]);
14532
15071
  tearDown();
14533
15072
  };
14534
15073
  unsub = config.verifyResults.subscribe((batch14) => {
14535
15074
  if (terminated) return;
14536
15075
  for (const m of batch14) {
14537
15076
  if (terminated) return;
14538
- if (m[0] !== import_core61.DATA) {
14539
- if (m[0] === import_core61.COMPLETE) {
14540
- actions.down([[import_core61.COMPLETE]]);
15077
+ if (m[0] !== import_core68.DATA) {
15078
+ if (m[0] === import_core68.COMPLETE) {
15079
+ actions.down([[import_core68.COMPLETE]]);
14541
15080
  tearDown();
14542
15081
  return;
14543
15082
  }
@@ -14568,7 +15107,7 @@ function autoSolidify(config) {
14568
15107
  emitTerminalError(err);
14569
15108
  return;
14570
15109
  }
14571
- actions.down([[import_core61.DATA, artifact]]);
15110
+ actions.down([[import_core68.DATA, artifact]]);
14572
15111
  }
14573
15112
  });
14574
15113
  if (terminated && unsub) {
@@ -14584,11 +15123,11 @@ function autoSolidify(config) {
14584
15123
  }
14585
15124
 
14586
15125
  // src/utils/harness/bridge.ts
14587
- var import_core62 = require("@graphrefly/pure-ts/core");
14588
- var import_extra45 = require("@graphrefly/pure-ts/extra");
15126
+ var import_core69 = require("@graphrefly/pure-ts/core");
15127
+ var import_extra50 = require("@graphrefly/pure-ts/extra");
14589
15128
  function createIntakeBridge(opts) {
14590
15129
  const { graph, source, intakeTopic, parser, name = "intake-bridge" } = opts;
14591
- const eff = (0, import_core62.node)(
15130
+ const eff = (0, import_core69.node)(
14592
15131
  [source],
14593
15132
  (batchData, _actions, ctx) => {
14594
15133
  const data = batchData.map(
@@ -14614,7 +15153,7 @@ function evalIntakeBridge(opts) {
14614
15153
  name = "eval-intake-bridge",
14615
15154
  defaultSeverity = "medium"
14616
15155
  } = opts;
14617
- const eff = (0, import_core62.node)(
15156
+ const eff = (0, import_core69.node)(
14618
15157
  [source],
14619
15158
  (batchData, _actions, ctx) => {
14620
15159
  const data = batchData.map(
@@ -14659,11 +15198,11 @@ function evalIntakeBridge(opts) {
14659
15198
  return eff;
14660
15199
  }
14661
15200
  function evalSource(trigger, runner) {
14662
- return (0, import_extra45.switchMap)(trigger, () => (0, import_extra45.fromAny)(runner()));
15201
+ return (0, import_extra50.switchMap)(trigger, () => (0, import_extra50.fromAny)(runner()));
14663
15202
  }
14664
15203
  function beforeAfterCompare(opts) {
14665
15204
  const { graph, before, after, name = "eval-delta" } = opts;
14666
- const der = (0, import_core62.node)(
15205
+ const der = (0, import_core69.node)(
14667
15206
  [before, after],
14668
15207
  (batchData, actions, ctx) => {
14669
15208
  const data = batchData.map(
@@ -14706,7 +15245,7 @@ function affectedTaskFilter(opts) {
14706
15245
  let taskSetNode = null;
14707
15246
  if (fullTaskSet != null) {
14708
15247
  if (Array.isArray(fullTaskSet)) {
14709
- const inlineSet = (0, import_core62.node)([], { initial: fullTaskSet });
15248
+ const inlineSet = (0, import_core69.node)([], { initial: fullTaskSet });
14710
15249
  graph.add(inlineSet, { name: `${name}/fullTaskSet` });
14711
15250
  taskSetNode = inlineSet;
14712
15251
  } else {
@@ -14715,7 +15254,7 @@ function affectedTaskFilter(opts) {
14715
15254
  }
14716
15255
  const deps = [issues];
14717
15256
  if (taskSetNode) deps.push(taskSetNode);
14718
- const der = (0, import_core62.node)(
15257
+ const der = (0, import_core69.node)(
14719
15258
  deps,
14720
15259
  (batchData, actions, ctx) => {
14721
15260
  const data = batchData.map(
@@ -14769,7 +15308,7 @@ function codeChangeBridge(opts) {
14769
15308
  return items;
14770
15309
  }
14771
15310
  const resolve = parser ?? defaultParser;
14772
- const eff = (0, import_core62.node)(
15311
+ const eff = (0, import_core69.node)(
14773
15312
  [source],
14774
15313
  (batchData, _actions, ctx) => {
14775
15314
  const data = batchData.map(
@@ -14788,7 +15327,7 @@ function codeChangeBridge(opts) {
14788
15327
  }
14789
15328
  function notifyEffect(opts) {
14790
15329
  const { graph, topic: topic2, transport, name = "notify-effect" } = opts;
14791
- const eff = (0, import_core62.node)(
15330
+ const eff = (0, import_core69.node)(
14792
15331
  [topic2.latest],
14793
15332
  (batchData, _actions, ctx) => {
14794
15333
  const data = batchData.map(
@@ -14881,10 +15420,10 @@ function resolvePromptFn(raw, fallbackTemplate, substitute) {
14881
15420
  }
14882
15421
 
14883
15422
  // src/utils/harness/strategy.ts
14884
- var import_core63 = require("@graphrefly/pure-ts/core");
15423
+ var import_core70 = require("@graphrefly/pure-ts/core");
14885
15424
 
14886
15425
  // src/utils/orchestration/audited-success-tracker.ts
14887
- var import_extra46 = require("@graphrefly/pure-ts/extra");
15426
+ var import_extra51 = require("@graphrefly/pure-ts/extra");
14888
15427
  var import_graph15 = require("@graphrefly/pure-ts/graph");
14889
15428
  var AuditedSuccessTrackerGraph = class extends import_graph15.Graph {
14890
15429
  /** Reactive entries — `Node<ReadonlyMap<TKey, TEntry>>`, fresh map per mutation. */
@@ -14892,10 +15431,10 @@ var AuditedSuccessTrackerGraph = class extends import_graph15.Graph {
14892
15431
  _map;
14893
15432
  constructor(opts) {
14894
15433
  super(opts?.name ?? "audited-success-tracker", opts?.graph);
14895
- this._map = (0, import_extra46.reactiveMap)({ name: "entries" });
15434
+ this._map = (0, import_extra51.reactiveMap)({ name: "entries" });
14896
15435
  this.entries = this._map.entries;
14897
15436
  this.add(this.entries, { name: "entries" });
14898
- this.addDisposer((0, import_extra46.keepalive)(this.entries));
15437
+ this.addDisposer((0, import_extra51.keepalive)(this.entries));
14899
15438
  this.addDisposer(() => this._map.dispose());
14900
15439
  }
14901
15440
  /**
@@ -14958,7 +15497,7 @@ function priorityScore(item, strategy, lastInteractionNs, urgency, signals) {
14958
15497
  const effectivenessBoost = signals?.effectivenessBoost ?? 15;
14959
15498
  const deps = [item, strategy, lastInteractionNs];
14960
15499
  if (urgency) deps.push(urgency);
14961
- return (0, import_core63.node)(
15500
+ return (0, import_core70.node)(
14962
15501
  deps,
14963
15502
  (batchData, actions, ctx) => {
14964
15503
  const values = batchData.map(
@@ -14969,7 +15508,7 @@ function priorityScore(item, strategy, lastInteractionNs, urgency, signals) {
14969
15508
  const lastNs = values[2];
14970
15509
  const urg = urgency ? values[3] : 0;
14971
15510
  const baseWeight = severityWeights[itm.severity ?? "medium"];
14972
- const ageSeconds2 = ((0, import_core63.monotonicNs)() - lastNs) / 1e9;
15511
+ const ageSeconds2 = ((0, import_core70.monotonicNs)() - lastNs) / 1e9;
14973
15512
  let score = decay(baseWeight, ageSeconds2, decayRate, 0);
14974
15513
  const key = strategyKey(DEFAULT_PRESET_ID, itm.rootCause, itm.intervention);
14975
15514
  const entry = strat.get(key);
@@ -14984,8 +15523,8 @@ function priorityScore(item, strategy, lastInteractionNs, urgency, signals) {
14984
15523
  }
14985
15524
 
14986
15525
  // src/utils/inspect/audit.ts
14987
- var import_core64 = require("@graphrefly/pure-ts/core");
14988
- var import_extra47 = require("@graphrefly/pure-ts/extra");
15526
+ var import_core71 = require("@graphrefly/pure-ts/core");
15527
+ var import_extra52 = require("@graphrefly/pure-ts/extra");
14989
15528
  var import_graph16 = require("@graphrefly/pure-ts/graph");
14990
15529
  function auditMeta(kind, extra) {
14991
15530
  return domainMeta("audit", kind, extra);
@@ -15023,7 +15562,7 @@ var AuditTrailGraph = class extends import_graph16.Graph {
15023
15562
  constructor(target, opts) {
15024
15563
  super(opts.name ?? `${target.name}_audit`, opts.graph);
15025
15564
  this._target = target;
15026
- this._log = (0, import_extra47.reactiveLog)([], {
15565
+ this._log = (0, import_extra52.reactiveLog)([], {
15027
15566
  name: "entries",
15028
15567
  ...opts.maxSize != null ? { maxSize: opts.maxSize } : {}
15029
15568
  });
@@ -15040,7 +15579,7 @@ var AuditTrailGraph = class extends import_graph16.Graph {
15040
15579
  },
15041
15580
  { meta: auditMeta("count") }
15042
15581
  );
15043
- this.addDisposer((0, import_extra47.keepalive)(this.count));
15582
+ this.addDisposer((0, import_extra52.keepalive)(this.count));
15044
15583
  const includeTypes = opts.includeTypes != null ? new Set(opts.includeTypes) : new Set(DEFAULT_INCLUDE_TYPES);
15045
15584
  this.includeTypes = includeTypes;
15046
15585
  const filter2 = opts.filter;
@@ -15053,13 +15592,13 @@ var AuditTrailGraph = class extends import_graph16.Graph {
15053
15592
  const path = event.path ?? "";
15054
15593
  const entry = {
15055
15594
  seq: seq++,
15056
- timestamp_ns: event.timestamp_ns ?? (0, import_core64.monotonicNs)(),
15057
- wall_clock_ns: (0, import_core64.wallClockNs)(),
15595
+ timestamp_ns: event.timestamp_ns ?? (0, import_core71.monotonicNs)(),
15596
+ wall_clock_ns: (0, import_core71.wallClockNs)(),
15058
15597
  path,
15059
15598
  type
15060
15599
  };
15061
- const node58 = path ? safeNode(target, path) : void 0;
15062
- const lastMutation = node58?.lastMutation;
15600
+ const node65 = path ? safeNode(target, path) : void 0;
15601
+ const lastMutation = node65?.lastMutation;
15063
15602
  if (lastMutation != null) entry.actor = lastMutation.actor;
15064
15603
  if (type === "data") entry.value = event.data;
15065
15604
  if (type === "error") entry.error = event.data;
@@ -15120,7 +15659,7 @@ var PolicyGateGraph = class extends import_graph16.Graph {
15120
15659
  super(opts.name ?? `${target.name}_policy`, opts.graph);
15121
15660
  this._target = target;
15122
15661
  this._mode = opts.mode ?? "audit";
15123
- const policiesNode = isNode2(policies) ? policies : (0, import_core64.node)([], { name: "policies", initial: policies });
15662
+ const policiesNode = isNode2(policies) ? policies : (0, import_core71.node)([], { name: "policies", initial: policies });
15124
15663
  this.policies = policiesNode;
15125
15664
  this.add(this.policies, { name: "policies" });
15126
15665
  this.violations = new TopicGraph("violations", {
@@ -15140,15 +15679,15 @@ var PolicyGateGraph = class extends import_graph16.Graph {
15140
15679
  meta: auditMeta("policy_violation_count")
15141
15680
  }
15142
15681
  );
15143
- this.addDisposer((0, import_extra47.keepalive)(this.violationCount));
15682
+ this.addDisposer((0, import_extra52.keepalive)(this.violationCount));
15144
15683
  const initialRules = policiesNode.cache ?? [];
15145
15684
  let latestRules = initialRules;
15146
- this._currentGuard = (0, import_core64.policyFromRules)(latestRules);
15685
+ this._currentGuard = (0, import_core71.policyFromRules)(latestRules);
15147
15686
  const offPolicies = policiesNode.subscribe((msgs) => {
15148
15687
  for (const m of msgs) {
15149
- if (m[0] === import_core64.DATA) {
15688
+ if (m[0] === import_core71.DATA) {
15150
15689
  latestRules = m[1] ?? [];
15151
- this._currentGuard = (0, import_core64.policyFromRules)(latestRules);
15690
+ this._currentGuard = (0, import_core71.policyFromRules)(latestRules);
15152
15691
  }
15153
15692
  }
15154
15693
  });
@@ -15162,7 +15701,7 @@ var PolicyGateGraph = class extends import_graph16.Graph {
15162
15701
  if (this._mode !== "enforce" && pathsNode != null) {
15163
15702
  const offAuditPaths = pathsNode.subscribe((msgs) => {
15164
15703
  for (const m of msgs) {
15165
- if (m[0] !== import_core64.DATA) continue;
15704
+ if (m[0] !== import_core71.DATA) continue;
15166
15705
  latestPaths = m[1] ?? [];
15167
15706
  }
15168
15707
  });
@@ -15172,8 +15711,8 @@ var PolicyGateGraph = class extends import_graph16.Graph {
15172
15711
  const restorers = /* @__PURE__ */ new Map();
15173
15712
  const wrapAndPush = (path) => {
15174
15713
  if (restorers.has(path)) return;
15175
- const node58 = safeNode(target, path);
15176
- if (!(node58 instanceof import_core64.NodeImpl)) return;
15714
+ const node65 = safeNode(target, path);
15715
+ if (!(node65 instanceof import_core71.NodeImpl)) return;
15177
15716
  const pathGuard = (actor, action) => {
15178
15717
  const ok = this._currentGuard(actor, action);
15179
15718
  if (!ok) {
@@ -15181,17 +15720,17 @@ var PolicyGateGraph = class extends import_graph16.Graph {
15181
15720
  }
15182
15721
  return ok;
15183
15722
  };
15184
- restorers.set(path, node58._pushGuard(pathGuard));
15723
+ restorers.set(path, node65._pushGuard(pathGuard));
15185
15724
  };
15186
15725
  for (const path of paths) wrapAndPush(path);
15187
15726
  if (pathsNode != null) {
15188
15727
  const offReactivePaths = pathsNode.subscribe((msgs) => {
15189
15728
  for (const m of msgs) {
15190
- if (m[0] !== import_core64.DATA) continue;
15729
+ if (m[0] !== import_core71.DATA) continue;
15191
15730
  const next = m[1] ?? [];
15192
15731
  const nextSet = new Set(next);
15193
15732
  const prevSet = new Set(latestPaths ?? []);
15194
- (0, import_core64.batch)(() => {
15733
+ (0, import_core71.batch)(() => {
15195
15734
  for (const p of prevSet) {
15196
15735
  if (nextSet.has(p)) continue;
15197
15736
  const r = restorers.get(p);
@@ -15250,7 +15789,7 @@ var PolicyGateGraph = class extends import_graph16.Graph {
15250
15789
  } else {
15251
15790
  const offCleanup = target.topology.subscribe((msgs) => {
15252
15791
  for (const m of msgs) {
15253
- if (m[0] !== import_core64.DATA) continue;
15792
+ if (m[0] !== import_core71.DATA) continue;
15254
15793
  const event = m[1];
15255
15794
  if (event.kind !== "removed" || event.nodeKind !== "node") continue;
15256
15795
  const r = restorers.get(event.name);
@@ -15287,8 +15826,8 @@ var PolicyGateGraph = class extends import_graph16.Graph {
15287
15826
  }
15288
15827
  _publishViolation(actor, action, path, result) {
15289
15828
  this.violations.publish({
15290
- timestamp_ns: (0, import_core64.monotonicNs)(),
15291
- wall_clock_ns: (0, import_core64.wallClockNs)(),
15829
+ timestamp_ns: (0, import_core71.monotonicNs)(),
15830
+ wall_clock_ns: (0, import_core71.wallClockNs)(),
15292
15831
  path,
15293
15832
  actor,
15294
15833
  action,
@@ -15309,14 +15848,14 @@ var PolicyGateGraph = class extends import_graph16.Graph {
15309
15848
  };
15310
15849
  function policyGate(target, policies, opts = {}) {
15311
15850
  const g = new PolicyGateGraph(target, policies, opts);
15312
- g.tagFactory("policyGate", (0, import_core64.placeholderArgs)(opts));
15851
+ g.tagFactory("policyGate", (0, import_core71.placeholderArgs)(opts));
15313
15852
  return g;
15314
15853
  }
15315
15854
  function complianceSnapshot(target, opts = {}) {
15316
15855
  const result = {
15317
15856
  format_version: 1,
15318
- timestamp_ns: (0, import_core64.monotonicNs)(),
15319
- wall_clock_ns: (0, import_core64.wallClockNs)(),
15857
+ timestamp_ns: (0, import_core71.monotonicNs)(),
15858
+ wall_clock_ns: (0, import_core71.wallClockNs)(),
15320
15859
  graph: target.snapshot()
15321
15860
  };
15322
15861
  if (opts.actor != null) result.actor = opts.actor;
@@ -15357,7 +15896,7 @@ function collectPaths(target) {
15357
15896
  return Object.keys(described.nodes);
15358
15897
  }
15359
15898
  function computeFingerprint(value) {
15360
- return (0, import_core64.defaultHash)(JSON.stringify(canonicalize(value)));
15899
+ return (0, import_core71.defaultHash)(JSON.stringify(canonicalize(value)));
15361
15900
  }
15362
15901
  function canonicalize(value) {
15363
15902
  const stack = /* @__PURE__ */ new Set();
@@ -15410,8 +15949,8 @@ function canonicalize(value) {
15410
15949
  }
15411
15950
 
15412
15951
  // src/utils/inspect/lens.ts
15413
- var import_core65 = require("@graphrefly/pure-ts/core");
15414
- var import_extra48 = require("@graphrefly/pure-ts/extra");
15952
+ var import_core72 = require("@graphrefly/pure-ts/core");
15953
+ var import_extra53 = require("@graphrefly/pure-ts/extra");
15415
15954
  var import_graph17 = require("@graphrefly/pure-ts/graph");
15416
15955
  var import_graph18 = require("@graphrefly/pure-ts/graph");
15417
15956
  function computeHealthReport(described) {
@@ -15451,7 +15990,7 @@ function graphLens(target) {
15451
15990
  reactiveName: "graphLens.topology"
15452
15991
  });
15453
15992
  const topology = topologyHandle.node;
15454
- const health = (0, import_core65.node)(
15993
+ const health = (0, import_core72.node)(
15455
15994
  [topology],
15456
15995
  (batchData, actions, ctx) => {
15457
15996
  const data = batchData.map(
@@ -15466,11 +16005,11 @@ function graphLens(target) {
15466
16005
  meta: domainMeta("lens", "health")
15467
16006
  }
15468
16007
  );
15469
- const stopHealthKeep = (0, import_extra48.keepalive)(health);
16008
+ const stopHealthKeep = (0, import_extra53.keepalive)(health);
15470
16009
  const flowMap = /* @__PURE__ */ new Map();
15471
16010
  let lastAppliedFlush_ns = -1;
15472
16011
  const dataFlow = target.observe({ reactive: true, tiers: ["data"] });
15473
- const flow = (0, import_core65.node)(
16012
+ const flow = (0, import_core72.node)(
15474
16013
  [dataFlow, topology],
15475
16014
  (batchData, actions, ctx) => {
15476
16015
  const data = batchData.map(
@@ -15508,7 +16047,7 @@ function graphLens(target) {
15508
16047
  meta: domainMeta("lens", "flow")
15509
16048
  }
15510
16049
  );
15511
- const stopFlowKeep = (0, import_extra48.keepalive)(flow);
16050
+ const stopFlowKeep = (0, import_extra53.keepalive)(flow);
15512
16051
  let disposed = false;
15513
16052
  return {
15514
16053
  topology,
@@ -15525,8 +16064,8 @@ function graphLens(target) {
15525
16064
  }
15526
16065
 
15527
16066
  // src/utils/job-queue/index.ts
15528
- var import_core66 = require("@graphrefly/pure-ts/core");
15529
- var import_extra49 = require("@graphrefly/pure-ts/extra");
16067
+ var import_core73 = require("@graphrefly/pure-ts/core");
16068
+ var import_extra54 = require("@graphrefly/pure-ts/extra");
15530
16069
  var import_graph19 = require("@graphrefly/pure-ts/graph");
15531
16070
  var DEFAULT_MAX_PER_PUMP2 = 256;
15532
16071
  var DEFAULT_COMPLETED_RETAINED_LIMIT = 1024;
@@ -15562,13 +16101,13 @@ var JobQueueGraph = class extends import_graph19.Graph {
15562
16101
  _removeByIdImpl;
15563
16102
  constructor(name, opts = {}) {
15564
16103
  super(name, opts.graph);
15565
- this._pending = (0, import_extra49.reactiveList)([], { name: "pending" });
15566
- this._jobs = (0, import_extra49.reactiveMap)({ name: "jobs" });
16104
+ this._pending = (0, import_extra54.reactiveList)([], { name: "pending" });
16105
+ this._jobs = (0, import_extra54.reactiveMap)({ name: "jobs" });
15567
16106
  this.pending = this._pending.items;
15568
16107
  this.jobs = this._jobs.entries;
15569
16108
  this.add(this.pending, { name: "pending" });
15570
16109
  this.add(this.jobs, { name: "jobs" });
15571
- this.depth = (0, import_core66.node)(
16110
+ this.depth = (0, import_core73.node)(
15572
16111
  [this.pending],
15573
16112
  (batchData, actions, ctx) => {
15574
16113
  const data = batchData.map(
@@ -15584,7 +16123,7 @@ var JobQueueGraph = class extends import_graph19.Graph {
15584
16123
  }
15585
16124
  );
15586
16125
  this.add(this.depth, { name: "depth" });
15587
- this.addDisposer((0, import_extra49.keepalive)(this.depth));
16126
+ this.addDisposer((0, import_extra54.keepalive)(this.depth));
15588
16127
  this.events = createAuditLog({
15589
16128
  name: "events",
15590
16129
  retainedLimit: 1024,
@@ -15721,7 +16260,7 @@ var JobQueueGraph = class extends import_graph19.Graph {
15721
16260
  action: "claim",
15722
16261
  id,
15723
16262
  attempts: inflight.attempts,
15724
- t_ns: (0, import_core66.wallClockNs)(),
16263
+ t_ns: (0, import_core73.wallClockNs)(),
15725
16264
  seq: bumpCursor(this._seqCursor)
15726
16265
  });
15727
16266
  }
@@ -15772,7 +16311,7 @@ var JobQueueGraph = class extends import_graph19.Graph {
15772
16311
  consumeFrom(source, opts) {
15773
16312
  return source.subscribe((msgs) => {
15774
16313
  for (const m of msgs) {
15775
- if (m[0] !== import_core66.DATA) continue;
16314
+ if (m[0] !== import_core73.DATA) continue;
15776
16315
  const payload = m[1];
15777
16316
  this.enqueue(payload, opts ? { metadata: opts.metadata } : void 0);
15778
16317
  }
@@ -15832,13 +16371,13 @@ var JobFlowGraph = class extends import_graph19.Graph {
15832
16371
  this._queues.set(stage, q);
15833
16372
  this.mount(stage, q);
15834
16373
  }
15835
- this._completed = (0, import_extra49.reactiveLog)([], {
16374
+ this._completed = (0, import_extra54.reactiveLog)([], {
15836
16375
  name: "completed",
15837
16376
  maxSize: DEFAULT_COMPLETED_RETAINED_LIMIT
15838
16377
  });
15839
16378
  this.completed = this._completed.entries;
15840
16379
  this.add(this.completed, { name: "completed" });
15841
- this.completedCount = (0, import_core66.node)(
16380
+ this.completedCount = (0, import_core73.node)(
15842
16381
  [this.completed],
15843
16382
  (batchData, actions, ctx) => {
15844
16383
  const data = batchData.map(
@@ -15854,7 +16393,7 @@ var JobFlowGraph = class extends import_graph19.Graph {
15854
16393
  }
15855
16394
  );
15856
16395
  this.add(this.completedCount, { name: "completedCount" });
15857
- this.addDisposer((0, import_extra49.keepalive)(this.completedCount));
16396
+ this.addDisposer((0, import_extra54.keepalive)(this.completedCount));
15858
16397
  const defaultMaxPerPump = Math.max(
15859
16398
  1,
15860
16399
  requireNonNegativeInt2(opts.maxPerPump ?? DEFAULT_MAX_PER_PUMP2, "job flow maxPerPump")
@@ -15866,14 +16405,14 @@ var JobFlowGraph = class extends import_graph19.Graph {
15866
16405
  const workFn = this._stageWorkFns.get(stage);
15867
16406
  const stagePerPump = stageMaxPerPump.get(stage) ?? defaultMaxPerPump;
15868
16407
  const stageMaxInflightCap = stageMaxInflight.get(stage);
15869
- const inflightCounter = stageMaxInflightCap !== void 0 ? (0, import_core66.node)([], { name: `__inflight__/${stage}`, initial: 0 }) : null;
16408
+ const inflightCounter = stageMaxInflightCap !== void 0 ? (0, import_core73.node)([], { name: `__inflight__/${stage}`, initial: 0 }) : null;
15870
16409
  if (inflightCounter) {
15871
16410
  this.add(inflightCounter, { name: `__inflight__/${stage}` });
15872
16411
  }
15873
16412
  const isTerminal = next === null;
15874
16413
  if (workFn) {
15875
16414
  const pumpDeps = inflightCounter != null ? [current.pending, inflightCounter] : [current.pending];
15876
- const pump = (0, import_core66.node)(
16415
+ const pump = (0, import_core73.node)(
15877
16416
  pumpDeps,
15878
16417
  (_data, _actions, ctx) => {
15879
16418
  if (!("inflight" in ctx.store)) {
@@ -15909,7 +16448,7 @@ var JobFlowGraph = class extends import_graph19.Graph {
15909
16448
  processed += 1;
15910
16449
  continue;
15911
16450
  }
15912
- const resultNode = (0, import_extra49.fromAny)(result);
16451
+ const resultNode = (0, import_extra54.fromAny)(result);
15913
16452
  let settled = false;
15914
16453
  let unsub;
15915
16454
  const cleanupSub = () => {
@@ -15926,7 +16465,7 @@ var JobFlowGraph = class extends import_graph19.Graph {
15926
16465
  unsub = resultNode.subscribe((msgs) => {
15927
16466
  if (settled) return;
15928
16467
  for (const m of msgs) {
15929
- if (m[0] === import_core66.DATA) {
16468
+ if (m[0] === import_core73.DATA) {
15930
16469
  settled = true;
15931
16470
  cleanupSub();
15932
16471
  const newPayload = m[1];
@@ -15940,12 +16479,12 @@ var JobFlowGraph = class extends import_graph19.Graph {
15940
16479
  payload: newPayload,
15941
16480
  metadata: Object.freeze(newMetadata)
15942
16481
  };
15943
- (0, import_core66.batch)(() => {
16482
+ (0, import_core73.batch)(() => {
15944
16483
  current.ack(job.id);
15945
16484
  this._completed.append(completedJob);
15946
16485
  });
15947
16486
  } else {
15948
- (0, import_core66.batch)(() => {
16487
+ (0, import_core73.batch)(() => {
15949
16488
  current.ack(job.id);
15950
16489
  next.enqueue(newPayload, {
15951
16490
  metadata: newMetadata
@@ -15953,7 +16492,7 @@ var JobFlowGraph = class extends import_graph19.Graph {
15953
16492
  });
15954
16493
  }
15955
16494
  return;
15956
- } else if (m[0] === import_core66.ERROR) {
16495
+ } else if (m[0] === import_core73.ERROR) {
15957
16496
  settled = true;
15958
16497
  cleanupSub();
15959
16498
  current.nack(job.id, { requeue: false });
@@ -15986,7 +16525,7 @@ var JobFlowGraph = class extends import_graph19.Graph {
15986
16525
  meta: jobQueueMeta("job_flow_pump", { stage, has_work: true })
15987
16526
  }
15988
16527
  );
15989
- this.addDisposer((0, import_extra49.keepalive)(pump));
16528
+ this.addDisposer((0, import_extra54.keepalive)(pump));
15990
16529
  } else {
15991
16530
  const pump = this.effect(
15992
16531
  `pump_${stage}`,
@@ -16006,12 +16545,12 @@ var JobFlowGraph = class extends import_graph19.Graph {
16006
16545
  ...job,
16007
16546
  metadata: Object.freeze(newMetadata)
16008
16547
  };
16009
- (0, import_core66.batch)(() => {
16548
+ (0, import_core73.batch)(() => {
16010
16549
  current.ack(job.id);
16011
16550
  this._completed.append(completedJob);
16012
16551
  });
16013
16552
  } else {
16014
- (0, import_core66.batch)(() => {
16553
+ (0, import_core73.batch)(() => {
16015
16554
  current.ack(job.id);
16016
16555
  next.enqueue(job.payload, {
16017
16556
  metadata: newMetadata
@@ -16025,7 +16564,7 @@ var JobFlowGraph = class extends import_graph19.Graph {
16025
16564
  meta: jobQueueMeta("job_flow_pump", { stage, has_work: false })
16026
16565
  }
16027
16566
  );
16028
- this.addDisposer((0, import_extra49.keepalive)(pump));
16567
+ this.addDisposer((0, import_extra54.keepalive)(pump));
16029
16568
  }
16030
16569
  }
16031
16570
  }
@@ -16050,19 +16589,19 @@ function jobQueue(name, opts) {
16050
16589
  function jobFlow(name, opts) {
16051
16590
  const g = new JobFlowGraph(name, opts);
16052
16591
  const { factory: _f, factoryArgs: _fa, ...tagArgs } = opts ?? {};
16053
- g.tagFactory("jobFlow", (0, import_core66.placeholderArgs)(tagArgs));
16592
+ g.tagFactory("jobFlow", (0, import_core73.placeholderArgs)(tagArgs));
16054
16593
  return g;
16055
16594
  }
16056
16595
 
16057
16596
  // src/utils/process/index.ts
16058
- var import_core67 = require("@graphrefly/pure-ts/core");
16059
- var import_extra50 = require("@graphrefly/pure-ts/extra");
16597
+ var import_core74 = require("@graphrefly/pure-ts/core");
16598
+ var import_extra55 = require("@graphrefly/pure-ts/extra");
16060
16599
  var import_graph20 = require("@graphrefly/pure-ts/graph");
16061
16600
  var processInstanceKeyOf = (i) => i.correlationId;
16062
16601
  var processStateKeyOf = (s) => s.correlationId;
16063
16602
  function toPromise(input) {
16064
16603
  if (input == null) return Promise.resolve(void 0);
16065
- const n = (0, import_extra50.fromAny)(input);
16604
+ const n = (0, import_extra55.fromAny)(input);
16066
16605
  return new Promise((resolve, reject) => {
16067
16606
  let settled = false;
16068
16607
  let unsub;
@@ -16074,19 +16613,19 @@ function toPromise(input) {
16074
16613
  unsub = n.subscribe((msgs) => {
16075
16614
  if (settled) return;
16076
16615
  for (const m of msgs) {
16077
- if (m[0] === import_core67.DATA) {
16616
+ if (m[0] === import_core74.DATA) {
16078
16617
  settled = true;
16079
16618
  Promise.resolve().then(cleanup);
16080
16619
  resolve(m[1]);
16081
16620
  return;
16082
16621
  }
16083
- if (m[0] === import_core67.ERROR) {
16622
+ if (m[0] === import_core74.ERROR) {
16084
16623
  settled = true;
16085
16624
  Promise.resolve().then(cleanup);
16086
16625
  reject(m[1]);
16087
16626
  return;
16088
16627
  }
16089
- if (m[0] === import_core67.COMPLETE) {
16628
+ if (m[0] === import_core74.COMPLETE) {
16090
16629
  settled = true;
16091
16630
  Promise.resolve().then(cleanup);
16092
16631
  resolve(void 0);
@@ -16167,8 +16706,8 @@ function processManager(cqrsGraph, name, opts) {
16167
16706
  correlationId,
16168
16707
  state: stateValue,
16169
16708
  status,
16170
- startedAt: startedAt.get(correlationId) ?? (0, import_core67.wallClockNs)(),
16171
- updatedAt: (0, import_core67.wallClockNs)(),
16709
+ startedAt: startedAt.get(correlationId) ?? (0, import_core74.wallClockNs)(),
16710
+ updatedAt: (0, import_core74.wallClockNs)(),
16172
16711
  ...opts.handlerVersion !== void 0 ? { handlerVersion: opts.handlerVersion } : {}
16173
16712
  };
16174
16713
  };
@@ -16266,10 +16805,10 @@ function processManager(cqrsGraph, name, opts) {
16266
16805
  if (result.schedule) {
16267
16806
  const { afterMs, eventType } = result.schedule;
16268
16807
  let timerUnsub;
16269
- const timerNode = (0, import_extra50.fromTimer)(afterMs);
16808
+ const timerNode = (0, import_extra55.fromTimer)(afterMs);
16270
16809
  const timerCb = (msgs) => {
16271
16810
  for (const m of msgs) {
16272
- if (m[0] === import_core67.DATA) {
16811
+ if (m[0] === import_core74.DATA) {
16273
16812
  if (timerUnsub) {
16274
16813
  timerUnsub();
16275
16814
  } else {
@@ -16286,7 +16825,7 @@ function processManager(cqrsGraph, name, opts) {
16286
16825
  // seq: Number.NaN — sentinel for synthetic events that do not
16287
16826
  // participate in cross-event ordering.
16288
16827
  payload: null,
16289
- timestampNs: (0, import_core67.wallClockNs)(),
16828
+ timestampNs: (0, import_core74.wallClockNs)(),
16290
16829
  seq: Number.NaN,
16291
16830
  correlationId,
16292
16831
  aggregateId: correlationId
@@ -16347,13 +16886,13 @@ function processManager(cqrsGraph, name, opts) {
16347
16886
  });
16348
16887
  }
16349
16888
  let _disposed = false;
16350
- const restoreState = (0, import_core67.node)([], {
16889
+ const restoreState = (0, import_core74.node)([], {
16351
16890
  initial: "pending",
16352
16891
  name: "restoreState",
16353
16892
  describeKind: "state"
16354
16893
  });
16355
16894
  subgraph.add(restoreState, { name: "restoreState" });
16356
- const gateOpen = (0, import_core67.node)(
16895
+ const gateOpen = (0, import_core74.node)(
16357
16896
  [restoreState],
16358
16897
  (data, a, ctx) => {
16359
16898
  const batch0 = data[0];
@@ -16366,11 +16905,11 @@ function processManager(cqrsGraph, name, opts) {
16366
16905
  const watchDisposers = [];
16367
16906
  for (const eventType of opts.watching) {
16368
16907
  const eventNode = cqrsGraph.event(eventType);
16369
- const gated = (0, import_extra50.valve)(eventNode, gateOpen, { name: `gatedEvent:${eventType}` });
16908
+ const gated = (0, import_extra55.valve)(eventNode, gateOpen, { name: `gatedEvent:${eventType}` });
16370
16909
  let lastCount = 0;
16371
16910
  const unsub = gated.subscribe((msgs) => {
16372
16911
  for (const m of msgs) {
16373
- if (m[0] !== import_core67.DATA) continue;
16912
+ if (m[0] !== import_core74.DATA) continue;
16374
16913
  const events = m[1];
16375
16914
  if (events.length <= lastCount) continue;
16376
16915
  const newEvents = events.slice(lastCount);
@@ -16395,7 +16934,7 @@ function processManager(cqrsGraph, name, opts) {
16395
16934
  correlationId,
16396
16935
  aggregateId: correlationId
16397
16936
  });
16398
- startedAt.set(correlationId, (0, import_core67.wallClockNs)());
16937
+ startedAt.set(correlationId, (0, import_core74.wallClockNs)());
16399
16938
  instanceStates.set(correlationId, opts.initial);
16400
16939
  activeInstances.add(correlationId);
16401
16940
  persistStateThrowing(correlationId, "running");
@@ -16447,21 +16986,21 @@ function processManager(cqrsGraph, name, opts) {
16447
16986
  }
16448
16987
  const tierLoad = tier2.load.bind(tier2);
16449
16988
  const tierList = tier2.list.bind(tier2);
16450
- const listSource = (0, import_extra50.fromAny)(tierList());
16451
- const flattened = (0, import_extra50.mergeMap)(listSource, (keys) => {
16989
+ const listSource = (0, import_extra55.fromAny)(tierList());
16990
+ const flattened = (0, import_extra55.mergeMap)(listSource, (keys) => {
16452
16991
  if (keys.length === 0) {
16453
- return (0, import_extra50.fromIter)([]);
16992
+ return (0, import_extra55.fromIter)([]);
16454
16993
  }
16455
- return (0, import_extra50.mergeMap)(
16456
- (0, import_extra50.fromIter)(keys),
16457
- (key) => (0, import_extra50.fromAny)(tierLoad(key)),
16994
+ return (0, import_extra55.mergeMap)(
16995
+ (0, import_extra55.fromIter)(keys),
16996
+ (key) => (0, import_extra55.fromAny)(tierLoad(key)),
16458
16997
  // Bound concurrent in-flight loads (D2, 2026-05-01) so a
16459
16998
  // large persisted-instance count doesn't exhaust file
16460
16999
  // handles / connection pools on the storage backend.
16461
17000
  { concurrent: opts.restoreConcurrency ?? 8 }
16462
17001
  );
16463
17002
  });
16464
- const restoreEffect = (0, import_core67.node)(
17003
+ const restoreEffect = (0, import_core74.node)(
16465
17004
  [flattened],
16466
17005
  (data, _a, ctx) => {
16467
17006
  if (_disposed) return;
@@ -16469,7 +17008,7 @@ function processManager(cqrsGraph, name, opts) {
16469
17008
  const hasSnapshots = batch0 != null && batch0.length > 0;
16470
17009
  const allDone = ctx.terminalDeps[0] === true;
16471
17010
  if (!hasSnapshots && !allDone) return;
16472
- (0, import_core67.batch)(() => {
17011
+ (0, import_core74.batch)(() => {
16473
17012
  if (hasSnapshots) {
16474
17013
  for (const snap of batch0) {
16475
17014
  if (snap == null) continue;
@@ -16697,7 +17236,7 @@ var ImageSizeAdapter = class {
16697
17236
  };
16698
17237
 
16699
17238
  // src/utils/reactive-layout/reactive-block-layout.ts
16700
- var import_core68 = require("@graphrefly/pure-ts/core");
17239
+ var import_core75 = require("@graphrefly/pure-ts/core");
16701
17240
  var import_graph21 = require("@graphrefly/pure-ts/graph");
16702
17241
  function measureBlock(block, maxWidth, adapters, measureCache, defaultFont, defaultLineHeight, index) {
16703
17242
  switch (block.type) {
@@ -16793,18 +17332,18 @@ function reactiveBlockLayout(opts) {
16793
17332
  } = opts;
16794
17333
  const g = new import_graph21.Graph(name);
16795
17334
  const measureCache = /* @__PURE__ */ new Map();
16796
- const blocksNode = (0, import_core68.node)([], { name: "blocks", initial: opts.blocks ?? [] });
16797
- const maxWidthNode = (0, import_core68.node)([], {
17335
+ const blocksNode = (0, import_core75.node)([], { name: "blocks", initial: opts.blocks ?? [] });
17336
+ const maxWidthNode = (0, import_core75.node)([], {
16798
17337
  name: "max-width",
16799
17338
  initial: Math.max(0, opts.maxWidth ?? 800)
16800
17339
  });
16801
- const gapNode = (0, import_core68.node)([], { name: "gap", initial: opts.gap ?? 0 });
16802
- const measuredBlocksNode = (0, import_core68.node)(
17340
+ const gapNode = (0, import_core75.node)([], { name: "gap", initial: opts.gap ?? 0 });
17341
+ const measuredBlocksNode = (0, import_core75.node)(
16803
17342
  [blocksNode, maxWidthNode],
16804
17343
  (data, actions, ctx) => {
16805
17344
  const blocksVal = data[0] != null && data[0].length > 0 ? data[0].at(-1) : ctx.prevData[0];
16806
17345
  const mwVal = data[1] != null && data[1].length > 0 ? data[1].at(-1) : ctx.prevData[1];
16807
- const t0 = (0, import_core68.monotonicNs)();
17346
+ const t0 = (0, import_core75.monotonicNs)();
16808
17347
  const result = measureBlocks(
16809
17348
  blocksVal,
16810
17349
  mwVal,
@@ -16813,7 +17352,7 @@ function reactiveBlockLayout(opts) {
16813
17352
  defaultFont,
16814
17353
  defaultLineHeight
16815
17354
  );
16816
- const elapsed = (0, import_core68.monotonicNs)() - t0;
17355
+ const elapsed = (0, import_core75.monotonicNs)() - t0;
16817
17356
  const meta2 = measuredBlocksNode.meta;
16818
17357
  if (meta2) {
16819
17358
  emitToMeta(meta2["block-count"], result.length);
@@ -16845,7 +17384,7 @@ function reactiveBlockLayout(opts) {
16845
17384
  }
16846
17385
  }
16847
17386
  );
16848
- const blockFlowNode = (0, import_core68.node)(
17387
+ const blockFlowNode = (0, import_core75.node)(
16849
17388
  [measuredBlocksNode, gapNode],
16850
17389
  (batchData, actions, ctx) => {
16851
17390
  const data = batchData.map(
@@ -16871,7 +17410,7 @@ function reactiveBlockLayout(opts) {
16871
17410
  }
16872
17411
  }
16873
17412
  );
16874
- const totalHeightNode = (0, import_core68.node)(
17413
+ const totalHeightNode = (0, import_core75.node)(
16875
17414
  [blockFlowNode],
16876
17415
  (batchData, actions, ctx) => {
16877
17416
  const data = batchData.map(
@@ -16899,7 +17438,7 @@ function reactiveBlockLayout(opts) {
16899
17438
  }
16900
17439
 
16901
17440
  // src/utils/reactive-layout/reactive-flow-layout.ts
16902
- var import_core69 = require("@graphrefly/pure-ts/core");
17441
+ var import_core76 = require("@graphrefly/pure-ts/core");
16903
17442
  var import_graph22 = require("@graphrefly/pure-ts/graph");
16904
17443
  function circleIntervalForBand(o, bandTop, bandBottom) {
16905
17444
  const hPad = o.hPad ?? 0;
@@ -16991,23 +17530,23 @@ function reactiveFlowLayout(opts) {
16991
17530
  const { adapter, name = "reactive-flow-layout", minSlotWidth = 20 } = opts;
16992
17531
  const g = new import_graph22.Graph(name);
16993
17532
  const measureCache = /* @__PURE__ */ new Map();
16994
- const textNode = (0, import_core69.node)([], { name: "text", initial: opts.text ?? "" });
16995
- const fontNode = (0, import_core69.node)([], { name: "font", initial: opts.font ?? "16px sans-serif" });
16996
- const lineHeightNode = (0, import_core69.node)([], { name: "line-height", initial: opts.lineHeight ?? 20 });
16997
- const containerNode = (0, import_core69.node)([], {
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)([], {
16998
17537
  name: "container",
16999
17538
  initial: opts.container ?? { width: 800, height: 600, paddingX: 0, paddingY: 0 }
17000
17539
  });
17001
- const columnsNode = (0, import_core69.node)([], {
17540
+ const columnsNode = (0, import_core76.node)([], {
17002
17541
  name: "columns",
17003
17542
  initial: opts.columns ?? { count: 1, gap: 0 }
17004
17543
  });
17005
- const obstaclesNode = (0, import_core69.node)([], { name: "obstacles", initial: opts.obstacles ?? [] });
17006
- const paragraphSpacingNode = (0, import_core69.node)([], {
17544
+ const obstaclesNode = (0, import_core76.node)([], { name: "obstacles", initial: opts.obstacles ?? [] });
17545
+ const paragraphSpacingNode = (0, import_core76.node)([], {
17007
17546
  name: "paragraph-spacing",
17008
17547
  initial: opts.paragraphSpacing ?? null
17009
17548
  });
17010
- const segmentsNode = (0, import_core69.node)(
17549
+ const segmentsNode = (0, import_core76.node)(
17011
17550
  [textNode, fontNode],
17012
17551
  (data, actions, ctx) => {
17013
17552
  const b0 = data[0];
@@ -17024,14 +17563,14 @@ function reactiveFlowLayout(opts) {
17024
17563
  },
17025
17564
  { name: "segments", describeKind: "derived" }
17026
17565
  );
17027
- const flowLinesNode = (0, import_core69.node)(
17566
+ const flowLinesNode = (0, import_core76.node)(
17028
17567
  [segmentsNode, containerNode, columnsNode, obstaclesNode, lineHeightNode, paragraphSpacingNode],
17029
17568
  (batchData, actions, ctx) => {
17030
17569
  const data = batchData.map(
17031
17570
  (batch14, i) => batch14 != null && batch14.length > 0 ? batch14.at(-1) : ctx.prevData[i]
17032
17571
  );
17033
17572
  const segments = data[0];
17034
- const t0 = (0, import_core69.monotonicNs)();
17573
+ const t0 = (0, import_core76.monotonicNs)();
17035
17574
  const effectiveSpacing = data[5] ?? data[4];
17036
17575
  const { lines: result, cursor } = computeFlowLines(
17037
17576
  segments,
@@ -17042,7 +17581,7 @@ function reactiveFlowLayout(opts) {
17042
17581
  minSlotWidth,
17043
17582
  { paragraphSpacing: effectiveSpacing }
17044
17583
  );
17045
- const elapsed = (0, import_core69.monotonicNs)() - t0;
17584
+ const elapsed = (0, import_core76.monotonicNs)() - t0;
17046
17585
  const overflow = Math.max(0, segments.length - cursor.segmentIndex);
17047
17586
  const meta2 = flowLinesNode.meta;
17048
17587
  if (meta2) {
@@ -17166,7 +17705,7 @@ ${catalogValidation.errors.join("\n")}`,
17166
17705
  }
17167
17706
 
17168
17707
  // src/utils/surface/reduce.ts
17169
- var import_core70 = require("@graphrefly/pure-ts/core");
17708
+ var import_core77 = require("@graphrefly/pure-ts/core");
17170
17709
  var DEFAULT_TIMEOUT_MS2 = 3e4;
17171
17710
  async function runReduction(spec, input, opts) {
17172
17711
  const inputPath = opts?.inputPath ?? "input";
@@ -17217,16 +17756,16 @@ async function runReduction(spec, input, opts) {
17217
17756
  for (const m of msgs) {
17218
17757
  if (settled) return;
17219
17758
  if (!primed) continue;
17220
- if (m[0] === import_core70.DATA) {
17759
+ if (m[0] === import_core77.DATA) {
17221
17760
  finish(() => resolve(m[1]));
17222
17761
  return;
17223
17762
  }
17224
- if (m[0] === import_core70.RESOLVED) {
17763
+ if (m[0] === import_core77.RESOLVED) {
17225
17764
  const cached = outputNode.cache;
17226
17765
  finish(() => resolve(cached));
17227
17766
  return;
17228
17767
  }
17229
- if (m[0] === import_core70.ERROR) {
17768
+ if (m[0] === import_core77.ERROR) {
17230
17769
  const payload = m[1];
17231
17770
  const message = payload instanceof Error ? payload.message : String(payload);
17232
17771
  const cause = payload instanceof Error ? payload : void 0;
@@ -17241,7 +17780,7 @@ async function runReduction(spec, input, opts) {
17241
17780
  );
17242
17781
  return;
17243
17782
  }
17244
- if (m[0] === import_core70.COMPLETE) {
17783
+ if (m[0] === import_core77.COMPLETE) {
17245
17784
  finish(
17246
17785
  () => reject(
17247
17786
  new SurfaceError(
@@ -17296,7 +17835,7 @@ async function runReduction(spec, input, opts) {
17296
17835
  }
17297
17836
 
17298
17837
  // src/utils/surface/snapshot.ts
17299
- var import_core71 = require("@graphrefly/pure-ts/core");
17838
+ var import_core78 = require("@graphrefly/pure-ts/core");
17300
17839
  var import_graph23 = require("@graphrefly/pure-ts/graph");
17301
17840
  var SNAPSHOT_WIRE_VERSION = import_graph23.SNAPSHOT_VERSION;
17302
17841
  var SNAPSHOT_KEY_PREFIX = "snapshot:";
@@ -17365,7 +17904,7 @@ async function saveSnapshot(graph, snapshotId, tier2) {
17365
17904
  name: graph.name,
17366
17905
  mode: "full",
17367
17906
  seq: 0,
17368
- timestamp_ns: (0, import_core71.wallClockNs)(),
17907
+ timestamp_ns: (0, import_core78.wallClockNs)(),
17369
17908
  format_version: SNAPSHOT_WIRE_VERSION,
17370
17909
  snapshot
17371
17910
  };