@fgv/ts-agent-memory 5.1.0-46 → 5.1.0-48
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/README.md +55 -0
- package/dist/packlets/ingest/orchestrator.js +115 -20
- package/dist/packlets/ingest/orchestrator.js.map +1 -1
- package/dist/packlets/observe/memoryObservationStore.js +6 -0
- package/dist/packlets/observe/memoryObservationStore.js.map +1 -1
- package/dist/packlets/observe/observer.js.map +1 -1
- package/dist/packlets/store/fileTreeMemoryStore.js +63 -135
- package/dist/packlets/store/fileTreeMemoryStore.js.map +1 -1
- package/dist/packlets/store/vectorMaintenance.js +251 -0
- package/dist/packlets/store/vectorMaintenance.js.map +1 -0
- package/dist/packlets/vector/inMemoryCosineIndex.js +81 -18
- package/dist/packlets/vector/inMemoryCosineIndex.js.map +1 -1
- package/dist/packlets/vector/inMemoryFragmentCosineIndex.js +7 -0
- package/dist/packlets/vector/inMemoryFragmentCosineIndex.js.map +1 -1
- package/dist/packlets/vector/vectorIndex.js.map +1 -1
- package/dist/ts-agent-memory.d.ts +389 -71
- package/lib/packlets/ingest/orchestrator.d.ts +62 -5
- package/lib/packlets/ingest/orchestrator.d.ts.map +1 -1
- package/lib/packlets/ingest/orchestrator.js +115 -20
- package/lib/packlets/ingest/orchestrator.js.map +1 -1
- package/lib/packlets/observe/memoryObservationStore.d.ts.map +1 -1
- package/lib/packlets/observe/memoryObservationStore.js +6 -0
- package/lib/packlets/observe/memoryObservationStore.js.map +1 -1
- package/lib/packlets/observe/observer.d.ts +61 -0
- package/lib/packlets/observe/observer.d.ts.map +1 -1
- package/lib/packlets/observe/observer.js.map +1 -1
- package/lib/packlets/store/fileTreeMemoryStore.d.ts +97 -60
- package/lib/packlets/store/fileTreeMemoryStore.d.ts.map +1 -1
- package/lib/packlets/store/fileTreeMemoryStore.js +63 -135
- package/lib/packlets/store/fileTreeMemoryStore.js.map +1 -1
- package/lib/packlets/store/vectorMaintenance.d.ts +149 -0
- package/lib/packlets/store/vectorMaintenance.d.ts.map +1 -0
- package/lib/packlets/store/vectorMaintenance.js +255 -0
- package/lib/packlets/store/vectorMaintenance.js.map +1 -0
- package/lib/packlets/vector/inMemoryCosineIndex.d.ts +30 -7
- package/lib/packlets/vector/inMemoryCosineIndex.d.ts.map +1 -1
- package/lib/packlets/vector/inMemoryCosineIndex.js +80 -17
- package/lib/packlets/vector/inMemoryCosineIndex.js.map +1 -1
- package/lib/packlets/vector/inMemoryFragmentCosineIndex.d.ts +7 -0
- package/lib/packlets/vector/inMemoryFragmentCosineIndex.d.ts.map +1 -1
- package/lib/packlets/vector/inMemoryFragmentCosineIndex.js +7 -0
- package/lib/packlets/vector/inMemoryFragmentCosineIndex.js.map +1 -1
- package/lib/packlets/vector/vectorIndex.d.ts +129 -1
- package/lib/packlets/vector/vectorIndex.d.ts.map +1 -1
- package/lib/packlets/vector/vectorIndex.js.map +1 -1
- package/package.json +17 -7
- package/.rush/temp/6e1299d1cebb080772163a532c221cd181b54f9f.tar.log +0 -462
- package/.rush/temp/chunked-rush-logs/ts-agent-memory.build.chunks.jsonl +0 -9
- package/.rush/temp/operation/build/all.log +0 -9
- package/.rush/temp/operation/build/log-chunks.jsonl +0 -9
- package/.rush/temp/operation/build/state.json +0 -3
- package/.rush/temp/shrinkwrap-deps.json +0 -689
- package/config/api-extractor.json +0 -343
- package/config/jest.config.json +0 -14
- package/config/rig.json +0 -4
- package/dist/test/unit/converters/antagonistRoundTrip.test.js +0 -95
- package/dist/test/unit/converters/antagonistRoundTrip.test.js.map +0 -1
- package/dist/test/unit/converters/bodyConverterRegistry.test.js +0 -72
- package/dist/test/unit/converters/bodyConverterRegistry.test.js.map +0 -1
- package/dist/test/unit/converters/envelopeConverter.test.js +0 -313
- package/dist/test/unit/converters/envelopeConverter.test.js.map +0 -1
- package/dist/test/unit/index/memoryIndex.test.js +0 -214
- package/dist/test/unit/index/memoryIndex.test.js.map +0 -1
- package/dist/test/unit/ingest/antagonistCycleAndParity.test.js +0 -277
- package/dist/test/unit/ingest/antagonistCycleAndParity.test.js.map +0 -1
- package/dist/test/unit/ingest/cycleGuard.test.js +0 -81
- package/dist/test/unit/ingest/cycleGuard.test.js.map +0 -1
- package/dist/test/unit/ingest/orchestrator.test.js +0 -1055
- package/dist/test/unit/ingest/orchestrator.test.js.map +0 -1
- package/dist/test/unit/observe/memoryObservationStore.test.js +0 -118
- package/dist/test/unit/observe/memoryObservationStore.test.js.map +0 -1
- package/dist/test/unit/retrieve/fragmentSemanticRetriever.test.js +0 -116
- package/dist/test/unit/retrieve/fragmentSemanticRetriever.test.js.map +0 -1
- package/dist/test/unit/retrieve/linkTraversalRetriever.test.js +0 -257
- package/dist/test/unit/retrieve/linkTraversalRetriever.test.js.map +0 -1
- package/dist/test/unit/retrieve/retrievers.test.js +0 -768
- package/dist/test/unit/retrieve/retrievers.test.js.map +0 -1
- package/dist/test/unit/retrieve/temporalRetrievers.test.js +0 -182
- package/dist/test/unit/retrieve/temporalRetrievers.test.js.map +0 -1
- package/dist/test/unit/store/antagonistTemporalBoundary.test.js +0 -120
- package/dist/test/unit/store/antagonistTemporalBoundary.test.js.map +0 -1
- package/dist/test/unit/store/embedOnWrite.test.js +0 -317
- package/dist/test/unit/store/embedOnWrite.test.js.map +0 -1
- package/dist/test/unit/store/fileTreeMemoryStore.test.js +0 -778
- package/dist/test/unit/store/fileTreeMemoryStore.test.js.map +0 -1
- package/dist/test/unit/store/fragmentEmbedOnWrite.test.js +0 -255
- package/dist/test/unit/store/fragmentEmbedOnWrite.test.js.map +0 -1
- package/dist/test/unit/store/indexInjection.test.js +0 -432
- package/dist/test/unit/store/indexInjection.test.js.map +0 -1
- package/dist/test/unit/store/lenientOpen.test.js +0 -248
- package/dist/test/unit/store/lenientOpen.test.js.map +0 -1
- package/dist/test/unit/store/listScoped.test.js +0 -109
- package/dist/test/unit/store/listScoped.test.js.map +0 -1
- package/dist/test/unit/store/observations.test.js +0 -239
- package/dist/test/unit/store/observations.test.js.map +0 -1
- package/dist/test/unit/store/rankAxis.test.js +0 -254
- package/dist/test/unit/store/rankAxis.test.js.map +0 -1
- package/dist/test/unit/store/scopeEncoding.test.js +0 -24
- package/dist/test/unit/store/scopeEncoding.test.js.map +0 -1
- package/dist/test/unit/store/temporalStore.test.js +0 -398
- package/dist/test/unit/store/temporalStore.test.js.map +0 -1
- package/dist/test/unit/tools/memoryTools.test.js +0 -841
- package/dist/test/unit/tools/memoryTools.test.js.map +0 -1
- package/dist/test/unit/types/identityCodec.test.js +0 -187
- package/dist/test/unit/types/identityCodec.test.js.map +0 -1
- package/dist/test/unit/types/ids.test.js +0 -84
- package/dist/test/unit/types/ids.test.js.map +0 -1
- package/dist/test/unit/types/temporalCodec.test.js +0 -203
- package/dist/test/unit/types/temporalCodec.test.js.map +0 -1
- package/dist/test/unit/types/temporalPolicy.test.js +0 -83
- package/dist/test/unit/types/temporalPolicy.test.js.map +0 -1
- package/dist/test/unit/types/writePolicy.test.js +0 -331
- package/dist/test/unit/types/writePolicy.test.js.map +0 -1
- package/dist/test/unit/vector/fragmentConverters.test.js +0 -58
- package/dist/test/unit/vector/fragmentConverters.test.js.map +0 -1
- package/dist/test/unit/vector/inMemoryCosineIndex.test.js +0 -252
- package/dist/test/unit/vector/inMemoryCosineIndex.test.js.map +0 -1
- package/dist/test/unit/vector/inMemoryFragmentCosineIndex.test.js +0 -362
- package/dist/test/unit/vector/inMemoryFragmentCosineIndex.test.js.map +0 -1
- package/dist/test/unit/vector/vectorIndex.test.js +0 -51
- package/dist/test/unit/vector/vectorIndex.test.js.map +0 -1
- package/eslint.config.js +0 -15
- package/etc/ts-agent-memory.api.md +0 -938
- package/lib/test/unit/converters/antagonistRoundTrip.test.d.ts +0 -10
- package/lib/test/unit/converters/antagonistRoundTrip.test.d.ts.map +0 -1
- package/lib/test/unit/converters/antagonistRoundTrip.test.js +0 -97
- package/lib/test/unit/converters/antagonistRoundTrip.test.js.map +0 -1
- package/lib/test/unit/converters/bodyConverterRegistry.test.d.ts +0 -2
- package/lib/test/unit/converters/bodyConverterRegistry.test.d.ts.map +0 -1
- package/lib/test/unit/converters/bodyConverterRegistry.test.js +0 -74
- package/lib/test/unit/converters/bodyConverterRegistry.test.js.map +0 -1
- package/lib/test/unit/converters/envelopeConverter.test.d.ts +0 -2
- package/lib/test/unit/converters/envelopeConverter.test.d.ts.map +0 -1
- package/lib/test/unit/converters/envelopeConverter.test.js +0 -315
- package/lib/test/unit/converters/envelopeConverter.test.js.map +0 -1
- package/lib/test/unit/index/memoryIndex.test.d.ts +0 -2
- package/lib/test/unit/index/memoryIndex.test.d.ts.map +0 -1
- package/lib/test/unit/index/memoryIndex.test.js +0 -216
- package/lib/test/unit/index/memoryIndex.test.js.map +0 -1
- package/lib/test/unit/ingest/antagonistCycleAndParity.test.d.ts +0 -9
- package/lib/test/unit/ingest/antagonistCycleAndParity.test.d.ts.map +0 -1
- package/lib/test/unit/ingest/antagonistCycleAndParity.test.js +0 -279
- package/lib/test/unit/ingest/antagonistCycleAndParity.test.js.map +0 -1
- package/lib/test/unit/ingest/cycleGuard.test.d.ts +0 -2
- package/lib/test/unit/ingest/cycleGuard.test.d.ts.map +0 -1
- package/lib/test/unit/ingest/cycleGuard.test.js +0 -83
- package/lib/test/unit/ingest/cycleGuard.test.js.map +0 -1
- package/lib/test/unit/ingest/orchestrator.test.d.ts +0 -2
- package/lib/test/unit/ingest/orchestrator.test.d.ts.map +0 -1
- package/lib/test/unit/ingest/orchestrator.test.js +0 -1057
- package/lib/test/unit/ingest/orchestrator.test.js.map +0 -1
- package/lib/test/unit/observe/memoryObservationStore.test.d.ts +0 -2
- package/lib/test/unit/observe/memoryObservationStore.test.d.ts.map +0 -1
- package/lib/test/unit/observe/memoryObservationStore.test.js +0 -120
- package/lib/test/unit/observe/memoryObservationStore.test.js.map +0 -1
- package/lib/test/unit/retrieve/fragmentSemanticRetriever.test.d.ts +0 -2
- package/lib/test/unit/retrieve/fragmentSemanticRetriever.test.d.ts.map +0 -1
- package/lib/test/unit/retrieve/fragmentSemanticRetriever.test.js +0 -118
- package/lib/test/unit/retrieve/fragmentSemanticRetriever.test.js.map +0 -1
- package/lib/test/unit/retrieve/linkTraversalRetriever.test.d.ts +0 -2
- package/lib/test/unit/retrieve/linkTraversalRetriever.test.d.ts.map +0 -1
- package/lib/test/unit/retrieve/linkTraversalRetriever.test.js +0 -259
- package/lib/test/unit/retrieve/linkTraversalRetriever.test.js.map +0 -1
- package/lib/test/unit/retrieve/retrievers.test.d.ts +0 -2
- package/lib/test/unit/retrieve/retrievers.test.d.ts.map +0 -1
- package/lib/test/unit/retrieve/retrievers.test.js +0 -770
- package/lib/test/unit/retrieve/retrievers.test.js.map +0 -1
- package/lib/test/unit/retrieve/temporalRetrievers.test.d.ts +0 -2
- package/lib/test/unit/retrieve/temporalRetrievers.test.d.ts.map +0 -1
- package/lib/test/unit/retrieve/temporalRetrievers.test.js +0 -184
- package/lib/test/unit/retrieve/temporalRetrievers.test.js.map +0 -1
- package/lib/test/unit/store/antagonistTemporalBoundary.test.d.ts +0 -9
- package/lib/test/unit/store/antagonistTemporalBoundary.test.d.ts.map +0 -1
- package/lib/test/unit/store/antagonistTemporalBoundary.test.js +0 -122
- package/lib/test/unit/store/antagonistTemporalBoundary.test.js.map +0 -1
- package/lib/test/unit/store/embedOnWrite.test.d.ts +0 -2
- package/lib/test/unit/store/embedOnWrite.test.d.ts.map +0 -1
- package/lib/test/unit/store/embedOnWrite.test.js +0 -319
- package/lib/test/unit/store/embedOnWrite.test.js.map +0 -1
- package/lib/test/unit/store/fileTreeMemoryStore.test.d.ts +0 -2
- package/lib/test/unit/store/fileTreeMemoryStore.test.d.ts.map +0 -1
- package/lib/test/unit/store/fileTreeMemoryStore.test.js +0 -780
- package/lib/test/unit/store/fileTreeMemoryStore.test.js.map +0 -1
- package/lib/test/unit/store/fragmentEmbedOnWrite.test.d.ts +0 -2
- package/lib/test/unit/store/fragmentEmbedOnWrite.test.d.ts.map +0 -1
- package/lib/test/unit/store/fragmentEmbedOnWrite.test.js +0 -257
- package/lib/test/unit/store/fragmentEmbedOnWrite.test.js.map +0 -1
- package/lib/test/unit/store/indexInjection.test.d.ts +0 -2
- package/lib/test/unit/store/indexInjection.test.d.ts.map +0 -1
- package/lib/test/unit/store/indexInjection.test.js +0 -434
- package/lib/test/unit/store/indexInjection.test.js.map +0 -1
- package/lib/test/unit/store/lenientOpen.test.d.ts +0 -2
- package/lib/test/unit/store/lenientOpen.test.d.ts.map +0 -1
- package/lib/test/unit/store/lenientOpen.test.js +0 -250
- package/lib/test/unit/store/lenientOpen.test.js.map +0 -1
- package/lib/test/unit/store/listScoped.test.d.ts +0 -2
- package/lib/test/unit/store/listScoped.test.d.ts.map +0 -1
- package/lib/test/unit/store/listScoped.test.js +0 -111
- package/lib/test/unit/store/listScoped.test.js.map +0 -1
- package/lib/test/unit/store/observations.test.d.ts +0 -2
- package/lib/test/unit/store/observations.test.d.ts.map +0 -1
- package/lib/test/unit/store/observations.test.js +0 -241
- package/lib/test/unit/store/observations.test.js.map +0 -1
- package/lib/test/unit/store/rankAxis.test.d.ts +0 -2
- package/lib/test/unit/store/rankAxis.test.d.ts.map +0 -1
- package/lib/test/unit/store/rankAxis.test.js +0 -256
- package/lib/test/unit/store/rankAxis.test.js.map +0 -1
- package/lib/test/unit/store/scopeEncoding.test.d.ts +0 -2
- package/lib/test/unit/store/scopeEncoding.test.d.ts.map +0 -1
- package/lib/test/unit/store/scopeEncoding.test.js +0 -26
- package/lib/test/unit/store/scopeEncoding.test.js.map +0 -1
- package/lib/test/unit/store/temporalStore.test.d.ts +0 -2
- package/lib/test/unit/store/temporalStore.test.d.ts.map +0 -1
- package/lib/test/unit/store/temporalStore.test.js +0 -400
- package/lib/test/unit/store/temporalStore.test.js.map +0 -1
- package/lib/test/unit/tools/memoryTools.test.d.ts +0 -2
- package/lib/test/unit/tools/memoryTools.test.d.ts.map +0 -1
- package/lib/test/unit/tools/memoryTools.test.js +0 -843
- package/lib/test/unit/tools/memoryTools.test.js.map +0 -1
- package/lib/test/unit/types/identityCodec.test.d.ts +0 -2
- package/lib/test/unit/types/identityCodec.test.d.ts.map +0 -1
- package/lib/test/unit/types/identityCodec.test.js +0 -189
- package/lib/test/unit/types/identityCodec.test.js.map +0 -1
- package/lib/test/unit/types/ids.test.d.ts +0 -2
- package/lib/test/unit/types/ids.test.d.ts.map +0 -1
- package/lib/test/unit/types/ids.test.js +0 -86
- package/lib/test/unit/types/ids.test.js.map +0 -1
- package/lib/test/unit/types/temporalCodec.test.d.ts +0 -2
- package/lib/test/unit/types/temporalCodec.test.d.ts.map +0 -1
- package/lib/test/unit/types/temporalCodec.test.js +0 -205
- package/lib/test/unit/types/temporalCodec.test.js.map +0 -1
- package/lib/test/unit/types/temporalPolicy.test.d.ts +0 -2
- package/lib/test/unit/types/temporalPolicy.test.d.ts.map +0 -1
- package/lib/test/unit/types/temporalPolicy.test.js +0 -85
- package/lib/test/unit/types/temporalPolicy.test.js.map +0 -1
- package/lib/test/unit/types/writePolicy.test.d.ts +0 -2
- package/lib/test/unit/types/writePolicy.test.d.ts.map +0 -1
- package/lib/test/unit/types/writePolicy.test.js +0 -333
- package/lib/test/unit/types/writePolicy.test.js.map +0 -1
- package/lib/test/unit/vector/fragmentConverters.test.d.ts +0 -2
- package/lib/test/unit/vector/fragmentConverters.test.d.ts.map +0 -1
- package/lib/test/unit/vector/fragmentConverters.test.js +0 -60
- package/lib/test/unit/vector/fragmentConverters.test.js.map +0 -1
- package/lib/test/unit/vector/inMemoryCosineIndex.test.d.ts +0 -2
- package/lib/test/unit/vector/inMemoryCosineIndex.test.d.ts.map +0 -1
- package/lib/test/unit/vector/inMemoryCosineIndex.test.js +0 -254
- package/lib/test/unit/vector/inMemoryCosineIndex.test.js.map +0 -1
- package/lib/test/unit/vector/inMemoryFragmentCosineIndex.test.d.ts +0 -2
- package/lib/test/unit/vector/inMemoryFragmentCosineIndex.test.d.ts.map +0 -1
- package/lib/test/unit/vector/inMemoryFragmentCosineIndex.test.js +0 -364
- package/lib/test/unit/vector/inMemoryFragmentCosineIndex.test.js.map +0 -1
- package/lib/test/unit/vector/vectorIndex.test.d.ts +0 -2
- package/lib/test/unit/vector/vectorIndex.test.d.ts.map +0 -1
- package/lib/test/unit/vector/vectorIndex.test.js +0 -53
- package/lib/test/unit/vector/vectorIndex.test.js.map +0 -1
- package/rush-logs/ts-agent-memory.build.cache.log +0 -3
- package/rush-logs/ts-agent-memory.build.log +0 -9
- package/src/index.ts +0 -14
- package/src/packlets/converters/bodyConverterRegistry.ts +0 -105
- package/src/packlets/converters/envelopeConverter.ts +0 -233
- package/src/packlets/converters/index.ts +0 -7
- package/src/packlets/index/index.ts +0 -6
- package/src/packlets/index/memoryIndex.ts +0 -332
- package/src/packlets/ingest/cycleGuard.ts +0 -153
- package/src/packlets/ingest/hostStages.ts +0 -111
- package/src/packlets/ingest/index.ts +0 -9
- package/src/packlets/ingest/model.ts +0 -195
- package/src/packlets/ingest/orchestrator.ts +0 -873
- package/src/packlets/observe/index.ts +0 -7
- package/src/packlets/observe/memoryObservationStore.ts +0 -153
- package/src/packlets/observe/observer.ts +0 -119
- package/src/packlets/retrieve/fragmentSemanticRetriever.ts +0 -138
- package/src/packlets/retrieve/hybridRetriever.ts +0 -194
- package/src/packlets/retrieve/index.ts +0 -14
- package/src/packlets/retrieve/linkTraversalRetriever.ts +0 -158
- package/src/packlets/retrieve/recencyRetriever.ts +0 -54
- package/src/packlets/retrieve/retriever.ts +0 -291
- package/src/packlets/retrieve/semanticRetriever.ts +0 -152
- package/src/packlets/retrieve/structuredFilterRetriever.ts +0 -58
- package/src/packlets/retrieve/tagRetriever.ts +0 -58
- package/src/packlets/retrieve/temporalRetrievers.ts +0 -210
- package/src/packlets/store/fileTreeMemoryStore.ts +0 -1834
- package/src/packlets/store/index.ts +0 -7
- package/src/packlets/store/scopeEncoding.ts +0 -36
- package/src/packlets/tools/index.ts +0 -6
- package/src/packlets/tools/memoryTools.ts +0 -706
- package/src/packlets/types/envelope.ts +0 -196
- package/src/packlets/types/filenameSafety.ts +0 -57
- package/src/packlets/types/identityCodec.ts +0 -447
- package/src/packlets/types/ids.ts +0 -124
- package/src/packlets/types/index.ts +0 -11
- package/src/packlets/types/temporal.ts +0 -96
- package/src/packlets/types/writePolicy.ts +0 -612
- package/src/packlets/vector/fragmentConverters.ts +0 -55
- package/src/packlets/vector/inMemoryCosineIndex.ts +0 -196
- package/src/packlets/vector/inMemoryFragmentCosineIndex.ts +0 -289
- package/src/packlets/vector/index.ts +0 -9
- package/src/packlets/vector/vectorIndex.ts +0 -273
- package/src/test/unit/converters/antagonistRoundTrip.test.ts +0 -110
- package/src/test/unit/converters/bodyConverterRegistry.test.ts +0 -89
- package/src/test/unit/converters/envelopeConverter.test.ts +0 -418
- package/src/test/unit/index/memoryIndex.test.ts +0 -272
- package/src/test/unit/ingest/antagonistCycleAndParity.test.ts +0 -367
- package/src/test/unit/ingest/cycleGuard.test.ts +0 -110
- package/src/test/unit/ingest/orchestrator.test.ts +0 -1351
- package/src/test/unit/observe/memoryObservationStore.test.ts +0 -158
- package/src/test/unit/retrieve/fragmentSemanticRetriever.test.ts +0 -163
- package/src/test/unit/retrieve/linkTraversalRetriever.test.ts +0 -329
- package/src/test/unit/retrieve/retrievers.test.ts +0 -1018
- package/src/test/unit/retrieve/temporalRetrievers.test.ts +0 -226
- package/src/test/unit/store/antagonistTemporalBoundary.test.ts +0 -158
- package/src/test/unit/store/embedOnWrite.test.ts +0 -418
- package/src/test/unit/store/fileTreeMemoryStore.test.ts +0 -1041
- package/src/test/unit/store/fragmentEmbedOnWrite.test.ts +0 -349
- package/src/test/unit/store/indexInjection.test.ts +0 -550
- package/src/test/unit/store/lenientOpen.test.ts +0 -292
- package/src/test/unit/store/listScoped.test.ts +0 -138
- package/src/test/unit/store/observations.test.ts +0 -290
- package/src/test/unit/store/rankAxis.test.ts +0 -349
- package/src/test/unit/store/scopeEncoding.test.ts +0 -37
- package/src/test/unit/store/temporalStore.test.ts +0 -469
- package/src/test/unit/tools/memoryTools.test.ts +0 -1120
- package/src/test/unit/types/identityCodec.test.ts +0 -266
- package/src/test/unit/types/ids.test.ts +0 -94
- package/src/test/unit/types/temporalCodec.test.ts +0 -259
- package/src/test/unit/types/temporalPolicy.test.ts +0 -124
- package/src/test/unit/types/writePolicy.test.ts +0 -446
- package/src/test/unit/vector/fragmentConverters.test.ts +0 -80
- package/src/test/unit/vector/inMemoryCosineIndex.test.ts +0 -318
- package/src/test/unit/vector/inMemoryFragmentCosineIndex.test.ts +0 -477
- package/src/test/unit/vector/vectorIndex.test.ts +0 -64
- package/temp/build/lint/_eslint-5eVG3S6w.json +0 -302
- package/temp/build/typescript/ts_8nwakTlr.json +0 -1
- package/temp/ts-agent-memory.api.json +0 -20933
- package/temp/ts-agent-memory.api.md +0 -938
- package/tsconfig.json +0 -8
|
@@ -329,6 +329,8 @@ export declare class FileTreeMemoryStore implements IMemoryStore {
|
|
|
329
329
|
private readonly _writePolicies;
|
|
330
330
|
private readonly _codecs;
|
|
331
331
|
private readonly _rankProjectors;
|
|
332
|
+
/** `undefined` = no declaration = every kind participates. */
|
|
333
|
+
private readonly _embedKinds;
|
|
332
334
|
private readonly _defaultCodec;
|
|
333
335
|
private readonly _defaultPolicy;
|
|
334
336
|
private readonly _scopeEncoding;
|
|
@@ -336,11 +338,9 @@ export declare class FileTreeMemoryStore implements IMemoryStore {
|
|
|
336
338
|
private readonly _index;
|
|
337
339
|
private readonly _hasher;
|
|
338
340
|
private readonly _observers;
|
|
341
|
+
/** Record- and fragment-vector maintenance; every operation is best-effort. */
|
|
342
|
+
private readonly _vectors;
|
|
339
343
|
private readonly _logger;
|
|
340
|
-
private readonly _vectorIndex;
|
|
341
|
-
private readonly _embed;
|
|
342
|
-
private readonly _fragmentIndex;
|
|
343
|
-
private readonly _fragmentEmbedder;
|
|
344
344
|
/**
|
|
345
345
|
* Records the initial walk could not load. Populated during `create()` in
|
|
346
346
|
* {@link MemoryRecordErrorMode | `'skip'` mode}; empty otherwise.
|
|
@@ -457,39 +457,6 @@ export declare class FileTreeMemoryStore implements IMemoryStore {
|
|
|
457
457
|
* later eviction failure never loses data with nothing written in its place.
|
|
458
458
|
*/
|
|
459
459
|
private _admitWrite;
|
|
460
|
-
/**
|
|
461
|
-
* Best-effort embed-on-write. When a vector index AND an embedder are wired,
|
|
462
|
-
* embeds the built record, `add`s the vector (replace semantics handle a same-id
|
|
463
|
-
* re-embed — no explicit remove), and stamps the returned `embeddingRef`. A
|
|
464
|
-
* failure (returned `fail` OR a thrown/rejected hook) is logged and the
|
|
465
|
-
* unembedded record is returned unchanged — the put still persists, and the
|
|
466
|
-
* derived index is reconciled by a later `rebuild`. A pass-through no-op when
|
|
467
|
-
* unwired (byte-identical record).
|
|
468
|
-
*
|
|
469
|
-
* Always succeeds (`Result` is the chain's shape, never a vector-induced
|
|
470
|
-
* failure).
|
|
471
|
-
*/
|
|
472
|
-
private _embedOnWrite;
|
|
473
|
-
/**
|
|
474
|
-
* Best-effort fragment-embed-on-write. When a fragment index AND a fragment
|
|
475
|
-
* embedder are wired, chunks + embeds the built record and replaces its
|
|
476
|
-
* fragments in the index (`addFragments` is whole-record-replace, so a re-authored
|
|
477
|
-
* document never leaves stale fragments behind — no explicit remove needed). A
|
|
478
|
-
* failure (returned `fail` OR a thrown/rejected hook) is logged and the record is
|
|
479
|
-
* returned unchanged — the put still persists, and the fragment index is a derived
|
|
480
|
-
* view a later `rebuild` reconciles. Unlike {@link FileTreeMemoryStore._embedOnWrite}
|
|
481
|
-
* it stamps nothing on the record (fragments have no per-record `embeddingRef`
|
|
482
|
-
* analog). A pass-through no-op when unwired (byte-identical record).
|
|
483
|
-
*/
|
|
484
|
-
private _embedFragmentsOnWrite;
|
|
485
|
-
/**
|
|
486
|
-
* Best-effort fragment removal. A no-op unless the full fragment lifecycle is
|
|
487
|
-
* wired (both an index AND an embedder), so an unwired store does no fragment
|
|
488
|
-
* work and behaves byte-identically. Failures are logged, never surfaced — a
|
|
489
|
-
* committed delete/eviction must not fail because a derived fragment index could
|
|
490
|
-
* not be pruned.
|
|
491
|
-
*/
|
|
492
|
-
private _removeFragmentsBestEffort;
|
|
493
460
|
/**
|
|
494
461
|
* Evict the records named by a `cull-oldest` decision, best-effort. Runs only
|
|
495
462
|
* after the authoritative `_persist`, so a failed eviction is logged (never
|
|
@@ -498,26 +465,6 @@ export declare class FileTreeMemoryStore implements IMemoryStore {
|
|
|
498
465
|
* `accept` / `reject` decisions evict nothing.
|
|
499
466
|
*/
|
|
500
467
|
private _applyEvictions;
|
|
501
|
-
/**
|
|
502
|
-
* Best-effort vector removal for each evicted record (never fails the put).
|
|
503
|
-
* Every evicted record is in the same `scope` as the incoming write (the
|
|
504
|
-
* cull-oldest cohort is the incoming record's `(scope, kind)` cohort), so that
|
|
505
|
-
* scope qualifies each removal target.
|
|
506
|
-
*/
|
|
507
|
-
private _removeEvictedVectors;
|
|
508
|
-
/**
|
|
509
|
-
* Run a consumer-supplied vector hook, normalizing a thrown/rejected hook into a
|
|
510
|
-
* `Failure` and logging any failure at `warn`. Best-effort: the caller proceeds
|
|
511
|
-
* regardless, since the index is rebuildable.
|
|
512
|
-
*/
|
|
513
|
-
private _tryVectorOp;
|
|
514
|
-
/**
|
|
515
|
-
* Best-effort vector removal. A no-op unless the full vector lifecycle is wired
|
|
516
|
-
* (both an index AND an embedder), so an unwired store does no vector work and
|
|
517
|
-
* behaves byte-identically. Failures are logged, never surfaced — a committed
|
|
518
|
-
* delete/eviction must not fail because a derived index could not be pruned.
|
|
519
|
-
*/
|
|
520
|
-
private _removeVectorBestEffort;
|
|
521
468
|
/**
|
|
522
469
|
* Build the record to persist. On a first write the incoming envelope is the
|
|
523
470
|
* base (final content equals the incoming content, so the dedup `hash` is
|
|
@@ -649,6 +596,10 @@ export declare class FileTreeMemoryStore implements IMemoryStore {
|
|
|
649
596
|
private _stampRank;
|
|
650
597
|
private _codecFor;
|
|
651
598
|
private _policyFor;
|
|
599
|
+
/** {@inheritDoc IMemoryStore.dedupScopeFor} */
|
|
600
|
+
dedupScopeFor(kind: Kind): DedupScope;
|
|
601
|
+
/** {@inheritDoc IMemoryStore.embedsKind} */
|
|
602
|
+
embedsKind(kind: Kind): boolean;
|
|
652
603
|
/**
|
|
653
604
|
* Read and validate the record at `<scope>/<idStem>.md`, returning `undefined`
|
|
654
605
|
* when the scope directory or file is absent. Verifies the on-disk id ↔
|
|
@@ -1172,6 +1123,37 @@ export declare interface IFileTreeMemoryStoreCreateParams {
|
|
|
1172
1123
|
* guard-host-callbacks conventions).
|
|
1173
1124
|
*/
|
|
1174
1125
|
readonly rankProjectors?: ReadonlyMap<Kind, RankProjector>;
|
|
1126
|
+
/**
|
|
1127
|
+
* The kinds whose records participate in the **record-granular** vector index.
|
|
1128
|
+
*
|
|
1129
|
+
* @remarks
|
|
1130
|
+
* **Absent means every kind participates**, which is the pre-existing behavior —
|
|
1131
|
+
* so omitting this is byte-identical to before it existed. Supplying it makes the
|
|
1132
|
+
* set an allowlist: a kind outside it is never handed to the {@link MemoryEmbedder}
|
|
1133
|
+
* on write, and is omitted from {@link IMemoryStore.asRecordSource | asRecordSource},
|
|
1134
|
+
* so a rebuild driven from this store does not pay for it either.
|
|
1135
|
+
*
|
|
1136
|
+
* Two costs motivate it, and the second is the one that is easy to miss:
|
|
1137
|
+
*
|
|
1138
|
+
* - **Embedder work on the critical path.** Embed-on-write is synchronous with
|
|
1139
|
+
* the write. A bookkeeping row — a status, a counter, a lease — that no query
|
|
1140
|
+
* will ever return still pays a full embedding round trip, and on a
|
|
1141
|
+
* locally-hosted model the first call after a restart pays a cold model load
|
|
1142
|
+
* on top.
|
|
1143
|
+
* - **Un-queried kinds crowd the `topK` window.** `IVectorIndex.query` applies
|
|
1144
|
+
* `topK` *before* any kind filter the retriever adds, so vectors that can never
|
|
1145
|
+
* be returned still occupy candidate slots. Over-fetching to compensate hides
|
|
1146
|
+
* this until the un-queried kinds start scoring well — at which point recall is
|
|
1147
|
+
* silently lost. Restricting what is indexed fixes the recall problem, not just
|
|
1148
|
+
* the cost.
|
|
1149
|
+
*
|
|
1150
|
+
* Applies to the record-granular path only. The fragment path
|
|
1151
|
+
* ({@link IFileTreeMemoryStoreCreateParams.fragmentIndex | fragmentIndex} /
|
|
1152
|
+
* `fragmentEmbedder`) is independent and unaffected — a kind may legitimately be
|
|
1153
|
+
* fragment-embedded and not record-embedded, which is the right shape for a long
|
|
1154
|
+
* document whose whole body exceeds the model's context.
|
|
1155
|
+
*/
|
|
1156
|
+
readonly embedKinds?: ReadonlySet<Kind>;
|
|
1175
1157
|
/** Default codec for kinds without an explicit entry. */
|
|
1176
1158
|
readonly defaultCodec?: IIdentityCodec;
|
|
1177
1159
|
/**
|
|
@@ -1828,6 +1810,12 @@ export declare interface IMemoryObservationQuery {
|
|
|
1828
1810
|
readonly phase?: MemoryObservationPhase;
|
|
1829
1811
|
/** Only records with this outcome. */
|
|
1830
1812
|
readonly outcome?: MemoryObservationOutcome;
|
|
1813
|
+
/**
|
|
1814
|
+
* Only `'write'` records with this embed outcome. Records carrying no embed
|
|
1815
|
+
* outcome never match, so `embed: 'failed'` answers "which writes left the
|
|
1816
|
+
* index short?" without a full scan of every record's `embeddingRef`.
|
|
1817
|
+
*/
|
|
1818
|
+
readonly embed?: MemoryEmbedOutcome;
|
|
1831
1819
|
}
|
|
1832
1820
|
|
|
1833
1821
|
/**
|
|
@@ -1863,6 +1851,12 @@ export declare interface IMemoryObservationRecord {
|
|
|
1863
1851
|
readonly error?: string;
|
|
1864
1852
|
/** Structured provenance of the write, when the operation carried one. */
|
|
1865
1853
|
readonly provenance?: IProvenance;
|
|
1854
|
+
/**
|
|
1855
|
+
* For `'write'` observations: what the record-granular vector index did about
|
|
1856
|
+
* this record. Absent when the question does not apply — see
|
|
1857
|
+
* {@link MemoryEmbedOutcome}.
|
|
1858
|
+
*/
|
|
1859
|
+
readonly embed?: MemoryEmbedOutcome;
|
|
1866
1860
|
/**
|
|
1867
1861
|
* For `'retrieve'` observations: an opaque snapshot of the query that drove
|
|
1868
1862
|
* the retrieval. Carried verbatim; never interpreted by the store.
|
|
@@ -2081,12 +2075,67 @@ export declare interface IMemoryStore {
|
|
|
2081
2075
|
/**
|
|
2082
2076
|
* Adapt this store to the {@link IMemoryRecordSource} seam so it can drive
|
|
2083
2077
|
* {@link IVectorIndex} rebuilds (e.g. `InMemoryCosineIndex.rebuild`). The
|
|
2084
|
-
* returned source's `list()` delegates to {@link IMemoryStore.listScoped}
|
|
2085
|
-
*
|
|
2078
|
+
* returned source's `list()` delegates to {@link IMemoryStore.listScoped},
|
|
2079
|
+
* **filtered to the kinds {@link IMemoryStore.embedsKind | embedsKind} reports** —
|
|
2080
|
+
* this source exists to feed the record vector index, so a kind excluded from
|
|
2081
|
+
* that index is excluded here too, and a reopen does not re-embed records the
|
|
2082
|
+
* index will never return. With no
|
|
2083
|
+
* {@link IFileTreeMemoryStoreCreateParams.embedKinds | embedKinds} declaration
|
|
2084
|
+
* every kind participates and the filter is the identity. `listScoped` itself is
|
|
2085
|
+
* **not** filtered and remains the whole-vault surface.
|
|
2086
|
+
*
|
|
2087
|
+
* The store cannot implement {@link IMemoryRecordSource} directly because its
|
|
2086
2088
|
* `list(filter?)` returns bare records (the ergonomic query surface) while the
|
|
2087
2089
|
* seam's `list()` returns scope-qualified records.
|
|
2088
2090
|
*/
|
|
2089
2091
|
asRecordSource(): IMemoryRecordSource;
|
|
2092
|
+
/**
|
|
2093
|
+
* The EFFECTIVE {@link DedupScope} for `kind` — the granularity at which a
|
|
2094
|
+
* write for this kind deduplicates against the existing vault.
|
|
2095
|
+
*
|
|
2096
|
+
* @remarks
|
|
2097
|
+
* This is a **read accessor over the store's already-injected write policies**,
|
|
2098
|
+
* and it is the single place any caller — the store's own write path included —
|
|
2099
|
+
* asks what a kind's dedup granularity is. It resolves the full chain the store
|
|
2100
|
+
* applies on write: the kind's registered {@link IWritePolicy}, falling back to
|
|
2101
|
+
* the store's default policy, then that policy's
|
|
2102
|
+
* {@link IWritePolicy.dedupScope | dedupScope}, falling back to
|
|
2103
|
+
* {@link DEFAULT_DEDUP_SCOPE}. Note the store's default policy is a
|
|
2104
|
+
* {@link KnowledgeLwwPolicy}, which declares `'content'` — so a kind with NO
|
|
2105
|
+
* registered policy resolves to `'content'`, not to `DEFAULT_DEDUP_SCOPE`.
|
|
2106
|
+
*
|
|
2107
|
+
* It exists so a caller that must agree with the store about dedup granularity
|
|
2108
|
+
* — notably the ingest orchestrator's stage-4 layer-1 exact match — can read the
|
|
2109
|
+
* declaration through this seam instead of being handed a second copy of the
|
|
2110
|
+
* policy map. A second declaration site is precisely the defect this accessor
|
|
2111
|
+
* was added to remove.
|
|
2112
|
+
*
|
|
2113
|
+
* Deliberately synchronous, total, and NOT `Result`-returning: it reads
|
|
2114
|
+
* constructor-injected configuration, touches no I/O, and cannot fail (every
|
|
2115
|
+
* link in the fallback chain has a total default). It exposes only the scope,
|
|
2116
|
+
* never the {@link IWritePolicy} itself, so it can never become a back door for
|
|
2117
|
+
* invoking admission or merge logic out of band.
|
|
2118
|
+
*/
|
|
2119
|
+
dedupScopeFor(kind: Kind): DedupScope;
|
|
2120
|
+
/**
|
|
2121
|
+
* Whether records of `kind` participate in the **record-granular** vector index.
|
|
2122
|
+
*
|
|
2123
|
+
* @remarks
|
|
2124
|
+
* A read accessor over the store's injected {@link IFileTreeMemoryStoreCreateParams.embedKinds | embedKinds}
|
|
2125
|
+
* declaration, in the same spirit as {@link IMemoryStore.dedupScopeFor} — one
|
|
2126
|
+
* place to ask, so the store's write path and any caller reasoning about index
|
|
2127
|
+
* coverage cannot disagree. `true` for every kind when no declaration was made.
|
|
2128
|
+
*
|
|
2129
|
+
* **This is distinct from a {@link MemoryEmbedder} decline, and the difference is
|
|
2130
|
+
* cost.** An embedder that returns `undefined` has already been called: the
|
|
2131
|
+
* round trip is paid, and on a locally-hosted model that round trip is the
|
|
2132
|
+
* expense. A kind excluded here is never handed to the embedder at all. The
|
|
2133
|
+
* decline makes the intent *expressible*; this makes it *free*.
|
|
2134
|
+
*
|
|
2135
|
+
* Deliberately synchronous, total, and NOT `Result`-returning: it reads
|
|
2136
|
+
* constructor-injected configuration, touches no I/O, and cannot fail.
|
|
2137
|
+
*/
|
|
2138
|
+
embedsKind(kind: Kind): boolean;
|
|
2090
2139
|
/**
|
|
2091
2140
|
* Write a record. Validates the body, computes a content hash, deduplicates
|
|
2092
2141
|
* (scope-wide, before policy), applies the kind's {@link IWritePolicy}, stamps
|
|
@@ -2239,17 +2288,40 @@ export declare class InMemoryCosineIndex implements IVectorIndex {
|
|
|
2239
2288
|
/**
|
|
2240
2289
|
* Re-embed every record from `source` and rebuild the index from scratch.
|
|
2241
2290
|
* Clears the current contents (and the established dimension) first, so a
|
|
2242
|
-
* re-embed with a different model is supported. Returns
|
|
2243
|
-
* indexed.
|
|
2291
|
+
* re-embed with a different model is supported. Returns an
|
|
2292
|
+
* {@link IVectorRebuildReport} describing what was indexed, declined and skipped.
|
|
2244
2293
|
*
|
|
2245
|
-
*
|
|
2246
|
-
*
|
|
2247
|
-
*
|
|
2294
|
+
* @remarks
|
|
2295
|
+
* **A failure to LIST is always fatal**, under either mode — and **leaves the
|
|
2296
|
+
* existing index untouched**: an unreadable source says nothing about which
|
|
2297
|
+
* records exist, so there is neither an honest partial to report nor any reason
|
|
2298
|
+
* to discard what is already held.
|
|
2299
|
+
*
|
|
2300
|
+
* Per-record embed/add failures are governed by
|
|
2301
|
+
* {@link IVectorRebuildOptions.onRecordError}, which defaults to `'fail'` —
|
|
2302
|
+
* **the historical all-or-nothing contract, unchanged**: the index is rolled back
|
|
2303
|
+
* to empty rather than left partially rebuilt, so a caller that retries a query
|
|
2304
|
+
* sees a clean empty index it can reason about.
|
|
2305
|
+
*
|
|
2306
|
+
* `'skip'` opts into the lenient shape the store's own open already uses: the
|
|
2307
|
+
* rebuild continues and every casualty is returned structurally on
|
|
2308
|
+
* {@link IVectorRebuildReport.skipped}. **It reports more, it does not report
|
|
2309
|
+
* less** — the point is to stop one bad record emptying an entire index, not to
|
|
2310
|
+
* make failures quieter. A caller that ignores `skipped` under `'skip'` has
|
|
2311
|
+
* chosen to, rather than been given no way to know.
|
|
2312
|
+
*
|
|
2313
|
+
* A {@link MemoryEmbedder} decline is not a failure under either mode: it is
|
|
2314
|
+
* counted on {@link IVectorRebuildReport.declined} and never appears in `skipped`.
|
|
2315
|
+
*
|
|
2316
|
+
* Both consumer-supplied hooks are capture-wrapped, so a `source` or `embed`
|
|
2317
|
+
* that throws or rejects becomes a `Failure` on the path above rather than an
|
|
2318
|
+
* exception escaping mid-rebuild — which would bypass the rollback entirely.
|
|
2248
2319
|
*
|
|
2249
2320
|
* @param source - The scope-qualified record source to re-embed.
|
|
2250
2321
|
* @param embed - The embedder applied to each record.
|
|
2322
|
+
* @param options - Rebuild options; omit for the historical `'fail'` behavior.
|
|
2251
2323
|
*/
|
|
2252
|
-
rebuild(source: IMemoryRecordSource, embed: MemoryEmbedder): Promise<Result<
|
|
2324
|
+
rebuild(source: IMemoryRecordSource, embed: MemoryEmbedder, options?: IVectorRebuildOptions): Promise<Result<IVectorRebuildReport>>;
|
|
2253
2325
|
/** Empty the index and forget the established dimension. */
|
|
2254
2326
|
private _reset;
|
|
2255
2327
|
/** The Euclidean magnitude (L2 norm) of a vector. */
|
|
@@ -2320,6 +2392,13 @@ export declare class InMemoryFragmentCosineIndex implements IFragmentVectorIndex
|
|
|
2320
2392
|
* On any failure (list, embed, or add) the index is rolled back to empty rather
|
|
2321
2393
|
* than left in a partially-rebuilt state.
|
|
2322
2394
|
*
|
|
2395
|
+
* @remarks
|
|
2396
|
+
* **Deliberately still returns a bare count**, unlike the record-granular
|
|
2397
|
+
* {@link InMemoryCosineIndex.rebuild}, which reports an
|
|
2398
|
+
* {@link IVectorRebuildReport}. The asymmetry is scope, not oversight: the
|
|
2399
|
+
* fragment path is tracked separately and gains the same treatment when the
|
|
2400
|
+
* `IVectorIndex`/`IFragmentVectorIndex` contracts are revisited together.
|
|
2401
|
+
*
|
|
2323
2402
|
* @param source - The scope-qualified record source to re-embed.
|
|
2324
2403
|
* @param embed - The fragment embedder applied to each record.
|
|
2325
2404
|
*/
|
|
@@ -2465,6 +2544,19 @@ export declare interface ISkippedRecord {
|
|
|
2465
2544
|
readonly error: string;
|
|
2466
2545
|
}
|
|
2467
2546
|
|
|
2547
|
+
/**
|
|
2548
|
+
* A record a rebuild could not index — because the embed failed or because the
|
|
2549
|
+
* subsequent add did — retained so a partial rebuild reports what it lost rather
|
|
2550
|
+
* than merely how much it kept.
|
|
2551
|
+
* @public
|
|
2552
|
+
*/
|
|
2553
|
+
export declare interface ISkippedVectorRecord {
|
|
2554
|
+
/** The scope-qualified address of the record that could not be indexed. */
|
|
2555
|
+
readonly target: IEdgeTarget;
|
|
2556
|
+
/** The failure message, from either the embed or the subsequent add. */
|
|
2557
|
+
readonly error: string;
|
|
2558
|
+
}
|
|
2559
|
+
|
|
2468
2560
|
/**
|
|
2469
2561
|
* Narrow an {@link IIdentityCodec} to {@link ITemporalIdentityCodec} by probing
|
|
2470
2562
|
* for the versioned methods. Used by the store when an `encode` result reports
|
|
@@ -2582,6 +2674,45 @@ export declare interface IVectorIndex {
|
|
|
2582
2674
|
* Return the `topK` nearest records to `vector`, in descending score order.
|
|
2583
2675
|
*/
|
|
2584
2676
|
query(vector: Float32Array, topK: number): Promise<Result<ReadonlyArray<IVectorQueryHit>>>;
|
|
2677
|
+
/**
|
|
2678
|
+
* The number of vectors currently held.
|
|
2679
|
+
*
|
|
2680
|
+
* @remarks
|
|
2681
|
+
* On the contract because without it a caller cannot distinguish *"the index is
|
|
2682
|
+
* empty"* from *"nothing matched"*: {@link IVectorIndex.query} answers an empty
|
|
2683
|
+
* index with `succeed([])`, which is indistinguishable from a genuine miss. The
|
|
2684
|
+
* only other check available to a caller — "is a vector index wired?" — tests the
|
|
2685
|
+
* **wiring**, and that stays true while the index holds nothing.
|
|
2686
|
+
*
|
|
2687
|
+
* Note the narrow scope: this answers *how many vectors are held*, **not** how
|
|
2688
|
+
* many there ought to be. Full coverage — "is every record that should be indexed
|
|
2689
|
+
* actually indexed?" — still requires comparing against the record source and
|
|
2690
|
+
* {@link IMemoryStore.embedsKind}.
|
|
2691
|
+
*
|
|
2692
|
+
* Synchronous and non-`Result` because both shipped implementations can answer it
|
|
2693
|
+
* without I/O that can fail — the in-memory index reads a `Map`'s size, and the
|
|
2694
|
+
* SQLite-backed one a prepared `COUNT` against an open connection it already owns.
|
|
2695
|
+
*/
|
|
2696
|
+
readonly size: number;
|
|
2697
|
+
/**
|
|
2698
|
+
* Re-embed every record from `source` and rebuild the index from scratch — the
|
|
2699
|
+
* **backfill / reconcile** operation.
|
|
2700
|
+
*
|
|
2701
|
+
* @remarks
|
|
2702
|
+
* On the contract because a persisted index is unusable without it. Records
|
|
2703
|
+
* written while the index was unwired, a re-embed after a dimension change (where
|
|
2704
|
+
* the backend supports one — a `vec0`-backed table's dimension is fixed at
|
|
2705
|
+
* creation, so there it needs a drop-and-re-index instead), and reconciliation
|
|
2706
|
+
* after a swallowed embed-on-write failure are all unreachable otherwise — and the store's own docstring already promises *"the derived index
|
|
2707
|
+
* is reconciled by a later `rebuild`"*, a promise the contract could not keep for
|
|
2708
|
+
* any index but the bundled one. A caller moving from the bundled implementation
|
|
2709
|
+
* to a persistent one found the swap type-checked everywhere **except** the one
|
|
2710
|
+
* place it backfills, which is the place that mattered.
|
|
2711
|
+
*
|
|
2712
|
+
* See {@link IVectorRebuildReport} for what it reports and
|
|
2713
|
+
* {@link IVectorRebuildOptions} for the failure mode.
|
|
2714
|
+
*/
|
|
2715
|
+
rebuild(source: IMemoryRecordSource, embed: MemoryEmbedder, options?: IVectorRebuildOptions): Promise<Result<IVectorRebuildReport>>;
|
|
2585
2716
|
}
|
|
2586
2717
|
|
|
2587
2718
|
/**
|
|
@@ -2640,6 +2771,43 @@ export declare interface IVectorQueryHit {
|
|
|
2640
2771
|
readonly fragmentId?: string;
|
|
2641
2772
|
}
|
|
2642
2773
|
|
|
2774
|
+
/**
|
|
2775
|
+
* Options for a vector-index rebuild.
|
|
2776
|
+
* @public
|
|
2777
|
+
*/
|
|
2778
|
+
export declare interface IVectorRebuildOptions {
|
|
2779
|
+
/**
|
|
2780
|
+
* How to treat a record the rebuild cannot index — an embed failure OR an add
|
|
2781
|
+
* failure. Defaults to `'fail'` — the historical behavior, unchanged for every
|
|
2782
|
+
* existing caller.
|
|
2783
|
+
*/
|
|
2784
|
+
readonly onRecordError?: VectorRebuildErrorMode;
|
|
2785
|
+
}
|
|
2786
|
+
|
|
2787
|
+
/**
|
|
2788
|
+
* What a rebuild actually did — the structural answer to "is this index complete?".
|
|
2789
|
+
*
|
|
2790
|
+
* @remarks
|
|
2791
|
+
* A bare count cannot distinguish the three ways a record can be absent from the
|
|
2792
|
+
* index, and that distinction is the entire point: **`declined` was intentional,
|
|
2793
|
+
* `skipped` was a fault, and neither is the same as "never attempted"**. A caller
|
|
2794
|
+
* deriving coverage from a count alone cannot tell an embedder outage from a
|
|
2795
|
+
* deliberate policy, which is precisely the confusion this type exists to end.
|
|
2796
|
+
* @public
|
|
2797
|
+
*/
|
|
2798
|
+
export declare interface IVectorRebuildReport {
|
|
2799
|
+
/** Records embedded and added to the index. */
|
|
2800
|
+
readonly indexed: number;
|
|
2801
|
+
/** Records the embedder deliberately declined (resolved `undefined`). */
|
|
2802
|
+
readonly declined: number;
|
|
2803
|
+
/**
|
|
2804
|
+
* Records whose embedding or add FAILED and were skipped. Non-empty only under
|
|
2805
|
+
* {@link VectorRebuildErrorMode | `onRecordError: 'skip'`} — under `'fail'` the
|
|
2806
|
+
* first failure aborts the rebuild and no report is returned at all.
|
|
2807
|
+
*/
|
|
2808
|
+
readonly skipped: ReadonlyArray<ISkippedVectorRecord>;
|
|
2809
|
+
}
|
|
2810
|
+
|
|
2643
2811
|
/**
|
|
2644
2812
|
* A per-kind write policy, injected at store construction. Invoked AFTER
|
|
2645
2813
|
* content-hash dedup (dedup is always pre-policy). The policy decides
|
|
@@ -2989,9 +3157,81 @@ export declare type MemoryDetailTier = 'gist' | 'full';
|
|
|
2989
3157
|
* Async and `Result`-returning, since a real embedder does a network call (cloud
|
|
2990
3158
|
* provider) or in-process model inference. The consumer wires this — the core
|
|
2991
3159
|
* package never calls an embedding provider directly, staying embedder-agnostic.
|
|
3160
|
+
*
|
|
3161
|
+
* @remarks
|
|
3162
|
+
* Resolving to `undefined` means **"intentionally not embedded"** — a deliberate
|
|
3163
|
+
* decline, not an error. The record is stored without an embedding reference, no
|
|
3164
|
+
* failure is reported, and **the decline itself logs nothing**. This is distinct
|
|
3165
|
+
* from a `Failure`, which means the embedder *tried and could not*.
|
|
3166
|
+
*
|
|
3167
|
+
* "Logs nothing" is a statement about the decline, not a promise of silence: a
|
|
3168
|
+
* decline on a record that was already embedded also prunes the vector that
|
|
3169
|
+
* reference named, and if that prune fails it is a genuine fault and warns like
|
|
3170
|
+
* any other. What a decline never does is warn merely for having happened.
|
|
3171
|
+
*
|
|
3172
|
+
* The distinction is load-bearing wherever the two are treated differently. On the
|
|
3173
|
+
* rebuild path a declined record is **excluded** from the index and counted on
|
|
3174
|
+
* {@link IVectorRebuildReport.declined}; a failed one is a genuine error and, under
|
|
3175
|
+
* `onRecordError: 'skip'`, is reported on {@link IVectorRebuildReport.skipped}. Collapsing "I chose not to" into `fail` would
|
|
3176
|
+
* make a deliberate policy indistinguishable from an embedder outage in the logs,
|
|
3177
|
+
* and would put a routine decision on whatever error path the caller has wired.
|
|
3178
|
+
*
|
|
3179
|
+
* The embedder receives the whole record, so the usual reason to decline is the
|
|
3180
|
+
* record's `kind` — a control or bookkeeping row that no query should ever return.
|
|
3181
|
+
*
|
|
3182
|
+
* @public
|
|
3183
|
+
*/
|
|
3184
|
+
export declare type MemoryEmbedder = (record: IMemoryRecord<unknown>) => Promise<Result<Float32Array | undefined>>;
|
|
3185
|
+
|
|
3186
|
+
/**
|
|
3187
|
+
* What the record-granular vector index did about a written record.
|
|
3188
|
+
*
|
|
3189
|
+
* @remarks
|
|
3190
|
+
* This exists because **`embeddingRef` absence is three-ways ambiguous**: a
|
|
3191
|
+
* record with no reference may have been declined, excluded, or genuinely
|
|
3192
|
+
* failed to embed, and the `put`'s own `outcome` cannot tell you which — it is
|
|
3193
|
+
* `'success'` in all three, because embed-on-write is best-effort by design and
|
|
3194
|
+
* never fails a durable write. Deriving index coverage from the absent field
|
|
3195
|
+
* alone therefore cannot distinguish a policy decision from an outage.
|
|
3196
|
+
*
|
|
3197
|
+
* - `'embedded'` — embedded and added; the record carries an `embeddingRef`.
|
|
3198
|
+
* - `'declined'` — the {@link MemoryEmbedder} resolved `undefined`: deliberately
|
|
3199
|
+
* not embedded. Not a fault.
|
|
3200
|
+
* - `'excluded'` — the record's kind is outside the store's `embedKinds`
|
|
3201
|
+
* declaration, so the embedder was never called. Also not a fault, and the
|
|
3202
|
+
* cheaper of the two.
|
|
3203
|
+
* - `'failed'` — the embedder returned a `Failure` (or threw), **or** the index
|
|
3204
|
+
* `add` did. Both are faults, and what they leave behind depends on whether
|
|
3205
|
+
* the record had been embedded before: a **first** write ends up with no
|
|
3206
|
+
* `embeddingRef` and nothing in the index, while an **update** keeps the
|
|
3207
|
+
* reference and vector it already had — so the index goes on answering on the
|
|
3208
|
+
* record's **previous** content until a `rebuild` reconciles it. Stale, not
|
|
3209
|
+
* absent. The store's diagnostic logger names which fault it was, because the
|
|
3210
|
+
* remediation differs (an embedder outage versus an index outage) while the
|
|
3211
|
+
* coverage answer — "this record needs a re-embed" — does not.
|
|
3212
|
+
*
|
|
3213
|
+
* Absent on a write observation means **no outcome is being reported**, which
|
|
3214
|
+
* covers three cases:
|
|
3215
|
+
*
|
|
3216
|
+
* 1. no vector index / embedder is wired, so there is no index for the record to
|
|
3217
|
+
* be absent from;
|
|
3218
|
+
* 2. the `put` was a dedup no-op, which attempted nothing;
|
|
3219
|
+
* 3. the `put` **failed** (`outcome: 'failure'`). An embed step may well have run
|
|
3220
|
+
* before the failure — a record can even have been added to the index and then
|
|
3221
|
+
* lost its durable write, leaving an orphan vector that a later `rebuild`
|
|
3222
|
+
* reconciles. That is deliberately not reported here: the field answers
|
|
3223
|
+
* "is this *stored* record in the index?", and on a failed write there is no
|
|
3224
|
+
* stored record for it to be a statement about.
|
|
3225
|
+
*
|
|
3226
|
+
* So `embed` is a property of successful writes. Never present on `'read'` /
|
|
3227
|
+
* `'delete'` / `'retrieve'`.
|
|
3228
|
+
*
|
|
3229
|
+
* Record-granular only. The fragment path is independent and reports nothing
|
|
3230
|
+
* here — a record may be fragment-embedded while its record-level outcome is
|
|
3231
|
+
* `'excluded'`.
|
|
2992
3232
|
* @public
|
|
2993
3233
|
*/
|
|
2994
|
-
export declare type
|
|
3234
|
+
export declare type MemoryEmbedOutcome = 'embedded' | 'declined' | 'excluded' | 'failed';
|
|
2995
3235
|
|
|
2996
3236
|
/**
|
|
2997
3237
|
* Stable file-stem identifier for a memory record. Equals the codec-produced
|
|
@@ -3143,7 +3383,9 @@ export declare class MemoryIngestOrchestrator implements IMemoryIngestOrchestrat
|
|
|
3143
3383
|
private _planFromVerdict;
|
|
3144
3384
|
/**
|
|
3145
3385
|
* Stage 4 — resolve a dedup verdict. Layer 1: an exact `{ kind, body }` match in
|
|
3146
|
-
* the candidate's scope is a `duplicate-of
|
|
3386
|
+
* the candidate's scope is a `duplicate-of`, at the granularity the kind's
|
|
3387
|
+
* {@link DedupScope} declares — scope-wide for `'content'`, restricted to the
|
|
3388
|
+
* candidate's own entity for `'entity'` (design note §1). Layer 2 (only when
|
|
3147
3389
|
* a resolver + vector index + embedder are all wired): embed the candidate,
|
|
3148
3390
|
* surface over-threshold neighbors, and dispatch to the {@link IEntityResolver}.
|
|
3149
3391
|
* Otherwise the verdict is `new` (the exact-only fall-back path).
|
|
@@ -3154,9 +3396,26 @@ export declare class MemoryIngestOrchestrator implements IMemoryIngestOrchestrat
|
|
|
3154
3396
|
/** Layer-2 continuation once the candidate has a provisional record to embed. */
|
|
3155
3397
|
private _resolveViaSimilarityEmbedded;
|
|
3156
3398
|
/**
|
|
3157
|
-
* Find an existing record
|
|
3158
|
-
*
|
|
3159
|
-
* — only a live (non-temporal or current) record deduplicates a
|
|
3399
|
+
* Find an existing record whose `{ kind, body }` hash matches the candidate's
|
|
3400
|
+
* (layer-1 exact dedup, design note §1). Invalidated temporal versions are
|
|
3401
|
+
* excluded — only a live (non-temporal or current) record deduplicates a
|
|
3402
|
+
* candidate.
|
|
3403
|
+
*
|
|
3404
|
+
* @remarks
|
|
3405
|
+
* The cohort's granularity is the kind's DECLARED {@link DedupScope}, read
|
|
3406
|
+
* through {@link IMemoryStore.dedupScopeFor} so this layer and the store's own
|
|
3407
|
+
* write path can never disagree:
|
|
3408
|
+
*
|
|
3409
|
+
* - `'content'` — every live same-kind record in the candidate's scope,
|
|
3410
|
+
* regardless of entity. A cross-id body collision IS a duplicate (the
|
|
3411
|
+
* knowledge family; unchanged behavior).
|
|
3412
|
+
* - `'entity'` — only records at the candidate's OWN entity address. Two
|
|
3413
|
+
* distinct entities with byte-identical bodies never collapse into one
|
|
3414
|
+
* another, which is what the declaration has always meant on the direct-put
|
|
3415
|
+
* path and now means here too.
|
|
3416
|
+
*
|
|
3417
|
+
* The same-id collapse itself remains the store's job — this layer only decides
|
|
3418
|
+
* whether a cross-id body collision is eligible to be a `duplicate-of` at all.
|
|
3160
3419
|
*/
|
|
3161
3420
|
private _findExactMatch;
|
|
3162
3421
|
/**
|
|
@@ -3168,8 +3427,46 @@ export declare class MemoryIngestOrchestrator implements IMemoryIngestOrchestrat
|
|
|
3168
3427
|
private static _recordBodyString;
|
|
3169
3428
|
/** The stage-4 exact-dedup key over `{ kind, body }` (design note §1). */
|
|
3170
3429
|
private _exactKey;
|
|
3171
|
-
/** Stage 5 — relate (host), validate edges, and run the write-time cycle guard. */
|
|
3430
|
+
/** Stage 5 — relate (host), redirect collapsed targets, validate edges, and run the write-time cycle guard. */
|
|
3172
3431
|
private _relate;
|
|
3432
|
+
/**
|
|
3433
|
+
* The stage-5 edge-target redirect map for this pass: every `duplicate-of`
|
|
3434
|
+
* candidate's OWN scoped address, mapped to the address of the record its
|
|
3435
|
+
* verdict collapsed it into (design note §3).
|
|
3436
|
+
*
|
|
3437
|
+
* @remarks
|
|
3438
|
+
* A `duplicate-of` verdict means "this candidate IS that record". The candidate
|
|
3439
|
+
* is therefore not written, and its address never becomes a live reference — so
|
|
3440
|
+
* a sibling edge built against it in the same pass would resolve to neither a
|
|
3441
|
+
* written candidate nor an existing record and would fail the WHOLE ingest item.
|
|
3442
|
+
* That is a second-order hazard of collapsing, not a defect in the edge: the
|
|
3443
|
+
* host related two candidates it was correctly told about, and one of them
|
|
3444
|
+
* turned out to already exist.
|
|
3445
|
+
*
|
|
3446
|
+
* Redirecting is the honest repair, and it is independent of {@link DedupScope}
|
|
3447
|
+
* — it applies equally to a `'content'` kind, where the collapse is exactly
|
|
3448
|
+
* right and the ingest still must not fail.
|
|
3449
|
+
*
|
|
3450
|
+
* The map cannot chain: {@link MemoryIngestOrchestrator._planFromVerdict}
|
|
3451
|
+
* requires every target-bearing verdict's target to already exist in the store
|
|
3452
|
+
* snapshot, so a redirect destination is always a persisted record and never
|
|
3453
|
+
* another collapsed candidate. One pass is sufficient by construction.
|
|
3454
|
+
*/
|
|
3455
|
+
private static _collapseRedirects;
|
|
3456
|
+
/**
|
|
3457
|
+
* Rewrite each edge whose TARGET names a collapsed candidate to point at the
|
|
3458
|
+
* record that candidate collapsed into.
|
|
3459
|
+
*
|
|
3460
|
+
* @remarks
|
|
3461
|
+
* Only the target is redirected. An edge whose SOURCE is a collapsed candidate
|
|
3462
|
+
* stays untouched and is still rejected by {@link
|
|
3463
|
+
* MemoryIngestOrchestrator._validateEdges}: sources are the records an edge is
|
|
3464
|
+
* written ONTO, a collapsed candidate is never written, and the relation
|
|
3465
|
+
* extractor is only ever offered writable candidates as edge sources in the
|
|
3466
|
+
* first place. Silently relocating such an edge onto an existing record would
|
|
3467
|
+
* attribute a link the host never asked for — the loud failure is correct there.
|
|
3468
|
+
*/
|
|
3469
|
+
private static _redirectEdges;
|
|
3173
3470
|
/**
|
|
3174
3471
|
* Validate stage-5 edges: each `source` must be a candidate being written; each
|
|
3175
3472
|
* `target` must resolve to a sibling candidate or an existing store record. All
|
|
@@ -3783,4 +4080,25 @@ export declare class TemporalVersionedPolicy implements IWritePolicy {
|
|
|
3783
4080
|
private _rebuild;
|
|
3784
4081
|
}
|
|
3785
4082
|
|
|
4083
|
+
/**
|
|
4084
|
+
* How a vector-index rebuild treats a record it cannot index — whether the
|
|
4085
|
+
* **embedding** failed or the subsequent **add** did. Both are governed by this
|
|
4086
|
+
* one mode; neither is unconditionally fatal.
|
|
4087
|
+
*
|
|
4088
|
+
* @remarks
|
|
4089
|
+
* Deliberately mirrors the store's own open-time `onRecordError` mode, including
|
|
4090
|
+
* its default: `'fail'` preserves the historical all-or-nothing contract exactly,
|
|
4091
|
+
* and `'skip'` is opt-in. Defined here rather than imported from the store packlet
|
|
4092
|
+
* — the `vector` packlet does not depend on `store`, and the two modes describe
|
|
4093
|
+
* different domains that merely happen to share a shape.
|
|
4094
|
+
*
|
|
4095
|
+
* A **decline** (a {@link MemoryEmbedder} resolving `undefined`) is not an error
|
|
4096
|
+
* and is unaffected by this mode: it is always **excluded** from the index and
|
|
4097
|
+
* counted on {@link IVectorRebuildReport.declined}, **never** appearing in
|
|
4098
|
+
* {@link IVectorRebuildReport.skipped}. The word is worth being careful with here:
|
|
4099
|
+
* `skipped` is now a formal field meaning *a fault*, and a decline is the opposite.
|
|
4100
|
+
* @public
|
|
4101
|
+
*/
|
|
4102
|
+
export declare type VectorRebuildErrorMode = 'skip' | 'fail';
|
|
4103
|
+
|
|
3786
4104
|
export { }
|