@remnic/core 9.50.2 → 9.51.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/dist/access-admin-ops-surface.d.ts +13 -11
- package/dist/access-admin-ops-surface.js +41 -39
- package/dist/access-authorization-probe.d.ts +13 -11
- package/dist/access-authorization-probe.js +42 -40
- package/dist/access-boundary.d.ts +13 -11
- package/dist/access-boundary.js +41 -39
- package/dist/access-cli.js +109 -104
- package/dist/access-cli.js.map +1 -1
- package/dist/access-coding-context-resolution.d.ts +3 -1
- package/dist/access-extraction-force-flush.d.ts +13 -11
- package/dist/access-extraction-force-flush.js +41 -39
- package/dist/access-health-types.d.ts +3 -1
- package/dist/access-http-lcm-compaction.d.ts +13 -11
- package/dist/access-http-lifecycle-flush.d.ts +13 -11
- package/dist/access-http-offline-stream.d.ts +13 -11
- package/dist/access-http-query.js +41 -39
- package/dist/access-http.d.ts +13 -11
- package/dist/access-http.js +52 -50
- package/dist/access-identity-continuity-surface.d.ts +11 -9
- package/dist/access-identity-continuity-surface.js +41 -39
- package/dist/access-lcm-surface.d.ts +13 -11
- package/dist/access-lcm-surface.js +41 -39
- package/dist/access-mcp.d.ts +13 -11
- package/dist/access-mcp.js +47 -45
- package/dist/access-memory-search-fanout.d.ts +4 -2
- package/dist/{access-namespace-preflight-Dj2QolFE.d.ts → access-namespace-preflight-Ds6CGlCP.d.ts} +1 -1
- package/dist/access-namespace-preflight.d.ts +5 -3
- package/dist/access-namespace-preflight.js +41 -39
- package/dist/access-observe-write-surface.d.ts +13 -11
- package/dist/access-observe-write-surface.js +41 -39
- package/dist/access-offline-manifest.d.ts +11 -9
- package/dist/access-operations-batch.js +43 -41
- package/dist/access-operations.d.ts +13 -11
- package/dist/access-operations.js +46 -44
- package/dist/access-recall-concurrency.d.ts +13 -11
- package/dist/access-recall-concurrency.js +41 -39
- package/dist/access-recall-response.d.ts +13 -11
- package/dist/access-recall-response.js +41 -39
- package/dist/access-recall-surface.d.ts +13 -11
- package/dist/access-recall-surface.js +41 -39
- package/dist/access-schema.js +3 -3
- package/dist/{access-service-DesbnTSa.d.ts → access-service-BY0KJ44c.d.ts} +7 -7
- package/dist/access-service-helpers.d.ts +13 -11
- package/dist/access-service.d.ts +13 -11
- package/dist/access-service.js +41 -39
- package/dist/access-surface-catalog.d.ts +13 -11
- 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 +5 -3
- package/dist/active-recall.js.map +1 -1
- package/dist/adapters/index.js +4 -4
- package/dist/adapters/registry.js +2 -2
- package/dist/ambient-provenance.d.ts +3 -1
- package/dist/archive-mutation-version.d.ts +9 -0
- package/dist/archive-mutation-version.js +20 -0
- 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 +11 -9
- package/dist/briefing.d.ts +4 -2
- package/dist/briefing.js +10 -9
- 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/buffer.js +5 -5
- 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-D-G7RgXR.d.ts → catalog-D3B4RDy1.d.ts} +1 -1
- package/dist/causal-behavior.d.ts +3 -1
- package/dist/causal-behavior.js +2 -2
- package/dist/causal-chain.js +2 -2
- package/dist/causal-consolidation.d.ts +3 -1
- package/dist/causal-consolidation.js +13 -12
- package/dist/causal-consolidation.js.map +1 -1
- package/dist/causal-retrieval.js +2 -2
- package/dist/causal-trajectory-graph.d.ts +4 -2
- package/dist/causal-trajectory-graph.js +2 -1
- package/dist/causal-trajectory-graph.js.map +1 -1
- package/dist/causal-trajectory.js +1 -1
- package/dist/{chunk-KDG2KTWW.js → chunk-33SV3E43.js} +4 -4
- package/dist/{chunk-2HGUDBRJ.js → chunk-37ZO6LLJ.js} +2 -2
- package/dist/{chunk-QW3WFHKU.js → chunk-45BRYON6.js} +2 -2
- package/dist/{chunk-GZICBRWK.js → chunk-4F6X3RXW.js} +2 -2
- package/dist/{chunk-7BAYBYY5.js → chunk-4PC4PRJE.js} +2 -2
- package/dist/{chunk-VJXY5ZCT.js → chunk-52UKFTUK.js} +2 -2
- package/dist/{chunk-ESG7Z255.js → chunk-5UDMFE3Q.js} +2 -2
- package/dist/{chunk-JPHEOE6Z.js → chunk-6MTSFX7A.js} +15 -15
- package/dist/chunk-6ZN34ISG.js +44 -0
- package/dist/chunk-6ZN34ISG.js.map +1 -0
- package/dist/{chunk-M4MP34AQ.js → chunk-AHZOMHWN.js} +1 -1
- package/dist/{chunk-Z3RHPGSY.js → chunk-AIUBBHSF.js} +3 -3
- package/dist/{chunk-S3AYIQCU.js → chunk-AXIDQG5A.js} +12 -12
- package/dist/{chunk-QN7NTKRC.js → chunk-AZ2QBGYB.js} +1 -1
- package/dist/{chunk-47J4EDGR.js → chunk-AZM4CCAC.js} +8 -8
- package/dist/{chunk-IXXABW5A.js → chunk-BHXYAVUM.js} +11 -5
- package/dist/chunk-BHXYAVUM.js.map +1 -0
- package/dist/{chunk-L2DPF4DF.js → chunk-BIJAWZYW.js} +54 -12
- package/dist/chunk-BIJAWZYW.js.map +1 -0
- package/dist/{chunk-LEJPSMKM.js → chunk-C5QLI33R.js} +3 -3
- package/dist/{chunk-SV3PSA7Y.js → chunk-CV6BBVYV.js} +5 -5
- package/dist/{chunk-V7X767RT.js → chunk-DCZBSE4F.js} +52 -52
- package/dist/chunk-FC67T4E6.js +70 -0
- package/dist/chunk-FC67T4E6.js.map +1 -0
- package/dist/{chunk-7PKFPLLZ.js → chunk-FXTYIA46.js} +2 -2
- package/dist/{chunk-64BHFFKZ.js → chunk-HLYR2TQL.js} +5 -5
- package/dist/{chunk-5C2HNJMO.js → chunk-J5LLX6IL.js} +32 -32
- package/dist/{chunk-RKNJBZ55.js → chunk-JBPKEARU.js} +4 -4
- package/dist/{chunk-PLKFO2HJ.js → chunk-JL43BVDE.js} +2 -2
- package/dist/{chunk-2S72LWKX.js → chunk-JYL3BVVZ.js} +2 -2
- package/dist/{chunk-IPLYGWQF.js → chunk-KQAFEZQX.js} +5 -5
- package/dist/chunk-LXY5VVGM.js +61 -0
- package/dist/chunk-LXY5VVGM.js.map +1 -0
- package/dist/{chunk-PYKKWQZ2.js → chunk-M7BXDKPR.js} +6 -6
- package/dist/{chunk-Z54EM5YZ.js → chunk-MAXVH44E.js} +7 -7
- package/dist/{chunk-LYMNZZIM.js → chunk-NIS256NW.js} +2 -2
- package/dist/{chunk-67QG75MJ.js → chunk-NLK2VZYZ.js} +2 -2
- package/dist/{chunk-A4QMKFFO.js → chunk-O5FFBO2M.js} +14 -28
- package/dist/chunk-O5FFBO2M.js.map +1 -0
- package/dist/{chunk-JYIFGGEM.js → chunk-OUKBMQ2O.js} +2 -2
- package/dist/{chunk-75XOWNRS.js → chunk-OYESWJ43.js} +4 -4
- package/dist/{chunk-TS4AJ2GI.js → chunk-PA45XCUD.js} +3 -3
- package/dist/{chunk-BJYET5TX.js → chunk-PRDJMOST.js} +7 -1
- package/dist/chunk-PRDJMOST.js.map +1 -0
- package/dist/{chunk-4MBPIL4V.js → chunk-PUSLMZBQ.js} +2 -2
- package/dist/{chunk-RVO6TCTU.js → chunk-QCECHYZL.js} +6 -6
- package/dist/{chunk-GFIKG4FR.js → chunk-QGR6OVGT.js} +2 -2
- package/dist/{chunk-NSGU76YO.js → chunk-QHFV6VNU.js} +6 -2
- package/dist/chunk-QHFV6VNU.js.map +1 -0
- package/dist/{chunk-PDEKQWDV.js → chunk-QT2FRYI4.js} +18 -2
- package/dist/chunk-QT2FRYI4.js.map +1 -0
- package/dist/{chunk-HNZKVLAN.js → chunk-S354QO4R.js} +2 -2
- package/dist/{chunk-NO37MR45.js → chunk-SOEN6KCF.js} +2 -2
- package/dist/{chunk-FXX6RQYC.js → chunk-TPTECFWR.js} +2 -2
- package/dist/{chunk-GDDGZVFI.js → chunk-UEVLYVNW.js} +2 -2
- package/dist/{chunk-YQ4IQ2GA.js → chunk-UT5BV5OG.js} +2 -2
- package/dist/{chunk-LAQ33B5D.js → chunk-UU3G6GUP.js} +1 -1
- package/dist/chunk-UU3G6GUP.js.map +1 -0
- package/dist/{chunk-LNTUXKBT.js → chunk-UYYW2KPU.js} +2 -2
- package/dist/{chunk-BOFVT6P3.js → chunk-VBHPOWBJ.js} +175 -98
- package/dist/chunk-VBHPOWBJ.js.map +1 -0
- package/dist/{chunk-QSYL5CXK.js → chunk-VKXWK44Q.js} +3 -3
- package/dist/{chunk-KMWYZTIE.js → chunk-VMMQDEN5.js} +2 -2
- package/dist/{chunk-JB6D7EFB.js → chunk-VVG2BOKA.js} +2 -2
- package/dist/chunk-W5BIQOAJ.js +69 -0
- package/dist/chunk-W5BIQOAJ.js.map +1 -0
- package/dist/{chunk-V5H6OJCR.js → chunk-W5XVQFLM.js} +2 -2
- package/dist/{chunk-OIOZ6MOP.js → chunk-W6FNX2LP.js} +2 -2
- package/dist/{chunk-6QPHF6RR.js → chunk-WQM326GS.js} +2 -2
- package/dist/{chunk-TQFHQPWD.js → chunk-XADV5IZ3.js} +8 -8
- package/dist/{chunk-DATDLJAO.js → chunk-XAPMEU3K.js} +2 -2
- package/dist/chunk-XXSOVESA.js +42 -0
- package/dist/chunk-XXSOVESA.js.map +1 -0
- package/dist/{chunk-IK6X5QPO.js → chunk-ZHY5TMJG.js} +1193 -443
- package/dist/chunk-ZHY5TMJG.js.map +1 -0
- package/dist/{chunk-N3LL5NEU.js → chunk-ZMYDYNI4.js} +2 -2
- package/dist/{cli-D4vvtxjY.d.ts → cli-CnOkH9hA.d.ts} +6 -6
- package/dist/cli.d.ts +15 -13
- package/dist/cli.js +74 -70
- package/dist/coding/pre-action-gate.d.ts +3 -1
- package/dist/coding/pre-action-gate.js +2 -2
- package/dist/compounding/engine.d.ts +4 -2
- package/dist/compounding/engine.js +10 -9
- 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 +5 -3
- package/dist/connectors/codex-materialize-runner.d.ts +3 -1
- package/dist/connectors/codex-materialize-runner.js +10 -9
- package/dist/connectors/codex-materialize.d.ts +3 -1
- package/dist/connectors/index.d.ts +3 -1
- package/dist/connectors/index.js +10 -9
- package/dist/consolidation-provenance-check.d.ts +4 -2
- package/dist/consolidation-undo.d.ts +4 -2
- package/dist/contradiction/index.d.ts +4 -2
- package/dist/contradiction-config.d.ts +29 -0
- package/dist/contradiction-config.js +12 -0
- package/dist/contradiction-config.js.map +1 -0
- package/dist/converge-config.d.ts +3 -1
- package/dist/convergence-refresh.d.ts +4 -2
- package/dist/convergence-refresh.js +12 -11
- 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 +21 -20
- 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/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-retrieval.d.ts +4 -2
- package/dist/entity-retrieval.js +10 -9
- package/dist/entity-schema.d.ts +3 -1
- package/dist/explicit-capture.d.ts +11 -9
- package/dist/explicit-capture.js +3 -2
- package/dist/external-wiki-access.d.ts +13 -11
- package/dist/external-wiki-access.js +42 -40
- 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 +13 -11
- 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 +22 -21
- package/dist/fallback-llm.d.ts +3 -1
- package/dist/graph-444E-DrF.d.ts +349 -0
- package/dist/graph-dashboard-diff.d.ts +4 -2
- package/dist/graph-dashboard-key.d.ts +4 -2
- package/dist/graph-dashboard-parser.d.ts +4 -2
- package/dist/{graph-edge-decay-Z6ENALU2.js → graph-edge-decay-65KMOJWY.js} +4 -3
- package/dist/graph-edge-decay-65KMOJWY.js.map +1 -0
- package/dist/graph-edge-reinforcement.d.ts +4 -2
- package/dist/graph-path-reconstruction.d.ts +10 -0
- package/dist/graph-path-reconstruction.js +12 -0
- package/dist/graph-path-reconstruction.js.map +1 -0
- package/dist/graph-path-scoring-config.d.ts +8 -0
- package/dist/graph-path-scoring-config.js +10 -0
- package/dist/graph-path-scoring-config.js.map +1 -0
- package/dist/graph-path-scoring.d.ts +36 -0
- package/dist/graph-path-scoring.js +11 -0
- package/dist/graph-path-scoring.js.map +1 -0
- package/dist/graph-snapshot.d.ts +4 -2
- package/dist/graph-snapshot.js +3 -2
- package/dist/graph.d.ts +5 -318
- package/dist/graph.js +5 -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.d.ts +22 -20
- package/dist/index.js +149 -144
- package/dist/intent.d.ts +3 -1
- package/dist/lcm/engine.d.ts +3 -1
- package/dist/lcm/engine.js +3 -3
- package/dist/lcm/index.d.ts +3 -1
- package/dist/lcm/index.js +6 -6
- 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 +10 -9
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.d.ts +4 -2
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +10 -9
- package/dist/maintenance/rebuild-memory-projection.d.ts +4 -2
- package/dist/maintenance/rebuild-memory-projection.js +11 -10
- package/dist/{maintenance-ClmUVpGI.d.ts → maintenance-CKwxpdRx.d.ts} +3 -3
- package/dist/mcp-memory-inspector-app.d.ts +13 -11
- 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-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 +20 -19
- package/dist/namespaces/principal.d.ts +3 -1
- package/dist/namespaces/search.d.ts +3 -1
- package/dist/namespaces/search.js +7 -7
- package/dist/namespaces/storage.d.ts +5 -3
- package/dist/namespaces/storage.js +10 -9
- 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 +22 -21
- package/dist/operator-doctor-replica.d.ts +3 -1
- package/dist/operator-toolkit.d.ts +6 -4
- package/dist/operator-toolkit.js +33 -29
- package/dist/orchestration/compression-guideline-coordinator.d.ts +4 -2
- package/dist/orchestration/maintenance.d.ts +6 -4
- package/dist/orchestration/maintenance.js +15 -14
- package/dist/{orchestrator-qJ07zI8H.d.ts → orchestrator-BshGam-o.d.ts} +45 -19
- package/dist/orchestrator.d.ts +11 -9
- package/dist/orchestrator.js +109 -104
- package/dist/patterns-cli.d.ts +3 -1
- package/dist/{pipeline-WFCxhHOn.d.ts → pipeline-D21Rs6gW.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/{qmd-5tzkQ44y.d.ts → qmd-Dhle1P4X.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/qmd.js +4 -4
- 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-planner-llm.js +3 -3
- package/dist/recall-state.d.ts +7 -1
- package/dist/recall-state.js +1 -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 +7 -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/resolve-auth-token.d.ts +3 -1
- package/dist/resume-bundles.js +6 -4
- 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/{scope-profiles--vfXPl3X.d.ts → scope-profiles-NzGPDXLn.d.ts} +1 -1
- package/dist/search/embed-helper.d.ts +3 -1
- package/dist/search/factory.d.ts +3 -1
- package/dist/search/factory.js +6 -6
- package/dist/search/index.d.ts +3 -1
- package/dist/search/index.js +12 -12
- 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-consolidation-BBDuP9nJ.d.ts → semantic-consolidation-DLDKvyy5.d.ts} +1 -1
- package/dist/semantic-consolidation.d.ts +4 -2
- package/dist/semantic-consolidation.js +11 -10
- package/dist/semantic-rule-promotion.js +10 -9
- package/dist/semantic-rule-verifier.d.ts +3 -1
- package/dist/semantic-rule-verifier.js +10 -9
- package/dist/{service-B8DtbpCM.d.ts → service-BIgVM7fL.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 +18 -17
- package/dist/{storage-BkYN1RIy.d.ts → storage-CVfGWqCI.d.ts} +7 -6
- package/dist/storage.d.ts +4 -2
- package/dist/storage.js +9 -8
- package/dist/summarizer.d.ts +3 -1
- package/dist/summary-snapshot.d.ts +3 -1
- 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/autodetect.js +1 -1
- package/dist/transfer/backup.js +1 -1
- package/dist/transfer/capsule-export.js +2 -2
- package/dist/trust-score-stage.d.ts +3 -1
- package/dist/trust-score.d.ts +3 -1
- package/dist/{types-u2s9j1uD.d.ts → types-CkiDUorT.d.ts} +10 -16
- 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 +10 -9
- package/dist/write-envelope.d.ts +3 -1
- package/package.json +2 -2
- package/src/archive-mutation-version.ts +59 -0
- package/src/config.test.ts +45 -0
- package/src/config.ts +10 -30
- package/src/contradiction/contradiction.test.ts +86 -1
- package/src/contradiction-config.ts +92 -0
- package/src/graph-path-reconstruction.ts +91 -0
- package/src/graph-path-scoring-config.ts +55 -0
- package/src/graph-path-scoring.test.ts +238 -0
- package/src/graph-path-scoring.ts +77 -0
- package/src/graph.test.ts +225 -5
- package/src/graph.ts +72 -5
- package/src/orchestration/contradiction-linking-coordinator.ts +246 -76
- package/src/orchestration/contradiction-localization.integration.test.ts +1953 -0
- package/src/orchestration/extraction-anchor-snapshot.ts +83 -0
- package/src/orchestration/extraction-persist-deps.ts +8 -2
- package/src/orchestration/extraction-persist.ts +43 -34
- package/src/orchestration/graph-path-state-loader.test.ts +801 -0
- package/src/orchestration/graph-path-state-loader.ts +318 -0
- package/src/orchestration/graph-recall-coordinator.integration.test.ts +1163 -0
- package/src/orchestration/graph-recall-coordinator.ts +206 -29
- package/src/orchestration/graph-recall-seam.ts +19 -0
- package/src/orchestration/recall-internal-deps.ts +7 -13
- package/src/orchestration/recall-internal.ts +5 -0
- package/src/orchestration/recall-introspection.ts +9 -1
- package/src/orchestration/recall-search-pipeline.ts +8 -13
- package/src/orchestration/update-localization.test.ts +784 -0
- package/src/orchestration/update-localization.ts +173 -0
- package/src/orchestrator.ts +19 -18
- package/src/recall-state.test.ts +29 -1
- package/src/recall-state.ts +13 -0
- package/src/recall-xray-renderer.test.ts +45 -0
- package/src/recall-xray-renderer.ts +16 -0
- package/src/recall-xray.ts +13 -0
- package/src/storage/supersession-side-effects.ts +97 -0
- package/src/storage/tombstone-blocked-capture-sync.ts +13 -5
- package/src/storage-contract/cache-coherence.test.ts +299 -0
- package/src/storage.ts +86 -88
- package/src/types.ts +12 -15
- package/dist/chunk-A4QMKFFO.js.map +0 -1
- package/dist/chunk-BJYET5TX.js.map +0 -1
- package/dist/chunk-BOFVT6P3.js.map +0 -1
- package/dist/chunk-IK6X5QPO.js.map +0 -1
- package/dist/chunk-IXXABW5A.js.map +0 -1
- package/dist/chunk-L2DPF4DF.js.map +0 -1
- package/dist/chunk-LAQ33B5D.js.map +0 -1
- package/dist/chunk-NSGU76YO.js.map +0 -1
- package/dist/chunk-PDEKQWDV.js.map +0 -1
- /package/dist/{graph-edge-decay-Z6ENALU2.js.map → archive-mutation-version.js.map} +0 -0
- /package/dist/{chunk-KDG2KTWW.js.map → chunk-33SV3E43.js.map} +0 -0
- /package/dist/{chunk-2HGUDBRJ.js.map → chunk-37ZO6LLJ.js.map} +0 -0
- /package/dist/{chunk-QW3WFHKU.js.map → chunk-45BRYON6.js.map} +0 -0
- /package/dist/{chunk-GZICBRWK.js.map → chunk-4F6X3RXW.js.map} +0 -0
- /package/dist/{chunk-7BAYBYY5.js.map → chunk-4PC4PRJE.js.map} +0 -0
- /package/dist/{chunk-VJXY5ZCT.js.map → chunk-52UKFTUK.js.map} +0 -0
- /package/dist/{chunk-ESG7Z255.js.map → chunk-5UDMFE3Q.js.map} +0 -0
- /package/dist/{chunk-JPHEOE6Z.js.map → chunk-6MTSFX7A.js.map} +0 -0
- /package/dist/{chunk-M4MP34AQ.js.map → chunk-AHZOMHWN.js.map} +0 -0
- /package/dist/{chunk-Z3RHPGSY.js.map → chunk-AIUBBHSF.js.map} +0 -0
- /package/dist/{chunk-S3AYIQCU.js.map → chunk-AXIDQG5A.js.map} +0 -0
- /package/dist/{chunk-QN7NTKRC.js.map → chunk-AZ2QBGYB.js.map} +0 -0
- /package/dist/{chunk-47J4EDGR.js.map → chunk-AZM4CCAC.js.map} +0 -0
- /package/dist/{chunk-LEJPSMKM.js.map → chunk-C5QLI33R.js.map} +0 -0
- /package/dist/{chunk-SV3PSA7Y.js.map → chunk-CV6BBVYV.js.map} +0 -0
- /package/dist/{chunk-V7X767RT.js.map → chunk-DCZBSE4F.js.map} +0 -0
- /package/dist/{chunk-7PKFPLLZ.js.map → chunk-FXTYIA46.js.map} +0 -0
- /package/dist/{chunk-64BHFFKZ.js.map → chunk-HLYR2TQL.js.map} +0 -0
- /package/dist/{chunk-5C2HNJMO.js.map → chunk-J5LLX6IL.js.map} +0 -0
- /package/dist/{chunk-RKNJBZ55.js.map → chunk-JBPKEARU.js.map} +0 -0
- /package/dist/{chunk-PLKFO2HJ.js.map → chunk-JL43BVDE.js.map} +0 -0
- /package/dist/{chunk-2S72LWKX.js.map → chunk-JYL3BVVZ.js.map} +0 -0
- /package/dist/{chunk-IPLYGWQF.js.map → chunk-KQAFEZQX.js.map} +0 -0
- /package/dist/{chunk-PYKKWQZ2.js.map → chunk-M7BXDKPR.js.map} +0 -0
- /package/dist/{chunk-Z54EM5YZ.js.map → chunk-MAXVH44E.js.map} +0 -0
- /package/dist/{chunk-LYMNZZIM.js.map → chunk-NIS256NW.js.map} +0 -0
- /package/dist/{chunk-67QG75MJ.js.map → chunk-NLK2VZYZ.js.map} +0 -0
- /package/dist/{chunk-JYIFGGEM.js.map → chunk-OUKBMQ2O.js.map} +0 -0
- /package/dist/{chunk-75XOWNRS.js.map → chunk-OYESWJ43.js.map} +0 -0
- /package/dist/{chunk-TS4AJ2GI.js.map → chunk-PA45XCUD.js.map} +0 -0
- /package/dist/{chunk-4MBPIL4V.js.map → chunk-PUSLMZBQ.js.map} +0 -0
- /package/dist/{chunk-RVO6TCTU.js.map → chunk-QCECHYZL.js.map} +0 -0
- /package/dist/{chunk-GFIKG4FR.js.map → chunk-QGR6OVGT.js.map} +0 -0
- /package/dist/{chunk-HNZKVLAN.js.map → chunk-S354QO4R.js.map} +0 -0
- /package/dist/{chunk-NO37MR45.js.map → chunk-SOEN6KCF.js.map} +0 -0
- /package/dist/{chunk-FXX6RQYC.js.map → chunk-TPTECFWR.js.map} +0 -0
- /package/dist/{chunk-GDDGZVFI.js.map → chunk-UEVLYVNW.js.map} +0 -0
- /package/dist/{chunk-YQ4IQ2GA.js.map → chunk-UT5BV5OG.js.map} +0 -0
- /package/dist/{chunk-LNTUXKBT.js.map → chunk-UYYW2KPU.js.map} +0 -0
- /package/dist/{chunk-QSYL5CXK.js.map → chunk-VKXWK44Q.js.map} +0 -0
- /package/dist/{chunk-KMWYZTIE.js.map → chunk-VMMQDEN5.js.map} +0 -0
- /package/dist/{chunk-JB6D7EFB.js.map → chunk-VVG2BOKA.js.map} +0 -0
- /package/dist/{chunk-V5H6OJCR.js.map → chunk-W5XVQFLM.js.map} +0 -0
- /package/dist/{chunk-OIOZ6MOP.js.map → chunk-W6FNX2LP.js.map} +0 -0
- /package/dist/{chunk-6QPHF6RR.js.map → chunk-WQM326GS.js.map} +0 -0
- /package/dist/{chunk-TQFHQPWD.js.map → chunk-XADV5IZ3.js.map} +0 -0
- /package/dist/{chunk-DATDLJAO.js.map → chunk-XAPMEU3K.js.map} +0 -0
- /package/dist/{chunk-N3LL5NEU.js.map → chunk-ZMYDYNI4.js.map} +0 -0
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ActivationPathTracker,
|
|
3
|
+
compareActivationPathCandidates,
|
|
4
|
+
reconstructActivationPath
|
|
5
|
+
} from "./chunk-LXY5VVGM.js";
|
|
1
6
|
import {
|
|
2
7
|
readEdgeConfidence
|
|
3
8
|
} from "./chunk-2LSZVONP.js";
|
|
@@ -490,6 +495,7 @@ var GraphIndex = class _GraphIndex {
|
|
|
490
495
|
const decay = this.cfg.graphActivationDecay;
|
|
491
496
|
const floor = opts?.includeLowConfidence === true ? 0 : clampConfidenceFloor(this.cfg.graphTraversalConfidenceFloor);
|
|
492
497
|
const iterations = clampPageRankIterations(this.cfg.graphTraversalPageRankIterations);
|
|
498
|
+
const recordPaths = opts?.recordPaths === true;
|
|
493
499
|
const deadlineAtMs = opts?.deadlineAtMs;
|
|
494
500
|
const deadlineExpired = () => typeof deadlineAtMs === "number" && Date.now() >= deadlineAtMs;
|
|
495
501
|
try {
|
|
@@ -514,19 +520,35 @@ var GraphIndex = class _GraphIndex {
|
|
|
514
520
|
const provenance = /* @__PURE__ */ new Map();
|
|
515
521
|
let frontier = /* @__PURE__ */ new Map();
|
|
516
522
|
const reachedBySeed = /* @__PURE__ */ new Map();
|
|
523
|
+
const pathTracker = recordPaths ? new ActivationPathTracker(seeds) : null;
|
|
524
|
+
const predecessors = pathTracker?.predecessors ?? null;
|
|
517
525
|
for (const seed of seeds) {
|
|
518
526
|
frontier.set(`${seed}\0${seed}`, { node: seed, seed, activation: 1 });
|
|
519
527
|
reachedBySeed.set(seed, /* @__PURE__ */ new Set([seed]));
|
|
520
528
|
}
|
|
521
|
-
const finalizeScores = () =>
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
529
|
+
const finalizeScores = () => {
|
|
530
|
+
const results = Array.from(scores.entries()).map(([p, score]) => ({
|
|
531
|
+
path: p,
|
|
532
|
+
score,
|
|
533
|
+
seed: provenance.get(p)?.seed ?? "",
|
|
534
|
+
hopDepth: provenance.get(p)?.hopDepth ?? 0,
|
|
535
|
+
decayedWeight: provenance.get(p)?.decayedWeight ?? 0,
|
|
536
|
+
graphType: provenance.get(p)?.graphType ?? "entity",
|
|
537
|
+
edgeConfidence: provenance.get(p)?.edgeConfidence ?? 1
|
|
538
|
+
})).sort((a, b) => {
|
|
539
|
+
const scoreDelta = b.score - a.score;
|
|
540
|
+
if (scoreDelta !== 0 || !recordPaths) return scoreDelta;
|
|
541
|
+
return a.path < b.path ? -1 : a.path > b.path ? 1 : 0;
|
|
542
|
+
});
|
|
543
|
+
if (!recordPaths || !predecessors) return results;
|
|
544
|
+
return results.map((result) => {
|
|
545
|
+
const seed = provenance.get(result.path)?.seed;
|
|
546
|
+
return {
|
|
547
|
+
...result,
|
|
548
|
+
activationPath: seed === void 0 ? null : reconstructActivationPath(seed, result.path, predecessors, steps)
|
|
549
|
+
};
|
|
550
|
+
});
|
|
551
|
+
};
|
|
530
552
|
for (let hop = 0; hop < steps && frontier.size > 0; hop++) {
|
|
531
553
|
if (deadlineExpired()) return finalizeScores();
|
|
532
554
|
const nextFrontier = /* @__PURE__ */ new Map();
|
|
@@ -543,17 +565,37 @@ var GraphIndex = class _GraphIndex {
|
|
|
543
565
|
if (reachedForSeed?.has(neighbor)) {
|
|
544
566
|
continue;
|
|
545
567
|
}
|
|
568
|
+
const candidatePathKey = pathTracker && !seedSet.has(neighbor) ? pathTracker.consider(
|
|
569
|
+
sourceSeed,
|
|
570
|
+
node,
|
|
571
|
+
neighbor,
|
|
572
|
+
hop + 1,
|
|
573
|
+
score,
|
|
574
|
+
conf,
|
|
575
|
+
edge.type
|
|
576
|
+
) : "";
|
|
546
577
|
if (!seedSet.has(neighbor)) {
|
|
547
578
|
const existing = scores.get(neighbor) ?? 0;
|
|
548
579
|
scores.set(neighbor, existing + score);
|
|
549
580
|
const prev = provenance.get(neighbor);
|
|
550
|
-
|
|
581
|
+
const candidateWinner = {
|
|
582
|
+
hopDepth: hop + 1,
|
|
583
|
+
landingStrength: score,
|
|
584
|
+
pathKey: candidatePathKey
|
|
585
|
+
};
|
|
586
|
+
const shouldReplace = !prev || (recordPaths ? compareActivationPathCandidates(candidateWinner, {
|
|
587
|
+
hopDepth: prev.hopDepth,
|
|
588
|
+
landingStrength: prev.decayedWeight,
|
|
589
|
+
pathKey: prev.pathKey
|
|
590
|
+
}) > 0 : hop + 1 < prev.hopDepth || hop + 1 === prev.hopDepth && score > prev.decayedWeight);
|
|
591
|
+
if (shouldReplace) {
|
|
551
592
|
provenance.set(neighbor, {
|
|
552
593
|
seed: sourceSeed,
|
|
553
594
|
hopDepth: hop + 1,
|
|
554
595
|
decayedWeight: score,
|
|
555
596
|
graphType: edge.type,
|
|
556
|
-
edgeConfidence: conf
|
|
597
|
+
edgeConfidence: conf,
|
|
598
|
+
pathKey: candidatePathKey
|
|
557
599
|
});
|
|
558
600
|
}
|
|
559
601
|
if (hop + 1 < steps) {
|
|
@@ -703,4 +745,4 @@ export {
|
|
|
703
745
|
applyPageRankRefinement,
|
|
704
746
|
applyLateralInhibition
|
|
705
747
|
};
|
|
706
|
-
//# sourceMappingURL=chunk-
|
|
748
|
+
//# sourceMappingURL=chunk-BIJAWZYW.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/graph.ts"],"sourcesContent":["/**\n * Multi-Graph Memory (MAGMA/SYNAPSE-inspired, v8.2)\n *\n * Maintains three typed edge graphs:\n * entity.jsonl — memories sharing a named entity (entityRef)\n * time.jsonl — consecutive memories in the same thread/session\n * causal.jsonl — memories linked by causal language heuristics\n *\n * Stored under `<memoryDir>/state/graphs/`.\n * All writes are fail-open: errors are caught/logged, never thrown.\n */\n\nimport { appendFile, mkdir, readFile, stat } from \"node:fs/promises\";\nimport * as path from \"node:path\";\n\nimport { readEdgeConfidence } from \"./graph-edge-reinforcement.js\";\nimport { emitGraphEvent } from \"./graph-events.js\";\nimport type { GraphConstructionCapabilitySet } from \"./capabilities.js\";\nimport {\n ActivationPathTracker,\n compareActivationPathCandidates,\n reconstructActivationPath,\n type ActivationPathCandidate,\n type ActivationPredecessor,\n} from \"./graph-path-reconstruction.js\";\nexport { reconstructActivationPath, type ActivationPredecessor };\n\nexport type GraphType = \"entity\" | \"time\" | \"causal\";\n\nexport interface ActivationPath {\n /** Node ids from the seed (inclusive) to the reached node (inclusive). */\n nodeIds: string[];\n /** Edge confidences, parallel to the hops in {@link nodeIds}. */\n edgeConfidences: number[];\n /** Graph types, parallel to the hops in {@link nodeIds}. */\n graphTypes: GraphType[];\n}\n\nexport interface GraphEdge {\n from: string; // relative memory path (e.g. \"facts/2026-02-22/abc.md\")\n to: string; // relative memory path\n type: GraphType;\n weight: number; // 1.0 default, decay applied during traversal\n label: string; // entity name, threadId, or matched causal phrase\n ts: string; // ISO timestamp of edge creation\n\n // Issue #681 — edge confidence + reinforcement (PR 1/3: schema + primitive only).\n // Both fields are optional so existing edges without confidence still validate.\n // Treat a missing `confidence` as 1.0 (legacy behavior) at read sites.\n // PR 2/3 wires the maintenance decay job; PR 3/3 weights PageRank traversal by confidence.\n confidence?: number; // [0, 1]; missing = 1.0\n lastReinforcedAt?: string; // ISO timestamp of most recent reinforcement\n}\n\nexport interface GraphConfig {\n multiGraphMemoryEnabled: boolean;\n entityGraphEnabled: boolean;\n timeGraphEnabled: boolean;\n causalGraphEnabled: boolean;\n maxGraphTraversalSteps: number;\n graphActivationDecay: number;\n maxEntityGraphEdgesPerMemory: number;\n graphLateralInhibitionEnabled: boolean;\n graphLateralInhibitionBeta: number;\n graphLateralInhibitionTopM: number;\n /**\n * Issue #681 PR 3/3 — minimum edge confidence required for traversal.\n * Edges with confidence below this floor are pruned. Legacy edges\n * (no `confidence` field) are treated as 1.0 and always pass.\n * Range `[0, 1]`. Default 0.2.\n */\n graphTraversalConfidenceFloor: number;\n /**\n * Issue #681 PR 3/3 — number of PageRank-style refinement iterations\n * applied on top of BFS activation. Set to 0 to disable refinement\n * and return raw BFS scores. Default 8.\n */\n graphTraversalPageRankIterations: number;\n /**\n * Issue #1904 — incremental GraphIndex edge cache. When true (the default,\n * and the value when omitted), a single-writer edge append is pushed into the\n * warm edge cache in place (revalidated by file size for cross-process\n * coherence) instead of nulling the cache and paying a full 6 MB re-read +\n * parse on the next traversal. Set false to restore the pre-#1904\n * null-on-every-write behavior. Optional here (unlike the required\n * PluginConfig field parseConfig always sets) so GraphConfig can still be\n * constructed directly with a partial config; only an explicit `false` opts\n * out, so an omitted field keeps the incremental default.\n */\n graphEdgeCacheIncrementalEnabled?: boolean;\n}\n\n/** Default minimum edge confidence required for traversal (issue #681 PR 3/3). */\nexport const DEFAULT_GRAPH_TRAVERSAL_CONFIDENCE_FLOOR = 0.2;\n/** Default PageRank-style refinement iteration count (issue #681 PR 3/3). */\nexport const DEFAULT_GRAPH_TRAVERSAL_PAGERANK_ITERATIONS = 8;\n\n// Causal signal phrases — order matters (most specific first)\nexport const CAUSAL_PHRASES = [\"as a result\", \"led to\", \"because of\", \"therefore\", \"caused\", \"because\"];\n\nexport function graphsDir(memoryDir: string): string {\n return path.join(memoryDir, \"state\", \"graphs\");\n}\n\nexport function graphFilePath(memoryDir: string, type: GraphType): string {\n return path.join(graphsDir(memoryDir), `${type}.jsonl`);\n}\n\nexport async function ensureGraphsDir(memoryDir: string): Promise<void> {\n await mkdir(graphsDir(memoryDir), { recursive: true });\n}\n\n// ---------------------------------------------------------------------------\n// Per-graph-file write lock (gotcha #40 promise-chain pattern).\n//\n// Both the append path (`appendEdge`) and the rewrite path used by the\n// decay maintenance job must serialize on the same lock keyed by the\n// JSONL file path. Without this, an extraction can append a new edge\n// between the decay job's read-snapshot and rewrite, silently dropping\n// the appended edge during active traffic (issue #729 / Codex P1).\n// ---------------------------------------------------------------------------\nconst graphWriteLocks = new Map<string, Promise<void>>();\n\n/**\n * Run `fn` while holding the write lock for the given graph JSONL file.\n *\n * The lock is keyed by absolute file path so concurrent writes to\n * different graph types proceed independently. The chain recovers from\n * rejection (gotcha #40) so a single I/O failure does not poison all\n * future writers, but the original error is still surfaced to the\n * caller of `withGraphWriteLock`.\n */\nexport function withGraphWriteLock<T>(filePath: string, fn: () => Promise<T>): Promise<T> {\n const prev = graphWriteLocks.get(filePath) ?? Promise.resolve();\n const next = prev.then(fn, fn);\n graphWriteLocks.set(\n filePath,\n next.then(\n () => undefined,\n () => undefined\n )\n );\n return next;\n}\n\nexport async function appendEdge(memoryDir: string, edge: GraphEdge): Promise<void> {\n await ensureGraphsDir(memoryDir);\n const filePath = graphFilePath(memoryDir, edge.type);\n const line = `${JSON.stringify(edge)}\\n`;\n await withGraphWriteLock(filePath, async () => {\n await appendFile(filePath, line, \"utf8\");\n });\n // Emit edge-added event for SSE subscribers (issue #691 PR 5/5).\n // Fail-open: emitGraphEvent catches listener errors so a bad SSE client\n // can never surface into the extraction pipeline.\n emitGraphEvent(memoryDir, \"edge-added\", {\n source: edge.from,\n target: edge.to,\n kind: edge.type,\n weight: edge.weight,\n label: edge.label,\n confidence: typeof edge.confidence === \"number\" ? edge.confidence : 1.0,\n });\n}\n\nfunction isNodeError(err: unknown): err is NodeJS.ErrnoException {\n return typeof err === \"object\" && err !== null && \"code\" in err;\n}\n\nfunction parseEdgesJsonl(raw: string, expectedType: GraphType): GraphEdge[] {\n const edges: GraphEdge[] = [];\n for (const line of raw.split(\"\\n\")) {\n const trimmed = line.trim();\n if (!trimmed) continue;\n try {\n const parsed = JSON.parse(trimmed) as unknown;\n if (isValidGraphEdge(parsed, expectedType)) {\n edges.push(parsed);\n }\n } catch {\n // skip corrupt lines — fail-open for partial JSONL recovery\n }\n }\n return edges;\n}\n\n/**\n * Read all edges of a given type from the JSONL file.\n * Returns [] if the file doesn't exist or any read error occurs (fail-open).\n *\n * Production traversal callers (recall/PageRank) depend on this fail-open\n * posture so a temporarily missing or unreadable graph file never blocks\n * a recall. Maintenance jobs that need to distinguish ENOENT from real\n * I/O failures must use {@link readEdgesStrict} instead.\n */\nexport async function readEdges(memoryDir: string, type: GraphType): Promise<GraphEdge[]> {\n const filePath = graphFilePath(memoryDir, type);\n try {\n const raw = await readFile(filePath, \"utf8\");\n return parseEdgesJsonl(raw, type);\n } catch {\n return [];\n }\n}\n\n/**\n * Same as {@link readEdges} but only swallows `ENOENT`; all other read\n * errors (`EACCES`, `EIO`, …) are propagated. Used by the graph-edge\n * decay maintenance job so I/O outages surface as a failed run instead\n * of being silently reported as \"no edges to decay\" (issue #729 /\n * Codex P1, line 120).\n */\nexport async function readEdgesStrict(memoryDir: string, type: GraphType): Promise<GraphEdge[]> {\n const filePath = graphFilePath(memoryDir, type);\n try {\n const raw = await readFile(filePath, \"utf8\");\n return parseEdgesJsonl(raw, type);\n } catch (err) {\n if (isNodeError(err) && err.code === \"ENOENT\") {\n return [];\n }\n throw err;\n }\n}\n\n/**\n * Read edges from all enabled graph types.\n */\nexport async function readAllEdges(\n memoryDir: string,\n graphCaps: Pick<GraphConstructionCapabilitySet, \"entityGraph\" | \"timeGraph\" | \"causalGraph\">,\n): Promise<GraphEdge[]> {\n const parts: GraphEdge[][] = await Promise.all([\n graphCaps.entityGraph ? readEdges(memoryDir, \"entity\") : Promise.resolve([]),\n graphCaps.timeGraph ? readEdges(memoryDir, \"time\") : Promise.resolve([]),\n graphCaps.causalGraph ? readEdges(memoryDir, \"causal\") : Promise.resolve([]),\n ]);\n return parts.flat();\n}\n\nexport interface GraphHealthFileStats {\n type: GraphType;\n filePath: string;\n exists: boolean;\n totalLines: number;\n validEdges: number;\n corruptLines: number;\n uniqueNodes: number;\n}\n\nexport interface GraphHealthReport {\n generatedAt: string;\n enabledTypes: GraphType[];\n totals: {\n totalLines: number;\n validEdges: number;\n corruptLines: number;\n uniqueNodes: number;\n };\n files: GraphHealthFileStats[];\n repairGuidance?: string[];\n}\n\nfunction isValidGraphEdge(raw: unknown, expectedType: GraphType): raw is GraphEdge {\n if (!raw || typeof raw !== \"object\") return false;\n const edge = raw as Record<string, unknown>;\n return (\n edge.type === expectedType &&\n typeof edge.from === \"string\" &&\n edge.from.length > 0 &&\n typeof edge.to === \"string\" &&\n edge.to.length > 0 &&\n typeof edge.weight === \"number\" &&\n Number.isFinite(edge.weight) &&\n typeof edge.label === \"string\" &&\n typeof edge.ts === \"string\"\n );\n}\n\nexport async function analyzeGraphHealth(\n memoryDir: string,\n options?: {\n entityGraphEnabled?: boolean;\n timeGraphEnabled?: boolean;\n causalGraphEnabled?: boolean;\n includeRepairGuidance?: boolean;\n }\n): Promise<GraphHealthReport> {\n const enabledTypes: GraphType[] = [];\n if (options?.entityGraphEnabled !== false) enabledTypes.push(\"entity\");\n if (options?.timeGraphEnabled !== false) enabledTypes.push(\"time\");\n if (options?.causalGraphEnabled !== false) enabledTypes.push(\"causal\");\n\n const files: GraphHealthFileStats[] = [];\n const globalNodes = new Set<string>();\n\n for (const type of enabledTypes) {\n const filePath = graphFilePath(memoryDir, type);\n let exists = true;\n let totalLines = 0;\n let validEdges = 0;\n let corruptLines = 0;\n const nodes = new Set<string>();\n\n try {\n const raw = await readFile(filePath, \"utf8\");\n for (const line of raw.split(\"\\n\")) {\n const trimmed = line.trim();\n if (!trimmed) continue;\n totalLines += 1;\n try {\n const parsed = JSON.parse(trimmed) as unknown;\n if (!isValidGraphEdge(parsed, type)) {\n corruptLines += 1;\n continue;\n }\n validEdges += 1;\n nodes.add(parsed.from);\n nodes.add(parsed.to);\n globalNodes.add(parsed.from);\n globalNodes.add(parsed.to);\n } catch {\n corruptLines += 1;\n }\n }\n } catch {\n exists = false;\n }\n\n files.push({\n type,\n filePath,\n exists,\n totalLines,\n validEdges,\n corruptLines,\n uniqueNodes: nodes.size,\n });\n }\n\n const totals = files.reduce(\n (acc, item) => {\n acc.totalLines += item.totalLines;\n acc.validEdges += item.validEdges;\n acc.corruptLines += item.corruptLines;\n return acc;\n },\n {\n totalLines: 0,\n validEdges: 0,\n corruptLines: 0,\n uniqueNodes: globalNodes.size,\n }\n );\n totals.uniqueNodes = globalNodes.size;\n\n const report: GraphHealthReport = {\n generatedAt: new Date().toISOString(),\n enabledTypes,\n totals,\n files,\n };\n\n if (options?.includeRepairGuidance === true) {\n const guidance: string[] = [];\n if (totals.corruptLines > 0) {\n guidance.push(\n \"Corrupt graph lines detected: back up memory/state/graphs, then rebuild graphs from clean memory replay/extraction runs.\"\n );\n }\n if (totals.validEdges === 0) {\n guidance.push(\n \"No valid edges detected yet: run normal extraction traffic (or replay ingestion) to seed graph files.\"\n );\n }\n if (guidance.length > 0) report.repairGuidance = guidance;\n }\n\n return report;\n}\n\n/**\n * Detect causal signal phrases in text. Returns the first matched phrase, or null.\n */\nexport function detectCausalPhrase(text: string): string | null {\n const lower = text.toLowerCase();\n for (const phrase of CAUSAL_PHRASES) {\n if (lower.includes(phrase)) return phrase;\n }\n return null;\n}\n\n/**\n * GraphIndex — builds and updates the three memory graphs.\n *\n * Usage (orchestrator):\n * this.graphIndex = new GraphIndex(config.memoryDir, config);\n *\n * // After each memory write:\n * await this.graphIndex.onMemoryWritten(memoryPath, frontmatter, threadId, recentInThread);\n */\n/**\n * Identity of one graph JSONL file used to validate the incremental edge cache\n * (issue #1904). An absent file (ENOENT) is recorded as the all-zero sentinel\n * `{ size: 0, mtimeMs: 0, ino: 0 }` so a later peer creation (ino becomes\n * non-zero) is detected as a change.\n */\ninterface GraphFileMeta {\n size: number;\n mtimeMs: number;\n ino: number;\n}\n\nexport class GraphIndex {\n private readonly memoryDir: string;\n private readonly cfg: GraphConfig;\n\n // Cache for readAllEdges() result. With 30k+ entity edges (6 MB JSONL) the\n // file read + JSON parse takes 2-4 s per call. This instance-level cache\n // eliminates that overhead on every spreadingActivation() call; it is\n // invalidated (set to null) in onMemoryWritten() so new edges appear promptly.\n private edgeCache: {\n allEdges: GraphEdge[];\n loadedAt: number;\n // Per-file identity of each enabled graph file observed at load (issue\n // #1904). An incremental push is trusted only when every file's identity is\n // explained entirely by OUR own append: size grows by exactly the bytes we\n // appended and the inode is unchanged (a local append keeps the inode; an\n // external atomic temp+rename rewrite — e.g. the edge-decay job — changes\n // it). Untouched files must match size AND mtime AND inode exactly. This\n // closes the size-only holes Codex flagged: a peer append racing cache\n // construction, and an equal-length atomic rewrite (e.g. confidence\n // 0.9->0.8) that preserves byte length. Any divergence forces a full reload.\n meta: Partial<Record<GraphType, GraphFileMeta>>;\n } | null = null;\n private static readonly EDGE_CACHE_TTL_MS = 300_000; // 5 minutes\n\n constructor(memoryDir: string, cfg: GraphConfig) {\n this.memoryDir = memoryDir;\n this.cfg = cfg;\n }\n\n /** Clear the edge cache so the next spreadingActivation() re-reads from disk.\n * Call after any code path that appends edges outside of onMemoryWritten(). */\n invalidateEdgeCache(): void {\n this.edgeCache = null;\n }\n\n private async loadEdgesCached(): Promise<GraphEdge[]> {\n if (this.edgeCache && Date.now() - this.edgeCache.loadedAt < GraphIndex.EDGE_CACHE_TTL_MS) {\n return this.edgeCache.allEdges;\n }\n // Consistent snapshot (issue #1904, Codex): capture file identity BEFORE and\n // AFTER reading edges and retry if it changed, so `allEdges` and the recorded\n // `meta` baseline reflect the SAME on-disk state. Without this a peer append\n // landing mid-read would leave the cache holding edges that exclude the peer\n // edge while the baseline already counts its bytes — a later local append\n // would then pass the size-delta check and silently omit the peer edge.\n let allEdges: GraphEdge[] = [];\n let meta = await this.readEnabledGraphFileMeta();\n let stable = false;\n for (let attempt = 0; attempt < 3; attempt++) {\n const before = meta;\n allEdges = await readAllEdges(this.memoryDir, {\n entityGraph: this.cfg.entityGraphEnabled,\n timeGraph: this.cfg.timeGraphEnabled,\n causalGraph: this.cfg.causalGraphEnabled,\n });\n meta = await this.readEnabledGraphFileMeta();\n if (this.graphFileMetaEqual(before, meta)) {\n stable = true;\n break;\n }\n // A write landed during the read; the just-captured `meta` is the new\n // baseline for the next attempt's before-snapshot.\n }\n if (stable) {\n this.edgeCache = { allEdges, loadedAt: Date.now(), meta };\n } else {\n // Contended: a peer kept writing across every attempt, so the final\n // allEdges/meta pair is not guaranteed consistent. Serve THIS read's edges\n // (best effort) but do NOT poison the cache — leave it null so the next\n // call re-reads, instead of installing a baseline that could hide a peer\n // edge for the TTL (Codex).\n this.edgeCache = null;\n }\n return allEdges;\n }\n\n /**\n * Identity ({ size, mtimeMs, ino }) of each ENABLED graph file (issue #1904).\n * Missing files (ENOENT) and any stat error map to the all-zero sentinel so\n * the baseline is fail-open: a later revalidation sees a mismatch (or a peer\n * creation flipping ino from 0 to non-zero) and forces a full reload rather\n * than trusting a stale incremental push.\n */\n private async readEnabledGraphFileMeta(): Promise<Partial<Record<GraphType, GraphFileMeta>>> {\n const enabled: GraphType[] = [];\n if (this.cfg.entityGraphEnabled) enabled.push(\"entity\");\n if (this.cfg.timeGraphEnabled) enabled.push(\"time\");\n if (this.cfg.causalGraphEnabled) enabled.push(\"causal\");\n const meta: Partial<Record<GraphType, GraphFileMeta>> = {};\n for (const type of enabled) {\n try {\n const st = await stat(graphFilePath(this.memoryDir, type));\n meta[type] = { size: st.size, mtimeMs: st.mtimeMs, ino: Number(st.ino) };\n } catch {\n meta[type] = { size: 0, mtimeMs: 0, ino: 0 };\n }\n }\n return meta;\n }\n\n /** True iff both metadata maps carry identical identity for every key. */\n private graphFileMetaEqual(\n a: Partial<Record<GraphType, GraphFileMeta>>,\n b: Partial<Record<GraphType, GraphFileMeta>>,\n ): boolean {\n const types: GraphType[] = [\"entity\", \"time\", \"causal\"];\n for (const type of types) {\n const x = a[type];\n const y = b[type];\n if (!x && !y) continue;\n if (!x || !y) return false;\n if (x.size !== y.size || x.mtimeMs !== y.mtimeMs || x.ino !== y.ino) return false;\n }\n return true;\n }\n\n /**\n * Re-stat every graph file whose identity the cache just committed and return\n * false if any has moved since (issue #1904, Codex). Closes the validation→\n * in-place-push TOCTOU window: a peer process (concurrent CLI / daemon /\n * decay job) can append between edgeFilesUnchangedExceptOurAppends()'s final\n * stat and the allEdges.push(...). Without this re-check the cache would be\n * accepted with identity predating the peer write and miss the peer edge for\n * the TTL. A residual infinitesimal window (peer writes during this re-stat)\n * remains and is TTL-bounded.\n */\n private async edgeCacheIdentityUnchangedSinceCommit(): Promise<boolean> {\n if (!this.edgeCache) return false;\n for (const type of Object.keys(this.edgeCache.meta) as GraphType[]) {\n const committed = this.edgeCache.meta[type];\n if (!committed) continue;\n let cur: GraphFileMeta;\n try {\n const st = await stat(graphFilePath(this.memoryDir, type));\n cur = { size: st.size, mtimeMs: st.mtimeMs, ino: Number(st.ino) };\n } catch (err) {\n if ((err as NodeJS.ErrnoException)?.code === \"ENOENT\") {\n cur = { size: 0, mtimeMs: 0, ino: 0 };\n } else {\n return false;\n }\n }\n if (\n cur.size !== committed.size ||\n cur.mtimeMs !== committed.mtimeMs ||\n cur.ino !== committed.ino\n ) {\n return false;\n }\n }\n return true;\n }\n\n /**\n * Called after a memory is written to disk.\n *\n * @param memoryPath - relative path from memoryDir (e.g. \"facts/2026-02-22/abc.md\")\n * @param entityRef - entityRef frontmatter field (if any)\n * @param content - full memory text (for causal detection)\n * @param created - ISO timestamp of this memory\n * @param threadId - current thread ID (for time graph)\n * @param recentInThread - paths of the N most-recent memories in this thread (for time graph)\n * @param entitySiblings - paths of other memories that share the same entityRef (for entity graph)\n */\n async onMemoryWritten(opts: {\n memoryPath: string;\n entityRef?: string;\n content: string;\n created: string;\n threadId?: string;\n recentInThread?: string[];\n entitySiblings?: string[];\n causalPredecessor?: string;\n /**\n * Optional frozen gate overrides (from GraphConstructionCapabilitySet).\n * When provided, these take precedence over `this.cfg` so the caller's\n * operation-scoped snapshot is the single source of truth (#1566).\n */\n graphCapsOverride?: {\n entityGraph: boolean;\n timeGraph: boolean;\n causalGraph: boolean;\n multiGraphMemory: boolean;\n };\n }): Promise<void> {\n const g = opts.graphCapsOverride;\n const multiGraphOn = g ? g.multiGraphMemory : this.cfg.multiGraphMemoryEnabled;\n if (!multiGraphOn) return;\n const entityOn = g ? g.entityGraph : this.cfg.entityGraphEnabled;\n const timeOn = g ? g.timeGraph : this.cfg.timeGraphEnabled;\n const causalOn = g ? g.causalGraph : this.cfg.causalGraphEnabled;\n const ts = new Date().toISOString();\n // Collect the edges appended this call so a coherent single-writer push can\n // extend the warm edge cache in place instead of nulling it (issue #1904).\n const appended: GraphEdge[] = [];\n\n try {\n // Entity graph\n if (entityOn && opts.entityRef && opts.entitySiblings?.length) {\n const siblings = opts.entitySiblings.slice(0, this.cfg.maxEntityGraphEdgesPerMemory);\n for (const sibling of siblings) {\n const edge: GraphEdge = {\n from: opts.memoryPath,\n to: sibling,\n type: \"entity\",\n weight: 1.0,\n label: opts.entityRef,\n ts,\n };\n appended.push(edge);\n await appendEdge(this.memoryDir, edge);\n }\n }\n\n // Time graph — link to most recent memory in same thread\n if (timeOn && opts.threadId && opts.recentInThread?.length) {\n const predecessor = opts.recentInThread[opts.recentInThread.length - 1];\n if (predecessor && predecessor !== opts.memoryPath) {\n const edge: GraphEdge = {\n from: predecessor,\n to: opts.memoryPath,\n type: \"time\",\n weight: 1.0,\n label: opts.threadId,\n ts,\n };\n appended.push(edge);\n await appendEdge(this.memoryDir, edge);\n }\n }\n\n // Causal graph\n if (causalOn && opts.causalPredecessor) {\n const phrase = detectCausalPhrase(opts.content);\n if (phrase) {\n const edge: GraphEdge = {\n from: opts.causalPredecessor,\n to: opts.memoryPath,\n type: \"causal\",\n weight: 1.0,\n label: phrase,\n ts,\n };\n appended.push(edge);\n await appendEdge(this.memoryDir, edge);\n }\n }\n } catch (err) {\n // Fail-open: graph write errors must never surface to caller\n const { log } = await import(\"./logger.js\");\n log.warn(`[graph] onMemoryWritten error: ${err}`);\n } finally {\n // Edge-cache coherence (issue #1904). Legacy behavior nulled the cache on\n // every write, paying a 2-4 s full re-read + parse on the next traversal.\n if (!this.edgeCache || Date.now() - this.edgeCache.loadedAt >= GraphIndex.EDGE_CACHE_TTL_MS) {\n // Nothing warm, or the entry is past its 5-min TTL backstop — reload.\n this.edgeCache = null;\n } else if (this.cfg.graphEdgeCacheIncrementalEnabled === false) {\n // Rollback lever: restore the pre-#1904 null-on-every-write behavior.\n this.edgeCache = null;\n } else {\n // Trust an in-place push ONLY when WE are the sole writer since load:\n // every enabled graph file's on-disk size must equal our baseline plus\n // exactly the bytes we appended to it. A divergence means a peer process\n // (backup daemon / CLI / decay job) also wrote — force a full reload for\n // cross-process coherence. Any stat error fails open to a full reload.\n try {\n if (await this.edgeFilesUnchangedExceptOurAppends(appended)) {\n if (appended.length > 0) {\n this.edgeCache.allEdges.push(...appended);\n // Close the validation→push TOCTOU window (#1904, Codex): a peer\n // process can append between the validation stat above and this\n // in-place push. Re-verify every committed identity; if any file\n // moved, the cache would miss the peer edge for the TTL, so null\n // it and let the next traversal reload. (Skipped when this call\n // pushed nothing — no new window was opened, and the validation\n // already confirmed no peer wrote.)\n if (this.edgeCache && !(await this.edgeCacheIdentityUnchangedSinceCommit())) {\n this.edgeCache = null;\n }\n }\n } else {\n this.edgeCache = null;\n }\n } catch {\n this.edgeCache = null;\n }\n }\n }\n }\n\n /**\n * Cross-process coherence check for the incremental edge cache (issue #1904).\n *\n * Returns true iff every ENABLED graph file's current identity is explained\n * ENTIRELY by THIS call's own append — no other process wrote to any graph\n * file since load. Per file:\n * - inode must be unchanged. A local append (`appendFile`) keeps the inode;\n * an external atomic temp+rename rewrite (e.g. the edge-decay job) changes\n * it, so an inode change — even one that preserves byte length, such as\n * decaying confidence 0.9->0.8 — forces a reload (Codex).\n * - a file WE appended to (delta > 0): size must equal baseline + our exact\n * appended bytes. If it was absent at load (sentinel ino 0), our append\n * created it, so we accept size === delta and adopt the new identity.\n * - a file we did NOT touch (delta 0): size AND mtime must be unchanged, so\n * an in-place equal-length rewrite (mtime bump) or a peer append (size\n * bump) both force a reload.\n * On success it commits the new identity baseline so the next append\n * revalidates against post-this-write truth. Fail-open: an unreadable file\n * (non-ENOENT) returns false, forcing a full reload.\n */\n private async edgeFilesUnchangedExceptOurAppends(appended: GraphEdge[]): Promise<boolean> {\n if (!this.edgeCache) return false;\n const expectedDelta: Partial<Record<GraphType, number>> = {};\n for (const edge of appended) {\n const bytes = Buffer.byteLength(`${JSON.stringify(edge)}\\n`, \"utf8\");\n expectedDelta[edge.type] = (expectedDelta[edge.type] ?? 0) + bytes;\n }\n const enabled: GraphType[] = [];\n if (this.cfg.entityGraphEnabled) enabled.push(\"entity\");\n if (this.cfg.timeGraphEnabled) enabled.push(\"time\");\n if (this.cfg.causalGraphEnabled) enabled.push(\"causal\");\n const observed: Partial<Record<GraphType, GraphFileMeta>> = {};\n for (const type of enabled) {\n let cur: GraphFileMeta;\n try {\n const st = await stat(graphFilePath(this.memoryDir, type));\n cur = { size: st.size, mtimeMs: st.mtimeMs, ino: Number(st.ino) };\n } catch (err) {\n // An absent graph file (ENOENT) is the normal partially-populated state\n // (e.g. entity edges written before any causal edge): treat it as the\n // all-zero sentinel so the incremental cache stays warm. Only a genuine\n // stat failure forces a full reload (#1904, Codex).\n if ((err as NodeJS.ErrnoException)?.code === \"ENOENT\") {\n cur = { size: 0, mtimeMs: 0, ino: 0 };\n } else {\n return false;\n }\n }\n const base = this.edgeCache.meta[type] ?? { size: 0, mtimeMs: 0, ino: 0 };\n const delta = expectedDelta[type] ?? 0;\n if (delta > 0) {\n if (base.ino === 0) {\n // File was absent at load; our append created it. Accept iff its whole\n // size is exactly our appended bytes (nothing else wrote it).\n if (cur.ino === 0 || cur.size !== delta) return false;\n } else {\n // Existing file: our append keeps the inode and grows size by exactly\n // our bytes. An atomic rewrite (ino change) or a peer append (size\n // mismatch) both fail here.\n if (cur.ino !== base.ino || cur.size !== base.size + delta) return false;\n }\n } else {\n // Untouched file: identity must be byte-for-byte unchanged.\n if (cur.ino !== base.ino || cur.size !== base.size || cur.mtimeMs !== base.mtimeMs) {\n return false;\n }\n }\n observed[type] = cur;\n }\n this.edgeCache.meta = observed;\n return true;\n }\n\n /**\n * Spreading activation BFS (SYNAPSE-inspired).\n *\n * Starting from `seeds`, traverse the combined graph for up to `maxSteps` hops.\n * Each candidate gets an activation score = edge.weight × edgeConfidence × decay^hop.\n *\n * Issue #681 PR 3/3 — confidence-aware traversal:\n * - Each edge's `weight` is multiplied by its `confidence` (legacy edges\n * missing `confidence` are treated as 1.0, preserving prior behavior).\n * - Edges with `confidence < graphTraversalConfidenceFloor` are pruned and\n * contribute neither activation nor downstream neighbors.\n * - When `graphTraversalPageRankIterations > 0`, an additional PageRank-\n * style refinement pass redistributes activation along confidence-weighted\n * edges, sharpening the ranking among multi-hop candidates.\n * - Per-result provenance includes the highest-confidence edge that landed\n * on each candidate, so the X-ray surface can attribute pruning and\n * ranking decisions back to specific edges.\n *\n * @param seeds - initial memory paths to expand from (e.g. QMD top results)\n * @param maxSteps - max BFS hops (from config: maxGraphTraversalSteps)\n * @returns Array of {path, score, edgeConfidence, ...} sorted descending, not including seed paths\n */\n async spreadingActivation(\n seeds: string[],\n maxSteps?: number,\n opts?: {\n /**\n * Issue #681 — when `true`, bypasses the configured\n * `graphTraversalConfidenceFloor` and includes low-confidence\n * edges in traversal. Equivalent to forcing the floor to `0`.\n * Default `false` (floor from config is applied).\n */\n includeLowConfidence?: boolean;\n /** Record one shortest seed-to-candidate path in each result. */\n recordPaths?: boolean;\n /** Absolute deadline in ms-since-epoch for post-retrieval assembly. */\n deadlineAtMs?: number;\n }\n ): Promise<\n Array<{\n path: string;\n score: number;\n seed: string;\n hopDepth: number;\n decayedWeight: number;\n graphType: \"entity\" | \"time\" | \"causal\";\n /**\n * Confidence of the edge that produced this candidate's recorded\n * provenance (the strongest edge along the chosen entry path).\n * In `[0, 1]`. Legacy edges without `confidence` surface as 1.0.\n */\n edgeConfidence: number;\n activationPath?: ActivationPath | null;\n }>\n > {\n if (!this.cfg.multiGraphMemoryEnabled) return [];\n const steps = maxSteps ?? this.cfg.maxGraphTraversalSteps;\n const decay = this.cfg.graphActivationDecay;\n // When `includeLowConfidence` is set, use floor=0 so all edges\n // participate in traversal regardless of their decay state.\n // Otherwise clamp the configured floor into [0, 1] so misconfiguration\n // cannot (a) admit edges with negative confidence or (b) reject every\n // edge.\n const floor =\n opts?.includeLowConfidence === true ? 0 : clampConfidenceFloor(this.cfg.graphTraversalConfidenceFloor);\n const iterations = clampPageRankIterations(this.cfg.graphTraversalPageRankIterations);\n const recordPaths = opts?.recordPaths === true;\n const deadlineAtMs = opts?.deadlineAtMs;\n const deadlineExpired = (): boolean =>\n typeof deadlineAtMs === \"number\" && Date.now() >= deadlineAtMs;\n\n try {\n if (deadlineExpired()) return [];\n const allEdges = await this.loadEdgesCached();\n if (deadlineExpired()) return [];\n\n // Build adjacency index: from → edges, to → edges (bidirectional for entity/time, directional for causal).\n // Edges below the confidence floor are pruned at index time so neither\n // direct activation nor downstream BFS expansion can re-introduce them.\n const adj = new Map<string, GraphEdge[]>();\n for (let i = 0; i < allEdges.length; i += 1) {\n if ((i & 1023) === 0 && deadlineExpired()) return [];\n const edge = allEdges[i];\n const conf = readEdgeConfidence(edge);\n if (conf < floor) continue;\n if (!adj.has(edge.from)) adj.set(edge.from, []);\n adj.get(edge.from)!.push(edge);\n // Entity and time edges are bidirectional\n if (edge.type !== \"causal\") {\n if (!adj.has(edge.to)) adj.set(edge.to, []);\n adj.get(edge.to)!.push({ ...edge, from: edge.to, to: edge.from });\n }\n }\n const seedSet = new Set(seeds);\n const scores = new Map<string, number>(); // candidate path → accumulated activation score\n\n const provenance = new Map<\n string,\n {\n seed: string;\n hopDepth: number;\n decayedWeight: number;\n graphType: \"entity\" | \"time\" | \"causal\";\n edgeConfidence: number;\n pathKey: string;\n }\n >();\n let frontier = new Map<string, { node: string; seed: string; activation: number }>();\n const reachedBySeed = new Map<string, Set<string>>();\n const pathTracker = recordPaths ? new ActivationPathTracker(seeds) : null;\n const predecessors = pathTracker?.predecessors ?? null;\n for (const seed of seeds) {\n frontier.set(`${seed}\\0${seed}`, { node: seed, seed, activation: 1 });\n reachedBySeed.set(seed, new Set([seed]));\n }\n const finalizeScores = () => {\n const results = Array.from(scores.entries())\n .map(([p, score]) => ({\n path: p,\n score,\n seed: provenance.get(p)?.seed ?? \"\",\n hopDepth: provenance.get(p)?.hopDepth ?? 0,\n decayedWeight: provenance.get(p)?.decayedWeight ?? 0,\n graphType: provenance.get(p)?.graphType ?? \"entity\",\n edgeConfidence: provenance.get(p)?.edgeConfidence ?? 1,\n }))\n .sort((a, b) => {\n const scoreDelta = b.score - a.score;\n if (scoreDelta !== 0 || !recordPaths) return scoreDelta;\n return a.path < b.path ? -1 : a.path > b.path ? 1 : 0;\n });\n if (!recordPaths || !predecessors) return results;\n return results.map((result) => {\n const seed = provenance.get(result.path)?.seed;\n return {\n ...result,\n activationPath:\n seed === undefined ? null : reconstructActivationPath(seed, result.path, predecessors, steps),\n };\n });\n };\n\n for (let hop = 0; hop < steps && frontier.size > 0; hop++) {\n if (deadlineExpired()) return finalizeScores();\n const nextFrontier = new Map<string, { node: string; seed: string; activation: number }>();\n\n for (const { node, seed: sourceSeed, activation } of frontier.values()) {\n const edges = adj.get(node) ?? [];\n for (let i = 0; i < edges.length; i += 1) {\n if ((i & 1023) === 0 && deadlineExpired()) return finalizeScores();\n const edge = edges[i];\n const neighbor = edge.to === node ? edge.from : edge.to;\n const conf = readEdgeConfidence(edge);\n // Defense in depth: the adjacency build already drops sub-floor\n // edges, but if a synthesized reverse edge ever bypassed that\n // path, this guard keeps spreading activation honest.\n if (conf < floor) continue;\n const score = activation * edge.weight * conf * decay;\n const reachedForSeed = reachedBySeed.get(sourceSeed);\n if (reachedForSeed?.has(neighbor)) {\n continue;\n }\n const candidatePathKey =\n pathTracker && !seedSet.has(neighbor)\n ? pathTracker.consider(\n sourceSeed,\n node,\n neighbor,\n hop + 1,\n score,\n conf,\n edge.type,\n )\n : \"\";\n\n if (!seedSet.has(neighbor)) {\n const existing = scores.get(neighbor) ?? 0;\n scores.set(neighbor, existing + score);\n\n const prev = provenance.get(neighbor);\n const candidateWinner: ActivationPathCandidate = {\n hopDepth: hop + 1,\n landingStrength: score,\n pathKey: candidatePathKey,\n };\n const shouldReplace =\n !prev ||\n (recordPaths\n ? compareActivationPathCandidates(candidateWinner, {\n hopDepth: prev.hopDepth,\n landingStrength: prev.decayedWeight,\n pathKey: prev.pathKey,\n }) > 0\n : hop + 1 < prev.hopDepth ||\n (hop + 1 === prev.hopDepth && score > prev.decayedWeight));\n if (shouldReplace) {\n provenance.set(neighbor, {\n seed: sourceSeed,\n hopDepth: hop + 1,\n decayedWeight: score,\n graphType: edge.type,\n edgeConfidence: conf,\n pathKey: candidatePathKey,\n });\n }\n\n\n if (hop + 1 < steps) {\n const frontierKey = `${sourceSeed}\\0${neighbor}`;\n const existingFrontier = nextFrontier.get(frontierKey);\n if (existingFrontier) {\n existingFrontier.activation += score;\n } else {\n nextFrontier.set(frontierKey, {\n node: neighbor,\n seed: sourceSeed,\n activation: score,\n });\n }\n }\n }\n }\n }\n\n for (const { node, seed } of nextFrontier.values()) {\n reachedBySeed.get(seed)?.add(node);\n }\n frontier = nextFrontier;\n }\n\n // Issue #681 PR 3/3 — optional PageRank-style refinement.\n // Redistributes a node's accumulated activation along its outgoing\n // edges, weighted by edge confidence. Damping is fixed at the\n // canonical 0.85 so the ranking stays comparable across queries;\n // the `iterations` knob bounds compute, not behavior shape.\n if (!deadlineExpired() && iterations > 0 && scores.size > 1) {\n applyPageRankRefinement(scores, adj, {\n iterations,\n floor,\n damping: 0.85,\n deadlineAtMs,\n });\n }\n\n // Apply lateral inhibition if enabled (Synapse-inspired competitive suppression)\n if (deadlineExpired()) return finalizeScores();\n if (this.cfg.graphLateralInhibitionEnabled && scores.size > 1) {\n const inhibited = applyLateralInhibition(scores, {\n beta: this.cfg.graphLateralInhibitionBeta,\n topM: this.cfg.graphLateralInhibitionTopM,\n });\n for (const [k, v] of inhibited) {\n scores.set(k, v);\n }\n }\n\n return finalizeScores();\n } catch (err) {\n const { log } = await import(\"./logger.js\");\n log.warn(`[graph] spreadingActivation error: ${err}`);\n return [];\n }\n }\n}\n\n/**\n * Clamp `graphTraversalConfidenceFloor` into the legal range `[0, 1]`.\n * Non-finite or non-numeric values fall back to the documented default\n * so misconfiguration cannot silently disable the floor or reject every edge.\n *\n * Exported for tests; call sites in `spreadingActivation` use it to make\n * the contract explicit at every boundary.\n */\nexport function clampConfidenceFloor(raw: unknown): number {\n if (typeof raw !== \"number\" || !Number.isFinite(raw)) {\n return DEFAULT_GRAPH_TRAVERSAL_CONFIDENCE_FLOOR;\n }\n if (raw < 0) return 0;\n if (raw > 1) return 1;\n return raw;\n}\n\n/**\n * Clamp `graphTraversalPageRankIterations` into a non-negative integer.\n * Negative or non-finite values fall back to 0 (disable refinement) so\n * misconfiguration cannot stall recall in an unbounded loop.\n */\nexport function clampPageRankIterations(raw: unknown): number {\n if (typeof raw !== \"number\" || !Number.isFinite(raw)) return 0;\n if (raw <= 0) return 0;\n return Math.floor(raw);\n}\n\n/**\n * PageRank-style refinement on top of the BFS activation map.\n *\n * Each iteration redistributes a fraction of every node's score along\n * its outgoing edges, scaled by edge confidence. Confidence below\n * `floor` is filtered out before redistribution, mirroring the BFS\n * pruning rule. Mutates `scores` in place.\n *\n * Exported for tests; in production, call sites pass the same adjacency\n * map already used by BFS so behavior stays consistent.\n */\nexport function applyPageRankRefinement(\n scores: Map<string, number>,\n adj: Map<string, GraphEdge[]>,\n opts: { iterations: number; floor: number; damping: number; deadlineAtMs?: number }\n): void {\n const { iterations, floor, damping, deadlineAtMs } = opts;\n if (iterations <= 0 || scores.size === 0) return;\n const safeDamping = Math.min(1, Math.max(0, damping));\n const deadlineExpired = (): boolean =>\n typeof deadlineAtMs === \"number\" && Date.now() >= deadlineAtMs;\n\n // Pre-compute confidence-weighted out-edge totals for normalization.\n // Done once per refinement, not per iteration, since adjacency is\n // immutable inside the loop.\n //\n // Codex P1 (#735): the denominator MUST be computed over the same\n // eligible-neighbor set the iteration redistributes into — i.e.\n // edges whose neighbor is in `scores`. Counting edges-to-seeds (or\n // edges-to-unseen-nodes) in the denominator while dropping their\n // flow during iteration leaks `safeDamping × score` every pass and\n // collapses leaf candidates' scores instead of just re-ranking them.\n const eligible = (edge: GraphEdge, fromNode: string): boolean => {\n if (readEdgeConfidence(edge) < floor) return false;\n const neighbor = edge.to === fromNode ? edge.from : edge.to;\n return scores.has(neighbor);\n };\n const outboundTotal = new Map<string, number>();\n for (const [node, edges] of adj.entries()) {\n if (deadlineExpired()) return;\n if (!scores.has(node)) continue; // only candidate nodes redistribute\n let sum = 0;\n for (const edge of edges) {\n if (!eligible(edge, node)) continue;\n sum += readEdgeConfidence(edge) * edge.weight;\n }\n if (sum > 0) outboundTotal.set(node, sum);\n }\n\n for (let i = 0; i < iterations; i += 1) {\n if (deadlineExpired()) return;\n const next = new Map<string, number>();\n // Teleport / damping floor: every node retains `(1 - damping) * score`\n // of its current activation so dangling nodes do not bleed to zero.\n for (const [node, score] of scores) {\n next.set(node, (1 - safeDamping) * score);\n }\n for (const [node, score] of scores) {\n const outEdges = adj.get(node);\n const total = outboundTotal.get(node);\n // Dangling-node fallback: when a candidate has zero eligible\n // outflow (no in-scores neighbors above the floor), the\n // `safeDamping × score` portion would otherwise evaporate. Keep\n // it on `node` so total mass is conserved and the score reflects\n // the candidate's standing rather than its in-degree topology.\n if (!outEdges || outEdges.length === 0 || !total || total <= 0) {\n next.set(node, (next.get(node) ?? 0) + safeDamping * score);\n continue;\n }\n for (let edgeIndex = 0; edgeIndex < outEdges.length; edgeIndex += 1) {\n if ((edgeIndex & 1023) === 0 && deadlineExpired()) return;\n const edge = outEdges[edgeIndex];\n if (!eligible(edge, node)) continue;\n const conf = readEdgeConfidence(edge);\n const neighbor = edge.to === node ? edge.from : edge.to;\n const flow = safeDamping * score * ((conf * edge.weight) / total);\n next.set(neighbor, (next.get(neighbor) ?? 0) + flow);\n }\n }\n for (const [node, score] of next) {\n scores.set(node, score);\n }\n }\n}\n\n/**\n * Lateral inhibition (Synapse-inspired).\n *\n * For each node, the top-M higher-activation competitors exert inhibition\n * proportional to their activation difference. Output is clamped to [0, ∞).\n *\n * No sigmoid is applied here — downstream `normalizeGraphActivationScore`\n * already applies x/(1+x) soft squash, so adding a sigmoid would double-\n * normalize and cap graph influence at ~50%.\n *\n * Formula: u_hat_i = max(0, u_i - beta * sum_{k in top-M where u_k > u_i}(u_k - u_i))\n *\n * When beta=0 or topM=0, returns original scores unchanged (no-op).\n */\nexport function applyLateralInhibition(\n scores: Map<string, number>,\n opts: { beta: number; topM: number }\n): Map<string, number> {\n const { beta, topM } = opts;\n if (beta === 0 || topM === 0) return new Map(scores);\n\n const sorted = Array.from(scores.entries()).sort((a, b) => b[1] - a[1]);\n const topCompetitors = sorted.slice(0, topM);\n\n const result = new Map<string, number>();\n for (const [node, u] of scores) {\n let inhibition = 0;\n for (const [, uK] of topCompetitors) {\n if (uK > u) {\n inhibition += uK - u;\n }\n }\n result.set(node, Math.max(0, u - beta * inhibition));\n }\n\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;AAYA,SAAS,YAAY,OAAO,UAAU,YAAY;AAClD,YAAY,UAAU;AAgFf,IAAM,2CAA2C;AAEjD,IAAM,8CAA8C;AAGpD,IAAM,iBAAiB,CAAC,eAAe,UAAU,cAAc,aAAa,UAAU,SAAS;AAE/F,SAAS,UAAU,WAA2B;AACnD,SAAY,UAAK,WAAW,SAAS,QAAQ;AAC/C;AAEO,SAAS,cAAc,WAAmB,MAAyB;AACxE,SAAY,UAAK,UAAU,SAAS,GAAG,GAAG,IAAI,QAAQ;AACxD;AAEA,eAAsB,gBAAgB,WAAkC;AACtE,QAAM,MAAM,UAAU,SAAS,GAAG,EAAE,WAAW,KAAK,CAAC;AACvD;AAWA,IAAM,kBAAkB,oBAAI,IAA2B;AAWhD,SAAS,mBAAsB,UAAkB,IAAkC;AACxF,QAAM,OAAO,gBAAgB,IAAI,QAAQ,KAAK,QAAQ,QAAQ;AAC9D,QAAM,OAAO,KAAK,KAAK,IAAI,EAAE;AAC7B,kBAAgB;AAAA,IACd;AAAA,IACA,KAAK;AAAA,MACH,MAAM;AAAA,MACN,MAAM;AAAA,IACR;AAAA,EACF;AACA,SAAO;AACT;AAEA,eAAsB,WAAW,WAAmB,MAAgC;AAClF,QAAM,gBAAgB,SAAS;AAC/B,QAAM,WAAW,cAAc,WAAW,KAAK,IAAI;AACnD,QAAM,OAAO,GAAG,KAAK,UAAU,IAAI,CAAC;AAAA;AACpC,QAAM,mBAAmB,UAAU,YAAY;AAC7C,UAAM,WAAW,UAAU,MAAM,MAAM;AAAA,EACzC,CAAC;AAID,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AC3D,aAAK,IAAI,WAAW,KAAK,IAAI,QAAQ,KAAK,KAAK,IAAI;AAAA,MACrD;AAAA,IACF;AACA,eAAW,CAAC,MAAM,KAAK,KAAK,MAAM;AAChC,aAAO,IAAI,MAAM,KAAK;AAAA,IACxB;AAAA,EACF;AACF;AAgBO,SAAS,uBACd,QACA,MACqB;AACrB,QAAM,EAAE,MAAM,KAAK,IAAI;AACvB,MAAI,SAAS,KAAK,SAAS,EAAG,QAAO,IAAI,IAAI,MAAM;AAEnD,QAAM,SAAS,MAAM,KAAK,OAAO,QAAQ,CAAC,EAAE,KAAK,CAAC,GAAG,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC;AACtE,QAAM,iBAAiB,OAAO,MAAM,GAAG,IAAI;AAE3C,QAAM,SAAS,oBAAI,IAAoB;AACvC,aAAW,CAAC,MAAM,CAAC,KAAK,QAAQ;AAC9B,QAAI,aAAa;AACjB,eAAW,CAAC,EAAE,EAAE,KAAK,gBAAgB;AACnC,UAAI,KAAK,GAAG;AACV,sBAAc,KAAK;AAAA,MACrB;AAAA,IACF;AACA,WAAO,IAAI,MAAM,KAAK,IAAI,GAAG,IAAI,OAAO,UAAU,CAAC;AAAA,EACrD;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
} from "./chunk-D24OXEPB.js";
|
|
10
10
|
import {
|
|
11
11
|
validateRequest
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-NIS256NW.js";
|
|
13
13
|
import {
|
|
14
14
|
REMNIC_CHATGPT_MEMORY_INSPECTOR_MIME_TYPE,
|
|
15
15
|
REMNIC_CHATGPT_MEMORY_INSPECTOR_TOOL,
|
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
} from "./chunk-YYQAKIDJ.js";
|
|
26
26
|
import {
|
|
27
27
|
getOperation
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-J5LLX6IL.js";
|
|
29
29
|
import {
|
|
30
30
|
assertOperationAllowed,
|
|
31
31
|
capabilityAllowsOp,
|
|
@@ -3761,4 +3761,4 @@ export {
|
|
|
3761
3761
|
MCP_SUPPORTED_PROTOCOL_VERSIONS,
|
|
3762
3762
|
EngramMcpServer
|
|
3763
3763
|
};
|
|
3764
|
-
//# sourceMappingURL=chunk-
|
|
3764
|
+
//# sourceMappingURL=chunk-C5QLI33R.js.map
|
|
@@ -12,17 +12,17 @@ import {
|
|
|
12
12
|
} from "./chunk-2DQ2XREU.js";
|
|
13
13
|
import {
|
|
14
14
|
compareEntityTimestamps
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-VBHPOWBJ.js";
|
|
16
16
|
import {
|
|
17
17
|
normalizeEntityName
|
|
18
18
|
} from "./chunk-YXZG5TVN.js";
|
|
19
|
+
import {
|
|
20
|
+
sanitizeMemoryContent
|
|
21
|
+
} from "./chunk-5GKPFL3S.js";
|
|
19
22
|
import {
|
|
20
23
|
normalizeEntityText,
|
|
21
24
|
resolveRequestedEntitySectionKeys
|
|
22
25
|
} from "./chunk-ZIKENA2C.js";
|
|
23
|
-
import {
|
|
24
|
-
sanitizeMemoryContent
|
|
25
|
-
} from "./chunk-5GKPFL3S.js";
|
|
26
26
|
import {
|
|
27
27
|
resolveNamespaceCapabilities
|
|
28
28
|
} from "./chunk-2XRE6FLM.js";
|
|
@@ -887,4 +887,4 @@ export {
|
|
|
887
887
|
entityIndexVersion,
|
|
888
888
|
entityRecentTranscriptLookbackHours
|
|
889
889
|
};
|
|
890
|
-
//# sourceMappingURL=chunk-
|
|
890
|
+
//# sourceMappingURL=chunk-CV6BBVYV.js.map
|
|
@@ -7,9 +7,6 @@ import {
|
|
|
7
7
|
import {
|
|
8
8
|
openclawReplayNormalizer
|
|
9
9
|
} from "./chunk-H4CKS5B2.js";
|
|
10
|
-
import {
|
|
11
|
-
exportJsonBundle
|
|
12
|
-
} from "./chunk-UP6MOYCB.js";
|
|
13
10
|
import {
|
|
14
11
|
exportSqlite
|
|
15
12
|
} from "./chunk-BV2TIZ4F.js";
|
|
@@ -28,12 +25,12 @@ import {
|
|
|
28
25
|
import {
|
|
29
26
|
backupMemoryDir
|
|
30
27
|
} from "./chunk-2NLLXCJG.js";
|
|
28
|
+
import {
|
|
29
|
+
exportJsonBundle
|
|
30
|
+
} from "./chunk-UP6MOYCB.js";
|
|
31
31
|
import {
|
|
32
32
|
exportMarkdownBundle
|
|
33
33
|
} from "./chunk-765K3SAT.js";
|
|
34
|
-
import {
|
|
35
|
-
RoutingRulesStore
|
|
36
|
-
} from "./chunk-XL24QQ63.js";
|
|
37
34
|
import {
|
|
38
35
|
buildReplayNormalizerRegistry,
|
|
39
36
|
clampBatchSize,
|
|
@@ -43,6 +40,9 @@ import {
|
|
|
43
40
|
isReplaySource,
|
|
44
41
|
normalizeReplaySessionKey
|
|
45
42
|
} from "./chunk-AJVLDJU6.js";
|
|
43
|
+
import {
|
|
44
|
+
RoutingRulesStore
|
|
45
|
+
} from "./chunk-XL24QQ63.js";
|
|
46
46
|
import {
|
|
47
47
|
TailscaleHelper
|
|
48
48
|
} from "./chunk-EEC4PCG5.js";
|
|
@@ -54,7 +54,7 @@ import {
|
|
|
54
54
|
} from "./chunk-IIFFC3RL.js";
|
|
55
55
|
import {
|
|
56
56
|
rebuildMemoryLifecycleLedger
|
|
57
|
-
} from "./chunk-
|
|
57
|
+
} from "./chunk-UEVLYVNW.js";
|
|
58
58
|
import {
|
|
59
59
|
rebuildObservations
|
|
60
60
|
} from "./chunk-DQTCGVFK.js";
|
|
@@ -70,9 +70,6 @@ import {
|
|
|
70
70
|
registerBulkImportSource,
|
|
71
71
|
runBulkImportPipeline
|
|
72
72
|
} from "./chunk-HSSERO3E.js";
|
|
73
|
-
import {
|
|
74
|
-
searchVerifiedEpisodes
|
|
75
|
-
} from "./chunk-7PKFPLLZ.js";
|
|
76
73
|
import {
|
|
77
74
|
getUtilityLearningStatus,
|
|
78
75
|
learnUtilityPromotionWeights
|
|
@@ -81,20 +78,23 @@ import {
|
|
|
81
78
|
getUtilityTelemetryStatus,
|
|
82
79
|
recordUtilityTelemetryEvent
|
|
83
80
|
} from "./chunk-6FC3IZ26.js";
|
|
81
|
+
import {
|
|
82
|
+
searchVerifiedEpisodes
|
|
83
|
+
} from "./chunk-FXTYIA46.js";
|
|
84
84
|
import {
|
|
85
85
|
ThreadingManager
|
|
86
86
|
} from "./chunk-OJP3N7UK.js";
|
|
87
87
|
import {
|
|
88
88
|
promoteSemanticRuleFromMemory
|
|
89
|
-
} from "./chunk-
|
|
89
|
+
} from "./chunk-4F6X3RXW.js";
|
|
90
90
|
import {
|
|
91
91
|
searchVerifiedSemanticRules
|
|
92
|
-
} from "./chunk-
|
|
92
|
+
} from "./chunk-QGR6OVGT.js";
|
|
93
93
|
import {
|
|
94
94
|
buildResumeBundleFromState,
|
|
95
95
|
getResumeBundleStatus,
|
|
96
96
|
recordResumeBundle
|
|
97
|
-
} from "./chunk-
|
|
97
|
+
} from "./chunk-XAPMEU3K.js";
|
|
98
98
|
import {
|
|
99
99
|
getWorkProductLedgerStatus,
|
|
100
100
|
recordWorkProductLedgerEntry,
|
|
@@ -105,7 +105,16 @@ import {
|
|
|
105
105
|
} from "./chunk-HYQJQGD3.js";
|
|
106
106
|
import {
|
|
107
107
|
parseXrayCliOptions
|
|
108
|
-
} from "./chunk-
|
|
108
|
+
} from "./chunk-VKXWK44Q.js";
|
|
109
|
+
import {
|
|
110
|
+
collectPatternMemories,
|
|
111
|
+
explainPatternMemory,
|
|
112
|
+
parsePatternsExplainOptions,
|
|
113
|
+
parsePatternsListOptions,
|
|
114
|
+
parseStrictCliDate,
|
|
115
|
+
renderPatternExplain,
|
|
116
|
+
renderPatternsList
|
|
117
|
+
} from "./chunk-3T74IZB3.js";
|
|
109
118
|
import {
|
|
110
119
|
readRuntimePolicySnapshot,
|
|
111
120
|
sanitizeRuntimePolicyValues
|
|
@@ -118,21 +127,12 @@ import {
|
|
|
118
127
|
runOperatorInventory,
|
|
119
128
|
runOperatorRepair,
|
|
120
129
|
runOperatorSetup
|
|
121
|
-
} from "./chunk-
|
|
130
|
+
} from "./chunk-6MTSFX7A.js";
|
|
122
131
|
import {
|
|
123
132
|
analyzeSessionIntegrity,
|
|
124
133
|
applySessionRepair,
|
|
125
134
|
planSessionRepair
|
|
126
135
|
} from "./chunk-KFY3SGN7.js";
|
|
127
|
-
import {
|
|
128
|
-
collectPatternMemories,
|
|
129
|
-
explainPatternMemory,
|
|
130
|
-
parsePatternsExplainOptions,
|
|
131
|
-
parsePatternsListOptions,
|
|
132
|
-
parseStrictCliDate,
|
|
133
|
-
renderPatternExplain,
|
|
134
|
-
renderPatternsList
|
|
135
|
-
} from "./chunk-3T74IZB3.js";
|
|
136
136
|
import {
|
|
137
137
|
GITHUB_CONNECTOR_ID,
|
|
138
138
|
GMAIL_CONNECTOR_ID,
|
|
@@ -150,12 +150,12 @@ import {
|
|
|
150
150
|
import {
|
|
151
151
|
listConnectorStates
|
|
152
152
|
} from "./chunk-6GUG4YNM.js";
|
|
153
|
+
import {
|
|
154
|
+
searchHarmonicRetrieval
|
|
155
|
+
} from "./chunk-AZ2QBGYB.js";
|
|
153
156
|
import {
|
|
154
157
|
rescoreMemoryImportance
|
|
155
158
|
} from "./chunk-JXS5PDQ7.js";
|
|
156
|
-
import {
|
|
157
|
-
searchHarmonicRetrieval
|
|
158
|
-
} from "./chunk-QN7NTKRC.js";
|
|
159
159
|
import {
|
|
160
160
|
createEvalBaselineSnapshot,
|
|
161
161
|
getEvalHarnessStatus,
|
|
@@ -165,6 +165,11 @@ import {
|
|
|
165
165
|
runEvalStoredBaselineCiGate,
|
|
166
166
|
validateEvalBenchmarkPack
|
|
167
167
|
} from "./chunk-MCA2X4WH.js";
|
|
168
|
+
import {
|
|
169
|
+
rebuildMemoryProjection,
|
|
170
|
+
repairMemoryProjection,
|
|
171
|
+
verifyMemoryProjection
|
|
172
|
+
} from "./chunk-AIUBBHSF.js";
|
|
168
173
|
import {
|
|
169
174
|
getCueAnchorStoreStatus
|
|
170
175
|
} from "./chunk-ACPCA4NO.js";
|
|
@@ -180,11 +185,6 @@ import {
|
|
|
180
185
|
renderConnectorsRunResult,
|
|
181
186
|
runConnectorPollOnce
|
|
182
187
|
} from "./chunk-OKTXM5H4.js";
|
|
183
|
-
import {
|
|
184
|
-
rebuildMemoryProjection,
|
|
185
|
-
repairMemoryProjection,
|
|
186
|
-
verifyMemoryProjection
|
|
187
|
-
} from "./chunk-Z3RHPGSY.js";
|
|
188
188
|
import {
|
|
189
189
|
applyCommitmentLedgerLifecycle,
|
|
190
190
|
getCommitmentLedgerStatus,
|
|
@@ -196,11 +196,11 @@ import {
|
|
|
196
196
|
} from "./chunk-UQ7RN5HK.js";
|
|
197
197
|
import {
|
|
198
198
|
parseConfig
|
|
199
|
-
} from "./chunk-
|
|
199
|
+
} from "./chunk-O5FFBO2M.js";
|
|
200
200
|
import {
|
|
201
201
|
EngramAccessHttpServer,
|
|
202
202
|
MeetingsInputError
|
|
203
|
-
} from "./chunk-
|
|
203
|
+
} from "./chunk-XADV5IZ3.js";
|
|
204
204
|
import {
|
|
205
205
|
WearablesInputError
|
|
206
206
|
} from "./chunk-V7IZKJI3.js";
|
|
@@ -213,13 +213,13 @@ import {
|
|
|
213
213
|
createProductionChatLlmAdapter,
|
|
214
214
|
loadChatSession,
|
|
215
215
|
sessionBelongsToPrincipal
|
|
216
|
-
} from "./chunk-
|
|
216
|
+
} from "./chunk-C5QLI33R.js";
|
|
217
217
|
import {
|
|
218
218
|
getAbstractionNodeStoreStatus
|
|
219
219
|
} from "./chunk-DJUKBGAD.js";
|
|
220
220
|
import {
|
|
221
221
|
EngramAccessService
|
|
222
|
-
} from "./chunk-
|
|
222
|
+
} from "./chunk-J5LLX6IL.js";
|
|
223
223
|
import {
|
|
224
224
|
WorkStorage
|
|
225
225
|
} from "./chunk-GDB4J2H3.js";
|
|
@@ -236,43 +236,43 @@ import {
|
|
|
236
236
|
parseRecallExplainFormat,
|
|
237
237
|
renderRecallExplain,
|
|
238
238
|
renderXray
|
|
239
|
-
} from "./chunk-
|
|
239
|
+
} from "./chunk-QT2FRYI4.js";
|
|
240
240
|
import {
|
|
241
241
|
readAggregateExtractionWatermark
|
|
242
|
-
} from "./chunk-
|
|
242
|
+
} from "./chunk-JYL3BVVZ.js";
|
|
243
243
|
import {
|
|
244
244
|
getObjectiveStateStoreStatus
|
|
245
245
|
} from "./chunk-HTP6XRUI.js";
|
|
246
|
-
import {
|
|
247
|
-
listNamespaces,
|
|
248
|
-
runNamespaceMigration,
|
|
249
|
-
verifyNamespaces
|
|
250
|
-
} from "./chunk-TS4AJ2GI.js";
|
|
251
246
|
import {
|
|
252
247
|
listMemoryGovernanceRuns,
|
|
253
248
|
readMemoryGovernanceRunArtifact,
|
|
254
249
|
restoreMemoryGovernanceRun,
|
|
255
250
|
runMemoryGovernance
|
|
256
|
-
} from "./chunk-
|
|
251
|
+
} from "./chunk-TPTECFWR.js";
|
|
257
252
|
import {
|
|
258
|
-
|
|
259
|
-
|
|
253
|
+
listNamespaces,
|
|
254
|
+
runNamespaceMigration,
|
|
255
|
+
verifyNamespaces
|
|
256
|
+
} from "./chunk-PA45XCUD.js";
|
|
260
257
|
import {
|
|
261
|
-
|
|
262
|
-
} from "./chunk-
|
|
258
|
+
resolveNamespaceChildRoot
|
|
259
|
+
} from "./chunk-PUSLMZBQ.js";
|
|
263
260
|
import {
|
|
264
261
|
getCausalTrajectoryStoreStatus
|
|
265
|
-
} from "./chunk-
|
|
262
|
+
} from "./chunk-AHZOMHWN.js";
|
|
263
|
+
import {
|
|
264
|
+
analyzeGraphHealth
|
|
265
|
+
} from "./chunk-BIJAWZYW.js";
|
|
266
266
|
import {
|
|
267
267
|
meetingIdDate
|
|
268
|
-
} from "./chunk-
|
|
268
|
+
} from "./chunk-VBHPOWBJ.js";
|
|
269
269
|
import {
|
|
270
270
|
isValidTranscriptDate
|
|
271
271
|
} from "./chunk-UHVXE24Y.js";
|
|
272
272
|
import {
|
|
273
273
|
RECALL_DISCLOSURE_LEVELS,
|
|
274
274
|
isRecallDisclosure
|
|
275
|
-
} from "./chunk-
|
|
275
|
+
} from "./chunk-UU3G6GUP.js";
|
|
276
276
|
import {
|
|
277
277
|
bumpMemoryCorpusVersionForDir
|
|
278
278
|
} from "./chunk-KMAP7SNQ.js";
|
|
@@ -7989,4 +7989,4 @@ export {
|
|
|
7989
7989
|
listMemoryMarkdownFilePaths,
|
|
7990
7990
|
registerCli
|
|
7991
7991
|
};
|
|
7992
|
-
//# sourceMappingURL=chunk-
|
|
7992
|
+
//# sourceMappingURL=chunk-DCZBSE4F.js.map
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import {
|
|
2
|
+
coerceBool,
|
|
3
|
+
coerceNumber
|
|
4
|
+
} from "./chunk-PQVCH2AE.js";
|
|
5
|
+
|
|
6
|
+
// src/contradiction-config.ts
|
|
7
|
+
function parseContradictionScanConfig(raw) {
|
|
8
|
+
if (!raw || typeof raw !== "object") {
|
|
9
|
+
return {
|
|
10
|
+
enabled: false,
|
|
11
|
+
similarityFloor: 0.82,
|
|
12
|
+
topicOverlapFloor: 0.4,
|
|
13
|
+
maxPairsPerRun: 500,
|
|
14
|
+
cooldownDays: 14,
|
|
15
|
+
autoMergeDuplicates: false
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
const src = raw;
|
|
19
|
+
const simFloor = coerceNumber(src.similarityFloor) ?? 0.82;
|
|
20
|
+
const topicFloor = coerceNumber(src.topicOverlapFloor) ?? 0.4;
|
|
21
|
+
const maxPairs = coerceNumber(src.maxPairsPerRun) ?? 500;
|
|
22
|
+
const cooldown = coerceNumber(src.cooldownDays) ?? 14;
|
|
23
|
+
return {
|
|
24
|
+
enabled: coerceBool(src.enabled) === true,
|
|
25
|
+
similarityFloor: Math.min(1, Math.max(0, simFloor)),
|
|
26
|
+
topicOverlapFloor: Math.min(1, Math.max(0, topicFloor)),
|
|
27
|
+
maxPairsPerRun: Math.max(1, maxPairs),
|
|
28
|
+
cooldownDays: Math.max(0, cooldown),
|
|
29
|
+
autoMergeDuplicates: coerceBool(src.autoMergeDuplicates) === true
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function parseContradictionLocalizationConfig(raw) {
|
|
33
|
+
const defaults = {
|
|
34
|
+
anchorEnabled: true,
|
|
35
|
+
anchorCandidates: 5,
|
|
36
|
+
searchCandidates: 5,
|
|
37
|
+
maxCandidates: 8
|
|
38
|
+
};
|
|
39
|
+
if (raw === void 0 || raw === null) return defaults;
|
|
40
|
+
if (typeof raw !== "object" || Array.isArray(raw)) {
|
|
41
|
+
throw new Error("contradictionLocalization must be an object");
|
|
42
|
+
}
|
|
43
|
+
const src = raw;
|
|
44
|
+
const rawEnabled = src.anchorEnabled;
|
|
45
|
+
const anchorEnabled = rawEnabled === void 0 || rawEnabled === null ? true : coerceBool(rawEnabled);
|
|
46
|
+
if (anchorEnabled === void 0) {
|
|
47
|
+
throw new Error("contradictionLocalization.anchorEnabled must be a boolean-like value");
|
|
48
|
+
}
|
|
49
|
+
const parseCap = (key) => {
|
|
50
|
+
const rawValue = src[key];
|
|
51
|
+
if (rawValue === void 0) return defaults[key];
|
|
52
|
+
const parsed = coerceNumber(rawValue);
|
|
53
|
+
if (parsed === void 0 || !Number.isInteger(parsed) || parsed < 0) {
|
|
54
|
+
throw new Error(`contradictionLocalization.${key} must be an integer >= 0`);
|
|
55
|
+
}
|
|
56
|
+
return parsed;
|
|
57
|
+
};
|
|
58
|
+
return {
|
|
59
|
+
anchorEnabled,
|
|
60
|
+
anchorCandidates: parseCap("anchorCandidates"),
|
|
61
|
+
searchCandidates: parseCap("searchCandidates"),
|
|
62
|
+
maxCandidates: parseCap("maxCandidates")
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export {
|
|
67
|
+
parseContradictionScanConfig,
|
|
68
|
+
parseContradictionLocalizationConfig
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=chunk-FC67T4E6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/contradiction-config.ts"],"sourcesContent":["import { coerceBool, coerceNumber } from \"./connectors/coerce.js\";\n\n/** Configuration for the nightly contradiction-scan cron (issue #520). */\nexport interface ContradictionScanConfig {\n /** Master switch for the contradiction scan cron. Default true. */\n enabled: boolean;\n /** Embedding cosine similarity floor for candidate pair generation. Default 0.82. */\n similarityFloor: number;\n /** Minimum topic-token Jaccard overlap for unstructured pairs. Default 0.4. */\n topicOverlapFloor: number;\n /** Cap on candidate pairs evaluated per cron run. Default 500. */\n maxPairsPerRun: number;\n /** Cooldown in days before re-evaluating a pair judged independent/both-valid. Default 14. */\n cooldownDays: number;\n /** When true, pairs judged \"duplicates\" are auto-flagged for dedup (still need user approval). Default false. */\n autoMergeDuplicates: boolean;\n}\n\nexport interface ContradictionLocalizationConfig {\n /** Enable the entity/category anchor pass before QMD search. */\n anchorEnabled: boolean;\n /** Maximum anchor candidates. Zero disables the anchor pass. */\n anchorCandidates: number;\n /** Maximum QMD search candidates. Zero disables text search. */\n searchCandidates: number;\n /** Maximum merged candidates passed to contradiction verification. */\n maxCandidates: number;\n}\n\nexport function parseContradictionScanConfig(raw: unknown): ContradictionScanConfig {\n if (!raw || typeof raw !== \"object\") {\n return {\n enabled: false,\n similarityFloor: 0.82,\n topicOverlapFloor: 0.4,\n maxPairsPerRun: 500,\n cooldownDays: 14,\n autoMergeDuplicates: false,\n };\n }\n const src = raw as Record<string, unknown>;\n const simFloor = coerceNumber(src.similarityFloor) ?? 0.82;\n const topicFloor = coerceNumber(src.topicOverlapFloor) ?? 0.4;\n const maxPairs = coerceNumber(src.maxPairsPerRun) ?? 500;\n const cooldown = coerceNumber(src.cooldownDays) ?? 14;\n return {\n enabled: coerceBool(src.enabled) === true,\n similarityFloor: Math.min(1, Math.max(0, simFloor)),\n topicOverlapFloor: Math.min(1, Math.max(0, topicFloor)),\n maxPairsPerRun: Math.max(1, maxPairs),\n cooldownDays: Math.max(0, cooldown),\n autoMergeDuplicates: coerceBool(src.autoMergeDuplicates) === true,\n };\n}\n\nexport function parseContradictionLocalizationConfig(raw: unknown): ContradictionLocalizationConfig {\n const defaults: ContradictionLocalizationConfig = {\n anchorEnabled: true,\n anchorCandidates: 5,\n searchCandidates: 5,\n maxCandidates: 8,\n };\n if (raw === undefined || raw === null) return defaults;\n if (typeof raw !== \"object\" || Array.isArray(raw)) {\n throw new Error(\"contradictionLocalization must be an object\");\n }\n const src = raw as Record<string, unknown>;\n const rawEnabled = src.anchorEnabled;\n const anchorEnabled = rawEnabled === undefined || rawEnabled === null ? true : coerceBool(rawEnabled);\n if (anchorEnabled === undefined) {\n throw new Error(\"contradictionLocalization.anchorEnabled must be a boolean-like value\");\n }\n\n const parseCap = (\n key: keyof Pick<ContradictionLocalizationConfig, \"anchorCandidates\" | \"searchCandidates\" | \"maxCandidates\">,\n ): number => {\n const rawValue = src[key];\n if (rawValue === undefined) return defaults[key];\n const parsed = coerceNumber(rawValue);\n if (parsed === undefined || !Number.isInteger(parsed) || parsed < 0) {\n throw new Error(`contradictionLocalization.${key} must be an integer >= 0`);\n }\n return parsed;\n };\n\n return {\n anchorEnabled,\n anchorCandidates: parseCap(\"anchorCandidates\"),\n searchCandidates: parseCap(\"searchCandidates\"),\n maxCandidates: parseCap(\"maxCandidates\"),\n };\n}\n"],"mappings":";;;;;;AA6BO,SAAS,6BAA6B,KAAuC;AAClF,MAAI,CAAC,OAAO,OAAO,QAAQ,UAAU;AACnC,WAAO;AAAA,MACL,SAAS;AAAA,MACT,iBAAiB;AAAA,MACjB,mBAAmB;AAAA,MACnB,gBAAgB;AAAA,MAChB,cAAc;AAAA,MACd,qBAAqB;AAAA,IACvB;AAAA,EACF;AACA,QAAM,MAAM;AACZ,QAAM,WAAW,aAAa,IAAI,eAAe,KAAK;AACtD,QAAM,aAAa,aAAa,IAAI,iBAAiB,KAAK;AAC1D,QAAM,WAAW,aAAa,IAAI,cAAc,KAAK;AACrD,QA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