@graphrefly/graphrefly 0.46.0 → 0.47.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) 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-WKSWLSCX.js → chunk-22SG74BD.js} +2 -2
  12. package/dist/{chunk-OO5BM6CJ.js → chunk-5IMMNARC.js} +2 -2
  13. package/dist/{chunk-KIIXR252.js → chunk-EHRRQ4IC.js} +2 -2
  14. package/dist/{chunk-HULCUY35.js → chunk-GWRNLJNW.js} +2 -2
  15. package/dist/{chunk-5THCXDWY.js → chunk-JKTC747G.js} +2 -2
  16. package/dist/{chunk-RGL53X5G.js → chunk-TNX5ZGDJ.js} +3 -3
  17. package/dist/{chunk-LBAJK24K.js → chunk-VLAGJZSL.js} +11 -3
  18. package/dist/chunk-VLAGJZSL.js.map +1 -0
  19. package/dist/chunk-Z65DVDEQ.js +146 -0
  20. package/dist/chunk-Z65DVDEQ.js.map +1 -0
  21. package/dist/{chunk-GBCENOLN.js → chunk-ZT4WMQW4.js} +3 -3
  22. package/dist/{chunk-FR6RGA3B.js → chunk-ZVXXDWIB.js} +19 -14
  23. package/dist/{chunk-FR6RGA3B.js.map → chunk-ZVXXDWIB.js.map} +1 -1
  24. package/dist/compat/index.cjs +156 -93
  25. package/dist/compat/index.cjs.map +1 -1
  26. package/dist/compat/index.d.cts +3 -3
  27. package/dist/compat/index.d.ts +3 -3
  28. package/dist/compat/index.js +2 -2
  29. package/dist/compat/nestjs/index.cjs +156 -93
  30. package/dist/compat/nestjs/index.cjs.map +1 -1
  31. package/dist/compat/nestjs/index.d.cts +4 -4
  32. package/dist/compat/nestjs/index.d.ts +4 -4
  33. package/dist/compat/nestjs/index.js +4 -5
  34. package/dist/{index-5SU_O78r.d.cts → index-B_p8tnvf.d.cts} +19 -3
  35. package/dist/{index-CEXCtYYJ.d.ts → index-_HDSmPyp.d.ts} +19 -3
  36. package/dist/index.cjs +77 -18
  37. package/dist/index.cjs.map +1 -1
  38. package/dist/index.d.cts +1 -2
  39. package/dist/index.d.ts +1 -2
  40. package/dist/index.js +9 -9
  41. package/dist/observable-B25XqCbZ.d.cts +59 -0
  42. package/dist/observable-B25XqCbZ.d.ts +59 -0
  43. package/dist/presets/ai/index.js +5 -5
  44. package/dist/presets/harness/index.js +7 -7
  45. package/dist/presets/index.js +8 -8
  46. package/dist/solutions/index.js +6 -6
  47. package/dist/utils/ai/index.js +3 -3
  48. package/dist/utils/index.cjs +8 -3
  49. package/dist/utils/index.cjs.map +1 -1
  50. package/dist/utils/index.js +3 -3
  51. package/dist/utils/memory/index.cjs +8 -3
  52. package/dist/utils/memory/index.cjs.map +1 -1
  53. package/dist/utils/memory/index.d.cts +78 -0
  54. package/dist/utils/memory/index.d.ts +78 -0
  55. package/dist/utils/memory/index.js +1 -1
  56. package/package.json +1 -5
  57. package/dist/chunk-3QZY5BI7.js +0 -92
  58. package/dist/chunk-3QZY5BI7.js.map +0 -1
  59. package/dist/chunk-LBAJK24K.js.map +0 -1
  60. package/dist/observable-BXQoW1P-.d.cts +0 -36
  61. package/dist/observable-BXQoW1P-.d.ts +0 -36
  62. /package/dist/{chunk-WKSWLSCX.js.map → chunk-22SG74BD.js.map} +0 -0
  63. /package/dist/{chunk-OO5BM6CJ.js.map → chunk-5IMMNARC.js.map} +0 -0
  64. /package/dist/{chunk-KIIXR252.js.map → chunk-EHRRQ4IC.js.map} +0 -0
  65. /package/dist/{chunk-HULCUY35.js.map → chunk-GWRNLJNW.js.map} +0 -0
  66. /package/dist/{chunk-5THCXDWY.js.map → chunk-JKTC747G.js.map} +0 -0
  67. /package/dist/{chunk-RGL53X5G.js.map → chunk-TNX5ZGDJ.js.map} +0 -0
  68. /package/dist/{chunk-GBCENOLN.js.map → chunk-ZT4WMQW4.js.map} +0 -0
@@ -12,13 +12,13 @@ import {
12
12
  } from "./chunk-BXGZFGZ4.js";
13
13
 
14
14
  // src/utils/memory/index.ts
15
- import { monotonicNs as monotonicNs2, NodeImpl, node as node2, wallClockNs as wallClockNs2 } from "@graphrefly/pure-ts/core";
15
+ import { monotonicNs, NodeImpl, node as node2, wallClockNs as wallClockNs2 } from "@graphrefly/pure-ts/core";
16
16
  import { fromTimer, keepalive as keepalive2, reactiveMap } from "@graphrefly/pure-ts/extra";
17
17
  import { Graph as Graph2 } from "@graphrefly/pure-ts/graph";
18
18
 
19
19
  // src/utils/memory/fact-store.ts
