@remnic/core 9.3.719 → 9.3.721
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-boundary.d.ts +10 -7
- package/dist/access-boundary.js +37 -34
- package/dist/access-cli.js +71 -66
- package/dist/access-cli.js.map +1 -1
- package/dist/access-http.d.ts +11 -8
- package/dist/access-http.js +44 -41
- package/dist/access-mcp.d.ts +11 -8
- package/dist/access-mcp.js +40 -37
- package/dist/access-operations-batch.js +38 -35
- package/dist/access-operations.d.ts +11 -8
- package/dist/access-operations.js +39 -36
- package/dist/access-schema.d.ts +19 -19
- package/dist/access-schema.js +3 -3
- package/dist/{access-service-CZbnt0t2.d.ts → access-service-Dj3I-VBS.d.ts} +3 -3
- package/dist/access-service.d.ts +11 -8
- package/dist/access-service.js +36 -33
- package/dist/access-surface-catalog.d.ts +10 -7
- package/dist/action-confidence.d.ts +1 -1
- package/dist/active-memory-bridge.d.ts +1 -1
- package/dist/active-recall.d.ts +1 -1
- package/dist/active-recall.js +4 -2
- package/dist/active-recall.js.map +1 -1
- package/dist/adapters/index.js +7 -7
- package/dist/adapters/registry.js +3 -3
- package/dist/{auto-sync-24NNS3GU.js → auto-sync-F3KCSQFJ.js} +5 -5
- package/dist/behavior-learner.d.ts +1 -1
- package/dist/behavior-signals.d.ts +1 -1
- package/dist/bootstrap.d.ts +11 -8
- package/dist/briefing.d.ts +1 -1
- package/dist/briefing.js +12 -10
- package/dist/buffer-surprise-report.d.ts +1 -1
- package/dist/buffer.d.ts +1 -1
- package/dist/calibration.d.ts +1 -1
- package/dist/calibration.js +2 -2
- package/dist/capabilities.d.ts +30 -2
- package/dist/capabilities.js +3 -1
- package/dist/{catalog-CEYlMs9X.d.ts → catalog-F-OEVbRQ.d.ts} +1 -1
- package/dist/causal-behavior.d.ts +1 -1
- package/dist/causal-behavior.js +2 -2
- package/dist/causal-chain.js +2 -2
- package/dist/causal-consolidation.d.ts +1 -1
- package/dist/causal-consolidation.js +15 -13
- package/dist/causal-consolidation.js.map +1 -1
- package/dist/causal-retrieval.js +2 -2
- package/dist/causal-trajectory-graph.d.ts +4 -0
- package/dist/causal-trajectory-graph.js +2 -2
- package/dist/causal-trajectory.js +1 -1
- package/dist/{chunk-TH7WMHVK.js → chunk-3NN73CM7.js} +2 -2
- package/dist/{chunk-A5TUPZ3N.js → chunk-4SF232E6.js} +60 -30
- package/dist/chunk-4SF232E6.js.map +1 -0
- package/dist/{chunk-DGTDRIUO.js → chunk-4T3BMHKD.js} +2 -2
- package/dist/{chunk-EH27LHML.js → chunk-5O42UKXI.js} +2 -2
- package/dist/{chunk-KRGC4EDX.js → chunk-6FAMMBQ3.js} +2 -2
- package/dist/{chunk-FEB7W5JG.js → chunk-6OIDDKAA.js} +27 -6
- package/dist/chunk-6OIDDKAA.js.map +1 -0
- package/dist/{chunk-67HG7KFE.js → chunk-6YKIYQU7.js} +2 -2
- package/dist/{chunk-LXSG4L55.js → chunk-7CTNUVHZ.js} +2 -2
- package/dist/{chunk-UCJ5CDTK.js → chunk-A5XNBK2D.js} +22 -14
- package/dist/chunk-A5XNBK2D.js.map +1 -0
- package/dist/{chunk-7EEVXW7X.js → chunk-A7TJZLPK.js} +2 -2
- package/dist/{chunk-P5IPFZVH.js → chunk-B7WISIAJ.js} +5 -5
- package/dist/chunk-BCDKBDSY.js +173 -0
- package/dist/chunk-BCDKBDSY.js.map +1 -0
- package/dist/{chunk-JAKYZGV4.js → chunk-BXEOHV7K.js} +3 -3
- package/dist/chunk-C4X4QGIO.js +60 -0
- package/dist/chunk-C4X4QGIO.js.map +1 -0
- package/dist/{chunk-S3OPGGZB.js → chunk-D7EBTQ24.js} +2 -2
- package/dist/{chunk-IO5NQEGZ.js → chunk-DKT3X5C3.js} +2 -2
- package/dist/{chunk-PBH4JUAB.js → chunk-DVRHLN2O.js} +18 -3
- package/dist/chunk-DVRHLN2O.js.map +1 -0
- package/dist/{chunk-S35FX6MU.js → chunk-EBDA5TYA.js} +2 -2
- package/dist/{chunk-2PTBLS2S.js → chunk-EDOQM4E4.js} +2 -2
- package/dist/{chunk-YTZLBBEB.js → chunk-EEJMD2L2.js} +3 -3
- package/dist/{chunk-YGKUAX2B.js → chunk-EHQ5HO5T.js} +11 -11
- package/dist/chunk-EHQ5HO5T.js.map +1 -0
- package/dist/{chunk-JIZGYQYH.js → chunk-EM2LDXJ2.js} +4 -4
- package/dist/{chunk-YYOK4GVF.js → chunk-EVPNWN7Z.js} +10 -10
- package/dist/{chunk-HLIR3RJ7.js → chunk-EXUCUPV2.js} +2 -2
- package/dist/{chunk-F3PVXKHP.js → chunk-GDUOCHCD.js} +27 -21
- package/dist/chunk-GDUOCHCD.js.map +1 -0
- package/dist/{chunk-L5ASZA2F.js → chunk-GJSL4WG2.js} +17 -2
- package/dist/chunk-GJSL4WG2.js.map +1 -0
- package/dist/{chunk-2SXMCQEQ.js → chunk-GZQXOQQ2.js} +3 -3
- package/dist/{chunk-2KAYTPPT.js → chunk-HCVWF657.js} +12 -12
- package/dist/{chunk-N3DUH6OO.js → chunk-ILFSEIRT.js} +1 -1
- package/dist/chunk-ILFSEIRT.js.map +1 -0
- package/dist/{chunk-4KZGLDJJ.js → chunk-J3JPB7ZI.js} +2 -2
- package/dist/{chunk-3JJWNZTT.js → chunk-L2B3EE7B.js} +102 -42
- package/dist/chunk-L2B3EE7B.js.map +1 -0
- package/dist/{chunk-NFRBADNR.js → chunk-LA3HZKES.js} +610 -369
- package/dist/chunk-LA3HZKES.js.map +1 -0
- package/dist/{chunk-LQ6JI4VH.js → chunk-LD53WPMU.js} +4 -4
- package/dist/{chunk-URM3HW2R.js → chunk-LLUGAZ3B.js} +2 -2
- package/dist/{chunk-RVLB4E6N.js → chunk-MDBZTH7N.js} +5 -32
- package/dist/chunk-MDBZTH7N.js.map +1 -0
- package/dist/{chunk-U5H7WHTS.js → chunk-N77ELJ2D.js} +4 -4
- package/dist/{chunk-2VHMVWPU.js → chunk-NXRUUDUF.js} +2 -2
- package/dist/{chunk-DIFU33GU.js → chunk-OHTOPFRF.js} +2 -2
- package/dist/{chunk-74MYJSKB.js → chunk-ORAK3LNZ.js} +2 -2
- package/dist/{chunk-REWQAFSA.js → chunk-PD42EYQN.js} +2 -2
- package/dist/chunk-PHK3HARR.js +32 -0
- package/dist/chunk-PHK3HARR.js.map +1 -0
- package/dist/{chunk-773DPI6T.js → chunk-PKMQK2WY.js} +4 -4
- package/dist/{chunk-72VDBALG.js → chunk-QD6QP5P6.js} +63 -54
- package/dist/chunk-QD6QP5P6.js.map +1 -0
- package/dist/{chunk-CTOQEZSN.js → chunk-QR67FU5G.js} +2 -2
- package/dist/{chunk-AU7Q3LSC.js → chunk-RKNJBZ55.js} +7 -7
- package/dist/{chunk-YI7RZO7Y.js → chunk-SQNED75R.js} +1 -1
- package/dist/{chunk-5CEJH5ZN.js → chunk-TAPSNIMA.js} +4 -4
- package/dist/{chunk-IF362TF6.js → chunk-TQT3USCG.js} +2 -2
- package/dist/chunk-TQT3USCG.js.map +1 -0
- package/dist/{chunk-5RHM43BJ.js → chunk-TXQCG6SE.js} +3 -3
- package/dist/{chunk-ANI5DUAE.js → chunk-UIXXE6NI.js} +7 -7
- package/dist/{chunk-2COL35PK.js → chunk-UO5ZHIIH.js} +2 -2
- package/dist/{chunk-OJU73BUX.js → chunk-VCLGUIFM.js} +2 -2
- package/dist/{chunk-5J4OL7TJ.js → chunk-VUA4S7P6.js} +4 -4
- package/dist/{chunk-A66YRSOS.js → chunk-WQYSDPMA.js} +2 -2
- package/dist/chunk-XGTBNVIU.js +79 -0
- package/dist/chunk-XGTBNVIU.js.map +1 -0
- package/dist/{chunk-OZ2KQ7HF.js → chunk-YEE5KJQQ.js} +2 -2
- package/dist/chunk-YN2UN7N3.js +217 -0
- package/dist/chunk-YN2UN7N3.js.map +1 -0
- package/dist/{chunk-WRFKZEO6.js → chunk-YQGHW5ML.js} +4 -4
- package/dist/{chunk-APUJIMDM.js → chunk-Z4RU5VPM.js} +2 -2
- package/dist/{chunk-DCWIQFNA.js → chunk-ZUDM75KG.js} +4 -4
- package/dist/{cli-1orcdXOY.d.ts → cli-P_GaYcCY.d.ts} +3 -3
- package/dist/cli.d.ts +9 -6
- package/dist/cli.js +67 -63
- package/dist/compounding/engine.d.ts +1 -1
- package/dist/compounding/engine.js +12 -10
- package/dist/compounding/preference-consolidator.d.ts +1 -1
- package/dist/compression-optimizer.d.ts +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.js +4 -2
- package/dist/connectors/codex-materialize-runner.d.ts +1 -1
- package/dist/connectors/codex-materialize-runner.js +12 -10
- package/dist/connectors/codex-materialize.d.ts +1 -1
- package/dist/connectors/index.d.ts +1 -1
- package/dist/connectors/index.js +13 -11
- package/dist/consolidation-provenance-check.d.ts +1 -1
- package/dist/consolidation-undo.d.ts +1 -1
- package/dist/contradiction/index.d.ts +1 -1
- package/dist/conversation-index/backend.d.ts +1 -1
- package/dist/conversation-index/backend.js +2 -2
- package/dist/conversation-index/chunker.d.ts +1 -1
- package/dist/conversation-index/faiss-adapter.d.ts +1 -1
- package/dist/conversation-index/indexer.d.ts +1 -1
- package/dist/conversation-index/search.d.ts +1 -1
- package/dist/day-summary.d.ts +1 -1
- package/dist/delinearize.d.ts +1 -1
- package/dist/direct-answer-wiring.d.ts +1 -1
- package/dist/direct-answer.d.ts +1 -1
- package/dist/embedding-fallback.d.ts +1 -1
- package/dist/enrichment/index.d.ts +1 -1
- package/dist/entity-retrieval.d.ts +1 -1
- package/dist/entity-retrieval.js +12 -10
- package/dist/entity-schema.d.ts +1 -1
- package/dist/explicit-capture.d.ts +11 -8
- package/dist/extraction-faithfulness.d.ts +8 -2
- package/dist/extraction-faithfulness.js +4 -3
- package/dist/extraction-judge-telemetry.d.ts +1 -1
- package/dist/extraction-judge-training.d.ts +1 -1
- package/dist/extraction-judge.d.ts +1 -1
- package/dist/extraction-judge.js +3 -3
- package/dist/extraction.d.ts +1 -1
- package/dist/extraction.js +5 -4
- package/dist/faithfulness-config.d.ts +55 -0
- package/dist/faithfulness-config.js +11 -0
- package/dist/faithfulness-config.js.map +1 -0
- package/dist/fallback-llm.d.ts +1 -1
- package/dist/fallback-llm.js +2 -2
- package/dist/{forget-U66KPDPY.js → forget-OEE5OELK.js} +2 -2
- package/dist/graph-dashboard-diff.d.ts +4 -0
- package/dist/graph-dashboard-key.d.ts +4 -0
- package/dist/graph-dashboard-parser.d.ts +4 -0
- package/dist/{graph-edge-decay-JLOF3YW4.js → graph-edge-decay-QPRJQ7DL.js} +3 -3
- package/dist/graph-edge-reinforcement.d.ts +4 -0
- package/dist/graph-snapshot.d.ts +7 -3
- package/dist/graph-snapshot.js +3 -3
- package/dist/graph.d.ts +7 -1
- package/dist/graph.js +2 -2
- package/dist/identity-continuity.d.ts +1 -1
- package/dist/importance.d.ts +1 -1
- package/dist/index.d.ts +571 -570
- package/dist/index.js +104 -99
- package/dist/index.js.map +1 -1
- package/dist/intent.d.ts +1 -1
- package/dist/lcm/engine.d.ts +1 -1
- package/dist/lcm/engine.js +2 -2
- package/dist/lcm/index.d.ts +1 -1
- package/dist/lcm/index.js +4 -4
- package/dist/lcm/tools.d.ts +1 -1
- package/dist/lifecycle.d.ts +1 -1
- package/dist/live-connectors-runner.d.ts +1 -1
- package/dist/local-llm.d.ts +1 -1
- package/dist/local-model-endpoint.d.ts +96 -0
- package/dist/local-model-endpoint.js +12 -0
- package/dist/local-model-endpoint.js.map +1 -0
- package/dist/maintenance/memory-governance.d.ts +1 -1
- package/dist/maintenance/memory-governance.js +12 -10
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +12 -10
- package/dist/maintenance/rebuild-memory-projection.js +13 -11
- package/dist/mcp-memory-inspector-app.d.ts +11 -8
- package/dist/memory-action-policy.d.ts +1 -1
- package/dist/memory-cache.d.ts +1 -1
- package/dist/memory-lifecycle-ledger-utils.d.ts +1 -1
- package/dist/memory-projection-store.d.ts +1 -1
- package/dist/memory-provenance.d.ts +1 -1
- package/dist/memory-worth-outcomes.d.ts +1 -1
- package/dist/models-json.d.ts +1 -1
- package/dist/namespaces/migrate.d.ts +2 -2
- package/dist/namespaces/migrate.js +22 -20
- package/dist/namespaces/principal.d.ts +1 -1
- package/dist/namespaces/search.d.ts +1 -1
- package/dist/namespaces/search.js +9 -9
- package/dist/namespaces/storage.d.ts +2 -2
- package/dist/namespaces/storage.js +12 -10
- package/dist/native-knowledge.d.ts +1 -1
- package/dist/operator-toolkit.d.ts +3 -2
- package/dist/operator-toolkit.js +32 -28
- package/dist/orchestration/maintenance.d.ts +2 -2
- package/dist/orchestration/maintenance.js +14 -12
- package/dist/{orchestrator-kOxredSr.d.ts → orchestrator-f5xv19kp.d.ts} +178 -81
- package/dist/orchestrator.d.ts +8 -5
- package/dist/orchestrator.js +56 -52
- package/dist/patterns-cli.d.ts +1 -1
- package/dist/policy-runtime.d.ts +1 -1
- package/dist/provenance.d.ts +1 -1
- package/dist/provenance.js +2 -1
- package/dist/qmd-recall-cache.d.ts +1 -1
- package/dist/qmd.d.ts +1 -1
- package/dist/recall-disclosure-escalation.d.ts +1 -1
- package/dist/recall-explain-renderer.d.ts +1 -1
- package/dist/recall-explain-renderer.js +3 -3
- package/dist/recall-planner-llm.d.ts +1 -1
- package/dist/recall-planner-llm.js +2 -2
- package/dist/recall-state.d.ts +1 -1
- package/dist/recall-tag-filter.d.ts +1 -1
- package/dist/recall-xray-cli.d.ts +1 -1
- package/dist/recall-xray-cli.js +4 -4
- package/dist/recall-xray-renderer.d.ts +1 -1
- package/dist/recall-xray-renderer.js +3 -3
- package/dist/recall-xray.d.ts +18 -1
- package/dist/recall-xray.js +2 -2
- package/dist/resolve-auth-token.d.ts +1 -1
- package/dist/resume-bundles.js +5 -3
- package/dist/retrieval-agents.d.ts +1 -1
- package/dist/retrieval-tiers.d.ts +1 -1
- package/dist/routing/engine.d.ts +1 -1
- package/dist/routing/store.d.ts +1 -1
- package/dist/search/embed-helper.d.ts +1 -1
- package/dist/search/factory.d.ts +1 -1
- package/dist/search/factory.js +8 -8
- package/dist/search/index.d.ts +1 -1
- package/dist/search/index.js +14 -14
- package/dist/search/lancedb-backend.d.ts +1 -1
- package/dist/search/lancedb-backend.js +2 -2
- package/dist/search/meilisearch-backend.d.ts +1 -1
- package/dist/search/meilisearch-backend.js +2 -2
- package/dist/search/noop-backend.d.ts +1 -1
- package/dist/search/orama-backend.d.ts +1 -1
- package/dist/search/orama-backend.js +2 -2
- package/dist/search/port.d.ts +1 -1
- package/dist/search/remote-backend.d.ts +1 -1
- package/dist/{semantic-consolidation-B58v3S-a.d.ts → semantic-consolidation-BQm1e1Pn.d.ts} +1 -1
- package/dist/semantic-consolidation.d.ts +2 -2
- package/dist/semantic-consolidation.js +13 -11
- package/dist/semantic-rule-promotion.js +12 -10
- package/dist/semantic-rule-verifier.d.ts +1 -1
- package/dist/semantic-rule-verifier.js +12 -10
- package/dist/session-observer-bands.d.ts +1 -1
- package/dist/session-observer-state.d.ts +1 -1
- package/dist/shared-context/manager.d.ts +1 -1
- package/dist/signal.d.ts +1 -1
- package/dist/storage.d.ts +45 -1
- package/dist/storage.js +11 -9
- package/dist/summarizer.d.ts +1 -1
- package/dist/summarizer.js +3 -3
- package/dist/summary-snapshot.d.ts +1 -1
- package/dist/temporal-supersession.d.ts +1 -1
- package/dist/temporal-validity.d.ts +1 -1
- package/dist/threading.d.ts +1 -1
- package/dist/tier-migration.d.ts +1 -1
- package/dist/tier-routing.d.ts +1 -1
- package/dist/topics.d.ts +1 -1
- package/dist/transcript.d.ts +1 -1
- package/dist/transfer/backup.js +2 -2
- package/dist/transfer/capsule-export.js +2 -2
- package/dist/transfer/capsule-import.js +1 -1
- package/dist/trust-score-stage.d.ts +178 -0
- package/dist/trust-score-stage.js +18 -0
- package/dist/trust-score-stage.js.map +1 -0
- package/dist/trust-score.d.ts +164 -0
- package/dist/trust-score.js +22 -0
- package/dist/trust-score.js.map +1 -0
- package/dist/{types-ACmDOScJ.d.ts → types-DwO1Ot4n.d.ts} +56 -2
- package/dist/types.d.ts +1 -1
- package/dist/types.js +1 -1
- package/dist/utility-runtime.d.ts +1 -1
- package/dist/verified-recall.js +12 -10
- package/package.json +2 -2
- package/src/access-service.ts +8 -5
- package/src/capabilities-cluster-b.test.ts +78 -0
- package/src/capabilities.test.ts +11 -1
- package/src/capabilities.ts +58 -0
- package/src/cli/research-status-commands.ts +7 -3
- package/src/cli.ts +11 -6
- package/src/config.ts +60 -30
- package/src/extraction-faithfulness.test.ts +175 -0
- package/src/extraction-faithfulness.ts +53 -1
- package/src/faithfulness-config.test.ts +96 -0
- package/src/faithfulness-config.ts +138 -0
- package/src/graph-snapshot.ts +3 -3
- package/src/graph.ts +8 -7
- package/src/lifecycle/tombstones.test.ts +242 -1
- package/src/lifecycle/tombstones.ts +157 -70
- package/src/local-model-endpoint.test.ts +155 -0
- package/src/local-model-endpoint.ts +189 -0
- package/src/operator-toolkit.ts +24 -7
- package/src/orchestration/tier-migration-coordinator.ts +286 -0
- package/src/orchestrator.ts +331 -222
- package/src/recall-xray.test.ts +62 -0
- package/src/recall-xray.ts +34 -0
- package/src/trust-score-recall-paths.test.ts +157 -0
- package/src/trust-score-stage.test.ts +350 -0
- package/src/trust-score-stage.ts +398 -0
- package/src/trust-score.test.ts +282 -0
- package/src/trust-score.ts +449 -0
- package/src/types.ts +61 -1
- package/dist/chunk-3JJWNZTT.js.map +0 -1
- package/dist/chunk-72VDBALG.js.map +0 -1
- package/dist/chunk-A5TUPZ3N.js.map +0 -1
- package/dist/chunk-F3PVXKHP.js.map +0 -1
- package/dist/chunk-FEB7W5JG.js.map +0 -1
- package/dist/chunk-IF362TF6.js.map +0 -1
- package/dist/chunk-L5ASZA2F.js.map +0 -1
- package/dist/chunk-N3DUH6OO.js.map +0 -1
- package/dist/chunk-NFRBADNR.js.map +0 -1
- package/dist/chunk-PBH4JUAB.js.map +0 -1
- package/dist/chunk-RVLB4E6N.js.map +0 -1
- package/dist/chunk-UCJ5CDTK.js.map +0 -1
- package/dist/chunk-YGKUAX2B.js.map +0 -1
- /package/dist/{auto-sync-24NNS3GU.js.map → auto-sync-F3KCSQFJ.js.map} +0 -0
- /package/dist/{chunk-TH7WMHVK.js.map → chunk-3NN73CM7.js.map} +0 -0
- /package/dist/{chunk-DGTDRIUO.js.map → chunk-4T3BMHKD.js.map} +0 -0
- /package/dist/{chunk-EH27LHML.js.map → chunk-5O42UKXI.js.map} +0 -0
- /package/dist/{chunk-KRGC4EDX.js.map → chunk-6FAMMBQ3.js.map} +0 -0
- /package/dist/{chunk-67HG7KFE.js.map → chunk-6YKIYQU7.js.map} +0 -0
- /package/dist/{chunk-LXSG4L55.js.map → chunk-7CTNUVHZ.js.map} +0 -0
- /package/dist/{chunk-7EEVXW7X.js.map → chunk-A7TJZLPK.js.map} +0 -0
- /package/dist/{chunk-P5IPFZVH.js.map → chunk-B7WISIAJ.js.map} +0 -0
- /package/dist/{chunk-JAKYZGV4.js.map → chunk-BXEOHV7K.js.map} +0 -0
- /package/dist/{chunk-S3OPGGZB.js.map → chunk-D7EBTQ24.js.map} +0 -0
- /package/dist/{chunk-IO5NQEGZ.js.map → chunk-DKT3X5C3.js.map} +0 -0
- /package/dist/{chunk-S35FX6MU.js.map → chunk-EBDA5TYA.js.map} +0 -0
- /package/dist/{chunk-2PTBLS2S.js.map → chunk-EDOQM4E4.js.map} +0 -0
- /package/dist/{chunk-YTZLBBEB.js.map → chunk-EEJMD2L2.js.map} +0 -0
- /package/dist/{chunk-JIZGYQYH.js.map → chunk-EM2LDXJ2.js.map} +0 -0
- /package/dist/{chunk-YYOK4GVF.js.map → chunk-EVPNWN7Z.js.map} +0 -0
- /package/dist/{chunk-HLIR3RJ7.js.map → chunk-EXUCUPV2.js.map} +0 -0
- /package/dist/{chunk-2SXMCQEQ.js.map → chunk-GZQXOQQ2.js.map} +0 -0
- /package/dist/{chunk-2KAYTPPT.js.map → chunk-HCVWF657.js.map} +0 -0
- /package/dist/{chunk-4KZGLDJJ.js.map → chunk-J3JPB7ZI.js.map} +0 -0
- /package/dist/{chunk-LQ6JI4VH.js.map → chunk-LD53WPMU.js.map} +0 -0
- /package/dist/{chunk-URM3HW2R.js.map → chunk-LLUGAZ3B.js.map} +0 -0
- /package/dist/{chunk-U5H7WHTS.js.map → chunk-N77ELJ2D.js.map} +0 -0
- /package/dist/{chunk-2VHMVWPU.js.map → chunk-NXRUUDUF.js.map} +0 -0
- /package/dist/{chunk-DIFU33GU.js.map → chunk-OHTOPFRF.js.map} +0 -0
- /package/dist/{chunk-74MYJSKB.js.map → chunk-ORAK3LNZ.js.map} +0 -0
- /package/dist/{chunk-REWQAFSA.js.map → chunk-PD42EYQN.js.map} +0 -0
- /package/dist/{chunk-773DPI6T.js.map → chunk-PKMQK2WY.js.map} +0 -0
- /package/dist/{chunk-CTOQEZSN.js.map → chunk-QR67FU5G.js.map} +0 -0
- /package/dist/{chunk-AU7Q3LSC.js.map → chunk-RKNJBZ55.js.map} +0 -0
- /package/dist/{chunk-YI7RZO7Y.js.map → chunk-SQNED75R.js.map} +0 -0
- /package/dist/{chunk-5CEJH5ZN.js.map → chunk-TAPSNIMA.js.map} +0 -0
- /package/dist/{chunk-5RHM43BJ.js.map → chunk-TXQCG6SE.js.map} +0 -0
- /package/dist/{chunk-ANI5DUAE.js.map → chunk-UIXXE6NI.js.map} +0 -0
- /package/dist/{chunk-2COL35PK.js.map → chunk-UO5ZHIIH.js.map} +0 -0
- /package/dist/{chunk-OJU73BUX.js.map → chunk-VCLGUIFM.js.map} +0 -0
- /package/dist/{chunk-5J4OL7TJ.js.map → chunk-VUA4S7P6.js.map} +0 -0
- /package/dist/{chunk-A66YRSOS.js.map → chunk-WQYSDPMA.js.map} +0 -0
- /package/dist/{chunk-OZ2KQ7HF.js.map → chunk-YEE5KJQQ.js.map} +0 -0
- /package/dist/{chunk-WRFKZEO6.js.map → chunk-YQGHW5ML.js.map} +0 -0
- /package/dist/{chunk-APUJIMDM.js.map → chunk-Z4RU5VPM.js.map} +0 -0
- /package/dist/{chunk-DCWIQFNA.js.map → chunk-ZUDM75KG.js.map} +0 -0
- /package/dist/{forget-U66KPDPY.js.map → forget-OEE5OELK.js.map} +0 -0
- /package/dist/{graph-edge-decay-JLOF3YW4.js.map → graph-edge-decay-QPRJQ7DL.js.map} +0 -0
package/src/orchestrator.ts
CHANGED
|
@@ -93,6 +93,7 @@ import {
|
|
|
93
93
|
gatewayTaskChainOptions,
|
|
94
94
|
} from "./fallback-llm.js";
|
|
95
95
|
import { MaintenanceScheduler } from "./orchestration/maintenance.js";
|
|
96
|
+
import { TierMigrationCoordinator } from "./orchestration/tier-migration-coordinator.js";
|
|
96
97
|
import {
|
|
97
98
|
runLiveConnectorsOnce,
|
|
98
99
|
type LiveConnectorsRunSummary,
|
|
@@ -116,6 +117,9 @@ import {
|
|
|
116
117
|
buildMemoryWorthCounterMap,
|
|
117
118
|
type MemoryWorthCounters,
|
|
118
119
|
} from "./memory-worth-filter.js";
|
|
120
|
+
import { applyTrustScoreStage, buildTrustSignalsForRerank, projectTrustForXray } from "./trust-score-stage.js";
|
|
121
|
+
import type { TrustStageResultItem } from "./trust-score-stage.js";
|
|
122
|
+
import { renderEpistemicHedge, type TrustSignals } from "./trust-score.js";
|
|
119
123
|
import { reorderRecallResultsWithMmr } from "./recall-mmr.js";
|
|
120
124
|
import { applyReasoningTraceBoost } from "./reasoning-trace-recall.js";
|
|
121
125
|
import { buildRetrievedMemoryProvenance } from "./memory-provenance.js";
|
|
@@ -1902,6 +1906,7 @@ export class Orchestrator {
|
|
|
1902
1906
|
readonly lastRecall: LastRecallStore;
|
|
1903
1907
|
readonly handleHistory: RecallHandleHistoryStore;
|
|
1904
1908
|
readonly tierMigrationStatus: TierMigrationStatusStore;
|
|
1909
|
+
readonly tierMigrationCoordinator: TierMigrationCoordinator;
|
|
1905
1910
|
/**
|
|
1906
1911
|
* In-memory X-ray snapshot from the most recent `recall()` call that
|
|
1907
1912
|
* was invoked with `xrayCapture: true` (issue #570 PR 1). Scope is
|
|
@@ -1941,6 +1946,18 @@ export class Orchestrator {
|
|
|
1941
1946
|
{ at: number; counters: ReadonlyMap<string, MemoryWorthCounters> }
|
|
1942
1947
|
>();
|
|
1943
1948
|
private static readonly MEMORY_WORTH_CACHE_TTL_MS = 30_000;
|
|
1949
|
+
/**
|
|
1950
|
+
* Issue #1577 — per-namespace TrustScore signal map cache. Same TTL/shape
|
|
1951
|
+
* discipline as {@link memoryWorthCounterCache}: seconds-scale, evicted on
|
|
1952
|
+
* every call, keyed by namespace. Holds the frontmatter-derived signals
|
|
1953
|
+
* (worth, provenance, faithfulness, corroboration, recency) so the trust
|
|
1954
|
+
* stage doesn't trigger a fresh `readAllMemories` scan per query.
|
|
1955
|
+
*/
|
|
1956
|
+
private readonly trustSignalCache = new Map<
|
|
1957
|
+
string,
|
|
1958
|
+
{ at: number; signals: ReadonlyMap<string, TrustSignals> }
|
|
1959
|
+
>();
|
|
1960
|
+
private static readonly TRUST_SIGNAL_CACHE_TTL_MS = 30_000;
|
|
1944
1961
|
/**
|
|
1945
1962
|
* Per-session workspace selections keyed by sessionKey.
|
|
1946
1963
|
* Set by the before_agent_start hook so recall() uses the correct
|
|
@@ -2007,8 +2024,6 @@ export class Orchestrator {
|
|
|
2007
2024
|
private wearablesServiceInstance: WearablesService | null = null;
|
|
2008
2025
|
private wearablesAutoSyncHandle: { stop(): Promise<void> } | null = null;
|
|
2009
2026
|
private lastQmdReprobeAtMs = 0;
|
|
2010
|
-
private tierMigrationInFlight = false;
|
|
2011
|
-
private lastTierMigrationRunAtMs = 0;
|
|
2012
2027
|
private readonly conversationIndexLastUpdateAtMs = new Map<string, number>();
|
|
2013
2028
|
private lastFileHygieneRunAtMs = 0;
|
|
2014
2029
|
// Pattern-reinforcement cadence gate (issue #687 PR 2/4). Tracks the
|
|
@@ -2833,6 +2848,14 @@ export class Orchestrator {
|
|
|
2833
2848
|
maxDepth: config.recallHandleSnapshotDepth,
|
|
2834
2849
|
});
|
|
2835
2850
|
this.tierMigrationStatus = new TierMigrationStatusStore(config.memoryDir);
|
|
2851
|
+
this.tierMigrationCoordinator = new TierMigrationCoordinator({
|
|
2852
|
+
config,
|
|
2853
|
+
getQmd: () => this.qmd,
|
|
2854
|
+
tierMigrationStatus: this.tierMigrationStatus,
|
|
2855
|
+
getUtilityRuntimeValues: () => this.utilityRuntimeValues,
|
|
2856
|
+
getCompounding: () => this.compounding,
|
|
2857
|
+
createColdStorage: (parentDir) => new StorageManager(parentDir),
|
|
2858
|
+
});
|
|
2836
2859
|
this.sessionObserver = new SessionObserverState({
|
|
2837
2860
|
memoryDir: config.memoryDir,
|
|
2838
2861
|
debounceMs: config.sessionObserverDebounceMs ?? 120_000,
|
|
@@ -7267,8 +7290,8 @@ export class Orchestrator {
|
|
|
7267
7290
|
const timings: Record<string, string> = {};
|
|
7268
7291
|
const profileTraceId = this.profiler.startTrace("recall", sessionKey, {
|
|
7269
7292
|
qmdEnabled: this.config.qmdEnabled,
|
|
7270
|
-
rerankEnabled:
|
|
7271
|
-
parallelRetrieval:
|
|
7293
|
+
rerankEnabled: caps.rerank,
|
|
7294
|
+
parallelRetrieval: caps.parallelRetrieval,
|
|
7272
7295
|
});
|
|
7273
7296
|
this.profiler.startSpan("planning", profileTraceId);
|
|
7274
7297
|
let profileTraceClosed = false;
|
|
@@ -7374,6 +7397,23 @@ export class Orchestrator {
|
|
|
7374
7397
|
// per-result explain data (e.g. reinforcementBoost) from the result that
|
|
7375
7398
|
// was actually served.
|
|
7376
7399
|
let xrayRecalledResults: QmdSearchResult[] = [];
|
|
7400
|
+
// Issue #1577 — per-recall trust map (admitted + quarantined items).
|
|
7401
|
+
// A LOCAL, not instance state, so concurrent recalls on the same
|
|
7402
|
+
// orchestrator cannot race on it (review: shared-trust-map concurrency).
|
|
7403
|
+
// Populated by applyTrustScoreRerank on whichever recall path runs;
|
|
7404
|
+
// consumed by formatQmdResults (epistemic hedge), publishRecallResults
|
|
7405
|
+
// (quarantine filtering on ALL paths), and the X-ray capture (trust
|
|
7406
|
+
// projection + quarantined-item visibility — rule 34).
|
|
7407
|
+
let recallTrustByPath: Map<string, TrustStageResultItem> | null = null;
|
|
7408
|
+
// Issue #1577 — sink for the cold-fallback pipeline's trust map. The cold
|
|
7409
|
+
// pipeline scores internally (applyColdFallbackPipeline) and writes its
|
|
7410
|
+
// per-path trust map here; each cold caller reads it back into
|
|
7411
|
+
// recallTrustByPath so cold/embedding/recent paths feed the same X-ray +
|
|
7412
|
+
// epistemic-rendering + publisher-quarantine consumers the hot path uses
|
|
7413
|
+
// (rule 41: the feature gate applies across ALL parallel recall paths).
|
|
7414
|
+
const trustByPathSink: { trustByPath: Map<string, TrustStageResultItem> | null } = {
|
|
7415
|
+
trustByPath: null,
|
|
7416
|
+
};
|
|
7377
7417
|
const lcmStructuredXrayResults: RecallXrayResult[] = [];
|
|
7378
7418
|
// Per-branch pre-limit candidate pool size for the X-ray filter
|
|
7379
7419
|
// trace (issue #570 PR 1). `recalledMemoryCount` is assigned
|
|
@@ -8729,10 +8769,10 @@ export class Orchestrator {
|
|
|
8729
8769
|
(async (): Promise<string | null> => {
|
|
8730
8770
|
const t0 = Date.now();
|
|
8731
8771
|
if (
|
|
8732
|
-
!
|
|
8772
|
+
!caps.harmonicRetrieval ||
|
|
8733
8773
|
!this.isRecallSectionEnabled(
|
|
8734
8774
|
"harmonic-retrieval",
|
|
8735
|
-
|
|
8775
|
+
caps.harmonicRetrieval,
|
|
8736
8776
|
)
|
|
8737
8777
|
) {
|
|
8738
8778
|
recordRecallSectionMetric({
|
|
@@ -9297,7 +9337,7 @@ export class Orchestrator {
|
|
|
9297
9337
|
[ParallelSearchResult[], ParallelSearchResult[]]
|
|
9298
9338
|
> | null =
|
|
9299
9339
|
!queryAwarePrefilterIsEmpty &&
|
|
9300
|
-
|
|
9340
|
+
caps.parallelRetrieval && maxPerAgent > 0
|
|
9301
9341
|
? Promise.all([
|
|
9302
9342
|
shouldRunAgent("direct", retrievalQuery, 0)
|
|
9303
9343
|
? Promise.all(
|
|
@@ -9386,7 +9426,7 @@ export class Orchestrator {
|
|
|
9386
9426
|
: 0;
|
|
9387
9427
|
let augmentedResults = filteredResults;
|
|
9388
9428
|
let maxSpecializedScore = 0;
|
|
9389
|
-
if (
|
|
9429
|
+
if (caps.parallelRetrieval && specializedAgentPromise) {
|
|
9390
9430
|
try {
|
|
9391
9431
|
const [directResults, temporalResults] =
|
|
9392
9432
|
await specializedAgentPromise;
|
|
@@ -11032,7 +11072,7 @@ export class Orchestrator {
|
|
|
11032
11072
|
);
|
|
11033
11073
|
|
|
11034
11074
|
// Optional LLM reranking (default off). Fail-open if rerank fails/slow.
|
|
11035
|
-
if (
|
|
11075
|
+
if (caps.rerank && this.config.rerankProvider === "local") {
|
|
11036
11076
|
const ranked = await rerankLocalOrNoop({
|
|
11037
11077
|
query: retrievalQuery,
|
|
11038
11078
|
candidates: memoryResults
|
|
@@ -11064,24 +11104,26 @@ export class Orchestrator {
|
|
|
11064
11104
|
memoryResults = reordered;
|
|
11065
11105
|
}
|
|
11066
11106
|
}
|
|
11067
|
-
if (
|
|
11107
|
+
if (caps.rerank && this.config.rerankProvider === "cloud") {
|
|
11068
11108
|
log.debug(
|
|
11069
11109
|
"rerankProvider=cloud is reserved/experimental in v2.2.0; skipping rerank",
|
|
11070
11110
|
);
|
|
11071
11111
|
}
|
|
11072
11112
|
|
|
11073
|
-
//
|
|
11074
|
-
//
|
|
11075
|
-
//
|
|
11076
|
-
//
|
|
11077
|
-
//
|
|
11078
|
-
|
|
11079
|
-
|
|
11080
|
-
|
|
11081
|
-
|
|
11082
|
-
|
|
11083
|
-
|
|
11084
|
-
|
|
11113
|
+
// Trust-reweighting stage. TrustScore (issue #1577) SUBSUMES the Memory
|
|
11114
|
+
// Worth multiplier — exactly one runs (rule 39; the double-multiplier
|
|
11115
|
+
// test in trust-score-stage.test.ts pins it structurally). Applied on
|
|
11116
|
+
// EVERY recall path via applyTrustScoreToBranch so the gate is consistent
|
|
11117
|
+
// (rule 41 parity). Fail-open on lookup errors so recall never breaks.
|
|
11118
|
+
{
|
|
11119
|
+
const trustOutcome = await this.applyTrustScoreToBranch(
|
|
11120
|
+
memoryResults,
|
|
11121
|
+
recallNamespaces,
|
|
11122
|
+
caps,
|
|
11123
|
+
"hot-qmd",
|
|
11124
|
+
);
|
|
11125
|
+
memoryResults = trustOutcome.results;
|
|
11126
|
+
recallTrustByPath = trustOutcome.trustByPath;
|
|
11085
11127
|
}
|
|
11086
11128
|
|
|
11087
11129
|
// Synapse-inspired confidence gate: check scores BEFORE slicing so
|
|
@@ -11198,6 +11240,7 @@ export class Orchestrator {
|
|
|
11198
11240
|
injectedChars: identityInjectedChars,
|
|
11199
11241
|
truncated: identityInjectionTruncated,
|
|
11200
11242
|
},
|
|
11243
|
+
trustByPath: recallTrustByPath,
|
|
11201
11244
|
});
|
|
11202
11245
|
recalledMemoryIds = this.extractMemoryIdsFromResults(memoryResults);
|
|
11203
11246
|
recalledMemoryPaths = memoryResults
|
|
@@ -11211,7 +11254,7 @@ export class Orchestrator {
|
|
|
11211
11254
|
// low-relevance results from polluting context.
|
|
11212
11255
|
const queryAwarePrefilter = await queryAwarePrefilterPromise;
|
|
11213
11256
|
if (queryAwarePrefilter.candidatePaths?.size !== 0) {
|
|
11214
|
-
|
|
11257
|
+
let scoped = await awaitAssemblyStep(
|
|
11215
11258
|
"embedding-fallback",
|
|
11216
11259
|
async () => {
|
|
11217
11260
|
const embeddingResults = await this.searchEmbeddingFallback(
|
|
@@ -11254,6 +11297,18 @@ export class Orchestrator {
|
|
|
11254
11297
|
},
|
|
11255
11298
|
[] as QmdSearchResult[],
|
|
11256
11299
|
);
|
|
11300
|
+
// Issue #1577 — apply TrustScore on the embedding-fallback path so the
|
|
11301
|
+
// feature gate is consistent across ALL recall paths (rule 41 parity).
|
|
11302
|
+
{
|
|
11303
|
+
const trustOutcome = await this.applyTrustScoreToBranch(
|
|
11304
|
+
scoped,
|
|
11305
|
+
recallNamespaces,
|
|
11306
|
+
caps,
|
|
11307
|
+
"embedding-fallback",
|
|
11308
|
+
);
|
|
11309
|
+
scoped = trustOutcome.results;
|
|
11310
|
+
recallTrustByPath = trustOutcome.trustByPath;
|
|
11311
|
+
}
|
|
11257
11312
|
if (scoped.length > 0) {
|
|
11258
11313
|
if (shouldPersistGraphSnapshot) {
|
|
11259
11314
|
graphSnapshotFinalResults = this.buildGraphRecallRankedResults(
|
|
@@ -11274,6 +11329,7 @@ export class Orchestrator {
|
|
|
11274
11329
|
injectedChars: identityInjectedChars,
|
|
11275
11330
|
truncated: identityInjectionTruncated,
|
|
11276
11331
|
},
|
|
11332
|
+
trustByPath: recallTrustByPath,
|
|
11277
11333
|
});
|
|
11278
11334
|
recalledMemoryIds = this.extractMemoryIdsFromResults(scoped);
|
|
11279
11335
|
recalledMemoryPaths = scoped
|
|
@@ -11295,10 +11351,15 @@ export class Orchestrator {
|
|
|
11295
11351
|
backendDegradations.push(degradation);
|
|
11296
11352
|
},
|
|
11297
11353
|
xrayPoolSizeSink: xrayColdPoolSink,
|
|
11354
|
+
trustByPathSink,
|
|
11298
11355
|
deadlineAtMs: enrichmentAssemblyDeadlineAtMs,
|
|
11299
11356
|
asOfMs,
|
|
11300
11357
|
...(options.includeLowConfidence === true ? { includeLowConfidence: true } : {}),
|
|
11301
11358
|
});
|
|
11359
|
+
// Issue #1577 — read the cold pipeline's trust map back so cold
|
|
11360
|
+
// results feed X-ray + epistemic rendering + publisher quarantine
|
|
11361
|
+
// filtering (rule 41 parity; review: the sink was never read back).
|
|
11362
|
+
recallTrustByPath = trustByPathSink.trustByPath;
|
|
11302
11363
|
if (longTerm.length > 0) {
|
|
11303
11364
|
if (shouldPersistGraphSnapshot) {
|
|
11304
11365
|
graphSnapshotFinalResults = this.buildGraphRecallRankedResults(
|
|
@@ -11319,6 +11380,7 @@ export class Orchestrator {
|
|
|
11319
11380
|
injectedChars: identityInjectedChars,
|
|
11320
11381
|
truncated: identityInjectionTruncated,
|
|
11321
11382
|
},
|
|
11383
|
+
trustByPath: recallTrustByPath,
|
|
11322
11384
|
});
|
|
11323
11385
|
recalledMemoryIds = this.extractMemoryIdsFromResults(longTerm);
|
|
11324
11386
|
recalledMemoryPaths = longTerm
|
|
@@ -11335,7 +11397,7 @@ export class Orchestrator {
|
|
|
11335
11397
|
this.appendRecallSection(
|
|
11336
11398
|
sectionBuckets,
|
|
11337
11399
|
"workspace-context",
|
|
11338
|
-
this.formatQmdResults("Workspace Context", globalResults, sessionKey),
|
|
11400
|
+
this.formatQmdResults("Workspace Context", globalResults, sessionKey, recallTrustByPath),
|
|
11339
11401
|
);
|
|
11340
11402
|
}
|
|
11341
11403
|
|
|
@@ -11371,7 +11433,7 @@ export class Orchestrator {
|
|
|
11371
11433
|
// Fallback: embeddings first, then recency-only.
|
|
11372
11434
|
const queryAwarePrefilter = await queryAwarePrefilterPromise;
|
|
11373
11435
|
if (queryAwarePrefilter.candidatePaths?.size !== 0) {
|
|
11374
|
-
|
|
11436
|
+
let scoped = await awaitAssemblyStep(
|
|
11375
11437
|
"embedding-fallback",
|
|
11376
11438
|
async () => {
|
|
11377
11439
|
const embeddingResults = await this.searchEmbeddingFallback(
|
|
@@ -11414,6 +11476,18 @@ export class Orchestrator {
|
|
|
11414
11476
|
},
|
|
11415
11477
|
[] as QmdSearchResult[],
|
|
11416
11478
|
);
|
|
11479
|
+
// Issue #1577 — apply TrustScore on the embedding-fallback path so the
|
|
11480
|
+
// feature gate is consistent across ALL recall paths (rule 41 parity).
|
|
11481
|
+
{
|
|
11482
|
+
const trustOutcome = await this.applyTrustScoreToBranch(
|
|
11483
|
+
scoped,
|
|
11484
|
+
recallNamespaces,
|
|
11485
|
+
caps,
|
|
11486
|
+
"embedding-fallback",
|
|
11487
|
+
);
|
|
11488
|
+
scoped = trustOutcome.results;
|
|
11489
|
+
recallTrustByPath = trustOutcome.trustByPath;
|
|
11490
|
+
}
|
|
11417
11491
|
if (scoped.length > 0) {
|
|
11418
11492
|
if (shouldPersistGraphSnapshot) {
|
|
11419
11493
|
graphSnapshotFinalResults = this.buildGraphRecallRankedResults(
|
|
@@ -11434,6 +11508,7 @@ export class Orchestrator {
|
|
|
11434
11508
|
injectedChars: identityInjectedChars,
|
|
11435
11509
|
truncated: identityInjectionTruncated,
|
|
11436
11510
|
},
|
|
11511
|
+
trustByPath: recallTrustByPath,
|
|
11437
11512
|
});
|
|
11438
11513
|
recalledMemoryIds = this.extractMemoryIdsFromResults(scoped);
|
|
11439
11514
|
recalledMemoryPaths = scoped
|
|
@@ -11523,10 +11598,13 @@ export class Orchestrator {
|
|
|
11523
11598
|
backendDegradations.push(degradation);
|
|
11524
11599
|
},
|
|
11525
11600
|
xrayPoolSizeSink: xrayColdPoolSink,
|
|
11601
|
+
trustByPathSink,
|
|
11526
11602
|
deadlineAtMs: enrichmentAssemblyDeadlineAtMs,
|
|
11527
11603
|
asOfMs,
|
|
11528
11604
|
...(options.includeLowConfidence === true ? { includeLowConfidence: true } : {}),
|
|
11529
11605
|
});
|
|
11606
|
+
// Issue #1577 — read the cold pipeline's trust map back (rule 41).
|
|
11607
|
+
recallTrustByPath = trustByPathSink.trustByPath;
|
|
11530
11608
|
if (longTerm.length > 0) {
|
|
11531
11609
|
recallSource = "cold_fallback";
|
|
11532
11610
|
recalledMemoryCount = longTerm.length;
|
|
@@ -11541,6 +11619,7 @@ export class Orchestrator {
|
|
|
11541
11619
|
injectedChars: identityInjectedChars,
|
|
11542
11620
|
truncated: identityInjectionTruncated,
|
|
11543
11621
|
},
|
|
11622
|
+
trustByPath: recallTrustByPath,
|
|
11544
11623
|
});
|
|
11545
11624
|
recalledMemoryIds = this.extractMemoryIdsFromResults(longTerm);
|
|
11546
11625
|
recalledMemoryPaths = longTerm
|
|
@@ -11550,7 +11629,7 @@ export class Orchestrator {
|
|
|
11550
11629
|
impressionRecorded = true;
|
|
11551
11630
|
}
|
|
11552
11631
|
} else {
|
|
11553
|
-
|
|
11632
|
+
let recent = await awaitAssemblyStep(
|
|
11554
11633
|
"recent-memory-scan",
|
|
11555
11634
|
async () => {
|
|
11556
11635
|
const recentSorted = queryAwareScopedMemories.sort(
|
|
@@ -11596,6 +11675,18 @@ export class Orchestrator {
|
|
|
11596
11675
|
},
|
|
11597
11676
|
[] as QmdSearchResult[],
|
|
11598
11677
|
);
|
|
11678
|
+
// Issue #1577 — apply TrustScore on the recent-scan path so the
|
|
11679
|
+
// feature gate is consistent across ALL recall paths (rule 41).
|
|
11680
|
+
{
|
|
11681
|
+
const trustOutcome = await this.applyTrustScoreToBranch(
|
|
11682
|
+
recent,
|
|
11683
|
+
recallNamespaces,
|
|
11684
|
+
caps,
|
|
11685
|
+
"recent-scan",
|
|
11686
|
+
);
|
|
11687
|
+
recent = trustOutcome.results;
|
|
11688
|
+
recallTrustByPath = trustOutcome.trustByPath;
|
|
11689
|
+
}
|
|
11599
11690
|
|
|
11600
11691
|
if (recent.length > 0) {
|
|
11601
11692
|
if (shouldPersistGraphSnapshot) {
|
|
@@ -11617,6 +11708,7 @@ export class Orchestrator {
|
|
|
11617
11708
|
injectedChars: identityInjectedChars,
|
|
11618
11709
|
truncated: identityInjectionTruncated,
|
|
11619
11710
|
},
|
|
11711
|
+
trustByPath: recallTrustByPath,
|
|
11620
11712
|
});
|
|
11621
11713
|
recalledMemoryIds = this.extractMemoryIdsFromResults(recent);
|
|
11622
11714
|
recalledMemoryPaths = recent
|
|
@@ -11638,10 +11730,13 @@ export class Orchestrator {
|
|
|
11638
11730
|
backendDegradations.push(degradation);
|
|
11639
11731
|
},
|
|
11640
11732
|
xrayPoolSizeSink: xrayColdPoolSink,
|
|
11733
|
+
trustByPathSink,
|
|
11641
11734
|
deadlineAtMs: enrichmentAssemblyDeadlineAtMs,
|
|
11642
11735
|
asOfMs,
|
|
11643
11736
|
...(options.includeLowConfidence === true ? { includeLowConfidence: true } : {}),
|
|
11644
11737
|
});
|
|
11738
|
+
// Issue #1577 — read the cold pipeline's trust map back (rule 41).
|
|
11739
|
+
recallTrustByPath = trustByPathSink.trustByPath;
|
|
11645
11740
|
if (longTerm.length > 0) {
|
|
11646
11741
|
if (shouldPersistGraphSnapshot) {
|
|
11647
11742
|
graphSnapshotFinalResults =
|
|
@@ -11663,6 +11758,7 @@ export class Orchestrator {
|
|
|
11663
11758
|
injectedChars: identityInjectedChars,
|
|
11664
11759
|
truncated: identityInjectionTruncated,
|
|
11665
11760
|
},
|
|
11761
|
+
trustByPath: recallTrustByPath,
|
|
11666
11762
|
});
|
|
11667
11763
|
recalledMemoryIds = this.extractMemoryIdsFromResults(longTerm);
|
|
11668
11764
|
recalledMemoryPaths = longTerm
|
|
@@ -11687,10 +11783,13 @@ export class Orchestrator {
|
|
|
11687
11783
|
backendDegradations.push(degradation);
|
|
11688
11784
|
},
|
|
11689
11785
|
xrayPoolSizeSink: xrayColdPoolSink,
|
|
11786
|
+
trustByPathSink,
|
|
11690
11787
|
deadlineAtMs: enrichmentAssemblyDeadlineAtMs,
|
|
11691
11788
|
asOfMs,
|
|
11692
11789
|
...(options.includeLowConfidence === true ? { includeLowConfidence: true } : {}),
|
|
11693
11790
|
});
|
|
11791
|
+
// Issue #1577 — read the cold pipeline's trust map back (rule 41).
|
|
11792
|
+
recallTrustByPath = trustByPathSink.trustByPath;
|
|
11694
11793
|
if (longTerm.length > 0) {
|
|
11695
11794
|
if (shouldPersistGraphSnapshot) {
|
|
11696
11795
|
graphSnapshotFinalResults = this.buildGraphRecallRankedResults(
|
|
@@ -11711,6 +11810,7 @@ export class Orchestrator {
|
|
|
11711
11810
|
injectedChars: identityInjectedChars,
|
|
11712
11811
|
truncated: identityInjectionTruncated,
|
|
11713
11812
|
},
|
|
11813
|
+
trustByPath: recallTrustByPath,
|
|
11714
11814
|
});
|
|
11715
11815
|
recalledMemoryIds = this.extractMemoryIdsFromResults(longTerm);
|
|
11716
11816
|
recalledMemoryPaths = longTerm
|
|
@@ -11981,6 +12081,7 @@ export class Orchestrator {
|
|
|
11981
12081
|
// X-ray capture is best-effort; missing provenance must not
|
|
11982
12082
|
// perturb recall or suppress the surfaced result.
|
|
11983
12083
|
}
|
|
12084
|
+
const trustItem = recallTrustByPath?.get(recalledPath);
|
|
11984
12085
|
results.push({
|
|
11985
12086
|
memoryId: derivedId,
|
|
11986
12087
|
path: recalledPath,
|
|
@@ -11989,8 +12090,30 @@ export class Orchestrator {
|
|
|
11989
12090
|
admittedBy: [],
|
|
11990
12091
|
...(provenance ? { provenance } : {}),
|
|
11991
12092
|
...(sourceSpan ? { sourceSpan } : {}),
|
|
12093
|
+
// Issue #1577 — per-result trust projection for X-ray visibility.
|
|
12094
|
+
...(trustItem ? { trust: projectTrustForXray(trustItem) } : {}),
|
|
11992
12095
|
});
|
|
11993
12096
|
}
|
|
12097
|
+
// Issue #1577 — surface quarantined items in X-ray with their exclusion
|
|
12098
|
+
// reason so operators see WHY a memory was dropped (rule 34 — exclusion
|
|
12099
|
+
// must never look like "no result"). These are NOT in recalledMemoryPaths
|
|
12100
|
+
// (they were excluded from injection) but ARE in the trust map.
|
|
12101
|
+
if (recallTrustByPath) {
|
|
12102
|
+
for (const [qPath, qItem] of recallTrustByPath) {
|
|
12103
|
+
if (!qItem.quarantined || recalledMemoryPaths.includes(qPath)) continue;
|
|
12104
|
+
const qId = idFromPath(qPath);
|
|
12105
|
+
if (!qId) continue;
|
|
12106
|
+
results.push({
|
|
12107
|
+
memoryId: qId,
|
|
12108
|
+
path: qPath,
|
|
12109
|
+
servedBy,
|
|
12110
|
+
scoreDecomposition: { final: 0 },
|
|
12111
|
+
admittedBy: [],
|
|
12112
|
+
rejectedBy: "trust-score:quarantine",
|
|
12113
|
+
trust: projectTrustForXray(qItem),
|
|
12114
|
+
});
|
|
12115
|
+
}
|
|
12116
|
+
}
|
|
11994
12117
|
// `considered` must reflect the pool size of the branch that
|
|
11995
12118
|
// actually produced the admitted results, NOT the max across
|
|
11996
12119
|
// every branch that ran. Otherwise a flow where hot_qmd
|
|
@@ -13751,192 +13874,7 @@ export class Orchestrator {
|
|
|
13751
13874
|
force?: boolean;
|
|
13752
13875
|
},
|
|
13753
13876
|
): Promise<TierMigrationCycleSummary> {
|
|
13754
|
-
|
|
13755
|
-
const persistSkipped = options?.force === true || trigger === "manual";
|
|
13756
|
-
if (!this.config.qmdTierMigrationEnabled && options?.force !== true) {
|
|
13757
|
-
const skipped: TierMigrationCycleSummary = {
|
|
13758
|
-
trigger,
|
|
13759
|
-
scanned: 0,
|
|
13760
|
-
migrated: 0,
|
|
13761
|
-
promoted: 0,
|
|
13762
|
-
demoted: 0,
|
|
13763
|
-
limit: 0,
|
|
13764
|
-
dryRun,
|
|
13765
|
-
skipped: "tier_migration_disabled",
|
|
13766
|
-
};
|
|
13767
|
-
if (persistSkipped) await this.tierMigrationStatus.recordCycle(skipped);
|
|
13768
|
-
return skipped;
|
|
13769
|
-
}
|
|
13770
|
-
if (
|
|
13771
|
-
trigger === "maintenance" &&
|
|
13772
|
-
!this.config.qmdTierAutoBackfillEnabled &&
|
|
13773
|
-
options?.force !== true
|
|
13774
|
-
) {
|
|
13775
|
-
const skipped: TierMigrationCycleSummary = {
|
|
13776
|
-
trigger,
|
|
13777
|
-
scanned: 0,
|
|
13778
|
-
migrated: 0,
|
|
13779
|
-
promoted: 0,
|
|
13780
|
-
demoted: 0,
|
|
13781
|
-
limit: 0,
|
|
13782
|
-
dryRun,
|
|
13783
|
-
skipped: "maintenance_backfill_disabled",
|
|
13784
|
-
};
|
|
13785
|
-
if (persistSkipped) await this.tierMigrationStatus.recordCycle(skipped);
|
|
13786
|
-
return skipped;
|
|
13787
|
-
}
|
|
13788
|
-
if (this.tierMigrationInFlight) {
|
|
13789
|
-
const skipped: TierMigrationCycleSummary = {
|
|
13790
|
-
trigger,
|
|
13791
|
-
scanned: 0,
|
|
13792
|
-
migrated: 0,
|
|
13793
|
-
promoted: 0,
|
|
13794
|
-
demoted: 0,
|
|
13795
|
-
limit: 0,
|
|
13796
|
-
dryRun,
|
|
13797
|
-
skipped: "migration_in_flight",
|
|
13798
|
-
};
|
|
13799
|
-
if (persistSkipped) await this.tierMigrationStatus.recordCycle(skipped);
|
|
13800
|
-
return skipped;
|
|
13801
|
-
}
|
|
13802
|
-
|
|
13803
|
-
const budgetTrigger = trigger === "manual" ? "maintenance" : trigger;
|
|
13804
|
-
const budget =
|
|
13805
|
-
this.compounding?.tierMigrationCycleBudget(budgetTrigger) ??
|
|
13806
|
-
defaultTierMigrationCycleBudget(this.config, budgetTrigger);
|
|
13807
|
-
const limit =
|
|
13808
|
-
options?.limitOverride !== undefined
|
|
13809
|
-
? Math.max(0, Math.floor(options.limitOverride))
|
|
13810
|
-
: budget.limit;
|
|
13811
|
-
const nowMs = Date.now();
|
|
13812
|
-
if (
|
|
13813
|
-
options?.force !== true &&
|
|
13814
|
-
nowMs - this.lastTierMigrationRunAtMs < budget.minIntervalMs
|
|
13815
|
-
) {
|
|
13816
|
-
const skipped: TierMigrationCycleSummary = {
|
|
13817
|
-
trigger,
|
|
13818
|
-
scanned: 0,
|
|
13819
|
-
migrated: 0,
|
|
13820
|
-
promoted: 0,
|
|
13821
|
-
demoted: 0,
|
|
13822
|
-
limit,
|
|
13823
|
-
dryRun,
|
|
13824
|
-
skipped: "min_interval",
|
|
13825
|
-
};
|
|
13826
|
-
if (persistSkipped) await this.tierMigrationStatus.recordCycle(skipped);
|
|
13827
|
-
return skipped;
|
|
13828
|
-
}
|
|
13829
|
-
|
|
13830
|
-
const policy = applyUtilityPromotionRuntimePolicy(
|
|
13831
|
-
{
|
|
13832
|
-
enabled: this.config.qmdTierMigrationEnabled,
|
|
13833
|
-
demotionMinAgeDays: this.config.qmdTierDemotionMinAgeDays,
|
|
13834
|
-
demotionValueThreshold: this.config.qmdTierDemotionValueThreshold,
|
|
13835
|
-
promotionValueThreshold: this.config.qmdTierPromotionValueThreshold,
|
|
13836
|
-
},
|
|
13837
|
-
this.utilityRuntimeValues,
|
|
13838
|
-
);
|
|
13839
|
-
|
|
13840
|
-
this.tierMigrationInFlight = true;
|
|
13841
|
-
try {
|
|
13842
|
-
const coldStorage = new StorageManager(path.join(storage.dir, "cold"));
|
|
13843
|
-
const [hotMemories, coldMemories] = await Promise.all([
|
|
13844
|
-
storage.readAllMemories(),
|
|
13845
|
-
coldStorage.readAllMemories(),
|
|
13846
|
-
]);
|
|
13847
|
-
const now = new Date();
|
|
13848
|
-
const scanLimit = Math.max(0, Math.floor(budget.scanLimit));
|
|
13849
|
-
const hotScanLimit = Math.min(
|
|
13850
|
-
hotMemories.length,
|
|
13851
|
-
Math.ceil(scanLimit * 0.75),
|
|
13852
|
-
);
|
|
13853
|
-
const coldScanLimit = Math.min(
|
|
13854
|
-
coldMemories.length,
|
|
13855
|
-
Math.max(0, scanLimit - hotScanLimit),
|
|
13856
|
-
);
|
|
13857
|
-
const toTimestamp = (memory: MemoryFile): number =>
|
|
13858
|
-
Date.parse(memory.frontmatter.updated ?? memory.frontmatter.created);
|
|
13859
|
-
const hotCandidates = hotMemories
|
|
13860
|
-
.map((memory) => ({ memory, tier: "hot" as MemoryTier }))
|
|
13861
|
-
.sort((a, b) => toTimestamp(a.memory) - toTimestamp(b.memory))
|
|
13862
|
-
.slice(0, hotScanLimit);
|
|
13863
|
-
const coldCandidates = coldMemories
|
|
13864
|
-
.map((memory) => ({ memory, tier: "cold" as MemoryTier }))
|
|
13865
|
-
.sort((a, b) => toTimestamp(b.memory) - toTimestamp(a.memory))
|
|
13866
|
-
.slice(0, coldScanLimit);
|
|
13867
|
-
const candidates = [...hotCandidates, ...coldCandidates];
|
|
13868
|
-
|
|
13869
|
-
const migration = new TierMigrationExecutor({
|
|
13870
|
-
storage,
|
|
13871
|
-
qmd: this.qmd,
|
|
13872
|
-
hotCollection: this.config.qmdCollection,
|
|
13873
|
-
coldCollection:
|
|
13874
|
-
this.config.qmdColdCollection ?? `${this.config.qmdCollection}-cold`,
|
|
13875
|
-
autoEmbed: this.config.qmdAutoEmbedEnabled,
|
|
13876
|
-
});
|
|
13877
|
-
|
|
13878
|
-
let migrated = 0;
|
|
13879
|
-
let promoted = 0;
|
|
13880
|
-
let demoted = 0;
|
|
13881
|
-
for (const candidate of candidates) {
|
|
13882
|
-
if (migrated >= limit) break;
|
|
13883
|
-
const decision = decideTierTransition(
|
|
13884
|
-
candidate.memory,
|
|
13885
|
-
candidate.tier,
|
|
13886
|
-
policy,
|
|
13887
|
-
now,
|
|
13888
|
-
);
|
|
13889
|
-
if (!decision.changed) continue;
|
|
13890
|
-
|
|
13891
|
-
if (!dryRun) {
|
|
13892
|
-
const res = await migration.migrateMemory({
|
|
13893
|
-
memory: candidate.memory,
|
|
13894
|
-
fromTier: candidate.tier,
|
|
13895
|
-
toTier: decision.nextTier,
|
|
13896
|
-
reason: `${trigger}:${decision.reason}`,
|
|
13897
|
-
});
|
|
13898
|
-
if (!res.changed) continue;
|
|
13899
|
-
}
|
|
13900
|
-
migrated += 1;
|
|
13901
|
-
if (decision.nextTier === "cold") demoted += 1;
|
|
13902
|
-
if (decision.nextTier === "hot") promoted += 1;
|
|
13903
|
-
}
|
|
13904
|
-
|
|
13905
|
-
if (!dryRun) this.lastTierMigrationRunAtMs = Date.now();
|
|
13906
|
-
log.debug(
|
|
13907
|
-
`tier migration cycle completed: trigger=${trigger} scanned=${candidates.length} migrated=${migrated} limit=${limit}${dryRun ? " dryRun=true" : ""}`,
|
|
13908
|
-
);
|
|
13909
|
-
const summary: TierMigrationCycleSummary = {
|
|
13910
|
-
trigger,
|
|
13911
|
-
scanned: candidates.length,
|
|
13912
|
-
migrated,
|
|
13913
|
-
promoted,
|
|
13914
|
-
demoted,
|
|
13915
|
-
limit,
|
|
13916
|
-
dryRun,
|
|
13917
|
-
};
|
|
13918
|
-
const shouldPersistCycle = trigger === "manual" || migrated > 0;
|
|
13919
|
-
if (shouldPersistCycle)
|
|
13920
|
-
await this.tierMigrationStatus.recordCycle(summary);
|
|
13921
|
-
return summary;
|
|
13922
|
-
} catch (err) {
|
|
13923
|
-
this.lastTierMigrationRunAtMs = Date.now();
|
|
13924
|
-
log.warn(`tier migration cycle failed (${trigger}, fail-open): ${err}`);
|
|
13925
|
-
const failed: TierMigrationCycleSummary = {
|
|
13926
|
-
trigger,
|
|
13927
|
-
scanned: 0,
|
|
13928
|
-
migrated: 0,
|
|
13929
|
-
promoted: 0,
|
|
13930
|
-
demoted: 0,
|
|
13931
|
-
limit,
|
|
13932
|
-
dryRun,
|
|
13933
|
-
errorCount: 1,
|
|
13934
|
-
};
|
|
13935
|
-
await this.tierMigrationStatus.recordCycle(failed);
|
|
13936
|
-
return failed;
|
|
13937
|
-
} finally {
|
|
13938
|
-
this.tierMigrationInFlight = false;
|
|
13939
|
-
}
|
|
13877
|
+
return this.tierMigrationCoordinator.runCycle(storage, trigger, options);
|
|
13940
13878
|
}
|
|
13941
13879
|
|
|
13942
13880
|
async getTierMigrationStatus(): Promise<TierMigrationStatusSnapshot> {
|
|
@@ -16283,6 +16221,7 @@ export class Orchestrator {
|
|
|
16283
16221
|
storage: StorageManager,
|
|
16284
16222
|
persistedIds: string[],
|
|
16285
16223
|
): Promise<void> {
|
|
16224
|
+
const caps = resolveCapabilities(this.config); // #1566 Cluster C
|
|
16286
16225
|
// Build temporal/tag indexes whenever either consumer is enabled:
|
|
16287
16226
|
// - queryAwareIndexingEnabled: uses indexes for query-aware prefiltering in recall
|
|
16288
16227
|
// - parallelRetrievalEnabled: temporal agent reads index_time.json for date-range lookup
|
|
@@ -16290,7 +16229,7 @@ export class Orchestrator {
|
|
|
16290
16229
|
// produce an empty temporal index, leaving the temporal agent with no data to work from.
|
|
16291
16230
|
if (
|
|
16292
16231
|
!this.config.queryAwareIndexingEnabled &&
|
|
16293
|
-
!
|
|
16232
|
+
!caps.parallelRetrieval
|
|
16294
16233
|
)
|
|
16295
16234
|
return;
|
|
16296
16235
|
// Check for missing indexes BEFORE the early-return so first-time enablement
|
|
@@ -17719,6 +17658,7 @@ export class Orchestrator {
|
|
|
17719
17658
|
title: string,
|
|
17720
17659
|
results: QmdSearchResult[],
|
|
17721
17660
|
sessionKey?: string,
|
|
17661
|
+
trustByPath?: Map<string, TrustStageResultItem> | null,
|
|
17722
17662
|
): string {
|
|
17723
17663
|
// Issue #1582 — handles are only rendered when a session key is available:
|
|
17724
17664
|
// resolution requires the handle history to have been recorded for this
|
|
@@ -17729,6 +17669,13 @@ export class Orchestrator {
|
|
|
17729
17669
|
results,
|
|
17730
17670
|
this.config.recallMemoryHandles === true && sessionKey != null,
|
|
17731
17671
|
);
|
|
17672
|
+
// Issue #1577 — epistemic hedge. Append a deterministic, component-derived
|
|
17673
|
+
// suffix so the downstream model knows each memory's trust status (the
|
|
17674
|
+
// cheap lever against confident-stale-answer failures). Gated separately
|
|
17675
|
+
// from scoring so rendering can ship after the stage is stable. High-band
|
|
17676
|
+
// and neutral items get no suffix (don't waste tokens on the common case).
|
|
17677
|
+
const renderHedge = this.config.trustScoreEpistemicRendering && trustByPath !== null && trustByPath !== undefined;
|
|
17678
|
+
const hedgeMap = renderHedge ? trustByPath : null;
|
|
17732
17679
|
const lines = results.map((r, i) => {
|
|
17733
17680
|
const snippet = r.snippet
|
|
17734
17681
|
? r.snippet.slice(0, 500).replace(/\n/g, " ")
|
|
@@ -17736,7 +17683,16 @@ export class Orchestrator {
|
|
|
17736
17683
|
const source = typeof r.line === "number" ? `${r.path}:${r.line}` : r.path;
|
|
17737
17684
|
const head = `[${i + 1}] ${source} (score: ${r.score.toFixed(3)})\n${snippet}`;
|
|
17738
17685
|
const handle = handleByIndex.get(i);
|
|
17739
|
-
|
|
17686
|
+
const hedged = head.replace(/\s+$/, "");
|
|
17687
|
+
const withHandle = handle ? `${hedged} ${handle}` : hedged;
|
|
17688
|
+
if (hedgeMap) {
|
|
17689
|
+
const item = hedgeMap.get(r.path);
|
|
17690
|
+
if (item) {
|
|
17691
|
+
const hedge = renderEpistemicHedge(item.trust);
|
|
17692
|
+
if (hedge.length > 0) return `${withHandle} ${hedge}`;
|
|
17693
|
+
}
|
|
17694
|
+
}
|
|
17695
|
+
return withHandle;
|
|
17740
17696
|
});
|
|
17741
17697
|
return `## ${title}\n\n${lines.join("\n\n")}`;
|
|
17742
17698
|
}
|
|
@@ -18093,15 +18049,30 @@ export class Orchestrator {
|
|
|
18093
18049
|
injectedChars: number;
|
|
18094
18050
|
truncated: boolean;
|
|
18095
18051
|
};
|
|
18052
|
+
/**
|
|
18053
|
+
* Issue #1577 — per-recall trust map. When present, quarantined items
|
|
18054
|
+
* are filtered from injection on EVERY recall path (hot QMD, embedding
|
|
18055
|
+
* fallback, cold archive, recent) so a faithfulness-contradicted memory
|
|
18056
|
+
* cannot sneak in via a branch that bypasses trust scoring (review:
|
|
18057
|
+
* fallback paths bypass trust). The map is also threaded to
|
|
18058
|
+
* formatQmdResults for the epistemic hedge.
|
|
18059
|
+
*/
|
|
18060
|
+
trustByPath?: Map<string, TrustStageResultItem> | null;
|
|
18096
18061
|
}): void {
|
|
18097
18062
|
const sectionId = "memories";
|
|
18098
|
-
|
|
18063
|
+
// Filter quarantined items from ALL recall paths so no branch can inject
|
|
18064
|
+
// a hard-negative memory that trust scoring excluded on another path.
|
|
18065
|
+
const trustByPath = options.trustByPath ?? null;
|
|
18066
|
+
const injectable = trustByPath
|
|
18067
|
+
? options.results.filter((r) => !trustByPath.get(r.path)?.quarantined)
|
|
18068
|
+
: options.results;
|
|
18069
|
+
const memoryIds = this.extractMemoryIdsFromResults(injectable);
|
|
18099
18070
|
this.trackMemoryAccess(memoryIds);
|
|
18100
18071
|
|
|
18101
18072
|
this.appendRecallSection(
|
|
18102
18073
|
options.sectionBuckets,
|
|
18103
18074
|
sectionId,
|
|
18104
|
-
this.formatQmdResults(options.title,
|
|
18075
|
+
this.formatQmdResults(options.title, injectable, options.sessionKey, trustByPath),
|
|
18105
18076
|
);
|
|
18106
18077
|
}
|
|
18107
18078
|
|
|
@@ -18522,6 +18493,125 @@ export class Orchestrator {
|
|
|
18522
18493
|
return reordered;
|
|
18523
18494
|
}
|
|
18524
18495
|
|
|
18496
|
+
/**
|
|
18497
|
+
* Issue #1577 — unified TrustScore recall stage. Thin wiring over the pure
|
|
18498
|
+
* {@link applyTrustScoreStage} scorer + the {@link buildTrustSignalsForRerank}
|
|
18499
|
+
* signal builder. The stage subsumes the Memory Worth multiplier — the
|
|
18500
|
+
* orchestrator runs exactly one of the two (mutual exclusion, rule 39; the
|
|
18501
|
+
* double-multiplier test in trust-score-stage.test.ts pins it structurally).
|
|
18502
|
+
*
|
|
18503
|
+
* Returns the admitted results AND the per-path trust map (including
|
|
18504
|
+
* quarantined items) so the caller can: (a) render epistemic hedges, (b)
|
|
18505
|
+
* surface quarantined items in X-ray with a reason (rule 34), and (c) filter
|
|
18506
|
+
* quarantined paths from fallback recall branches. The trust map is a
|
|
18507
|
+
* per-recall local — never instance state — so concurrent recalls cannot
|
|
18508
|
+
* race on it (review: shared-trust-map concurrency).
|
|
18509
|
+
*/
|
|
18510
|
+
private async applyTrustScoreRerank(
|
|
18511
|
+
results: QmdSearchResult[],
|
|
18512
|
+
namespaces: string[],
|
|
18513
|
+
): Promise<{
|
|
18514
|
+
results: QmdSearchResult[];
|
|
18515
|
+
trustByPath: Map<string, TrustStageResultItem> | null;
|
|
18516
|
+
}> {
|
|
18517
|
+
if (results.length === 0) return { results, trustByPath: null };
|
|
18518
|
+
const now = new Date();
|
|
18519
|
+
const halfLifeDays =
|
|
18520
|
+
this.config.recallMemoryWorthHalfLifeMs > 0
|
|
18521
|
+
? this.config.recallMemoryWorthHalfLifeMs / (24 * 60 * 60 * 1000)
|
|
18522
|
+
: undefined;
|
|
18523
|
+
// Cold-tier direct-fallback reader: resolve once, reuse for every missing
|
|
18524
|
+
// candidate (mirrors the memory-worth filter's reader selection).
|
|
18525
|
+
let fallbackReader: StorageManager | null = null;
|
|
18526
|
+
const signals = await buildTrustSignalsForRerank(
|
|
18527
|
+
results.map((r) => r.path),
|
|
18528
|
+
namespaces,
|
|
18529
|
+
{
|
|
18530
|
+
readNamespaceMemories: async (ns) => (await this.getStorage(ns)).readAllMemories(),
|
|
18531
|
+
readMemoryFrontmatter: async (path) => {
|
|
18532
|
+
if (!fallbackReader) {
|
|
18533
|
+
for (const ns of namespaces) {
|
|
18534
|
+
try {
|
|
18535
|
+
fallbackReader = await this.getStorage(ns);
|
|
18536
|
+
break;
|
|
18537
|
+
} catch {
|
|
18538
|
+
// try next namespace
|
|
18539
|
+
}
|
|
18540
|
+
}
|
|
18541
|
+
}
|
|
18542
|
+
if (!fallbackReader) return null;
|
|
18543
|
+
const memory = await this.readQmdResultMemory(path, fallbackReader, namespaces);
|
|
18544
|
+
return memory ? memory.frontmatter : null;
|
|
18545
|
+
},
|
|
18546
|
+
},
|
|
18547
|
+
{ cache: this.trustSignalCache, ttlMs: Orchestrator.TRUST_SIGNAL_CACHE_TTL_MS },
|
|
18548
|
+
now,
|
|
18549
|
+
{
|
|
18550
|
+
recencyHalfLifeDays: halfLifeDays,
|
|
18551
|
+
logDebug: (message, context) => log.debug(message, context),
|
|
18552
|
+
},
|
|
18553
|
+
);
|
|
18554
|
+
if (signals.size === 0) {
|
|
18555
|
+
return { results, trustByPath: null };
|
|
18556
|
+
}
|
|
18557
|
+
// Synthetic monotone-decreasing rank so the multiplier rebias is applied
|
|
18558
|
+
// on top of upstream ordering, not raw QMD scores (see applyMemoryWorthRerank).
|
|
18559
|
+
const rankedInputs = results.map((r, i) => ({ path: r.path, score: results.length - i }));
|
|
18560
|
+
const stage = applyTrustScoreStage(rankedInputs, {
|
|
18561
|
+
signals,
|
|
18562
|
+
weights: this.config.trustScoreWeights,
|
|
18563
|
+
minMultiplier: this.config.trustScoreMinMultiplier,
|
|
18564
|
+
maxMultiplier: this.config.trustScoreMaxMultiplier,
|
|
18565
|
+
quarantine: this.config.trustScoreQuarantine,
|
|
18566
|
+
});
|
|
18567
|
+
const trustByPath = new Map(stage.all.map((item) => [item.path, item]));
|
|
18568
|
+
const byPath = new Map(results.map((r) => [r.path, r]));
|
|
18569
|
+
const admitted = stage.admitted
|
|
18570
|
+
.map((item) => byPath.get(item.path))
|
|
18571
|
+
.filter((r): r is QmdSearchResult => r !== undefined);
|
|
18572
|
+
return { results: admitted, trustByPath };
|
|
18573
|
+
}
|
|
18574
|
+
|
|
18575
|
+
/**
|
|
18576
|
+
* Issue #1577 — apply the TrustScore stage (or, when trust is off, the Memory
|
|
18577
|
+
* Worth multiplier fallback) to ONE recall branch's results, returning the
|
|
18578
|
+
* scored results + the per-path trust map. Thin wiring over
|
|
18579
|
+
* {@link applyTrustScoreRerank} so every recall path — hot QMD, embedding
|
|
18580
|
+
* fallback, recent scan — applies the SAME multiplier gate (rule 41: a
|
|
18581
|
+
* feature gate must apply across ALL parallel recall paths). TrustScore
|
|
18582
|
+
* subsumes Memory Worth; exactly one runs (rule 39). Fail-open on lookup
|
|
18583
|
+
* errors so a storage hiccup never breaks a fallback path.
|
|
18584
|
+
*/
|
|
18585
|
+
private async applyTrustScoreToBranch(
|
|
18586
|
+
results: QmdSearchResult[],
|
|
18587
|
+
namespaces: string[],
|
|
18588
|
+
caps: CapabilitySet,
|
|
18589
|
+
label: string,
|
|
18590
|
+
): Promise<{
|
|
18591
|
+
results: QmdSearchResult[];
|
|
18592
|
+
trustByPath: Map<string, TrustStageResultItem> | null;
|
|
18593
|
+
}> {
|
|
18594
|
+
if (caps.recallTrustScore && results.length > 0) {
|
|
18595
|
+
try {
|
|
18596
|
+
return await this.applyTrustScoreRerank(results, namespaces);
|
|
18597
|
+
} catch (err) {
|
|
18598
|
+
log.debug(`trust-score stage (${label}) failed open`, {
|
|
18599
|
+
error: (err as Error).message,
|
|
18600
|
+
});
|
|
18601
|
+
}
|
|
18602
|
+
} else if (caps.recallMemoryWorthFilter && results.length > 0) {
|
|
18603
|
+
try {
|
|
18604
|
+
const filtered = await this.applyMemoryWorthRerank(results, namespaces);
|
|
18605
|
+
return { results: filtered, trustByPath: null };
|
|
18606
|
+
} catch (err) {
|
|
18607
|
+
log.debug(`memory-worth filter (${label}) failed open`, {
|
|
18608
|
+
error: (err as Error).message,
|
|
18609
|
+
});
|
|
18610
|
+
}
|
|
18611
|
+
}
|
|
18612
|
+
return { results, trustByPath: null };
|
|
18613
|
+
}
|
|
18614
|
+
|
|
18525
18615
|
private diversifyAndLimitRecallResults(
|
|
18526
18616
|
sectionId: string,
|
|
18527
18617
|
results: QmdSearchResult[],
|
|
@@ -18896,6 +18986,14 @@ export class Orchestrator {
|
|
|
18896
18986
|
* Unset by default so existing call sites are unaffected.
|
|
18897
18987
|
*/
|
|
18898
18988
|
xrayPoolSizeSink?: { size: number };
|
|
18989
|
+
/**
|
|
18990
|
+
* Issue #1577 — out-parameter that receives the TrustScore stage's
|
|
18991
|
+
* per-path trust map (admitted + quarantined) when the cold path runs
|
|
18992
|
+
* trust scoring. Mirrors the xrayPoolSizeSink pattern so recallInternal
|
|
18993
|
+
can propagate trust data for epistemic rendering and X-ray visibility
|
|
18994
|
+
without changing the cold pipeline's return type.
|
|
18995
|
+
*/
|
|
18996
|
+
trustByPathSink?: { trustByPath: Map<string, TrustStageResultItem> | null };
|
|
18899
18997
|
deadlineAtMs?: number | null;
|
|
18900
18998
|
/** Issue #681 — when true, bypass graphTraversalConfidenceFloor. */
|
|
18901
18999
|
includeLowConfidence?: boolean;
|
|
@@ -19201,7 +19299,7 @@ export class Orchestrator {
|
|
|
19201
19299
|
log.debug("cold-tier recall boost skipped: shared assembly deadline already expired");
|
|
19202
19300
|
}
|
|
19203
19301
|
|
|
19204
|
-
if (
|
|
19302
|
+
if (caps.rerank && this.config.rerankProvider === "local") {
|
|
19205
19303
|
const ranked = await rerankLocalOrNoop({
|
|
19206
19304
|
query: options.prompt,
|
|
19207
19305
|
candidates: results
|
|
@@ -19232,16 +19330,27 @@ export class Orchestrator {
|
|
|
19232
19330
|
results = reordered;
|
|
19233
19331
|
}
|
|
19234
19332
|
}
|
|
19235
|
-
if (
|
|
19333
|
+
if (caps.rerank && this.config.rerankProvider === "cloud") {
|
|
19236
19334
|
log.debug(
|
|
19237
19335
|
"rerankProvider=cloud is reserved/experimental in v2.2.0; skipping rerank",
|
|
19238
19336
|
);
|
|
19239
19337
|
}
|
|
19240
19338
|
|
|
19241
|
-
//
|
|
19242
|
-
// feature flag produces divergent behavior by retrieval path (
|
|
19243
|
-
//
|
|
19244
|
-
|
|
19339
|
+
// Trust-reweighting — must fire on the cold fallback path too, or the
|
|
19340
|
+
// feature flag produces divergent behavior by retrieval path (rule 39).
|
|
19341
|
+
// TrustScore subsumes the Memory Worth multiplier; run exactly one.
|
|
19342
|
+
// Fail-open on lookup errors.
|
|
19343
|
+
if (caps.recallTrustScore && results.length > 0) {
|
|
19344
|
+
try {
|
|
19345
|
+
const trustOutcome = await this.applyTrustScoreRerank(results, options.recallNamespaces);
|
|
19346
|
+
results = trustOutcome.results;
|
|
19347
|
+
if (options.trustByPathSink) options.trustByPathSink.trustByPath = trustOutcome.trustByPath;
|
|
19348
|
+
} catch (err) {
|
|
19349
|
+
log.debug("trust-score stage (cold) failed open", {
|
|
19350
|
+
error: (err as Error).message,
|
|
19351
|
+
});
|
|
19352
|
+
}
|
|
19353
|
+
} else if (caps.recallMemoryWorthFilter && results.length > 0) {
|
|
19245
19354
|
try {
|
|
19246
19355
|
results = await this.applyMemoryWorthRerank(results, options.recallNamespaces);
|
|
19247
19356
|
} catch (err) {
|