@graphrefly/graphrefly 0.47.2 → 0.48.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/base/composition/index.cjs +4 -3
- package/dist/base/composition/index.cjs.map +1 -1
- package/dist/base/composition/index.d.cts +14 -5
- package/dist/base/composition/index.d.ts +14 -5
- package/dist/base/composition/index.js +8 -8
- package/dist/base/index.cjs +152 -78
- package/dist/base/index.cjs.map +1 -1
- package/dist/base/index.d.cts +2 -2
- package/dist/base/index.d.ts +2 -2
- package/dist/base/index.js +75 -70
- package/dist/base/io/index.cjs +31 -17
- package/dist/base/io/index.cjs.map +1 -1
- package/dist/base/io/index.d.cts +32 -5
- package/dist/base/io/index.d.ts +32 -5
- package/dist/base/io/index.js +1 -1
- package/dist/base/mutation/index.cjs +21 -0
- package/dist/base/mutation/index.cjs.map +1 -1
- package/dist/base/mutation/index.d.cts +23 -1
- package/dist/base/mutation/index.d.ts +23 -1
- package/dist/base/mutation/index.js +3 -1
- package/dist/base/sources/browser/index.cjs +5 -3
- package/dist/base/sources/browser/index.cjs.map +1 -1
- package/dist/base/sources/browser/index.d.cts +20 -2
- package/dist/base/sources/browser/index.d.ts +20 -2
- package/dist/base/sources/browser/index.js +5 -3
- package/dist/base/sources/browser/index.js.map +1 -1
- package/dist/base/sources/event/index.cjs +28 -0
- package/dist/base/sources/event/index.cjs.map +1 -1
- package/dist/base/sources/event/index.d.cts +67 -3
- package/dist/base/sources/event/index.d.ts +67 -3
- package/dist/base/sources/event/index.js +4 -1
- package/dist/base/sources/index.cjs +75 -37
- package/dist/base/sources/index.cjs.map +1 -1
- package/dist/base/sources/index.d.cts +1 -1
- package/dist/base/sources/index.d.ts +1 -1
- package/dist/base/sources/index.js +5 -2
- package/dist/{chunk-R6ZCSXKX.js → chunk-23MAWVOJ.js} +3 -3
- package/dist/{chunk-MS3WPRJR.js → chunk-3REMCHSS.js} +6 -6
- package/dist/chunk-3REMCHSS.js.map +1 -0
- package/dist/{chunk-CEVNQ74M.js → chunk-3YGXPUHW.js} +2 -2
- package/dist/{chunk-CEVNQ74M.js.map → chunk-3YGXPUHW.js.map} +1 -1
- package/dist/{chunk-6ZLCPUXS.js → chunk-46X2EFQH.js} +15 -4
- package/dist/chunk-46X2EFQH.js.map +1 -0
- package/dist/{chunk-NY2PYHNC.js → chunk-5UY3PNFY.js} +12 -5
- package/dist/chunk-5UY3PNFY.js.map +1 -0
- package/dist/{chunk-FQSQONOU.js → chunk-65OM4XLQ.js} +49 -3
- package/dist/chunk-65OM4XLQ.js.map +1 -0
- package/dist/{chunk-3PSLNJDU.js → chunk-6DQYBIHW.js} +314 -49
- package/dist/chunk-6DQYBIHW.js.map +1 -0
- package/dist/{chunk-LDCSZ72P.js → chunk-6YBER5UP.js} +3 -3
- package/dist/{chunk-LDCSZ72P.js.map → chunk-6YBER5UP.js.map} +1 -1
- package/dist/{chunk-3O3NKZJW.js → chunk-7T7WLEPM.js} +24 -3
- package/dist/chunk-7T7WLEPM.js.map +1 -0
- package/dist/{chunk-PKPO3JTZ.js → chunk-AQAKDE7F.js} +29 -11
- package/dist/chunk-AQAKDE7F.js.map +1 -0
- package/dist/{chunk-6MRSX3YK.js → chunk-B5Y5GPD5.js} +2 -2
- package/dist/{chunk-BXGZFGZ4.js → chunk-C5QD5DQX.js} +22 -1
- package/dist/chunk-C5QD5DQX.js.map +1 -0
- package/dist/{chunk-4XCHZRUJ.js → chunk-D5YGR4TP.js} +58 -7
- package/dist/chunk-D5YGR4TP.js.map +1 -0
- package/dist/{chunk-NPRP3MCV.js → chunk-DHDCOOJU.js} +2 -2
- package/dist/chunk-DHDCOOJU.js.map +1 -0
- package/dist/{chunk-VP3TIUDF.js → chunk-DVTDF5OI.js} +2 -2
- package/dist/{chunk-OXD5LFQP.js → chunk-G7H6PN7P.js} +2 -2
- package/dist/{chunk-EL5VHUGK.js → chunk-GGKHHG5Y.js} +32 -18
- package/dist/chunk-GGKHHG5Y.js.map +1 -0
- package/dist/{chunk-446I4EGD.js → chunk-J5TBZFBD.js} +2 -2
- package/dist/{chunk-7AVQIGF6.js → chunk-K4ZYJ4EM.js} +554 -460
- package/dist/chunk-K4ZYJ4EM.js.map +1 -0
- package/dist/{chunk-QFE5BQH7.js → chunk-LTSI7ULC.js} +2 -2
- package/dist/{chunk-5GVURVIG.js → chunk-MMHGYX44.js} +12 -2
- package/dist/{chunk-5GVURVIG.js.map → chunk-MMHGYX44.js.map} +1 -1
- package/dist/{chunk-KRFGO5QH.js → chunk-MQMTRKY3.js} +118 -43
- package/dist/chunk-MQMTRKY3.js.map +1 -0
- package/dist/{chunk-42FQ27MQ.js → chunk-MTODGQBR.js} +44 -179
- package/dist/chunk-MTODGQBR.js.map +1 -0
- package/dist/{chunk-FVINAAKA.js → chunk-NBK6QQMG.js} +14 -13
- package/dist/{chunk-FVINAAKA.js.map → chunk-NBK6QQMG.js.map} +1 -1
- package/dist/{chunk-KNU73RZW.js → chunk-NSA5K5G2.js} +2 -2
- package/dist/{chunk-MLTPJMH6.js → chunk-QQYULEZL.js} +2 -2
- package/dist/chunk-QSW4DFKE.js +31 -0
- package/dist/chunk-QSW4DFKE.js.map +1 -0
- package/dist/{chunk-VAZXUK6G.js → chunk-SUNCHMML.js} +2 -2
- package/dist/{chunk-EP4WVQLX.js → chunk-T2U6N3FV.js} +6 -6
- package/dist/{chunk-T7SP3EYR.js → chunk-T5URUIIY.js} +33 -24
- package/dist/chunk-T5URUIIY.js.map +1 -0
- package/dist/{chunk-VNXAF2KE.js → chunk-TPTZZV25.js} +6 -6
- package/dist/chunk-TPTZZV25.js.map +1 -0
- package/dist/{chunk-IOJDYUA7.js → chunk-V46JWFGV.js} +6 -5
- package/dist/chunk-V46JWFGV.js.map +1 -0
- package/dist/{chunk-WGDEBIP4.js → chunk-X6ESZDR6.js} +5 -6
- package/dist/chunk-X6ESZDR6.js.map +1 -0
- package/dist/{chunk-N65E26UL.js → chunk-XEWV254I.js} +2 -2
- package/dist/{chunk-N65E26UL.js.map → chunk-XEWV254I.js.map} +1 -1
- package/dist/{chunk-PTWADEH3.js → chunk-YBJVKMTM.js} +34 -14
- package/dist/chunk-YBJVKMTM.js.map +1 -0
- package/dist/{chunk-DDTS7F5O.js → chunk-ZW32BPXV.js} +12 -3
- package/dist/chunk-ZW32BPXV.js.map +1 -0
- package/dist/compat/index.cjs +51 -4
- package/dist/compat/index.cjs.map +1 -1
- package/dist/compat/index.d.cts +1 -1
- package/dist/compat/index.d.ts +1 -1
- package/dist/compat/index.js +6 -6
- package/dist/compat/nestjs/index.cjs +51 -4
- package/dist/compat/nestjs/index.cjs.map +1 -1
- package/dist/compat/nestjs/index.d.cts +1 -1
- package/dist/compat/nestjs/index.d.ts +1 -1
- package/dist/compat/nestjs/index.js +3 -3
- package/dist/{fallback-Bx46zqky.d.cts → fallback-BROR6ZhO.d.cts} +1 -1
- package/dist/{fallback-pIWW8A2d.d.ts → fallback-DO80aM_3.d.ts} +1 -1
- package/dist/{index-B_p8tnvf.d.cts → index-D1z3XcF9.d.cts} +1 -0
- package/dist/{index-_HDSmPyp.d.ts → index-DZ6yua0Q.d.ts} +1 -0
- package/dist/index.cjs +2215 -1676
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -10
- package/dist/index.d.ts +10 -10
- package/dist/index.js +169 -146
- package/dist/index.js.map +1 -1
- package/dist/presets/ai/index.cjs +46 -0
- package/dist/presets/ai/index.cjs.map +1 -1
- package/dist/presets/ai/index.js +12 -12
- package/dist/presets/harness/index.cjs +130 -18
- package/dist/presets/harness/index.cjs.map +1 -1
- package/dist/presets/harness/index.d.cts +15 -5
- package/dist/presets/harness/index.d.ts +15 -5
- package/dist/presets/harness/index.js +22 -22
- package/dist/presets/index.cjs +222 -53
- package/dist/presets/index.cjs.map +1 -1
- package/dist/presets/index.d.cts +2 -2
- package/dist/presets/index.d.ts +2 -2
- package/dist/presets/index.js +45 -45
- package/dist/presets/inspect/index.cjs +63 -14
- package/dist/presets/inspect/index.cjs.map +1 -1
- package/dist/presets/inspect/index.d.cts +1 -1
- package/dist/presets/inspect/index.d.ts +1 -1
- package/dist/presets/inspect/index.js +6 -6
- package/dist/presets/resilience/index.cjs +29 -21
- package/dist/presets/resilience/index.cjs.map +1 -1
- package/dist/presets/resilience/index.d.cts +12 -8
- package/dist/presets/resilience/index.d.ts +12 -8
- package/dist/presets/resilience/index.js +3 -3
- package/dist/{rate-limiter-DpVbSYdH.d.cts → rate-limiter-DC26FM8J.d.cts} +10 -1
- package/dist/{rate-limiter-CEALq4N1.d.ts → rate-limiter-DyWpwpQP.d.ts} +10 -1
- package/dist/{reactive-layout-fswlBUvX.d.ts → reactive-layout-BBBWH0V_.d.cts} +85 -4
- package/dist/{reactive-layout-fswlBUvX.d.cts → reactive-layout-BBBWH0V_.d.ts} +85 -4
- package/dist/solutions/index.cjs +168 -47
- package/dist/solutions/index.cjs.map +1 -1
- package/dist/solutions/index.d.cts +2 -2
- package/dist/solutions/index.d.ts +2 -2
- package/dist/solutions/index.js +28 -28
- package/dist/{spawnable-5mDY501F.d.cts → spawnable-B2IlW60f.d.cts} +23 -2
- package/dist/{spawnable-D3lR0oQu.d.ts → spawnable-tttFz2Nh.d.ts} +23 -2
- package/dist/testing/index.cjs +94 -0
- package/dist/testing/index.cjs.map +1 -0
- package/dist/testing/index.d.cts +59 -0
- package/dist/testing/index.d.ts +59 -0
- package/dist/testing/index.js +73 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/utils/ai/browser.cjs.map +1 -1
- package/dist/utils/ai/browser.d.cts +2 -2
- package/dist/utils/ai/browser.d.ts +2 -2
- package/dist/utils/ai/browser.js +6 -6
- package/dist/utils/ai/browser.js.map +1 -1
- package/dist/utils/ai/index.cjs +250 -166
- package/dist/utils/ai/index.cjs.map +1 -1
- package/dist/utils/ai/index.d.cts +108 -12
- package/dist/utils/ai/index.d.ts +108 -12
- package/dist/utils/ai/index.js +21 -19
- package/dist/utils/ai/node.cjs.map +1 -1
- package/dist/utils/ai/node.d.cts +5 -5
- package/dist/utils/ai/node.d.ts +5 -5
- package/dist/utils/ai/node.js +2 -2
- package/dist/utils/ai/node.js.map +1 -1
- package/dist/utils/cqrs/index.cjs +29 -3
- package/dist/utils/cqrs/index.cjs.map +1 -1
- package/dist/utils/cqrs/index.d.cts +12 -7
- package/dist/utils/cqrs/index.d.ts +12 -7
- package/dist/utils/cqrs/index.js +2 -2
- package/dist/utils/demo-shell/index.cjs +45 -19
- package/dist/utils/demo-shell/index.cjs.map +1 -1
- package/dist/utils/demo-shell/index.d.cts +1 -1
- package/dist/utils/demo-shell/index.d.ts +1 -1
- package/dist/utils/demo-shell/index.js +2 -2
- package/dist/utils/domain-templates/index.cjs.map +1 -1
- package/dist/utils/domain-templates/index.js +3 -3
- package/dist/utils/graphspec/index.cjs.map +1 -1
- package/dist/utils/graphspec/index.js +3 -3
- package/dist/utils/index.cjs +1642 -1225
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.d.cts +7 -7
- package/dist/utils/index.d.ts +7 -7
- package/dist/utils/index.js +72 -54
- package/dist/utils/inspect/index.cjs +52 -4
- package/dist/utils/inspect/index.cjs.map +1 -1
- package/dist/utils/inspect/index.d.cts +32 -3
- package/dist/utils/inspect/index.d.ts +32 -3
- package/dist/utils/inspect/index.js +4 -4
- package/dist/utils/job-queue/index.cjs +46 -9
- package/dist/utils/job-queue/index.cjs.map +1 -1
- package/dist/utils/job-queue/index.d.cts +33 -3
- package/dist/utils/job-queue/index.d.ts +33 -3
- package/dist/utils/job-queue/index.js +2 -2
- package/dist/utils/memory/index.cjs +556 -462
- package/dist/utils/memory/index.cjs.map +1 -1
- package/dist/utils/memory/index.d.cts +203 -24
- package/dist/utils/memory/index.d.ts +203 -24
- package/dist/utils/memory/index.js +10 -2
- package/dist/utils/messaging/index.cjs.map +1 -1
- package/dist/utils/messaging/index.d.cts +4 -3
- package/dist/utils/messaging/index.d.ts +4 -3
- package/dist/utils/messaging/index.js +2 -2
- package/dist/utils/orchestration/index.cjs +9 -0
- package/dist/utils/orchestration/index.cjs.map +1 -1
- package/dist/utils/orchestration/index.js +3 -3
- package/dist/utils/process/index.cjs +32 -2
- package/dist/utils/process/index.cjs.map +1 -1
- package/dist/utils/process/index.d.cts +4 -3
- package/dist/utils/process/index.d.ts +4 -3
- package/dist/utils/process/index.js +2 -2
- package/dist/utils/reactive-layout/index.cjs +184 -55
- package/dist/utils/reactive-layout/index.cjs.map +1 -1
- package/dist/utils/reactive-layout/index.d.cts +128 -3
- package/dist/utils/reactive-layout/index.d.ts +128 -3
- package/dist/utils/reactive-layout/index.js +16 -8
- package/dist/utils/reduction/index.cjs.map +1 -1
- package/dist/utils/reduction/index.js +2 -2
- package/dist/utils/resilience/index.cjs +29 -20
- package/dist/utils/resilience/index.cjs.map +1 -1
- package/dist/utils/resilience/index.d.cts +1 -1
- package/dist/utils/resilience/index.d.ts +1 -1
- package/dist/utils/resilience/index.js +2 -2
- package/dist/utils/surface/index.cjs.map +1 -1
- package/dist/utils/surface/index.js +4 -4
- package/package.json +15 -3
- package/dist/chunk-3O3NKZJW.js.map +0 -1
- package/dist/chunk-3PSLNJDU.js.map +0 -1
- package/dist/chunk-42FQ27MQ.js.map +0 -1
- package/dist/chunk-4XCHZRUJ.js.map +0 -1
- package/dist/chunk-6ZLCPUXS.js.map +0 -1
- package/dist/chunk-7AVQIGF6.js.map +0 -1
- package/dist/chunk-BXGZFGZ4.js.map +0 -1
- package/dist/chunk-DDTS7F5O.js.map +0 -1
- package/dist/chunk-EL5VHUGK.js.map +0 -1
- package/dist/chunk-FQSQONOU.js.map +0 -1
- package/dist/chunk-IOJDYUA7.js.map +0 -1
- package/dist/chunk-KRFGO5QH.js.map +0 -1
- package/dist/chunk-MS3WPRJR.js.map +0 -1
- package/dist/chunk-NPRP3MCV.js.map +0 -1
- package/dist/chunk-NY2PYHNC.js.map +0 -1
- package/dist/chunk-PKPO3JTZ.js.map +0 -1
- package/dist/chunk-PTWADEH3.js.map +0 -1
- package/dist/chunk-T7SP3EYR.js.map +0 -1
- package/dist/chunk-VNXAF2KE.js.map +0 -1
- package/dist/chunk-W2BOPXTI.js +0 -1
- package/dist/chunk-W2BOPXTI.js.map +0 -1
- package/dist/chunk-WGDEBIP4.js.map +0 -1
- /package/dist/{chunk-R6ZCSXKX.js.map → chunk-23MAWVOJ.js.map} +0 -0
- /package/dist/{chunk-6MRSX3YK.js.map → chunk-B5Y5GPD5.js.map} +0 -0
- /package/dist/{chunk-VP3TIUDF.js.map → chunk-DVTDF5OI.js.map} +0 -0
- /package/dist/{chunk-OXD5LFQP.js.map → chunk-G7H6PN7P.js.map} +0 -0
- /package/dist/{chunk-446I4EGD.js.map → chunk-J5TBZFBD.js.map} +0 -0
- /package/dist/{chunk-QFE5BQH7.js.map → chunk-LTSI7ULC.js.map} +0 -0
- /package/dist/{chunk-KNU73RZW.js.map → chunk-NSA5K5G2.js.map} +0 -0
- /package/dist/{chunk-MLTPJMH6.js.map → chunk-QQYULEZL.js.map} +0 -0
- /package/dist/{chunk-VAZXUK6G.js.map → chunk-SUNCHMML.js.map} +0 -0
- /package/dist/{chunk-EP4WVQLX.js.map → chunk-T2U6N3FV.js.map} +0 -0
|
@@ -173,6 +173,16 @@ interface FactStoreAuditRecord extends BaseAuditRecord {
|
|
|
173
173
|
readonly action: "ingest" | "invalidate" | "outcome" | "consolidate" | "decay" | "overflow";
|
|
174
174
|
readonly id?: FactId;
|
|
175
175
|
readonly reason?: CascadeReason;
|
|
176
|
+
/**
|
|
177
|
+
* Number of facts whose state actually changed in a batch action
|
|
178
|
+
* (post-filter — excludes no-op / non-finite / resurrection-guard
|
|
179
|
+
* skips; equals the length of the emitted `decay_processor` value
|
|
180
|
+
* array). Populated for `"decay"` (a per-tick batch over many facts
|
|
181
|
+
* with no single `id` — the bare `{action,t_ns,seq}` record was opaque
|
|
182
|
+
* to audit-log forensics). Absent for single-fact actions (`id`
|
|
183
|
+
* carries those).
|
|
184
|
+
*/
|
|
185
|
+
readonly count?: number;
|
|
176
186
|
}
|
|
177
187
|
interface ReactiveFactStoreConfig<T> {
|
|
178
188
|
readonly extractDependencies: (f: MemoryFragment<T>) => readonly FactId[];
|
|
@@ -306,29 +316,6 @@ interface ReactiveFactStoreConfig<T> {
|
|
|
306
316
|
*/
|
|
307
317
|
readonly recordIngest?: boolean;
|
|
308
318
|
}
|
|
309
|
-
interface ReactiveFactStoreGraph<T> extends Graph {
|
|
310
|
-
/** Per-shard `state<FactStore<T>>` nodes (length = shard count). */
|
|
311
|
-
readonly shards: readonly Node<FactStore<T>>[];
|
|
312
|
-
/** Unified read view across all shards (derived). */
|
|
313
|
-
readonly factStore: Node<FactStore<T>>;
|
|
314
|
-
readonly dependentsIndex: Node<DependentsIndex>;
|
|
315
|
-
readonly answer: Node<MemoryAnswer<T> | null>;
|
|
316
|
-
readonly cascade: Node<readonly CascadeEvent[]>;
|
|
317
|
-
readonly cascadeOverflow: Node<CascadeOverflow | null>;
|
|
318
|
-
readonly review: Node<ReviewRequest | null>;
|
|
319
|
-
readonly consolidated: Node<readonly MemoryFragment<T>[]>;
|
|
320
|
-
readonly events: ReactiveLogBundle<FactStoreAuditRecord>;
|
|
321
|
-
/**
|
|
322
|
-
* Payload-carrying, replayable log of every committed fragment. Present iff
|
|
323
|
-
* {@link ReactiveFactStoreConfig.recordIngest} is `true`. Unlike
|
|
324
|
-
* {@link ReactiveFactStoreGraph.events} (action-only audit), each entry is
|
|
325
|
-
* the full {@link MemoryFragment} — `attachStorage` it for a durable,
|
|
326
|
-
* replayable projection source (see `recordIngest` docs for the recipe).
|
|
327
|
-
*/
|
|
328
|
-
readonly ingestLog?: ReactiveLogBundle<MemoryFragment<T>>;
|
|
329
|
-
/** Reactive read: a single fact by id (SENTINEL until the fact exists). */
|
|
330
|
-
itemNode(id: FactId): Node<MemoryFragment<T> | undefined>;
|
|
331
|
-
}
|
|
332
319
|
/**
|
|
333
320
|
* Build a static-topology reactive fact store (DS-14.7 architecture C).
|
|
334
321
|
*
|
|
@@ -362,6 +349,38 @@ interface ReactiveFactStoreGraph<T> extends Graph {
|
|
|
362
349
|
*
|
|
363
350
|
* @category memory
|
|
364
351
|
*/
|
|
352
|
+
declare class ReactiveFactStoreGraph<T> extends Graph {
|
|
353
|
+
/** Per-shard `state<FactStore<T>>` nodes (length = shard count). */
|
|
354
|
+
readonly shards: readonly Node<FactStore<T>>[];
|
|
355
|
+
/** Unified read view across all shards (derived). */
|
|
356
|
+
readonly factStore: Node<FactStore<T>>;
|
|
357
|
+
readonly dependentsIndex: Node<DependentsIndex>;
|
|
358
|
+
readonly answer: Node<MemoryAnswer<T> | null>;
|
|
359
|
+
readonly cascade: Node<readonly CascadeEvent[]>;
|
|
360
|
+
readonly cascadeOverflow: Node<CascadeOverflow | null>;
|
|
361
|
+
readonly review: Node<ReviewRequest | null>;
|
|
362
|
+
readonly consolidated: Node<readonly MemoryFragment<T>[]>;
|
|
363
|
+
readonly events: ReactiveLogBundle<FactStoreAuditRecord>;
|
|
364
|
+
/**
|
|
365
|
+
* Payload-carrying, replayable log of every committed fragment. Present iff
|
|
366
|
+
* {@link ReactiveFactStoreConfig.recordIngest} is `true`. Unlike
|
|
367
|
+
* {@link ReactiveFactStoreGraph.events} (action-only audit), each entry is
|
|
368
|
+
* the full {@link MemoryFragment} — `attachStorage` it for a durable,
|
|
369
|
+
* replayable projection source (see `recordIngest` docs for the recipe).
|
|
370
|
+
*/
|
|
371
|
+
readonly ingestLog?: ReactiveLogBundle<MemoryFragment<T>>;
|
|
372
|
+
constructor(config: ReactiveFactStoreConfig<T>);
|
|
373
|
+
/** Reactive read: a single fact by id (SENTINEL until the fact exists). */
|
|
374
|
+
itemNode(id: FactId): Node<MemoryFragment<T> | undefined>;
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Build a static-topology reactive fact store (DS-14.7 architecture C).
|
|
378
|
+
*
|
|
379
|
+
* Thin factory over {@link ReactiveFactStoreGraph} — see that class for the
|
|
380
|
+
* full topology / locked-decision docs and the `instanceof`-narrowable type.
|
|
381
|
+
*
|
|
382
|
+
* @category memory
|
|
383
|
+
*/
|
|
365
384
|
declare function reactiveFactStore<T>(config: ReactiveFactStoreConfig<T>): ReactiveFactStoreGraph<T>;
|
|
366
385
|
|
|
367
386
|
/**
|
|
@@ -954,6 +973,166 @@ interface ShardByTenantConfig<T> {
|
|
|
954
973
|
*/
|
|
955
974
|
declare function shardByTenant<T>(tenantOf: (f: MemoryFragment<T>) => string, opts?: ShardByTenantOptions): ShardByTenantConfig<T>;
|
|
956
975
|
|
|
976
|
+
/**
|
|
977
|
+
* `simpleFactStore()` — the 80%-case ergonomic wrapper over
|
|
978
|
+
* {@link reactiveFactStore} / {@link persistentReactiveFactStore}
|
|
979
|
+
* (DS-14.7 follow-up #2; design LOCKED 2026-05-17 `/dev-dispatch` Q-walk,
|
|
980
|
+
* Q1–Q6 + sub-decisions resolved).
|
|
981
|
+
*
|
|
982
|
+
* Closes the gap where a consumer wanting durable agent memory had to
|
|
983
|
+
* hand-compose: an `ingest` source + `extractDependencies` + (optionally) a
|
|
984
|
+
* `StorageBackend` + decay/consolidation recipes + the
|
|
985
|
+
* `BigInt(monotonicNs())` fragment boilerplate. `simpleFactStore` owns all
|
|
986
|
+
* of that and exposes a single ergonomic `remember(id, payload, opts?)`.
|
|
987
|
+
*
|
|
988
|
+
* **Q-walk locks (canonical: `docs/optimizations.md` DS-14.7 follow-up #2):**
|
|
989
|
+
* - **Q1** — `extractDependencies` defaults to `() => []` (flat store;
|
|
990
|
+
* cascade inert by default — dependency-tracking is opt-in).
|
|
991
|
+
* - **Q2** — single factory, **optional `storage`**: present → wraps
|
|
992
|
+
* {@link persistentReactiveFactStore} (durable, event-sourced); absent →
|
|
993
|
+
* in-memory {@link reactiveFactStore}.
|
|
994
|
+
* - **Q3** — the wrapper **owns** the internal `ingest` source and exposes
|
|
995
|
+
* {@link SimpleFactStoreGraph.remember}. `remember` `.emit`s into the
|
|
996
|
+
* owned leaf source — this is the *sanctioned* external push that the
|
|
997
|
+
* `reactiveFactStore` ingest contract documents (same shape as the
|
|
998
|
+
* `decay`/replay recipes' `.emit`-into-source), **not** a spec-§5.9
|
|
999
|
+
* imperative trigger: it feeds DATA into a source node, it does not
|
|
1000
|
+
* bypass topology for control flow. Reactive reads (`answer` / `review` /
|
|
1001
|
+
* `events`) stay the canonical observation surface.
|
|
1002
|
+
* - **Q4** — auto-wire **default recipes** with internal `fromTimer`
|
|
1003
|
+
* cadences (batteries-included; user-blessed 2026-05-17). `decay` is
|
|
1004
|
+
* generically meaningful (confidence forgetting needs no domain
|
|
1005
|
+
* knowledge) → **ON by default** with conservative defaults
|
|
1006
|
+
* ({@link DEFAULT_DECAY_HALF_LIFE_NS} / {@link DEFAULT_DECAY_PERIOD_MS}),
|
|
1007
|
+
* tunable or `false` to disable. `consolidate` is **domain-bound** —
|
|
1008
|
+
* {@link consolidationRem} *requires* a `summarize` (there is no generic
|
|
1009
|
+
* default; an arbitrary `T` cannot be summarized blindly), so it is wired
|
|
1010
|
+
* **iff** the caller supplies `opts.consolidate`. This consolidation
|
|
1011
|
+
* asymmetry is dictated by the recipe's own required contract, not an
|
|
1012
|
+
* autonomous downgrade of the Q4 lock.
|
|
1013
|
+
* - **Q5** — minimal input: `remember(id, payload, { tags? })` auto-fills
|
|
1014
|
+
* `t_ns = BigInt(monotonicNs())` (per the {@link MemoryFragment.t_ns}
|
|
1015
|
+
* contract + the clock-return-type rule — `monotonicNs()` is `number`,
|
|
1016
|
+
* the `BigInt(...)` wrap is load-bearing) and `confidence = 1`.
|
|
1017
|
+
* - **Q6** — **wraps** the existing factories (not a parallel impl).
|
|
1018
|
+
*
|
|
1019
|
+
* Presentation-only (`@graphrefly/graphrefly`, `utils/memory` barrel),
|
|
1020
|
+
* universal tier (`fromTimer` only, no `node:*`/DOM — the optional
|
|
1021
|
+
* `StorageBackend` impl's tier is the *caller's* concern, forwarded
|
|
1022
|
+
* verbatim, exactly as {@link persistentReactiveFactStore} does).
|
|
1023
|
+
*
|
|
1024
|
+
* @module
|
|
1025
|
+
*/
|
|
1026
|
+
|
|
1027
|
+
/**
|
|
1028
|
+
* Default exponential-decay half-life: **7 days** in nanoseconds. Confidence
|
|
1029
|
+
* halves once per week of fact age — gentle forgetting suitable for the
|
|
1030
|
+
* 80%-case agent memory. Override via `opts.decay.halfLifeNs`.
|
|
1031
|
+
*/
|
|
1032
|
+
declare const DEFAULT_DECAY_HALF_LIFE_NS = 604800000000000n;
|
|
1033
|
+
/**
|
|
1034
|
+
* Default decay tick cadence: **1 hour** (ms). How often the forgetting pass
|
|
1035
|
+
* runs. Override via `opts.decay.periodMs`.
|
|
1036
|
+
*/
|
|
1037
|
+
declare const DEFAULT_DECAY_PERIOD_MS = 3600000;
|
|
1038
|
+
/** Per-fact override fields accepted by {@link SimpleFactStoreGraph.remember}. */
|
|
1039
|
+
interface RememberOptions {
|
|
1040
|
+
/** Tags. Default `[]`. */
|
|
1041
|
+
readonly tags?: readonly string[];
|
|
1042
|
+
/** Dependency edges (fact IDs this fact derives from). Default `[]`. */
|
|
1043
|
+
readonly sources?: readonly FactId[];
|
|
1044
|
+
/** Confidence 0..1. Default `1`. */
|
|
1045
|
+
readonly confidence?: number;
|
|
1046
|
+
/** Valid-time end — set to obsolete a fact (MEME L3 lever). */
|
|
1047
|
+
readonly validTo?: bigint;
|
|
1048
|
+
/** Valid-time start — `undefined` = unbounded past. */
|
|
1049
|
+
readonly validFrom?: bigint;
|
|
1050
|
+
/** Free-form provenance string. */
|
|
1051
|
+
readonly provenance?: string;
|
|
1052
|
+
}
|
|
1053
|
+
interface SimpleFactStoreOptions<T> {
|
|
1054
|
+
/**
|
|
1055
|
+
* Durable backing. Present → delegates to
|
|
1056
|
+
* {@link persistentReactiveFactStore} (event-sourced, replay-on-start,
|
|
1057
|
+
* substrate-owned cursor). Absent → in-memory {@link reactiveFactStore}.
|
|
1058
|
+
* The backend's runtime tier (node / browser) is the caller's concern —
|
|
1059
|
+
* forwarded verbatim.
|
|
1060
|
+
*/
|
|
1061
|
+
readonly storage?: StorageBackend;
|
|
1062
|
+
/**
|
|
1063
|
+
* Cascade dependency extractor. **Default `() => []`** — flat store, no
|
|
1064
|
+
* cascade. Supply to opt into MEME L2 cascade invalidation.
|
|
1065
|
+
*/
|
|
1066
|
+
readonly extractDependencies?: (f: MemoryFragment<T>) => readonly FactId[];
|
|
1067
|
+
/**
|
|
1068
|
+
* Exponential-decay forgetting. **Default: ON** with
|
|
1069
|
+
* {@link DEFAULT_DECAY_HALF_LIFE_NS} / {@link DEFAULT_DECAY_PERIOD_MS}.
|
|
1070
|
+
* Pass a partial to tune; pass `false` to disable. Wires an internal
|
|
1071
|
+
* `fromTimer` (the user-blessed batteries-included cadence).
|
|
1072
|
+
*/
|
|
1073
|
+
readonly decay?: false | Partial<DecayExponentialOptions>;
|
|
1074
|
+
/**
|
|
1075
|
+
* REM-replay consolidation. **Domain-bound** — requires a `summarize`
|
|
1076
|
+
* (no generic default exists). Supply the full
|
|
1077
|
+
* {@link ConsolidationRemOptions} to enable; omit to disable. Wires an
|
|
1078
|
+
* internal `fromTimer` at `consolidate.periodMs`.
|
|
1079
|
+
*/
|
|
1080
|
+
readonly consolidate?: ConsolidationRemOptions<T>;
|
|
1081
|
+
/** Persistent-only: durable bucket name. Default `fact_store_ingest`. */
|
|
1082
|
+
readonly persistName?: string;
|
|
1083
|
+
/** Persistent-only: durable codec. Default `bigintJsonCodecFor`. */
|
|
1084
|
+
readonly codec?: Codec<readonly MemoryFragment<T>[]>;
|
|
1085
|
+
}
|
|
1086
|
+
/**
|
|
1087
|
+
* The ergonomic write added to every `simpleFactStore` graph. Normalizes to a
|
|
1088
|
+
* {@link MemoryFragment} (auto `t_ns = BigInt(monotonicNs())`,
|
|
1089
|
+
* `confidence = 1`, `tags`/`sources` = `[]`) and `.emit`s it into the owned
|
|
1090
|
+
* `ingest` source. Re-`remember`ing an existing `id` is the MEME L1
|
|
1091
|
+
* direct-replace lever; set `opts.validTo` to obsolete (MEME L3).
|
|
1092
|
+
*/
|
|
1093
|
+
type SimpleFactStoreRemember<T> = (id: FactId, payload: T, opts?: RememberOptions) => void;
|
|
1094
|
+
/**
|
|
1095
|
+
* In-memory `simpleFactStore` graph (no `storage`) augmented with
|
|
1096
|
+
* {@link SimpleFactStoreRemember}.
|
|
1097
|
+
*/
|
|
1098
|
+
interface SimpleFactStoreGraph<T> extends ReactiveFactStoreGraph<T> {
|
|
1099
|
+
remember: SimpleFactStoreRemember<T>;
|
|
1100
|
+
}
|
|
1101
|
+
/**
|
|
1102
|
+
* Durable (`storage`-backed) `simpleFactStore` graph — the **type-honest**
|
|
1103
|
+
* persistent surface. EC-LOW-1 (`/qa` 2026-05-17): the `storage` overload
|
|
1104
|
+
* returns this so `position` / `replayedCount` / `flush` / `tier` are typed
|
|
1105
|
+
* without a hand-cast (the durable path is the headline 80%-case).
|
|
1106
|
+
*/
|
|
1107
|
+
type PersistentSimpleFactStoreGraph<T> = PersistentReactiveFactStoreGraph<T> & {
|
|
1108
|
+
remember: SimpleFactStoreRemember<T>;
|
|
1109
|
+
};
|
|
1110
|
+
/**
|
|
1111
|
+
* Build a fact store with sensible defaults and a one-call `remember`.
|
|
1112
|
+
*
|
|
1113
|
+
* @example
|
|
1114
|
+
* ```ts
|
|
1115
|
+
* import { simpleFactStore } from "@graphrefly/graphrefly/utils/memory";
|
|
1116
|
+
* import { memoryBackend } from "@graphrefly/graphrefly/extra";
|
|
1117
|
+
*
|
|
1118
|
+
* const mem = simpleFactStore<string>(); // in-memory, decay ON
|
|
1119
|
+
* mem.remember("user:lang", "TypeScript", { tags: ["pref"] });
|
|
1120
|
+
* mem.answer.subscribe((a) => console.log(a)); // reactive read
|
|
1121
|
+
*
|
|
1122
|
+
* // Durable: the `storage` overload returns the typed persistent surface
|
|
1123
|
+
* // (no hand-cast needed for `position` / `flush`).
|
|
1124
|
+
* const durable = simpleFactStore<string>({ storage: memoryBackend() });
|
|
1125
|
+
* durable.remember("k", "v");
|
|
1126
|
+
* await durable.flush();
|
|
1127
|
+
* ```
|
|
1128
|
+
*
|
|
1129
|
+
* @category memory
|
|
1130
|
+
*/
|
|
1131
|
+
declare function simpleFactStore<T>(opts: SimpleFactStoreOptions<T> & {
|
|
1132
|
+
storage: StorageBackend;
|
|
1133
|
+
}): PersistentSimpleFactStoreGraph<T>;
|
|
1134
|
+
declare function simpleFactStore<T>(opts?: SimpleFactStoreOptions<T>): SimpleFactStoreGraph<T>;
|
|
1135
|
+
|
|
957
1136
|
/**
|
|
958
1137
|
* Memory patterns (roadmap §4.3) — public-face Phase-4 primitives audited under
|
|
959
1138
|
* `archive/docs/SESSION-public-face-blocks-review.md` (Wave A, locked 2026-04-25).
|
|
@@ -1295,4 +1474,4 @@ type KnowledgeGraph<TEntity, TRelation extends string = string> = Graph & {
|
|
|
1295
1474
|
*/
|
|
1296
1475
|
declare function knowledgeGraph<TEntity, TRelation extends string = string>(name: string, opts?: KnowledgeGraphOptions): KnowledgeGraph<TEntity, TRelation>;
|
|
1297
1476
|
|
|
1298
|
-
export { type AdmissionFilter, type AdmissionLlmJudgeOptions, type BitemporalQueryOptions, type CascadeEvent, type CascadeOverflow, type CascadeReason, type CollectionAuditRecord, type CollectionEntry, type CollectionGraph, type CollectionOptions, type CollectionScoreFn, type ConsolidationRemConfig, type ConsolidationRemOptions, type DecayExponentialOptions, type DecayPolicy, type DependentsIndex, type FactId, type FactStore, type FactStoreAuditRecord, type HnswAdapter, type InfluenceAnalysis, type InfluenceAnalysisOptions, type InfluenceRow, type InvalidationTraceEntry, type InvalidationTracerOptions, type KnowledgeEdge, type KnowledgeGraph, type KnowledgeGraphAuditRecord, type KnowledgeGraphOptions, type MemoryAnswer, type MemoryFragment, type MemoryQuery, NodeOrValue, type OutcomeSignal, type PersistentReactiveFactStoreConfig, type PersistentReactiveFactStoreGraph, type RankedCollectionEntry, type ReactiveFactStoreConfig, type
|
|
1477
|
+
export { type AdmissionFilter, type AdmissionLlmJudgeOptions, type BitemporalQueryOptions, type CascadeEvent, type CascadeOverflow, type CascadeReason, type CollectionAuditRecord, type CollectionEntry, type CollectionGraph, type CollectionOptions, type CollectionScoreFn, type ConsolidationRemConfig, type ConsolidationRemOptions, DEFAULT_DECAY_HALF_LIFE_NS, DEFAULT_DECAY_PERIOD_MS, type DecayExponentialOptions, type DecayPolicy, type DependentsIndex, type FactId, type FactStore, type FactStoreAuditRecord, type HnswAdapter, type InfluenceAnalysis, type InfluenceAnalysisOptions, type InfluenceRow, type InvalidationTraceEntry, type InvalidationTracerOptions, type KnowledgeEdge, type KnowledgeGraph, type KnowledgeGraphAuditRecord, type KnowledgeGraphOptions, type MemoryAnswer, type MemoryFragment, type MemoryQuery, NodeOrValue, type OutcomeSignal, type PersistentReactiveFactStoreConfig, type PersistentReactiveFactStoreGraph, type RankedCollectionEntry, type ReactiveFactStoreConfig, ReactiveFactStoreGraph, type RememberOptions, type ReviewRequest, type ScoringByOutcomeOptions, type ScoringPolicy, type ShardByTenantConfig, type ShardByTenantOptions, type ShardKey, type SimpleFactStoreGraph, type SimpleFactStoreOptions, type StoreReadHandle, type VectorBackend, type VectorIndexAuditRecord, type VectorIndexGraph, type VectorIndexOptions, type VectorRecord, type VectorSearchResult, admissionLlmJudge, bitemporalQuery, collection, consolidationRem, cosineSimilarity, decayExponential, influenceAnalysis, invalidationTracer, knowledgeGraph, persistentReactiveFactStore, reactiveFactStore, scoringByOutcome, shardByTenant, simpleFactStore, vectorIndex };
|
|
@@ -173,6 +173,16 @@ interface FactStoreAuditRecord extends BaseAuditRecord {
|
|
|
173
173
|
readonly action: "ingest" | "invalidate" | "outcome" | "consolidate" | "decay" | "overflow";
|
|
174
174
|
readonly id?: FactId;
|
|
175
175
|
readonly reason?: CascadeReason;
|
|
176
|
+
/**
|
|
177
|
+
* Number of facts whose state actually changed in a batch action
|
|
178
|
+
* (post-filter — excludes no-op / non-finite / resurrection-guard
|
|
179
|
+
* skips; equals the length of the emitted `decay_processor` value
|
|
180
|
+
* array). Populated for `"decay"` (a per-tick batch over many facts
|
|
181
|
+
* with no single `id` — the bare `{action,t_ns,seq}` record was opaque
|
|
182
|
+
* to audit-log forensics). Absent for single-fact actions (`id`
|
|
183
|
+
* carries those).
|
|
184
|
+
*/
|
|
185
|
+
readonly count?: number;
|
|
176
186
|
}
|
|
177
187
|
interface ReactiveFactStoreConfig<T> {
|
|
178
188
|
readonly extractDependencies: (f: MemoryFragment<T>) => readonly FactId[];
|
|
@@ -306,29 +316,6 @@ interface ReactiveFactStoreConfig<T> {
|
|
|
306
316
|
*/
|
|
307
317
|
readonly recordIngest?: boolean;
|
|
308
318
|
}
|
|
309
|
-
interface ReactiveFactStoreGraph<T> extends Graph {
|
|
310
|
-
/** Per-shard `state<FactStore<T>>` nodes (length = shard count). */
|
|
311
|
-
readonly shards: readonly Node<FactStore<T>>[];
|
|
312
|
-
/** Unified read view across all shards (derived). */
|
|
313
|
-
readonly factStore: Node<FactStore<T>>;
|
|
314
|
-
readonly dependentsIndex: Node<DependentsIndex>;
|
|
315
|
-
readonly answer: Node<MemoryAnswer<T> | null>;
|
|
316
|
-
readonly cascade: Node<readonly CascadeEvent[]>;
|
|
317
|
-
readonly cascadeOverflow: Node<CascadeOverflow | null>;
|
|
318
|
-
readonly review: Node<ReviewRequest | null>;
|
|
319
|
-
readonly consolidated: Node<readonly MemoryFragment<T>[]>;
|
|
320
|
-
readonly events: ReactiveLogBundle<FactStoreAuditRecord>;
|
|
321
|
-
/**
|
|
322
|
-
* Payload-carrying, replayable log of every committed fragment. Present iff
|
|
323
|
-
* {@link ReactiveFactStoreConfig.recordIngest} is `true`. Unlike
|
|
324
|
-
* {@link ReactiveFactStoreGraph.events} (action-only audit), each entry is
|
|
325
|
-
* the full {@link MemoryFragment} — `attachStorage` it for a durable,
|
|
326
|
-
* replayable projection source (see `recordIngest` docs for the recipe).
|
|
327
|
-
*/
|
|
328
|
-
readonly ingestLog?: ReactiveLogBundle<MemoryFragment<T>>;
|
|
329
|
-
/** Reactive read: a single fact by id (SENTINEL until the fact exists). */
|
|
330
|
-
itemNode(id: FactId): Node<MemoryFragment<T> | undefined>;
|
|
331
|
-
}
|
|
332
319
|
/**
|
|
333
320
|
* Build a static-topology reactive fact store (DS-14.7 architecture C).
|
|
334
321
|
*
|
|
@@ -362,6 +349,38 @@ interface ReactiveFactStoreGraph<T> extends Graph {
|
|
|
362
349
|
*
|
|
363
350
|
* @category memory
|
|
364
351
|
*/
|
|
352
|
+
declare class ReactiveFactStoreGraph<T> extends Graph {
|
|
353
|
+
/** Per-shard `state<FactStore<T>>` nodes (length = shard count). */
|
|
354
|
+
readonly shards: readonly Node<FactStore<T>>[];
|
|
355
|
+
/** Unified read view across all shards (derived). */
|
|
356
|
+
readonly factStore: Node<FactStore<T>>;
|
|
357
|
+
readonly dependentsIndex: Node<DependentsIndex>;
|
|
358
|
+
readonly answer: Node<MemoryAnswer<T> | null>;
|
|
359
|
+
readonly cascade: Node<readonly CascadeEvent[]>;
|
|
360
|
+
readonly cascadeOverflow: Node<CascadeOverflow | null>;
|
|
361
|
+
readonly review: Node<ReviewRequest | null>;
|
|
362
|
+
readonly consolidated: Node<readonly MemoryFragment<T>[]>;
|
|
363
|
+
readonly events: ReactiveLogBundle<FactStoreAuditRecord>;
|
|
364
|
+
/**
|
|
365
|
+
* Payload-carrying, replayable log of every committed fragment. Present iff
|
|
366
|
+
* {@link ReactiveFactStoreConfig.recordIngest} is `true`. Unlike
|
|
367
|
+
* {@link ReactiveFactStoreGraph.events} (action-only audit), each entry is
|
|
368
|
+
* the full {@link MemoryFragment} — `attachStorage` it for a durable,
|
|
369
|
+
* replayable projection source (see `recordIngest` docs for the recipe).
|
|
370
|
+
*/
|
|
371
|
+
readonly ingestLog?: ReactiveLogBundle<MemoryFragment<T>>;
|
|
372
|
+
constructor(config: ReactiveFactStoreConfig<T>);
|
|
373
|
+
/** Reactive read: a single fact by id (SENTINEL until the fact exists). */
|
|
374
|
+
itemNode(id: FactId): Node<MemoryFragment<T> | undefined>;
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Build a static-topology reactive fact store (DS-14.7 architecture C).
|
|
378
|
+
*
|
|
379
|
+
* Thin factory over {@link ReactiveFactStoreGraph} — see that class for the
|
|
380
|
+
* full topology / locked-decision docs and the `instanceof`-narrowable type.
|
|
381
|
+
*
|
|
382
|
+
* @category memory
|
|
383
|
+
*/
|
|
365
384
|
declare function reactiveFactStore<T>(config: ReactiveFactStoreConfig<T>): ReactiveFactStoreGraph<T>;
|
|
366
385
|
|
|
367
386
|
/**
|
|
@@ -954,6 +973,166 @@ interface ShardByTenantConfig<T> {
|
|
|
954
973
|
*/
|
|
955
974
|
declare function shardByTenant<T>(tenantOf: (f: MemoryFragment<T>) => string, opts?: ShardByTenantOptions): ShardByTenantConfig<T>;
|
|
956
975
|
|
|
976
|
+
/**
|
|
977
|
+
* `simpleFactStore()` — the 80%-case ergonomic wrapper over
|
|
978
|
+
* {@link reactiveFactStore} / {@link persistentReactiveFactStore}
|
|
979
|
+
* (DS-14.7 follow-up #2; design LOCKED 2026-05-17 `/dev-dispatch` Q-walk,
|
|
980
|
+
* Q1–Q6 + sub-decisions resolved).
|
|
981
|
+
*
|
|
982
|
+
* Closes the gap where a consumer wanting durable agent memory had to
|
|
983
|
+
* hand-compose: an `ingest` source + `extractDependencies` + (optionally) a
|
|
984
|
+
* `StorageBackend` + decay/consolidation recipes + the
|
|
985
|
+
* `BigInt(monotonicNs())` fragment boilerplate. `simpleFactStore` owns all
|
|
986
|
+
* of that and exposes a single ergonomic `remember(id, payload, opts?)`.
|
|
987
|
+
*
|
|
988
|
+
* **Q-walk locks (canonical: `docs/optimizations.md` DS-14.7 follow-up #2):**
|
|
989
|
+
* - **Q1** — `extractDependencies` defaults to `() => []` (flat store;
|
|
990
|
+
* cascade inert by default — dependency-tracking is opt-in).
|
|
991
|
+
* - **Q2** — single factory, **optional `storage`**: present → wraps
|
|
992
|
+
* {@link persistentReactiveFactStore} (durable, event-sourced); absent →
|
|
993
|
+
* in-memory {@link reactiveFactStore}.
|
|
994
|
+
* - **Q3** — the wrapper **owns** the internal `ingest` source and exposes
|
|
995
|
+
* {@link SimpleFactStoreGraph.remember}. `remember` `.emit`s into the
|
|
996
|
+
* owned leaf source — this is the *sanctioned* external push that the
|
|
997
|
+
* `reactiveFactStore` ingest contract documents (same shape as the
|
|
998
|
+
* `decay`/replay recipes' `.emit`-into-source), **not** a spec-§5.9
|
|
999
|
+
* imperative trigger: it feeds DATA into a source node, it does not
|
|
1000
|
+
* bypass topology for control flow. Reactive reads (`answer` / `review` /
|
|
1001
|
+
* `events`) stay the canonical observation surface.
|
|
1002
|
+
* - **Q4** — auto-wire **default recipes** with internal `fromTimer`
|
|
1003
|
+
* cadences (batteries-included; user-blessed 2026-05-17). `decay` is
|
|
1004
|
+
* generically meaningful (confidence forgetting needs no domain
|
|
1005
|
+
* knowledge) → **ON by default** with conservative defaults
|
|
1006
|
+
* ({@link DEFAULT_DECAY_HALF_LIFE_NS} / {@link DEFAULT_DECAY_PERIOD_MS}),
|
|
1007
|
+
* tunable or `false` to disable. `consolidate` is **domain-bound** —
|
|
1008
|
+
* {@link consolidationRem} *requires* a `summarize` (there is no generic
|
|
1009
|
+
* default; an arbitrary `T` cannot be summarized blindly), so it is wired
|
|
1010
|
+
* **iff** the caller supplies `opts.consolidate`. This consolidation
|
|
1011
|
+
* asymmetry is dictated by the recipe's own required contract, not an
|
|
1012
|
+
* autonomous downgrade of the Q4 lock.
|
|
1013
|
+
* - **Q5** — minimal input: `remember(id, payload, { tags? })` auto-fills
|
|
1014
|
+
* `t_ns = BigInt(monotonicNs())` (per the {@link MemoryFragment.t_ns}
|
|
1015
|
+
* contract + the clock-return-type rule — `monotonicNs()` is `number`,
|
|
1016
|
+
* the `BigInt(...)` wrap is load-bearing) and `confidence = 1`.
|
|
1017
|
+
* - **Q6** — **wraps** the existing factories (not a parallel impl).
|
|
1018
|
+
*
|
|
1019
|
+
* Presentation-only (`@graphrefly/graphrefly`, `utils/memory` barrel),
|
|
1020
|
+
* universal tier (`fromTimer` only, no `node:*`/DOM — the optional
|
|
1021
|
+
* `StorageBackend` impl's tier is the *caller's* concern, forwarded
|
|
1022
|
+
* verbatim, exactly as {@link persistentReactiveFactStore} does).
|
|
1023
|
+
*
|
|
1024
|
+
* @module
|
|
1025
|
+
*/
|
|
1026
|
+
|
|
1027
|
+
/**
|
|
1028
|
+
* Default exponential-decay half-life: **7 days** in nanoseconds. Confidence
|
|
1029
|
+
* halves once per week of fact age — gentle forgetting suitable for the
|
|
1030
|
+
* 80%-case agent memory. Override via `opts.decay.halfLifeNs`.
|
|
1031
|
+
*/
|
|
1032
|
+
declare const DEFAULT_DECAY_HALF_LIFE_NS = 604800000000000n;
|
|
1033
|
+
/**
|
|
1034
|
+
* Default decay tick cadence: **1 hour** (ms). How often the forgetting pass
|
|
1035
|
+
* runs. Override via `opts.decay.periodMs`.
|
|
1036
|
+
*/
|
|
1037
|
+
declare const DEFAULT_DECAY_PERIOD_MS = 3600000;
|
|
1038
|
+
/** Per-fact override fields accepted by {@link SimpleFactStoreGraph.remember}. */
|
|
1039
|
+
interface RememberOptions {
|
|
1040
|
+
/** Tags. Default `[]`. */
|
|
1041
|
+
readonly tags?: readonly string[];
|
|
1042
|
+
/** Dependency edges (fact IDs this fact derives from). Default `[]`. */
|
|
1043
|
+
readonly sources?: readonly FactId[];
|
|
1044
|
+
/** Confidence 0..1. Default `1`. */
|
|
1045
|
+
readonly confidence?: number;
|
|
1046
|
+
/** Valid-time end — set to obsolete a fact (MEME L3 lever). */
|
|
1047
|
+
readonly validTo?: bigint;
|
|
1048
|
+
/** Valid-time start — `undefined` = unbounded past. */
|
|
1049
|
+
readonly validFrom?: bigint;
|
|
1050
|
+
/** Free-form provenance string. */
|
|
1051
|
+
readonly provenance?: string;
|
|
1052
|
+
}
|
|
1053
|
+
interface SimpleFactStoreOptions<T> {
|
|
1054
|
+
/**
|
|
1055
|
+
* Durable backing. Present → delegates to
|
|
1056
|
+
* {@link persistentReactiveFactStore} (event-sourced, replay-on-start,
|
|
1057
|
+
* substrate-owned cursor). Absent → in-memory {@link reactiveFactStore}.
|
|
1058
|
+
* The backend's runtime tier (node / browser) is the caller's concern —
|
|
1059
|
+
* forwarded verbatim.
|
|
1060
|
+
*/
|
|
1061
|
+
readonly storage?: StorageBackend;
|
|
1062
|
+
/**
|
|
1063
|
+
* Cascade dependency extractor. **Default `() => []`** — flat store, no
|
|
1064
|
+
* cascade. Supply to opt into MEME L2 cascade invalidation.
|
|
1065
|
+
*/
|
|
1066
|
+
readonly extractDependencies?: (f: MemoryFragment<T>) => readonly FactId[];
|
|
1067
|
+
/**
|
|
1068
|
+
* Exponential-decay forgetting. **Default: ON** with
|
|
1069
|
+
* {@link DEFAULT_DECAY_HALF_LIFE_NS} / {@link DEFAULT_DECAY_PERIOD_MS}.
|
|
1070
|
+
* Pass a partial to tune; pass `false` to disable. Wires an internal
|
|
1071
|
+
* `fromTimer` (the user-blessed batteries-included cadence).
|
|
1072
|
+
*/
|
|
1073
|
+
readonly decay?: false | Partial<DecayExponentialOptions>;
|
|
1074
|
+
/**
|
|
1075
|
+
* REM-replay consolidation. **Domain-bound** — requires a `summarize`
|
|
1076
|
+
* (no generic default exists). Supply the full
|
|
1077
|
+
* {@link ConsolidationRemOptions} to enable; omit to disable. Wires an
|
|
1078
|
+
* internal `fromTimer` at `consolidate.periodMs`.
|
|
1079
|
+
*/
|
|
1080
|
+
readonly consolidate?: ConsolidationRemOptions<T>;
|
|
1081
|
+
/** Persistent-only: durable bucket name. Default `fact_store_ingest`. */
|
|
1082
|
+
readonly persistName?: string;
|
|
1083
|
+
/** Persistent-only: durable codec. Default `bigintJsonCodecFor`. */
|
|
1084
|
+
readonly codec?: Codec<readonly MemoryFragment<T>[]>;
|
|
1085
|
+
}
|
|
1086
|
+
/**
|
|
1087
|
+
* The ergonomic write added to every `simpleFactStore` graph. Normalizes to a
|
|
1088
|
+
* {@link MemoryFragment} (auto `t_ns = BigInt(monotonicNs())`,
|
|
1089
|
+
* `confidence = 1`, `tags`/`sources` = `[]`) and `.emit`s it into the owned
|
|
1090
|
+
* `ingest` source. Re-`remember`ing an existing `id` is the MEME L1
|
|
1091
|
+
* direct-replace lever; set `opts.validTo` to obsolete (MEME L3).
|
|
1092
|
+
*/
|
|
1093
|
+
type SimpleFactStoreRemember<T> = (id: FactId, payload: T, opts?: RememberOptions) => void;
|
|
1094
|
+
/**
|
|
1095
|
+
* In-memory `simpleFactStore` graph (no `storage`) augmented with
|
|
1096
|
+
* {@link SimpleFactStoreRemember}.
|
|
1097
|
+
*/
|
|
1098
|
+
interface SimpleFactStoreGraph<T> extends ReactiveFactStoreGraph<T> {
|
|
1099
|
+
remember: SimpleFactStoreRemember<T>;
|
|
1100
|
+
}
|
|
1101
|
+
/**
|
|
1102
|
+
* Durable (`storage`-backed) `simpleFactStore` graph — the **type-honest**
|
|
1103
|
+
* persistent surface. EC-LOW-1 (`/qa` 2026-05-17): the `storage` overload
|
|
1104
|
+
* returns this so `position` / `replayedCount` / `flush` / `tier` are typed
|
|
1105
|
+
* without a hand-cast (the durable path is the headline 80%-case).
|
|
1106
|
+
*/
|
|
1107
|
+
type PersistentSimpleFactStoreGraph<T> = PersistentReactiveFactStoreGraph<T> & {
|
|
1108
|
+
remember: SimpleFactStoreRemember<T>;
|
|
1109
|
+
};
|
|
1110
|
+
/**
|
|
1111
|
+
* Build a fact store with sensible defaults and a one-call `remember`.
|
|
1112
|
+
*
|
|
1113
|
+
* @example
|
|
1114
|
+
* ```ts
|
|
1115
|
+
* import { simpleFactStore } from "@graphrefly/graphrefly/utils/memory";
|
|
1116
|
+
* import { memoryBackend } from "@graphrefly/graphrefly/extra";
|
|
1117
|
+
*
|
|
1118
|
+
* const mem = simpleFactStore<string>(); // in-memory, decay ON
|
|
1119
|
+
* mem.remember("user:lang", "TypeScript", { tags: ["pref"] });
|
|
1120
|
+
* mem.answer.subscribe((a) => console.log(a)); // reactive read
|
|
1121
|
+
*
|
|
1122
|
+
* // Durable: the `storage` overload returns the typed persistent surface
|
|
1123
|
+
* // (no hand-cast needed for `position` / `flush`).
|
|
1124
|
+
* const durable = simpleFactStore<string>({ storage: memoryBackend() });
|
|
1125
|
+
* durable.remember("k", "v");
|
|
1126
|
+
* await durable.flush();
|
|
1127
|
+
* ```
|
|
1128
|
+
*
|
|
1129
|
+
* @category memory
|
|
1130
|
+
*/
|
|
1131
|
+
declare function simpleFactStore<T>(opts: SimpleFactStoreOptions<T> & {
|
|
1132
|
+
storage: StorageBackend;
|
|
1133
|
+
}): PersistentSimpleFactStoreGraph<T>;
|
|
1134
|
+
declare function simpleFactStore<T>(opts?: SimpleFactStoreOptions<T>): SimpleFactStoreGraph<T>;
|
|
1135
|
+
|
|
957
1136
|
/**
|
|
958
1137
|
* Memory patterns (roadmap §4.3) — public-face Phase-4 primitives audited under
|
|
959
1138
|
* `archive/docs/SESSION-public-face-blocks-review.md` (Wave A, locked 2026-04-25).
|
|
@@ -1295,4 +1474,4 @@ type KnowledgeGraph<TEntity, TRelation extends string = string> = Graph & {
|
|
|
1295
1474
|
*/
|
|
1296
1475
|
declare function knowledgeGraph<TEntity, TRelation extends string = string>(name: string, opts?: KnowledgeGraphOptions): KnowledgeGraph<TEntity, TRelation>;
|
|
1297
1476
|
|
|
1298
|
-
export { type AdmissionFilter, type AdmissionLlmJudgeOptions, type BitemporalQueryOptions, type CascadeEvent, type CascadeOverflow, type CascadeReason, type CollectionAuditRecord, type CollectionEntry, type CollectionGraph, type CollectionOptions, type CollectionScoreFn, type ConsolidationRemConfig, type ConsolidationRemOptions, type DecayExponentialOptions, type DecayPolicy, type DependentsIndex, type FactId, type FactStore, type FactStoreAuditRecord, type HnswAdapter, type InfluenceAnalysis, type InfluenceAnalysisOptions, type InfluenceRow, type InvalidationTraceEntry, type InvalidationTracerOptions, type KnowledgeEdge, type KnowledgeGraph, type KnowledgeGraphAuditRecord, type KnowledgeGraphOptions, type MemoryAnswer, type MemoryFragment, type MemoryQuery, NodeOrValue, type OutcomeSignal, type PersistentReactiveFactStoreConfig, type PersistentReactiveFactStoreGraph, type RankedCollectionEntry, type ReactiveFactStoreConfig, type
|
|
1477
|
+
export { type AdmissionFilter, type AdmissionLlmJudgeOptions, type BitemporalQueryOptions, type CascadeEvent, type CascadeOverflow, type CascadeReason, type CollectionAuditRecord, type CollectionEntry, type CollectionGraph, type CollectionOptions, type CollectionScoreFn, type ConsolidationRemConfig, type ConsolidationRemOptions, DEFAULT_DECAY_HALF_LIFE_NS, DEFAULT_DECAY_PERIOD_MS, type DecayExponentialOptions, type DecayPolicy, type DependentsIndex, type FactId, type FactStore, type FactStoreAuditRecord, type HnswAdapter, type InfluenceAnalysis, type InfluenceAnalysisOptions, type InfluenceRow, type InvalidationTraceEntry, type InvalidationTracerOptions, type KnowledgeEdge, type KnowledgeGraph, type KnowledgeGraphAuditRecord, type KnowledgeGraphOptions, type MemoryAnswer, type MemoryFragment, type MemoryQuery, NodeOrValue, type OutcomeSignal, type PersistentReactiveFactStoreConfig, type PersistentReactiveFactStoreGraph, type RankedCollectionEntry, type ReactiveFactStoreConfig, ReactiveFactStoreGraph, type RememberOptions, type ReviewRequest, type ScoringByOutcomeOptions, type ScoringPolicy, type ShardByTenantConfig, type ShardByTenantOptions, type ShardKey, type SimpleFactStoreGraph, type SimpleFactStoreOptions, type StoreReadHandle, type VectorBackend, type VectorIndexAuditRecord, type VectorIndexGraph, type VectorIndexOptions, type VectorRecord, type VectorSearchResult, admissionLlmJudge, bitemporalQuery, collection, consolidationRem, cosineSimilarity, decayExponential, influenceAnalysis, invalidationTracer, knowledgeGraph, persistentReactiveFactStore, reactiveFactStore, scoringByOutcome, shardByTenant, simpleFactStore, vectorIndex };
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
+
DEFAULT_DECAY_HALF_LIFE_NS,
|
|
3
|
+
DEFAULT_DECAY_PERIOD_MS,
|
|
4
|
+
ReactiveFactStoreGraph,
|
|
2
5
|
admissionLlmJudge,
|
|
3
6
|
bitemporalQuery,
|
|
4
7
|
collection,
|
|
@@ -12,13 +15,17 @@ import {
|
|
|
12
15
|
reactiveFactStore,
|
|
13
16
|
scoringByOutcome,
|
|
14
17
|
shardByTenant,
|
|
18
|
+
simpleFactStore,
|
|
15
19
|
vectorIndex
|
|
16
|
-
} from "../../chunk-
|
|
20
|
+
} from "../../chunk-K4ZYJ4EM.js";
|
|
17
21
|
import "../../chunk-QMBYUVRL.js";
|
|
18
22
|
import "../../chunk-FMPF42Q4.js";
|
|
19
|
-
import "../../chunk-
|
|
23
|
+
import "../../chunk-C5QD5DQX.js";
|
|
20
24
|
import "../../chunk-AZDQPQ3V.js";
|
|
21
25
|
export {
|
|
26
|
+
DEFAULT_DECAY_HALF_LIFE_NS,
|
|
27
|
+
DEFAULT_DECAY_PERIOD_MS,
|
|
28
|
+
ReactiveFactStoreGraph,
|
|
22
29
|
admissionLlmJudge,
|
|
23
30
|
bitemporalQuery,
|
|
24
31
|
collection,
|
|
@@ -32,6 +39,7 @@ export {
|
|
|
32
39
|
reactiveFactStore,
|
|
33
40
|
scoringByOutcome,
|
|
34
41
|
shardByTenant,
|
|
42
|
+
simpleFactStore,
|
|
35
43
|
vectorIndex
|
|
36
44
|
};
|
|
37
45
|
//# sourceMappingURL=index.js.map
|