@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,419 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AUDN (Add/Update/Delete/Noop) decision resolution and mutation execution.
|
|
3
|
+
* Handles fast-path AUDN, deferred AUDN, conflict candidate discovery,
|
|
4
|
+
* and the full mutation pipeline (update, supersede, delete canonical facts).
|
|
5
|
+
*/
|
|
6
|
+
import { embedText } from './embedding.js';
|
|
7
|
+
import { cachedResolveAUDN } from './extraction-cache.js';
|
|
8
|
+
import { applyOpinionSignal, audnActionToOpinionSignal } from './memory-network.js';
|
|
9
|
+
import { buildAtomicFactProjection, buildForesightProjections } from './memcell-projection.js';
|
|
10
|
+
import { applyClarificationOverrides, mergeCandidates } from './conflict-policy.js';
|
|
11
|
+
import { emitAuditEvent } from './audit-events.js';
|
|
12
|
+
import { recordContradictionLesson } from './lesson-service.js';
|
|
13
|
+
import { shouldDeferAudn, deferMemoryForReconciliation } from './deferred-audn.js';
|
|
14
|
+
import { timed } from './timing.js';
|
|
15
|
+
import { emitLineageEvent } from './memory-lineage.js';
|
|
16
|
+
import { storeCanonicalFact, storeProjection, applyEntityScopedDedup, ensureClaimTarget, findConflictCandidates, findSlotConflictCandidates } from './memory-storage.js';
|
|
17
|
+
/** Find conflict candidates, merge slot-aware candidates, and filter out superseded. */
|
|
18
|
+
export async function findFilteredCandidates(deps, userId, fact, embedding, claimSlot, supersededTargets) {
|
|
19
|
+
const candidates = await timed('ingest.fact.find-conflicts', () => findConflictCandidates(deps, userId, fact.fact, embedding));
|
|
20
|
+
const slotAwareCandidates = claimSlot
|
|
21
|
+
? await timed('ingest.fact.find-slot-candidates', () => findSlotConflictCandidates(deps, userId, claimSlot))
|
|
22
|
+
: [];
|
|
23
|
+
const merged = mergeCandidates(candidates, slotAwareCandidates);
|
|
24
|
+
return merged.filter((c) => !supersededTargets.has(c.id));
|
|
25
|
+
}
|
|
26
|
+
/** Resolve AUDN decision (fast/deferred/full) and execute it. */
|
|
27
|
+
export async function resolveAndExecuteAudn(deps, userId, fact, embedding, sourceSite, sourceUrl, episodeId, trustScore, claimSlot, logicalTimestamp, filteredCandidates, supersededTargets, workspace, traceContext) {
|
|
28
|
+
const candidateIds = new Set(filteredCandidates.map((c) => c.id));
|
|
29
|
+
const ctx = { userId, fact, embedding, sourceSite, sourceUrl, episodeId, trustScore, claimSlot, logicalTimestamp, workspace };
|
|
30
|
+
const fastDecision = tryFastAUDN(fact.fact, filteredCandidates, deps.config);
|
|
31
|
+
if (fastDecision) {
|
|
32
|
+
return executeAndTrackSupersede(deps, fastDecision, candidateIds, ctx, supersededTargets, requireTraceContext(traceContext), 'fast-audn', 'NOOP', fastDecision.action);
|
|
33
|
+
}
|
|
34
|
+
if (shouldDeferAudn(false, filteredCandidates.length)) {
|
|
35
|
+
const result = await storeCanonicalFact(deps, ctx);
|
|
36
|
+
if (result.memoryId) {
|
|
37
|
+
await deferMemoryForReconciliation(deps.stores.pool, result.memoryId, filteredCandidates);
|
|
38
|
+
console.log(`[deferred-audn] Deferred: ${result.memoryId} (${filteredCandidates.length} candidates)`);
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
...result,
|
|
42
|
+
embedding,
|
|
43
|
+
trace: buildAudnTrace(requireTraceContext(traceContext), 'deferred-audn', 'ADD', 'deferred-audn-store', result.outcome, result.memoryId, null),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
if (deps.config.tbcEnabled) {
|
|
47
|
+
const { resolveAndExecuteTbc } = await import('./tbc-execution.js');
|
|
48
|
+
return resolveAndExecuteTbc(deps, ctx, filteredCandidates, candidateIds, supersededTargets, requireTraceContext(traceContext));
|
|
49
|
+
}
|
|
50
|
+
const rawDecision = await timed('ingest.fact.audn', () => cachedResolveAUDN(fact.fact, filteredCandidates));
|
|
51
|
+
let decision = applyClarificationOverrides(rawDecision, fact.fact, filteredCandidates, fact.keywords, fact.type);
|
|
52
|
+
if (deps.config.entityGraphEnabled && deps.stores.entity) {
|
|
53
|
+
decision = await applyEntityScopedDedup(deps, decision, userId, fact.entities);
|
|
54
|
+
}
|
|
55
|
+
return executeAndTrackSupersede(deps, decision, candidateIds, ctx, supersededTargets, requireTraceContext(traceContext), 'llm-audn', rawDecision.action, decision.action);
|
|
56
|
+
}
|
|
57
|
+
/** Execute the AUDN decision and track supersede targets. */
|
|
58
|
+
async function executeAndTrackSupersede(deps, decision, candidateIds, ctx, supersededTargets, traceContext, source, rawAction, effectiveAction) {
|
|
59
|
+
const result = await executeAudnDecision(deps, decision, candidateIds, ctx);
|
|
60
|
+
if (decision.action === 'SUPERSEDE' && result.memoryId) {
|
|
61
|
+
supersededTargets.add(result.memoryId);
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
...result,
|
|
65
|
+
embedding: ctx.embedding,
|
|
66
|
+
trace: buildAudnTrace(traceContext, source, effectiveAction, reasonCodeForDecision(source, decision, result), result.outcome, result.memoryId, decision.targetMemoryId, rawAction),
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Execute an AUDN decision via the standard ingest seam.
|
|
71
|
+
*
|
|
72
|
+
* Exposed (renamed from the legacy private `executeDecision`) so that the
|
|
73
|
+
* TBC executor in `tbc-execution.ts` can route Affirm/Update/Retract/
|
|
74
|
+
* Supersede through the same mutation path AUDN uses today, keeping the
|
|
75
|
+
* fail-closed semantics in place.
|
|
76
|
+
*/
|
|
77
|
+
export async function executeAudnDecision(deps, decision, candidateIds, ctx) {
|
|
78
|
+
const opinionResult = await tryOpinionIntercept(deps, decision, ctx);
|
|
79
|
+
if (opinionResult)
|
|
80
|
+
return opinionResult;
|
|
81
|
+
if (decision.action === 'ADD') {
|
|
82
|
+
return storeCanonicalFact(deps, ctx);
|
|
83
|
+
}
|
|
84
|
+
if (decision.action === 'NOOP') {
|
|
85
|
+
return recordNoop(deps, decision.targetMemoryId, candidateIds, ctx.userId, ctx.episodeId, ctx.fact.fact);
|
|
86
|
+
}
|
|
87
|
+
if (decision.action === 'CLARIFY') {
|
|
88
|
+
return storeClarification(deps, decision, ctx);
|
|
89
|
+
}
|
|
90
|
+
if (!decision.targetMemoryId || !candidateIds.has(decision.targetMemoryId)) {
|
|
91
|
+
console.error(`AUDN ${decision.action} rejected for fact "${ctx.fact.fact.slice(0, 50)}...": invalid targetMemoryId "${decision.targetMemoryId}". Candidates were: ${[...candidateIds].join(', ')}`);
|
|
92
|
+
return storeCanonicalFact(deps, ctx);
|
|
93
|
+
}
|
|
94
|
+
return executeMutationDecision(deps, decision, ctx);
|
|
95
|
+
}
|
|
96
|
+
function buildAudnTrace(traceContext, source, action, reasonCode, outcome, memoryId, targetMemoryId, rawAction) {
|
|
97
|
+
return {
|
|
98
|
+
factText: traceContext.fact.fact,
|
|
99
|
+
headline: traceContext.fact.headline,
|
|
100
|
+
factType: traceContext.fact.type,
|
|
101
|
+
importance: traceContext.fact.importance,
|
|
102
|
+
...(traceContext.logicalTimestamp ? { logicalTimestamp: traceContext.logicalTimestamp.toISOString() } : {}),
|
|
103
|
+
writeSecurity: {
|
|
104
|
+
allowed: traceContext.writeSecurity.allowed,
|
|
105
|
+
blockedBy: traceContext.writeSecurity.blockedBy,
|
|
106
|
+
trustScore: traceContext.writeSecurity.trust.score,
|
|
107
|
+
},
|
|
108
|
+
...(traceContext.entropyResult ? { entropyGate: traceContext.entropyResult } : {}),
|
|
109
|
+
candidates: traceContext.candidates,
|
|
110
|
+
decision: {
|
|
111
|
+
source,
|
|
112
|
+
action,
|
|
113
|
+
reasonCode,
|
|
114
|
+
targetMemoryId,
|
|
115
|
+
candidateIds: traceContext.candidates.map((candidate) => candidate.id),
|
|
116
|
+
...(rawAction ? { rawAction } : {}),
|
|
117
|
+
},
|
|
118
|
+
outcome,
|
|
119
|
+
memoryId,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
function requireTraceContext(traceContext) {
|
|
123
|
+
if (!traceContext) {
|
|
124
|
+
throw new Error('resolveAndExecuteAudn requires traceContext.');
|
|
125
|
+
}
|
|
126
|
+
return traceContext;
|
|
127
|
+
}
|
|
128
|
+
function reasonCodeForDecision(source, decision, result) {
|
|
129
|
+
if (source === 'fast-audn')
|
|
130
|
+
return 'fast-audn-noop';
|
|
131
|
+
// BEAM CR fix: bilateral preservation intercepted DELETE/SUPERSEDE.
|
|
132
|
+
if (result.outcome === 'preserved_contradiction')
|
|
133
|
+
return 'llm-audn-bilateral-preserve';
|
|
134
|
+
if (isInvalidTargetFallback(decision, result)) {
|
|
135
|
+
return 'invalid-target-fallback';
|
|
136
|
+
}
|
|
137
|
+
return decision.action === 'SUPERSEDE' && !result.memoryId
|
|
138
|
+
? 'invalid-target-fallback'
|
|
139
|
+
: decisionReasonCode(decision.action);
|
|
140
|
+
}
|
|
141
|
+
function isInvalidTargetFallback(decision, result) {
|
|
142
|
+
// The bilateral path emits outcome='preserved_contradiction' for DELETE
|
|
143
|
+
// and SUPERSEDE — that is the intended behavior, not a stored-fallback.
|
|
144
|
+
if (result.outcome === 'preserved_contradiction')
|
|
145
|
+
return false;
|
|
146
|
+
return !['ADD', 'NOOP', 'CLARIFY'].includes(decision.action) && result.outcome === 'stored';
|
|
147
|
+
}
|
|
148
|
+
function decisionReasonCode(action) {
|
|
149
|
+
const reasonCodes = {
|
|
150
|
+
ADD: 'llm-audn-add',
|
|
151
|
+
NOOP: 'llm-audn-noop',
|
|
152
|
+
CLARIFY: 'llm-audn-clarify',
|
|
153
|
+
UPDATE: 'llm-audn-update',
|
|
154
|
+
DELETE: 'llm-audn-delete',
|
|
155
|
+
SUPERSEDE: 'llm-audn-supersede',
|
|
156
|
+
};
|
|
157
|
+
return reasonCodes[action];
|
|
158
|
+
}
|
|
159
|
+
/** Handle opinion network intercept: update confidence instead of normal AUDN. */
|
|
160
|
+
async function tryOpinionIntercept(deps, decision, ctx) {
|
|
161
|
+
if (ctx.fact.network !== 'opinion' || !decision.targetMemoryId || decision.action === 'ADD')
|
|
162
|
+
return null;
|
|
163
|
+
const targetMemory = await deps.stores.memory.getMemory(decision.targetMemoryId, ctx.userId);
|
|
164
|
+
if (!targetMemory || targetMemory.network !== 'opinion' || targetMemory.opinion_confidence === null)
|
|
165
|
+
return null;
|
|
166
|
+
const signal = audnActionToOpinionSignal(decision.action);
|
|
167
|
+
const newConfidence = applyOpinionSignal(targetMemory.opinion_confidence, signal);
|
|
168
|
+
await deps.stores.memory.updateOpinionConfidence(ctx.userId, decision.targetMemoryId, newConfidence);
|
|
169
|
+
if (newConfidence <= 0 && targetMemory.opinion_confidence > 0) {
|
|
170
|
+
await deps.stores.memory.storeMemory({
|
|
171
|
+
userId: ctx.userId, content: ctx.fact.fact, embedding: ctx.embedding, memoryType: 'episodic', importance: ctx.fact.importance,
|
|
172
|
+
sourceSite: ctx.sourceSite, sourceUrl: ctx.sourceUrl, episodeId: ctx.episodeId, status: 'needs_clarification',
|
|
173
|
+
metadata: { clarification_note: 'Opinion confidence dropped to zero', target_memory_id: decision.targetMemoryId },
|
|
174
|
+
trustScore: ctx.trustScore, network: 'opinion', opinionConfidence: 0,
|
|
175
|
+
createdAt: ctx.logicalTimestamp, observedAt: ctx.logicalTimestamp,
|
|
176
|
+
workspaceId: ctx.workspace?.workspaceId, agentId: ctx.workspace?.agentId, visibility: ctx.workspace?.visibility,
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
if (decision.action === 'SUPERSEDE') {
|
|
180
|
+
return storeCanonicalFact(deps, ctx);
|
|
181
|
+
}
|
|
182
|
+
return { outcome: decision.action === 'NOOP' ? 'skipped' : 'updated', memoryId: decision.targetMemoryId };
|
|
183
|
+
}
|
|
184
|
+
/** Store a fact as needs_clarification for the CLARIFY action. */
|
|
185
|
+
async function storeClarification(deps, decision, ctx) {
|
|
186
|
+
await deps.stores.memory.storeMemory({
|
|
187
|
+
userId: ctx.userId, content: ctx.fact.fact, embedding: ctx.embedding,
|
|
188
|
+
memoryType: ctx.fact.type === 'knowledge' ? 'semantic' : 'episodic',
|
|
189
|
+
importance: ctx.fact.importance, sourceSite: ctx.sourceSite, sourceUrl: ctx.sourceUrl, episodeId: ctx.episodeId,
|
|
190
|
+
status: 'needs_clarification',
|
|
191
|
+
metadata: {
|
|
192
|
+
clarification_note: decision.clarificationNote ?? 'Low-confidence contradiction detected',
|
|
193
|
+
target_memory_id: decision.targetMemoryId ?? undefined,
|
|
194
|
+
contradiction_confidence: decision.contradictionConfidence ?? undefined,
|
|
195
|
+
},
|
|
196
|
+
trustScore: ctx.trustScore, createdAt: ctx.logicalTimestamp, observedAt: ctx.logicalTimestamp,
|
|
197
|
+
workspaceId: ctx.workspace?.workspaceId, agentId: ctx.workspace?.agentId, visibility: ctx.workspace?.visibility,
|
|
198
|
+
});
|
|
199
|
+
return { outcome: 'skipped', memoryId: null };
|
|
200
|
+
}
|
|
201
|
+
/** Execute UPDATE, DELETE, or SUPERSEDE — fails closed on error. */
|
|
202
|
+
async function executeMutationDecision(deps, decision, ctx) {
|
|
203
|
+
if (decision.action === 'UPDATE') {
|
|
204
|
+
return await updateCanonicalFact(deps, decision, ctx);
|
|
205
|
+
}
|
|
206
|
+
// BEAM CR fix: bilateral preservation intercepts DELETE/SUPERSEDE when the
|
|
207
|
+
// flag is on and the contradictions store is wired. Keeps both memories
|
|
208
|
+
// instead of discarding the older side. Fails closed: any error bubbles
|
|
209
|
+
// up instead of silently falling back to ADD.
|
|
210
|
+
if ((decision.action === 'DELETE' || decision.action === 'SUPERSEDE') &&
|
|
211
|
+
deps.config.contradictionPreservationEnabled &&
|
|
212
|
+
deps.stores.contradictions) {
|
|
213
|
+
return await preserveBilateralContradiction(deps, decision, ctx);
|
|
214
|
+
}
|
|
215
|
+
if (decision.action === 'DELETE') {
|
|
216
|
+
return await deleteCanonicalFact(deps, decision.targetMemoryId, ctx.userId, ctx.fact, ctx.sourceSite, ctx.sourceUrl, ctx.episodeId, decision.contradictionConfidence, ctx.logicalTimestamp);
|
|
217
|
+
}
|
|
218
|
+
return await supersedeCanonicalFact(deps, decision.targetMemoryId, ctx.userId, ctx.fact, ctx.embedding, ctx.sourceSite, ctx.sourceUrl, ctx.episodeId, decision.contradictionConfidence, ctx.trustScore, ctx.logicalTimestamp, ctx.workspace);
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* BEAM CR fix — bilateral preservation path. Instead of expiring/soft-deleting
|
|
222
|
+
* the prior memory, store the new fact as a standalone canonical row, then
|
|
223
|
+
* mark BOTH rows as contradicting each other. Records the pair in
|
|
224
|
+
* `memory_contradictions` so retrieval and analytics can surface both sides.
|
|
225
|
+
* Fails closed: errors propagate to the caller so AUDN never silently falls
|
|
226
|
+
* back to ADD (per CLAUDE.md mandate).
|
|
227
|
+
*/
|
|
228
|
+
async function preserveBilateralContradiction(deps, decision, ctx) {
|
|
229
|
+
const contradictions = deps.stores.contradictions;
|
|
230
|
+
if (!contradictions) {
|
|
231
|
+
throw new Error('AUDN bilateral preservation: contradictions store missing.');
|
|
232
|
+
}
|
|
233
|
+
const targetMemoryId = decision.targetMemoryId;
|
|
234
|
+
if (!targetMemoryId) {
|
|
235
|
+
throw new Error('AUDN bilateral preservation: missing targetMemoryId.');
|
|
236
|
+
}
|
|
237
|
+
const existing = await deps.stores.memory.getMemoryIncludingDeleted(targetMemoryId, ctx.userId);
|
|
238
|
+
if (!existing) {
|
|
239
|
+
throw new Error(`AUDN bilateral preservation: target memory ${targetMemoryId} not found.`);
|
|
240
|
+
}
|
|
241
|
+
const newMemoryId = await storeProjection(deps, ctx.userId, ctx.fact, ctx.embedding, ctx.sourceSite, ctx.sourceUrl, ctx.episodeId, ctx.trustScore, { logicalTimestamp: ctx.logicalTimestamp, workspace: ctx.workspace });
|
|
242
|
+
if (!newMemoryId) {
|
|
243
|
+
throw new Error(`AUDN bilateral preservation: storeProjection returned no id for target ${targetMemoryId}.`);
|
|
244
|
+
}
|
|
245
|
+
await contradictions.record({
|
|
246
|
+
userId: ctx.userId,
|
|
247
|
+
conversationId: ctx.episodeId,
|
|
248
|
+
leftMemoryId: existing.id,
|
|
249
|
+
rightMemoryId: newMemoryId,
|
|
250
|
+
leftSummary: existing.content,
|
|
251
|
+
rightSummary: ctx.fact.fact,
|
|
252
|
+
});
|
|
253
|
+
await contradictions.markContradictionFlagsBilateral(ctx.userId, existing.id, newMemoryId);
|
|
254
|
+
if (deps.config.auditLoggingEnabled) {
|
|
255
|
+
emitAuditEvent('memory:contradiction-preserved', ctx.userId, {
|
|
256
|
+
action: decision.action,
|
|
257
|
+
leftMemoryId: existing.id,
|
|
258
|
+
rightMemoryId: newMemoryId,
|
|
259
|
+
contradictionConfidence: decision.contradictionConfidence,
|
|
260
|
+
}, { memoryId: newMemoryId });
|
|
261
|
+
}
|
|
262
|
+
return { outcome: 'preserved_contradiction', memoryId: newMemoryId };
|
|
263
|
+
}
|
|
264
|
+
async function updateCanonicalFact(deps, decision, ctx) {
|
|
265
|
+
const { userId, fact, sourceSite, sourceUrl, episodeId, trustScore, logicalTimestamp, workspace } = ctx;
|
|
266
|
+
if (!decision.updatedContent) {
|
|
267
|
+
throw new Error(`AUDN UPDATE failed: missing updatedContent for target "${decision.targetMemoryId}"`);
|
|
268
|
+
}
|
|
269
|
+
const target = await ensureClaimTarget(deps, userId, decision.targetMemoryId);
|
|
270
|
+
const updatedEmbedding = await embedText(decision.updatedContent);
|
|
271
|
+
await deps.stores.memory.updateMemoryContent(userId, target.memoryId, decision.updatedContent, updatedEmbedding, fact.importance, fact.keywords.join(' '), trustScore);
|
|
272
|
+
const updatedAtomicFact = buildAtomicFactProjection({ ...fact, fact: decision.updatedContent }, updatedEmbedding);
|
|
273
|
+
await deps.stores.representation.replaceAtomicFactsForMemory(userId, target.memoryId, [{
|
|
274
|
+
userId, parentMemoryId: target.memoryId,
|
|
275
|
+
factText: updatedAtomicFact.factText, embedding: updatedAtomicFact.embedding,
|
|
276
|
+
factType: updatedAtomicFact.factType, importance: updatedAtomicFact.importance,
|
|
277
|
+
sourceSite, sourceUrl, episodeId,
|
|
278
|
+
keywords: updatedAtomicFact.keywords.join(' '), metadata: updatedAtomicFact.metadata,
|
|
279
|
+
workspaceId: workspace?.workspaceId, agentId: workspace?.agentId,
|
|
280
|
+
}]);
|
|
281
|
+
const updatedForesight = buildForesightProjections({ ...fact, fact: decision.updatedContent }, updatedEmbedding);
|
|
282
|
+
await deps.stores.representation.replaceForesightForMemory(userId, target.memoryId, updatedForesight.map((entry) => ({
|
|
283
|
+
userId, parentMemoryId: target.memoryId,
|
|
284
|
+
content: entry.content, embedding: entry.embedding, foresightType: entry.foresightType,
|
|
285
|
+
sourceSite, sourceUrl, episodeId,
|
|
286
|
+
metadata: entry.metadata, validFrom: entry.validFrom, validTo: entry.validTo,
|
|
287
|
+
workspaceId: workspace?.workspaceId, agentId: workspace?.agentId,
|
|
288
|
+
})));
|
|
289
|
+
const lineage = await emitLineageEvent({ claims: deps.stores.claim, repo: deps.stores.memory, config: deps.config }, {
|
|
290
|
+
kind: 'canonical-update',
|
|
291
|
+
userId,
|
|
292
|
+
fact,
|
|
293
|
+
updatedContent: decision.updatedContent,
|
|
294
|
+
updatedEmbedding,
|
|
295
|
+
sourceSite,
|
|
296
|
+
sourceUrl,
|
|
297
|
+
episodeId,
|
|
298
|
+
logicalTimestamp,
|
|
299
|
+
target,
|
|
300
|
+
contradictionConfidence: decision.contradictionConfidence,
|
|
301
|
+
});
|
|
302
|
+
if (!lineage?.cmoId) {
|
|
303
|
+
throw new Error(`AUDN UPDATE failed: missing successor canonical object for "${target.memoryId}"`);
|
|
304
|
+
}
|
|
305
|
+
await deps.stores.memory.updateMemoryMetadata(userId, target.memoryId, { cmo_id: lineage.cmoId });
|
|
306
|
+
return { outcome: 'updated', memoryId: target.memoryId };
|
|
307
|
+
}
|
|
308
|
+
async function supersedeCanonicalFact(deps, targetMemoryId, userId, fact, embedding, sourceSite, sourceUrl, episodeId, contradictionConfidence, trustScore, logicalTimestamp, workspace) {
|
|
309
|
+
const target = await ensureClaimTarget(deps, userId, targetMemoryId);
|
|
310
|
+
await deps.stores.memory.expireMemory(userId, target.memoryId);
|
|
311
|
+
const newMemoryId = await storeProjection(deps, userId, fact, embedding, sourceSite, sourceUrl, episodeId, trustScore ?? 1.0, {
|
|
312
|
+
logicalTimestamp,
|
|
313
|
+
workspace,
|
|
314
|
+
});
|
|
315
|
+
if (!newMemoryId)
|
|
316
|
+
return { outcome: 'skipped', memoryId: null };
|
|
317
|
+
const lineage = await emitLineageEvent({ claims: deps.stores.claim, repo: deps.stores.memory, config: deps.config }, {
|
|
318
|
+
kind: 'canonical-supersede',
|
|
319
|
+
userId,
|
|
320
|
+
fact,
|
|
321
|
+
embedding,
|
|
322
|
+
sourceSite,
|
|
323
|
+
sourceUrl,
|
|
324
|
+
episodeId,
|
|
325
|
+
logicalTimestamp,
|
|
326
|
+
target,
|
|
327
|
+
newMemoryId,
|
|
328
|
+
contradictionConfidence,
|
|
329
|
+
});
|
|
330
|
+
if (!lineage?.cmoId) {
|
|
331
|
+
throw new Error(`AUDN SUPERSEDE failed: missing successor canonical object for "${target.memoryId}"`);
|
|
332
|
+
}
|
|
333
|
+
await deps.stores.memory.updateMemoryMetadata(userId, newMemoryId, { cmo_id: lineage.cmoId });
|
|
334
|
+
if (deps.config.lessonsEnabled && deps.stores.lesson && contradictionConfidence) {
|
|
335
|
+
recordContradictionLesson(deps.stores.lesson, {
|
|
336
|
+
userId, content: fact.fact, sourceSite,
|
|
337
|
+
contradictionConfidence, supersededMemoryId: target.memoryId,
|
|
338
|
+
}).catch((err) => console.error('Lesson recording failed:', err));
|
|
339
|
+
}
|
|
340
|
+
return { outcome: 'deleted', memoryId: newMemoryId };
|
|
341
|
+
}
|
|
342
|
+
/** Handle AUDN DELETE: soft-delete the old memory without creating a replacement. */
|
|
343
|
+
async function deleteCanonicalFact(deps, targetMemoryId, userId, fact, sourceSite, sourceUrl, episodeId, contradictionConfidence, logicalTimestamp) {
|
|
344
|
+
const target = await ensureClaimTarget(deps, userId, targetMemoryId);
|
|
345
|
+
const targetMemory = await deps.stores.memory.getMemoryIncludingDeleted(target.memoryId, userId);
|
|
346
|
+
if (!targetMemory)
|
|
347
|
+
return { outcome: 'skipped', memoryId: null };
|
|
348
|
+
await deps.stores.memory.softDeleteMemory(userId, target.memoryId);
|
|
349
|
+
await emitLineageEvent({ claims: deps.stores.claim, repo: deps.stores.memory, config: deps.config }, {
|
|
350
|
+
kind: 'canonical-delete',
|
|
351
|
+
userId,
|
|
352
|
+
fact,
|
|
353
|
+
sourceSite,
|
|
354
|
+
sourceUrl,
|
|
355
|
+
episodeId,
|
|
356
|
+
logicalTimestamp,
|
|
357
|
+
target,
|
|
358
|
+
targetEmbedding: targetMemory.embedding,
|
|
359
|
+
contradictionConfidence,
|
|
360
|
+
});
|
|
361
|
+
if (deps.config.auditLoggingEnabled) {
|
|
362
|
+
emitAuditEvent('memory:delete', userId, {
|
|
363
|
+
reason: 'audn-delete', targetMemoryId: target.memoryId, contradictionConfidence,
|
|
364
|
+
}, { memoryId: target.memoryId });
|
|
365
|
+
}
|
|
366
|
+
return { outcome: 'deleted', memoryId: null };
|
|
367
|
+
}
|
|
368
|
+
async function recordNoop(deps, targetMemoryId, candidateIds, userId, episodeId, quoteText) {
|
|
369
|
+
if (!targetMemoryId || !candidateIds.has(targetMemoryId))
|
|
370
|
+
return { outcome: 'skipped', memoryId: null };
|
|
371
|
+
try {
|
|
372
|
+
const target = await ensureClaimTarget(deps, userId, targetMemoryId);
|
|
373
|
+
await deps.stores.claim.addEvidence({ claimVersionId: target.versionId, episodeId, memoryId: target.memoryId, quoteText });
|
|
374
|
+
}
|
|
375
|
+
catch {
|
|
376
|
+
// Target memory may not exist if AUDN decision was cached from a previous run.
|
|
377
|
+
// Safe to skip -- NOOP means "do nothing."
|
|
378
|
+
}
|
|
379
|
+
return { outcome: 'skipped', memoryId: null };
|
|
380
|
+
}
|
|
381
|
+
const QUOTED_LITERAL_PATTERN = /["""'\u2018\u2019\u201C\u201D]([^"""'\u2018\u2019\u201C\u201D]{2,80})["""'\u2018\u2019\u201C\u201D]/g;
|
|
382
|
+
function sharesQuotedLiteral(factText, candidateContent) {
|
|
383
|
+
const quotedLiterals = extractQuotedLiterals(factText);
|
|
384
|
+
if (quotedLiterals.length === 0)
|
|
385
|
+
return true;
|
|
386
|
+
const lowerCandidate = candidateContent.toLowerCase();
|
|
387
|
+
return quotedLiterals.every((literal) => lowerCandidate.includes(literal.toLowerCase()));
|
|
388
|
+
}
|
|
389
|
+
function extractQuotedLiterals(text) {
|
|
390
|
+
const literals = [];
|
|
391
|
+
let match;
|
|
392
|
+
while ((match = QUOTED_LITERAL_PATTERN.exec(text)) !== null) {
|
|
393
|
+
literals.push(match[1]);
|
|
394
|
+
}
|
|
395
|
+
return literals;
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* Fast-path AUDN: skip the LLM call for clear-cut embedding similarity cases.
|
|
399
|
+
* sim >= 0.95: near-duplicate -> NOOP (skip storing).
|
|
400
|
+
* Returns null when the case is ambiguous and needs full LLM AUDN.
|
|
401
|
+
*/
|
|
402
|
+
function tryFastAUDN(factText, candidates, runtimeConfig) {
|
|
403
|
+
if (!runtimeConfig.fastAudnEnabled)
|
|
404
|
+
return null;
|
|
405
|
+
const topCandidate = candidates.reduce((best, c) => (c.similarity > best.similarity ? c : best), candidates[0]);
|
|
406
|
+
if (!sharesQuotedLiteral(factText, topCandidate.content)) {
|
|
407
|
+
return null;
|
|
408
|
+
}
|
|
409
|
+
if (topCandidate.similarity >= runtimeConfig.fastAudnDuplicateThreshold) {
|
|
410
|
+
console.log(`[fast-audn] NOOP: sim=${topCandidate.similarity.toFixed(4)} >= ${runtimeConfig.fastAudnDuplicateThreshold} (near-duplicate of ${topCandidate.id})`);
|
|
411
|
+
return {
|
|
412
|
+
action: 'NOOP',
|
|
413
|
+
targetMemoryId: topCandidate.id,
|
|
414
|
+
updatedContent: null,
|
|
415
|
+
contradictionConfidence: null,
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
return null;
|
|
419
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CRUD operations and auxiliary methods extracted from MemoryService.
|
|
3
|
+
* Covers list, get, delete, stats, consolidation, decay, audit, lessons, and backfill.
|
|
4
|
+
*/
|
|
5
|
+
import { type ClaimSlotInput } from '../db/claim-repository.js';
|
|
6
|
+
import { type ConsolidationResult, type ConsolidationExecutionResult } from './consolidation-service.js';
|
|
7
|
+
import { type DecayResult, type CapCheckResult } from './memory-lifecycle.js';
|
|
8
|
+
import { type ReconciliationResult } from './deferred-audn.js';
|
|
9
|
+
import type { AuditTrailEntry, MutationSummary } from '../db/repository-types.js';
|
|
10
|
+
import type { MemoryServiceDeps } from './memory-service-types.js';
|
|
11
|
+
export interface ClaimSlotBackfillResult {
|
|
12
|
+
scanned: number;
|
|
13
|
+
updated: number;
|
|
14
|
+
}
|
|
15
|
+
export declare function listMemories(deps: MemoryServiceDeps, userId: string, limit?: number, offset?: number, sourceSite?: string, episodeId?: string): Promise<import("../index.js").MemoryRow[]>;
|
|
16
|
+
export declare function listMemoriesInWorkspace(deps: MemoryServiceDeps, workspaceId: string, limit: number | undefined, offset: number | undefined, callerAgentId: string): Promise<import("../index.js").MemoryRow[]>;
|
|
17
|
+
export declare function getMemory(deps: MemoryServiceDeps, id: string, userId: string): Promise<import("../index.js").MemoryRow | null>;
|
|
18
|
+
export declare function getMemoryInWorkspace(deps: MemoryServiceDeps, id: string, workspaceId: string, callerAgentId: string): Promise<import("../index.js").MemoryRow | null>;
|
|
19
|
+
/** Workspace delete enforces visibility: returns false if caller can't see the memory. */
|
|
20
|
+
export declare function deleteMemoryInWorkspace(deps: MemoryServiceDeps, id: string, workspaceId: string, callerAgentId: string): Promise<boolean>;
|
|
21
|
+
/** Expand staged summaries to full content for on-demand loading. */
|
|
22
|
+
export declare function expandMemories(deps: MemoryServiceDeps, userId: string, memoryIds: string[]): Promise<Array<{
|
|
23
|
+
id: string;
|
|
24
|
+
content: string;
|
|
25
|
+
}>>;
|
|
26
|
+
export declare function expandMemoriesInWorkspace(deps: MemoryServiceDeps, workspaceId: string, memoryIds: string[], callerAgentId: string): Promise<Array<{
|
|
27
|
+
id: string;
|
|
28
|
+
content: string;
|
|
29
|
+
}>>;
|
|
30
|
+
export declare function deleteMemory(deps: MemoryServiceDeps, id: string, userId: string): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* Delete all memories, episodes, claims, and related data for a user + source_site,
|
|
33
|
+
* and tombstone (soft-delete) every `raw_documents` row registered against the
|
|
34
|
+
* same source. Surgical reset scoped to a single source -- does NOT wipe the whole user.
|
|
35
|
+
*/
|
|
36
|
+
export declare function resetBySource(deps: MemoryServiceDeps, userId: string, sourceSite: string): Promise<{
|
|
37
|
+
deletedMemories: number;
|
|
38
|
+
deletedEpisodes: number;
|
|
39
|
+
deletedDocuments: number;
|
|
40
|
+
}>;
|
|
41
|
+
export declare function getStats(deps: MemoryServiceDeps, userId: string): Promise<{
|
|
42
|
+
count: number;
|
|
43
|
+
avgImportance: number;
|
|
44
|
+
sourceDistribution: Record<string, number>;
|
|
45
|
+
}>;
|
|
46
|
+
/** Identify memory clusters that are candidates for consolidation. */
|
|
47
|
+
export declare function consolidate(deps: MemoryServiceDeps, userId: string): Promise<ConsolidationResult>;
|
|
48
|
+
/** Execute consolidation: synthesize clusters via LLM and archive originals. */
|
|
49
|
+
export declare function performExecuteConsolidation(deps: MemoryServiceDeps, userId: string): Promise<ConsolidationExecutionResult>;
|
|
50
|
+
/** Run deferred AUDN reconciliation for a user (background pass). */
|
|
51
|
+
export declare function reconcileDeferred(deps: MemoryServiceDeps, userId: string): Promise<ReconciliationResult>;
|
|
52
|
+
/** Run deferred AUDN reconciliation across all users (batch job). */
|
|
53
|
+
export declare function reconcileDeferredAll(deps: MemoryServiceDeps): Promise<ReconciliationResult>;
|
|
54
|
+
/** Get deferred AUDN reconciliation status for a user. */
|
|
55
|
+
export declare function getDeferredStatus(deps: MemoryServiceDeps, userId: string): Promise<{
|
|
56
|
+
pending: number;
|
|
57
|
+
enabled: boolean;
|
|
58
|
+
}>;
|
|
59
|
+
/** Evaluate memories for decay and return archival candidates. */
|
|
60
|
+
export declare function evaluateDecay(deps: MemoryServiceDeps, userId: string, referenceTime?: Date): Promise<DecayResult>;
|
|
61
|
+
/** Archive memories identified by the decay cycle. */
|
|
62
|
+
export declare function archiveDecayed(deps: MemoryServiceDeps, userId: string, memoryIds: string[]): Promise<number>;
|
|
63
|
+
/** Check whether the user's memory count exceeds the configured cap. */
|
|
64
|
+
export declare function checkCap(deps: MemoryServiceDeps, userId: string): Promise<CapCheckResult>;
|
|
65
|
+
/**
|
|
66
|
+
* Get the full mutation audit trail for a single memory.
|
|
67
|
+
* Traces back through claim versions to show the complete lifecycle.
|
|
68
|
+
*/
|
|
69
|
+
export declare function getAuditTrail(deps: MemoryServiceDeps, userId: string, memoryId: string): Promise<AuditTrailEntry[]>;
|
|
70
|
+
/** Get aggregate mutation statistics for a user's memory store. */
|
|
71
|
+
export declare function getMutationSummary(deps: MemoryServiceDeps, userId: string): Promise<MutationSummary>;
|
|
72
|
+
/** Get recent mutations for a user, ordered newest first. */
|
|
73
|
+
export declare function getRecentMutations(deps: MemoryServiceDeps, userId: string, limit?: number): Promise<import("../db/repository-types.js").ClaimVersionRow[]>;
|
|
74
|
+
/**
|
|
75
|
+
* Backfill deterministic relation slots for active legacy claims.
|
|
76
|
+
* This repairs claims written before canonical slot metadata existed.
|
|
77
|
+
*/
|
|
78
|
+
export declare function backfillClaimSlots(deps: MemoryServiceDeps, userId: string): Promise<ClaimSlotBackfillResult>;
|
|
79
|
+
/** Trace the supersession chain forward from a version. */
|
|
80
|
+
export declare function getReversalChain(deps: MemoryServiceDeps, userId: string, versionId: string): Promise<import("../db/repository-types.js").ClaimVersionRow[]>;
|
|
81
|
+
/** Get all active lessons for a user. */
|
|
82
|
+
export declare function getLessons(deps: MemoryServiceDeps, userId: string): Promise<import("../db/repository-lessons.js").LessonRow[]>;
|
|
83
|
+
/** Get lesson stats for a user. */
|
|
84
|
+
export declare function getLessonStats(deps: MemoryServiceDeps, userId: string): Promise<{
|
|
85
|
+
totalActive: number;
|
|
86
|
+
byType: Record<string, number>;
|
|
87
|
+
}>;
|
|
88
|
+
/** Record a user-reported lesson (explicit feedback). */
|
|
89
|
+
export declare function reportLesson(deps: MemoryServiceDeps, userId: string, pattern: string, sourceMemoryIds: string[], severity?: 'low' | 'medium' | 'high' | 'critical'): Promise<string>;
|
|
90
|
+
/** Deactivate a lesson. */
|
|
91
|
+
export declare function deactivateLesson(deps: MemoryServiceDeps, userId: string, lessonId: string): Promise<void>;
|
|
92
|
+
/** Derive a persisted claim slot from existing entity relations. */
|
|
93
|
+
export declare function derivePersistedClaimSlot(deps: MemoryServiceDeps, userId: string, memoryId: string): Promise<ClaimSlotInput | null>;
|