@fgv/ts-agent-memory 5.1.0-47 → 5.1.0-49
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/packlets/ingest/orchestrator.js +11 -1
- 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/retrieve/linkTraversalRetriever.js +1 -1
- package/dist/packlets/retrieve/linkTraversalRetriever.js.map +1 -1
- package/dist/packlets/retrieve/recencyRetriever.js +1 -1
- package/dist/packlets/retrieve/recencyRetriever.js.map +1 -1
- package/dist/packlets/retrieve/retriever.js +11 -5
- package/dist/packlets/retrieve/retriever.js.map +1 -1
- package/dist/packlets/retrieve/structuredFilterRetriever.js +27 -5
- package/dist/packlets/retrieve/structuredFilterRetriever.js.map +1 -1
- package/dist/packlets/retrieve/tagRetriever.js +1 -1
- package/dist/packlets/retrieve/tagRetriever.js.map +1 -1
- package/dist/packlets/retrieve/temporalRetrievers.js +1 -1
- package/dist/packlets/retrieve/temporalRetrievers.js.map +1 -1
- package/dist/packlets/store/fileTreeMemoryStore.js +152 -132
- 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/types/envelope.js.map +1 -1
- 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 +431 -79
- package/lib/packlets/ingest/orchestrator.d.ts.map +1 -1
- package/lib/packlets/ingest/orchestrator.js +11 -1
- 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/retrieve/linkTraversalRetriever.d.ts +1 -1
- package/lib/packlets/retrieve/linkTraversalRetriever.js +1 -1
- package/lib/packlets/retrieve/linkTraversalRetriever.js.map +1 -1
- package/lib/packlets/retrieve/recencyRetriever.d.ts +1 -1
- package/lib/packlets/retrieve/recencyRetriever.js +1 -1
- package/lib/packlets/retrieve/recencyRetriever.js.map +1 -1
- package/lib/packlets/retrieve/retriever.d.ts +26 -7
- package/lib/packlets/retrieve/retriever.d.ts.map +1 -1
- package/lib/packlets/retrieve/retriever.js +11 -5
- package/lib/packlets/retrieve/retriever.js.map +1 -1
- package/lib/packlets/retrieve/structuredFilterRetriever.d.ts +26 -4
- package/lib/packlets/retrieve/structuredFilterRetriever.d.ts.map +1 -1
- package/lib/packlets/retrieve/structuredFilterRetriever.js +27 -5
- package/lib/packlets/retrieve/structuredFilterRetriever.js.map +1 -1
- package/lib/packlets/retrieve/tagRetriever.d.ts +1 -1
- package/lib/packlets/retrieve/tagRetriever.js +1 -1
- package/lib/packlets/retrieve/tagRetriever.js.map +1 -1
- package/lib/packlets/retrieve/temporalRetrievers.js +1 -1
- package/lib/packlets/retrieve/temporalRetrievers.js.map +1 -1
- package/lib/packlets/store/fileTreeMemoryStore.d.ts +135 -59
- package/lib/packlets/store/fileTreeMemoryStore.d.ts.map +1 -1
- package/lib/packlets/store/fileTreeMemoryStore.js +151 -131
- 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/types/envelope.d.ts +11 -0
- package/lib/packlets/types/envelope.d.ts.map +1 -1
- package/lib/packlets/types/envelope.js.map +1 -1
- 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/5667e36f1c0cc503a5c20a3ebff76e7b9a702d41.tar.log +0 -468
- 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/dedupScope.test.js +0 -434
- package/dist/test/unit/ingest/dedupScope.test.js.map +0 -1
- package/dist/test/unit/ingest/orchestrator.test.js +0 -1058
- 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 -842
- 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 -940
- 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/dedupScope.test.d.ts +0 -2
- package/lib/test/unit/ingest/dedupScope.test.d.ts.map +0 -1
- package/lib/test/unit/ingest/dedupScope.test.js +0 -436
- package/lib/test/unit/ingest/dedupScope.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 -1060
- 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 -844
- 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 -968
- 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 -1872
- 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/dedupScope.test.ts +0 -542
- package/src/test/unit/ingest/orchestrator.test.ts +0 -1355
- 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 -1121
- 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 -306
- package/temp/build/typescript/ts_8nwakTlr.json +0 -1
- package/temp/ts-agent-memory.api.json +0 -21030
- package/temp/ts-agent-memory.api.md +0 -940
- package/tsconfig.json +0 -8
|
@@ -1,313 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2026 Erik Fortune
|
|
3
|
-
* SPDX-License-Identifier: MIT
|
|
4
|
-
*/
|
|
5
|
-
import '@fgv/ts-utils-jest';
|
|
6
|
-
import { Converters } from '@fgv/ts-utils';
|
|
7
|
-
import { BodyConverterRegistry, edgeConverter, edgeTargetConverter, envelopeConverter, envelopeYamlConverter, joinFrontmatter, parseMemoryFile, provenanceConverter, serializeMemoryFile, splitFrontmatter, temporalConverter } from '../../../packlets/converters';
|
|
8
|
-
const validEnvelopeObject = {
|
|
9
|
-
id: 'intro-to-rust',
|
|
10
|
-
entityId: 'intro-to-rust',
|
|
11
|
-
kind: 'knowledge',
|
|
12
|
-
tags: ['rust', 'systems'],
|
|
13
|
-
links: [{ type: 'related', target: { scope: 'knowledge', id: 'ownership' } }],
|
|
14
|
-
created: 1000,
|
|
15
|
-
updated: 2000,
|
|
16
|
-
seq: 5,
|
|
17
|
-
contentHash: 'crc-abc',
|
|
18
|
-
provenance: { source: 'agent', by: 'curator' }
|
|
19
|
-
};
|
|
20
|
-
describe('provenanceConverter', () => {
|
|
21
|
-
test('validates the known fields', () => {
|
|
22
|
-
expect(provenanceConverter.convert({ source: 'human', by: 'erik', model: 'gpt', confidence: 0.9 })).toSucceedWith({ source: 'human', by: 'erik', model: 'gpt', confidence: 0.9 });
|
|
23
|
-
});
|
|
24
|
-
test('preserves opaque extension keys verbatim', () => {
|
|
25
|
-
expect(provenanceConverter.convert({ source: 'agent', sentiment: { score: 0.5 }, epistemic: 'belief' })).toSucceedAndSatisfy((p) => {
|
|
26
|
-
expect(p.source).toBe('agent');
|
|
27
|
-
expect(p.sentiment).toEqual({ score: 0.5 });
|
|
28
|
-
expect(p.epistemic).toBe('belief');
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
test('accepts an arbitrary source string (open vocabulary)', () => {
|
|
32
|
-
expect(provenanceConverter.convert({ source: 'host-ingest' })).toSucceedWith({ source: 'host-ingest' });
|
|
33
|
-
});
|
|
34
|
-
test('validates a scope-qualified derivedFrom (nested { scope, id })', () => {
|
|
35
|
-
expect(provenanceConverter.convert({
|
|
36
|
-
source: 'host-ingest',
|
|
37
|
-
derivedFrom: { scope: 'conversations/conv-a', id: 'turn-3' }
|
|
38
|
-
})).toSucceedAndSatisfy((p) => {
|
|
39
|
-
expect(p.derivedFrom).toEqual({ scope: 'conversations/conv-a', id: 'turn-3' });
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
test('rejects a bare-string derivedFrom (the pre-scoped format)', () => {
|
|
43
|
-
expect(provenanceConverter.convert({ source: 'host-ingest', derivedFrom: 'turn-3' })).toFail();
|
|
44
|
-
});
|
|
45
|
-
test('rejects a derivedFrom missing scope', () => {
|
|
46
|
-
expect(provenanceConverter.convert({ source: 'host-ingest', derivedFrom: { id: 'turn-3' } })).toFailWith(/scope/i);
|
|
47
|
-
});
|
|
48
|
-
test('rejects a derivedFrom missing id', () => {
|
|
49
|
-
expect(provenanceConverter.convert({ source: 'host-ingest', derivedFrom: { scope: 'conversations/conv-a' } })).toFailWith(/id/i);
|
|
50
|
-
});
|
|
51
|
-
test('fails when source is missing', () => {
|
|
52
|
-
expect(provenanceConverter.convert({ by: 'erik' })).toFail();
|
|
53
|
-
});
|
|
54
|
-
test('fails on a non-object', () => {
|
|
55
|
-
expect(provenanceConverter.convert('nope')).toFail();
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
describe('edgeTargetConverter', () => {
|
|
59
|
-
test('validates a scope-qualified target', () => {
|
|
60
|
-
expect(edgeTargetConverter.convert({ scope: 'conversations/conv-a', id: 'turn-3' })).toSucceedAndSatisfy((t) => {
|
|
61
|
-
expect(t).toEqual({ scope: 'conversations/conv-a', id: 'turn-3' });
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
test('rejects a target missing scope', () => {
|
|
65
|
-
expect(edgeTargetConverter.convert({ id: 'turn-3' })).toFailWith(/scope/i);
|
|
66
|
-
});
|
|
67
|
-
test('rejects a target missing id', () => {
|
|
68
|
-
expect(edgeTargetConverter.convert({ scope: 'conversations/conv-a' })).toFailWith(/id/i);
|
|
69
|
-
});
|
|
70
|
-
test('rejects a bare-string target (the pre-scoped format)', () => {
|
|
71
|
-
expect(edgeTargetConverter.convert('turn-3')).toFail();
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
describe('edgeConverter', () => {
|
|
75
|
-
test('validates a full attributed edge', () => {
|
|
76
|
-
expect(edgeConverter.convert({
|
|
77
|
-
type: 'mtm-ref',
|
|
78
|
-
target: { scope: 'conversations/conv-a', id: 'turn-3' },
|
|
79
|
-
confidence: 0.8,
|
|
80
|
-
provenance: { source: 'agent' },
|
|
81
|
-
valid_at: 100,
|
|
82
|
-
invalid_at: 200
|
|
83
|
-
})).toSucceedAndSatisfy((edge) => {
|
|
84
|
-
expect(edge.type).toBe('mtm-ref');
|
|
85
|
-
expect(edge.target).toEqual({ scope: 'conversations/conv-a', id: 'turn-3' });
|
|
86
|
-
expect(edge.confidence).toBe(0.8);
|
|
87
|
-
expect(edge.provenance).toEqual({ source: 'agent' });
|
|
88
|
-
expect(edge.valid_at).toBe(100);
|
|
89
|
-
expect(edge.invalid_at).toBe(200);
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
test('validates a minimal edge', () => {
|
|
93
|
-
expect(edgeConverter.convert({ type: 'related', target: { scope: 'knowledge', id: 'ownership' } })).toSucceedAndSatisfy((edge) => {
|
|
94
|
-
expect(edge.type).toBe('related');
|
|
95
|
-
expect(edge.target).toEqual({ scope: 'knowledge', id: 'ownership' });
|
|
96
|
-
expect(edge.confidence).toBeUndefined();
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
test('accepts a null invalid_at (still valid)', () => {
|
|
100
|
-
expect(edgeConverter.convert({ type: 'related', target: { scope: 'knowledge', id: 'x' }, invalid_at: null })).toSucceedAndSatisfy((edge) => {
|
|
101
|
-
expect(edge.invalid_at).toBeNull();
|
|
102
|
-
});
|
|
103
|
-
});
|
|
104
|
-
test('fails when invalid_at is neither a number nor null', () => {
|
|
105
|
-
expect(edgeConverter.convert({ type: 'related', target: { scope: 'knowledge', id: 'x' }, invalid_at: 'soon' })).toFail();
|
|
106
|
-
});
|
|
107
|
-
test('fails when target is missing', () => {
|
|
108
|
-
expect(edgeConverter.convert({ type: 'related' })).toFail();
|
|
109
|
-
});
|
|
110
|
-
test('fails when target is a bare string (rejects the pre-scoped format)', () => {
|
|
111
|
-
expect(edgeConverter.convert({ type: 'related', target: 'ownership' })).toFail();
|
|
112
|
-
});
|
|
113
|
-
});
|
|
114
|
-
describe('temporalConverter', () => {
|
|
115
|
-
test('validates a temporal block', () => {
|
|
116
|
-
expect(temporalConverter.convert({ valid_at: 1, invalid_at: null })).toSucceedWith({
|
|
117
|
-
valid_at: 1,
|
|
118
|
-
invalid_at: null
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
test('validates an empty temporal block', () => {
|
|
122
|
-
expect(temporalConverter.convert({})).toSucceedWith({});
|
|
123
|
-
});
|
|
124
|
-
});
|
|
125
|
-
describe('envelopeConverter', () => {
|
|
126
|
-
test('validates a full envelope without optional blocks', () => {
|
|
127
|
-
expect(envelopeConverter.convert(validEnvelopeObject)).toSucceedAndSatisfy((envelope) => {
|
|
128
|
-
expect(envelope.id).toBe('intro-to-rust');
|
|
129
|
-
expect(envelope.tags).toEqual(['rust', 'systems']);
|
|
130
|
-
expect(envelope.links).toHaveLength(1);
|
|
131
|
-
expect(envelope.temporal).toBeUndefined();
|
|
132
|
-
expect(envelope.embeddingRef).toBeUndefined();
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
test('validates a temporal envelope with a string embeddingRef', () => {
|
|
136
|
-
expect(envelopeConverter.convert(Object.assign(Object.assign({}, validEnvelopeObject), { temporal: { valid_at: 10 }, embeddingRef: 'vec-1' }))).toSucceedAndSatisfy((envelope) => {
|
|
137
|
-
expect(envelope.temporal).toEqual({ valid_at: 10 });
|
|
138
|
-
expect(envelope.embeddingRef).toBe('vec-1');
|
|
139
|
-
});
|
|
140
|
-
});
|
|
141
|
-
test('accepts a null embeddingRef (not embedded)', () => {
|
|
142
|
-
expect(envelopeConverter.convert(Object.assign(Object.assign({}, validEnvelopeObject), { embeddingRef: null }))).toSucceedAndSatisfy((envelope) => {
|
|
143
|
-
expect(envelope.embeddingRef).toBeNull();
|
|
144
|
-
});
|
|
145
|
-
});
|
|
146
|
-
test('fails when embeddingRef is neither a string nor null', () => {
|
|
147
|
-
expect(envelopeConverter.convert(Object.assign(Object.assign({}, validEnvelopeObject), { embeddingRef: 42 }))).toFail();
|
|
148
|
-
});
|
|
149
|
-
test('rank is absent when not present', () => {
|
|
150
|
-
expect(envelopeConverter.convert(validEnvelopeObject)).toSucceedAndSatisfy((envelope) => {
|
|
151
|
-
expect(envelope.rank).toBeUndefined();
|
|
152
|
-
});
|
|
153
|
-
});
|
|
154
|
-
test('validates and preserves a numeric rank', () => {
|
|
155
|
-
expect(envelopeConverter.convert(Object.assign(Object.assign({}, validEnvelopeObject), { rank: 42 }))).toSucceedAndSatisfy((envelope) => {
|
|
156
|
-
expect(envelope.rank).toBe(42);
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
test('serialize/parse round-trips rank through frontmatter', () => {
|
|
160
|
-
const registry = BodyConverterRegistry.create().orThrow();
|
|
161
|
-
registry.register('knowledge', Converters.string);
|
|
162
|
-
const envelope = envelopeConverter.convert(Object.assign(Object.assign({}, validEnvelopeObject), { rank: 7 })).orThrow();
|
|
163
|
-
const file = serializeMemoryFile(envelope, 'body').orThrow();
|
|
164
|
-
expect(parseMemoryFile(file, registry)).toSucceedAndSatisfy((record) => {
|
|
165
|
-
expect(record.envelope.rank).toBe(7);
|
|
166
|
-
});
|
|
167
|
-
});
|
|
168
|
-
test('fails when rank is not a number', () => {
|
|
169
|
-
expect(envelopeConverter.convert(Object.assign(Object.assign({}, validEnvelopeObject), { rank: 'high' }))).toFail();
|
|
170
|
-
});
|
|
171
|
-
test('fails when a required field is missing', () => {
|
|
172
|
-
const missing = Object.assign({}, validEnvelopeObject);
|
|
173
|
-
delete missing.contentHash;
|
|
174
|
-
expect(envelopeConverter.convert(missing)).toFail();
|
|
175
|
-
});
|
|
176
|
-
});
|
|
177
|
-
describe('envelopeYamlConverter', () => {
|
|
178
|
-
test('parses an envelope from a YAML string', () => {
|
|
179
|
-
const yaml = serializeMemoryFile(envelopeConverter.convert(validEnvelopeObject).orThrow(), 'body text').orThrow();
|
|
180
|
-
const frontmatter = splitFrontmatter(yaml).orThrow().frontmatter;
|
|
181
|
-
expect(envelopeYamlConverter.convert(frontmatter)).toSucceedAndSatisfy((envelope) => {
|
|
182
|
-
expect(envelope.id).toBe('intro-to-rust');
|
|
183
|
-
});
|
|
184
|
-
});
|
|
185
|
-
test('fails on a YAML string that is not an object', () => {
|
|
186
|
-
expect(envelopeYamlConverter.convert('just a scalar')).toFail();
|
|
187
|
-
});
|
|
188
|
-
});
|
|
189
|
-
describe('splitFrontmatter / joinFrontmatter', () => {
|
|
190
|
-
test('splits a well-formed memory file', () => {
|
|
191
|
-
const raw = '---\nid: x\nkind: knowledge\n---\nThe body.\nSecond line.';
|
|
192
|
-
expect(splitFrontmatter(raw)).toSucceedWith({
|
|
193
|
-
frontmatter: 'id: x\nkind: knowledge',
|
|
194
|
-
body: 'The body.\nSecond line.'
|
|
195
|
-
});
|
|
196
|
-
});
|
|
197
|
-
test('strips trailing CR so CRLF-authored files parse identically to LF', () => {
|
|
198
|
-
const raw = '---\r\nid: x\r\nkind: knowledge\r\n---\r\nThe body.\r\nSecond line.';
|
|
199
|
-
expect(splitFrontmatter(raw)).toSucceedWith({
|
|
200
|
-
frontmatter: 'id: x\nkind: knowledge',
|
|
201
|
-
body: 'The body.\nSecond line.'
|
|
202
|
-
});
|
|
203
|
-
});
|
|
204
|
-
test('fails when the opening delimiter is missing', () => {
|
|
205
|
-
expect(splitFrontmatter('no frontmatter here')).toFailWith(/missing opening frontmatter delimiter/i);
|
|
206
|
-
});
|
|
207
|
-
test('fails when the closing delimiter is missing', () => {
|
|
208
|
-
expect(splitFrontmatter('---\nid: x\nstill going')).toFailWith(/missing closing frontmatter delimiter/i);
|
|
209
|
-
});
|
|
210
|
-
test('join adds a trailing newline to the frontmatter when absent', () => {
|
|
211
|
-
expect(joinFrontmatter('id: x', 'body')).toBe('---\nid: x\n---\nbody');
|
|
212
|
-
});
|
|
213
|
-
test('join does not double the trailing newline when present', () => {
|
|
214
|
-
expect(joinFrontmatter('id: x\n', 'body')).toBe('---\nid: x\n---\nbody');
|
|
215
|
-
});
|
|
216
|
-
test('split and join round-trip', () => {
|
|
217
|
-
const raw = '---\nid: x\n---\nbody content';
|
|
218
|
-
const parts = splitFrontmatter(raw).orThrow();
|
|
219
|
-
expect(joinFrontmatter(parts.frontmatter, parts.body)).toBe(raw);
|
|
220
|
-
});
|
|
221
|
-
});
|
|
222
|
-
describe('parseMemoryFile / serializeMemoryFile', () => {
|
|
223
|
-
let registry;
|
|
224
|
-
const knowledgeKind = 'knowledge';
|
|
225
|
-
beforeEach(() => {
|
|
226
|
-
registry = BodyConverterRegistry.create().orThrow();
|
|
227
|
-
registry.register(knowledgeKind, Converters.string);
|
|
228
|
-
});
|
|
229
|
-
test('serializes then parses a record round-trip', () => {
|
|
230
|
-
const envelope = envelopeConverter.convert(validEnvelopeObject).orThrow();
|
|
231
|
-
const file = serializeMemoryFile(envelope, 'The knowledge body.').orThrow();
|
|
232
|
-
expect(parseMemoryFile(file, registry)).toSucceedAndSatisfy((record) => {
|
|
233
|
-
expect(record.envelope.id).toBe('intro-to-rust');
|
|
234
|
-
expect(record.body).toBe('The knowledge body.');
|
|
235
|
-
});
|
|
236
|
-
});
|
|
237
|
-
test('round-trips a scope-qualified edge target through the frontmatter intact', () => {
|
|
238
|
-
const envelope = envelopeConverter
|
|
239
|
-
.convert(Object.assign(Object.assign({}, validEnvelopeObject), { links: [{ type: 'mtm-ref', target: { scope: 'conversations/conv-a', id: 'turn-3' } }] }))
|
|
240
|
-
.orThrow();
|
|
241
|
-
const file = serializeMemoryFile(envelope, 'body').orThrow();
|
|
242
|
-
// On-wire the target is a nested object, NOT a bare scalar.
|
|
243
|
-
expect(file).toMatch(/scope: conversations\/conv-a/);
|
|
244
|
-
expect(file).toMatch(/id: turn-3/);
|
|
245
|
-
expect(parseMemoryFile(file, registry)).toSucceedAndSatisfy((record) => {
|
|
246
|
-
expect(record.envelope.links).toEqual([
|
|
247
|
-
{ type: 'mtm-ref', target: { scope: 'conversations/conv-a', id: 'turn-3' } }
|
|
248
|
-
]);
|
|
249
|
-
// Serializing the reparsed record reproduces byte-identical output.
|
|
250
|
-
expect(serializeMemoryFile(record.envelope, record.body)).toSucceedWith(file);
|
|
251
|
-
});
|
|
252
|
-
});
|
|
253
|
-
test('round-trips a scope-qualified provenance.derivedFrom through the frontmatter intact', () => {
|
|
254
|
-
const envelope = envelopeConverter
|
|
255
|
-
.convert(Object.assign(Object.assign({}, validEnvelopeObject), { provenance: {
|
|
256
|
-
source: 'host-ingest',
|
|
257
|
-
derivedFrom: { scope: 'conversations/conv-a', id: 'turn-3' }
|
|
258
|
-
} }))
|
|
259
|
-
.orThrow();
|
|
260
|
-
const file = serializeMemoryFile(envelope, 'body').orThrow();
|
|
261
|
-
// On-wire the back-reference is a nested object, NOT a bare scalar.
|
|
262
|
-
expect(file).toMatch(/scope: conversations\/conv-a/);
|
|
263
|
-
expect(parseMemoryFile(file, registry)).toSucceedAndSatisfy((record) => {
|
|
264
|
-
expect(record.envelope.provenance.derivedFrom).toEqual({
|
|
265
|
-
scope: 'conversations/conv-a',
|
|
266
|
-
id: 'turn-3'
|
|
267
|
-
});
|
|
268
|
-
expect(serializeMemoryFile(record.envelope, record.body)).toSucceedWith(file);
|
|
269
|
-
});
|
|
270
|
-
});
|
|
271
|
-
test('two records whose derivedFrom share a stem across scopes round-trip as distinct scoped refs', () => {
|
|
272
|
-
// Same idStem ('turn-3'), different scopes — exactly the ambiguity a bare
|
|
273
|
-
// MemoryId could not disambiguate. Each must round-trip to ITS OWN scope.
|
|
274
|
-
const makeFile = (scope) => {
|
|
275
|
-
const envelope = envelopeConverter
|
|
276
|
-
.convert(Object.assign(Object.assign({}, validEnvelopeObject), { provenance: { source: 'host-ingest', derivedFrom: { scope, id: 'turn-3' } } }))
|
|
277
|
-
.orThrow();
|
|
278
|
-
return serializeMemoryFile(envelope, 'body').orThrow();
|
|
279
|
-
};
|
|
280
|
-
const fileA = makeFile('conversations/conv-a');
|
|
281
|
-
const fileB = makeFile('conversations/conv-b');
|
|
282
|
-
expect(fileA).not.toBe(fileB);
|
|
283
|
-
expect(parseMemoryFile(fileA, registry)).toSucceedAndSatisfy((record) => {
|
|
284
|
-
expect(record.envelope.provenance.derivedFrom).toEqual({
|
|
285
|
-
scope: 'conversations/conv-a',
|
|
286
|
-
id: 'turn-3'
|
|
287
|
-
});
|
|
288
|
-
});
|
|
289
|
-
expect(parseMemoryFile(fileB, registry)).toSucceedAndSatisfy((record) => {
|
|
290
|
-
expect(record.envelope.provenance.derivedFrom).toEqual({
|
|
291
|
-
scope: 'conversations/conv-b',
|
|
292
|
-
id: 'turn-3'
|
|
293
|
-
});
|
|
294
|
-
});
|
|
295
|
-
});
|
|
296
|
-
test('fails when the frontmatter cannot be split', () => {
|
|
297
|
-
expect(parseMemoryFile('no delimiters', registry)).toFailWith(/missing opening frontmatter delimiter/i);
|
|
298
|
-
});
|
|
299
|
-
test('fails with envelope context when the envelope is invalid', () => {
|
|
300
|
-
const file = '---\nid: x\n---\nbody';
|
|
301
|
-
expect(parseMemoryFile(file, registry)).toFailWith(/invalid envelope/i);
|
|
302
|
-
});
|
|
303
|
-
test('fails with body context when the body fails the registered converter', () => {
|
|
304
|
-
const envelope = envelopeConverter.convert(Object.assign(Object.assign({}, validEnvelopeObject), { kind: 'unregistered' })).orThrow();
|
|
305
|
-
const file = serializeMemoryFile(envelope, 'body').orThrow();
|
|
306
|
-
expect(parseMemoryFile(file, registry)).toFailWith(/invalid body.*no converter registered/i);
|
|
307
|
-
});
|
|
308
|
-
test('serialize fails (with id context) when the envelope cannot be dumped to YAML', () => {
|
|
309
|
-
const unserializable = Object.assign(Object.assign({}, validEnvelopeObject), { weird: BigInt(10) });
|
|
310
|
-
expect(serializeMemoryFile(unserializable, 'body')).toFailWith(/failed to serialize envelope/i);
|
|
311
|
-
});
|
|
312
|
-
});
|
|
313
|
-
//# sourceMappingURL=envelopeConverter.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"envelopeConverter.test.js","sourceRoot":"","sources":["../../../../src/test/unit/converters/envelopeCon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AG,uBAAuB,CAAC;QACrC,MAAM,CAAC,eAAe,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,mBAAmB,CAAC,CAAC;IAC1E,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,sEAAsE,EAAE,GAAG,EAAE;QAChF,MAAM,QAAQ,GAAG,iBAAiB,CAAC,OAAO,iCAAM,mBAAmB,KAAE,IAAI,EAAE,cAAc,IAAG,CAAC,OAAO,EAAE,CAAC;QACvG,MAAM,IAAI,GAAG,mBAAmB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,OAAO,EAAE,CAAC;QAC7D,MAAM,CAAC,eAAe,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,wCAAwC,CAAC,CAAC;IAC/F,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,8EAA8E,EAAE,GAAG,EAAE;QACxF,MAAM,cAAc,GAAG,gCAAK,mBAAmB,KAAE,KAAK,EAAE,MAAM,CAAC,EAAE,CAAC,GAAgC,CAAC;QACnG,MAAM,CAAC,mBAAmB,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,+BAA+B,CAAC,CAAC;IAClG,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["/*\n * Copyright (c) 2026 Erik Fortune\n * SPDX-License-Identifier: MIT\n */\n\nimport '@fgv/ts-utils-jest';\nimport { Converters } from '@fgv/ts-utils';\nimport {\n BodyConverterRegistry,\n edgeConverter,\n edgeTargetConverter,\n envelopeConverter,\n envelopeYamlConverter,\n joinFrontmatter,\n parseMemoryFile,\n provenanceConverter,\n serializeMemoryFile,\n splitFrontmatter,\n temporalConverter\n} from '../../../packlets/converters';\nimport { IMemoryEnvelope, Kind } from '../../../packlets/types';\n\nconst validEnvelopeObject: Record<string, unknown> = {\n id: 'intro-to-rust',\n entityId: 'intro-to-rust',\n kind: 'knowledge',\n tags: ['rust', 'systems'],\n links: [{ type: 'related', target: { scope: 'knowledge', id: 'ownership' } }],\n created: 1000,\n updated: 2000,\n seq: 5,\n contentHash: 'crc-abc',\n provenance: { source: 'agent', by: 'curator' }\n};\n\ndescribe('provenanceConverter', () => {\n test('validates the known fields', () => {\n expect(\n provenanceConverter.convert({ source: 'human', by: 'erik', model: 'gpt', confidence: 0.9 })\n ).toSucceedWith({ source: 'human', by: 'erik', model: 'gpt', confidence: 0.9 });\n });\n\n test('preserves opaque extension keys verbatim', () => {\n expect(\n provenanceConverter.convert({ source: 'agent', sentiment: { score: 0.5 }, epistemic: 'belief' })\n ).toSucceedAndSatisfy((p) => {\n expect(p.source).toBe('agent');\n expect(p.sentiment).toEqual({ score: 0.5 });\n expect(p.epistemic).toBe('belief');\n });\n });\n\n test('accepts an arbitrary source string (open vocabulary)', () => {\n expect(provenanceConverter.convert({ source: 'host-ingest' })).toSucceedWith({ source: 'host-ingest' });\n });\n\n test('validates a scope-qualified derivedFrom (nested { scope, id })', () => {\n expect(\n provenanceConverter.convert({\n source: 'host-ingest',\n derivedFrom: { scope: 'conversations/conv-a', id: 'turn-3' }\n })\n ).toSucceedAndSatisfy((p) => {\n expect(p.derivedFrom).toEqual({ scope: 'conversations/conv-a', id: 'turn-3' });\n });\n });\n\n test('rejects a bare-string derivedFrom (the pre-scoped format)', () => {\n expect(provenanceConverter.convert({ source: 'host-ingest', derivedFrom: 'turn-3' })).toFail();\n });\n\n test('rejects a derivedFrom missing scope', () => {\n expect(provenanceConverter.convert({ source: 'host-ingest', derivedFrom: { id: 'turn-3' } })).toFailWith(\n /scope/i\n );\n });\n\n test('rejects a derivedFrom missing id', () => {\n expect(\n provenanceConverter.convert({ source: 'host-ingest', derivedFrom: { scope: 'conversations/conv-a' } })\n ).toFailWith(/id/i);\n });\n\n test('fails when source is missing', () => {\n expect(provenanceConverter.convert({ by: 'erik' })).toFail();\n });\n\n test('fails on a non-object', () => {\n expect(provenanceConverter.convert('nope')).toFail();\n });\n});\n\ndescribe('edgeTargetConverter', () => {\n test('validates a scope-qualified target', () => {\n expect(edgeTargetConverter.convert({ scope: 'conversations/conv-a', id: 'turn-3' })).toSucceedAndSatisfy(\n (t) => {\n expect(t).toEqual({ scope: 'conversations/conv-a', id: 'turn-3' });\n }\n );\n });\n\n test('rejects a target missing scope', () => {\n expect(edgeTargetConverter.convert({ id: 'turn-3' })).toFailWith(/scope/i);\n });\n\n test('rejects a target missing id', () => {\n expect(edgeTargetConverter.convert({ scope: 'conversations/conv-a' })).toFailWith(/id/i);\n });\n\n test('rejects a bare-string target (the pre-scoped format)', () => {\n expect(edgeTargetConverter.convert('turn-3')).toFail();\n });\n});\n\ndescribe('edgeConverter', () => {\n test('validates a full attributed edge', () => {\n expect(\n edgeConverter.convert({\n type: 'mtm-ref',\n target: { scope: 'conversations/conv-a', id: 'turn-3' },\n confidence: 0.8,\n provenance: { source: 'agent' },\n valid_at: 100,\n invalid_at: 200\n })\n ).toSucceedAndSatisfy((edge) => {\n expect(edge.type).toBe('mtm-ref');\n expect(edge.target).toEqual({ scope: 'conversations/conv-a', id: 'turn-3' });\n expect(edge.confidence).toBe(0.8);\n expect(edge.provenance).toEqual({ source: 'agent' });\n expect(edge.valid_at).toBe(100);\n expect(edge.invalid_at).toBe(200);\n });\n });\n\n test('validates a minimal edge', () => {\n expect(\n edgeConverter.convert({ type: 'related', target: { scope: 'knowledge', id: 'ownership' } })\n ).toSucceedAndSatisfy((edge) => {\n expect(edge.type).toBe('related');\n expect(edge.target).toEqual({ scope: 'knowledge', id: 'ownership' });\n expect(edge.confidence).toBeUndefined();\n });\n });\n\n test('accepts a null invalid_at (still valid)', () => {\n expect(\n edgeConverter.convert({ type: 'related', target: { scope: 'knowledge', id: 'x' }, invalid_at: null })\n ).toSucceedAndSatisfy((edge) => {\n expect(edge.invalid_at).toBeNull();\n });\n });\n\n test('fails when invalid_at is neither a number nor null', () => {\n expect(\n edgeConverter.convert({ type: 'related', target: { scope: 'knowledge', id: 'x' }, invalid_at: 'soon' })\n ).toFail();\n });\n\n test('fails when target is missing', () => {\n expect(edgeConverter.convert({ type: 'related' })).toFail();\n });\n\n test('fails when target is a bare string (rejects the pre-scoped format)', () => {\n expect(edgeConverter.convert({ type: 'related', target: 'ownership' })).toFail();\n });\n});\n\ndescribe('temporalConverter', () => {\n test('validates a temporal block', () => {\n expect(temporalConverter.convert({ valid_at: 1, invalid_at: null })).toSucceedWith({\n valid_at: 1,\n invalid_at: null\n });\n });\n\n test('validates an empty temporal block', () => {\n expect(temporalConverter.convert({})).toSucceedWith({});\n });\n});\n\ndescribe('envelopeConverter', () => {\n test('validates a full envelope without optional blocks', () => {\n expect(envelopeConverter.convert(validEnvelopeObject)).toSucceedAndSatisfy((envelope) => {\n expect(envelope.id).toBe('intro-to-rust');\n expect(envelope.tags).toEqual(['rust', 'systems']);\n expect(envelope.links).toHaveLength(1);\n expect(envelope.temporal).toBeUndefined();\n expect(envelope.embeddingRef).toBeUndefined();\n });\n });\n\n test('validates a temporal envelope with a string embeddingRef', () => {\n expect(\n envelopeConverter.convert({\n ...validEnvelopeObject,\n temporal: { valid_at: 10 },\n embeddingRef: 'vec-1'\n })\n ).toSucceedAndSatisfy((envelope) => {\n expect(envelope.temporal).toEqual({ valid_at: 10 });\n expect(envelope.embeddingRef).toBe('vec-1');\n });\n });\n\n test('accepts a null embeddingRef (not embedded)', () => {\n expect(envelopeConverter.convert({ ...validEnvelopeObject, embeddingRef: null })).toSucceedAndSatisfy(\n (envelope) => {\n expect(envelope.embeddingRef).toBeNull();\n }\n );\n });\n\n test('fails when embeddingRef is neither a string nor null', () => {\n expect(envelopeConverter.convert({ ...validEnvelopeObject, embeddingRef: 42 })).toFail();\n });\n\n test('rank is absent when not present', () => {\n expect(envelopeConverter.convert(validEnvelopeObject)).toSucceedAndSatisfy((envelope) => {\n expect(envelope.rank).toBeUndefined();\n });\n });\n\n test('validates and preserves a numeric rank', () => {\n expect(envelopeConverter.convert({ ...validEnvelopeObject, rank: 42 })).toSucceedAndSatisfy(\n (envelope) => {\n expect(envelope.rank).toBe(42);\n }\n );\n });\n\n test('serialize/parse round-trips rank through frontmatter', () => {\n const registry = BodyConverterRegistry.create().orThrow();\n registry.register('knowledge' as Kind, Converters.string);\n const envelope = envelopeConverter.convert({ ...validEnvelopeObject, rank: 7 }).orThrow();\n const file = serializeMemoryFile(envelope, 'body').orThrow();\n expect(parseMemoryFile(file, registry)).toSucceedAndSatisfy((record) => {\n expect(record.envelope.rank).toBe(7);\n });\n });\n\n test('fails when rank is not a number', () => {\n expect(envelopeConverter.convert({ ...validEnvelopeObject, rank: 'high' })).toFail();\n });\n\n test('fails when a required field is missing', () => {\n const missing: Record<string, unknown> = { ...validEnvelopeObject };\n delete missing.contentHash;\n expect(envelopeConverter.convert(missing)).toFail();\n });\n});\n\ndescribe('envelopeYamlConverter', () => {\n test('parses an envelope from a YAML string', () => {\n const yaml = serializeMemoryFile(\n envelopeConverter.convert(validEnvelopeObject).orThrow(),\n 'body text'\n ).orThrow();\n const frontmatter = splitFrontmatter(yaml).orThrow().frontmatter;\n expect(envelopeYamlConverter.convert(frontmatter)).toSucceedAndSatisfy((envelope) => {\n expect(envelope.id).toBe('intro-to-rust');\n });\n });\n\n test('fails on a YAML string that is not an object', () => {\n expect(envelopeYamlConverter.convert('just a scalar')).toFail();\n });\n});\n\ndescribe('splitFrontmatter / joinFrontmatter', () => {\n test('splits a well-formed memory file', () => {\n const raw = '---\\nid: x\\nkind: knowledge\\n---\\nThe body.\\nSecond line.';\n expect(splitFrontmatter(raw)).toSucceedWith({\n frontmatter: 'id: x\\nkind: knowledge',\n body: 'The body.\\nSecond line.'\n });\n });\n\n test('strips trailing CR so CRLF-authored files parse identically to LF', () => {\n const raw = '---\\r\\nid: x\\r\\nkind: knowledge\\r\\n---\\r\\nThe body.\\r\\nSecond line.';\n expect(splitFrontmatter(raw)).toSucceedWith({\n frontmatter: 'id: x\\nkind: knowledge',\n body: 'The body.\\nSecond line.'\n });\n });\n\n test('fails when the opening delimiter is missing', () => {\n expect(splitFrontmatter('no frontmatter here')).toFailWith(/missing opening frontmatter delimiter/i);\n });\n\n test('fails when the closing delimiter is missing', () => {\n expect(splitFrontmatter('---\\nid: x\\nstill going')).toFailWith(/missing closing frontmatter delimiter/i);\n });\n\n test('join adds a trailing newline to the frontmatter when absent', () => {\n expect(joinFrontmatter('id: x', 'body')).toBe('---\\nid: x\\n---\\nbody');\n });\n\n test('join does not double the trailing newline when present', () => {\n expect(joinFrontmatter('id: x\\n', 'body')).toBe('---\\nid: x\\n---\\nbody');\n });\n\n test('split and join round-trip', () => {\n const raw = '---\\nid: x\\n---\\nbody content';\n const parts = splitFrontmatter(raw).orThrow();\n expect(joinFrontmatter(parts.frontmatter, parts.body)).toBe(raw);\n });\n});\n\ndescribe('parseMemoryFile / serializeMemoryFile', () => {\n let registry: BodyConverterRegistry;\n const knowledgeKind: Kind = 'knowledge' as Kind;\n\n beforeEach(() => {\n registry = BodyConverterRegistry.create().orThrow();\n registry.register(knowledgeKind, Converters.string);\n });\n\n test('serializes then parses a record round-trip', () => {\n const envelope = envelopeConverter.convert(validEnvelopeObject).orThrow();\n const file = serializeMemoryFile(envelope, 'The knowledge body.').orThrow();\n expect(parseMemoryFile(file, registry)).toSucceedAndSatisfy((record) => {\n expect(record.envelope.id).toBe('intro-to-rust');\n expect(record.body).toBe('The knowledge body.');\n });\n });\n\n test('round-trips a scope-qualified edge target through the frontmatter intact', () => {\n const envelope = envelopeConverter\n .convert({\n ...validEnvelopeObject,\n links: [{ type: 'mtm-ref', target: { scope: 'conversations/conv-a', id: 'turn-3' } }]\n })\n .orThrow();\n const file = serializeMemoryFile(envelope, 'body').orThrow();\n // On-wire the target is a nested object, NOT a bare scalar.\n expect(file).toMatch(/scope: conversations\\/conv-a/);\n expect(file).toMatch(/id: turn-3/);\n expect(parseMemoryFile(file, registry)).toSucceedAndSatisfy((record) => {\n expect(record.envelope.links).toEqual([\n { type: 'mtm-ref', target: { scope: 'conversations/conv-a', id: 'turn-3' } }\n ]);\n // Serializing the reparsed record reproduces byte-identical output.\n expect(serializeMemoryFile(record.envelope, record.body as string)).toSucceedWith(file);\n });\n });\n\n test('round-trips a scope-qualified provenance.derivedFrom through the frontmatter intact', () => {\n const envelope = envelopeConverter\n .convert({\n ...validEnvelopeObject,\n provenance: {\n source: 'host-ingest',\n derivedFrom: { scope: 'conversations/conv-a', id: 'turn-3' }\n }\n })\n .orThrow();\n const file = serializeMemoryFile(envelope, 'body').orThrow();\n // On-wire the back-reference is a nested object, NOT a bare scalar.\n expect(file).toMatch(/scope: conversations\\/conv-a/);\n expect(parseMemoryFile(file, registry)).toSucceedAndSatisfy((record) => {\n expect(record.envelope.provenance.derivedFrom).toEqual({\n scope: 'conversations/conv-a',\n id: 'turn-3'\n });\n expect(serializeMemoryFile(record.envelope, record.body as string)).toSucceedWith(file);\n });\n });\n\n test('two records whose derivedFrom share a stem across scopes round-trip as distinct scoped refs', () => {\n // Same idStem ('turn-3'), different scopes — exactly the ambiguity a bare\n // MemoryId could not disambiguate. Each must round-trip to ITS OWN scope.\n const makeFile = (scope: string): string => {\n const envelope = envelopeConverter\n .convert({\n ...validEnvelopeObject,\n provenance: { source: 'host-ingest', derivedFrom: { scope, id: 'turn-3' } }\n })\n .orThrow();\n return serializeMemoryFile(envelope, 'body').orThrow();\n };\n const fileA = makeFile('conversations/conv-a');\n const fileB = makeFile('conversations/conv-b');\n expect(fileA).not.toBe(fileB);\n expect(parseMemoryFile(fileA, registry)).toSucceedAndSatisfy((record) => {\n expect(record.envelope.provenance.derivedFrom).toEqual({\n scope: 'conversations/conv-a',\n id: 'turn-3'\n });\n });\n expect(parseMemoryFile(fileB, registry)).toSucceedAndSatisfy((record) => {\n expect(record.envelope.provenance.derivedFrom).toEqual({\n scope: 'conversations/conv-b',\n id: 'turn-3'\n });\n });\n });\n\n test('fails when the frontmatter cannot be split', () => {\n expect(parseMemoryFile('no delimiters', registry)).toFailWith(/missing opening frontmatter delimiter/i);\n });\n\n test('fails with envelope context when the envelope is invalid', () => {\n const file = '---\\nid: x\\n---\\nbody';\n expect(parseMemoryFile(file, registry)).toFailWith(/invalid envelope/i);\n });\n\n test('fails with body context when the body fails the registered converter', () => {\n const envelope = envelopeConverter.convert({ ...validEnvelopeObject, kind: 'unregistered' }).orThrow();\n const file = serializeMemoryFile(envelope, 'body').orThrow();\n expect(parseMemoryFile(file, registry)).toFailWith(/invalid body.*no converter registered/i);\n });\n\n test('serialize fails (with id context) when the envelope cannot be dumped to YAML', () => {\n const unserializable = { ...validEnvelopeObject, weird: BigInt(10) } as unknown as IMemoryEnvelope;\n expect(serializeMemoryFile(unserializable, 'body')).toFailWith(/failed to serialize envelope/i);\n });\n});\n"]}
|
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2026 Erik Fortune
|
|
3
|
-
* SPDX-License-Identifier: MIT
|
|
4
|
-
*/
|
|
5
|
-
import '@fgv/ts-utils-jest';
|
|
6
|
-
import { MemoryIndex, envelopeConverter, rankCompare } from '../../../index';
|
|
7
|
-
/**
|
|
8
|
-
* The scope every link target in this fixture lives under. Links are authored as
|
|
9
|
-
* bare id strings and resolved to `{ scope: LINK_TARGET_SCOPE, id }`, so the
|
|
10
|
-
* cross-scope source tests can share one target while their sources differ.
|
|
11
|
-
*/
|
|
12
|
-
const LINK_TARGET_SCOPE = 'knowledge';
|
|
13
|
-
/** A scope-qualified backlink-target query for the fixed link-target scope. */
|
|
14
|
-
function bt(id) {
|
|
15
|
-
return { scope: LINK_TARGET_SCOPE, id: id };
|
|
16
|
-
}
|
|
17
|
-
/** Extract the bare ids from a set of scope-qualified targets (backlink results). */
|
|
18
|
-
function targetIds(targets) {
|
|
19
|
-
return targets.map((t) => t.id);
|
|
20
|
-
}
|
|
21
|
-
function makeEntry(spec) {
|
|
22
|
-
var _a, _b, _c, _d, _e, _f;
|
|
23
|
-
const record = {
|
|
24
|
-
envelope: envelopeConverter
|
|
25
|
-
.convert(Object.assign(Object.assign({ id: spec.id, entityId: spec.id, kind: (_a = spec.kind) !== null && _a !== void 0 ? _a : 'knowledge', tags: (_b = spec.tags) !== null && _b !== void 0 ? _b : [], links: ((_c = spec.links) !== null && _c !== void 0 ? _c : []).map((target) => ({
|
|
26
|
-
type: 'rel',
|
|
27
|
-
target: { scope: LINK_TARGET_SCOPE, id: target }
|
|
28
|
-
})), created: 0, updated: (_d = spec.updated) !== null && _d !== void 0 ? _d : 0, seq: (_e = spec.seq) !== null && _e !== void 0 ? _e : 0, contentHash: 'h' }, (spec.rank !== undefined ? { rank: spec.rank } : {})), { provenance: { source: 'agent' } }))
|
|
29
|
-
.orThrow(),
|
|
30
|
-
body: `body-${spec.id}`
|
|
31
|
-
};
|
|
32
|
-
return { scope: ((_f = spec.scope) !== null && _f !== void 0 ? _f : 'knowledge'), record };
|
|
33
|
-
}
|
|
34
|
-
function ids(records) {
|
|
35
|
-
return records.map((r) => r.envelope.id);
|
|
36
|
-
}
|
|
37
|
-
describe('MemoryIndex', () => {
|
|
38
|
-
let index;
|
|
39
|
-
beforeEach(() => {
|
|
40
|
-
index = MemoryIndex.create().orThrow();
|
|
41
|
-
});
|
|
42
|
-
describe('create', () => {
|
|
43
|
-
test('starts empty', () => {
|
|
44
|
-
expect(index.entries()).toHaveLength(0);
|
|
45
|
-
expect(index.byKind('knowledge')).toHaveLength(0);
|
|
46
|
-
expect(index.byTag('any')).toHaveLength(0);
|
|
47
|
-
expect(index.byRecency()).toHaveLength(0);
|
|
48
|
-
expect(index.backlinks(bt('none'))).toHaveLength(0);
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
describe('rebuild', () => {
|
|
52
|
-
test('indexes every entry and reports the count', () => {
|
|
53
|
-
const entries = [
|
|
54
|
-
makeEntry({ id: 'a', tags: ['x'], links: ['b'] }),
|
|
55
|
-
makeEntry({ id: 'b', tags: ['x', 'y'] })
|
|
56
|
-
];
|
|
57
|
-
expect(index.rebuild(entries)).toSucceedWith(2);
|
|
58
|
-
expect(index.entries()).toHaveLength(2);
|
|
59
|
-
expect([...ids(index.byKind('knowledge'))].sort()).toEqual(['a', 'b']);
|
|
60
|
-
expect([...ids(index.byTag('x'))].sort()).toEqual(['a', 'b']);
|
|
61
|
-
expect(ids(index.byTag('y'))).toEqual(['b']);
|
|
62
|
-
expect(targetIds(index.backlinks(bt('b')))).toEqual(['a']);
|
|
63
|
-
});
|
|
64
|
-
test('clears prior state', () => {
|
|
65
|
-
index.rebuild([makeEntry({ id: 'a', tags: ['x'] })]).orThrow();
|
|
66
|
-
expect(index.rebuild([makeEntry({ id: 'c', tags: ['z'] })])).toSucceedWith(1);
|
|
67
|
-
expect(ids(index.entries().map((e) => e.record))).toEqual(['c']);
|
|
68
|
-
expect(index.byTag('x')).toHaveLength(0);
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
describe('patch', () => {
|
|
72
|
-
test('put inserts a new entry and returns it', () => {
|
|
73
|
-
const entry = makeEntry({ id: 'a', tags: ['x'], links: ['b'] });
|
|
74
|
-
expect(index.patch('put', entry)).toSucceedWith(entry);
|
|
75
|
-
expect(ids(index.byKind('knowledge'))).toEqual(['a']);
|
|
76
|
-
expect(targetIds(index.backlinks(bt('b')))).toEqual(['a']);
|
|
77
|
-
});
|
|
78
|
-
test('put on an existing key replaces stale associations', () => {
|
|
79
|
-
index.patch('put', makeEntry({ id: 'a', kind: 'knowledge', tags: ['old'], links: ['b'] })).orThrow();
|
|
80
|
-
index.patch('put', makeEntry({ id: 'a', kind: 'note', tags: ['new'], links: ['c'] })).orThrow();
|
|
81
|
-
expect(index.entries()).toHaveLength(1);
|
|
82
|
-
expect(index.byTag('old')).toHaveLength(0);
|
|
83
|
-
expect(ids(index.byTag('new'))).toEqual(['a']);
|
|
84
|
-
expect(index.byKind('knowledge')).toHaveLength(0);
|
|
85
|
-
expect(ids(index.byKind('note'))).toEqual(['a']);
|
|
86
|
-
expect(index.backlinks(bt('b'))).toHaveLength(0);
|
|
87
|
-
expect(targetIds(index.backlinks(bt('c')))).toEqual(['a']);
|
|
88
|
-
});
|
|
89
|
-
test('delete removes the entry and its associations', () => {
|
|
90
|
-
const entry = makeEntry({ id: 'a', tags: ['x'], links: ['b'] });
|
|
91
|
-
index.patch('put', entry).orThrow();
|
|
92
|
-
expect(index.patch('delete', entry)).toSucceedWith(entry);
|
|
93
|
-
expect(index.entries()).toHaveLength(0);
|
|
94
|
-
expect(index.byTag('x')).toHaveLength(0);
|
|
95
|
-
expect(index.backlinks(bt('b'))).toHaveLength(0);
|
|
96
|
-
});
|
|
97
|
-
test('delete of an absent key is a no-op that still succeeds', () => {
|
|
98
|
-
const entry = makeEntry({ id: 'ghost' });
|
|
99
|
-
expect(index.patch('delete', entry)).toSucceedWith(entry);
|
|
100
|
-
expect(index.entries()).toHaveLength(0);
|
|
101
|
-
});
|
|
102
|
-
test('distinguishes entries with the same id across scopes', () => {
|
|
103
|
-
index.patch('put', makeEntry({ id: 'turn-0', scope: 'conversations/c1' })).orThrow();
|
|
104
|
-
index.patch('put', makeEntry({ id: 'turn-0', scope: 'conversations/c2' })).orThrow();
|
|
105
|
-
expect(index.entries()).toHaveLength(2);
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
describe('byRecency', () => {
|
|
109
|
-
test('orders most-recently-updated first, breaking ties by seq', () => {
|
|
110
|
-
index
|
|
111
|
-
.rebuild([
|
|
112
|
-
makeEntry({ id: 'old', updated: 100, seq: 1 }),
|
|
113
|
-
makeEntry({ id: 'newest', updated: 300, seq: 3 }),
|
|
114
|
-
makeEntry({ id: 'tie-lo', updated: 200, seq: 4 }),
|
|
115
|
-
makeEntry({ id: 'tie-hi', updated: 200, seq: 9 })
|
|
116
|
-
])
|
|
117
|
-
.orThrow();
|
|
118
|
-
expect(ids(index.byRecency())).toEqual(['newest', 'tie-hi', 'tie-lo', 'old']);
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
describe('byRank', () => {
|
|
122
|
-
test('orders by rank descending, absent-rank records last, recency tiebreak', () => {
|
|
123
|
-
index
|
|
124
|
-
.rebuild([
|
|
125
|
-
makeEntry({ id: 'mid', rank: 5, updated: 100, seq: 1 }),
|
|
126
|
-
makeEntry({ id: 'top', rank: 9, updated: 100, seq: 2 }),
|
|
127
|
-
makeEntry({ id: 'tie-lo', rank: 3, updated: 200, seq: 4 }),
|
|
128
|
-
makeEntry({ id: 'tie-hi', rank: 3, updated: 200, seq: 9 }),
|
|
129
|
-
makeEntry({ id: 'unranked-old', updated: 100, seq: 5 }),
|
|
130
|
-
makeEntry({ id: 'unranked-new', updated: 400, seq: 6 })
|
|
131
|
-
])
|
|
132
|
-
.orThrow();
|
|
133
|
-
// ranked (desc): top(9), mid(5), tie-hi(3,seq9), tie-lo(3,seq4);
|
|
134
|
-
// then unranked by recency: unranked-new(updated400), unranked-old(updated100).
|
|
135
|
-
expect(ids(index.byRank())).toEqual(['top', 'mid', 'tie-hi', 'tie-lo', 'unranked-new', 'unranked-old']);
|
|
136
|
-
});
|
|
137
|
-
test('is empty on an empty index', () => {
|
|
138
|
-
expect(index.byRank()).toHaveLength(0);
|
|
139
|
-
});
|
|
140
|
-
test('sorts a ranked record ahead of an earlier-listed absent-rank record', () => {
|
|
141
|
-
// Input lists the absent-rank record first so the sort compares (ranked, absent),
|
|
142
|
-
// exercising the ranked-before-absent direction of the comparator.
|
|
143
|
-
index
|
|
144
|
-
.rebuild([
|
|
145
|
-
makeEntry({ id: 'unranked', updated: 100, seq: 1 }),
|
|
146
|
-
makeEntry({ id: 'ranked', rank: 5, updated: 100, seq: 2 })
|
|
147
|
-
])
|
|
148
|
-
.orThrow();
|
|
149
|
-
expect(ids(index.byRank())).toEqual(['ranked', 'unranked']);
|
|
150
|
-
});
|
|
151
|
-
test('orders two absent-rank records by recency alone', () => {
|
|
152
|
-
index
|
|
153
|
-
.rebuild([makeEntry({ id: 'a', updated: 100, seq: 1 }), makeEntry({ id: 'b', updated: 300, seq: 2 })])
|
|
154
|
-
.orThrow();
|
|
155
|
-
expect(ids(index.byRank())).toEqual(['b', 'a']);
|
|
156
|
-
});
|
|
157
|
-
test("index byRank agrees pairwise with the retrieve packlet's rankCompare", () => {
|
|
158
|
-
// Guard against the two hand-duplicated comparators (index `_compareByRank`
|
|
159
|
-
// and retrieve `rankCompare`) drifting: a future tie-break edit to one that
|
|
160
|
-
// diverges from the other is caught here on a shared mixed fixture.
|
|
161
|
-
const fixture = [
|
|
162
|
-
makeEntry({ id: 'r-top', rank: 9, updated: 100, seq: 1 }),
|
|
163
|
-
makeEntry({ id: 'r-mid', rank: 5, updated: 400, seq: 2 }),
|
|
164
|
-
makeEntry({ id: 'r-tie-a', rank: 3, updated: 200, seq: 3 }),
|
|
165
|
-
makeEntry({ id: 'r-tie-b', rank: 3, updated: 200, seq: 8 }),
|
|
166
|
-
makeEntry({ id: 'absent-old', updated: 100, seq: 4 }),
|
|
167
|
-
makeEntry({ id: 'absent-new', updated: 500, seq: 5 })
|
|
168
|
-
];
|
|
169
|
-
index.rebuild(fixture).orThrow();
|
|
170
|
-
const viaIndex = ids(index.byRank());
|
|
171
|
-
const viaRankCompare = ids(fixture.map((e) => e.record).sort(rankCompare));
|
|
172
|
-
expect(viaIndex).toEqual(viaRankCompare);
|
|
173
|
-
// And the shared expected ordering is what both must produce.
|
|
174
|
-
expect(viaIndex).toEqual(['r-top', 'r-mid', 'r-tie-b', 'r-tie-a', 'absent-new', 'absent-old']);
|
|
175
|
-
});
|
|
176
|
-
});
|
|
177
|
-
describe('backlinks', () => {
|
|
178
|
-
test('aggregates multiple sources pointing at one target', () => {
|
|
179
|
-
index
|
|
180
|
-
.rebuild([makeEntry({ id: 'a', links: ['target'] }), makeEntry({ id: 'b', links: ['target'] })])
|
|
181
|
-
.orThrow();
|
|
182
|
-
expect(targetIds(index.backlinks(bt('target'))).sort()).toEqual(['a', 'b']);
|
|
183
|
-
});
|
|
184
|
-
test('drops the target set once the last source is removed', () => {
|
|
185
|
-
const a = makeEntry({ id: 'a', links: ['target'] });
|
|
186
|
-
index.patch('put', a).orThrow();
|
|
187
|
-
index.patch('delete', a).orThrow();
|
|
188
|
-
expect(index.backlinks(bt('target'))).toHaveLength(0);
|
|
189
|
-
});
|
|
190
|
-
test('tracks same-id sources across scopes independently', () => {
|
|
191
|
-
// Two distinct records that share the id 'a' under different scopes, both
|
|
192
|
-
// linking 'target'. Removing one must NOT drop the other's inbound edge.
|
|
193
|
-
const a1 = makeEntry({ id: 'a', scope: 'conversations/c1', links: ['target'] });
|
|
194
|
-
const a2 = makeEntry({ id: 'a', scope: 'conversations/c2', links: ['target'] });
|
|
195
|
-
index.patch('put', a1).orThrow();
|
|
196
|
-
index.patch('put', a2).orThrow();
|
|
197
|
-
expect(targetIds(index.backlinks(bt('target')))).toEqual(['a', 'a']);
|
|
198
|
-
index.patch('delete', a1).orThrow();
|
|
199
|
-
expect(targetIds(index.backlinks(bt('target')))).toEqual(['a']);
|
|
200
|
-
});
|
|
201
|
-
});
|
|
202
|
-
describe('duplicate associations', () => {
|
|
203
|
-
test('a record with duplicate tags and links is cleaned up exactly once on delete', () => {
|
|
204
|
-
const entry = makeEntry({ id: 'a', tags: ['dup', 'dup'], links: ['t', 't'] });
|
|
205
|
-
index.patch('put', entry).orThrow();
|
|
206
|
-
expect(ids(index.byTag('dup'))).toEqual(['a']);
|
|
207
|
-
expect(targetIds(index.backlinks(bt('t')))).toEqual(['a']);
|
|
208
|
-
index.patch('delete', entry).orThrow();
|
|
209
|
-
expect(index.byTag('dup')).toHaveLength(0);
|
|
210
|
-
expect(index.backlinks(bt('t'))).toHaveLength(0);
|
|
211
|
-
});
|
|
212
|
-
});
|
|
213
|
-
});
|
|
214
|
-
//# sourceMappingURL=memoryIndex.test.js.map
|