20
- import { monotonicNs, node, wallClockNs } from "@graphrefly/pure-ts/core";
21
- import { keepalive } from "@graphrefly/pure-ts/extra";
20
+ import { node, wallClockNs } from "@graphrefly/pure-ts/core";
21
+ import { keepalive, reactiveLog } from "@graphrefly/pure-ts/extra";
22
22
  import { Graph } from "@graphrefly/pure-ts/graph";
23
23
  var OVERFLOW_SAMPLE_SIZE = 8;
24
24
  function factMeta(kind, extra) {
@@ -65,6 +65,8 @@ function reactiveFactStore(config) {
65
65
  graph
66
66
  });
67
67
  const seqCursor = registerCursor(graph, "seq", 0);
68
+ const ingestLog = config.recordIngest ? reactiveLog([], { name: "ingest_log" }) : void 0;
69
+ if (ingestLog) graph.addDisposer(() => ingestLog.dispose());
68
70
  const emptyStore = () => ({ byId: /* @__PURE__ */ new Map() });
69
71
  const shards = [];
70
72
  for (let s = 0; s < shardCount; s += 1) {
@@ -220,6 +222,8 @@ function reactiveFactStore(config) {
220
222
  factId: dep,
221
223
  rootFactId: f.id,
222
224
  reason: "obsolete",
225
+ // `obsolete` guard above guarantees `f.validTo` is set.
226
+ rootValidTo: f.validTo,
223
227
  iteration: cascadeIteration + 1,
224
228
  causalReason: `dependentsIndex[${f.id}] \u2192 ${dep} (obsolete: validTo set)`
225
229
  });
@@ -292,11 +296,10 @@ function reactiveFactStore(config) {
292
296
  actions.emit([]);
293
297
  return;
294
298
  }
295
- const now = monotonicNs();
296
- for (const [id] of byId) {
299
+ for (const [id, e] of byId) {
297
300
  replaceFragment(
298
301
  id,
299
- (prev) => prev.validTo !== void 0 ? prev : { ...prev, validTo: BigInt(now) }
302
+ (prev) => prev.validTo !== void 0 ? prev : { ...prev, validTo: e.rootValidTo }
300
303
  );
301
304
  }
302
305
  actions.emit([...byId.values()]);
@@ -454,6 +457,7 @@ function reactiveFactStore(config) {
454
457
  t_ns: wallClockNs(),
455
458
  seq: bumpCursor(seqCursor)
456
459
  });
460
+ ingestLog?.append(f);
457
461
  }
458
462
  actions.emit(f ?? null);
459
463
  },
@@ -490,6 +494,7 @@ function reactiveFactStore(config) {
490
494
  review,
491
495
  consolidated,
492
496
  events,
497
+ ...ingestLog ? { ingestLog } : {},
493
498
  itemNode
494
499
  });
495
500
  return out;
@@ -562,7 +567,7 @@ function collection(name, opts = {}) {
562
567
  return scoreInput;
563
568
  };
564
569
  const graph = new Graph2(name);
565
- const retentionScore = (_k, v) => ranked ? decay(v.baseScore, ageSeconds(monotonicNs2(), v.lastAccessNs), decayRate, minScore) : v.lastAccessNs;
570
+ const retentionScore = (_k, v) => ranked ? decay(v.baseScore, ageSeconds(monotonicNs(), v.lastAccessNs), decayRate, minScore) : v.lastAccessNs;
566
571
  const items = reactiveMap({
567
572
  name: "items",
568
573
  ...maxSize !== void 0 ? { retention: { score: retentionScore, maxSize } } : {}
@@ -575,12 +580,12 @@ function collection(name, opts = {}) {
575
580
  refreshTick = node2(
576
581
  [tickCounter],
577
582
  (_batchData, actions) => {
578
- actions.emit(monotonicNs2());
583
+ actions.emit(monotonicNs());
579
584
  },
580
585
  {
581
586
  name: "refresh_tick_ns",
582
587
  describeKind: "derived",
583
- initial: monotonicNs2(),
588
+ initial: monotonicNs(),
584
589
  meta: memoryMeta("clock")
585
590
  }
586
591
  );
@@ -601,9 +606,9 @@ function collection(name, opts = {}) {
601
606
  let now;
602
607
  if (refreshTick) {
603
608
  const tickValue = values[1];
604
- now = typeof tickValue === "number" ? tickValue : monotonicNs2();
609
+ now = typeof tickValue === "number" ? tickValue : monotonicNs();
605
610
  } else {
606
- now = monotonicNs2();
611
+ now = monotonicNs();
607
612
  }
608
613
  if (!snapshot || snapshot.size === 0) {
609
614
  actions.emit([]);
@@ -661,7 +666,7 @@ function collection(name, opts = {}) {
661
666
  });
662
667
  const seqCursor = registerCursor(graph, "seq", 0);
663
668
  const upsertImpl = (id, value, _opts) => {
664
- const now = monotonicNs2();
669
+ const now = monotonicNs();
665
670
  const prev = items.get(id);
666
671
  const baseScore = _opts?.score ?? readScoreFn()(value);
667
672
  items.set(id, {
@@ -847,7 +852,7 @@ function vectorIndex(opts = {}) {
847
852
  id,
848
853
  vector: [...vector],
849
854
  ...copiedMeta !== void 0 ? { meta: copiedMeta } : {},
850
- upsertedAtNs: monotonicNs2()
855
+ upsertedAtNs: monotonicNs()
851
856
  };
852
857
  entries.set(id, record);
853
858
  };
@@ -1274,4 +1279,4 @@ export {
1274
1279
  vectorIndex,
1275
1280
  knowledgeGraph
1276
1281
  };
1277
- //# sourceMappingURL=chunk-FR6RGA3B.js.map
1282
+ //# sourceMappingURL=chunk-ZVXXDWIB.js.map