@atomicmemory/core 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +27 -0
- package/LICENSE +201 -0
- package/README.md +314 -0
- package/dist/app/bind-ephemeral.d.ts +18 -0
- package/dist/app/bind-ephemeral.js +22 -0
- package/dist/app/cors-headers.d.ts +12 -0
- package/dist/app/cors-headers.js +18 -0
- package/dist/app/create-app.d.ts +25 -0
- package/dist/app/create-app.js +156 -0
- package/dist/app/runtime-config-route-snapshot.d.ts +27 -0
- package/dist/app/runtime-config-route-snapshot.js +27 -0
- package/dist/app/runtime-container.d.ts +281 -0
- package/dist/app/runtime-container.js +297 -0
- package/dist/app/startup-checks.d.ts +28 -0
- package/dist/app/startup-checks.js +45 -0
- package/dist/bin.d.ts +17 -0
- package/dist/bin.js +128 -0
- package/dist/config.d.ts +680 -0
- package/dist/config.js +808 -0
- package/dist/db/agent-trust-repository.d.ts +49 -0
- package/dist/db/agent-trust-repository.js +66 -0
- package/dist/db/belief-edges-repository.d.ts +68 -0
- package/dist/db/belief-edges-repository.js +124 -0
- package/dist/db/claim-repository.d.ts +6 -0
- package/dist/db/claim-repository.js +4 -0
- package/dist/db/contradictions-repository.d.ts +56 -0
- package/dist/db/contradictions-repository.js +88 -0
- package/dist/db/document-chunk-repository.d.ts +48 -0
- package/dist/db/document-chunk-repository.js +145 -0
- package/dist/db/document-chunk-types.d.ts +35 -0
- package/dist/db/document-chunk-types.js +9 -0
- package/dist/db/document-list-cursor.d.ts +45 -0
- package/dist/db/document-list-cursor.js +111 -0
- package/dist/db/document-list-repository.d.ts +103 -0
- package/dist/db/document-list-repository.js +204 -0
- package/dist/db/entity-cards-repository.d.ts +37 -0
- package/dist/db/entity-cards-repository.js +46 -0
- package/dist/db/entity-values-repository.d.ts +26 -0
- package/dist/db/entity-values-repository.js +57 -0
- package/dist/db/link-repository.d.ts +30 -0
- package/dist/db/link-repository.js +54 -0
- package/dist/db/memory-repository.d.ts +163 -0
- package/dist/db/memory-repository.js +232 -0
- package/dist/db/migrate.d.ts +6 -0
- package/dist/db/migrate.js +36 -0
- package/dist/db/mmr.d.ts +14 -0
- package/dist/db/mmr.js +57 -0
- package/dist/db/passport-feed-repository.d.ts +91 -0
- package/dist/db/passport-feed-repository.js +198 -0
- package/dist/db/pg-episode-store.d.ts +19 -0
- package/dist/db/pg-episode-store.js +17 -0
- package/dist/db/pg-link-store.d.ts +17 -0
- package/dist/db/pg-link-store.js +14 -0
- package/dist/db/pg-memory-store.d.ts +68 -0
- package/dist/db/pg-memory-store.js +53 -0
- package/dist/db/pg-recap-store.d.ts +13 -0
- package/dist/db/pg-recap-store.js +19 -0
- package/dist/db/pg-representation-store.d.ts +17 -0
- package/dist/db/pg-representation-store.js +17 -0
- package/dist/db/pg-search-store.d.ts +29 -0
- package/dist/db/pg-search-store.js +47 -0
- package/dist/db/pool.d.ts +5 -0
- package/dist/db/pool.js +21 -0
- package/dist/db/ppr.d.ts +56 -0
- package/dist/db/ppr.js +178 -0
- package/dist/db/query-helpers.d.ts +44 -0
- package/dist/db/query-helpers.js +60 -0
- package/dist/db/raw-doc-artifact-sync.d.ts +128 -0
- package/dist/db/raw-doc-artifact-sync.js +259 -0
- package/dist/db/raw-document-blob-repository.d.ts +148 -0
- package/dist/db/raw-document-blob-repository.js +300 -0
- package/dist/db/raw-document-repository.d.ts +104 -0
- package/dist/db/raw-document-repository.js +410 -0
- package/dist/db/raw-document-status-repository.d.ts +122 -0
- package/dist/db/raw-document-status-repository.js +183 -0
- package/dist/db/raw-document-types.d.ts +236 -0
- package/dist/db/raw-document-types.js +10 -0
- package/dist/db/raw-storage-reconciliation-repository.d.ts +110 -0
- package/dist/db/raw-storage-reconciliation-repository.js +200 -0
- package/dist/db/reflection-jobs-repository.d.ts +33 -0
- package/dist/db/reflection-jobs-repository.js +48 -0
- package/dist/db/reflections-repository.d.ts +41 -0
- package/dist/db/reflections-repository.js +83 -0
- package/dist/db/repository-claims.d.ts +141 -0
- package/dist/db/repository-claims.js +376 -0
- package/dist/db/repository-deferred-audn.d.ts +33 -0
- package/dist/db/repository-deferred-audn.js +69 -0
- package/dist/db/repository-document-delete.d.ts +53 -0
- package/dist/db/repository-document-delete.js +156 -0
- package/dist/db/repository-entities.d.ts +114 -0
- package/dist/db/repository-entities.js +317 -0
- package/dist/db/repository-entity-attributes.d.ts +41 -0
- package/dist/db/repository-entity-attributes.js +65 -0
- package/dist/db/repository-entity-graph.d.ts +32 -0
- package/dist/db/repository-entity-graph.js +87 -0
- package/dist/db/repository-first-mentions.d.ts +41 -0
- package/dist/db/repository-first-mentions.js +79 -0
- package/dist/db/repository-lessons.d.ts +51 -0
- package/dist/db/repository-lessons.js +90 -0
- package/dist/db/repository-links.d.ts +26 -0
- package/dist/db/repository-links.js +105 -0
- package/dist/db/repository-observation.d.ts +26 -0
- package/dist/db/repository-observation.js +51 -0
- package/dist/db/repository-read.d.ts +56 -0
- package/dist/db/repository-read.js +271 -0
- package/dist/db/repository-recaps.d.ts +59 -0
- package/dist/db/repository-recaps.js +158 -0
- package/dist/db/repository-representations.d.ts +48 -0
- package/dist/db/repository-representations.js +162 -0
- package/dist/db/repository-temporal-state.d.ts +35 -0
- package/dist/db/repository-temporal-state.js +46 -0
- package/dist/db/repository-tll.d.ts +88 -0
- package/dist/db/repository-tll.js +179 -0
- package/dist/db/repository-types.d.ts +313 -0
- package/dist/db/repository-types.js +142 -0
- package/dist/db/repository-user-profiles.d.ts +17 -0
- package/dist/db/repository-user-profiles.js +28 -0
- package/dist/db/repository-vector-search.d.ts +33 -0
- package/dist/db/repository-vector-search.js +373 -0
- package/dist/db/repository-wipe.d.ts +34 -0
- package/dist/db/repository-wipe.js +94 -0
- package/dist/db/repository-write.d.ts +61 -0
- package/dist/db/repository-write.js +279 -0
- package/dist/db/schema.sql +1355 -0
- package/dist/db/storage-artifact-delete-tx.d.ts +56 -0
- package/dist/db/storage-artifact-delete-tx.js +123 -0
- package/dist/db/storage-artifact-providers.d.ts +21 -0
- package/dist/db/storage-artifact-providers.js +21 -0
- package/dist/db/storage-artifact-recovery-repository.d.ts +66 -0
- package/dist/db/storage-artifact-recovery-repository.js +58 -0
- package/dist/db/storage-artifact-repository.d.ts +329 -0
- package/dist/db/storage-artifact-repository.js +497 -0
- package/dist/db/stores.d.ts +220 -0
- package/dist/db/stores.js +12 -0
- package/dist/db/summaries-repository.d.ts +74 -0
- package/dist/db/summaries-repository.js +125 -0
- package/dist/eval/beam-10m-loader.d.ts +98 -0
- package/dist/eval/beam-10m-loader.js +128 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +17 -0
- package/dist/middleware/require-bearer.d.ts +27 -0
- package/dist/middleware/require-bearer.js +60 -0
- package/dist/middleware/validate-response.d.ts +33 -0
- package/dist/middleware/validate-response.js +55 -0
- package/dist/middleware/validate.d.ts +43 -0
- package/dist/middleware/validate.js +85 -0
- package/dist/routes/agents.d.ts +13 -0
- package/dist/routes/agents.js +89 -0
- package/dist/routes/document-response-formatters.d.ts +98 -0
- package/dist/routes/document-response-formatters.js +243 -0
- package/dist/routes/documents.d.ts +74 -0
- package/dist/routes/documents.js +425 -0
- package/dist/routes/memories.d.ts +29 -0
- package/dist/routes/memories.js +725 -0
- package/dist/routes/memory-response-formatters.d.ts +179 -0
- package/dist/routes/memory-response-formatters.js +210 -0
- package/dist/routes/public-raw-storage-metadata.d.ts +54 -0
- package/dist/routes/public-raw-storage-metadata.js +56 -0
- package/dist/routes/reflect.d.ts +14 -0
- package/dist/routes/reflect.js +19 -0
- package/dist/routes/response-schema-map.d.ts +14 -0
- package/dist/routes/response-schema-map.js +69 -0
- package/dist/routes/route-errors.d.ts +12 -0
- package/dist/routes/route-errors.js +30 -0
- package/dist/routes/storage-error-handlers.d.ts +34 -0
- package/dist/routes/storage-error-handlers.js +185 -0
- package/dist/routes/storage-response-formatters.d.ts +44 -0
- package/dist/routes/storage-response-formatters.js +155 -0
- package/dist/routes/storage.d.ts +38 -0
- package/dist/routes/storage.js +369 -0
- package/dist/routes/upstream-provider-errors.d.ts +19 -0
- package/dist/routes/upstream-provider-errors.js +95 -0
- package/dist/schemas/agents.d.ts +79 -0
- package/dist/schemas/agents.js +126 -0
- package/dist/schemas/common.d.ts +110 -0
- package/dist/schemas/common.js +190 -0
- package/dist/schemas/document-list-responses.d.ts +102 -0
- package/dist/schemas/document-list-responses.js +87 -0
- package/dist/schemas/document-list-schemas.d.ts +123 -0
- package/dist/schemas/document-list-schemas.js +174 -0
- package/dist/schemas/document-response-schemas.d.ts +610 -0
- package/dist/schemas/document-response-schemas.js +264 -0
- package/dist/schemas/document-status-envelope.d.ts +48 -0
- package/dist/schemas/document-status-envelope.js +54 -0
- package/dist/schemas/documents.d.ts +292 -0
- package/dist/schemas/documents.js +449 -0
- package/dist/schemas/errors.d.ts +75 -0
- package/dist/schemas/errors.js +105 -0
- package/dist/schemas/memories.d.ts +378 -0
- package/dist/schemas/memories.js +542 -0
- package/dist/schemas/openapi.d.ts +24 -0
- package/dist/schemas/openapi.js +1038 -0
- package/dist/schemas/response-scalars.d.ts +10 -0
- package/dist/schemas/response-scalars.js +10 -0
- package/dist/schemas/responses.d.ts +536 -0
- package/dist/schemas/responses.js +350 -0
- package/dist/schemas/search-response-parts.d.ts +97 -0
- package/dist/schemas/search-response-parts.js +103 -0
- package/dist/schemas/storage-schemas.d.ts +175 -0
- package/dist/schemas/storage-schemas.js +277 -0
- package/dist/schemas/zod-setup.d.ts +15 -0
- package/dist/schemas/zod-setup.js +17 -0
- package/dist/server.d.ts +13 -0
- package/dist/server.js +57 -0
- package/dist/services/abstract-query-policy.d.ts +13 -0
- package/dist/services/abstract-query-policy.js +50 -0
- package/dist/services/affinity-clustering.d.ts +66 -0
- package/dist/services/affinity-clustering.js +125 -0
- package/dist/services/agentic-retrieval.d.ts +38 -0
- package/dist/services/agentic-retrieval.js +126 -0
- package/dist/services/answer-format.d.ts +56 -0
- package/dist/services/answer-format.js +118 -0
- package/dist/services/answer-rescue.d.ts +72 -0
- package/dist/services/answer-rescue.js +177 -0
- package/dist/services/answer-verifier.d.ts +24 -0
- package/dist/services/answer-verifier.js +73 -0
- package/dist/services/api-retry.d.ts +6 -0
- package/dist/services/api-retry.js +41 -0
- package/dist/services/assistant-turn-filter.d.ts +20 -0
- package/dist/services/assistant-turn-filter.js +69 -0
- package/dist/services/atomicmem-uri.d.ts +33 -0
- package/dist/services/atomicmem-uri.js +86 -0
- package/dist/services/audit-events.d.ts +54 -0
- package/dist/services/audit-events.js +56 -0
- package/dist/services/chunked-extraction.d.ts +21 -0
- package/dist/services/chunked-extraction.js +108 -0
- package/dist/services/claim-slotting.d.ts +27 -0
- package/dist/services/claim-slotting.js +38 -0
- package/dist/services/claude-code-llm.d.ts +19 -0
- package/dist/services/claude-code-llm.js +96 -0
- package/dist/services/composite-dedup.d.ts +50 -0
- package/dist/services/composite-dedup.js +153 -0
- package/dist/services/composite-grouping.d.ts +41 -0
- package/dist/services/composite-grouping.js +111 -0
- package/dist/services/composite-staleness.d.ts +20 -0
- package/dist/services/composite-staleness.js +50 -0
- package/dist/services/conciseness-preference.d.ts +14 -0
- package/dist/services/conciseness-preference.js +42 -0
- package/dist/services/conflict-policy.d.ts +20 -0
- package/dist/services/conflict-policy.js +335 -0
- package/dist/services/consensus-extraction.d.ts +39 -0
- package/dist/services/consensus-extraction.js +147 -0
- package/dist/services/consensus-validation.d.ts +52 -0
- package/dist/services/consensus-validation.js +206 -0
- package/dist/services/consolidation-service.d.ts +60 -0
- package/dist/services/consolidation-service.js +171 -0
- package/dist/services/content-detection.d.ts +18 -0
- package/dist/services/content-detection.js +25 -0
- package/dist/services/contradiction-surfacing.d.ts +62 -0
- package/dist/services/contradiction-surfacing.js +111 -0
- package/dist/services/cost-telemetry.d.ts +39 -0
- package/dist/services/cost-telemetry.js +58 -0
- package/dist/services/counter-evidence.d.ts +34 -0
- package/dist/services/counter-evidence.js +92 -0
- package/dist/services/current-state-ranking.d.ts +21 -0
- package/dist/services/current-state-ranking.js +152 -0
- package/dist/services/deferred-audn.d.ts +47 -0
- package/dist/services/deferred-audn.js +162 -0
- package/dist/services/document-chunker.d.ts +50 -0
- package/dist/services/document-chunker.js +153 -0
- package/dist/services/document-failure-markers.d.ts +91 -0
- package/dist/services/document-failure-markers.js +305 -0
- package/dist/services/document-indexer.d.ts +122 -0
- package/dist/services/document-indexer.js +405 -0
- package/dist/services/document-service.d.ts +245 -0
- package/dist/services/document-service.js +325 -0
- package/dist/services/document-upload-artifact-sync.d.ts +80 -0
- package/dist/services/document-upload-artifact-sync.js +162 -0
- package/dist/services/document-upload-beta2-recovery.d.ts +72 -0
- package/dist/services/document-upload-beta2-recovery.js +94 -0
- package/dist/services/document-upload.d.ts +44 -0
- package/dist/services/document-upload.js +353 -0
- package/dist/services/embedding.d.ts +57 -0
- package/dist/services/embedding.js +416 -0
- package/dist/services/entity-attribute-extractor.d.ts +34 -0
- package/dist/services/entity-attribute-extractor.js +117 -0
- package/dist/services/entity-card-synthesis.d.ts +54 -0
- package/dist/services/entity-card-synthesis.js +92 -0
- package/dist/services/entity-dedup.d.ts +9 -0
- package/dist/services/entity-dedup.js +14 -0
- package/dist/services/entity-graph.d.ts +17 -0
- package/dist/services/entity-graph.js +135 -0
- package/dist/services/entropy-gate.d.ts +52 -0
- package/dist/services/entropy-gate.js +56 -0
- package/dist/services/episode-fetcher.d.ts +47 -0
- package/dist/services/episode-fetcher.js +128 -0
- package/dist/services/event-anchor-facts.d.ts +8 -0
- package/dist/services/event-anchor-facts.js +205 -0
- package/dist/services/event-chain-detector.d.ts +52 -0
- package/dist/services/event-chain-detector.js +83 -0
- package/dist/services/extraction-cache.d.ts +9 -0
- package/dist/services/extraction-cache.js +54 -0
- package/dist/services/extraction-enrichment.d.ts +9 -0
- package/dist/services/extraction-enrichment.js +223 -0
- package/dist/services/extraction.d.ts +69 -0
- package/dist/services/extraction.js +596 -0
- package/dist/services/fact-normalization.d.ts +12 -0
- package/dist/services/fact-normalization.js +248 -0
- package/dist/services/filecoin-observability.d.ts +127 -0
- package/dist/services/filecoin-observability.js +200 -0
- package/dist/services/first-mention-service.d.ts +76 -0
- package/dist/services/first-mention-service.js +186 -0
- package/dist/services/hierarchical-retrieval.d.ts +49 -0
- package/dist/services/hierarchical-retrieval.js +50 -0
- package/dist/services/ingest-fact-pipeline.d.ts +32 -0
- package/dist/services/ingest-fact-pipeline.js +212 -0
- package/dist/services/ingest-post-write.d.ts +50 -0
- package/dist/services/ingest-post-write.js +117 -0
- package/dist/services/ingest-trace.d.ts +32 -0
- package/dist/services/ingest-trace.js +60 -0
- package/dist/services/input-sanitizer.d.ts +41 -0
- package/dist/services/input-sanitizer.js +135 -0
- package/dist/services/iterative-retrieval.d.ts +26 -0
- package/dist/services/iterative-retrieval.js +139 -0
- package/dist/services/keyword-expansion.d.ts +10 -0
- package/dist/services/keyword-expansion.js +26 -0
- package/dist/services/lesson-service.d.ts +68 -0
- package/dist/services/lesson-service.js +178 -0
- package/dist/services/literal-extractor.d.ts +16 -0
- package/dist/services/literal-extractor.js +74 -0
- package/dist/services/literal-list-protection.d.ts +17 -0
- package/dist/services/literal-list-protection.js +134 -0
- package/dist/services/literal-query-expansion.d.ts +20 -0
- package/dist/services/literal-query-expansion.js +181 -0
- package/dist/services/llm.d.ts +61 -0
- package/dist/services/llm.js +265 -0
- package/dist/services/memcell-projection.d.ts +17 -0
- package/dist/services/memcell-projection.js +41 -0
- package/dist/services/memory-audn.d.ts +43 -0
- package/dist/services/memory-audn.js +419 -0
- package/dist/services/memory-crud.d.ts +93 -0
- package/dist/services/memory-crud.js +255 -0
- package/dist/services/memory-ingest.d.ts +21 -0
- package/dist/services/memory-ingest.js +249 -0
- package/dist/services/memory-lifecycle.d.ts +75 -0
- package/dist/services/memory-lifecycle.js +108 -0
- package/dist/services/memory-lineage.d.ts +181 -0
- package/dist/services/memory-lineage.js +232 -0
- package/dist/services/memory-network.d.ts +40 -0
- package/dist/services/memory-network.js +75 -0
- package/dist/services/memory-search-types.d.ts +25 -0
- package/dist/services/memory-search-types.js +10 -0
- package/dist/services/memory-search.d.ts +48 -0
- package/dist/services/memory-search.js +505 -0
- package/dist/services/memory-service-types.d.ts +371 -0
- package/dist/services/memory-service-types.js +8 -0
- package/dist/services/memory-service.d.ts +152 -0
- package/dist/services/memory-service.js +225 -0
- package/dist/services/memory-storage.d.ts +33 -0
- package/dist/services/memory-storage.js +328 -0
- package/dist/services/msr-aggregator.d.ts +38 -0
- package/dist/services/msr-aggregator.js +97 -0
- package/dist/services/msr-detector.d.ts +35 -0
- package/dist/services/msr-detector.js +65 -0
- package/dist/services/namespace-retrieval.d.ts +60 -0
- package/dist/services/namespace-retrieval.js +180 -0
- package/dist/services/observation-date-extraction.d.ts +12 -0
- package/dist/services/observation-date-extraction.js +50 -0
- package/dist/services/observation-service.d.ts +27 -0
- package/dist/services/observation-service.js +84 -0
- package/dist/services/packaging-observability.d.ts +29 -0
- package/dist/services/packaging-observability.js +146 -0
- package/dist/services/query-expansion.d.ts +83 -0
- package/dist/services/query-expansion.js +242 -0
- package/dist/services/query-keyword-matches.d.ts +6 -0
- package/dist/services/query-keyword-matches.js +56 -0
- package/dist/services/query-term-visibility.d.ts +28 -0
- package/dist/services/query-term-visibility.js +100 -0
- package/dist/services/quick-extraction.d.ts +25 -0
- package/dist/services/quick-extraction.js +431 -0
- package/dist/services/quoted-entity-extraction.d.ts +10 -0
- package/dist/services/quoted-entity-extraction.js +161 -0
- package/dist/services/raw-storage-reconciler-backoff.d.ts +8 -0
- package/dist/services/raw-storage-reconciler-backoff.js +14 -0
- package/dist/services/raw-storage-reconciler-scheduler.d.ts +29 -0
- package/dist/services/raw-storage-reconciler-scheduler.js +43 -0
- package/dist/services/raw-storage-reconciler.d.ts +71 -0
- package/dist/services/raw-storage-reconciler.js +278 -0
- package/dist/services/recap-builder.d.ts +49 -0
- package/dist/services/recap-builder.js +157 -0
- package/dist/services/reflect-jobs.d.ts +23 -0
- package/dist/services/reflect-jobs.js +36 -0
- package/dist/services/reflect-prompts.d.ts +71 -0
- package/dist/services/reflect-prompts.js +99 -0
- package/dist/services/reflect-retrieval.d.ts +33 -0
- package/dist/services/reflect-retrieval.js +30 -0
- package/dist/services/reflect.d.ts +49 -0
- package/dist/services/reflect.js +84 -0
- package/dist/services/relative-temporal.d.ts +14 -0
- package/dist/services/relative-temporal.js +163 -0
- package/dist/services/relevance-policy.d.ts +37 -0
- package/dist/services/relevance-policy.js +109 -0
- package/dist/services/rerank.d.ts +32 -0
- package/dist/services/rerank.js +118 -0
- package/dist/services/reranker.d.ts +20 -0
- package/dist/services/reranker.js +99 -0
- package/dist/services/retrieval-channel-rules.d.ts +34 -0
- package/dist/services/retrieval-channel-rules.js +41 -0
- package/dist/services/retrieval-config-overlay.d.ts +36 -0
- package/dist/services/retrieval-config-overlay.js +44 -0
- package/dist/services/retrieval-format.d.ts +119 -0
- package/dist/services/retrieval-format.js +559 -0
- package/dist/services/retrieval-policy.d.ts +69 -0
- package/dist/services/retrieval-policy.js +275 -0
- package/dist/services/retrieval-profiles.d.ts +37 -0
- package/dist/services/retrieval-profiles.js +90 -0
- package/dist/services/retrieval-side-effects.d.ts +14 -0
- package/dist/services/retrieval-side-effects.js +26 -0
- package/dist/services/retrieval-trace.d.ts +108 -0
- package/dist/services/retrieval-trace.js +147 -0
- package/dist/services/rrf-fusion.d.ts +18 -0
- package/dist/services/rrf-fusion.js +34 -0
- package/dist/services/search-pipeline.d.ts +71 -0
- package/dist/services/search-pipeline.js +788 -0
- package/dist/services/session-date.d.ts +20 -0
- package/dist/services/session-date.js +61 -0
- package/dist/services/session-packaging.d.ts +53 -0
- package/dist/services/session-packaging.js +182 -0
- package/dist/services/session-summary-generator.d.ts +53 -0
- package/dist/services/session-summary-generator.js +134 -0
- package/dist/services/specialists/cr-specialist.d.ts +52 -0
- package/dist/services/specialists/cr-specialist.js +121 -0
- package/dist/services/specialists/dispatch.d.ts +53 -0
- package/dist/services/specialists/dispatch.js +102 -0
- package/dist/services/specialists/ie-ku-specialist.d.ts +37 -0
- package/dist/services/specialists/ie-ku-specialist.js +63 -0
- package/dist/services/specialists/msr-specialist.d.ts +61 -0
- package/dist/services/specialists/msr-specialist.js +162 -0
- package/dist/services/specialists/tr-specialist.d.ts +37 -0
- package/dist/services/specialists/tr-specialist.js +146 -0
- package/dist/services/storage-key-prefix.d.ts +42 -0
- package/dist/services/storage-key-prefix.js +45 -0
- package/dist/services/storage-put-recovery.d.ts +71 -0
- package/dist/services/storage-put-recovery.js +269 -0
- package/dist/services/storage-service-errors.d.ts +124 -0
- package/dist/services/storage-service-errors.js +189 -0
- package/dist/services/storage-service.d.ts +176 -0
- package/dist/services/storage-service.js +423 -0
- package/dist/services/subject-aware-ranking.d.ts +19 -0
- package/dist/services/subject-aware-ranking.js +161 -0
- package/dist/services/supplemental-extraction.d.ts +7 -0
- package/dist/services/supplemental-extraction.js +116 -0
- package/dist/services/tbc-execution.d.ts +49 -0
- package/dist/services/tbc-execution.js +284 -0
- package/dist/services/temporal-classifier.d.ts +56 -0
- package/dist/services/temporal-classifier.js +94 -0
- package/dist/services/temporal-endpoint-evidence.d.ts +12 -0
- package/dist/services/temporal-endpoint-evidence.js +313 -0
- package/dist/services/temporal-fingerprint.d.ts +6 -0
- package/dist/services/temporal-fingerprint.js +12 -0
- package/dist/services/temporal-format.d.ts +9 -0
- package/dist/services/temporal-format.js +21 -0
- package/dist/services/temporal-intent.d.ts +39 -0
- package/dist/services/temporal-intent.js +78 -0
- package/dist/services/temporal-query-constraints.d.ts +16 -0
- package/dist/services/temporal-query-constraints.js +107 -0
- package/dist/services/temporal-query-expansion.d.ts +14 -0
- package/dist/services/temporal-query-expansion.js +131 -0
- package/dist/services/temporal-rerank.d.ts +22 -0
- package/dist/services/temporal-rerank.js +47 -0
- package/dist/services/temporal-result-protection.d.ts +7 -0
- package/dist/services/temporal-result-protection.js +60 -0
- package/dist/services/temporal-state-write.d.ts +57 -0
- package/dist/services/temporal-state-write.js +45 -0
- package/dist/services/tiered-context.d.ts +87 -0
- package/dist/services/tiered-context.js +214 -0
- package/dist/services/tiered-loading.d.ts +88 -0
- package/dist/services/tiered-loading.js +263 -0
- package/dist/services/timeline-pack.d.ts +36 -0
- package/dist/services/timeline-pack.js +50 -0
- package/dist/services/timing.d.ts +13 -0
- package/dist/services/timing.js +72 -0
- package/dist/services/tll-augmentation.d.ts +20 -0
- package/dist/services/tll-augmentation.js +125 -0
- package/dist/services/tll-retrieval.d.ts +55 -0
- package/dist/services/tll-retrieval.js +101 -0
- package/dist/services/topic-abstraction.d.ts +36 -0
- package/dist/services/topic-abstraction.js +105 -0
- package/dist/services/trust-scoring.d.ts +43 -0
- package/dist/services/trust-scoring.js +89 -0
- package/dist/services/typed-belief-calculus.d.ts +126 -0
- package/dist/services/typed-belief-calculus.js +204 -0
- package/dist/services/upload-config.d.ts +34 -0
- package/dist/services/upload-config.js +23 -0
- package/dist/services/upload-decision.d.ts +65 -0
- package/dist/services/upload-decision.js +98 -0
- package/dist/services/upload-helpers.d.ts +107 -0
- package/dist/services/upload-helpers.js +148 -0
- package/dist/services/user-profile-builder.d.ts +22 -0
- package/dist/services/user-profile-builder.js +109 -0
- package/dist/services/voyage-embedding.d.ts +22 -0
- package/dist/services/voyage-embedding.js +77 -0
- package/dist/services/write-security.d.ts +31 -0
- package/dist/services/write-security.js +64 -0
- package/dist/storage/artifact-public-redaction.d.ts +34 -0
- package/dist/storage/artifact-public-redaction.js +83 -0
- package/dist/storage/cleanup.d.ts +103 -0
- package/dist/storage/cleanup.js +138 -0
- package/dist/storage/codec-factory.d.ts +17 -0
- package/dist/storage/codec-factory.js +33 -0
- package/dist/storage/codecs/aes-gcm-codec.d.ts +44 -0
- package/dist/storage/codecs/aes-gcm-codec.js +108 -0
- package/dist/storage/codecs/noop-codec.d.ts +16 -0
- package/dist/storage/codecs/noop-codec.js +23 -0
- package/dist/storage/factory.d.ts +44 -0
- package/dist/storage/factory.js +99 -0
- package/dist/storage/filecoin-cid-validation.d.ts +82 -0
- package/dist/storage/filecoin-cid-validation.js +122 -0
- package/dist/storage/filecoin-public-metadata.d.ts +73 -0
- package/dist/storage/filecoin-public-metadata.js +110 -0
- package/dist/storage/local-fs-store.d.ts +39 -0
- package/dist/storage/local-fs-store.js +145 -0
- package/dist/storage/pointer-uri-allowlist.d.ts +38 -0
- package/dist/storage/pointer-uri-allowlist.js +70 -0
- package/dist/storage/provider-metadata-projection.d.ts +27 -0
- package/dist/storage/provider-metadata-projection.js +68 -0
- package/dist/storage/providers/filecoin/backend.d.ts +42 -0
- package/dist/storage/providers/filecoin/backend.js +250 -0
- package/dist/storage/providers/filecoin/config.d.ts +70 -0
- package/dist/storage/providers/filecoin/config.js +275 -0
- package/dist/storage/providers/filecoin/errors.d.ts +45 -0
- package/dist/storage/providers/filecoin/errors.js +56 -0
- package/dist/storage/providers/filecoin/filecoin-pin-car.d.ts +78 -0
- package/dist/storage/providers/filecoin/filecoin-pin-car.js +155 -0
- package/dist/storage/providers/filecoin/filecoin-pin-client.d.ts +92 -0
- package/dist/storage/providers/filecoin/filecoin-pin-client.js +199 -0
- package/dist/storage/providers/filecoin/filecoin-pin-mapping.d.ts +58 -0
- package/dist/storage/providers/filecoin/filecoin-pin-mapping.js +103 -0
- package/dist/storage/providers/filecoin/filecoin-pin-timeout.d.ts +30 -0
- package/dist/storage/providers/filecoin/filecoin-pin-timeout.js +53 -0
- package/dist/storage/providers/filecoin/filecoin-pin-vendor.d.ts +111 -0
- package/dist/storage/providers/filecoin/filecoin-pin-vendor.js +87 -0
- package/dist/storage/providers/filecoin/hints.d.ts +71 -0
- package/dist/storage/providers/filecoin/hints.js +123 -0
- package/dist/storage/providers/filecoin/index.d.ts +51 -0
- package/dist/storage/providers/filecoin/index.js +103 -0
- package/dist/storage/providers/filecoin/ipfs-cid.d.ts +50 -0
- package/dist/storage/providers/filecoin/ipfs-cid.js +64 -0
- package/dist/storage/providers/filecoin/metadata.d.ts +72 -0
- package/dist/storage/providers/filecoin/metadata.js +137 -0
- package/dist/storage/providers/filecoin/piece-cid.d.ts +48 -0
- package/dist/storage/providers/filecoin/piece-cid.js +57 -0
- package/dist/storage/providers/filecoin/provider-client.d.ts +234 -0
- package/dist/storage/providers/filecoin/provider-client.js +27 -0
- package/dist/storage/providers/filecoin/readiness.d.ts +62 -0
- package/dist/storage/providers/filecoin/readiness.js +85 -0
- package/dist/storage/providers/filecoin/retriever.d.ts +82 -0
- package/dist/storage/providers/filecoin/retriever.js +63 -0
- package/dist/storage/providers/filecoin/skeleton-client.d.ts +36 -0
- package/dist/storage/providers/filecoin/skeleton-client.js +55 -0
- package/dist/storage/providers/filecoin/synapse-client.d.ts +169 -0
- package/dist/storage/providers/filecoin/synapse-client.js +343 -0
- package/dist/storage/providers/filecoin/synapse-construction.d.ts +26 -0
- package/dist/storage/providers/filecoin/synapse-construction.js +47 -0
- package/dist/storage/providers/filecoin/synapse-error-mapping.d.ts +23 -0
- package/dist/storage/providers/filecoin/synapse-error-mapping.js +49 -0
- package/dist/storage/providers/filecoin/synapse-readiness.d.ts +37 -0
- package/dist/storage/providers/filecoin/synapse-readiness.js +231 -0
- package/dist/storage/providers/filecoin/uri.d.ts +49 -0
- package/dist/storage/providers/filecoin/uri.js +84 -0
- package/dist/storage/providers/filecoin/verified-fetch-lifecycle.d.ts +77 -0
- package/dist/storage/providers/filecoin/verified-fetch-lifecycle.js +196 -0
- package/dist/storage/providers/filecoin/verified-fetch-retriever.d.ts +54 -0
- package/dist/storage/providers/filecoin/verified-fetch-retriever.js +81 -0
- package/dist/storage/providers/filecoin/verified-fetch-vendor.d.ts +71 -0
- package/dist/storage/providers/filecoin/verified-fetch-vendor.js +94 -0
- package/dist/storage/raw-content-codec.d.ts +89 -0
- package/dist/storage/raw-content-codec.js +47 -0
- package/dist/storage/raw-content-store-backend-adapter.d.ts +28 -0
- package/dist/storage/raw-content-store-backend-adapter.js +67 -0
- package/dist/storage/raw-content-store.d.ts +228 -0
- package/dist/storage/raw-content-store.js +27 -0
- package/dist/storage/s3-store.d.ts +42 -0
- package/dist/storage/s3-store.js +181 -0
- package/dist/storage/storage-backend-registry.d.ts +58 -0
- package/dist/storage/storage-backend-registry.js +56 -0
- package/dist/storage/storage-backend.d.ts +82 -0
- package/dist/storage/storage-backend.js +14 -0
- package/dist/storage/storage-capabilities.d.ts +56 -0
- package/dist/storage/storage-capabilities.js +170 -0
- package/dist/storage/store-registry.d.ts +67 -0
- package/dist/storage/store-registry.js +77 -0
- package/dist/vector-math.d.ts +15 -0
- package/dist/vector-math.js +31 -0
- package/dist/xml-escape.d.ts +5 -0
- package/dist/xml-escape.js +7 -0
- package/openapi.json +15395 -0
- package/openapi.yaml +10794 -0
- package/package.json +119 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Memory lifecycle management: decay cycle and memory count cap.
|
|
3
|
+
*
|
|
4
|
+
* Decay cycle: Computes a retention score for each memory using the same
|
|
5
|
+
* three-signal formula as retrieval scoring (similarity excluded since there's
|
|
6
|
+
* no query). Memories below the retention threshold are archived (soft-deleted).
|
|
7
|
+
* This implements the Ebbinghaus forgetting curve for long-term store health.
|
|
8
|
+
*
|
|
9
|
+
* Memory count cap: Checks whether a user's active memory count exceeds
|
|
10
|
+
* a configured limit and returns a recommendation for whether consolidation
|
|
11
|
+
* or decay should run.
|
|
12
|
+
*
|
|
13
|
+
* Both features are pure functions over memory data + config — they compute
|
|
14
|
+
* what should happen but let the caller decide when to act.
|
|
15
|
+
*/
|
|
16
|
+
/** 30-day time constant in milliseconds, matching the SQL decay formula. */
|
|
17
|
+
const DECAY_TAU_MS = 2_592_000_000;
|
|
18
|
+
export const DEFAULT_DECAY_CONFIG = {
|
|
19
|
+
retentionThreshold: 0.2,
|
|
20
|
+
importanceWeight: 0.4,
|
|
21
|
+
recencyWeight: 0.4,
|
|
22
|
+
accessWeight: 0.2,
|
|
23
|
+
minAgeMs: 7 * 24 * 60 * 60 * 1000, // 7 days
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Compute the retention score for a single memory.
|
|
27
|
+
*
|
|
28
|
+
* Formula: importanceWeight * importance + recencyWeight * recency + accessWeight * accessFreq
|
|
29
|
+
* Where recency = exp(-timeSinceAccess / TAU) and accessFreq = min(1, accessCount / 10).
|
|
30
|
+
*/
|
|
31
|
+
export function computeRetentionScore(memory, referenceTime, decayConfig) {
|
|
32
|
+
const elapsedMs = referenceTime.getTime() - memory.last_accessed_at.getTime();
|
|
33
|
+
const recency = Math.exp(-elapsedMs / DECAY_TAU_MS);
|
|
34
|
+
const accessFreq = Math.min(1.0, memory.access_count / 10);
|
|
35
|
+
const rawScore = (decayConfig.importanceWeight * memory.importance)
|
|
36
|
+
+ (decayConfig.recencyWeight * recency)
|
|
37
|
+
+ (decayConfig.accessWeight * accessFreq);
|
|
38
|
+
return rawScore * (memory.trust_score ?? 1.0);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Evaluate a batch of memories and identify those below the retention threshold.
|
|
42
|
+
* Does not modify any data — returns candidates for the caller to archive.
|
|
43
|
+
*/
|
|
44
|
+
export function evaluateDecayCandidates(memories, referenceTime, decayConfig = DEFAULT_DECAY_CONFIG) {
|
|
45
|
+
const eligible = memories.filter((m) => {
|
|
46
|
+
const ageMs = referenceTime.getTime() - m.created_at.getTime();
|
|
47
|
+
return ageMs >= decayConfig.minAgeMs;
|
|
48
|
+
});
|
|
49
|
+
const scored = eligible.map((m) => {
|
|
50
|
+
const retentionScore = computeRetentionScore(m, referenceTime, decayConfig);
|
|
51
|
+
const elapsedMs = referenceTime.getTime() - m.last_accessed_at.getTime();
|
|
52
|
+
return {
|
|
53
|
+
id: m.id,
|
|
54
|
+
content: m.content,
|
|
55
|
+
retentionScore,
|
|
56
|
+
importance: m.importance,
|
|
57
|
+
daysSinceAccess: elapsedMs / (24 * 60 * 60 * 1000),
|
|
58
|
+
accessCount: m.access_count,
|
|
59
|
+
};
|
|
60
|
+
});
|
|
61
|
+
const candidates = scored
|
|
62
|
+
.filter((s) => s.retentionScore < decayConfig.retentionThreshold)
|
|
63
|
+
.sort((a, b) => a.retentionScore - b.retentionScore);
|
|
64
|
+
const totalScore = scored.reduce((sum, s) => sum + s.retentionScore, 0);
|
|
65
|
+
const avgRetentionScore = scored.length > 0 ? totalScore / scored.length : 0;
|
|
66
|
+
return {
|
|
67
|
+
memoriesEvaluated: eligible.length,
|
|
68
|
+
candidatesForArchival: candidates,
|
|
69
|
+
retentionThreshold: decayConfig.retentionThreshold,
|
|
70
|
+
avgRetentionScore,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
const DEFAULT_CAP_CONFIG = {
|
|
74
|
+
maxMemories: 5000,
|
|
75
|
+
warnRatio: 0.8,
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Check whether a user's memory count is within the configured cap.
|
|
79
|
+
* Returns a status and recommendation for what lifecycle action to take.
|
|
80
|
+
*/
|
|
81
|
+
export function checkMemoryCap(activeMemories, capConfig = DEFAULT_CAP_CONFIG) {
|
|
82
|
+
const usageRatio = activeMemories / capConfig.maxMemories;
|
|
83
|
+
const status = resolveCapStatus(usageRatio, capConfig.warnRatio);
|
|
84
|
+
const recommendation = resolveRecommendation(status, usageRatio);
|
|
85
|
+
return {
|
|
86
|
+
activeMemories,
|
|
87
|
+
maxMemories: capConfig.maxMemories,
|
|
88
|
+
status,
|
|
89
|
+
usageRatio,
|
|
90
|
+
recommendation,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
function resolveCapStatus(usageRatio, warnRatio) {
|
|
94
|
+
if (usageRatio >= 1.0)
|
|
95
|
+
return 'exceeded';
|
|
96
|
+
if (usageRatio >= warnRatio)
|
|
97
|
+
return 'warn';
|
|
98
|
+
return 'ok';
|
|
99
|
+
}
|
|
100
|
+
function resolveRecommendation(status, usageRatio) {
|
|
101
|
+
if (status === 'ok')
|
|
102
|
+
return 'none';
|
|
103
|
+
if (status === 'warn')
|
|
104
|
+
return 'consolidate';
|
|
105
|
+
if (usageRatio >= 1.2)
|
|
106
|
+
return 'consolidate-and-decay';
|
|
107
|
+
return 'decay';
|
|
108
|
+
}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal claim-lineage emission seam for the existing lineage-producing write
|
|
3
|
+
* paths only.
|
|
4
|
+
*
|
|
5
|
+
* This module centralizes the current claim/version/evidence/canonical-object
|
|
6
|
+
* write sequences without changing their semantics. It deliberately models the
|
|
7
|
+
* current consolidation anomaly as its own variant: consolidation creates a
|
|
8
|
+
* claim/version pair but does not emit a mutation canonical memory object.
|
|
9
|
+
*
|
|
10
|
+
* Out of scope:
|
|
11
|
+
* - schema changes
|
|
12
|
+
* - new mutation types
|
|
13
|
+
* - workspace/scope behavior changes
|
|
14
|
+
* - routing lineage-bypassing paths through claim versions
|
|
15
|
+
*/
|
|
16
|
+
import type { ClaimSlotInput } from '../db/claim-repository.js';
|
|
17
|
+
import type { IngestRuntimeConfig } from './memory-service-types.js';
|
|
18
|
+
import type { ClaimTarget, FactInput } from './memory-service-types.js';
|
|
19
|
+
type MutationType = 'add' | 'update' | 'supersede' | 'delete';
|
|
20
|
+
type MutationProvenanceType = MutationType | 'clarify';
|
|
21
|
+
type MutationCanonicalObjectRepo = {
|
|
22
|
+
storeCanonicalMemoryObject(input: {
|
|
23
|
+
userId: string;
|
|
24
|
+
objectFamily: 'ingested_fact';
|
|
25
|
+
canonicalPayload: ReturnType<typeof buildCanonicalPayload>;
|
|
26
|
+
provenance: {
|
|
27
|
+
episodeId: string;
|
|
28
|
+
sourceSite: string;
|
|
29
|
+
sourceUrl: string;
|
|
30
|
+
};
|
|
31
|
+
observedAt: Date | undefined;
|
|
32
|
+
lineage: {
|
|
33
|
+
mutationType: MutationType;
|
|
34
|
+
previousObjectId: string | null;
|
|
35
|
+
claimId?: string;
|
|
36
|
+
claimVersionId?: string;
|
|
37
|
+
previousVersionId?: string;
|
|
38
|
+
mutationReason?: string;
|
|
39
|
+
contradictionConfidence?: number | null;
|
|
40
|
+
actorModel?: string | null;
|
|
41
|
+
};
|
|
42
|
+
}): Promise<string>;
|
|
43
|
+
};
|
|
44
|
+
type LineageClaimsPort = {
|
|
45
|
+
createClaim(userId: string, claimType: string, validAt?: Date, claimSlot?: ClaimSlotInput | null): Promise<string>;
|
|
46
|
+
createClaimVersion(input: {
|
|
47
|
+
claimId: string;
|
|
48
|
+
userId: string;
|
|
49
|
+
memoryId?: string;
|
|
50
|
+
content: string;
|
|
51
|
+
embedding: number[];
|
|
52
|
+
importance: number;
|
|
53
|
+
sourceSite: string;
|
|
54
|
+
sourceUrl?: string;
|
|
55
|
+
episodeId?: string;
|
|
56
|
+
validFrom?: Date;
|
|
57
|
+
provenance?: {
|
|
58
|
+
mutationType?: MutationProvenanceType;
|
|
59
|
+
mutationReason?: string;
|
|
60
|
+
previousVersionId?: string;
|
|
61
|
+
actorModel?: string;
|
|
62
|
+
contradictionConfidence?: number;
|
|
63
|
+
};
|
|
64
|
+
}): Promise<string>;
|
|
65
|
+
setClaimCurrentVersion(claimId: string, versionId: string | null, status?: string, validAt?: Date): Promise<void>;
|
|
66
|
+
addEvidence(input: {
|
|
67
|
+
claimVersionId: string;
|
|
68
|
+
episodeId?: string;
|
|
69
|
+
memoryId?: string;
|
|
70
|
+
quoteText?: string;
|
|
71
|
+
speaker?: string;
|
|
72
|
+
}): Promise<void>;
|
|
73
|
+
createUpdateVersion(input: {
|
|
74
|
+
oldVersionId: string;
|
|
75
|
+
claimId: string;
|
|
76
|
+
userId: string;
|
|
77
|
+
memoryId: string;
|
|
78
|
+
content: string;
|
|
79
|
+
embedding: number[];
|
|
80
|
+
importance: number;
|
|
81
|
+
sourceSite: string;
|
|
82
|
+
sourceUrl?: string;
|
|
83
|
+
episodeId?: string;
|
|
84
|
+
validFrom?: Date;
|
|
85
|
+
mutationReason?: string;
|
|
86
|
+
actorModel?: string;
|
|
87
|
+
}): Promise<string>;
|
|
88
|
+
supersedeClaimVersion(userId: string, versionId: string, supersededByVersionId: string | null, validTo?: Date): Promise<void>;
|
|
89
|
+
invalidateClaim(userId: string, claimId: string, invalidAt?: Date, invalidatedByVersionId?: string | null, status?: string): Promise<void>;
|
|
90
|
+
};
|
|
91
|
+
type LineageDeps = {
|
|
92
|
+
claims: LineageClaimsPort;
|
|
93
|
+
repo?: MutationCanonicalObjectRepo;
|
|
94
|
+
config: Pick<IngestRuntimeConfig, 'llmModel'>;
|
|
95
|
+
};
|
|
96
|
+
type BackfillMemory = {
|
|
97
|
+
id: string;
|
|
98
|
+
content: string;
|
|
99
|
+
embedding: number[];
|
|
100
|
+
importance: number;
|
|
101
|
+
sourceSite: string;
|
|
102
|
+
sourceUrl: string;
|
|
103
|
+
episodeId?: string;
|
|
104
|
+
createdAt: Date;
|
|
105
|
+
memoryType: string;
|
|
106
|
+
cmoId: string | null;
|
|
107
|
+
};
|
|
108
|
+
type LineageEvent = {
|
|
109
|
+
kind: 'canonical-add';
|
|
110
|
+
userId: string;
|
|
111
|
+
fact: FactInput;
|
|
112
|
+
embedding: number[];
|
|
113
|
+
sourceSite: string;
|
|
114
|
+
sourceUrl: string;
|
|
115
|
+
episodeId: string;
|
|
116
|
+
logicalTimestamp: Date | undefined;
|
|
117
|
+
claimSlot: ClaimSlotInput | null;
|
|
118
|
+
createProjection: (cmoId: string) => Promise<string | null>;
|
|
119
|
+
} | {
|
|
120
|
+
kind: 'claim-backfill';
|
|
121
|
+
userId: string;
|
|
122
|
+
memory: BackfillMemory;
|
|
123
|
+
} | {
|
|
124
|
+
kind: 'consolidation-add';
|
|
125
|
+
userId: string;
|
|
126
|
+
memoryId: string;
|
|
127
|
+
content: string;
|
|
128
|
+
embedding: number[];
|
|
129
|
+
importance: number;
|
|
130
|
+
sourceSite: string;
|
|
131
|
+
mutationReason: string;
|
|
132
|
+
} | {
|
|
133
|
+
kind: 'canonical-update';
|
|
134
|
+
userId: string;
|
|
135
|
+
fact: FactInput;
|
|
136
|
+
updatedContent: string;
|
|
137
|
+
updatedEmbedding: number[];
|
|
138
|
+
sourceSite: string;
|
|
139
|
+
sourceUrl: string;
|
|
140
|
+
episodeId: string;
|
|
141
|
+
logicalTimestamp: Date | undefined;
|
|
142
|
+
target: ClaimTarget;
|
|
143
|
+
contradictionConfidence?: number | null;
|
|
144
|
+
} | {
|
|
145
|
+
kind: 'canonical-supersede';
|
|
146
|
+
userId: string;
|
|
147
|
+
fact: FactInput;
|
|
148
|
+
embedding: number[];
|
|
149
|
+
sourceSite: string;
|
|
150
|
+
sourceUrl: string;
|
|
151
|
+
episodeId: string;
|
|
152
|
+
logicalTimestamp: Date | undefined;
|
|
153
|
+
target: ClaimTarget;
|
|
154
|
+
newMemoryId: string;
|
|
155
|
+
contradictionConfidence?: number | null;
|
|
156
|
+
} | {
|
|
157
|
+
kind: 'canonical-delete';
|
|
158
|
+
userId: string;
|
|
159
|
+
fact: FactInput;
|
|
160
|
+
sourceSite: string;
|
|
161
|
+
sourceUrl: string;
|
|
162
|
+
episodeId: string;
|
|
163
|
+
logicalTimestamp: Date | undefined;
|
|
164
|
+
target: ClaimTarget;
|
|
165
|
+
targetEmbedding: number[];
|
|
166
|
+
contradictionConfidence?: number | null;
|
|
167
|
+
};
|
|
168
|
+
export type LineageEmission = {
|
|
169
|
+
claimId: string;
|
|
170
|
+
versionId: string;
|
|
171
|
+
memoryId: string | null;
|
|
172
|
+
cmoId: string | null;
|
|
173
|
+
};
|
|
174
|
+
export declare function emitLineageEvent(deps: LineageDeps, event: LineageEvent): Promise<LineageEmission | null>;
|
|
175
|
+
declare function buildCanonicalPayload(fact: FactInput): {
|
|
176
|
+
factText: string;
|
|
177
|
+
factType: "preference" | "project" | "knowledge" | "person" | "plan";
|
|
178
|
+
headline: string;
|
|
179
|
+
keywords: string[];
|
|
180
|
+
};
|
|
181
|
+
export {};
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal claim-lineage emission seam for the existing lineage-producing write
|
|
3
|
+
* paths only.
|
|
4
|
+
*
|
|
5
|
+
* This module centralizes the current claim/version/evidence/canonical-object
|
|
6
|
+
* write sequences without changing their semantics. It deliberately models the
|
|
7
|
+
* current consolidation anomaly as its own variant: consolidation creates a
|
|
8
|
+
* claim/version pair but does not emit a mutation canonical memory object.
|
|
9
|
+
*
|
|
10
|
+
* Out of scope:
|
|
11
|
+
* - schema changes
|
|
12
|
+
* - new mutation types
|
|
13
|
+
* - workspace/scope behavior changes
|
|
14
|
+
* - routing lineage-bypassing paths through claim versions
|
|
15
|
+
*/
|
|
16
|
+
export async function emitLineageEvent(deps, event) {
|
|
17
|
+
switch (event.kind) {
|
|
18
|
+
case 'canonical-add':
|
|
19
|
+
return emitCanonicalAdd(deps, event);
|
|
20
|
+
case 'claim-backfill':
|
|
21
|
+
return emitBackfill(deps, event);
|
|
22
|
+
case 'consolidation-add':
|
|
23
|
+
return emitConsolidationAdd(deps, event);
|
|
24
|
+
case 'canonical-update':
|
|
25
|
+
return emitCanonicalUpdate(deps, event);
|
|
26
|
+
case 'canonical-supersede':
|
|
27
|
+
return emitCanonicalSupersede(deps, event);
|
|
28
|
+
case 'canonical-delete':
|
|
29
|
+
return emitCanonicalDelete(deps, event);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function buildCanonicalPayload(fact) {
|
|
33
|
+
return {
|
|
34
|
+
factText: fact.fact,
|
|
35
|
+
factType: fact.type,
|
|
36
|
+
headline: fact.headline,
|
|
37
|
+
keywords: fact.keywords,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
async function emitCanonicalAdd(deps, event) {
|
|
41
|
+
const cmoId = await requireRepo(deps).storeCanonicalMemoryObject({
|
|
42
|
+
userId: event.userId,
|
|
43
|
+
objectFamily: 'ingested_fact',
|
|
44
|
+
canonicalPayload: buildCanonicalPayload(event.fact),
|
|
45
|
+
provenance: { episodeId: event.episodeId, sourceSite: event.sourceSite, sourceUrl: event.sourceUrl },
|
|
46
|
+
observedAt: event.logicalTimestamp,
|
|
47
|
+
lineage: { mutationType: 'add', previousObjectId: null },
|
|
48
|
+
});
|
|
49
|
+
const memoryId = await event.createProjection(cmoId);
|
|
50
|
+
if (!memoryId)
|
|
51
|
+
return null;
|
|
52
|
+
const claimId = await deps.claims.createClaim(event.userId, event.fact.type, event.logicalTimestamp, event.claimSlot);
|
|
53
|
+
const versionId = await deps.claims.createClaimVersion({
|
|
54
|
+
claimId,
|
|
55
|
+
userId: event.userId,
|
|
56
|
+
memoryId,
|
|
57
|
+
content: event.fact.fact,
|
|
58
|
+
embedding: event.embedding,
|
|
59
|
+
importance: event.fact.importance,
|
|
60
|
+
sourceSite: event.sourceSite,
|
|
61
|
+
sourceUrl: event.sourceUrl,
|
|
62
|
+
episodeId: event.episodeId,
|
|
63
|
+
validFrom: event.logicalTimestamp,
|
|
64
|
+
provenance: { mutationType: 'add', actorModel: lineageActorModel(deps) },
|
|
65
|
+
});
|
|
66
|
+
await deps.claims.setClaimCurrentVersion(claimId, versionId, 'active', event.logicalTimestamp);
|
|
67
|
+
await deps.claims.addEvidence({ claimVersionId: versionId, episodeId: event.episodeId, memoryId, quoteText: event.fact.fact });
|
|
68
|
+
return { claimId, versionId, memoryId, cmoId };
|
|
69
|
+
}
|
|
70
|
+
async function emitBackfill(deps, event) {
|
|
71
|
+
const claimId = await deps.claims.createClaim(event.userId, event.memory.memoryType, event.memory.createdAt);
|
|
72
|
+
const versionId = await deps.claims.createClaimVersion({
|
|
73
|
+
claimId,
|
|
74
|
+
userId: event.userId,
|
|
75
|
+
memoryId: event.memory.id,
|
|
76
|
+
content: event.memory.content,
|
|
77
|
+
embedding: event.memory.embedding,
|
|
78
|
+
importance: event.memory.importance,
|
|
79
|
+
sourceSite: event.memory.sourceSite,
|
|
80
|
+
sourceUrl: event.memory.sourceUrl,
|
|
81
|
+
episodeId: event.memory.episodeId,
|
|
82
|
+
validFrom: event.memory.createdAt,
|
|
83
|
+
});
|
|
84
|
+
await deps.claims.setClaimCurrentVersion(claimId, versionId, 'active', event.memory.createdAt);
|
|
85
|
+
await deps.claims.addEvidence({
|
|
86
|
+
claimVersionId: versionId,
|
|
87
|
+
episodeId: event.memory.episodeId,
|
|
88
|
+
memoryId: event.memory.id,
|
|
89
|
+
quoteText: event.memory.content,
|
|
90
|
+
});
|
|
91
|
+
return { claimId, versionId, memoryId: event.memory.id, cmoId: event.memory.cmoId };
|
|
92
|
+
}
|
|
93
|
+
async function emitConsolidationAdd(deps, event) {
|
|
94
|
+
const claimId = await deps.claims.createClaim(event.userId, 'consolidated');
|
|
95
|
+
const versionId = await deps.claims.createClaimVersion({
|
|
96
|
+
claimId,
|
|
97
|
+
userId: event.userId,
|
|
98
|
+
memoryId: event.memoryId,
|
|
99
|
+
content: event.content,
|
|
100
|
+
embedding: event.embedding,
|
|
101
|
+
importance: event.importance,
|
|
102
|
+
sourceSite: event.sourceSite,
|
|
103
|
+
provenance: {
|
|
104
|
+
mutationType: 'add',
|
|
105
|
+
mutationReason: event.mutationReason,
|
|
106
|
+
actorModel: lineageActorModel(deps),
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
await deps.claims.setClaimCurrentVersion(claimId, versionId);
|
|
110
|
+
return { claimId, versionId, memoryId: event.memoryId, cmoId: null };
|
|
111
|
+
}
|
|
112
|
+
async function emitCanonicalUpdate(deps, event) {
|
|
113
|
+
const mutationReason = `Updated from: "${event.fact.fact.slice(0, 100)}"`;
|
|
114
|
+
const versionId = await deps.claims.createUpdateVersion({
|
|
115
|
+
oldVersionId: event.target.versionId,
|
|
116
|
+
claimId: event.target.claimId,
|
|
117
|
+
userId: event.userId,
|
|
118
|
+
memoryId: event.target.memoryId,
|
|
119
|
+
content: event.updatedContent,
|
|
120
|
+
embedding: event.updatedEmbedding,
|
|
121
|
+
importance: event.fact.importance,
|
|
122
|
+
sourceSite: event.sourceSite,
|
|
123
|
+
sourceUrl: event.sourceUrl,
|
|
124
|
+
episodeId: event.episodeId,
|
|
125
|
+
validFrom: event.logicalTimestamp,
|
|
126
|
+
mutationReason,
|
|
127
|
+
actorModel: lineageActorModel(deps),
|
|
128
|
+
});
|
|
129
|
+
await deps.claims.addEvidence({
|
|
130
|
+
claimVersionId: versionId,
|
|
131
|
+
episodeId: event.episodeId,
|
|
132
|
+
memoryId: event.target.memoryId,
|
|
133
|
+
quoteText: event.fact.fact,
|
|
134
|
+
});
|
|
135
|
+
const cmoId = await createMutationCanonicalObject(deps, event, versionId, mutationReason, {
|
|
136
|
+
...event.fact,
|
|
137
|
+
fact: event.updatedContent,
|
|
138
|
+
});
|
|
139
|
+
return { claimId: event.target.claimId, versionId, memoryId: event.target.memoryId, cmoId };
|
|
140
|
+
}
|
|
141
|
+
async function emitCanonicalSupersede(deps, event) {
|
|
142
|
+
const mutationReason = `Superseded memory "${event.target.memoryId}" with new fact`;
|
|
143
|
+
const versionId = await deps.claims.createClaimVersion({
|
|
144
|
+
claimId: event.target.claimId,
|
|
145
|
+
userId: event.userId,
|
|
146
|
+
memoryId: event.newMemoryId,
|
|
147
|
+
content: event.fact.fact,
|
|
148
|
+
embedding: event.embedding,
|
|
149
|
+
importance: event.fact.importance,
|
|
150
|
+
sourceSite: event.sourceSite,
|
|
151
|
+
sourceUrl: event.sourceUrl,
|
|
152
|
+
episodeId: event.episodeId,
|
|
153
|
+
validFrom: event.logicalTimestamp,
|
|
154
|
+
provenance: {
|
|
155
|
+
mutationType: 'supersede',
|
|
156
|
+
mutationReason,
|
|
157
|
+
previousVersionId: event.target.versionId,
|
|
158
|
+
actorModel: lineageActorModel(deps),
|
|
159
|
+
contradictionConfidence: event.contradictionConfidence ?? undefined,
|
|
160
|
+
},
|
|
161
|
+
});
|
|
162
|
+
await deps.claims.supersedeClaimVersion(event.userId, event.target.versionId, versionId, event.logicalTimestamp ?? new Date());
|
|
163
|
+
await deps.claims.setClaimCurrentVersion(event.target.claimId, versionId, 'active', event.logicalTimestamp);
|
|
164
|
+
await deps.claims.addEvidence({
|
|
165
|
+
claimVersionId: versionId,
|
|
166
|
+
episodeId: event.episodeId,
|
|
167
|
+
memoryId: event.newMemoryId,
|
|
168
|
+
quoteText: event.fact.fact,
|
|
169
|
+
});
|
|
170
|
+
const cmoId = await createMutationCanonicalObject(deps, event, versionId, mutationReason, event.fact);
|
|
171
|
+
return { claimId: event.target.claimId, versionId, memoryId: event.newMemoryId, cmoId };
|
|
172
|
+
}
|
|
173
|
+
async function emitCanonicalDelete(deps, event) {
|
|
174
|
+
const mutationReason = `Deleted memory "${event.target.memoryId}" — fact: "${event.fact.fact.slice(0, 100)}"`;
|
|
175
|
+
const versionId = await deps.claims.createClaimVersion({
|
|
176
|
+
claimId: event.target.claimId,
|
|
177
|
+
userId: event.userId,
|
|
178
|
+
content: `[DELETED] ${event.fact.fact}`,
|
|
179
|
+
embedding: event.targetEmbedding,
|
|
180
|
+
importance: 0,
|
|
181
|
+
sourceSite: '',
|
|
182
|
+
sourceUrl: '',
|
|
183
|
+
episodeId: event.episodeId,
|
|
184
|
+
validFrom: event.logicalTimestamp,
|
|
185
|
+
provenance: {
|
|
186
|
+
mutationType: 'delete',
|
|
187
|
+
mutationReason,
|
|
188
|
+
previousVersionId: event.target.versionId,
|
|
189
|
+
actorModel: lineageActorModel(deps),
|
|
190
|
+
contradictionConfidence: event.contradictionConfidence ?? undefined,
|
|
191
|
+
},
|
|
192
|
+
});
|
|
193
|
+
await deps.claims.supersedeClaimVersion(event.userId, event.target.versionId, versionId, event.logicalTimestamp ?? new Date());
|
|
194
|
+
await deps.claims.invalidateClaim(event.userId, event.target.claimId, event.logicalTimestamp ?? new Date(), versionId);
|
|
195
|
+
const cmoId = await createMutationCanonicalObject(deps, event, versionId, mutationReason, event.fact);
|
|
196
|
+
return { claimId: event.target.claimId, versionId, memoryId: null, cmoId };
|
|
197
|
+
}
|
|
198
|
+
async function createMutationCanonicalObject(deps, event, claimVersionId, mutationReason, fact) {
|
|
199
|
+
return requireRepo(deps).storeCanonicalMemoryObject({
|
|
200
|
+
userId: event.userId,
|
|
201
|
+
objectFamily: 'ingested_fact',
|
|
202
|
+
canonicalPayload: buildCanonicalPayload(fact),
|
|
203
|
+
provenance: { episodeId: event.episodeId, sourceSite: event.sourceSite, sourceUrl: event.sourceUrl },
|
|
204
|
+
observedAt: event.logicalTimestamp,
|
|
205
|
+
lineage: {
|
|
206
|
+
mutationType: mutationTypeFor(event.kind),
|
|
207
|
+
previousObjectId: event.target.cmoId,
|
|
208
|
+
claimId: event.target.claimId,
|
|
209
|
+
claimVersionId,
|
|
210
|
+
previousVersionId: event.target.versionId,
|
|
211
|
+
mutationReason,
|
|
212
|
+
contradictionConfidence: event.contradictionConfidence ?? undefined,
|
|
213
|
+
actorModel: lineageActorModel(deps),
|
|
214
|
+
},
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
function mutationTypeFor(kind) {
|
|
218
|
+
if (kind === 'canonical-update')
|
|
219
|
+
return 'update';
|
|
220
|
+
if (kind === 'canonical-supersede')
|
|
221
|
+
return 'supersede';
|
|
222
|
+
return 'delete';
|
|
223
|
+
}
|
|
224
|
+
function requireRepo(deps) {
|
|
225
|
+
if (!deps.repo) {
|
|
226
|
+
throw new Error('Lineage event requires canonical object repository access');
|
|
227
|
+
}
|
|
228
|
+
return deps.repo;
|
|
229
|
+
}
|
|
230
|
+
function lineageActorModel(deps) {
|
|
231
|
+
return deps.config.llmModel;
|
|
232
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 4-Network memory separation (Hindsight-inspired).
|
|
3
|
+
*
|
|
4
|
+
* Classifies extracted facts into one of four memory networks:
|
|
5
|
+
* - world: objective third-person facts about the external environment
|
|
6
|
+
* - experience: first-person biographical records of user actions/interactions
|
|
7
|
+
* - opinion: subjective beliefs with incrementally-updated confidence [0,1]
|
|
8
|
+
* - observation: synthesized entity profiles (generated async, never from extraction)
|
|
9
|
+
*
|
|
10
|
+
* Also implements opinion confidence evolution:
|
|
11
|
+
* reinforce (+α), weaken (-α), contradict (-2α), clamped to [0,1].
|
|
12
|
+
*/
|
|
13
|
+
import type { ExtractedFact } from './extraction.js';
|
|
14
|
+
export type MemoryNetwork = 'world' | 'experience' | 'opinion' | 'observation';
|
|
15
|
+
export interface NetworkClassification {
|
|
16
|
+
network: MemoryNetwork;
|
|
17
|
+
opinionConfidence: number | null;
|
|
18
|
+
}
|
|
19
|
+
export type OpinionSignal = 'reinforce' | 'weaken' | 'contradict';
|
|
20
|
+
/**
|
|
21
|
+
* Classify an extracted fact into the appropriate memory network.
|
|
22
|
+
* Observation is never produced by extraction — only by ObservationService.
|
|
23
|
+
*/
|
|
24
|
+
export declare function classifyNetwork(fact: ExtractedFact): NetworkClassification;
|
|
25
|
+
/**
|
|
26
|
+
* Apply a confidence update signal to an opinion memory.
|
|
27
|
+
* Returns the new confidence, clamped to [0, 1].
|
|
28
|
+
*
|
|
29
|
+
* - reinforce: evidence supports the opinion → +α
|
|
30
|
+
* - weaken: mild contradicting evidence → -α
|
|
31
|
+
* - contradict: strong contradicting evidence → -2α
|
|
32
|
+
*/
|
|
33
|
+
export declare function applyOpinionSignal(currentConfidence: number, signal: OpinionSignal): number;
|
|
34
|
+
/**
|
|
35
|
+
* Map an AUDN action to the appropriate opinion signal.
|
|
36
|
+
* - NOOP → reinforce (same opinion seen again)
|
|
37
|
+
* - UPDATE → weaken (opinion modified, not replaced)
|
|
38
|
+
* - SUPERSEDE/DELETE → contradict (opinion replaced or removed)
|
|
39
|
+
*/
|
|
40
|
+
export declare function audnActionToOpinionSignal(action: string): OpinionSignal;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 4-Network memory separation (Hindsight-inspired).
|
|
3
|
+
*
|
|
4
|
+
* Classifies extracted facts into one of four memory networks:
|
|
5
|
+
* - world: objective third-person facts about the external environment
|
|
6
|
+
* - experience: first-person biographical records of user actions/interactions
|
|
7
|
+
* - opinion: subjective beliefs with incrementally-updated confidence [0,1]
|
|
8
|
+
* - observation: synthesized entity profiles (generated async, never from extraction)
|
|
9
|
+
*
|
|
10
|
+
* Also implements opinion confidence evolution:
|
|
11
|
+
* reinforce (+α), weaken (-α), contradict (-2α), clamped to [0,1].
|
|
12
|
+
*/
|
|
13
|
+
/** Step size for opinion confidence updates. */
|
|
14
|
+
const OPINION_ALPHA = 0.1;
|
|
15
|
+
/** Default confidence assigned to newly-extracted opinions. */
|
|
16
|
+
const OPINION_INITIAL_CONFIDENCE = 0.7;
|
|
17
|
+
/** Signals indicating the user is expressing a subjective belief. */
|
|
18
|
+
const OPINION_SIGNALS = [
|
|
19
|
+
'i think', 'i believe', 'i feel', 'i prefer', 'in my opinion',
|
|
20
|
+
'i find', 'i like', 'i dislike', 'i hate', 'i love',
|
|
21
|
+
'seems to me', 'i\'d rather', 'my favorite', 'i enjoy',
|
|
22
|
+
'overrated', 'underrated', 'better than', 'worse than',
|
|
23
|
+
];
|
|
24
|
+
/** Signals indicating an objective world fact (third-person, verifiable). */
|
|
25
|
+
const WORLD_SIGNALS = [
|
|
26
|
+
'was released', 'is owned by', 'was founded', 'is headquartered',
|
|
27
|
+
'is the ceo', 'was acquired', 'is a product of', 'is developed by',
|
|
28
|
+
'version ', 'announced', 'launched', 'published', 'is written in',
|
|
29
|
+
'supports', 'is compatible with', 'requires', 'is licensed under',
|
|
30
|
+
'was invented', 'is maintained by', 'merged with',
|
|
31
|
+
];
|
|
32
|
+
/**
|
|
33
|
+
* Classify an extracted fact into the appropriate memory network.
|
|
34
|
+
* Observation is never produced by extraction — only by ObservationService.
|
|
35
|
+
*/
|
|
36
|
+
export function classifyNetwork(fact) {
|
|
37
|
+
const lower = fact.fact.toLowerCase();
|
|
38
|
+
// Preferences with subjective language → opinion network
|
|
39
|
+
if (fact.type === 'preference' || OPINION_SIGNALS.some((s) => lower.includes(s))) {
|
|
40
|
+
return { network: 'opinion', opinionConfidence: OPINION_INITIAL_CONFIDENCE };
|
|
41
|
+
}
|
|
42
|
+
// Knowledge facts with world signals → world network
|
|
43
|
+
if (fact.type === 'knowledge' && WORLD_SIGNALS.some((s) => lower.includes(s))) {
|
|
44
|
+
return { network: 'world', opinionConfidence: null };
|
|
45
|
+
}
|
|
46
|
+
// Everything else: experience (first-person biographical)
|
|
47
|
+
return { network: 'experience', opinionConfidence: null };
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Apply a confidence update signal to an opinion memory.
|
|
51
|
+
* Returns the new confidence, clamped to [0, 1].
|
|
52
|
+
*
|
|
53
|
+
* - reinforce: evidence supports the opinion → +α
|
|
54
|
+
* - weaken: mild contradicting evidence → -α
|
|
55
|
+
* - contradict: strong contradicting evidence → -2α
|
|
56
|
+
*/
|
|
57
|
+
export function applyOpinionSignal(currentConfidence, signal) {
|
|
58
|
+
const delta = signal === 'reinforce' ? OPINION_ALPHA
|
|
59
|
+
: signal === 'weaken' ? -OPINION_ALPHA
|
|
60
|
+
: -2 * OPINION_ALPHA;
|
|
61
|
+
return Math.max(0.0, Math.min(1.0, currentConfidence + delta));
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Map an AUDN action to the appropriate opinion signal.
|
|
65
|
+
* - NOOP → reinforce (same opinion seen again)
|
|
66
|
+
* - UPDATE → weaken (opinion modified, not replaced)
|
|
67
|
+
* - SUPERSEDE/DELETE → contradict (opinion replaced or removed)
|
|
68
|
+
*/
|
|
69
|
+
export function audnActionToOpinionSignal(action) {
|
|
70
|
+
if (action === 'NOOP')
|
|
71
|
+
return 'reinforce';
|
|
72
|
+
if (action === 'UPDATE')
|
|
73
|
+
return 'weaken';
|
|
74
|
+
return 'contradict';
|
|
75
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared internal types for the memory-search pipeline.
|
|
3
|
+
*
|
|
4
|
+
* These shapes are private to the search internals — kept out of
|
|
5
|
+
* `memory-service-types.ts` (which is the cross-module public surface)
|
|
6
|
+
* but split out from `memory-search.ts` so the TLL-augmentation sibling
|
|
7
|
+
* module (`tll-augmentation.ts`) can consume them without duplicating
|
|
8
|
+
* definitions or introducing a circular import.
|
|
9
|
+
*/
|
|
10
|
+
import type { SearchResult } from '../db/memory-repository.js';
|
|
11
|
+
import type { ConsensusResult } from './consensus-validation.js';
|
|
12
|
+
import type { RelevanceFilterDecision } from './relevance-policy.js';
|
|
13
|
+
export interface RelevanceFilterSummary {
|
|
14
|
+
threshold: number | null;
|
|
15
|
+
source: string;
|
|
16
|
+
reason: string;
|
|
17
|
+
queryLabel: string;
|
|
18
|
+
removedIds: string[];
|
|
19
|
+
decisions: RelevanceFilterDecision[];
|
|
20
|
+
}
|
|
21
|
+
export interface PostProcessedSearch {
|
|
22
|
+
memories: SearchResult[];
|
|
23
|
+
consensusResult?: ConsensusResult;
|
|
24
|
+
relevanceFilter: RelevanceFilterSummary;
|
|
25
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared internal types for the memory-search pipeline.
|
|
3
|
+
*
|
|
4
|
+
* These shapes are private to the search internals — kept out of
|
|
5
|
+
* `memory-service-types.ts` (which is the cross-module public surface)
|
|
6
|
+
* but split out from `memory-search.ts` so the TLL-augmentation sibling
|
|
7
|
+
* module (`tll-augmentation.ts`) can consume them without duplicating
|
|
8
|
+
* definitions or introducing a circular import.
|
|
9
|
+
*/
|
|
10
|
+
export {};
|