@remnic/core 9.65.2 → 9.65.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/access-admin-ops-surface.d.ts +44 -44
- package/dist/access-admin-ops-surface.js +14 -14
- package/dist/access-authorization-probe.d.ts +38 -38
- package/dist/access-authorization-probe.js +15 -15
- package/dist/access-boundary.d.ts +40 -40
- package/dist/access-boundary.js +14 -14
- package/dist/access-cli.js +52 -52
- package/dist/access-coding-context-resolution.d.ts +3 -1
- package/dist/access-extraction-force-flush.d.ts +25 -25
- package/dist/access-extraction-force-flush.js +14 -14
- package/dist/access-health-types.d.ts +3 -1
- package/dist/access-http-lcm-compaction.d.ts +39 -39
- package/dist/access-http-lifecycle-flush.d.ts +39 -39
- package/dist/access-http-offline-stream.d.ts +25 -25
- package/dist/access-http-query.d.ts +4 -2
- package/dist/access-http-query.js +16 -16
- package/dist/access-http.d.ts +51 -44
- package/dist/access-http.js +30 -30
- package/dist/access-identity-continuity-surface.d.ts +12 -12
- package/dist/access-identity-continuity-surface.js +14 -14
- package/dist/access-lcm-surface.d.ts +27 -27
- package/dist/access-lcm-surface.js +14 -14
- package/dist/access-mcp-admin-tools.d.ts +9 -1
- package/dist/access-mcp-admin-tools.js +3 -1
- package/dist/access-mcp-output-schemas.js +1 -1
- package/dist/access-mcp.d.ts +39 -39
- package/dist/access-mcp.js +24 -24
- package/dist/access-memory-search-fanout.d.ts +4 -2
- package/dist/{access-namespace-preflight-Dhvcl-T0.d.ts → access-namespace-preflight-B7Usyz-K.d.ts} +1 -1
- package/dist/access-namespace-preflight.d.ts +5 -3
- package/dist/access-namespace-preflight.js +14 -14
- package/dist/access-observe-write-surface.d.ts +39 -39
- package/dist/access-observe-write-surface.js +14 -14
- package/dist/access-offline-manifest.d.ts +12 -12
- package/dist/access-operations-batch.js +18 -18
- package/dist/access-operations.d.ts +40 -40
- package/dist/access-operations.js +21 -21
- package/dist/access-recall-concurrency.d.ts +40 -40
- package/dist/access-recall-concurrency.js +14 -14
- package/dist/access-recall-response.d.ts +24 -24
- package/dist/access-recall-response.js +14 -14
- package/dist/access-recall-surface.d.ts +24 -24
- package/dist/access-recall-surface.js +14 -14
- package/dist/access-schema.d.ts +45 -45
- package/dist/{access-service-Bke1alZO.d.ts → access-service-DkaIG3n8.d.ts} +219 -75
- package/dist/access-service-helpers.d.ts +40 -40
- package/dist/access-service.d.ts +47 -47
- package/dist/access-service.js +14 -14
- package/dist/access-surface-catalog.d.ts +40 -40
- package/dist/access-surface-catalog.js +20 -16
- package/dist/access-surface-catalog.js.map +1 -1
- package/dist/access-wearables-meetings-surface.d.ts +5 -3
- package/dist/action-confidence.d.ts +3 -1
- package/dist/active-memory-bridge.d.ts +3 -1
- package/dist/active-recall.d.ts +3 -1
- package/dist/active-recall.js +6 -1
- package/dist/active-recall.js.map +1 -1
- package/dist/ambient-provenance.d.ts +3 -1
- package/dist/artifact-search.d.ts +3 -1
- package/dist/behavior-learner.d.ts +3 -1
- package/dist/behavior-signals.d.ts +3 -1
- package/dist/bootstrap.d.ts +12 -12
- package/dist/briefing-window.d.ts +4 -2
- package/dist/briefing.d.ts +4 -2
- package/dist/briefing.js +3 -3
- package/dist/buffer-surprise-report.d.ts +3 -1
- package/dist/buffer-turn-helpers.d.ts +3 -1
- package/dist/buffer.d.ts +4 -2
- package/dist/bulk-import/index.d.ts +5 -3
- package/dist/calibration.d.ts +3 -1
- package/dist/capabilities.d.ts +3 -1
- package/dist/{catalog-DV6qnbr7.d.ts → catalog-CX2BZEJh.d.ts} +1 -1
- package/dist/causal-behavior.d.ts +1 -1
- package/dist/causal-consolidation.d.ts +3 -1
- package/dist/causal-consolidation.js +7 -7
- package/dist/causal-trajectory-graph.d.ts +1 -1
- package/dist/{chunk-R7JAM2XF.js → chunk-2VXWFYJE.js} +3 -3
- package/dist/{chunk-UXO5IMBK.js → chunk-4XDGYCZI.js} +2 -2
- package/dist/{chunk-OTHZWLUD.js → chunk-57HVIG5U.js} +2 -2
- package/dist/{chunk-EILZG5VC.js → chunk-6TAX66IA.js} +2 -2
- package/dist/{chunk-NKKD4ZAU.js → chunk-6VALIZKG.js} +2 -2
- package/dist/{chunk-BWLRUMOG.js → chunk-76PL4XLG.js} +435 -1
- package/dist/chunk-76PL4XLG.js.map +1 -0
- package/dist/{chunk-2E36UXVW.js → chunk-7KFIMGMP.js} +2 -2
- package/dist/{chunk-LGO6A7GJ.js → chunk-7QOO4LGC.js} +28 -28
- package/dist/{chunk-TBOJ76ER.js → chunk-AB3A7EFH.js} +18 -2
- package/dist/{chunk-TBOJ76ER.js.map → chunk-AB3A7EFH.js.map} +1 -1
- package/dist/{chunk-DZUJ46DO.js → chunk-AUO2LJ3K.js} +2 -2
- package/dist/{chunk-ZO6AXLEH.js → chunk-AYDDB3XI.js} +2 -2
- package/dist/{chunk-NTWN6HB2.js → chunk-AYYGRVRP.js} +2 -2
- package/dist/{chunk-7YQ4IYS2.js → chunk-AZAA5DNP.js} +2 -2
- package/dist/{chunk-4KYOLI6M.js → chunk-BKYPJUQL.js} +120 -14
- package/dist/chunk-BKYPJUQL.js.map +1 -0
- package/dist/{chunk-Z7PBQPJ4.js → chunk-BQUEAVNW.js} +2 -2
- package/dist/{chunk-35NN3ZFA.js → chunk-CTVWELNK.js} +21 -3
- package/dist/chunk-CTVWELNK.js.map +1 -0
- package/dist/{chunk-5YQ63T4B.js → chunk-D27J626P.js} +2 -2
- package/dist/{chunk-LZH5FR2W.js → chunk-DHTQP334.js} +2 -2
- package/dist/{chunk-Y7DK7HHJ.js → chunk-E4MVQQVX.js} +2 -2
- package/dist/{chunk-JYYBA7TF.js → chunk-EIVIB73I.js} +2 -2
- package/dist/{chunk-S2DPMJXH.js → chunk-EV3YFLCB.js} +2 -2
- package/dist/{chunk-TZNQUNKL.js → chunk-FC7TIRFS.js} +15 -1
- package/dist/chunk-FC7TIRFS.js.map +1 -0
- package/dist/{chunk-3I7ASZN3.js → chunk-G57LQRP6.js} +2 -2
- package/dist/{chunk-UIN2BWDD.js → chunk-GN55KU2P.js} +2 -2
- package/dist/{chunk-PE255F4T.js → chunk-GUXS322H.js} +2 -2
- package/dist/{chunk-V3MXUL3D.js → chunk-H5FW4S5Q.js} +319 -643
- package/dist/chunk-H5FW4S5Q.js.map +1 -0
- package/dist/chunk-I32NKXE2.js +879 -0
- package/dist/chunk-I32NKXE2.js.map +1 -0
- package/dist/{chunk-YB42WZCY.js → chunk-IQSC3V2E.js} +2 -2
- package/dist/{chunk-MN4KB2A4.js → chunk-MBDJJTAT.js} +3 -3
- package/dist/{chunk-SQI57UCJ.js → chunk-MRTUN665.js} +2 -2
- package/dist/{chunk-SBDCZ2AX.js → chunk-NXKJHSDN.js} +1 -1
- package/dist/chunk-NXKJHSDN.js.map +1 -0
- package/dist/{chunk-SPUJNJJC.js → chunk-NZWEEALH.js} +2 -2
- package/dist/{chunk-2XDWWPTN.js → chunk-OJD4WS2E.js} +2 -2
- package/dist/{chunk-ZWXJBFZU.js → chunk-OLWTCWQ2.js} +8 -8
- package/dist/{chunk-XRYZRW54.js → chunk-P4DHENRE.js} +2 -2
- package/dist/{chunk-J275IYMG.js → chunk-PAYGC3BD.js} +29 -2
- package/dist/chunk-PAYGC3BD.js.map +1 -0
- package/dist/{chunk-IID2CMUU.js → chunk-PDVQ5JU3.js} +2 -2
- package/dist/{chunk-7BY7V4YX.js → chunk-Q4WONDMJ.js} +4 -3
- package/dist/{chunk-7BY7V4YX.js.map → chunk-Q4WONDMJ.js.map} +1 -1
- package/dist/{chunk-5NM4OH4P.js → chunk-QFMO32TO.js} +3 -3
- package/dist/{chunk-SIHSCCUQ.js → chunk-QXIQPCCN.js} +1 -1
- package/dist/{chunk-2YI72KM3.js → chunk-R47WINCY.js} +2 -2
- package/dist/{chunk-ZQHI2BZB.js → chunk-RK4WXUI2.js} +2 -2
- package/dist/{chunk-QOS5LBZN.js → chunk-S7Q5CM7E.js} +2 -2
- package/dist/{chunk-GDFVPUJ5.js → chunk-TDKSCV62.js} +2 -2
- package/dist/{chunk-OCZIYAE5.js → chunk-TYUS5TLG.js} +3 -3
- package/dist/{chunk-GNCCUR6K.js → chunk-URHCUXKI.js} +2 -2
- package/dist/{chunk-TF77C7SV.js → chunk-VA5KMSAE.js} +7 -5
- package/dist/chunk-VA5KMSAE.js.map +1 -0
- package/dist/{chunk-SB7D4BT7.js → chunk-WN5FSGLE.js} +1545 -105
- package/dist/chunk-WN5FSGLE.js.map +1 -0
- package/dist/{chunk-YLDXWCZP.js → chunk-YF6UHWOV.js} +14 -9
- package/dist/chunk-YF6UHWOV.js.map +1 -0
- package/dist/{chunk-CT56C22C.js → chunk-Z4RPXHJH.js} +4 -4
- package/dist/{cli-cShQ13XG.d.ts → cli-ChKeYMZv.d.ts} +5 -5
- package/dist/cli.d.ts +25 -25
- package/dist/cli.js +44 -43
- package/dist/coding/pre-action-gate.d.ts +2 -60
- package/dist/compounding/engine.d.ts +4 -2
- package/dist/compounding/engine.js +3 -3
- package/dist/compounding/preference-consolidator.d.ts +3 -1
- package/dist/compression-optimizer.d.ts +3 -1
- package/dist/config.d.ts +3 -1
- package/dist/config.js +6 -1
- package/dist/connectors/codex-materialize-runner.d.ts +3 -1
- package/dist/connectors/codex-materialize-runner.js +3 -3
- package/dist/connectors/codex-materialize.d.ts +3 -1
- package/dist/connectors/index.d.ts +3 -1
- package/dist/connectors/index.js +3 -3
- package/dist/consolidation-provenance-check.d.ts +4 -2
- package/dist/consolidation-undo.d.ts +4 -2
- package/dist/contradiction/index.d.ts +10 -270
- package/dist/contradiction/index.js +11 -6
- package/dist/{contradiction-review-QKJH5DKD.js → contradiction-review-WRVLRWHS.js} +6 -2
- package/dist/{contradiction-scan-VOTQRRSX.js → contradiction-scan-AKUWPX5N.js} +5 -3
- package/dist/converge-config.d.ts +3 -1
- package/dist/convergence-refresh.d.ts +4 -2
- package/dist/convergence-refresh.js +5 -5
- package/dist/conversation-index/backend.d.ts +3 -1
- package/dist/conversation-index/chunker.d.ts +3 -1
- package/dist/conversation-index/faiss-adapter.d.ts +3 -1
- package/dist/conversation-index/indexer.d.ts +3 -1
- package/dist/conversation-index/search.d.ts +3 -1
- package/dist/corpus-watermark.d.ts +3 -1
- package/dist/corpus-watermark.js +5 -5
- package/dist/cross-lingual-recall.d.ts +3 -1
- package/dist/day-summary.d.ts +3 -1
- package/dist/delinearize.d.ts +3 -1
- package/dist/dependency-propagation-config.d.ts +3 -1
- package/dist/{dependency-propagation-delivery-CsGg-VwS.d.ts → dependency-propagation-delivery-B8ZMBBCY.d.ts} +1 -1
- package/dist/direct-answer-wiring.d.ts +3 -1
- package/dist/direct-answer.d.ts +3 -1
- package/dist/embedding-fallback.d.ts +3 -1
- package/dist/enrichment/index.d.ts +3 -1
- package/dist/entity-origin-fields.d.ts +3 -1
- package/dist/entity-retrieval.d.ts +4 -2
- package/dist/entity-retrieval.js +3 -3
- package/dist/entity-schema.d.ts +3 -1
- package/dist/episodic-context.d.ts +3 -1
- package/dist/explicit-capture.d.ts +12 -12
- package/dist/external-wiki-access.d.ts +40 -40
- package/dist/external-wiki-access.js +15 -15
- package/dist/external-wiki-collection-registration.d.ts +3 -1
- package/dist/external-wiki-collection.d.ts +3 -1
- package/dist/external-wiki-mcp-tools.d.ts +40 -40
- package/dist/extraction-error-classification.d.ts +3 -1
- package/dist/extraction-faithfulness.d.ts +3 -1
- package/dist/extraction-judge-telemetry.d.ts +3 -1
- package/dist/extraction-judge-training.d.ts +3 -1
- package/dist/extraction-judge.d.ts +3 -1
- package/dist/extraction-liveness.d.ts +3 -1
- package/dist/extraction-normalization.d.ts +3 -1
- package/dist/extraction-prompt.d.ts +3 -1
- package/dist/extraction-source-grounding-rules.d.ts +3 -1
- package/dist/extraction-source-grounding.d.ts +3 -1
- package/dist/extraction.d.ts +3 -1
- package/dist/extraction.js +3 -3
- package/dist/fallback-llm.d.ts +3 -1
- package/dist/graph-dashboard-diff.d.ts +3 -1
- package/dist/graph-dashboard-key.d.ts +3 -1
- package/dist/graph-dashboard-parser.d.ts +3 -1
- package/dist/graph-edge-reinforcement.d.ts +3 -1
- package/dist/graph-path-reconstruction.d.ts +3 -1
- package/dist/graph-path-scoring.d.ts +3 -1
- package/dist/graph-snapshot.d.ts +3 -1
- package/dist/graph.d.ts +3 -1
- package/dist/harmonic-retrieval.js +1 -1
- package/dist/importance.d.ts +3 -1
- package/dist/importers/index.d.ts +3 -1
- package/dist/in-flight-reads.d.ts +3 -1
- package/dist/index-CexDrJzC.d.ts +284 -0
- package/dist/index.d.ts +251 -29
- package/dist/index.js +129 -75
- package/dist/intent.d.ts +3 -1
- package/dist/lcm/engine.d.ts +3 -1
- package/dist/lcm/index.d.ts +3 -1
- package/dist/lcm/tools.d.ts +3 -1
- package/dist/lifecycle.d.ts +3 -1
- package/dist/live-connectors-runner.d.ts +3 -1
- package/dist/local-llm.d.ts +3 -1
- package/dist/local-model-endpoint.d.ts +3 -1
- package/dist/maintenance/memory-governance.d.ts +3 -1
- package/dist/maintenance/memory-governance.js +3 -3
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.d.ts +4 -2
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +3 -3
- package/dist/maintenance/rebuild-memory-projection.d.ts +4 -2
- package/dist/maintenance/rebuild-memory-projection.js +4 -4
- package/dist/{maintenance-jhMpeGne.d.ts → maintenance-nkdtSrVr.d.ts} +3 -3
- package/dist/mcp-memory-inspector-app.d.ts +37 -37
- package/dist/memory-action-policy.d.ts +3 -1
- package/dist/memory-cache.d.ts +3 -1
- package/dist/memory-lifecycle-ledger-utils.d.ts +3 -1
- package/dist/memory-projection-store.d.ts +3 -1
- package/dist/memory-provenance.d.ts +3 -1
- package/dist/memory-snapshot.d.ts +3 -1
- package/dist/memory-subject-cli.d.ts +40 -40
- package/dist/memory-subject.d.ts +42 -42
- package/dist/memory-worth-outcomes.d.ts +4 -2
- package/dist/models-json.d.ts +3 -1
- package/dist/namespaces/migrate.d.ts +5 -3
- package/dist/namespaces/migrate.js +4 -4
- package/dist/namespaces/principal.d.ts +3 -1
- package/dist/namespaces/search.d.ts +3 -1
- package/dist/namespaces/storage.d.ts +5 -3
- package/dist/namespaces/storage.js +3 -3
- package/dist/native-knowledge.d.ts +3 -1
- package/dist/offline-sync-impression-drain.d.ts +3 -1
- package/dist/operator-doctor-corpus.d.ts +3 -1
- package/dist/operator-doctor-corpus.js +6 -6
- package/dist/operator-doctor-replica.d.ts +3 -1
- package/dist/operator-toolkit.d.ts +5 -3
- package/dist/operator-toolkit.js +15 -12
- package/dist/orchestration/compression-guideline-coordinator.d.ts +4 -2
- package/dist/orchestration/maintenance.d.ts +6 -4
- package/dist/orchestration/maintenance.js +9 -9
- package/dist/{orchestrator-DyGUC7re.d.ts → orchestrator-Bvq1-RQs.d.ts} +23 -9
- package/dist/orchestrator.d.ts +12 -12
- package/dist/orchestrator.js +52 -52
- package/dist/patterns-cli.d.ts +3 -1
- package/dist/{pipeline-C25Oxtp1.d.ts → pipeline-C8vfIiTX.d.ts} +1 -1
- package/dist/policy-runtime.d.ts +3 -1
- package/dist/proactive-contention.d.ts +3 -1
- package/dist/provenance.d.ts +3 -1
- package/dist/{public-http-CMe7NQzj.d.ts → public-http-Cy0aYbys.d.ts} +1 -1
- package/dist/{qmd-DkDVCbgF.d.ts → qmd-B9p1SZTZ.d.ts} +1 -1
- package/dist/qmd-preflight.d.ts +4 -2
- package/dist/qmd-recall-cache.d.ts +3 -1
- package/dist/qmd.d.ts +4 -2
- package/dist/recall-concurrency-config.d.ts +3 -1
- package/dist/recall-disclosure-escalation.d.ts +3 -1
- package/dist/recall-explain-renderer.d.ts +3 -1
- package/dist/recall-explain-renderer.js +3 -3
- package/dist/recall-memory-map.d.ts +3 -1
- package/dist/recall-planner-llm.d.ts +3 -1
- package/dist/recall-state.d.ts +3 -1
- package/dist/recall-tag-filter.d.ts +3 -1
- package/dist/recall-timings.d.ts +3 -1
- package/dist/recall-xray-cli.d.ts +3 -1
- package/dist/recall-xray-cli.js +4 -4
- package/dist/recall-xray-renderer.d.ts +3 -1
- package/dist/recall-xray-renderer.js +3 -3
- package/dist/recall-xray.d.ts +3 -1
- package/dist/recall-xray.js +2 -2
- package/dist/reconcile/cursor.d.ts +3 -1
- package/dist/reconcile/manifest.d.ts +3 -1
- package/dist/reconcile/plan.d.ts +3 -1
- package/dist/replay/normalizers/chatgpt.d.ts +3 -1
- package/dist/replay/normalizers/claude.d.ts +3 -1
- package/dist/replay/normalizers/openclaw.d.ts +3 -1
- package/dist/replay/normalizers/shared.d.ts +3 -1
- package/dist/replay/runner.d.ts +3 -1
- package/dist/replay/types.d.ts +3 -1
- package/dist/replica-divergence.d.ts +3 -1
- package/dist/replica-peers-config.d.ts +3 -1
- package/dist/{resolution-MFY72STR.js → resolution-4552BNRV.js} +13 -3
- package/dist/resolve-auth-token.d.ts +3 -1
- package/dist/resume-bundles.js +4 -2
- package/dist/retrieval-agents.d.ts +4 -2
- package/dist/retrieval-tiers.d.ts +3 -1
- package/dist/routing/engine.d.ts +3 -1
- package/dist/routing/store.d.ts +3 -1
- package/dist/salvage-envelope.d.ts +3 -1
- package/dist/schemas.d.ts +44 -44
- package/dist/{scope-profiles-B9xMoFO-.d.ts → scope-profiles-DLrRxFWR.d.ts} +1 -1
- package/dist/search/embed-helper.d.ts +3 -1
- package/dist/search/factory.d.ts +3 -1
- package/dist/search/index.d.ts +3 -1
- package/dist/search/lancedb-backend.d.ts +3 -1
- package/dist/search/meilisearch-backend.d.ts +3 -1
- package/dist/search/noop-backend.d.ts +3 -1
- package/dist/search/orama-backend.d.ts +3 -1
- package/dist/search/port.d.ts +3 -1
- package/dist/search/remote-backend.d.ts +3 -1
- package/dist/{semantic-TddhF0y7.d.ts → semantic-BalR6EXU.d.ts} +1 -1
- package/dist/{semantic-consolidation-C4uykW84.d.ts → semantic-consolidation-DlN6xe20.d.ts} +1 -1
- package/dist/semantic-consolidation.d.ts +4 -2
- package/dist/semantic-consolidation.js +4 -4
- package/dist/semantic-rule-promotion.js +3 -3
- package/dist/semantic-rule-verifier.d.ts +3 -1
- package/dist/semantic-rule-verifier.js +3 -3
- package/dist/{service-DCZDZNcV.d.ts → service-GkYyVfm9.d.ts} +2 -2
- package/dist/session-observer-bands.d.ts +3 -1
- package/dist/session-observer-state.d.ts +3 -1
- package/dist/shared-context/manager.d.ts +3 -1
- package/dist/signal.d.ts +3 -1
- package/dist/source-agent-qualifier.d.ts +3 -1
- package/dist/source-agent-qualifier.js +3 -3
- package/dist/{storage-CcKmEjL8.d.ts → storage-BIDzuKIn.d.ts} +1 -1
- package/dist/storage.d.ts +4 -2
- package/dist/storage.js +2 -2
- package/dist/subject-config.d.ts +3 -1
- package/dist/summarizer.d.ts +3 -1
- package/dist/summary-snapshot.d.ts +3 -1
- package/dist/support-passport/index.d.ts +43 -43
- package/dist/support-passport/index.js +17 -17
- package/dist/temporal-supersession.d.ts +4 -2
- package/dist/temporal-timeline-recall.d.ts +3 -1
- package/dist/temporal-validity.d.ts +3 -1
- package/dist/threading.d.ts +3 -1
- package/dist/tier-migration.d.ts +4 -2
- package/dist/tier-routing.d.ts +3 -1
- package/dist/topics.d.ts +3 -1
- package/dist/transcript.d.ts +3 -1
- package/dist/transfer/types.d.ts +20 -20
- package/dist/trust-score-stage.d.ts +3 -1
- package/dist/trust-score.d.ts +3 -1
- package/dist/{types-Pi0lfaEt.d.ts → types-BxAcOl5Q.d.ts} +323 -4
- package/dist/types.d.ts +3 -1
- package/dist/types.js +1 -1
- package/dist/utility-runtime.d.ts +3 -1
- package/dist/verified-recall.js +3 -3
- package/dist/who-knows-cli.d.ts +40 -40
- package/dist/who-knows-cli.js +4 -4
- package/dist/who-knows.d.ts +42 -42
- package/dist/who-knows.js +3 -3
- package/dist/write-envelope.d.ts +3 -1
- package/package.json +2 -2
- package/src/access-boundary.ts +4 -0
- package/src/access-http.ts +6 -5
- package/src/access-mcp-admin-tools.ts +24 -0
- package/src/access-mcp-output-schemas.ts +14 -0
- package/src/access-mcp.ts +2 -2
- package/src/access-operations-batch.ts +5 -0
- package/src/access-service.ts +27 -0
- package/src/access-surface-catalog.test.ts +24 -0
- package/src/access-surface-catalog.ts +4 -0
- package/src/coding/action-gate.test.ts +341 -0
- package/src/coding/action-gate.ts +556 -0
- package/src/config.ts +5 -0
- package/src/contradiction/contradiction-review.ts +50 -4
- package/src/contradiction/contradiction-scan.ts +14 -3
- package/src/contradiction/resolution.ts +50 -2
- package/src/index.ts +4 -3
- package/src/orchestration/recall-rerank-coordinator.ts +123 -4
- package/src/orchestration/recall-result-formatter.ts +6 -2
- package/src/orchestration/recall-search-pipeline.ts +14 -1
- package/src/preferences/drift-config.ts +118 -0
- package/src/preferences/drift-recall.ts +133 -0
- package/src/preferences/drift-types.ts +87 -0
- package/src/preferences/index.ts +12 -0
- package/src/preferences/preference-drift.test.ts +690 -0
- package/src/preferences/preference-drift.ts +724 -0
- package/src/review/review-deck-access.test.ts +325 -0
- package/src/review/review-deck-http-base.ts +133 -0
- package/src/review/review-deck-mutation.test.ts +417 -0
- package/src/review/review-deck-mutation.ts +677 -0
- package/src/review/review-deck-snapshot.ts +196 -0
- package/src/review/review-deck-surface.ts +117 -0
- package/src/review/review-deck.test.ts +347 -0
- package/src/review/review-deck.ts +311 -0
- package/src/storage.ts +4 -6
- package/src/types.ts +7 -3
- package/dist/chunk-35NN3ZFA.js.map +0 -1
- package/dist/chunk-4KYOLI6M.js.map +0 -1
- package/dist/chunk-BWLRUMOG.js.map +0 -1
- package/dist/chunk-J275IYMG.js.map +0 -1
- package/dist/chunk-SB7D4BT7.js.map +0 -1
- package/dist/chunk-SBDCZ2AX.js.map +0 -1
- package/dist/chunk-TF77C7SV.js.map +0 -1
- package/dist/chunk-TZNQUNKL.js.map +0 -1
- package/dist/chunk-V3MXUL3D.js.map +0 -1
- package/dist/chunk-XCTXS7VY.js +0 -402
- package/dist/chunk-XCTXS7VY.js.map +0 -1
- package/dist/chunk-YLDXWCZP.js.map +0 -1
- /package/dist/{chunk-R7JAM2XF.js.map → chunk-2VXWFYJE.js.map} +0 -0
- /package/dist/{chunk-UXO5IMBK.js.map → chunk-4XDGYCZI.js.map} +0 -0
- /package/dist/{chunk-OTHZWLUD.js.map → chunk-57HVIG5U.js.map} +0 -0
- /package/dist/{chunk-EILZG5VC.js.map → chunk-6TAX66IA.js.map} +0 -0
- /package/dist/{chunk-NKKD4ZAU.js.map → chunk-6VALIZKG.js.map} +0 -0
- /package/dist/{chunk-2E36UXVW.js.map → chunk-7KFIMGMP.js.map} +0 -0
- /package/dist/{chunk-LGO6A7GJ.js.map → chunk-7QOO4LGC.js.map} +0 -0
- /package/dist/{chunk-DZUJ46DO.js.map → chunk-AUO2LJ3K.js.map} +0 -0
- /package/dist/{chunk-ZO6AXLEH.js.map → chunk-AYDDB3XI.js.map} +0 -0
- /package/dist/{chunk-NTWN6HB2.js.map → chunk-AYYGRVRP.js.map} +0 -0
- /package/dist/{chunk-7YQ4IYS2.js.map → chunk-AZAA5DNP.js.map} +0 -0
- /package/dist/{chunk-Z7PBQPJ4.js.map → chunk-BQUEAVNW.js.map} +0 -0
- /package/dist/{chunk-5YQ63T4B.js.map → chunk-D27J626P.js.map} +0 -0
- /package/dist/{chunk-LZH5FR2W.js.map → chunk-DHTQP334.js.map} +0 -0
- /package/dist/{chunk-Y7DK7HHJ.js.map → chunk-E4MVQQVX.js.map} +0 -0
- /package/dist/{chunk-JYYBA7TF.js.map → chunk-EIVIB73I.js.map} +0 -0
- /package/dist/{chunk-S2DPMJXH.js.map → chunk-EV3YFLCB.js.map} +0 -0
- /package/dist/{chunk-3I7ASZN3.js.map → chunk-G57LQRP6.js.map} +0 -0
- /package/dist/{chunk-UIN2BWDD.js.map → chunk-GN55KU2P.js.map} +0 -0
- /package/dist/{chunk-PE255F4T.js.map → chunk-GUXS322H.js.map} +0 -0
- /package/dist/{chunk-YB42WZCY.js.map → chunk-IQSC3V2E.js.map} +0 -0
- /package/dist/{chunk-MN4KB2A4.js.map → chunk-MBDJJTAT.js.map} +0 -0
- /package/dist/{chunk-SQI57UCJ.js.map → chunk-MRTUN665.js.map} +0 -0
- /package/dist/{chunk-SPUJNJJC.js.map → chunk-NZWEEALH.js.map} +0 -0
- /package/dist/{chunk-2XDWWPTN.js.map → chunk-OJD4WS2E.js.map} +0 -0
- /package/dist/{chunk-ZWXJBFZU.js.map → chunk-OLWTCWQ2.js.map} +0 -0
- /package/dist/{chunk-XRYZRW54.js.map → chunk-P4DHENRE.js.map} +0 -0
- /package/dist/{chunk-IID2CMUU.js.map → chunk-PDVQ5JU3.js.map} +0 -0
- /package/dist/{chunk-5NM4OH4P.js.map → chunk-QFMO32TO.js.map} +0 -0
- /package/dist/{chunk-SIHSCCUQ.js.map → chunk-QXIQPCCN.js.map} +0 -0
- /package/dist/{chunk-2YI72KM3.js.map → chunk-R47WINCY.js.map} +0 -0
- /package/dist/{chunk-ZQHI2BZB.js.map → chunk-RK4WXUI2.js.map} +0 -0
- /package/dist/{chunk-QOS5LBZN.js.map → chunk-S7Q5CM7E.js.map} +0 -0
- /package/dist/{chunk-GDFVPUJ5.js.map → chunk-TDKSCV62.js.map} +0 -0
- /package/dist/{chunk-OCZIYAE5.js.map → chunk-TYUS5TLG.js.map} +0 -0
- /package/dist/{chunk-GNCCUR6K.js.map → chunk-URHCUXKI.js.map} +0 -0
- /package/dist/{chunk-CT56C22C.js.map → chunk-Z4RPXHJH.js.map} +0 -0
- /package/dist/{contradiction-review-QKJH5DKD.js.map → contradiction-review-WRVLRWHS.js.map} +0 -0
- /package/dist/{contradiction-scan-VOTQRRSX.js.map → contradiction-scan-AKUWPX5N.js.map} +0 -0
- /package/dist/{resolution-MFY72STR.js.map → resolution-4552BNRV.js.map} +0 -0
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-7T4TOGMS.js";
|
|
4
4
|
import {
|
|
5
5
|
defineOperation
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-WN5FSGLE.js";
|
|
7
7
|
|
|
8
8
|
// src/external-wiki-access.ts
|
|
9
9
|
import { z } from "zod";
|
|
@@ -26,4 +26,4 @@ var externalWikiSearchOperation = defineOperation({
|
|
|
26
26
|
export {
|
|
27
27
|
externalWikiSearchOperation
|
|
28
28
|
};
|
|
29
|
-
//# sourceMappingURL=chunk-
|
|
29
|
+
//# sourceMappingURL=chunk-PDVQ5JU3.js.map
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
migrateUnscopedPairsToNamespace,
|
|
7
7
|
readPair,
|
|
8
8
|
writePairs
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-CTVWELNK.js";
|
|
10
10
|
import {
|
|
11
11
|
extractJsonCandidates
|
|
12
12
|
} from "./chunk-RGMVMVMF.js";
|
|
@@ -548,6 +548,7 @@ export {
|
|
|
548
548
|
verdictCacheSize,
|
|
549
549
|
judgeContradictionPairs,
|
|
550
550
|
ACTIVE_STATUSES,
|
|
551
|
-
runContradictionScan
|
|
551
|
+
runContradictionScan,
|
|
552
|
+
resolveScanStorage
|
|
552
553
|
};
|
|
553
|
-
//# sourceMappingURL=chunk-
|
|
554
|
+
//# sourceMappingURL=chunk-Q4WONDMJ.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/contradiction/contradiction-judge.ts","../src/contradiction/contradiction-scan.ts"],"sourcesContent":["/**\n * Contradiction Judge — LLM-as-judge for semantic contradiction detection (issue #520).\n *\n * Pairs semantically-similar memories and classifies their relationship.\n * Reuses the extraction-judge adapter pattern but with a contradiction-specific\n * prompt and verdict taxonomy.\n *\n * Design constraints:\n * - Default verdict on any failure is \"needs-user\" (rule 48: least-privileged default).\n * - Never auto-resolve; all verdicts enter the review queue.\n * - Content-hash caching avoids redundant LLM calls across runs.\n */\n\nimport { createHash } from \"node:crypto\";\nimport { log } from \"../logger.js\";\nimport type { PluginConfig } from \"../types.js\";\nimport type { LocalLlmClient } from \"../local-llm.js\";\nimport type { FallbackLlmClient } from \"../fallback-llm.js\";\nimport { extractJsonCandidates } from \"../json-extract.js\";\n\n// ── Types ──────────────────────────────────────────────────────────────────────\n\nexport type ContradictionVerdict =\n | \"contradicts\"\n | \"independent\"\n | \"duplicates\"\n | \"needs-user\";\n\nexport interface ContradictionJudgeInput {\n /** Memory ID of the first fact. */\n memoryIdA: string;\n /** Memory ID of the second fact. */\n memoryIdB: string;\n /** Content text of the first fact. */\n textA: string;\n /** Content text of the second fact. */\n textB: string;\n /** Category of the first fact (optional context). */\n categoryA?: string;\n /** Category of the second fact (optional context). */\n categoryB?: string;\n}\n\nexport interface ContradictionJudgeResult {\n /** Memory IDs of the pair. */\n memoryIdA: string;\n memoryIdB: string;\n /** Verdict from the judge. */\n verdict: ContradictionVerdict;\n /** Human-readable rationale. */\n rationale: string;\n /** Confidence in [0, 1]. */\n confidence: number;\n}\n\nexport interface ContradictionJudgeBatchResult {\n /** Results keyed by pair key (\"idA:idB\"). */\n results: Map<string, ContradictionJudgeResult>;\n /** Number served from cache. */\n cached: number;\n /** Number produced by LLM call. */\n judged: number;\n /** Total wall-clock time in ms. */\n elapsed: number;\n}\n\n// ── Prompt ─────────────────────────────────────────────────────────────────────\n\nconst CONTRADICTION_JUDGE_PROMPT = `You are a memory contradiction classifier. You will receive pairs of stored memories and must classify their semantic relationship.\n\nFor each pair, respond with a JSON array where each element has:\n- \"pairKey\": the pairKey provided in the input\n- \"verdict\": one of \"contradicts\", \"independent\", \"duplicates\", \"needs-user\"\n- \"rationale\": one sentence explaining why\n- \"confidence\": number between 0 and 1\n\nVERDICT DEFINITIONS:\n- \"contradicts\": The two memories make claims that cannot both be true. One must be wrong or outdated.\n- \"duplicates\": The two memories convey essentially the same information (near-paraphrase).\n- \"independent\": The memories are topically similar but do not conflict or duplicate.\n- \"needs-user\": Cannot determine with sufficient confidence; requires human review.\n\nIMPORTANT:\n- Be conservative. When in doubt, prefer \"needs-user\" over a wrong classification.\n- Two memories about the same entity/topic are NOT necessarily contradictory.\n- Temporal changes (\"Joshua uses pnpm\" vs \"Joshua switched to npm\") ARE contradictions.\n- Different aspects of the same entity (\"Joshua uses pnpm\" vs \"Joshua works on Remnic\") are \"independent\".`;\n\n// ── Cache ──────────────────────────────────────────────────────────────────────\n\n/** Module-level fallback cache — only used when caller does not supply one. */\nlet defaultVerdictCache: Map<string, ContradictionJudgeResult> = new Map();\nconst CACHE_MAX = 10_000;\n\nfunction pairKey(idA: string, idB: string): string {\n const sorted = [idA, idB].sort();\n return `${sorted[0]}:${sorted[1]}`;\n}\n\nfunction contentHash(a: ContradictionJudgeInput): string {\n // Sort each side pair to be order-independent (matching pairKey behavior)\n const sides = [\n { text: a.textA.trim(), category: (a.categoryA ?? \"\").trim() },\n { text: a.textB.trim(), category: (a.categoryB ?? \"\").trim() },\n ].sort((left, right) => {\n const leftKey = JSON.stringify(left);\n const rightKey = JSON.stringify(right);\n return leftKey.localeCompare(rightKey);\n });\n const normalized = JSON.stringify(sides);\n return createHash(\"sha256\").update(normalized).digest(\"hex\").slice(0, 16);\n}\n\nexport function createVerdictCache(): Map<string, ContradictionJudgeResult> {\n return new Map();\n}\n\nexport function clearVerdictCache(): void {\n defaultVerdictCache.clear();\n}\n\nexport function verdictCacheSize(): number {\n return defaultVerdictCache.size;\n}\n\n// ── Public API ──────────────────────────────────────────────────────────────────\n\n/**\n * Judge a batch of memory pairs for contradiction.\n *\n * Uses content-hash caching to skip pairs already judged in a prior run.\n * On any LLM failure, all unresolved pairs default to \"needs-user\".\n */\nexport async function judgeContradictionPairs(\n pairs: ContradictionJudgeInput[],\n config: PluginConfig,\n localLlm: LocalLlmClient | null,\n fallbackLlm: FallbackLlmClient | null,\n cache?: Map<string, ContradictionJudgeResult>,\n): Promise<ContradictionJudgeBatchResult> {\n const startTime = Date.now();\n const results = new Map<string, ContradictionJudgeResult>();\n const activeCache = cache ?? defaultVerdictCache;\n let cached = 0;\n let judged = 0;\n\n // Partition into cached vs needs-judging\n const toJudge: ContradictionJudgeInput[] = [];\n for (const pair of pairs) {\n const key = pairKey(pair.memoryIdA, pair.memoryIdB);\n const hash = contentHash(pair);\n const cachedResult = activeCache.get(hash);\n if (cachedResult) {\n results.set(key, { ...cachedResult, memoryIdA: pair.memoryIdA, memoryIdB: pair.memoryIdB });\n cached++;\n } else {\n toJudge.push(pair);\n }\n }\n\n if (toJudge.length === 0) {\n return { results, cached, judged, elapsed: Date.now() - startTime };\n }\n\n // Build the prompt with all pairs\n const pairDescriptions = toJudge.map((p, i) => {\n const pk = pairKey(p.memoryIdA, p.memoryIdB);\n const catA = p.categoryA ? ` [${p.categoryA}]` : \"\";\n const catB = p.categoryB ? ` [${p.categoryB}]` : \"\";\n return `Pair ${i + 1} (pairKey: \"${pk}\"):${catA} \"${p.textA}\"${catB} \"${p.textB}\"`;\n });\n\n const userMessage = `Classify these ${toJudge.length} memory pair(s):\\n\\n${pairDescriptions.join(\"\\n\\n\")}`;\n\n // Try LLM call\n let llmResponse: string | null = null;\n\n if (localLlm) {\n try {\n llmResponse = await callLlm(localLlm, config, userMessage);\n } catch (err) {\n log.warn(\"[contradiction-judge] local LLM call failed: %s\", err instanceof Error ? err.message : err);\n }\n }\n\n if (!llmResponse && fallbackLlm) {\n try {\n llmResponse = await callLlm(fallbackLlm, config, userMessage);\n } catch (err) {\n log.warn(\"[contradiction-judge] fallback LLM call failed: %s\", err instanceof Error ? err.message : err);\n }\n }\n\n // Parse response or default to needs-user\n if (llmResponse) {\n const candidates = extractJsonCandidates(llmResponse);\n const parsed = parseJudgeResponse(candidates, toJudge);\n\n for (const result of parsed) {\n const key = pairKey(result.memoryIdA, result.memoryIdB);\n results.set(key, result);\n\n // Update cache\n const input = toJudge.find(\n (p) => pairKey(p.memoryIdA, p.memoryIdB) === key,\n );\n if (input) {\n const hash = contentHash(input);\n if (activeCache.size >= CACHE_MAX) {\n const firstKey = activeCache.keys().next().value;\n if (firstKey !== undefined) activeCache.delete(firstKey);\n }\n activeCache.set(hash, result);\n }\n judged++;\n }\n } else {\n // All unresolved → needs-user (rule 48)\n for (const pair of toJudge) {\n const key = pairKey(pair.memoryIdA, pair.memoryIdB);\n const result: ContradictionJudgeResult = {\n memoryIdA: pair.memoryIdA,\n memoryIdB: pair.memoryIdB,\n verdict: \"needs-user\",\n rationale: \"LLM call failed; requires manual review\",\n confidence: 0,\n };\n results.set(key, result);\n judged++;\n }\n }\n\n return { results, cached, judged, elapsed: Date.now() - startTime };\n}\n\n// ── Internals ──────────────────────────────────────────────────────────────────\n\nasync function callLlm(\n client: LocalLlmClient | FallbackLlmClient,\n config: PluginConfig,\n userMessage: string,\n): Promise<string> {\n const messages: Array<{ role: \"user\" | \"assistant\" | \"system\"; content: string }> = [\n { role: \"system\", content: CONTRADICTION_JUDGE_PROMPT },\n { role: \"user\", content: userMessage },\n ];\n if (\"chatCompletion\" in client && typeof client.chatCompletion === \"function\") {\n const result = await client.chatCompletion(messages, {\n temperature: 0.1,\n maxTokens: 4096,\n operation: \"contradiction-judge\",\n });\n return result?.content ?? \"\";\n }\n // FallbackLlmClient — try OpenAI-compatible chat completions\n if (\"complete\" in client && typeof (client as Record<string, unknown>).complete === \"function\") {\n const result = await (client as { complete: (msg: Array<{ role: string; content: string }>) => Promise<{ content: string }> }).complete(messages);\n return result.content ?? \"\";\n }\n return \"\";\n}\n\nfunction parseJudgeResponse(\n candidates: string[],\n inputs: ContradictionJudgeInput[],\n): ContradictionJudgeResult[] {\n const VALID_VERDICTS: ContradictionVerdict[] = [\"contradicts\", \"independent\", \"duplicates\", \"needs-user\"];\n let conservativeFallback: ContradictionJudgeResult[] | null = null;\n\n for (const candidate of candidates) {\n try {\n const parsed = JSON.parse(candidate);\n const items = Array.isArray(parsed) ? parsed : [parsed];\n const results: ContradictionJudgeResult[] = [];\n const matchedKeys = new Set<string>();\n\n for (const item of items) {\n if (!item || typeof item !== \"object\") continue;\n\n const verdict = typeof item.verdict === \"string\" && VALID_VERDICTS.includes(item.verdict as ContradictionVerdict)\n ? (item.verdict as ContradictionVerdict)\n : \"needs-user\";\n\n const pairKeyVal = typeof item.pairKey === \"string\" && item.pairKey.length > 0\n ? item.pairKey\n : null;\n const input = pairKeyVal\n ? inputs.find((p) => pairKey(p.memoryIdA, p.memoryIdB) === pairKeyVal)\n : null;\n\n if (!input) continue;\n\n matchedKeys.add(pairKey(input.memoryIdA, input.memoryIdB));\n\n const confidence = typeof item.confidence === \"number\"\n ? Math.min(1, Math.max(0, item.confidence))\n : 0.5;\n\n results.push({\n memoryIdA: input.memoryIdA,\n memoryIdB: input.memoryIdB,\n verdict,\n rationale: typeof item.rationale === \"string\" ? item.rationale : \"No rationale provided\",\n confidence,\n });\n }\n\n // Backfill any inputs the LLM omitted with needs-user\n for (const inp of inputs) {\n const key = pairKey(inp.memoryIdA, inp.memoryIdB);\n if (!matchedKeys.has(key)) {\n results.push({\n memoryIdA: inp.memoryIdA,\n memoryIdB: inp.memoryIdB,\n verdict: \"needs-user\",\n rationale: \"LLM response omitted this pair\",\n confidence: 0,\n });\n }\n }\n\n if (matchedKeys.size > 0) return results;\n if (results.length > 0 && conservativeFallback === null) {\n conservativeFallback = results;\n }\n } catch {\n continue;\n }\n }\n\n if (conservativeFallback !== null) return conservativeFallback;\n\n // All parse attempts failed → needs-user for every input\n return inputs.map((p) => ({\n memoryIdA: p.memoryIdA,\n memoryIdB: p.memoryIdB,\n verdict: \"needs-user\" as ContradictionVerdict,\n rationale: \"Failed to parse judge response\",\n confidence: 0,\n }));\n}\n\nexport { pairKey as _pairKey, contentHash as _contentHash };\n","/**\n * Contradiction Scan — pair generator + scan driver (issue #520).\n *\n * Nightly cron that pairs semantically-similar active memories within\n * the same namespace, sends candidate pairs to the LLM-as-judge\n * contradiction classifier, and drops contradicting pairs into a\n * review queue for user resolution.\n *\n * Pair generation (cheap pre-filter):\n * 1. Find candidate peers via embedding cosine >= similarityFloor.\n * 2. Restrict to pairs sharing at least one entityRef OR overlapping\n * topic tokens >= topicOverlapFloor.\n * 3. Skip pairs already judged independent/both-valid within cooldown.\n * 4. Cap per-run work at maxPairsPerRun.\n */\n\nimport { resolveNamespaceCapabilities } from \"../capabilities.js\";\nimport type { StorageManager } from \"../storage.js\";\nimport type { PluginConfig, MemoryFile, MemoryStatus } from \"../types.js\";\nimport type { SemanticDedupLookup } from \"../dedup/semantic.js\";\nimport { log } from \"../logger.js\";\nimport { judgeContradictionPairs, type ContradictionJudgeInput } from \"./contradiction-judge.js\";\nimport {\n writePairs,\n readPair,\n isCoolingDown,\n memoryHashesChanged,\n computeMemoryContentHash,\n computePairId,\n migrateUnscopedPairsToNamespace,\n type ContradictionPair,\n} from \"./contradiction-review.js\";\nimport type { LocalLlmClient } from \"../local-llm.js\";\nimport type { FallbackLlmClient } from \"../fallback-llm.js\";\nimport { isSupportPassportPrivateMemory } from \"../support-passport/card-projection.js\";\n\n// ── Types ──────────────────────────────────────────────────────────────────────\n\n/** The set of statuses that represent \"live\" memories eligible for scanning. */\nexport const ACTIVE_STATUSES: Set<MemoryStatus> = new Set([\"active\"]);\n\n/** High-value taxonomy buckets to scan. */\nconst SCAN_CATEGORIES = new Set([\n \"decision\",\n \"principle\",\n \"rule\",\n \"entity\",\n \"fact\",\n \"preference\",\n]);\n\nexport interface ScanResult {\n /** Total active memories scanned. */\n scanned: number;\n /** Candidate pairs generated by the pre-filter. */\n candidates: number;\n /** Pairs sent to judge. */\n judged: number;\n /** Pairs written to review queue. */\n queued: number;\n /** Pairs skipped due to cooldown. */\n cooledDown: number;\n /** Total wall-clock time in ms. */\n elapsedMs: number;\n}\n\nexport interface ScanStorageResolution {\n storage: StorageManager;\n namespace?: string;\n}\n\nexport interface ScanDependencies {\n storage: StorageManager;\n config: PluginConfig;\n memoryDir: string;\n /** Pre-built embedding lookup. When provided, used as-is for Strategy 3. */\n embeddingLookup?: SemanticDedupLookup;\n /**\n * Factory to build a namespace-scoped embedding lookup.\n * When provided, takes precedence over `embeddingLookup`.\n * The scan driver passes its own `storage` so the lookup queries the correct index.\n */\n embeddingLookupFactory?: (storage: StorageManager) => SemanticDedupLookup | undefined;\n /** Resolver for namespace-scoped storage. Required for scans when namespaces are enabled. */\n storageForNamespace?: (\n namespace: string | undefined,\n ) => StorageManager | ScanStorageResolution | Promise<StorageManager | ScanStorageResolution>;\n localLlm: LocalLlmClient | null;\n fallbackLlm: FallbackLlmClient | null;\n namespace?: string;\n}\n\n// ── Main scan driver ───────────────────────────────────────────────────────────\n\n/**\n * Run a contradiction scan over the memory corpus.\n *\n * This is the entry point called by the nightly cron and by the CLI.\n */\nexport async function runContradictionScan(deps: ScanDependencies): Promise<ScanResult> {\n const startTime = Date.now();\n const { config, memoryDir, embeddingLookup, embeddingLookupFactory, localLlm, fallbackLlm } = deps;\n const requestedNamespace = normalizeScanNamespace(deps.namespace);\n const scanConfig = config.contradictionScan;\n\n if (!scanConfig.enabled) {\n log.info(\"[contradiction-scan] disabled by config\");\n return { scanned: 0, candidates: 0, judged: 0, queued: 0, cooledDown: 0, elapsedMs: 0 };\n }\n\n const { storage: scanStorage, namespace } = await resolveScanStorage(deps, requestedNamespace);\n if (resolveNamespaceCapabilities(config).namespaces && namespace !== undefined && isDefaultNamespaceScan(config, requestedNamespace, namespace)) {\n const migrated = migrateUnscopedPairsToNamespace(memoryDir, namespace, { cooldownDays: scanConfig.cooldownDays });\n if (migrated > 0) {\n log.info(\"[contradiction-scan] migrated %d legacy unscoped review pairs to namespace %s\", migrated, namespace);\n }\n }\n\n // Prefer the factory (which uses the scan's own storage for correct namespace scoping)\n // over a pre-built lookup (which may use default-namespace storage).\n const scopedEmbeddingLookup = embeddingLookupFactory\n ? embeddingLookupFactory(scanStorage)\n : embeddingLookup;\n\n // 1. Load active memories in scan categories\n const memories = await loadEligibleMemories(scanStorage);\n log.info(\"[contradiction-scan] loaded %d eligible memories\", memories.length);\n\n if (memories.length < 2) {\n return { scanned: memories.length, candidates: 0, judged: 0, queued: 0, cooledDown: 0, elapsedMs: Date.now() - startTime };\n }\n\n // 2. Prepare exact existing-pair lookup for cooldown checking.\n // Pair IDs are deterministic, so lookup the candidate's file directly instead\n // of paging through the review queue and risking a bounded-list miss.\n const existingPairCache = new Map<string, ContradictionPair | undefined>();\n const getExistingPair = (pairId: string): ContradictionPair | undefined => {\n if (!existingPairCache.has(pairId)) {\n existingPairCache.set(pairId, readPair(memoryDir, pairId) ?? undefined);\n }\n return existingPairCache.get(pairId);\n };\n\n // 3. Generate candidate pairs\n const candidates = await generatePairs(memories, getExistingPair, scanConfig, namespace, scopedEmbeddingLookup);\n const cooledDown = candidates.skipped;\n log.info(\"[contradiction-scan] generated %d candidates (%d cooled down)\", candidates.pairs.length, cooledDown);\n\n if (candidates.pairs.length === 0) {\n return {\n scanned: memories.length,\n candidates: 0,\n judged: 0,\n queued: 0,\n cooledDown,\n elapsedMs: Date.now() - startTime,\n };\n }\n\n // 4. Build judge inputs. Candidate generation already preserves strategy\n // priority and caps work at maxPairsPerRun.\n const judgeInputs: ContradictionJudgeInput[] = candidates.pairs.map((pair) => ({\n memoryIdA: pair.idA,\n memoryIdB: pair.idB,\n textA: pair.textA,\n textB: pair.textB,\n categoryA: pair.categoryA,\n categoryB: pair.categoryB,\n }));\n\n // 6. Send to judge (per-scan cache avoids module-level singleton leak)\n const scanCache = new Map<string, import(\"./contradiction-judge.js\").ContradictionJudgeResult>();\n const judgeResult = await judgeContradictionPairs(judgeInputs, config, localLlm, fallbackLlm, scanCache);\n log.info(\"[contradiction-scan] judge completed: %d judged, %d cached in %dms\", judgeResult.judged, judgeResult.cached, judgeResult.elapsed);\n\n // 7. Write to review queue\n const queueEntries: Array<Omit<ContradictionPair, \"pairId\"> & { memoryIds: [string, string] }> = [];\n const currentMemoryHashes = memoryContentHashMap(memories);\n for (const [key, result] of judgeResult.results) {\n queueEntries.push({\n memoryIds: [result.memoryIdA, result.memoryIdB],\n verdict: result.verdict,\n rationale: result.rationale,\n confidence: result.confidence,\n detectedAt: new Date().toISOString(),\n // Set lastReviewedAt for non-actionable verdicts so cooldown prevents re-judging\n lastReviewedAt: result.verdict === \"independent\" ? new Date().toISOString() : undefined,\n memoryContentHashes: pairMemoryContentHashes(result.memoryIdA, result.memoryIdB, currentMemoryHashes),\n namespace,\n });\n }\n\n const written = writePairs(memoryDir, queueEntries, { cooldownDays: scanConfig.cooldownDays });\n const elapsed = Date.now() - startTime;\n log.info(\"[contradiction-scan] complete: %d queued in %dms\", written.length, elapsed);\n\n return {\n scanned: memories.length,\n candidates: candidates.pairs.length,\n judged: judgeResult.judged,\n queued: written.length,\n cooledDown,\n elapsedMs: elapsed,\n };\n}\n\n// ── Pair generation ────────────────────────────────────────────────────────────\n\ninterface CandidatePair {\n idA: string;\n idB: string;\n textA: string;\n textB: string;\n categoryA?: string;\n categoryB?: string;\n}\n\ninterface PairGenResult {\n pairs: CandidatePair[];\n skipped: number;\n}\n\nasync function generatePairs(\n memories: MemoryFile[],\n getExistingPair: (pairId: string) => ContradictionPair | undefined,\n scanConfig: PluginConfig[\"contradictionScan\"],\n namespace: string | undefined,\n embeddingLookup?: SemanticDedupLookup,\n): Promise<PairGenResult> {\n const pairs: CandidatePair[] = [];\n let skipped = 0;\n const seen = new Set<string>();\n const maxPairs = Math.max(0, Math.floor(scanConfig.maxPairsPerRun));\n if (maxPairs === 0) return { pairs, skipped };\n\n const orderedMemories = [...memories].sort(compareMemoryId);\n const currentMemoryHashes = memoryContentHashMap(orderedMemories);\n\n const pushCandidate = (pair: CandidatePair): void => {\n if (pairs.length < maxPairs) pairs.push(pair);\n };\n\n const hasCapacity = (): boolean => pairs.length < maxPairs;\n const isSkippedByCooldown = (existing: ContradictionPair | undefined): boolean => {\n if (!existing || !isCoolingDown(existing, scanConfig.cooldownDays)) return false;\n return !memoryHashesChanged(\"\", existing, (memoryId) => currentMemoryHashes.get(memoryId) ?? null);\n };\n\n // Build index by entityRef for fast lookup\n const byEntity = new Map<string, MemoryFile[]>();\n for (const mem of orderedMemories) {\n const entity = mem.frontmatter.entityRef;\n if (entity) {\n const existing = byEntity.get(entity) ?? [];\n existing.push(mem);\n byEntity.set(entity, existing);\n }\n }\n\n // Strategy 1: Entity-ref based pairing (high precision)\n entityPairs:\n for (const entity of [...byEntity.keys()].sort()) {\n const group = byEntity.get(entity) ?? [];\n if (group.length < 2) continue;\n for (let i = 0; i < group.length; i++) {\n for (let j = i + 1; j < group.length; j++) {\n if (!hasCapacity()) break entityPairs;\n const a = group[i];\n const b = group[j];\n const pairId = computePairId(a.frontmatter.id!, b.frontmatter.id!, namespace);\n\n if (seen.has(pairId)) continue;\n seen.add(pairId);\n\n // Check cooldown\n const existing = getExistingPair(pairId);\n if (isSkippedByCooldown(existing)) {\n skipped++;\n continue;\n }\n\n pushCandidate({\n idA: a.frontmatter.id!,\n idB: b.frontmatter.id!,\n textA: a.content,\n textB: b.content,\n categoryA: a.frontmatter.category as string | undefined,\n categoryB: b.frontmatter.category as string | undefined,\n });\n }\n }\n }\n\n // Strategy 2: Tag/topic overlap for memories without a shared entityRef\n topicPairs:\n for (let i = 0; i < orderedMemories.length; i++) {\n for (let j = i + 1; j < orderedMemories.length; j++) {\n if (!hasCapacity()) break topicPairs;\n const a = orderedMemories[i];\n const b = orderedMemories[j];\n if (shareEntityRef(a, b)) continue;\n const overlap = jaccardOverlap(\n (a.frontmatter.tags as string[]) ?? [],\n (b.frontmatter.tags as string[]) ?? [],\n );\n\n if (overlap < scanConfig.topicOverlapFloor) continue;\n\n const pairId = computePairId(a.frontmatter.id!, b.frontmatter.id!, namespace);\n if (seen.has(pairId)) continue;\n seen.add(pairId);\n\n const existing = getExistingPair(pairId);\n if (isSkippedByCooldown(existing)) {\n skipped++;\n continue;\n }\n\n pushCandidate({\n idA: a.frontmatter.id!,\n idB: b.frontmatter.id!,\n textA: a.content,\n textB: b.content,\n categoryA: a.frontmatter.category as string | undefined,\n categoryB: b.frontmatter.category as string | undefined,\n });\n }\n }\n\n // Strategy 3: Embedding cosine similarity (enforces similarityFloor config)\n if (embeddingLookup && hasCapacity()) {\n const memoryById = new Map(orderedMemories.map((m) => [m.frontmatter.id!, m]));\n embeddingPairs:\n for (const mem of orderedMemories) {\n if (!hasCapacity()) break;\n const id = mem.frontmatter.id!;\n try {\n const hits = (await embeddingLookup(mem.content, 20)).sort((a, b) =>\n b.score - a.score || a.id.localeCompare(b.id),\n );\n for (const hit of hits) {\n if (!hasCapacity()) break embeddingPairs;\n if (hit.score < scanConfig.similarityFloor) continue;\n if (hit.id === id) continue;\n const peer = memoryById.get(hit.id);\n if (!peer) continue;\n\n const pairId = computePairId(id, hit.id, namespace);\n if (seen.has(pairId)) continue;\n seen.add(pairId);\n\n const existing = getExistingPair(pairId);\n if (isSkippedByCooldown(existing)) {\n skipped++;\n continue;\n }\n\n pushCandidate({\n idA: id,\n idB: hit.id,\n textA: mem.content,\n textB: peer.content,\n categoryA: mem.frontmatter.category as string | undefined,\n categoryB: peer.frontmatter.category as string | undefined,\n });\n }\n } catch {\n // Embedding backend unavailable — skip, entity-ref/tag strategies already covered\n }\n }\n }\n\n return { pairs, skipped };\n}\n\n// ── Helpers ────────────────────────────────────────────────────────────────────\n\nfunction normalizeScanNamespace(namespace: string | undefined): string | undefined {\n const trimmed = namespace?.trim();\n return trimmed ? trimmed : undefined;\n}\n\nasync function resolveScanStorage(\n deps: ScanDependencies,\n namespace: string | undefined,\n): Promise<ScanStorageResolution> {\n if (!resolveNamespaceCapabilities(deps.config).namespaces) {\n const defaultNamespace = normalizeScanNamespace(deps.config.defaultNamespace);\n if (namespace && namespace !== defaultNamespace) {\n throw new Error(`unsupported namespace: ${namespace}`);\n }\n return { storage: deps.storage, namespace: undefined };\n }\n\n if (deps.storageForNamespace) {\n const resolved = await deps.storageForNamespace(namespace);\n if (isScanStorageResolution(resolved)) {\n return {\n storage: resolved.storage,\n namespace: normalizeScanNamespace(resolved.namespace) ?? fallbackResolvedNamespace(deps, namespace),\n };\n }\n if (!isStorageManagerLike(resolved)) {\n throw new Error(\"storageForNamespace must return a StorageManager or { storage: StorageManager, namespace?: string }\");\n }\n return {\n storage: resolved,\n namespace: fallbackResolvedNamespace(deps, namespace),\n };\n }\n\n throw new Error(\n \"contradiction scans require storageForNamespace when namespaces are enabled so callers can enforce namespace access\",\n );\n}\n\nfunction isScanStorageResolution(value: StorageManager | ScanStorageResolution): value is ScanStorageResolution {\n if (isStorageManagerLike(value)) return false;\n if (typeof value !== \"object\" || value === null) return false;\n const candidate = value as { storage?: unknown };\n return isStorageManagerLike(candidate.storage);\n}\n\nfunction isStorageManagerLike(value: unknown): value is StorageManager {\n if (typeof value !== \"object\" || value === null) return false;\n const candidate = value as { readAllMemories?: unknown };\n return typeof candidate.readAllMemories === \"function\";\n}\n\nfunction fallbackResolvedNamespace(deps: ScanDependencies, namespace: string | undefined): string | undefined {\n if (namespace) return namespace;\n return resolveNamespaceCapabilities(deps.config).namespaces ? deps.config.defaultNamespace : undefined;\n}\n\nfunction isDefaultNamespaceScan(\n config: PluginConfig,\n requestedNamespace: string | undefined,\n resolvedNamespace: string,\n): boolean {\n if (requestedNamespace === undefined) return true;\n return requestedNamespace === config.defaultNamespace || resolvedNamespace === config.defaultNamespace;\n}\n\nasync function loadEligibleMemories(storage: StorageManager): Promise<MemoryFile[]> {\n let all: MemoryFile[];\n try {\n all = await storage.readAllMemories();\n } catch {\n return [];\n }\n\n return all.filter((mem) => {\n const fm = mem.frontmatter;\n if (isSupportPassportPrivateMemory(mem)) return false;\n // Only active memories (rule 53: explicit ACTIVE_STATUSES set)\n const status = (fm.status as MemoryStatus) ?? \"active\";\n if (!ACTIVE_STATUSES.has(status)) return false;\n\n // Only scan high-value categories\n const category = fm.category as string | undefined;\n if (category && !SCAN_CATEGORIES.has(category)) return false;\n\n // Must have content\n if (!mem.content || mem.content.trim().length === 0) return false;\n\n // Must have an ID\n if (!fm.id) return false;\n\n return true;\n });\n}\n\nfunction jaccardOverlap(a: string[], b: string[]): number {\n if (a.length === 0 && b.length === 0) return 0;\n const setA = new Set(a.map((t) => t.toLowerCase()));\n const setB = new Set(b.map((t) => t.toLowerCase()));\n let intersection = 0;\n for (const item of setA) {\n if (setB.has(item)) intersection++;\n }\n const union = setA.size + setB.size - intersection;\n return union === 0 ? 0 : intersection / union;\n}\n\nfunction shareEntityRef(a: MemoryFile, b: MemoryFile): boolean {\n const entityA = a.frontmatter.entityRef?.trim();\n const entityB = b.frontmatter.entityRef?.trim();\n return Boolean(entityA && entityB && entityA === entityB);\n}\n\nfunction compareMemoryId(a: MemoryFile, b: MemoryFile): number {\n return (a.frontmatter.id ?? \"\").localeCompare(b.frontmatter.id ?? \"\");\n}\n\nfunction memoryContentHashMap(memories: MemoryFile[]): Map<string, string> {\n const hashes = new Map<string, string>();\n for (const memory of memories) {\n const id = memory.frontmatter.id;\n if (!id) continue;\n hashes.set(id, computeMemoryContentHash(memory.content, memory.frontmatter.category as string | undefined));\n }\n return hashes;\n}\n\nfunction pairMemoryContentHashes(\n memoryIdA: string,\n memoryIdB: string,\n currentMemoryHashes: Map<string, string>,\n): Record<string, string> | undefined {\n const hashA = currentMemoryHashes.get(memoryIdA);\n const hashB = currentMemoryHashes.get(memoryIdB);\n if (!hashA || !hashB) return undefined;\n return {\n [memoryIdA]: hashA,\n [memoryIdB]: hashB,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAaA,SAAS,kBAAkB;AAuD3B,IAAM,6BAA6B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAuBnC,IAAI,sBAA6D,oBAAI,IAAI;AACzE,IAAM,YAAY;AAElB,SAAS,QAAQ,KAAa,KAAqB;AACjD,QAAM,SAAS,CAAC,KAAK,GAAG,EAAE,KAAK;AAC/B,SAAO,GAAG,OAAO,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC;AAClC;AAEA,SAAS,YAAY,GAAoC;AAEvD,QAAM,QAAQ;AAAA,IACZ,EAAE,MAAM,EAAE,MAAM,KAAK,GAAG,WAAW,EAAE,aAAa,IAAI,KAAK,EAAE;AAAA,IAC7D,EAAE,MAAM,EAAE,MAAM,KAAK,GAAG,WAAW,EAAE,aAAa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ClD,MAAI,eAAe;AACnB,aAAW,QAAQ,MAAM;AACvB,QAAI,KAAK,IAAI,IAAI,EAAG;AAAA,EACtB;AACA,QAAM,QAAQ,KAAK,OAAO,KAAK,OAAO;AACtC,SAAO,UAAU,IAAI,IAAI,eAAe;AAC1C;AAEA,SAAS,eAAe,GAAe,GAAwB;AAC7D,QAAM,UAAU,EAAE,YAAY,WAAW,KAAK;AAC9C,QAAM,UAAU,EAAE,YAAY,WAAW,KAAK;AAC9C,SAAO,QAAQ,WAAW,WAAW,YAAY,OAAO;AAC1D;AAEA,SAAS,gBAAgB,GAAe,GAAuB;AAC7D,UAAQ,EAAE,YAAY,MAAM,IAAI,cAAc,EAAE,YAAY,MAAM,EAAE;AACtE;AAEA,SAAS,qBAAqB,UAA6C;AACzE,QAAM,SAAS,oBAAI,IAAoB;AACvC,aAAW,UAAU,UAAU;AAC7B,UAAM,KAAK,OAAO,YAAY;AAC9B,QAAI,CAAC,GAAI;AACT,WAAO,IAAI,IAAI,yBAAyB,OAAO,SAAS,OAAO,YAAY,QAA8B,CAAC;AAAA,EAC5G;AACA,SAAO;AACT;AAEA,SAAS,wBACP,WACA,WACA,qBACoC;AACpC,QAAM,QAAQ,oBAAoB,IAAI,SAAS;AAC/C,QAAM,QAAQ,oBAAoB,IAAI,SAAS;AAC/C,MAAI,CAAC,SAAS,CAAC,MAAO,QAAO;AAC7B,SAAO;AAAA,IACL,CAAC,SAAS,GAAG;AAAA,IACb,CAAC,SAAS,GAAG;AAAA,EACf;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/contradiction/contradiction-judge.ts","../src/contradiction/contradiction-scan.ts"],"sourcesContent":["/**\n * Contradiction Judge — LLM-as-judge for semantic contradiction detection (issue #520).\n *\n * Pairs semantically-similar memories and classifies their relationship.\n * Reuses the extraction-judge adapter pattern but with a contradiction-specific\n * prompt and verdict taxonomy.\n *\n * Design constraints:\n * - Default verdict on any failure is \"needs-user\" (rule 48: least-privileged default).\n * - Never auto-resolve; all verdicts enter the review queue.\n * - Content-hash caching avoids redundant LLM calls across runs.\n */\n\nimport { createHash } from \"node:crypto\";\nimport { log } from \"../logger.js\";\nimport type { PluginConfig } from \"../types.js\";\nimport type { LocalLlmClient } from \"../local-llm.js\";\nimport type { FallbackLlmClient } from \"../fallback-llm.js\";\nimport { extractJsonCandidates } from \"../json-extract.js\";\n\n// ── Types ──────────────────────────────────────────────────────────────────────\n\nexport type ContradictionVerdict =\n | \"contradicts\"\n | \"independent\"\n | \"duplicates\"\n | \"needs-user\";\n\nexport interface ContradictionJudgeInput {\n /** Memory ID of the first fact. */\n memoryIdA: string;\n /** Memory ID of the second fact. */\n memoryIdB: string;\n /** Content text of the first fact. */\n textA: string;\n /** Content text of the second fact. */\n textB: string;\n /** Category of the first fact (optional context). */\n categoryA?: string;\n /** Category of the second fact (optional context). */\n categoryB?: string;\n}\n\nexport interface ContradictionJudgeResult {\n /** Memory IDs of the pair. */\n memoryIdA: string;\n memoryIdB: string;\n /** Verdict from the judge. */\n verdict: ContradictionVerdict;\n /** Human-readable rationale. */\n rationale: string;\n /** Confidence in [0, 1]. */\n confidence: number;\n}\n\nexport interface ContradictionJudgeBatchResult {\n /** Results keyed by pair key (\"idA:idB\"). */\n results: Map<string, ContradictionJudgeResult>;\n /** Number served from cache. */\n cached: number;\n /** Number produced by LLM call. */\n judged: number;\n /** Total wall-clock time in ms. */\n elapsed: number;\n}\n\n// ── Prompt ─────────────────────────────────────────────────────────────────────\n\nconst CONTRADICTION_JUDGE_PROMPT = `You are a memory contradiction classifier. You will receive pairs of stored memories and must classify their semantic relationship.\n\nFor each pair, respond with a JSON array where each element has:\n- \"pairKey\": the pairKey provided in the input\n- \"verdict\": one of \"contradicts\", \"independent\", \"duplicates\", \"needs-user\"\n- \"rationale\": one sentence explaining why\n- \"confidence\": number between 0 and 1\n\nVERDICT DEFINITIONS:\n- \"contradicts\": The two memories make claims that cannot both be true. One must be wrong or outdated.\n- \"duplicates\": The two memories convey essentially the same information (near-paraphrase).\n- \"independent\": The memories are topically similar but do not conflict or duplicate.\n- \"needs-user\": Cannot determine with sufficient confidence; requires human review.\n\nIMPORTANT:\n- Be conservative. When in doubt, prefer \"needs-user\" over a wrong classification.\n- Two memories about the same entity/topic are NOT necessarily contradictory.\n- Temporal changes (\"Joshua uses pnpm\" vs \"Joshua switched to npm\") ARE contradictions.\n- Different aspects of the same entity (\"Joshua uses pnpm\" vs \"Joshua works on Remnic\") are \"independent\".`;\n\n// ── Cache ──────────────────────────────────────────────────────────────────────\n\n/** Module-level fallback cache — only used when caller does not supply one. */\nlet defaultVerdictCache: Map<string, ContradictionJudgeResult> = new Map();\nconst CACHE_MAX = 10_000;\n\nfunction pairKey(idA: string, idB: string): string {\n const sorted = [idA, idB].sort();\n return `${sorted[0]}:${sorted[1]}`;\n}\n\nfunction contentHash(a: ContradictionJudgeInput): string {\n // Sort each side pair to be order-independent (matching pairKey behavior)\n const sides = [\n { text: a.textA.trim(), category: (a.categoryA ?? \"\").trim() },\n { text: a.textB.trim(), category: (a.categoryB ?? \"\").trim() },\n ].sort((left, right) => {\n const leftKey = JSON.stringify(left);\n const rightKey = JSON.stringify(right);\n return leftKey.localeCompare(rightKey);\n });\n const normalized = JSON.stringify(sides);\n return createHash(\"sha256\").update(normalized).digest(\"hex\").slice(0, 16);\n}\n\nexport function createVerdictCache(): Map<string, ContradictionJudgeResult> {\n return new Map();\n}\n\nexport function clearVerdictCache(): void {\n defaultVerdictCache.clear();\n}\n\nexport function verdictCacheSize(): number {\n return defaultVerdictCache.size;\n}\n\n// ── Public API ──────────────────────────────────────────────────────────────────\n\n/**\n * Judge a batch of memory pairs for contradiction.\n *\n * Uses content-hash caching to skip pairs already judged in a prior run.\n * On any LLM failure, all unresolved pairs default to \"needs-user\".\n */\nexport async function judgeContradictionPairs(\n pairs: ContradictionJudgeInput[],\n config: PluginConfig,\n localLlm: LocalLlmClient | null,\n fallbackLlm: FallbackLlmClient | null,\n cache?: Map<string, ContradictionJudgeResult>,\n): Promise<ContradictionJudgeBatchResult> {\n const startTime = Date.now();\n const results = new Map<string, ContradictionJudgeResult>();\n const activeCache = cache ?? defaultVerdictCache;\n let cached = 0;\n let judged = 0;\n\n // Partition into cached vs needs-judging\n const toJudge: ContradictionJudgeInput[] = [];\n for (const pair of pairs) {\n const key = pairKey(pair.memoryIdA, pair.memoryIdB);\n const hash = contentHash(pair);\n const cachedResult = activeCache.get(hash);\n if (cachedResult) {\n results.set(key, { ...cachedResult, memoryIdA: pair.memoryIdA, memoryIdB: pair.memoryIdB });\n cached++;\n } else {\n toJudge.push(pair);\n }\n }\n\n if (toJudge.length === 0) {\n return { results, cached, judged, elapsed: Date.now() - startTime };\n }\n\n // Build the prompt with all pairs\n const pairDescriptions = toJudge.map((p, i) => {\n const pk = pairKey(p.memoryIdA, p.memoryIdB);\n const catA = p.categoryA ? ` [${p.categoryA}]` : \"\";\n const catB = p.categoryB ? ` [${p.categoryB}]` : \"\";\n return `Pair ${i + 1} (pairKey: \"${pk}\"):${catA} \"${p.textA}\"${catB} \"${p.textB}\"`;\n });\n\n const userMessage = `Classify these ${toJudge.length} memory pair(s):\\n\\n${pairDescriptions.join(\"\\n\\n\")}`;\n\n // Try LLM call\n let llmResponse: string | null = null;\n\n if (localLlm) {\n try {\n llmResponse = await callLlm(localLlm, config, userMessage);\n } catch (err) {\n log.warn(\"[contradiction-judge] local LLM call failed: %s\", err instanceof Error ? err.message : err);\n }\n }\n\n if (!llmResponse && fallbackLlm) {\n try {\n llmResponse = await callLlm(fallbackLlm, config, userMessage);\n } catch (err) {\n log.warn(\"[contradiction-judge] fallback LLM call failed: %s\", err instanceof Error ? err.message : err);\n }\n }\n\n // Parse response or default to needs-user\n if (llmResponse) {\n const candidates = extractJsonCandidates(llmResponse);\n const parsed = parseJudgeResponse(candidates, toJudge);\n\n for (const result of parsed) {\n const key = pairKey(result.memoryIdA, result.memoryIdB);\n results.set(key, result);\n\n // Update cache\n const input = toJudge.find(\n (p) => pairKey(p.memoryIdA, p.memoryIdB) === key,\n );\n if (input) {\n const hash = contentHash(input);\n if (activeCache.size >= CACHE_MAX) {\n const firstKey = activeCache.keys().next().value;\n if (firstKey !== undefined) activeCache.delete(firstKey);\n }\n activeCache.set(hash, result);\n }\n judged++;\n }\n } else {\n // All unresolved → needs-user (rule 48)\n for (const pair of toJudge) {\n const key = pairKey(pair.memoryIdA, pair.memoryIdB);\n const result: ContradictionJudgeResult = {\n memoryIdA: pair.memoryIdA,\n memoryIdB: pair.memoryIdB,\n verdict: \"needs-user\",\n rationale: \"LLM call failed; requires manual review\",\n confidence: 0,\n };\n results.set(key, result);\n judged++;\n }\n }\n\n return { results, cached, judged, elapsed: Date.now() - startTime };\n}\n\n// ── Internals ──────────────────────────────────────────────────────────────────\n\nasync function callLlm(\n client: LocalLlmClient | FallbackLlmClient,\n config: PluginConfig,\n userMessage: string,\n): Promise<string> {\n const messages: Array<{ role: \"user\" | \"assistant\" | \"system\"; content: string }> = [\n { role: \"system\", content: CONTRADICTION_JUDGE_PROMPT },\n { role: \"user\", content: userMessage },\n ];\n if (\"chatCompletion\" in client && typeof client.chatCompletion === \"function\") {\n const result = await client.chatCompletion(messages, {\n temperature: 0.1,\n maxTokens: 4096,\n operation: \"contradiction-judge\",\n });\n return result?.content ?? \"\";\n }\n // FallbackLlmClient — try OpenAI-compatible chat completions\n if (\"complete\" in client && typeof (client as Record<string, unknown>).complete === \"function\") {\n const result = await (client as { complete: (msg: Array<{ role: string; content: string }>) => Promise<{ content: string }> }).complete(messages);\n return result.content ?? \"\";\n }\n return \"\";\n}\n\nfunction parseJudgeResponse(\n candidates: string[],\n inputs: ContradictionJudgeInput[],\n): ContradictionJudgeResult[] {\n const VALID_VERDICTS: ContradictionVerdict[] = [\"contradicts\", \"independent\", \"duplicates\", \"needs-user\"];\n let conservativeFallback: ContradictionJudgeResult[] | null = null;\n\n for (const candidate of candidates) {\n try {\n const parsed = JSON.parse(candidate);\n const items = Array.isArray(parsed) ? parsed : [parsed];\n const results: ContradictionJudgeResult[] = [];\n const matchedKeys = new Set<string>();\n\n for (const item of items) {\n if (!item || typeof item !== \"object\") continue;\n\n const verdict = typeof item.verdict === \"string\" && VALID_VERDICTS.includes(item.verdict as ContradictionVerdict)\n ? (item.verdict as ContradictionVerdict)\n : \"needs-user\";\n\n const pairKeyVal = typeof item.pairKey === \"string\" && item.pairKey.length > 0\n ? item.pairKey\n : null;\n const input = pairKeyVal\n ? inputs.find((p) => pairKey(p.memoryIdA, p.memoryIdB) === pairKeyVal)\n : null;\n\n if (!input) continue;\n\n matchedKeys.add(pairKey(input.memoryIdA, input.memoryIdB));\n\n const confidence = typeof item.confidence === \"number\"\n ? Math.min(1, Math.max(0, item.confidence))\n : 0.5;\n\n results.push({\n memoryIdA: input.memoryIdA,\n memoryIdB: input.memoryIdB,\n verdict,\n rationale: typeof item.rationale === \"string\" ? item.rationale : \"No rationale provided\",\n confidence,\n });\n }\n\n // Backfill any inputs the LLM omitted with needs-user\n for (const inp of inputs) {\n const key = pairKey(inp.memoryIdA, inp.memoryIdB);\n if (!matchedKeys.has(key)) {\n results.push({\n memoryIdA: inp.memoryIdA,\n memoryIdB: inp.memoryIdB,\n verdict: \"needs-user\",\n rationale: \"LLM response omitted this pair\",\n confidence: 0,\n });\n }\n }\n\n if (matchedKeys.size > 0) return results;\n if (results.length > 0 && conservativeFallback === null) {\n conservativeFallback = results;\n }\n } catch {\n continue;\n }\n }\n\n if (conservativeFallback !== null) return conservativeFallback;\n\n // All parse attempts failed → needs-user for every input\n return inputs.map((p) => ({\n memoryIdA: p.memoryIdA,\n memoryIdB: p.memoryIdB,\n verdict: \"needs-user\" as ContradictionVerdict,\n rationale: \"Failed to parse judge response\",\n confidence: 0,\n }));\n}\n\nexport { pairKey as _pairKey, contentHash as _contentHash };\n","/**\n * Contradiction Scan — pair generator + scan driver (issue #520).\n *\n * Nightly cron that pairs semantically-similar active memories within\n * the same namespace, sends candidate pairs to the LLM-as-judge\n * contradiction classifier, and drops contradicting pairs into a\n * review queue for user resolution.\n *\n * Pair generation (cheap pre-filter):\n * 1. Find candidate peers via embedding cosine >= similarityFloor.\n * 2. Restrict to pairs sharing at least one entityRef OR overlapping\n * topic tokens >= topicOverlapFloor.\n * 3. Skip pairs already judged independent/both-valid within cooldown.\n * 4. Cap per-run work at maxPairsPerRun.\n */\n\nimport { resolveNamespaceCapabilities } from \"../capabilities.js\";\nimport type { StorageManager } from \"../storage.js\";\nimport type { PluginConfig, MemoryFile, MemoryStatus } from \"../types.js\";\nimport type { SemanticDedupLookup } from \"../dedup/semantic.js\";\nimport { log } from \"../logger.js\";\nimport { judgeContradictionPairs, type ContradictionJudgeInput } from \"./contradiction-judge.js\";\nimport {\n writePairs,\n readPair,\n isCoolingDown,\n memoryHashesChanged,\n computeMemoryContentHash,\n computePairId,\n migrateUnscopedPairsToNamespace,\n type ContradictionPair,\n} from \"./contradiction-review.js\";\nimport type { LocalLlmClient } from \"../local-llm.js\";\nimport type { FallbackLlmClient } from \"../fallback-llm.js\";\nimport { isSupportPassportPrivateMemory } from \"../support-passport/card-projection.js\";\n\n// ── Types ──────────────────────────────────────────────────────────────────────\n\n/** The set of statuses that represent \"live\" memories eligible for scanning. */\nexport const ACTIVE_STATUSES: Set<MemoryStatus> = new Set([\"active\"]);\n\n/** High-value taxonomy buckets to scan. */\nconst SCAN_CATEGORIES = new Set([\n \"decision\",\n \"principle\",\n \"rule\",\n \"entity\",\n \"fact\",\n \"preference\",\n]);\n\nexport interface ScanResult {\n /** Total active memories scanned. */\n scanned: number;\n /** Candidate pairs generated by the pre-filter. */\n candidates: number;\n /** Pairs sent to judge. */\n judged: number;\n /** Pairs written to review queue. */\n queued: number;\n /** Pairs skipped due to cooldown. */\n cooledDown: number;\n /** Total wall-clock time in ms. */\n elapsedMs: number;\n}\n\nexport interface ScanStorageResolution {\n storage: StorageManager;\n namespace?: string;\n}\n\nexport interface ScanDependencies {\n storage: StorageManager;\n config: PluginConfig;\n memoryDir: string;\n /** Pre-built embedding lookup. When provided, used as-is for Strategy 3. */\n embeddingLookup?: SemanticDedupLookup;\n /**\n * Factory to build a namespace-scoped embedding lookup.\n * When provided, takes precedence over `embeddingLookup`.\n * The scan driver passes its own `storage` so the lookup queries the correct index.\n */\n embeddingLookupFactory?: (storage: StorageManager) => SemanticDedupLookup | undefined;\n /** Resolver for namespace-scoped storage. Required for scans when namespaces are enabled. */\n storageForNamespace?: (\n namespace: string | undefined,\n ) => StorageManager | ScanStorageResolution | Promise<StorageManager | ScanStorageResolution>;\n localLlm: LocalLlmClient | null;\n fallbackLlm: FallbackLlmClient | null;\n namespace?: string;\n}\n\n// ── Main scan driver ───────────────────────────────────────────────────────────\n\n/**\n * Run a contradiction scan over the memory corpus.\n *\n * This is the entry point called by the nightly cron and by the CLI.\n */\nexport async function runContradictionScan(deps: ScanDependencies): Promise<ScanResult> {\n const startTime = Date.now();\n const { config, memoryDir, embeddingLookup, embeddingLookupFactory, localLlm, fallbackLlm } = deps;\n const requestedNamespace = normalizeScanNamespace(deps.namespace);\n const scanConfig = config.contradictionScan;\n\n if (!scanConfig.enabled) {\n log.info(\"[contradiction-scan] disabled by config\");\n return { scanned: 0, candidates: 0, judged: 0, queued: 0, cooledDown: 0, elapsedMs: 0 };\n }\n\n const { storage: scanStorage, namespace } = await resolveScanStorage(deps, requestedNamespace);\n if (resolveNamespaceCapabilities(config).namespaces && namespace !== undefined && isDefaultNamespaceScan(config, requestedNamespace, namespace)) {\n const migrated = migrateUnscopedPairsToNamespace(memoryDir, namespace, { cooldownDays: scanConfig.cooldownDays });\n if (migrated > 0) {\n log.info(\"[contradiction-scan] migrated %d legacy unscoped review pairs to namespace %s\", migrated, namespace);\n }\n }\n\n // Prefer the factory (which uses the scan's own storage for correct namespace scoping)\n // over a pre-built lookup (which may use default-namespace storage).\n const scopedEmbeddingLookup = embeddingLookupFactory\n ? embeddingLookupFactory(scanStorage)\n : embeddingLookup;\n\n // 1. Load active memories in scan categories\n const memories = await loadEligibleMemories(scanStorage);\n log.info(\"[contradiction-scan] loaded %d eligible memories\", memories.length);\n\n if (memories.length < 2) {\n return { scanned: memories.length, candidates: 0, judged: 0, queued: 0, cooledDown: 0, elapsedMs: Date.now() - startTime };\n }\n\n // 2. Prepare exact existing-pair lookup for cooldown checking.\n // Pair IDs are deterministic, so lookup the candidate's file directly instead\n // of paging through the review queue and risking a bounded-list miss.\n const existingPairCache = new Map<string, ContradictionPair | undefined>();\n const getExistingPair = (pairId: string): ContradictionPair | undefined => {\n if (!existingPairCache.has(pairId)) {\n existingPairCache.set(pairId, readPair(memoryDir, pairId) ?? undefined);\n }\n return existingPairCache.get(pairId);\n };\n\n // 3. Generate candidate pairs\n const candidates = await generatePairs(memories, getExistingPair, scanConfig, namespace, scopedEmbeddingLookup);\n const cooledDown = candidates.skipped;\n log.info(\"[contradiction-scan] generated %d candidates (%d cooled down)\", candidates.pairs.length, cooledDown);\n\n if (candidates.pairs.length === 0) {\n return {\n scanned: memories.length,\n candidates: 0,\n judged: 0,\n queued: 0,\n cooledDown,\n elapsedMs: Date.now() - startTime,\n };\n }\n\n // 4. Build judge inputs. Candidate generation already preserves strategy\n // priority and caps work at maxPairsPerRun.\n const judgeInputs: ContradictionJudgeInput[] = candidates.pairs.map((pair) => ({\n memoryIdA: pair.idA,\n memoryIdB: pair.idB,\n textA: pair.textA,\n textB: pair.textB,\n categoryA: pair.categoryA,\n categoryB: pair.categoryB,\n }));\n\n // 6. Send to judge (per-scan cache avoids module-level singleton leak)\n const scanCache = new Map<string, import(\"./contradiction-judge.js\").ContradictionJudgeResult>();\n const judgeResult = await judgeContradictionPairs(judgeInputs, config, localLlm, fallbackLlm, scanCache);\n log.info(\"[contradiction-scan] judge completed: %d judged, %d cached in %dms\", judgeResult.judged, judgeResult.cached, judgeResult.elapsed);\n\n // 7. Write to review queue\n const queueEntries: Array<Omit<ContradictionPair, \"pairId\"> & { memoryIds: [string, string] }> = [];\n const currentMemoryHashes = memoryContentHashMap(memories);\n for (const [key, result] of judgeResult.results) {\n queueEntries.push({\n memoryIds: [result.memoryIdA, result.memoryIdB],\n verdict: result.verdict,\n rationale: result.rationale,\n confidence: result.confidence,\n detectedAt: new Date().toISOString(),\n // Set lastReviewedAt for non-actionable verdicts so cooldown prevents re-judging\n lastReviewedAt: result.verdict === \"independent\" ? new Date().toISOString() : undefined,\n memoryContentHashes: pairMemoryContentHashes(result.memoryIdA, result.memoryIdB, currentMemoryHashes),\n namespace,\n });\n }\n\n const written = writePairs(memoryDir, queueEntries, { cooldownDays: scanConfig.cooldownDays });\n const elapsed = Date.now() - startTime;\n log.info(\"[contradiction-scan] complete: %d queued in %dms\", written.length, elapsed);\n\n return {\n scanned: memories.length,\n candidates: candidates.pairs.length,\n judged: judgeResult.judged,\n queued: written.length,\n cooledDown,\n elapsedMs: elapsed,\n };\n}\n\n// ── Pair generation ────────────────────────────────────────────────────────────\n\ninterface CandidatePair {\n idA: string;\n idB: string;\n textA: string;\n textB: string;\n categoryA?: string;\n categoryB?: string;\n}\n\ninterface PairGenResult {\n pairs: CandidatePair[];\n skipped: number;\n}\n\nasync function generatePairs(\n memories: MemoryFile[],\n getExistingPair: (pairId: string) => ContradictionPair | undefined,\n scanConfig: PluginConfig[\"contradictionScan\"],\n namespace: string | undefined,\n embeddingLookup?: SemanticDedupLookup,\n): Promise<PairGenResult> {\n const pairs: CandidatePair[] = [];\n let skipped = 0;\n const seen = new Set<string>();\n const maxPairs = Math.max(0, Math.floor(scanConfig.maxPairsPerRun));\n if (maxPairs === 0) return { pairs, skipped };\n\n const orderedMemories = [...memories].sort(compareMemoryId);\n const currentMemoryHashes = memoryContentHashMap(orderedMemories);\n\n const pushCandidate = (pair: CandidatePair): void => {\n if (pairs.length < maxPairs) pairs.push(pair);\n };\n\n const hasCapacity = (): boolean => pairs.length < maxPairs;\n const isSkippedByCooldown = (existing: ContradictionPair | undefined): boolean => {\n if (!existing || !isCoolingDown(existing, scanConfig.cooldownDays)) return false;\n return !memoryHashesChanged(\"\", existing, (memoryId) => currentMemoryHashes.get(memoryId) ?? null);\n };\n\n // Build index by entityRef for fast lookup\n const byEntity = new Map<string, MemoryFile[]>();\n for (const mem of orderedMemories) {\n const entity = mem.frontmatter.entityRef;\n if (entity) {\n const existing = byEntity.get(entity) ?? [];\n existing.push(mem);\n byEntity.set(entity, existing);\n }\n }\n\n // Strategy 1: Entity-ref based pairing (high precision)\n entityPairs:\n for (const entity of [...byEntity.keys()].sort()) {\n const group = byEntity.get(entity) ?? [];\n if (group.length < 2) continue;\n for (let i = 0; i < group.length; i++) {\n for (let j = i + 1; j < group.length; j++) {\n if (!hasCapacity()) break entityPairs;\n const a = group[i];\n const b = group[j];\n const pairId = computePairId(a.frontmatter.id!, b.frontmatter.id!, namespace);\n\n if (seen.has(pairId)) continue;\n seen.add(pairId);\n\n // Check cooldown\n const existing = getExistingPair(pairId);\n if (isSkippedByCooldown(existing)) {\n skipped++;\n continue;\n }\n\n pushCandidate({\n idA: a.frontmatter.id!,\n idB: b.frontmatter.id!,\n textA: a.content,\n textB: b.content,\n categoryA: a.frontmatter.category as string | undefined,\n categoryB: b.frontmatter.category as string | undefined,\n });\n }\n }\n }\n\n // Strategy 2: Tag/topic overlap for memories without a shared entityRef\n topicPairs:\n for (let i = 0; i < orderedMemories.length; i++) {\n for (let j = i + 1; j < orderedMemories.length; j++) {\n if (!hasCapacity()) break topicPairs;\n const a = orderedMemories[i];\n const b = orderedMemories[j];\n if (shareEntityRef(a, b)) continue;\n const overlap = jaccardOverlap(\n (a.frontmatter.tags as string[]) ?? [],\n (b.frontmatter.tags as string[]) ?? [],\n );\n\n if (overlap < scanConfig.topicOverlapFloor) continue;\n\n const pairId = computePairId(a.frontmatter.id!, b.frontmatter.id!, namespace);\n if (seen.has(pairId)) continue;\n seen.add(pairId);\n\n const existing = getExistingPair(pairId);\n if (isSkippedByCooldown(existing)) {\n skipped++;\n continue;\n }\n\n pushCandidate({\n idA: a.frontmatter.id!,\n idB: b.frontmatter.id!,\n textA: a.content,\n textB: b.content,\n categoryA: a.frontmatter.category as string | undefined,\n categoryB: b.frontmatter.category as string | undefined,\n });\n }\n }\n\n // Strategy 3: Embedding cosine similarity (enforces similarityFloor config)\n if (embeddingLookup && hasCapacity()) {\n const memoryById = new Map(orderedMemories.map((m) => [m.frontmatter.id!, m]));\n embeddingPairs:\n for (const mem of orderedMemories) {\n if (!hasCapacity()) break;\n const id = mem.frontmatter.id!;\n try {\n const hits = (await embeddingLookup(mem.content, 20)).sort((a, b) =>\n b.score - a.score || a.id.localeCompare(b.id),\n );\n for (const hit of hits) {\n if (!hasCapacity()) break embeddingPairs;\n if (hit.score < scanConfig.similarityFloor) continue;\n if (hit.id === id) continue;\n const peer = memoryById.get(hit.id);\n if (!peer) continue;\n\n const pairId = computePairId(id, hit.id, namespace);\n if (seen.has(pairId)) continue;\n seen.add(pairId);\n\n const existing = getExistingPair(pairId);\n if (isSkippedByCooldown(existing)) {\n skipped++;\n continue;\n }\n\n pushCandidate({\n idA: id,\n idB: hit.id,\n textA: mem.content,\n textB: peer.content,\n categoryA: mem.frontmatter.category as string | undefined,\n categoryB: peer.frontmatter.category as string | undefined,\n });\n }\n } catch {\n // Embedding backend unavailable — skip, entity-ref/tag strategies already covered\n }\n }\n }\n\n return { pairs, skipped };\n}\n\n// ── Helpers ────────────────────────────────────────────────────────────────────\n\nfunction normalizeScanNamespace(namespace: string | undefined): string | undefined {\n const trimmed = namespace?.trim();\n return trimmed ? trimmed : undefined;\n}\n\n/**\n * Resolve the namespace-scoped storage a scan must read and write through.\n *\n * Exported and narrowed to the fields it actually reads so sibling scans\n * (preference drift, issue #2371) share ONE namespace resolver rather than\n * re-deriving the read/write namespace independently — the divergence the\n * namespace/ACL scenario matrix in AGENTS.md exists to prevent.\n */\nexport async function resolveScanStorage(\n deps: Pick<ScanDependencies, \"config\" | \"storage\" | \"storageForNamespace\">,\n namespace: string | undefined,\n): Promise<ScanStorageResolution> {\n if (!resolveNamespaceCapabilities(deps.config).namespaces) {\n const defaultNamespace = normalizeScanNamespace(deps.config.defaultNamespace);\n if (namespace && namespace !== defaultNamespace) {\n throw new Error(`unsupported namespace: ${namespace}`);\n }\n return { storage: deps.storage, namespace: undefined };\n }\n\n if (deps.storageForNamespace) {\n const resolved = await deps.storageForNamespace(namespace);\n if (isScanStorageResolution(resolved)) {\n return {\n storage: resolved.storage,\n namespace: normalizeScanNamespace(resolved.namespace) ?? fallbackResolvedNamespace(deps, namespace),\n };\n }\n if (!isStorageManagerLike(resolved)) {\n throw new Error(\"storageForNamespace must return a StorageManager or { storage: StorageManager, namespace?: string }\");\n }\n return {\n storage: resolved,\n namespace: fallbackResolvedNamespace(deps, namespace),\n };\n }\n\n throw new Error(\n \"contradiction scans require storageForNamespace when namespaces are enabled so callers can enforce namespace access\",\n );\n}\n\nfunction isScanStorageResolution(value: StorageManager | ScanStorageResolution): value is ScanStorageResolution {\n if (isStorageManagerLike(value)) return false;\n if (typeof value !== \"object\" || value === null) return false;\n const candidate = value as { storage?: unknown };\n return isStorageManagerLike(candidate.storage);\n}\n\nfunction isStorageManagerLike(value: unknown): value is StorageManager {\n if (typeof value !== \"object\" || value === null) return false;\n const candidate = value as { readAllMemories?: unknown };\n return typeof candidate.readAllMemories === \"function\";\n}\n\nfunction fallbackResolvedNamespace(\n deps: Pick<ScanDependencies, \"config\">,\n namespace: string | undefined,\n): string | undefined {\n if (namespace) return namespace;\n return resolveNamespaceCapabilities(deps.config).namespaces ? deps.config.defaultNamespace : undefined;\n}\n\nfunction isDefaultNamespaceScan(\n config: PluginConfig,\n requestedNamespace: string | undefined,\n resolvedNamespace: string,\n): boolean {\n if (requestedNamespace === undefined) return true;\n return requestedNamespace === config.defaultNamespace || resolvedNamespace === config.defaultNamespace;\n}\n\nasync function loadEligibleMemories(storage: StorageManager): Promise<MemoryFile[]> {\n let all: MemoryFile[];\n try {\n all = await storage.readAllMemories();\n } catch {\n return [];\n }\n\n return all.filter((mem) => {\n const fm = mem.frontmatter;\n if (isSupportPassportPrivateMemory(mem)) return false;\n // Only active memories (rule 53: explicit ACTIVE_STATUSES set)\n const status = (fm.status as MemoryStatus) ?? \"active\";\n if (!ACTIVE_STATUSES.has(status)) return false;\n\n // Only scan high-value categories\n const category = fm.category as string | undefined;\n if (category && !SCAN_CATEGORIES.has(category)) return false;\n\n // Must have content\n if (!mem.content || mem.content.trim().length === 0) return false;\n\n // Must have an ID\n if (!fm.id) return false;\n\n return true;\n });\n}\n\nfunction jaccardOverlap(a: string[], b: string[]): number {\n if (a.length === 0 && b.length === 0) return 0;\n const setA = new Set(a.map((t) => t.toLowerCase()));\n const setB = new Set(b.map((t) => t.toLowerCase()));\n let intersection = 0;\n for (const item of setA) {\n if (setB.has(item)) intersection++;\n }\n const union = setA.size + setB.size - intersection;\n return union === 0 ? 0 : intersection / union;\n}\n\nfunction shareEntityRef(a: MemoryFile, b: MemoryFile): boolean {\n const entityA = a.frontmatter.entityRef?.trim();\n const entityB = b.frontmatter.entityRef?.trim();\n return Boolean(entityA && entityB && entityA === entityB);\n}\n\nfunction compareMemoryId(a: MemoryFile, b: MemoryFile): number {\n return (a.frontmatter.id ?? \"\").localeCompare(b.frontmatter.id ?? \"\");\n}\n\nfunction memoryContentHashMap(memories: MemoryFile[]): Map<string, string> {\n const hashes = new Map<string, string>();\n for (const memory of memories) {\n const id = memory.frontmatter.id;\n if (!id) continue;\n hashes.set(id, computeMemoryContentHash(memory.content, memory.frontmatter.category as string | undefined));\n }\n return hashes;\n}\n\nfunction pairMemoryContentHashes(\n memoryIdA: string,\n memoryIdB: string,\n currentMemoryHashes: Map<string, string>,\n): Record<string, string> | undefined {\n const hashA = currentMemoryHashes.get(memoryIdA);\n const hashB = currentMemoryHashes.get(memoryIdB);\n if (!hashA || !hashB) return undefined;\n return {\n [memoryIdA]: hashA,\n [memoryIdB]: hashB,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAaA,SAAS,kBAAkB;AAuD3B,IAAM,6BAA6B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;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QAAQ,oBAAoB,IAAI,SAAS;AAC/C,MAAI,CAAC,SAAS,CAAC,MAAO,QAAO;AAC7B,SAAO;AAAA,IACL,CAAC,SAAS,GAAG;AAAA,IACb,CAAC,SAAS,GAAG;AAAA,EACf;AACF;","names":[]}
|
|
@@ -7,10 +7,10 @@ import {
|
|
|
7
7
|
import {
|
|
8
8
|
listMemoryGovernanceRuns,
|
|
9
9
|
readMemoryGovernanceRunArtifact
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-EIVIB73I.js";
|
|
11
11
|
import {
|
|
12
12
|
StorageManager
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-PAYGC3BD.js";
|
|
14
14
|
import {
|
|
15
15
|
normalizeProjectionPreview,
|
|
16
16
|
normalizeProjectionTags
|
|
@@ -1005,4 +1005,4 @@ export {
|
|
|
1005
1005
|
verifyMemoryProjection,
|
|
1006
1006
|
repairMemoryProjection
|
|
1007
1007
|
};
|
|
1008
|
-
//# sourceMappingURL=chunk-
|
|
1008
|
+
//# sourceMappingURL=chunk-QFMO32TO.js.map
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from "./chunk-JCWY73FK.js";
|
|
8
8
|
import {
|
|
9
9
|
StorageManager
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-PAYGC3BD.js";
|
|
11
11
|
import {
|
|
12
12
|
parseContinuityImprovementLoops
|
|
13
13
|
} from "./chunk-LDXUBPMO.js";
|
|
@@ -1283,4 +1283,4 @@ export {
|
|
|
1283
1283
|
defaultTierMigrationCycleBudget,
|
|
1284
1284
|
CompoundingEngine
|
|
1285
1285
|
};
|
|
1286
|
-
//# sourceMappingURL=chunk-
|
|
1286
|
+
//# sourceMappingURL=chunk-R47WINCY.js.map
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
} from "./chunk-5JMAGU26.js";
|
|
6
6
|
import {
|
|
7
7
|
runPostConsolidationMaterialize
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-S7Q5CM7E.js";
|
|
9
9
|
import {
|
|
10
10
|
isSemanticConsolidationLlmOperator
|
|
11
11
|
} from "./chunk-G7D6GZ5J.js";
|
|
@@ -220,4 +220,4 @@ export {
|
|
|
220
220
|
buildExtensionsBlockForConsolidation,
|
|
221
221
|
materializeAfterSemanticConsolidation
|
|
222
222
|
};
|
|
223
|
-
//# sourceMappingURL=chunk-
|
|
223
|
+
//# sourceMappingURL=chunk-RK4WXUI2.js.map
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
} from "./chunk-RDFF2NAU.js";
|
|
5
5
|
import {
|
|
6
6
|
StorageManager
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-PAYGC3BD.js";
|
|
8
8
|
import {
|
|
9
9
|
excludeSupportPassportPrivateMemories
|
|
10
10
|
} from "./chunk-XDL5CYZN.js";
|
|
@@ -138,4 +138,4 @@ export {
|
|
|
138
138
|
runCodexMaterialize,
|
|
139
139
|
runPostConsolidationMaterialize
|
|
140
140
|
};
|
|
141
|
-
//# sourceMappingURL=chunk-
|
|
141
|
+
//# sourceMappingURL=chunk-S7Q5CM7E.js.map
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-KJTKLXTH.js";
|
|
4
4
|
import {
|
|
5
5
|
StorageManager
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-PAYGC3BD.js";
|
|
7
7
|
import {
|
|
8
8
|
copyExistingFileToBackup,
|
|
9
9
|
writeFileAtomically
|
|
@@ -260,4 +260,4 @@ export {
|
|
|
260
260
|
backupExistingLedger,
|
|
261
261
|
rebuildMemoryLifecycleLedger
|
|
262
262
|
};
|
|
263
|
-
//# sourceMappingURL=chunk-
|
|
263
|
+
//# sourceMappingURL=chunk-TDKSCV62.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
externalWikiSearchOperation
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-PDVQ5JU3.js";
|
|
4
4
|
import {
|
|
5
5
|
memoryStoreRequestSchema
|
|
6
6
|
} from "./chunk-W675UJCZ.js";
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
DELTA_SUBCOMMANDS,
|
|
11
11
|
defineOperation,
|
|
12
12
|
isCodegraphToolName
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-WN5FSGLE.js";
|
|
14
14
|
import {
|
|
15
15
|
serializeMutations,
|
|
16
16
|
withHeldFileLock
|
|
@@ -1818,4 +1818,4 @@ export {
|
|
|
1818
1818
|
codegraphIngestTracesOperation,
|
|
1819
1819
|
REGISTERED_OPERATIONS
|
|
1820
1820
|
};
|
|
1821
|
-
//# sourceMappingURL=chunk-
|
|
1821
|
+
//# sourceMappingURL=chunk-TYUS5TLG.js.map
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
} from "./chunk-NOB2T2FC.js";
|
|
12
12
|
import {
|
|
13
13
|
parseConfig
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-76PL4XLG.js";
|
|
15
15
|
import {
|
|
16
16
|
resolveObjectiveStateStoreDir,
|
|
17
17
|
validateObjectiveStateSnapshot
|
|
@@ -268,4 +268,4 @@ export {
|
|
|
268
268
|
recordResumeBundle,
|
|
269
269
|
getResumeBundleStatus
|
|
270
270
|
};
|
|
271
|
-
//# sourceMappingURL=chunk-
|
|
271
|
+
//# sourceMappingURL=chunk-URHCUXKI.js.map
|
|
@@ -17,18 +17,19 @@ import {
|
|
|
17
17
|
validateRequest
|
|
18
18
|
} from "./chunk-W675UJCZ.js";
|
|
19
19
|
import {
|
|
20
|
+
MCP_ADMIN_OPS_MIGRATED_OPERATIONS,
|
|
20
21
|
MCP_ADMIN_OPS_TOOLS,
|
|
21
22
|
MCP_GIT_CONTEXT_SCHEMA_PROPS_IGNORED
|
|
22
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-AB3A7EFH.js";
|
|
23
24
|
import {
|
|
24
25
|
applyToolOutputSchemas
|
|
25
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-FC7TIRFS.js";
|
|
26
27
|
import {
|
|
27
28
|
getOperation
|
|
28
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-WN5FSGLE.js";
|
|
29
30
|
import {
|
|
30
31
|
WHO_KNOWS_MCP_TOOLS
|
|
31
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-NZWEEALH.js";
|
|
32
33
|
import {
|
|
33
34
|
PROMOTION_CANDIDATES_MCP_TOOLS
|
|
34
35
|
} from "./chunk-RIAM7DND.js";
|
|
@@ -1676,6 +1677,7 @@ var MCP_MIGRATED_OPERATIONS = {
|
|
|
1676
1677
|
"engram.dreams_status": "dreams_status",
|
|
1677
1678
|
"engram.dreams_run": "dreams_run",
|
|
1678
1679
|
...SUPPORT_PASSPORT_MCP_MIGRATED_OPERATIONS,
|
|
1680
|
+
...MCP_ADMIN_OPS_MIGRATED_OPERATIONS,
|
|
1679
1681
|
"engram.memory_chat": "chat_message"
|
|
1680
1682
|
};
|
|
1681
1683
|
var STRICT_MCP_SCHEMA_KEYS = {
|
|
@@ -3962,4 +3964,4 @@ export {
|
|
|
3962
3964
|
MCP_MIGRATED_OPERATIONS,
|
|
3963
3965
|
EngramMcpServer
|
|
3964
3966
|
};
|
|
3965
|
-
//# sourceMappingURL=chunk-
|
|
3967
|
+
//# sourceMappingURL=chunk-VA5KMSAE.js.map
|