@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
|
@@ -4,16 +4,16 @@ import {
|
|
|
4
4
|
loadSyncState,
|
|
5
5
|
syncWearableSource,
|
|
6
6
|
wearableSourceLabel
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-4T3BMHKD.js";
|
|
8
8
|
import {
|
|
9
9
|
MaintenanceScheduler
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-Z4RU5VPM.js";
|
|
11
11
|
import {
|
|
12
12
|
migrateFromEngram
|
|
13
13
|
} from "./chunk-7HYPN2GC.js";
|
|
14
14
|
import {
|
|
15
15
|
LcmEngine
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-PKMQK2WY.js";
|
|
17
17
|
import {
|
|
18
18
|
chunkTranscriptEntries
|
|
19
19
|
} from "./chunk-TECVW3JP.js";
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
import {
|
|
24
24
|
CompoundingEngine,
|
|
25
25
|
defaultTierMigrationCycleBudget
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-WQYSDPMA.js";
|
|
27
27
|
import {
|
|
28
28
|
SharedContextManager
|
|
29
29
|
} from "./chunk-UFS7OXGL.js";
|
|
@@ -32,6 +32,12 @@ import {
|
|
|
32
32
|
applyUtilityRankingRuntimeDelta,
|
|
33
33
|
loadUtilityRuntimeValues
|
|
34
34
|
} from "./chunk-LXOM6IQU.js";
|
|
35
|
+
import {
|
|
36
|
+
TierMigrationExecutor
|
|
37
|
+
} from "./chunk-VOUOLGIP.js";
|
|
38
|
+
import {
|
|
39
|
+
decideTierTransition
|
|
40
|
+
} from "./chunk-S75M5ZRK.js";
|
|
35
41
|
import {
|
|
36
42
|
TmtBuilder
|
|
37
43
|
} from "./chunk-ECZU5BJH.js";
|
|
@@ -39,38 +45,26 @@ import {
|
|
|
39
45
|
extractTopics
|
|
40
46
|
} from "./chunk-UHGBNIOS.js";
|
|
41
47
|
import {
|
|
42
|
-
|
|
43
|
-
|
|
48
|
+
applyTrustScoreStage,
|
|
49
|
+
buildTrustSignalsForRerank,
|
|
50
|
+
projectTrustForXray
|
|
51
|
+
} from "./chunk-BCDKBDSY.js";
|
|
44
52
|
import {
|
|
45
|
-
|
|
46
|
-
} from "./chunk-
|
|
47
|
-
import {
|
|
48
|
-
decideTierTransition
|
|
49
|
-
} from "./chunk-S75M5ZRK.js";
|
|
50
|
-
import {
|
|
51
|
-
HourlySummarizer
|
|
52
|
-
} from "./chunk-IO5NQEGZ.js";
|
|
53
|
+
renderEpistemicHedge
|
|
54
|
+
} from "./chunk-YN2UN7N3.js";
|
|
53
55
|
import {
|
|
54
56
|
buildTargetedFactRecallSection,
|
|
55
57
|
shouldRecallTargetedFactEvidence
|
|
56
58
|
} from "./chunk-4SBW47WK.js";
|
|
57
59
|
import {
|
|
58
|
-
|
|
59
|
-
} from "./chunk-
|
|
60
|
-
import {
|
|
61
|
-
applyRuntimeRetrievalPolicy
|
|
62
|
-
} from "./chunk-5IZL4DCV.js";
|
|
63
|
-
import {
|
|
64
|
-
RelevanceStore
|
|
65
|
-
} from "./chunk-GG6AJN7A.js";
|
|
60
|
+
CODEX_THREAD_KEY_PREFIX
|
|
61
|
+
} from "./chunk-4EX5WZ4M.js";
|
|
66
62
|
import {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
} from "./chunk-E3VODCC3.js";
|
|
63
|
+
HourlySummarizer
|
|
64
|
+
} from "./chunk-DKT3X5C3.js";
|
|
70
65
|
import {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
} from "./chunk-L6W77GWW.js";
|
|
66
|
+
SessionObserverState
|
|
67
|
+
} from "./chunk-DKTSR7EK.js";
|
|
74
68
|
import {
|
|
75
69
|
mergeWithAgentResults,
|
|
76
70
|
runDirectAgent,
|
|
@@ -89,27 +83,44 @@ import {
|
|
|
89
83
|
recencyWindowFromPrompt,
|
|
90
84
|
resolvePromptTagPrefilterAsync
|
|
91
85
|
} from "./chunk-MGN7VHWQ.js";
|
|
86
|
+
import {
|
|
87
|
+
applyRuntimeRetrievalPolicy
|
|
88
|
+
} from "./chunk-5IZL4DCV.js";
|
|
89
|
+
import {
|
|
90
|
+
findUnresolvedEntityRefs
|
|
91
|
+
} from "./chunk-X7XN6YU4.js";
|
|
92
|
+
import {
|
|
93
|
+
RelevanceStore
|
|
94
|
+
} from "./chunk-GG6AJN7A.js";
|
|
95
|
+
import {
|
|
96
|
+
RerankCache,
|
|
97
|
+
rerankLocalOrNoop
|
|
98
|
+
} from "./chunk-E3VODCC3.js";
|
|
99
|
+
import {
|
|
100
|
+
buildResponseGuidanceRecallSection,
|
|
101
|
+
shouldRecallResponseGuidance
|
|
102
|
+
} from "./chunk-L6W77GWW.js";
|
|
103
|
+
import {
|
|
104
|
+
createRecallSectionMetricRecorder
|
|
105
|
+
} from "./chunk-VQ34TERH.js";
|
|
92
106
|
import {
|
|
93
107
|
LastRecallStore,
|
|
94
108
|
RecallHandleHistoryStore,
|
|
95
109
|
TierMigrationStatusStore,
|
|
96
110
|
clampGraphRecallExpandedEntries
|
|
97
111
|
} from "./chunk-UC4YOAC2.js";
|
|
98
|
-
import {
|
|
99
|
-
findUnresolvedEntityRefs
|
|
100
|
-
} from "./chunk-X7XN6YU4.js";
|
|
101
112
|
import {
|
|
102
113
|
reorderRecallResultsWithMmr
|
|
103
114
|
} from "./chunk-YDBIWGNI.js";
|
|
104
|
-
import {
|
|
105
|
-
createRecallSectionMetricRecorder
|
|
106
|
-
} from "./chunk-VQ34TERH.js";
|
|
107
115
|
import {
|
|
108
116
|
applyReasoningTraceBoost
|
|
109
117
|
} from "./chunk-ZZTOURJI.js";
|
|
110
118
|
import {
|
|
111
119
|
NegativeExampleStore
|
|
112
120
|
} from "./chunk-EXM3CQTZ.js";
|
|
121
|
+
import {
|
|
122
|
+
evaluateMemoryActionPolicy
|
|
123
|
+
} from "./chunk-H63EDPFJ.js";
|
|
113
124
|
import {
|
|
114
125
|
applyMemoryWorthFilter,
|
|
115
126
|
buildMemoryWorthCounterMap
|
|
@@ -117,9 +128,6 @@ import {
|
|
|
117
128
|
import {
|
|
118
129
|
runLiveConnectorsOnce
|
|
119
130
|
} from "./chunk-VU3SVYMA.js";
|
|
120
|
-
import {
|
|
121
|
-
evaluateMemoryActionPolicy
|
|
122
|
-
} from "./chunk-H63EDPFJ.js";
|
|
123
131
|
import {
|
|
124
132
|
hasBroadGraphIntent,
|
|
125
133
|
inferIntentFromText,
|
|
@@ -136,10 +144,10 @@ import {
|
|
|
136
144
|
getVerdictKind,
|
|
137
145
|
judgeFactDurability,
|
|
138
146
|
validateProcedureExtraction
|
|
139
|
-
} from "./chunk-
|
|
147
|
+
} from "./chunk-3NN73CM7.js";
|
|
140
148
|
import {
|
|
141
149
|
ExtractionEngine
|
|
142
|
-
} from "./chunk-
|
|
150
|
+
} from "./chunk-GZQXOQQ2.js";
|
|
143
151
|
import {
|
|
144
152
|
parseMemoryActionEligibilityContext
|
|
145
153
|
} from "./chunk-5GSUBCZM.js";
|
|
@@ -176,7 +184,7 @@ import {
|
|
|
176
184
|
buildEntityRecallSection,
|
|
177
185
|
entityRecentTranscriptLookbackHours,
|
|
178
186
|
readRecentEntityTranscriptEntries
|
|
179
|
-
} from "./chunk-
|
|
187
|
+
} from "./chunk-5O42UKXI.js";
|
|
180
188
|
import {
|
|
181
189
|
formatDaySummaryMemories
|
|
182
190
|
} from "./chunk-EO5QWINU.js";
|
|
@@ -189,34 +197,34 @@ import {
|
|
|
189
197
|
import {
|
|
190
198
|
compareVerifiedEpisodeResults,
|
|
191
199
|
searchVerifiedEpisodes
|
|
192
|
-
} from "./chunk-
|
|
200
|
+
} from "./chunk-EBDA5TYA.js";
|
|
193
201
|
import {
|
|
194
202
|
ThreadingManager
|
|
195
203
|
} from "./chunk-QRDOSYOR.js";
|
|
196
204
|
import {
|
|
197
205
|
compareVerifiedSemanticRuleResults,
|
|
198
206
|
searchVerifiedSemanticRules
|
|
199
|
-
} from "./chunk-
|
|
207
|
+
} from "./chunk-YEE5KJQQ.js";
|
|
200
208
|
import {
|
|
201
209
|
searchWorkProductLedgerEntries
|
|
202
210
|
} from "./chunk-ZRWB5D4H.js";
|
|
203
211
|
import {
|
|
204
212
|
TranscriptManager
|
|
205
213
|
} from "./chunk-GY3SKOS4.js";
|
|
214
|
+
import {
|
|
215
|
+
PolicyRuntimeManager
|
|
216
|
+
} from "./chunk-33JBK2XP.js";
|
|
206
217
|
import {
|
|
207
218
|
runNamespaceMaintenanceFanout,
|
|
208
219
|
summarizeNamespaceMaintenanceHealth
|
|
209
|
-
} from "./chunk-
|
|
220
|
+
} from "./chunk-PD42EYQN.js";
|
|
210
221
|
import {
|
|
211
222
|
NamespaceCatalog,
|
|
212
223
|
planNamespaceMaintenance
|
|
213
|
-
} from "./chunk-
|
|
224
|
+
} from "./chunk-EXUCUPV2.js";
|
|
214
225
|
import {
|
|
215
226
|
NamespaceStorageRouter
|
|
216
|
-
} from "./chunk-
|
|
217
|
-
import {
|
|
218
|
-
PolicyRuntimeManager
|
|
219
|
-
} from "./chunk-33JBK2XP.js";
|
|
227
|
+
} from "./chunk-OHTOPFRF.js";
|
|
220
228
|
import {
|
|
221
229
|
isAboveImportanceThreshold,
|
|
222
230
|
scoreImportance
|
|
@@ -245,10 +253,6 @@ import {
|
|
|
245
253
|
refineCompressionGuidelineCandidateSemantically,
|
|
246
254
|
renderCompressionGuidelinesMarkdown
|
|
247
255
|
} from "./chunk-OD4FM2U7.js";
|
|
248
|
-
import {
|
|
249
|
-
resolveCapabilities,
|
|
250
|
-
resolveGraphConstructionCapabilities
|
|
251
|
-
} from "./chunk-PBH4JUAB.js";
|
|
252
256
|
import {
|
|
253
257
|
buildConsolidationPrompt,
|
|
254
258
|
buildExtensionsBlockForConsolidation,
|
|
@@ -258,7 +262,7 @@ import {
|
|
|
258
262
|
materializeAfterSemanticConsolidation,
|
|
259
263
|
parseConsolidationResponse,
|
|
260
264
|
parseOperatorAwareConsolidationResponse
|
|
261
|
-
} from "./chunk-
|
|
265
|
+
} from "./chunk-NXRUUDUF.js";
|
|
262
266
|
import {
|
|
263
267
|
buildRecallQueryPolicy
|
|
264
268
|
} from "./chunk-LBJBNWS2.js";
|
|
@@ -299,7 +303,7 @@ import {
|
|
|
299
303
|
clusterByKey,
|
|
300
304
|
createCorrectionService,
|
|
301
305
|
detectPassiveCorrections
|
|
302
|
-
} from "./chunk-
|
|
306
|
+
} from "./chunk-VCLGUIFM.js";
|
|
303
307
|
import {
|
|
304
308
|
listTrustZoneRecords,
|
|
305
309
|
searchTrustZoneRecords
|
|
@@ -309,25 +313,25 @@ import {
|
|
|
309
313
|
} from "./chunk-FF4KLI5W.js";
|
|
310
314
|
import {
|
|
311
315
|
buildXraySnapshot
|
|
312
|
-
} from "./chunk-
|
|
313
|
-
import {
|
|
314
|
-
combineNamespaces,
|
|
315
|
-
getConfiguredNamespaces,
|
|
316
|
-
resolveCodingNamespaceOverlay,
|
|
317
|
-
resolveNamespaceFromStorageDir,
|
|
318
|
-
resolveScopePlan,
|
|
319
|
-
resolveScopeProfilePlan
|
|
320
|
-
} from "./chunk-J6BH2OBA.js";
|
|
316
|
+
} from "./chunk-GJSL4WG2.js";
|
|
321
317
|
import {
|
|
322
318
|
NamespaceSearchRouter
|
|
323
|
-
} from "./chunk-
|
|
319
|
+
} from "./chunk-QR67FU5G.js";
|
|
324
320
|
import {
|
|
325
321
|
createConversationIndexRuntime,
|
|
326
322
|
createSearchBackend
|
|
327
|
-
} from "./chunk-
|
|
323
|
+
} from "./chunk-HCVWF657.js";
|
|
328
324
|
import {
|
|
329
325
|
NoopSearchBackend
|
|
330
326
|
} from "./chunk-CYEPCZN5.js";
|
|
327
|
+
import {
|
|
328
|
+
combineNamespaces,
|
|
329
|
+
getConfiguredNamespaces,
|
|
330
|
+
resolveCodingNamespaceOverlay,
|
|
331
|
+
resolveNamespaceFromStorageDir,
|
|
332
|
+
resolveScopePlan,
|
|
333
|
+
resolveScopeProfilePlan
|
|
334
|
+
} from "./chunk-J6BH2OBA.js";
|
|
331
335
|
import {
|
|
332
336
|
namespaceIdentityFromToken,
|
|
333
337
|
namespaceIdentityToken,
|
|
@@ -352,19 +356,23 @@ import {
|
|
|
352
356
|
import {
|
|
353
357
|
shouldSkipImplicitExtraction
|
|
354
358
|
} from "./chunk-EH5ED3C6.js";
|
|
359
|
+
import {
|
|
360
|
+
resolveCapabilities,
|
|
361
|
+
resolveGraphConstructionCapabilities
|
|
362
|
+
} from "./chunk-DVRHLN2O.js";
|
|
355
363
|
import {
|
|
356
364
|
searchCausalTrajectories
|
|
357
|
-
} from "./chunk-
|
|
365
|
+
} from "./chunk-SQNED75R.js";
|
|
358
366
|
import {
|
|
359
367
|
GraphIndex
|
|
360
|
-
} from "./chunk-
|
|
368
|
+
} from "./chunk-EHQ5HO5T.js";
|
|
361
369
|
import {
|
|
362
370
|
decideLifecycleTransition,
|
|
363
371
|
resolveLifecycleState
|
|
364
372
|
} from "./chunk-TBBDFYXW.js";
|
|
365
373
|
import {
|
|
366
374
|
buildChainFollowupGenerator
|
|
367
|
-
} from "./chunk-
|
|
375
|
+
} from "./chunk-UO5ZHIIH.js";
|
|
368
376
|
import {
|
|
369
377
|
ContentHashIndex,
|
|
370
378
|
StorageManager,
|
|
@@ -372,10 +380,10 @@ import {
|
|
|
372
380
|
fingerprintEntityStructuredFacts,
|
|
373
381
|
normalizeAttributePairs,
|
|
374
382
|
parseEntityFile
|
|
375
|
-
} from "./chunk-
|
|
383
|
+
} from "./chunk-EVPNWN7Z.js";
|
|
376
384
|
import {
|
|
377
385
|
buildRetiredFactTombstoneInputs
|
|
378
|
-
} from "./chunk-
|
|
386
|
+
} from "./chunk-L2B3EE7B.js";
|
|
379
387
|
import {
|
|
380
388
|
isValidTranscriptDate,
|
|
381
389
|
loadSpeakerRegistry,
|
|
@@ -406,16 +414,16 @@ import {
|
|
|
406
414
|
} from "./chunk-SVOZFLIQ.js";
|
|
407
415
|
import {
|
|
408
416
|
confidenceTier
|
|
409
|
-
} from "./chunk-
|
|
410
|
-
import {
|
|
411
|
-
inferMemoryStatus,
|
|
412
|
-
isActiveMemoryStatus
|
|
413
|
-
} from "./chunk-RULE4VG5.js";
|
|
417
|
+
} from "./chunk-ILFSEIRT.js";
|
|
414
418
|
import {
|
|
415
419
|
buildQmdRecallCacheKey,
|
|
416
420
|
getCachedQmdRecall,
|
|
417
421
|
setCachedQmdRecall
|
|
418
422
|
} from "./chunk-42JKGUFJ.js";
|
|
423
|
+
import {
|
|
424
|
+
inferMemoryStatus,
|
|
425
|
+
isActiveMemoryStatus
|
|
426
|
+
} from "./chunk-RULE4VG5.js";
|
|
419
427
|
import {
|
|
420
428
|
lintWorkspaceFiles,
|
|
421
429
|
rotateMarkdownFileToArchive
|
|
@@ -424,12 +432,12 @@ import {
|
|
|
424
432
|
applyFaithfulnessVerdict,
|
|
425
433
|
createFaithfulnessCounters,
|
|
426
434
|
runFaithfulnessGateBatch
|
|
427
|
-
} from "./chunk-
|
|
435
|
+
} from "./chunk-6OIDDKAA.js";
|
|
428
436
|
import {
|
|
429
437
|
FallbackLlmClient,
|
|
430
438
|
fallbackLlmRuntimeContextFromConfig,
|
|
431
439
|
gatewayTaskChainOptions
|
|
432
|
-
} from "./chunk-
|
|
440
|
+
} from "./chunk-VUA4S7P6.js";
|
|
433
441
|
import {
|
|
434
442
|
keyring_exports,
|
|
435
443
|
secureStoreDir
|
|
@@ -478,7 +486,7 @@ import {
|
|
|
478
486
|
} from "./chunk-PVGDJXVK.js";
|
|
479
487
|
|
|
480
488
|
// src/orchestrator.ts
|
|
481
|
-
import
|
|
489
|
+
import path3 from "path";
|
|
482
490
|
import os from "os";
|
|
483
491
|
import { createHash, randomBytes } from "crypto";
|
|
484
492
|
import { existsSync, readFileSync } from "fs";
|
|
@@ -546,6 +554,192 @@ ${preview}${suffix}`;
|
|
|
546
554
|
${blocks.join("\n\n")}`;
|
|
547
555
|
}
|
|
548
556
|
|
|
557
|
+
// src/orchestration/tier-migration-coordinator.ts
|
|
558
|
+
import path from "path";
|
|
559
|
+
var TierMigrationCoordinator = class {
|
|
560
|
+
constructor(deps) {
|
|
561
|
+
this.deps = deps;
|
|
562
|
+
}
|
|
563
|
+
deps;
|
|
564
|
+
inFlight = false;
|
|
565
|
+
lastRunAtMs = 0;
|
|
566
|
+
/** Whether a migration cycle is currently executing (diagnostics). */
|
|
567
|
+
isInFlight() {
|
|
568
|
+
return this.inFlight;
|
|
569
|
+
}
|
|
570
|
+
/** Latest status snapshot (delegates to the status store). */
|
|
571
|
+
getStatus() {
|
|
572
|
+
return this.deps.tierMigrationStatus.get();
|
|
573
|
+
}
|
|
574
|
+
/**
|
|
575
|
+
* Run one tier-migration cycle. Behavior-preserving move of the
|
|
576
|
+
* orchestrator's former `runTierMigrationCycle`.
|
|
577
|
+
*/
|
|
578
|
+
async runCycle(storage, trigger, options) {
|
|
579
|
+
const { config, tierMigrationStatus } = this.deps;
|
|
580
|
+
const dryRun = options?.dryRun === true;
|
|
581
|
+
const persistSkipped = options?.force === true || trigger === "manual";
|
|
582
|
+
if (!config.qmdTierMigrationEnabled && options?.force !== true) {
|
|
583
|
+
const skipped = {
|
|
584
|
+
trigger,
|
|
585
|
+
scanned: 0,
|
|
586
|
+
migrated: 0,
|
|
587
|
+
promoted: 0,
|
|
588
|
+
demoted: 0,
|
|
589
|
+
limit: 0,
|
|
590
|
+
dryRun,
|
|
591
|
+
skipped: "tier_migration_disabled"
|
|
592
|
+
};
|
|
593
|
+
if (persistSkipped) await tierMigrationStatus.recordCycle(skipped);
|
|
594
|
+
return skipped;
|
|
595
|
+
}
|
|
596
|
+
if (trigger === "maintenance" && !config.qmdTierAutoBackfillEnabled && options?.force !== true) {
|
|
597
|
+
const skipped = {
|
|
598
|
+
trigger,
|
|
599
|
+
scanned: 0,
|
|
600
|
+
migrated: 0,
|
|
601
|
+
promoted: 0,
|
|
602
|
+
demoted: 0,
|
|
603
|
+
limit: 0,
|
|
604
|
+
dryRun,
|
|
605
|
+
skipped: "maintenance_backfill_disabled"
|
|
606
|
+
};
|
|
607
|
+
if (persistSkipped) await tierMigrationStatus.recordCycle(skipped);
|
|
608
|
+
return skipped;
|
|
609
|
+
}
|
|
610
|
+
if (this.inFlight) {
|
|
611
|
+
const skipped = {
|
|
612
|
+
trigger,
|
|
613
|
+
scanned: 0,
|
|
614
|
+
migrated: 0,
|
|
615
|
+
promoted: 0,
|
|
616
|
+
demoted: 0,
|
|
617
|
+
limit: 0,
|
|
618
|
+
dryRun,
|
|
619
|
+
skipped: "migration_in_flight"
|
|
620
|
+
};
|
|
621
|
+
if (persistSkipped) await tierMigrationStatus.recordCycle(skipped);
|
|
622
|
+
return skipped;
|
|
623
|
+
}
|
|
624
|
+
const budgetTrigger = trigger === "manual" ? "maintenance" : trigger;
|
|
625
|
+
const budget = this.deps.getCompounding()?.tierMigrationCycleBudget(budgetTrigger) ?? defaultTierMigrationCycleBudget(config, budgetTrigger);
|
|
626
|
+
const limit = options?.limitOverride !== void 0 ? Math.max(0, Math.floor(options.limitOverride)) : budget.limit;
|
|
627
|
+
const nowMs = Date.now();
|
|
628
|
+
if (options?.force !== true && nowMs - this.lastRunAtMs < budget.minIntervalMs) {
|
|
629
|
+
const skipped = {
|
|
630
|
+
trigger,
|
|
631
|
+
scanned: 0,
|
|
632
|
+
migrated: 0,
|
|
633
|
+
promoted: 0,
|
|
634
|
+
demoted: 0,
|
|
635
|
+
limit,
|
|
636
|
+
dryRun,
|
|
637
|
+
skipped: "min_interval"
|
|
638
|
+
};
|
|
639
|
+
if (persistSkipped) await tierMigrationStatus.recordCycle(skipped);
|
|
640
|
+
return skipped;
|
|
641
|
+
}
|
|
642
|
+
const policy = applyUtilityPromotionRuntimePolicy(
|
|
643
|
+
{
|
|
644
|
+
enabled: config.qmdTierMigrationEnabled,
|
|
645
|
+
demotionMinAgeDays: config.qmdTierDemotionMinAgeDays,
|
|
646
|
+
demotionValueThreshold: config.qmdTierDemotionValueThreshold,
|
|
647
|
+
promotionValueThreshold: config.qmdTierPromotionValueThreshold
|
|
648
|
+
},
|
|
649
|
+
this.deps.getUtilityRuntimeValues()
|
|
650
|
+
);
|
|
651
|
+
this.inFlight = true;
|
|
652
|
+
try {
|
|
653
|
+
const coldStorage = this.deps.createColdStorage(
|
|
654
|
+
path.join(storage.dir, "cold")
|
|
655
|
+
);
|
|
656
|
+
const [hotMemories, coldMemories] = await Promise.all([
|
|
657
|
+
storage.readAllMemories(),
|
|
658
|
+
coldStorage.readAllMemories()
|
|
659
|
+
]);
|
|
660
|
+
const now = /* @__PURE__ */ new Date();
|
|
661
|
+
const scanLimit = Math.max(0, Math.floor(budget.scanLimit));
|
|
662
|
+
const hotScanLimit = Math.min(
|
|
663
|
+
hotMemories.length,
|
|
664
|
+
Math.ceil(scanLimit * 0.75)
|
|
665
|
+
);
|
|
666
|
+
const coldScanLimit = Math.min(
|
|
667
|
+
coldMemories.length,
|
|
668
|
+
Math.max(0, scanLimit - hotScanLimit)
|
|
669
|
+
);
|
|
670
|
+
const toTimestamp = (memory) => Date.parse(memory.frontmatter.updated ?? memory.frontmatter.created);
|
|
671
|
+
const hotCandidates = hotMemories.map((memory) => ({ memory, tier: "hot" })).sort((a, b) => toTimestamp(a.memory) - toTimestamp(b.memory)).slice(0, hotScanLimit);
|
|
672
|
+
const coldCandidates = coldMemories.map((memory) => ({ memory, tier: "cold" })).sort((a, b) => toTimestamp(b.memory) - toTimestamp(a.memory)).slice(0, coldScanLimit);
|
|
673
|
+
const candidates = [...hotCandidates, ...coldCandidates];
|
|
674
|
+
const migration = new TierMigrationExecutor({
|
|
675
|
+
storage,
|
|
676
|
+
qmd: this.deps.getQmd(),
|
|
677
|
+
hotCollection: config.qmdCollection,
|
|
678
|
+
coldCollection: config.qmdColdCollection ?? `${config.qmdCollection}-cold`,
|
|
679
|
+
autoEmbed: config.qmdAutoEmbedEnabled
|
|
680
|
+
});
|
|
681
|
+
let migrated = 0;
|
|
682
|
+
let promoted = 0;
|
|
683
|
+
let demoted = 0;
|
|
684
|
+
for (const candidate of candidates) {
|
|
685
|
+
if (migrated >= limit) break;
|
|
686
|
+
const decision = decideTierTransition(
|
|
687
|
+
candidate.memory,
|
|
688
|
+
candidate.tier,
|
|
689
|
+
policy,
|
|
690
|
+
now
|
|
691
|
+
);
|
|
692
|
+
if (!decision.changed) continue;
|
|
693
|
+
if (!dryRun) {
|
|
694
|
+
const res = await migration.migrateMemory({
|
|
695
|
+
memory: candidate.memory,
|
|
696
|
+
fromTier: candidate.tier,
|
|
697
|
+
toTier: decision.nextTier,
|
|
698
|
+
reason: `${trigger}:${decision.reason}`
|
|
699
|
+
});
|
|
700
|
+
if (!res.changed) continue;
|
|
701
|
+
}
|
|
702
|
+
migrated += 1;
|
|
703
|
+
if (decision.nextTier === "cold") demoted += 1;
|
|
704
|
+
if (decision.nextTier === "hot") promoted += 1;
|
|
705
|
+
}
|
|
706
|
+
if (!dryRun) this.lastRunAtMs = Date.now();
|
|
707
|
+
log.debug(
|
|
708
|
+
`tier migration cycle completed: trigger=${trigger} scanned=${candidates.length} migrated=${migrated} limit=${limit}${dryRun ? " dryRun=true" : ""}`
|
|
709
|
+
);
|
|
710
|
+
const summary = {
|
|
711
|
+
trigger,
|
|
712
|
+
scanned: candidates.length,
|
|
713
|
+
migrated,
|
|
714
|
+
promoted,
|
|
715
|
+
demoted,
|
|
716
|
+
limit,
|
|
717
|
+
dryRun
|
|
718
|
+
};
|
|
719
|
+
const shouldPersistCycle = trigger === "manual" || migrated > 0;
|
|
720
|
+
if (shouldPersistCycle) await tierMigrationStatus.recordCycle(summary);
|
|
721
|
+
return summary;
|
|
722
|
+
} catch (err) {
|
|
723
|
+
this.lastRunAtMs = Date.now();
|
|
724
|
+
log.warn(`tier migration cycle failed (${trigger}, fail-open): ${err}`);
|
|
725
|
+
const failed = {
|
|
726
|
+
trigger,
|
|
727
|
+
scanned: 0,
|
|
728
|
+
migrated: 0,
|
|
729
|
+
promoted: 0,
|
|
730
|
+
demoted: 0,
|
|
731
|
+
limit,
|
|
732
|
+
dryRun,
|
|
733
|
+
errorCount: 1
|
|
734
|
+
};
|
|
735
|
+
await tierMigrationStatus.recordCycle(failed);
|
|
736
|
+
return failed;
|
|
737
|
+
} finally {
|
|
738
|
+
this.inFlight = false;
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
};
|
|
742
|
+
|
|
549
743
|
// src/maintenance/pattern-reinforcement.ts
|
|
550
744
|
function patternReinforcementKey(content) {
|
|
551
745
|
return content.trim().toLowerCase().replace(/\s+/g, " ").slice(0, 200);
|
|
@@ -879,7 +1073,7 @@ function generateResolverDocument(taxonomy) {
|
|
|
879
1073
|
|
|
880
1074
|
// src/taxonomy/taxonomy-loader.ts
|
|
881
1075
|
import { readFile, mkdir, writeFile } from "fs/promises";
|
|
882
|
-
import
|
|
1076
|
+
import path2 from "path";
|
|
883
1077
|
var TAXONOMY_DIR = ".taxonomy";
|
|
884
1078
|
var TAXONOMY_FILE = "taxonomy.json";
|
|
885
1079
|
var MAX_SLUG_LENGTH = 32;
|
|
@@ -977,7 +1171,7 @@ function validateTaxonomy(taxonomy) {
|
|
|
977
1171
|
}
|
|
978
1172
|
}
|
|
979
1173
|
async function loadTaxonomy(memoryDir) {
|
|
980
|
-
const taxonomyPath =
|
|
1174
|
+
const taxonomyPath = path2.join(memoryDir, TAXONOMY_DIR, TAXONOMY_FILE);
|
|
981
1175
|
let raw;
|
|
982
1176
|
try {
|
|
983
1177
|
raw = await readFile(taxonomyPath, "utf-8");
|
|
@@ -1027,16 +1221,16 @@ async function loadTaxonomy(memoryDir) {
|
|
|
1027
1221
|
}
|
|
1028
1222
|
async function saveTaxonomy(memoryDir, taxonomy) {
|
|
1029
1223
|
validateTaxonomy(taxonomy);
|
|
1030
|
-
const dir =
|
|
1224
|
+
const dir = path2.join(memoryDir, TAXONOMY_DIR);
|
|
1031
1225
|
await mkdir(dir, { recursive: true });
|
|
1032
|
-
const filePath =
|
|
1226
|
+
const filePath = path2.join(dir, TAXONOMY_FILE);
|
|
1033
1227
|
await writeFile(filePath, JSON.stringify(taxonomy, null, 2) + "\n", "utf-8");
|
|
1034
1228
|
}
|
|
1035
1229
|
function getTaxonomyDir(memoryDir) {
|
|
1036
|
-
return
|
|
1230
|
+
return path2.join(memoryDir, TAXONOMY_DIR);
|
|
1037
1231
|
}
|
|
1038
1232
|
function getTaxonomyFilePath(memoryDir) {
|
|
1039
|
-
return
|
|
1233
|
+
return path2.join(memoryDir, TAXONOMY_DIR, TAXONOMY_FILE);
|
|
1040
1234
|
}
|
|
1041
1235
|
|
|
1042
1236
|
// src/wearables/registry.ts
|
|
@@ -1717,7 +1911,7 @@ async function raceRecallAbort(promise, signal, message = "recall aborted") {
|
|
|
1717
1911
|
}
|
|
1718
1912
|
}
|
|
1719
1913
|
function qmdCollectionPathParts(resultPath) {
|
|
1720
|
-
if (!resultPath ||
|
|
1914
|
+
if (!resultPath || path3.isAbsolute(resultPath)) return null;
|
|
1721
1915
|
const normalized = resultPath.replace(/\\/g, "/").replace(/^\/+/, "");
|
|
1722
1916
|
const slashIndex = normalized.indexOf("/");
|
|
1723
1917
|
if (slashIndex <= 0 || slashIndex >= normalized.length - 1) return null;
|
|
@@ -1730,9 +1924,9 @@ function qmdCollectionPathParts(resultPath) {
|
|
|
1730
1924
|
}
|
|
1731
1925
|
function qmdResultPathCandidates(storageDir, resultPath) {
|
|
1732
1926
|
const candidates = /* @__PURE__ */ new Set();
|
|
1733
|
-
const storageRoot =
|
|
1927
|
+
const storageRoot = path3.resolve(storageDir);
|
|
1734
1928
|
const addCandidate = (candidate) => {
|
|
1735
|
-
const resolved =
|
|
1929
|
+
const resolved = path3.resolve(candidate);
|
|
1736
1930
|
if (isPathInsideStorageRoot(storageRoot, resolved)) {
|
|
1737
1931
|
candidates.add(resolved);
|
|
1738
1932
|
}
|
|
@@ -1740,12 +1934,12 @@ function qmdResultPathCandidates(storageDir, resultPath) {
|
|
|
1740
1934
|
const addRelativeCandidates = (relativePath) => {
|
|
1741
1935
|
const normalized = relativePath.replace(/\\/g, "/").replace(/^\/+/, "");
|
|
1742
1936
|
if (!normalized) return;
|
|
1743
|
-
addCandidate(
|
|
1937
|
+
addCandidate(path3.join(storageRoot, normalized));
|
|
1744
1938
|
if (/^\d{4}-\d{2}-\d{2}\//.test(normalized)) {
|
|
1745
|
-
addCandidate(
|
|
1939
|
+
addCandidate(path3.join(storageRoot, "facts", normalized));
|
|
1746
1940
|
}
|
|
1747
1941
|
};
|
|
1748
|
-
if (
|
|
1942
|
+
if (path3.isAbsolute(resultPath)) {
|
|
1749
1943
|
addCandidate(resultPath);
|
|
1750
1944
|
} else {
|
|
1751
1945
|
addRelativeCandidates(resultPath);
|
|
@@ -1862,7 +2056,7 @@ async function qmdStartupCollectionCheckWithTimeout(promise, controller, label)
|
|
|
1862
2056
|
return await Promise.race([checkedPromise, timeoutPromise]);
|
|
1863
2057
|
}
|
|
1864
2058
|
function defaultWorkspaceDir() {
|
|
1865
|
-
return
|
|
2059
|
+
return path3.join(os.homedir(), ".openclaw", "workspace");
|
|
1866
2060
|
}
|
|
1867
2061
|
function sanitizeSessionKeyForFilename(sessionKey) {
|
|
1868
2062
|
const readable = sessionKey.replace(/[^a-zA-Z0-9._-]/g, "_");
|
|
@@ -2169,11 +2363,11 @@ function mergeGraphExpandedResults(primary, expanded) {
|
|
|
2169
2363
|
return Array.from(mergedByPath.values());
|
|
2170
2364
|
}
|
|
2171
2365
|
function graphPathRelativeToStorage(storageDir, candidatePath) {
|
|
2172
|
-
const absolutePath =
|
|
2173
|
-
const rel =
|
|
2366
|
+
const absolutePath = path3.isAbsolute(candidatePath) ? candidatePath : path3.resolve(storageDir, candidatePath);
|
|
2367
|
+
const rel = path3.relative(storageDir, absolutePath);
|
|
2174
2368
|
if (!rel || rel === ".") return null;
|
|
2175
2369
|
if (rel.startsWith("..")) return null;
|
|
2176
|
-
return rel.split(
|
|
2370
|
+
return rel.split(path3.sep).join("/");
|
|
2177
2371
|
}
|
|
2178
2372
|
function normalizeGraphActivationScore(score) {
|
|
2179
2373
|
const bounded = Number.isFinite(score) && score > 0 ? score : 0;
|
|
@@ -2318,7 +2512,7 @@ function buildMemoryPathById(allMemsForGraph, storageDir) {
|
|
|
2318
2512
|
for (const mem of allMemsForGraph ?? []) {
|
|
2319
2513
|
const id = mem.frontmatter.id;
|
|
2320
2514
|
if (!id) continue;
|
|
2321
|
-
pathById.set(id,
|
|
2515
|
+
pathById.set(id, path3.relative(storageDir, mem.path));
|
|
2322
2516
|
}
|
|
2323
2517
|
return pathById;
|
|
2324
2518
|
}
|
|
@@ -2326,7 +2520,7 @@ function appendMemoryToGraphContext(options) {
|
|
|
2326
2520
|
if (!Array.isArray(options.allMemsForGraph)) return;
|
|
2327
2521
|
const nowIso = (/* @__PURE__ */ new Date()).toISOString();
|
|
2328
2522
|
options.allMemsForGraph.push({
|
|
2329
|
-
path:
|
|
2523
|
+
path: path3.join(options.storageDir, options.memoryRelPath),
|
|
2330
2524
|
content: options.content,
|
|
2331
2525
|
frontmatter: {
|
|
2332
2526
|
id: options.memoryId,
|
|
@@ -2346,16 +2540,16 @@ function resolvePersistedMemoryRelativePath(options) {
|
|
|
2346
2540
|
const persisted = options.pathById.get(options.memoryId);
|
|
2347
2541
|
if (persisted) return persisted;
|
|
2348
2542
|
if (options.category === "correction") {
|
|
2349
|
-
return
|
|
2543
|
+
return path3.join("corrections", `${options.memoryId}.md`);
|
|
2350
2544
|
}
|
|
2351
2545
|
const subtree = categoryDirName(options.category);
|
|
2352
2546
|
const idParts = options.memoryId.split("-");
|
|
2353
2547
|
const maybeTimestamp = Number(idParts[1]);
|
|
2354
2548
|
if (Number.isFinite(maybeTimestamp) && maybeTimestamp > 0) {
|
|
2355
2549
|
const day = new Date(maybeTimestamp).toISOString().slice(0, 10);
|
|
2356
|
-
return
|
|
2550
|
+
return path3.join(subtree, day, `${options.memoryId}.md`);
|
|
2357
2551
|
}
|
|
2358
|
-
return
|
|
2552
|
+
return path3.join(subtree, `${options.memoryId}.md`);
|
|
2359
2553
|
}
|
|
2360
2554
|
var Orchestrator = class _Orchestrator {
|
|
2361
2555
|
storage;
|
|
@@ -2432,6 +2626,7 @@ var Orchestrator = class _Orchestrator {
|
|
|
2432
2626
|
lastRecall;
|
|
2433
2627
|
handleHistory;
|
|
2434
2628
|
tierMigrationStatus;
|
|
2629
|
+
tierMigrationCoordinator;
|
|
2435
2630
|
/**
|
|
2436
2631
|
* In-memory X-ray snapshot from the most recent `recall()` call that
|
|
2437
2632
|
* was invoked with `xrayCapture: true` (issue #570 PR 1). Scope is
|
|
@@ -2467,6 +2662,15 @@ var Orchestrator = class _Orchestrator {
|
|
|
2467
2662
|
*/
|
|
2468
2663
|
memoryWorthCounterCache = /* @__PURE__ */ new Map();
|
|
2469
2664
|
static MEMORY_WORTH_CACHE_TTL_MS = 3e4;
|
|
2665
|
+
/**
|
|
2666
|
+
* Issue #1577 — per-namespace TrustScore signal map cache. Same TTL/shape
|
|
2667
|
+
* discipline as {@link memoryWorthCounterCache}: seconds-scale, evicted on
|
|
2668
|
+
* every call, keyed by namespace. Holds the frontmatter-derived signals
|
|
2669
|
+
* (worth, provenance, faithfulness, corroboration, recency) so the trust
|
|
2670
|
+
* stage doesn't trigger a fresh `readAllMemories` scan per query.
|
|
2671
|
+
*/
|
|
2672
|
+
trustSignalCache = /* @__PURE__ */ new Map();
|
|
2673
|
+
static TRUST_SIGNAL_CACHE_TTL_MS = 3e4;
|
|
2470
2674
|
/**
|
|
2471
2675
|
* Per-session workspace selections keyed by sessionKey.
|
|
2472
2676
|
* Set by the before_agent_start hook so recall() uses the correct
|
|
@@ -2513,8 +2717,6 @@ var Orchestrator = class _Orchestrator {
|
|
|
2513
2717
|
wearablesServiceInstance = null;
|
|
2514
2718
|
wearablesAutoSyncHandle = null;
|
|
2515
2719
|
lastQmdReprobeAtMs = 0;
|
|
2516
|
-
tierMigrationInFlight = false;
|
|
2517
|
-
lastTierMigrationRunAtMs = 0;
|
|
2518
2720
|
conversationIndexLastUpdateAtMs = /* @__PURE__ */ new Map();
|
|
2519
2721
|
lastFileHygieneRunAtMs = 0;
|
|
2520
2722
|
// Pattern-reinforcement cadence gate (issue #687 PR 2/4). Tracks the
|
|
@@ -2801,7 +3003,7 @@ var Orchestrator = class _Orchestrator {
|
|
|
2801
3003
|
const defaultNs = normalizeNamespaceIdentity(this.config.defaultNamespace);
|
|
2802
3004
|
if (ns !== defaultNs && !isSafeRouteNamespace(ns)) return;
|
|
2803
3005
|
if (!this.storageDirMatchesNamespaceHint(ns, storageDir)) return;
|
|
2804
|
-
const resolvedStorageDir =
|
|
3006
|
+
const resolvedStorageDir = path3.resolve(storageDir);
|
|
2805
3007
|
let hints = this.namespaceStorageDirHints.get(resolvedStorageDir);
|
|
2806
3008
|
if (!hints) {
|
|
2807
3009
|
hints = /* @__PURE__ */ new Set();
|
|
@@ -2812,21 +3014,21 @@ var Orchestrator = class _Orchestrator {
|
|
|
2812
3014
|
storageDirMatchesNamespaceHint(namespace, storageDir) {
|
|
2813
3015
|
const ns = normalizeNamespaceIdentity(namespace);
|
|
2814
3016
|
if (!ns) return false;
|
|
2815
|
-
const resolvedStorageDir =
|
|
2816
|
-
const resolvedMemoryDir =
|
|
3017
|
+
const resolvedStorageDir = path3.resolve(storageDir);
|
|
3018
|
+
const resolvedMemoryDir = path3.resolve(this.config.memoryDir);
|
|
2817
3019
|
const defaultNs = normalizeNamespaceIdentity(this.config.defaultNamespace);
|
|
2818
3020
|
if (resolvedStorageDir === resolvedMemoryDir) return ns === defaultNs;
|
|
2819
|
-
const resolvedNamespacesDir =
|
|
3021
|
+
const resolvedNamespacesDir = path3.join(resolvedMemoryDir, "namespaces");
|
|
2820
3022
|
if (!isPathInsideStorageRoot(resolvedNamespacesDir, resolvedStorageDir)) return false;
|
|
2821
|
-
const rawRoot =
|
|
2822
|
-
const tokenRoot =
|
|
3023
|
+
const rawRoot = path3.resolve(resolvedNamespacesDir, ns);
|
|
3024
|
+
const tokenRoot = path3.resolve(resolvedNamespacesDir, namespaceIdentityToken(ns));
|
|
2823
3025
|
return resolvedStorageDir === rawRoot || resolvedStorageDir === tokenRoot;
|
|
2824
3026
|
}
|
|
2825
3027
|
namespaceStorageDirHintOwnershipRank(record, resolvedStorageDir, configured) {
|
|
2826
|
-
if (resolvedStorageDir ===
|
|
3028
|
+
if (resolvedStorageDir === path3.resolve(this.config.memoryDir)) {
|
|
2827
3029
|
return record.namespace === normalizeNamespaceIdentity(this.config.defaultNamespace) ? 0 : 3;
|
|
2828
3030
|
}
|
|
2829
|
-
const leaf =
|
|
3031
|
+
const leaf = path3.basename(resolvedStorageDir);
|
|
2830
3032
|
const tokenOwnsRoot = namespaceIdentityToken(record.namespace) === leaf;
|
|
2831
3033
|
if (tokenOwnsRoot && configured.has(record.namespace)) return 0;
|
|
2832
3034
|
if (record.namespace === leaf) return 1;
|
|
@@ -2854,7 +3056,7 @@ var Orchestrator = class _Orchestrator {
|
|
|
2854
3056
|
loadNamespaceStorageDirHintsFromCatalog() {
|
|
2855
3057
|
if (this.namespaceStorageDirHintsLoaded || !this.namespaceCatalog.enabled) return;
|
|
2856
3058
|
this.namespaceStorageDirHintsLoaded = true;
|
|
2857
|
-
const catalogPath =
|
|
3059
|
+
const catalogPath = path3.join(this.config.memoryDir, "state", "namespaces.jsonl");
|
|
2858
3060
|
if (!existsSync(catalogPath)) return;
|
|
2859
3061
|
let body;
|
|
2860
3062
|
try {
|
|
@@ -2891,7 +3093,7 @@ var Orchestrator = class _Orchestrator {
|
|
|
2891
3093
|
if (!this.storageDirMatchesNamespaceHint(record.namespace, record.storageDir)) {
|
|
2892
3094
|
continue;
|
|
2893
3095
|
}
|
|
2894
|
-
const resolvedStorageDir =
|
|
3096
|
+
const resolvedStorageDir = path3.resolve(record.storageDir);
|
|
2895
3097
|
const current = preferredByStorageDir.get(resolvedStorageDir);
|
|
2896
3098
|
preferredByStorageDir.set(
|
|
2897
3099
|
resolvedStorageDir,
|
|
@@ -3073,7 +3275,7 @@ var Orchestrator = class _Orchestrator {
|
|
|
3073
3275
|
this.config = config;
|
|
3074
3276
|
this.profiler = new ProfilingCollector({
|
|
3075
3277
|
enabled: config.profilingEnabled,
|
|
3076
|
-
storageDir: config.profilingStorageDir ||
|
|
3278
|
+
storageDir: config.profilingStorageDir || path3.join(config.memoryDir, "profiling"),
|
|
3077
3279
|
maxTraces: config.profilingMaxTraces
|
|
3078
3280
|
});
|
|
3079
3281
|
this.namespaceCatalog = new NamespaceCatalog(config);
|
|
@@ -3141,7 +3343,7 @@ var Orchestrator = class _Orchestrator {
|
|
|
3141
3343
|
this.compounding = config.compoundingEnabled ? new CompoundingEngine(config, this.storage) : void 0;
|
|
3142
3344
|
this.buffer = new SmartBuffer(config, this.storage);
|
|
3143
3345
|
this.transcript = new TranscriptManager(config);
|
|
3144
|
-
this.conversationIndexDir =
|
|
3346
|
+
this.conversationIndexDir = path3.join(
|
|
3145
3347
|
config.memoryDir,
|
|
3146
3348
|
"conversation-index",
|
|
3147
3349
|
"chunks"
|
|
@@ -3154,6 +3356,14 @@ var Orchestrator = class _Orchestrator {
|
|
|
3154
3356
|
maxDepth: config.recallHandleSnapshotDepth
|
|
3155
3357
|
});
|
|
3156
3358
|
this.tierMigrationStatus = new TierMigrationStatusStore(config.memoryDir);
|
|
3359
|
+
this.tierMigrationCoordinator = new TierMigrationCoordinator({
|
|
3360
|
+
config,
|
|
3361
|
+
getQmd: () => this.qmd,
|
|
3362
|
+
tierMigrationStatus: this.tierMigrationStatus,
|
|
3363
|
+
getUtilityRuntimeValues: () => this.utilityRuntimeValues,
|
|
3364
|
+
getCompounding: () => this.compounding,
|
|
3365
|
+
createColdStorage: (parentDir) => new StorageManager(parentDir)
|
|
3366
|
+
});
|
|
3157
3367
|
this.sessionObserver = new SessionObserverState({
|
|
3158
3368
|
memoryDir: config.memoryDir,
|
|
3159
3369
|
debounceMs: config.sessionObserverDebounceMs ?? 12e4,
|
|
@@ -3201,7 +3411,7 @@ var Orchestrator = class _Orchestrator {
|
|
|
3201
3411
|
this.modelRegistry
|
|
3202
3412
|
);
|
|
3203
3413
|
this.threading = new ThreadingManager(
|
|
3204
|
-
|
|
3414
|
+
path3.join(config.memoryDir, "threads"),
|
|
3205
3415
|
config.threadingGapMinutes
|
|
3206
3416
|
);
|
|
3207
3417
|
this.tmtBuilder = new TmtBuilder(config.memoryDir, {
|
|
@@ -3504,7 +3714,7 @@ var Orchestrator = class _Orchestrator {
|
|
|
3504
3714
|
const files = await readdir(wsDir).catch(() => []);
|
|
3505
3715
|
for (const f of files) {
|
|
3506
3716
|
if (!f.startsWith(".compaction-reset-signal-")) continue;
|
|
3507
|
-
const fp =
|
|
3717
|
+
const fp = path3.join(wsDir, f);
|
|
3508
3718
|
const s = await stat(fp).catch(() => null);
|
|
3509
3719
|
if (s && Date.now() - s.mtimeMs >= COMPACTION_SIGNAL_MAX_AGE_MS) {
|
|
3510
3720
|
await unlink(fp).catch(() => {
|
|
@@ -3721,7 +3931,7 @@ var Orchestrator = class _Orchestrator {
|
|
|
3721
3931
|
if (signal.aborted) return;
|
|
3722
3932
|
if (!this.wearablesAutoSyncHandle && this.config.wearables.enabled && this.config.wearables.autoSyncEnabled && Object.values(this.config.wearables.sources).some((source) => source.enabled)) {
|
|
3723
3933
|
try {
|
|
3724
|
-
const { startWearablesAutoSync } = await import("./auto-sync-
|
|
3934
|
+
const { startWearablesAutoSync } = await import("./auto-sync-F3KCSQFJ.js");
|
|
3725
3935
|
if (signal.aborted) return;
|
|
3726
3936
|
this.wearablesAutoSyncHandle = startWearablesAutoSync(
|
|
3727
3937
|
{
|
|
@@ -4011,15 +4221,15 @@ ${doc.content}` : doc.content,
|
|
|
4011
4221
|
this.lastFileHygieneRunAtMs = now;
|
|
4012
4222
|
if (hygiene.rotateEnabled) {
|
|
4013
4223
|
for (const rel of hygiene.rotatePaths) {
|
|
4014
|
-
const abs =
|
|
4224
|
+
const abs = path3.isAbsolute(rel) ? rel : path3.join(this.config.workspaceDir, rel);
|
|
4015
4225
|
try {
|
|
4016
4226
|
const raw = await readFile2(abs, "utf-8");
|
|
4017
4227
|
if (raw.length > hygiene.rotateMaxBytes) {
|
|
4018
|
-
const archiveDir =
|
|
4228
|
+
const archiveDir = path3.join(
|
|
4019
4229
|
this.config.workspaceDir,
|
|
4020
4230
|
hygiene.archiveDir
|
|
4021
4231
|
);
|
|
4022
|
-
const base =
|
|
4232
|
+
const base = path3.basename(abs);
|
|
4023
4233
|
const prefix = base.toUpperCase().replace(/\.MD$/i, "").replace(/[^A-Z0-9]+/g, "-") || "FILE";
|
|
4024
4234
|
const { newContent } = await rotateMarkdownFileToArchive({
|
|
4025
4235
|
filePath: abs,
|
|
@@ -4044,8 +4254,8 @@ ${doc.content}` : doc.content,
|
|
|
4044
4254
|
log.warn(w.message);
|
|
4045
4255
|
}
|
|
4046
4256
|
if (hygiene.warningsLogEnabled && warnings.length > 0) {
|
|
4047
|
-
const fp =
|
|
4048
|
-
await mkdir2(
|
|
4257
|
+
const fp = path3.join(this.config.memoryDir, hygiene.warningsLogPath);
|
|
4258
|
+
await mkdir2(path3.dirname(fp), { recursive: true });
|
|
4049
4259
|
const stamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
4050
4260
|
const block = `
|
|
4051
4261
|
|
|
@@ -4530,7 +4740,7 @@ ${evidenceText}`
|
|
|
4530
4740
|
for (const categoryDir of RECALL_FALLBACK_DIRS) {
|
|
4531
4741
|
if (memoryRootReal === null) break;
|
|
4532
4742
|
for (const date of datesToScan) {
|
|
4533
|
-
const dateDir =
|
|
4743
|
+
const dateDir = path3.join(storage.dir, categoryDir, date);
|
|
4534
4744
|
try {
|
|
4535
4745
|
const dirStat = await lstat(dateDir);
|
|
4536
4746
|
if (dirStat.isSymbolicLink() || !dirStat.isDirectory()) continue;
|
|
@@ -4539,7 +4749,7 @@ ${evidenceText}`
|
|
|
4539
4749
|
for (const entry of entries) {
|
|
4540
4750
|
if (entry.isSymbolicLink()) continue;
|
|
4541
4751
|
if (!entry.name.endsWith(".md")) continue;
|
|
4542
|
-
const fullPath =
|
|
4752
|
+
const fullPath = path3.join(dateDir, entry.name);
|
|
4543
4753
|
try {
|
|
4544
4754
|
assertPathInsideRoot(memoryRootReal, await realpath(fullPath), fullPath);
|
|
4545
4755
|
const raw = await readFile2(fullPath, "utf-8");
|
|
@@ -4561,7 +4771,7 @@ ${evidenceText}`
|
|
|
4561
4771
|
facts.push({
|
|
4562
4772
|
path: fullPath,
|
|
4563
4773
|
frontmatter: {
|
|
4564
|
-
id: fm.id ||
|
|
4774
|
+
id: fm.id || path3.basename(entry.name, ".md"),
|
|
4565
4775
|
category: fm.category || "fact",
|
|
4566
4776
|
created,
|
|
4567
4777
|
updated: fm.updated || created,
|
|
@@ -4584,13 +4794,13 @@ ${evidenceText}`
|
|
|
4584
4794
|
return a.frontmatter.created < b.frontmatter.created ? -1 : 1;
|
|
4585
4795
|
});
|
|
4586
4796
|
const hourlySummaries = [];
|
|
4587
|
-
const hourlyBaseDir =
|
|
4797
|
+
const hourlyBaseDir = path3.join(storage.dir, "summaries", "hourly");
|
|
4588
4798
|
try {
|
|
4589
4799
|
const sessionKeys = await readdir(hourlyBaseDir, { withFileTypes: true });
|
|
4590
4800
|
for (const sk of sessionKeys) {
|
|
4591
4801
|
if (!sk.isDirectory()) continue;
|
|
4592
4802
|
for (const date of datesToScan) {
|
|
4593
|
-
const summaryFile =
|
|
4803
|
+
const summaryFile = path3.join(hourlyBaseDir, sk.name, `${date}.md`);
|
|
4594
4804
|
try {
|
|
4595
4805
|
const raw = await readFile2(summaryFile, "utf-8");
|
|
4596
4806
|
const filtered = filterHourlySummaryMarkdownForLocalDay(
|
|
@@ -4694,7 +4904,7 @@ ${evidenceText}`
|
|
|
4694
4904
|
}
|
|
4695
4905
|
async getLastGraphRecallSnapshot(namespace) {
|
|
4696
4906
|
const storage = await this.getStorage(namespace);
|
|
4697
|
-
const snapshotPath =
|
|
4907
|
+
const snapshotPath = path3.join(
|
|
4698
4908
|
storage.dir,
|
|
4699
4909
|
"state",
|
|
4700
4910
|
"last_graph_recall.json"
|
|
@@ -4733,7 +4943,7 @@ ${evidenceText}`
|
|
|
4733
4943
|
}
|
|
4734
4944
|
async getLastIntentSnapshot(namespace) {
|
|
4735
4945
|
const storage = await this.getStorage(namespace);
|
|
4736
|
-
const snapshotPath =
|
|
4946
|
+
const snapshotPath = path3.join(storage.dir, "state", "last_intent.json");
|
|
4737
4947
|
try {
|
|
4738
4948
|
const raw = await readFile2(snapshotPath, "utf-8");
|
|
4739
4949
|
const parsed = JSON.parse(raw);
|
|
@@ -4766,7 +4976,7 @@ ${evidenceText}`
|
|
|
4766
4976
|
}
|
|
4767
4977
|
async getLastQmdRecallSnapshot(namespace) {
|
|
4768
4978
|
const storage = await this.getStorage(namespace);
|
|
4769
|
-
const snapshotPath =
|
|
4979
|
+
const snapshotPath = path3.join(
|
|
4770
4980
|
storage.dir,
|
|
4771
4981
|
"state",
|
|
4772
4982
|
"last_qmd_recall.json"
|
|
@@ -4919,7 +5129,7 @@ ${r.snippet.trim()}
|
|
|
4919
5129
|
const entries = await readdir(dir, { withFileTypes: true });
|
|
4920
5130
|
let total = 0;
|
|
4921
5131
|
for (const entry of entries) {
|
|
4922
|
-
const fullPath =
|
|
5132
|
+
const fullPath = path3.join(dir, entry.name);
|
|
4923
5133
|
if (entry.isDirectory()) {
|
|
4924
5134
|
total += await this.countConversationChunkDocs(fullPath);
|
|
4925
5135
|
continue;
|
|
@@ -5825,7 +6035,7 @@ ${r.snippet.trim()}
|
|
|
5825
6035
|
resolvedPath = resolvedCold.result.path;
|
|
5826
6036
|
resolvedResult = resolvedCold.result;
|
|
5827
6037
|
}
|
|
5828
|
-
if (!
|
|
6038
|
+
if (!path3.isAbsolute(resolvedPath)) {
|
|
5829
6039
|
resolvedAmbiguousSeeds.set(result.path, null);
|
|
5830
6040
|
return null;
|
|
5831
6041
|
}
|
|
@@ -5850,7 +6060,7 @@ ${r.snippet.trim()}
|
|
|
5850
6060
|
}
|
|
5851
6061
|
continue;
|
|
5852
6062
|
}
|
|
5853
|
-
if (
|
|
6063
|
+
if (path3.isAbsolute(result.path)) {
|
|
5854
6064
|
const resolved = await resolveAmbiguousSeedOwner(result, null);
|
|
5855
6065
|
if (resolved) {
|
|
5856
6066
|
addResultForNamespace(resolved.namespace, resolved.result);
|
|
@@ -5893,7 +6103,7 @@ ${r.snippet.trim()}
|
|
|
5893
6103
|
0
|
|
5894
6104
|
);
|
|
5895
6105
|
seedPaths.push(
|
|
5896
|
-
...seedRelativePaths.map((rel) =>
|
|
6106
|
+
...seedRelativePaths.map((rel) => path3.join(storage.dir, rel))
|
|
5897
6107
|
);
|
|
5898
6108
|
const seedSet = new Set(seedRelativePaths);
|
|
5899
6109
|
const expanded = await this.graphIndexFor(storage).spreadingActivation(
|
|
@@ -5909,7 +6119,7 @@ ${r.snippet.trim()}
|
|
|
5909
6119
|
for (const candidate of expanded.slice(0, perNamespaceExpandedCap)) {
|
|
5910
6120
|
if (deadlineExpired()) break;
|
|
5911
6121
|
if (seedSet.has(candidate.path)) continue;
|
|
5912
|
-
const memoryPath =
|
|
6122
|
+
const memoryPath = path3.resolve(storage.dir, candidate.path);
|
|
5913
6123
|
const memory = await storage.readMemoryByPath(memoryPath);
|
|
5914
6124
|
if (deadlineExpired()) break;
|
|
5915
6125
|
if (!memory) continue;
|
|
@@ -5934,7 +6144,7 @@ ${r.snippet.trim()}
|
|
|
5934
6144
|
path: memory.path,
|
|
5935
6145
|
score,
|
|
5936
6146
|
namespace,
|
|
5937
|
-
seed:
|
|
6147
|
+
seed: path3.resolve(storage.dir, candidate.seed),
|
|
5938
6148
|
hopDepth: candidate.hopDepth,
|
|
5939
6149
|
decayedWeight: candidate.decayedWeight,
|
|
5940
6150
|
graphType: candidate.graphType,
|
|
@@ -5955,12 +6165,12 @@ ${r.snippet.trim()}
|
|
|
5955
6165
|
}
|
|
5956
6166
|
async recordLastGraphRecallSnapshot(options) {
|
|
5957
6167
|
try {
|
|
5958
|
-
const snapshotPath =
|
|
6168
|
+
const snapshotPath = path3.join(
|
|
5959
6169
|
options.storage.dir,
|
|
5960
6170
|
"state",
|
|
5961
6171
|
"last_graph_recall.json"
|
|
5962
6172
|
);
|
|
5963
|
-
await mkdir2(
|
|
6173
|
+
await mkdir2(path3.dirname(snapshotPath), { recursive: true });
|
|
5964
6174
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
5965
6175
|
const totalSeedCount = options.seedPaths.length;
|
|
5966
6176
|
const totalExpandedCount = options.expandedPaths.length;
|
|
@@ -5994,12 +6204,12 @@ ${r.snippet.trim()}
|
|
|
5994
6204
|
}
|
|
5995
6205
|
async recordLastIntentSnapshot(options) {
|
|
5996
6206
|
try {
|
|
5997
|
-
const snapshotPath =
|
|
6207
|
+
const snapshotPath = path3.join(
|
|
5998
6208
|
options.storage.dir,
|
|
5999
6209
|
"state",
|
|
6000
6210
|
"last_intent.json"
|
|
6001
6211
|
);
|
|
6002
|
-
await mkdir2(
|
|
6212
|
+
await mkdir2(path3.dirname(snapshotPath), { recursive: true });
|
|
6003
6213
|
await writeFile2(
|
|
6004
6214
|
snapshotPath,
|
|
6005
6215
|
JSON.stringify(options.snapshot, null, 2),
|
|
@@ -6011,12 +6221,12 @@ ${r.snippet.trim()}
|
|
|
6011
6221
|
}
|
|
6012
6222
|
async recordLastQmdRecallSnapshot(options) {
|
|
6013
6223
|
try {
|
|
6014
|
-
const snapshotPath =
|
|
6224
|
+
const snapshotPath = path3.join(
|
|
6015
6225
|
options.storage.dir,
|
|
6016
6226
|
"state",
|
|
6017
6227
|
"last_qmd_recall.json"
|
|
6018
6228
|
);
|
|
6019
|
-
await mkdir2(
|
|
6229
|
+
await mkdir2(path3.dirname(snapshotPath), { recursive: true });
|
|
6020
6230
|
await writeFile2(
|
|
6021
6231
|
snapshotPath,
|
|
6022
6232
|
JSON.stringify(options.snapshot, null, 2),
|
|
@@ -6031,8 +6241,8 @@ ${r.snippet.trim()}
|
|
|
6031
6241
|
const stateDir = await this.resolveStateDirForNamespace(
|
|
6032
6242
|
options.namespace
|
|
6033
6243
|
);
|
|
6034
|
-
const snapshotPath =
|
|
6035
|
-
await mkdir2(
|
|
6244
|
+
const snapshotPath = path3.join(stateDir, "last_intent.json");
|
|
6245
|
+
await mkdir2(path3.dirname(snapshotPath), { recursive: true });
|
|
6036
6246
|
await writeFile2(
|
|
6037
6247
|
snapshotPath,
|
|
6038
6248
|
JSON.stringify(options.snapshot, null, 2),
|
|
@@ -6044,12 +6254,12 @@ ${r.snippet.trim()}
|
|
|
6044
6254
|
}
|
|
6045
6255
|
async resolveStateDirForNamespace(namespace) {
|
|
6046
6256
|
if (!this.config.namespacesEnabled) {
|
|
6047
|
-
return
|
|
6257
|
+
return path3.join(this.config.memoryDir, "state");
|
|
6048
6258
|
}
|
|
6049
6259
|
if (namespace !== this.config.defaultNamespace) {
|
|
6050
|
-
return
|
|
6260
|
+
return path3.join(this.config.memoryDir, "namespaces", namespace, "state");
|
|
6051
6261
|
}
|
|
6052
|
-
const candidate =
|
|
6262
|
+
const candidate = path3.join(
|
|
6053
6263
|
this.config.memoryDir,
|
|
6054
6264
|
"namespaces",
|
|
6055
6265
|
this.config.defaultNamespace
|
|
@@ -6057,11 +6267,11 @@ ${r.snippet.trim()}
|
|
|
6057
6267
|
try {
|
|
6058
6268
|
const candidateStat = await stat(candidate);
|
|
6059
6269
|
if (candidateStat.isDirectory()) {
|
|
6060
|
-
return
|
|
6270
|
+
return path3.join(candidate, "state");
|
|
6061
6271
|
}
|
|
6062
6272
|
} catch {
|
|
6063
6273
|
}
|
|
6064
|
-
return
|
|
6274
|
+
return path3.join(this.config.memoryDir, "state");
|
|
6065
6275
|
}
|
|
6066
6276
|
buildGraphRecallRankedResults(results, sourceLabelResolver, limit = 64) {
|
|
6067
6277
|
return results.slice(0, limit).map((result) => ({
|
|
@@ -6260,8 +6470,8 @@ ${r.snippet.trim()}
|
|
|
6260
6470
|
const timings = {};
|
|
6261
6471
|
const profileTraceId = this.profiler.startTrace("recall", sessionKey, {
|
|
6262
6472
|
qmdEnabled: this.config.qmdEnabled,
|
|
6263
|
-
rerankEnabled:
|
|
6264
|
-
parallelRetrieval:
|
|
6473
|
+
rerankEnabled: caps.rerank,
|
|
6474
|
+
parallelRetrieval: caps.parallelRetrieval
|
|
6265
6475
|
});
|
|
6266
6476
|
this.profiler.startSpan("planning", profileTraceId);
|
|
6267
6477
|
let profileTraceClosed = false;
|
|
@@ -6332,6 +6542,10 @@ ${r.snippet.trim()}
|
|
|
6332
6542
|
let recalledMemoryIds = [];
|
|
6333
6543
|
let recalledMemoryPaths = [];
|
|
6334
6544
|
let xrayRecalledResults = [];
|
|
6545
|
+
let recallTrustByPath = null;
|
|
6546
|
+
const trustByPathSink = {
|
|
6547
|
+
trustByPath: null
|
|
6548
|
+
};
|
|
6335
6549
|
const lcmStructuredXrayResults = [];
|
|
6336
6550
|
const xrayBranchPoolSize = {
|
|
6337
6551
|
hot_qmd: 0,
|
|
@@ -6459,7 +6673,7 @@ ${r.snippet.trim()}
|
|
|
6459
6673
|
const graphExpandedResultPaths = /* @__PURE__ */ new Set();
|
|
6460
6674
|
const graphSourceLabelsForPath = (resultPath) => {
|
|
6461
6675
|
const labels = [];
|
|
6462
|
-
const normalizedPath = resultPath.split(
|
|
6676
|
+
const normalizedPath = resultPath.split(path3.sep).join("/");
|
|
6463
6677
|
const isEntityPath = normalizedPath.startsWith("entities/") || normalizedPath.includes("/entities/");
|
|
6464
6678
|
if (graphBaselinePaths.has(resultPath)) labels.push("baseline");
|
|
6465
6679
|
if (graphExpandedResultPaths.has(resultPath))
|
|
@@ -6609,7 +6823,7 @@ ${r.snippet.trim()}
|
|
|
6609
6823
|
profileStorageNamespaces.map((namespace) => this.storageRouter.storageFor(namespace))
|
|
6610
6824
|
);
|
|
6611
6825
|
const emptyProfileStorage = new Proxy(
|
|
6612
|
-
{ dir:
|
|
6826
|
+
{ dir: path3.join(this.config.memoryDir, ".empty-scope-profile") },
|
|
6613
6827
|
{
|
|
6614
6828
|
get(target, prop) {
|
|
6615
6829
|
if (prop in target) return target[prop];
|
|
@@ -7363,9 +7577,9 @@ ${rows.join("\n")}
|
|
|
7363
7577
|
const harmonicRetrievalPromise = observeEnrichmentPromise(
|
|
7364
7578
|
(async () => {
|
|
7365
7579
|
const t0 = Date.now();
|
|
7366
|
-
if (!
|
|
7580
|
+
if (!caps.harmonicRetrieval || !this.isRecallSectionEnabled(
|
|
7367
7581
|
"harmonic-retrieval",
|
|
7368
|
-
|
|
7582
|
+
caps.harmonicRetrieval
|
|
7369
7583
|
)) {
|
|
7370
7584
|
recordRecallSectionMetric({
|
|
7371
7585
|
section: "harmonicRetrieval",
|
|
@@ -7830,7 +8044,7 @@ ${rows.join("\n")}
|
|
|
7830
8044
|
log.info(`QMD re-probe succeeded: ${this.qmd.debugStatus()}`);
|
|
7831
8045
|
}
|
|
7832
8046
|
const maxPerAgent = this.config.parallelMaxResultsPerAgent;
|
|
7833
|
-
const specializedAgentPromise = !queryAwarePrefilterIsEmpty &&
|
|
8047
|
+
const specializedAgentPromise = !queryAwarePrefilterIsEmpty && caps.parallelRetrieval && maxPerAgent > 0 ? Promise.all([
|
|
7834
8048
|
shouldRunAgent("direct", retrievalQuery, 0) ? Promise.all(
|
|
7835
8049
|
profileStorageDirs.map(
|
|
7836
8050
|
(memoryDir) => runDirectAgent(
|
|
@@ -7903,7 +8117,7 @@ ${rows.join("\n")}
|
|
|
7903
8117
|
const preAugmentTopScore = filteredResults.length > 0 ? Math.max(...filteredResults.map((r) => r.score)) : 0;
|
|
7904
8118
|
let augmentedResults = filteredResults;
|
|
7905
8119
|
let maxSpecializedScore = 0;
|
|
7906
|
-
if (
|
|
8120
|
+
if (caps.parallelRetrieval && specializedAgentPromise) {
|
|
7907
8121
|
try {
|
|
7908
8122
|
const [directResults, temporalResults] = await specializedAgentPromise;
|
|
7909
8123
|
if (filteredResults.length > 0) {
|
|
@@ -8085,11 +8299,11 @@ ${formatted}`;
|
|
|
8085
8299
|
if (!this.config.compactionResetEnabled) return null;
|
|
8086
8300
|
const workspaceDir = compactionWorkspaceDir || this.config.workspaceDir || defaultWorkspaceDir();
|
|
8087
8301
|
const safeSessionKey = sanitizeSessionKeyForFilename(effectiveSessionKey);
|
|
8088
|
-
const signalPath =
|
|
8302
|
+
const signalPath = path3.join(
|
|
8089
8303
|
workspaceDir,
|
|
8090
8304
|
`.compaction-reset-signal-${safeSessionKey}`
|
|
8091
8305
|
);
|
|
8092
|
-
const bootPath =
|
|
8306
|
+
const bootPath = path3.join(workspaceDir, "BOOT.md");
|
|
8093
8307
|
try {
|
|
8094
8308
|
const signalStat = await stat(signalPath).catch(() => null);
|
|
8095
8309
|
if (!signalStat) return null;
|
|
@@ -9110,7 +9324,7 @@ ${tmtNode.summary}`
|
|
|
9110
9324
|
),
|
|
9111
9325
|
qmdBoostInput.results
|
|
9112
9326
|
);
|
|
9113
|
-
if (
|
|
9327
|
+
if (caps.rerank && this.config.rerankProvider === "local") {
|
|
9114
9328
|
const ranked = await rerankLocalOrNoop({
|
|
9115
9329
|
query: retrievalQuery,
|
|
9116
9330
|
candidates: memoryResults.slice(0, this.config.rerankMaxCandidates).map((r) => ({
|
|
@@ -9139,17 +9353,20 @@ ${tmtNode.summary}`
|
|
|
9139
9353
|
memoryResults = reordered;
|
|
9140
9354
|
}
|
|
9141
9355
|
}
|
|
9142
|
-
if (
|
|
9356
|
+
if (caps.rerank && this.config.rerankProvider === "cloud") {
|
|
9143
9357
|
log.debug(
|
|
9144
9358
|
"rerankProvider=cloud is reserved/experimental in v2.2.0; skipping rerank"
|
|
9145
9359
|
);
|
|
9146
9360
|
}
|
|
9147
|
-
|
|
9148
|
-
|
|
9149
|
-
memoryResults
|
|
9150
|
-
|
|
9151
|
-
|
|
9152
|
-
|
|
9361
|
+
{
|
|
9362
|
+
const trustOutcome = await this.applyTrustScoreToBranch(
|
|
9363
|
+
memoryResults,
|
|
9364
|
+
recallNamespaces,
|
|
9365
|
+
caps,
|
|
9366
|
+
"hot-qmd"
|
|
9367
|
+
);
|
|
9368
|
+
memoryResults = trustOutcome.results;
|
|
9369
|
+
recallTrustByPath = trustOutcome.trustByPath;
|
|
9153
9370
|
}
|
|
9154
9371
|
const effectiveGateScore = preAugmentTopScore > 0 ? Math.max(preAugmentTopScore, maxSpecializedScore) : 0;
|
|
9155
9372
|
xrayBranchPoolSize.hot_qmd = Math.max(
|
|
@@ -9227,7 +9444,8 @@ ${tmtNode.summary}`
|
|
|
9227
9444
|
mode: identityInjectionModeUsed,
|
|
9228
9445
|
injectedChars: identityInjectedChars,
|
|
9229
9446
|
truncated: identityInjectionTruncated
|
|
9230
|
-
}
|
|
9447
|
+
},
|
|
9448
|
+
trustByPath: recallTrustByPath
|
|
9231
9449
|
});
|
|
9232
9450
|
recalledMemoryIds = this.extractMemoryIdsFromResults(memoryResults);
|
|
9233
9451
|
recalledMemoryPaths = memoryResults.map((result) => result.path).filter(Boolean);
|
|
@@ -9236,7 +9454,7 @@ ${tmtNode.summary}`
|
|
|
9236
9454
|
} else if (!confidenceGateRejected) {
|
|
9237
9455
|
const queryAwarePrefilter = await queryAwarePrefilterPromise;
|
|
9238
9456
|
if (queryAwarePrefilter.candidatePaths?.size !== 0) {
|
|
9239
|
-
|
|
9457
|
+
let scoped = await awaitAssemblyStep(
|
|
9240
9458
|
"embedding-fallback",
|
|
9241
9459
|
async () => {
|
|
9242
9460
|
const embeddingResults = await this.searchEmbeddingFallback(
|
|
@@ -9277,6 +9495,16 @@ ${tmtNode.summary}`
|
|
|
9277
9495
|
},
|
|
9278
9496
|
[]
|
|
9279
9497
|
);
|
|
9498
|
+
{
|
|
9499
|
+
const trustOutcome = await this.applyTrustScoreToBranch(
|
|
9500
|
+
scoped,
|
|
9501
|
+
recallNamespaces,
|
|
9502
|
+
caps,
|
|
9503
|
+
"embedding-fallback"
|
|
9504
|
+
);
|
|
9505
|
+
scoped = trustOutcome.results;
|
|
9506
|
+
recallTrustByPath = trustOutcome.trustByPath;
|
|
9507
|
+
}
|
|
9280
9508
|
if (scoped.length > 0) {
|
|
9281
9509
|
if (shouldPersistGraphSnapshot) {
|
|
9282
9510
|
graphSnapshotFinalResults = this.buildGraphRecallRankedResults(
|
|
@@ -9296,7 +9524,8 @@ ${tmtNode.summary}`
|
|
|
9296
9524
|
mode: identityInjectionModeUsed,
|
|
9297
9525
|
injectedChars: identityInjectedChars,
|
|
9298
9526
|
truncated: identityInjectionTruncated
|
|
9299
|
-
}
|
|
9527
|
+
},
|
|
9528
|
+
trustByPath: recallTrustByPath
|
|
9300
9529
|
});
|
|
9301
9530
|
recalledMemoryIds = this.extractMemoryIdsFromResults(scoped);
|
|
9302
9531
|
recalledMemoryPaths = scoped.map((result) => result.path).filter(Boolean);
|
|
@@ -9316,10 +9545,12 @@ ${tmtNode.summary}`
|
|
|
9316
9545
|
backendDegradations.push(degradation);
|
|
9317
9546
|
},
|
|
9318
9547
|
xrayPoolSizeSink: xrayColdPoolSink,
|
|
9548
|
+
trustByPathSink,
|
|
9319
9549
|
deadlineAtMs: enrichmentAssemblyDeadlineAtMs,
|
|
9320
9550
|
asOfMs,
|
|
9321
9551
|
...options.includeLowConfidence === true ? { includeLowConfidence: true } : {}
|
|
9322
9552
|
});
|
|
9553
|
+
recallTrustByPath = trustByPathSink.trustByPath;
|
|
9323
9554
|
if (longTerm.length > 0) {
|
|
9324
9555
|
if (shouldPersistGraphSnapshot) {
|
|
9325
9556
|
graphSnapshotFinalResults = this.buildGraphRecallRankedResults(
|
|
@@ -9339,7 +9570,8 @@ ${tmtNode.summary}`
|
|
|
9339
9570
|
mode: identityInjectionModeUsed,
|
|
9340
9571
|
injectedChars: identityInjectedChars,
|
|
9341
9572
|
truncated: identityInjectionTruncated
|
|
9342
|
-
}
|
|
9573
|
+
},
|
|
9574
|
+
trustByPath: recallTrustByPath
|
|
9343
9575
|
});
|
|
9344
9576
|
recalledMemoryIds = this.extractMemoryIdsFromResults(longTerm);
|
|
9345
9577
|
recalledMemoryPaths = longTerm.map((result) => result.path).filter(Boolean);
|
|
@@ -9353,7 +9585,7 @@ ${tmtNode.summary}`
|
|
|
9353
9585
|
this.appendRecallSection(
|
|
9354
9586
|
sectionBuckets,
|
|
9355
9587
|
"workspace-context",
|
|
9356
|
-
this.formatQmdResults("Workspace Context", globalResults, sessionKey)
|
|
9588
|
+
this.formatQmdResults("Workspace Context", globalResults, sessionKey, recallTrustByPath)
|
|
9357
9589
|
);
|
|
9358
9590
|
}
|
|
9359
9591
|
recordRecallSectionMetric({
|
|
@@ -9383,7 +9615,7 @@ ${tmtNode.summary}`
|
|
|
9383
9615
|
} else if (recallResultLimit > 0 && !this.qmd.isAvailable()) {
|
|
9384
9616
|
const queryAwarePrefilter = await queryAwarePrefilterPromise;
|
|
9385
9617
|
if (queryAwarePrefilter.candidatePaths?.size !== 0) {
|
|
9386
|
-
|
|
9618
|
+
let scoped = await awaitAssemblyStep(
|
|
9387
9619
|
"embedding-fallback",
|
|
9388
9620
|
async () => {
|
|
9389
9621
|
const embeddingResults = await this.searchEmbeddingFallback(
|
|
@@ -9424,6 +9656,16 @@ ${tmtNode.summary}`
|
|
|
9424
9656
|
},
|
|
9425
9657
|
[]
|
|
9426
9658
|
);
|
|
9659
|
+
{
|
|
9660
|
+
const trustOutcome = await this.applyTrustScoreToBranch(
|
|
9661
|
+
scoped,
|
|
9662
|
+
recallNamespaces,
|
|
9663
|
+
caps,
|
|
9664
|
+
"embedding-fallback"
|
|
9665
|
+
);
|
|
9666
|
+
scoped = trustOutcome.results;
|
|
9667
|
+
recallTrustByPath = trustOutcome.trustByPath;
|
|
9668
|
+
}
|
|
9427
9669
|
if (scoped.length > 0) {
|
|
9428
9670
|
if (shouldPersistGraphSnapshot) {
|
|
9429
9671
|
graphSnapshotFinalResults = this.buildGraphRecallRankedResults(
|
|
@@ -9443,7 +9685,8 @@ ${tmtNode.summary}`
|
|
|
9443
9685
|
mode: identityInjectionModeUsed,
|
|
9444
9686
|
injectedChars: identityInjectedChars,
|
|
9445
9687
|
truncated: identityInjectionTruncated
|
|
9446
|
-
}
|
|
9688
|
+
},
|
|
9689
|
+
trustByPath: recallTrustByPath
|
|
9447
9690
|
});
|
|
9448
9691
|
recalledMemoryIds = this.extractMemoryIdsFromResults(scoped);
|
|
9449
9692
|
recalledMemoryPaths = scoped.map((result) => result.path).filter(Boolean);
|
|
@@ -9490,10 +9733,12 @@ ${tmtNode.summary}`
|
|
|
9490
9733
|
backendDegradations.push(degradation);
|
|
9491
9734
|
},
|
|
9492
9735
|
xrayPoolSizeSink: xrayColdPoolSink,
|
|
9736
|
+
trustByPathSink,
|
|
9493
9737
|
deadlineAtMs: enrichmentAssemblyDeadlineAtMs,
|
|
9494
9738
|
asOfMs,
|
|
9495
9739
|
...options.includeLowConfidence === true ? { includeLowConfidence: true } : {}
|
|
9496
9740
|
});
|
|
9741
|
+
recallTrustByPath = trustByPathSink.trustByPath;
|
|
9497
9742
|
if (longTerm.length > 0) {
|
|
9498
9743
|
recallSource = "cold_fallback";
|
|
9499
9744
|
recalledMemoryCount = longTerm.length;
|
|
@@ -9507,7 +9752,8 @@ ${tmtNode.summary}`
|
|
|
9507
9752
|
mode: identityInjectionModeUsed,
|
|
9508
9753
|
injectedChars: identityInjectedChars,
|
|
9509
9754
|
truncated: identityInjectionTruncated
|
|
9510
|
-
}
|
|
9755
|
+
},
|
|
9756
|
+
trustByPath: recallTrustByPath
|
|
9511
9757
|
});
|
|
9512
9758
|
recalledMemoryIds = this.extractMemoryIdsFromResults(longTerm);
|
|
9513
9759
|
recalledMemoryPaths = longTerm.map((result) => result.path).filter(Boolean);
|
|
@@ -9515,7 +9761,7 @@ ${tmtNode.summary}`
|
|
|
9515
9761
|
impressionRecorded = true;
|
|
9516
9762
|
}
|
|
9517
9763
|
} else {
|
|
9518
|
-
|
|
9764
|
+
let recent = await awaitAssemblyStep(
|
|
9519
9765
|
"recent-memory-scan",
|
|
9520
9766
|
async () => {
|
|
9521
9767
|
const recentSorted = queryAwareScopedMemories.sort(
|
|
@@ -9553,6 +9799,16 @@ ${tmtNode.summary}`
|
|
|
9553
9799
|
},
|
|
9554
9800
|
[]
|
|
9555
9801
|
);
|
|
9802
|
+
{
|
|
9803
|
+
const trustOutcome = await this.applyTrustScoreToBranch(
|
|
9804
|
+
recent,
|
|
9805
|
+
recallNamespaces,
|
|
9806
|
+
caps,
|
|
9807
|
+
"recent-scan"
|
|
9808
|
+
);
|
|
9809
|
+
recent = trustOutcome.results;
|
|
9810
|
+
recallTrustByPath = trustOutcome.trustByPath;
|
|
9811
|
+
}
|
|
9556
9812
|
if (recent.length > 0) {
|
|
9557
9813
|
if (shouldPersistGraphSnapshot) {
|
|
9558
9814
|
graphSnapshotFinalResults = this.buildGraphRecallRankedResults(
|
|
@@ -9572,7 +9828,8 @@ ${tmtNode.summary}`
|
|
|
9572
9828
|
mode: identityInjectionModeUsed,
|
|
9573
9829
|
injectedChars: identityInjectedChars,
|
|
9574
9830
|
truncated: identityInjectionTruncated
|
|
9575
|
-
}
|
|
9831
|
+
},
|
|
9832
|
+
trustByPath: recallTrustByPath
|
|
9576
9833
|
});
|
|
9577
9834
|
recalledMemoryIds = this.extractMemoryIdsFromResults(recent);
|
|
9578
9835
|
recalledMemoryPaths = recent.map((result) => result.path).filter(Boolean);
|
|
@@ -9592,10 +9849,12 @@ ${tmtNode.summary}`
|
|
|
9592
9849
|
backendDegradations.push(degradation);
|
|
9593
9850
|
},
|
|
9594
9851
|
xrayPoolSizeSink: xrayColdPoolSink,
|
|
9852
|
+
trustByPathSink,
|
|
9595
9853
|
deadlineAtMs: enrichmentAssemblyDeadlineAtMs,
|
|
9596
9854
|
asOfMs,
|
|
9597
9855
|
...options.includeLowConfidence === true ? { includeLowConfidence: true } : {}
|
|
9598
9856
|
});
|
|
9857
|
+
recallTrustByPath = trustByPathSink.trustByPath;
|
|
9599
9858
|
if (longTerm.length > 0) {
|
|
9600
9859
|
if (shouldPersistGraphSnapshot) {
|
|
9601
9860
|
graphSnapshotFinalResults = this.buildGraphRecallRankedResults(
|
|
@@ -9615,7 +9874,8 @@ ${tmtNode.summary}`
|
|
|
9615
9874
|
mode: identityInjectionModeUsed,
|
|
9616
9875
|
injectedChars: identityInjectedChars,
|
|
9617
9876
|
truncated: identityInjectionTruncated
|
|
9618
|
-
}
|
|
9877
|
+
},
|
|
9878
|
+
trustByPath: recallTrustByPath
|
|
9619
9879
|
});
|
|
9620
9880
|
recalledMemoryIds = this.extractMemoryIdsFromResults(longTerm);
|
|
9621
9881
|
recalledMemoryPaths = longTerm.map((result) => result.path).filter(Boolean);
|
|
@@ -9638,10 +9898,12 @@ ${tmtNode.summary}`
|
|
|
9638
9898
|
backendDegradations.push(degradation);
|
|
9639
9899
|
},
|
|
9640
9900
|
xrayPoolSizeSink: xrayColdPoolSink,
|
|
9901
|
+
trustByPathSink,
|
|
9641
9902
|
deadlineAtMs: enrichmentAssemblyDeadlineAtMs,
|
|
9642
9903
|
asOfMs,
|
|
9643
9904
|
...options.includeLowConfidence === true ? { includeLowConfidence: true } : {}
|
|
9644
9905
|
});
|
|
9906
|
+
recallTrustByPath = trustByPathSink.trustByPath;
|
|
9645
9907
|
if (longTerm.length > 0) {
|
|
9646
9908
|
if (shouldPersistGraphSnapshot) {
|
|
9647
9909
|
graphSnapshotFinalResults = this.buildGraphRecallRankedResults(
|
|
@@ -9661,7 +9923,8 @@ ${tmtNode.summary}`
|
|
|
9661
9923
|
mode: identityInjectionModeUsed,
|
|
9662
9924
|
injectedChars: identityInjectedChars,
|
|
9663
9925
|
truncated: identityInjectionTruncated
|
|
9664
|
-
}
|
|
9926
|
+
},
|
|
9927
|
+
trustByPath: recallTrustByPath
|
|
9665
9928
|
});
|
|
9666
9929
|
recalledMemoryIds = this.extractMemoryIdsFromResults(longTerm);
|
|
9667
9930
|
recalledMemoryPaths = longTerm.map((result) => result.path).filter(Boolean);
|
|
@@ -9864,6 +10127,7 @@ _Context: ${topQuestion.context}_`
|
|
|
9864
10127
|
}
|
|
9865
10128
|
} catch {
|
|
9866
10129
|
}
|
|
10130
|
+
const trustItem = recallTrustByPath?.get(recalledPath);
|
|
9867
10131
|
results.push({
|
|
9868
10132
|
memoryId: derivedId,
|
|
9869
10133
|
path: recalledPath,
|
|
@@ -9871,9 +10135,27 @@ _Context: ${topQuestion.context}_`
|
|
|
9871
10135
|
scoreDecomposition,
|
|
9872
10136
|
admittedBy: [],
|
|
9873
10137
|
...provenance ? { provenance } : {},
|
|
9874
|
-
...sourceSpan ? { sourceSpan } : {}
|
|
10138
|
+
...sourceSpan ? { sourceSpan } : {},
|
|
10139
|
+
// Issue #1577 — per-result trust projection for X-ray visibility.
|
|
10140
|
+
...trustItem ? { trust: projectTrustForXray(trustItem) } : {}
|
|
9875
10141
|
});
|
|
9876
10142
|
}
|
|
10143
|
+
if (recallTrustByPath) {
|
|
10144
|
+
for (const [qPath, qItem] of recallTrustByPath) {
|
|
10145
|
+
if (!qItem.quarantined || recalledMemoryPaths.includes(qPath)) continue;
|
|
10146
|
+
const qId = idFromPath(qPath);
|
|
10147
|
+
if (!qId) continue;
|
|
10148
|
+
results.push({
|
|
10149
|
+
memoryId: qId,
|
|
10150
|
+
path: qPath,
|
|
10151
|
+
servedBy,
|
|
10152
|
+
scoreDecomposition: { final: 0 },
|
|
10153
|
+
admittedBy: [],
|
|
10154
|
+
rejectedBy: "trust-score:quarantine",
|
|
10155
|
+
trust: projectTrustForXray(qItem)
|
|
10156
|
+
});
|
|
10157
|
+
}
|
|
10158
|
+
}
|
|
9877
10159
|
let xrayConsidered;
|
|
9878
10160
|
switch (recallSource) {
|
|
9879
10161
|
case "hot_qmd":
|
|
@@ -11126,165 +11408,7 @@ ${normalized}`).digest("hex");
|
|
|
11126
11408
|
}
|
|
11127
11409
|
}
|
|
11128
11410
|
async runTierMigrationCycle(storage, trigger, options) {
|
|
11129
|
-
|
|
11130
|
-
const persistSkipped = options?.force === true || trigger === "manual";
|
|
11131
|
-
if (!this.config.qmdTierMigrationEnabled && options?.force !== true) {
|
|
11132
|
-
const skipped = {
|
|
11133
|
-
trigger,
|
|
11134
|
-
scanned: 0,
|
|
11135
|
-
migrated: 0,
|
|
11136
|
-
promoted: 0,
|
|
11137
|
-
demoted: 0,
|
|
11138
|
-
limit: 0,
|
|
11139
|
-
dryRun,
|
|
11140
|
-
skipped: "tier_migration_disabled"
|
|
11141
|
-
};
|
|
11142
|
-
if (persistSkipped) await this.tierMigrationStatus.recordCycle(skipped);
|
|
11143
|
-
return skipped;
|
|
11144
|
-
}
|
|
11145
|
-
if (trigger === "maintenance" && !this.config.qmdTierAutoBackfillEnabled && options?.force !== true) {
|
|
11146
|
-
const skipped = {
|
|
11147
|
-
trigger,
|
|
11148
|
-
scanned: 0,
|
|
11149
|
-
migrated: 0,
|
|
11150
|
-
promoted: 0,
|
|
11151
|
-
demoted: 0,
|
|
11152
|
-
limit: 0,
|
|
11153
|
-
dryRun,
|
|
11154
|
-
skipped: "maintenance_backfill_disabled"
|
|
11155
|
-
};
|
|
11156
|
-
if (persistSkipped) await this.tierMigrationStatus.recordCycle(skipped);
|
|
11157
|
-
return skipped;
|
|
11158
|
-
}
|
|
11159
|
-
if (this.tierMigrationInFlight) {
|
|
11160
|
-
const skipped = {
|
|
11161
|
-
trigger,
|
|
11162
|
-
scanned: 0,
|
|
11163
|
-
migrated: 0,
|
|
11164
|
-
promoted: 0,
|
|
11165
|
-
demoted: 0,
|
|
11166
|
-
limit: 0,
|
|
11167
|
-
dryRun,
|
|
11168
|
-
skipped: "migration_in_flight"
|
|
11169
|
-
};
|
|
11170
|
-
if (persistSkipped) await this.tierMigrationStatus.recordCycle(skipped);
|
|
11171
|
-
return skipped;
|
|
11172
|
-
}
|
|
11173
|
-
const budgetTrigger = trigger === "manual" ? "maintenance" : trigger;
|
|
11174
|
-
const budget = this.compounding?.tierMigrationCycleBudget(budgetTrigger) ?? defaultTierMigrationCycleBudget(this.config, budgetTrigger);
|
|
11175
|
-
const limit = options?.limitOverride !== void 0 ? Math.max(0, Math.floor(options.limitOverride)) : budget.limit;
|
|
11176
|
-
const nowMs = Date.now();
|
|
11177
|
-
if (options?.force !== true && nowMs - this.lastTierMigrationRunAtMs < budget.minIntervalMs) {
|
|
11178
|
-
const skipped = {
|
|
11179
|
-
trigger,
|
|
11180
|
-
scanned: 0,
|
|
11181
|
-
migrated: 0,
|
|
11182
|
-
promoted: 0,
|
|
11183
|
-
demoted: 0,
|
|
11184
|
-
limit,
|
|
11185
|
-
dryRun,
|
|
11186
|
-
skipped: "min_interval"
|
|
11187
|
-
};
|
|
11188
|
-
if (persistSkipped) await this.tierMigrationStatus.recordCycle(skipped);
|
|
11189
|
-
return skipped;
|
|
11190
|
-
}
|
|
11191
|
-
const policy = applyUtilityPromotionRuntimePolicy(
|
|
11192
|
-
{
|
|
11193
|
-
enabled: this.config.qmdTierMigrationEnabled,
|
|
11194
|
-
demotionMinAgeDays: this.config.qmdTierDemotionMinAgeDays,
|
|
11195
|
-
demotionValueThreshold: this.config.qmdTierDemotionValueThreshold,
|
|
11196
|
-
promotionValueThreshold: this.config.qmdTierPromotionValueThreshold
|
|
11197
|
-
},
|
|
11198
|
-
this.utilityRuntimeValues
|
|
11199
|
-
);
|
|
11200
|
-
this.tierMigrationInFlight = true;
|
|
11201
|
-
try {
|
|
11202
|
-
const coldStorage = new StorageManager(path2.join(storage.dir, "cold"));
|
|
11203
|
-
const [hotMemories, coldMemories] = await Promise.all([
|
|
11204
|
-
storage.readAllMemories(),
|
|
11205
|
-
coldStorage.readAllMemories()
|
|
11206
|
-
]);
|
|
11207
|
-
const now = /* @__PURE__ */ new Date();
|
|
11208
|
-
const scanLimit = Math.max(0, Math.floor(budget.scanLimit));
|
|
11209
|
-
const hotScanLimit = Math.min(
|
|
11210
|
-
hotMemories.length,
|
|
11211
|
-
Math.ceil(scanLimit * 0.75)
|
|
11212
|
-
);
|
|
11213
|
-
const coldScanLimit = Math.min(
|
|
11214
|
-
coldMemories.length,
|
|
11215
|
-
Math.max(0, scanLimit - hotScanLimit)
|
|
11216
|
-
);
|
|
11217
|
-
const toTimestamp = (memory) => Date.parse(memory.frontmatter.updated ?? memory.frontmatter.created);
|
|
11218
|
-
const hotCandidates = hotMemories.map((memory) => ({ memory, tier: "hot" })).sort((a, b) => toTimestamp(a.memory) - toTimestamp(b.memory)).slice(0, hotScanLimit);
|
|
11219
|
-
const coldCandidates = coldMemories.map((memory) => ({ memory, tier: "cold" })).sort((a, b) => toTimestamp(b.memory) - toTimestamp(a.memory)).slice(0, coldScanLimit);
|
|
11220
|
-
const candidates = [...hotCandidates, ...coldCandidates];
|
|
11221
|
-
const migration = new TierMigrationExecutor({
|
|
11222
|
-
storage,
|
|
11223
|
-
qmd: this.qmd,
|
|
11224
|
-
hotCollection: this.config.qmdCollection,
|
|
11225
|
-
coldCollection: this.config.qmdColdCollection ?? `${this.config.qmdCollection}-cold`,
|
|
11226
|
-
autoEmbed: this.config.qmdAutoEmbedEnabled
|
|
11227
|
-
});
|
|
11228
|
-
let migrated = 0;
|
|
11229
|
-
let promoted = 0;
|
|
11230
|
-
let demoted = 0;
|
|
11231
|
-
for (const candidate of candidates) {
|
|
11232
|
-
if (migrated >= limit) break;
|
|
11233
|
-
const decision = decideTierTransition(
|
|
11234
|
-
candidate.memory,
|
|
11235
|
-
candidate.tier,
|
|
11236
|
-
policy,
|
|
11237
|
-
now
|
|
11238
|
-
);
|
|
11239
|
-
if (!decision.changed) continue;
|
|
11240
|
-
if (!dryRun) {
|
|
11241
|
-
const res = await migration.migrateMemory({
|
|
11242
|
-
memory: candidate.memory,
|
|
11243
|
-
fromTier: candidate.tier,
|
|
11244
|
-
toTier: decision.nextTier,
|
|
11245
|
-
reason: `${trigger}:${decision.reason}`
|
|
11246
|
-
});
|
|
11247
|
-
if (!res.changed) continue;
|
|
11248
|
-
}
|
|
11249
|
-
migrated += 1;
|
|
11250
|
-
if (decision.nextTier === "cold") demoted += 1;
|
|
11251
|
-
if (decision.nextTier === "hot") promoted += 1;
|
|
11252
|
-
}
|
|
11253
|
-
if (!dryRun) this.lastTierMigrationRunAtMs = Date.now();
|
|
11254
|
-
log.debug(
|
|
11255
|
-
`tier migration cycle completed: trigger=${trigger} scanned=${candidates.length} migrated=${migrated} limit=${limit}${dryRun ? " dryRun=true" : ""}`
|
|
11256
|
-
);
|
|
11257
|
-
const summary = {
|
|
11258
|
-
trigger,
|
|
11259
|
-
scanned: candidates.length,
|
|
11260
|
-
migrated,
|
|
11261
|
-
promoted,
|
|
11262
|
-
demoted,
|
|
11263
|
-
limit,
|
|
11264
|
-
dryRun
|
|
11265
|
-
};
|
|
11266
|
-
const shouldPersistCycle = trigger === "manual" || migrated > 0;
|
|
11267
|
-
if (shouldPersistCycle)
|
|
11268
|
-
await this.tierMigrationStatus.recordCycle(summary);
|
|
11269
|
-
return summary;
|
|
11270
|
-
} catch (err) {
|
|
11271
|
-
this.lastTierMigrationRunAtMs = Date.now();
|
|
11272
|
-
log.warn(`tier migration cycle failed (${trigger}, fail-open): ${err}`);
|
|
11273
|
-
const failed = {
|
|
11274
|
-
trigger,
|
|
11275
|
-
scanned: 0,
|
|
11276
|
-
migrated: 0,
|
|
11277
|
-
promoted: 0,
|
|
11278
|
-
demoted: 0,
|
|
11279
|
-
limit,
|
|
11280
|
-
dryRun,
|
|
11281
|
-
errorCount: 1
|
|
11282
|
-
};
|
|
11283
|
-
await this.tierMigrationStatus.recordCycle(failed);
|
|
11284
|
-
return failed;
|
|
11285
|
-
} finally {
|
|
11286
|
-
this.tierMigrationInFlight = false;
|
|
11287
|
-
}
|
|
11411
|
+
return this.tierMigrationCoordinator.runCycle(storage, trigger, options);
|
|
11288
11412
|
}
|
|
11289
11413
|
async getTierMigrationStatus() {
|
|
11290
11414
|
return this.tierMigrationStatus.get();
|
|
@@ -12628,7 +12752,7 @@ ${normalized}`).digest("hex");
|
|
|
12628
12752
|
const allMems = allMemsForGraph ?? [];
|
|
12629
12753
|
for (const m of allMems) {
|
|
12630
12754
|
if (m.frontmatter.entityRef === entityRef) {
|
|
12631
|
-
const rel =
|
|
12755
|
+
const rel = path3.relative(storage.dir, m.path);
|
|
12632
12756
|
if (rel !== memoryRelPath) entitySiblings.push(rel);
|
|
12633
12757
|
}
|
|
12634
12758
|
}
|
|
@@ -12687,7 +12811,8 @@ ${normalized}`).digest("hex");
|
|
|
12687
12811
|
* Fail-open: any error is logged but does not abort extraction.
|
|
12688
12812
|
*/
|
|
12689
12813
|
async updateTemporalTagIndexes(storage, persistedIds) {
|
|
12690
|
-
|
|
12814
|
+
const caps = resolveCapabilities(this.config);
|
|
12815
|
+
if (!this.config.queryAwareIndexingEnabled && !caps.parallelRetrieval)
|
|
12691
12816
|
return;
|
|
12692
12817
|
const needsFullRebuild = !indexesExist(this.config.memoryDir);
|
|
12693
12818
|
if (!needsFullRebuild && persistedIds.length === 0) return;
|
|
@@ -12950,7 +13075,7 @@ ${normalized}`).digest("hex");
|
|
|
12950
13075
|
}
|
|
12951
13076
|
if (this.config.semanticConsolidationEnabled) {
|
|
12952
13077
|
try {
|
|
12953
|
-
const stateFilePath =
|
|
13078
|
+
const stateFilePath = path3.join(
|
|
12954
13079
|
this.config.memoryDir,
|
|
12955
13080
|
"state",
|
|
12956
13081
|
"semantic-consolidation-last-run.json"
|
|
@@ -12998,7 +13123,7 @@ ${normalized}`).digest("hex");
|
|
|
12998
13123
|
);
|
|
12999
13124
|
}
|
|
13000
13125
|
if (semResult.errors === 0 || semResult.memoriesArchived > 0) {
|
|
13001
|
-
const stateDir =
|
|
13126
|
+
const stateDir = path3.join(this.config.memoryDir, "state");
|
|
13002
13127
|
await mkdir2(stateDir, { recursive: true });
|
|
13003
13128
|
await writeFile2(
|
|
13004
13129
|
stateFilePath,
|
|
@@ -13499,12 +13624,12 @@ ${texts.map((t, i) => `[${i + 1}] ${t}`).join("\n\n")}`;
|
|
|
13499
13624
|
protectedCategories: this.config.lifecycleProtectedCategories
|
|
13500
13625
|
}
|
|
13501
13626
|
};
|
|
13502
|
-
const metricsPath =
|
|
13627
|
+
const metricsPath = path3.join(
|
|
13503
13628
|
storage.dir,
|
|
13504
13629
|
"state",
|
|
13505
13630
|
"lifecycle-metrics.json"
|
|
13506
13631
|
);
|
|
13507
|
-
await mkdir2(
|
|
13632
|
+
await mkdir2(path3.dirname(metricsPath), { recursive: true });
|
|
13508
13633
|
await writeFile2(metricsPath, JSON.stringify(metrics, null, 2), "utf-8");
|
|
13509
13634
|
return updatedCount;
|
|
13510
13635
|
}
|
|
@@ -13690,18 +13815,29 @@ ${reflectionsContent.trim()}
|
|
|
13690
13815
|
);
|
|
13691
13816
|
}
|
|
13692
13817
|
}
|
|
13693
|
-
formatQmdResults(title, results, sessionKey) {
|
|
13818
|
+
formatQmdResults(title, results, sessionKey, trustByPath) {
|
|
13694
13819
|
const handleByIndex = buildHandleIndexForResults(
|
|
13695
13820
|
results,
|
|
13696
13821
|
this.config.recallMemoryHandles === true && sessionKey != null
|
|
13697
13822
|
);
|
|
13823
|
+
const renderHedge = this.config.trustScoreEpistemicRendering && trustByPath !== null && trustByPath !== void 0;
|
|
13824
|
+
const hedgeMap = renderHedge ? trustByPath : null;
|
|
13698
13825
|
const lines = results.map((r, i) => {
|
|
13699
13826
|
const snippet = r.snippet ? r.snippet.slice(0, 500).replace(/\n/g, " ") : "(no preview)";
|
|
13700
13827
|
const source = typeof r.line === "number" ? `${r.path}:${r.line}` : r.path;
|
|
13701
13828
|
const head = `[${i + 1}] ${source} (score: ${r.score.toFixed(3)})
|
|
13702
13829
|
${snippet}`;
|
|
13703
13830
|
const handle = handleByIndex.get(i);
|
|
13704
|
-
|
|
13831
|
+
const hedged = head.replace(/\s+$/, "");
|
|
13832
|
+
const withHandle = handle ? `${hedged} ${handle}` : hedged;
|
|
13833
|
+
if (hedgeMap) {
|
|
13834
|
+
const item = hedgeMap.get(r.path);
|
|
13835
|
+
if (item) {
|
|
13836
|
+
const hedge = renderEpistemicHedge(item.trust);
|
|
13837
|
+
if (hedge.length > 0) return `${withHandle} ${hedge}`;
|
|
13838
|
+
}
|
|
13839
|
+
}
|
|
13840
|
+
return withHandle;
|
|
13705
13841
|
});
|
|
13706
13842
|
return `## ${title}
|
|
13707
13843
|
|
|
@@ -13993,12 +14129,14 @@ ${lines.join("\n\n")}`;
|
|
|
13993
14129
|
}
|
|
13994
14130
|
publishRecallResults(options) {
|
|
13995
14131
|
const sectionId = "memories";
|
|
13996
|
-
const
|
|
14132
|
+
const trustByPath = options.trustByPath ?? null;
|
|
14133
|
+
const injectable = trustByPath ? options.results.filter((r) => !trustByPath.get(r.path)?.quarantined) : options.results;
|
|
14134
|
+
const memoryIds = this.extractMemoryIdsFromResults(injectable);
|
|
13997
14135
|
this.trackMemoryAccess(memoryIds);
|
|
13998
14136
|
this.appendRecallSection(
|
|
13999
14137
|
options.sectionBuckets,
|
|
14000
14138
|
sectionId,
|
|
14001
|
-
this.formatQmdResults(options.title,
|
|
14139
|
+
this.formatQmdResults(options.title, injectable, options.sessionKey, trustByPath)
|
|
14002
14140
|
);
|
|
14003
14141
|
}
|
|
14004
14142
|
/**
|
|
@@ -14034,7 +14172,7 @@ ${lines.join("\n\n")}`;
|
|
|
14034
14172
|
const seenStorageDirs = /* @__PURE__ */ new Set();
|
|
14035
14173
|
const addStorage = (storage) => {
|
|
14036
14174
|
const storageDir = storageDirFor(storage);
|
|
14037
|
-
const storageKey = storageDir ?
|
|
14175
|
+
const storageKey = storageDir ? path3.resolve(storageDir) : `storage-without-dir-${storages.length}`;
|
|
14038
14176
|
if (seenStorageDirs.has(storageKey)) return;
|
|
14039
14177
|
seenStorageDirs.add(storageKey);
|
|
14040
14178
|
storages.push(storage);
|
|
@@ -14064,7 +14202,7 @@ ${lines.join("\n\n")}`;
|
|
|
14064
14202
|
continue;
|
|
14065
14203
|
}
|
|
14066
14204
|
try {
|
|
14067
|
-
const coldRoot =
|
|
14205
|
+
const coldRoot = path3.join(storageDir, "cold");
|
|
14068
14206
|
for (const candidate of qmdResultPathCandidates(
|
|
14069
14207
|
coldRoot,
|
|
14070
14208
|
parts.relativePath
|
|
@@ -14105,7 +14243,7 @@ ${lines.join("\n\n")}`;
|
|
|
14105
14243
|
return null;
|
|
14106
14244
|
}
|
|
14107
14245
|
}
|
|
14108
|
-
if (
|
|
14246
|
+
if (path3.isAbsolute(resultPath)) {
|
|
14109
14247
|
if (!fallbackStorageDir) {
|
|
14110
14248
|
return await fallbackStorage.readMemoryByPath(resultPath);
|
|
14111
14249
|
}
|
|
@@ -14144,7 +14282,7 @@ ${lines.join("\n\n")}`;
|
|
|
14144
14282
|
);
|
|
14145
14283
|
if (!memory) return null;
|
|
14146
14284
|
let ownerNamespace = null;
|
|
14147
|
-
if (
|
|
14285
|
+
if (path3.isAbsolute(memory.path)) {
|
|
14148
14286
|
const ownerStorage = await this.storageForAbsoluteQmdResultPath(
|
|
14149
14287
|
memory.path,
|
|
14150
14288
|
fallbackStorage,
|
|
@@ -14168,16 +14306,16 @@ ${lines.join("\n\n")}`;
|
|
|
14168
14306
|
};
|
|
14169
14307
|
}
|
|
14170
14308
|
async storageForAbsoluteQmdResultPath(resultPath, fallbackStorage, recallNamespaces = []) {
|
|
14171
|
-
const resolvedPath =
|
|
14172
|
-
const memoryRoot =
|
|
14173
|
-
const namespacesRoot =
|
|
14309
|
+
const resolvedPath = path3.resolve(resultPath);
|
|
14310
|
+
const memoryRoot = path3.resolve(this.config.memoryDir);
|
|
14311
|
+
const namespacesRoot = path3.join(memoryRoot, "namespaces");
|
|
14174
14312
|
const fallbackStorageDir = typeof fallbackStorage.dir === "string" && fallbackStorage.dir ? fallbackStorage.dir : null;
|
|
14175
14313
|
const matches = [];
|
|
14176
14314
|
const seenDirs = /* @__PURE__ */ new Set();
|
|
14177
14315
|
const maybeAddStorage = (storage, namespace) => {
|
|
14178
14316
|
const storageDir = typeof storage.dir === "string" && storage.dir ? storage.dir : null;
|
|
14179
14317
|
if (!storageDir) return;
|
|
14180
|
-
const candidateRoot =
|
|
14318
|
+
const candidateRoot = path3.resolve(storageDir);
|
|
14181
14319
|
if (seenDirs.has(candidateRoot)) return;
|
|
14182
14320
|
if (!isPathInsideStorageRoot(candidateRoot, resolvedPath)) return;
|
|
14183
14321
|
if (candidateRoot === memoryRoot && isPathInsideStorageRoot(namespacesRoot, resolvedPath)) {
|
|
@@ -14195,7 +14333,7 @@ ${lines.join("\n\n")}`;
|
|
|
14195
14333
|
candidateNamespaces.add(ns);
|
|
14196
14334
|
}
|
|
14197
14335
|
if (isPathInsideStorageRoot(namespacesRoot, resolvedPath)) {
|
|
14198
|
-
const relativeToNamespaces =
|
|
14336
|
+
const relativeToNamespaces = path3.relative(namespacesRoot, resolvedPath);
|
|
14199
14337
|
const [namespaceSegment] = relativeToNamespaces.split(/[\\/]/);
|
|
14200
14338
|
if (namespaceSegment) {
|
|
14201
14339
|
candidateNamespaces.add(
|
|
@@ -14240,7 +14378,7 @@ ${lines.join("\n\n")}`;
|
|
|
14240
14378
|
nsMap = buildMemoryWorthCounterMap(memories);
|
|
14241
14379
|
this.memoryWorthCounterCache.set(ns, { at: nowMs, counters: nsMap });
|
|
14242
14380
|
}
|
|
14243
|
-
for (const [
|
|
14381
|
+
for (const [path4, c] of nsMap) counters.set(path4, c);
|
|
14244
14382
|
} catch (err) {
|
|
14245
14383
|
log.debug("memory-worth: failed to read namespace, skipping", {
|
|
14246
14384
|
namespace: ns,
|
|
@@ -14299,6 +14437,99 @@ ${lines.join("\n\n")}`;
|
|
|
14299
14437
|
}
|
|
14300
14438
|
return reordered;
|
|
14301
14439
|
}
|
|
14440
|
+
/**
|
|
14441
|
+
* Issue #1577 — unified TrustScore recall stage. Thin wiring over the pure
|
|
14442
|
+
* {@link applyTrustScoreStage} scorer + the {@link buildTrustSignalsForRerank}
|
|
14443
|
+
* signal builder. The stage subsumes the Memory Worth multiplier — the
|
|
14444
|
+
* orchestrator runs exactly one of the two (mutual exclusion, rule 39; the
|
|
14445
|
+
* double-multiplier test in trust-score-stage.test.ts pins it structurally).
|
|
14446
|
+
*
|
|
14447
|
+
* Returns the admitted results AND the per-path trust map (including
|
|
14448
|
+
* quarantined items) so the caller can: (a) render epistemic hedges, (b)
|
|
14449
|
+
* surface quarantined items in X-ray with a reason (rule 34), and (c) filter
|
|
14450
|
+
* quarantined paths from fallback recall branches. The trust map is a
|
|
14451
|
+
* per-recall local — never instance state — so concurrent recalls cannot
|
|
14452
|
+
* race on it (review: shared-trust-map concurrency).
|
|
14453
|
+
*/
|
|
14454
|
+
async applyTrustScoreRerank(results, namespaces) {
|
|
14455
|
+
if (results.length === 0) return { results, trustByPath: null };
|
|
14456
|
+
const now = /* @__PURE__ */ new Date();
|
|
14457
|
+
const halfLifeDays = this.config.recallMemoryWorthHalfLifeMs > 0 ? this.config.recallMemoryWorthHalfLifeMs / (24 * 60 * 60 * 1e3) : void 0;
|
|
14458
|
+
let fallbackReader = null;
|
|
14459
|
+
const signals = await buildTrustSignalsForRerank(
|
|
14460
|
+
results.map((r) => r.path),
|
|
14461
|
+
namespaces,
|
|
14462
|
+
{
|
|
14463
|
+
readNamespaceMemories: async (ns) => (await this.getStorage(ns)).readAllMemories(),
|
|
14464
|
+
readMemoryFrontmatter: async (path4) => {
|
|
14465
|
+
if (!fallbackReader) {
|
|
14466
|
+
for (const ns of namespaces) {
|
|
14467
|
+
try {
|
|
14468
|
+
fallbackReader = await this.getStorage(ns);
|
|
14469
|
+
break;
|
|
14470
|
+
} catch {
|
|
14471
|
+
}
|
|
14472
|
+
}
|
|
14473
|
+
}
|
|
14474
|
+
if (!fallbackReader) return null;
|
|
14475
|
+
const memory = await this.readQmdResultMemory(path4, fallbackReader, namespaces);
|
|
14476
|
+
return memory ? memory.frontmatter : null;
|
|
14477
|
+
}
|
|
14478
|
+
},
|
|
14479
|
+
{ cache: this.trustSignalCache, ttlMs: _Orchestrator.TRUST_SIGNAL_CACHE_TTL_MS },
|
|
14480
|
+
now,
|
|
14481
|
+
{
|
|
14482
|
+
recencyHalfLifeDays: halfLifeDays,
|
|
14483
|
+
logDebug: (message, context) => log.debug(message, context)
|
|
14484
|
+
}
|
|
14485
|
+
);
|
|
14486
|
+
if (signals.size === 0) {
|
|
14487
|
+
return { results, trustByPath: null };
|
|
14488
|
+
}
|
|
14489
|
+
const rankedInputs = results.map((r, i) => ({ path: r.path, score: results.length - i }));
|
|
14490
|
+
const stage = applyTrustScoreStage(rankedInputs, {
|
|
14491
|
+
signals,
|
|
14492
|
+
weights: this.config.trustScoreWeights,
|
|
14493
|
+
minMultiplier: this.config.trustScoreMinMultiplier,
|
|
14494
|
+
maxMultiplier: this.config.trustScoreMaxMultiplier,
|
|
14495
|
+
quarantine: this.config.trustScoreQuarantine
|
|
14496
|
+
});
|
|
14497
|
+
const trustByPath = new Map(stage.all.map((item) => [item.path, item]));
|
|
14498
|
+
const byPath = new Map(results.map((r) => [r.path, r]));
|
|
14499
|
+
const admitted = stage.admitted.map((item) => byPath.get(item.path)).filter((r) => r !== void 0);
|
|
14500
|
+
return { results: admitted, trustByPath };
|
|
14501
|
+
}
|
|
14502
|
+
/**
|
|
14503
|
+
* Issue #1577 — apply the TrustScore stage (or, when trust is off, the Memory
|
|
14504
|
+
* Worth multiplier fallback) to ONE recall branch's results, returning the
|
|
14505
|
+
* scored results + the per-path trust map. Thin wiring over
|
|
14506
|
+
* {@link applyTrustScoreRerank} so every recall path — hot QMD, embedding
|
|
14507
|
+
* fallback, recent scan — applies the SAME multiplier gate (rule 41: a
|
|
14508
|
+
* feature gate must apply across ALL parallel recall paths). TrustScore
|
|
14509
|
+
* subsumes Memory Worth; exactly one runs (rule 39). Fail-open on lookup
|
|
14510
|
+
* errors so a storage hiccup never breaks a fallback path.
|
|
14511
|
+
*/
|
|
14512
|
+
async applyTrustScoreToBranch(results, namespaces, caps, label) {
|
|
14513
|
+
if (caps.recallTrustScore && results.length > 0) {
|
|
14514
|
+
try {
|
|
14515
|
+
return await this.applyTrustScoreRerank(results, namespaces);
|
|
14516
|
+
} catch (err) {
|
|
14517
|
+
log.debug(`trust-score stage (${label}) failed open`, {
|
|
14518
|
+
error: err.message
|
|
14519
|
+
});
|
|
14520
|
+
}
|
|
14521
|
+
} else if (caps.recallMemoryWorthFilter && results.length > 0) {
|
|
14522
|
+
try {
|
|
14523
|
+
const filtered = await this.applyMemoryWorthRerank(results, namespaces);
|
|
14524
|
+
return { results: filtered, trustByPath: null };
|
|
14525
|
+
} catch (err) {
|
|
14526
|
+
log.debug(`memory-worth filter (${label}) failed open`, {
|
|
14527
|
+
error: err.message
|
|
14528
|
+
});
|
|
14529
|
+
}
|
|
14530
|
+
}
|
|
14531
|
+
return { results, trustByPath: null };
|
|
14532
|
+
}
|
|
14302
14533
|
diversifyAndLimitRecallResults(sectionId, results, limit, retrievalQuery, caps = resolveCapabilities(this.config)) {
|
|
14303
14534
|
const safeLimit = typeof limit === "number" && Number.isFinite(limit) ? Math.max(0, Math.floor(limit)) : 0;
|
|
14304
14535
|
if (!Array.isArray(results) || results.length === 0) return [];
|
|
@@ -14411,12 +14642,12 @@ ${lines.join("\n\n")}`;
|
|
|
14411
14642
|
*/
|
|
14412
14643
|
semanticDedupScopeFor(targetStorage) {
|
|
14413
14644
|
if (!this.config.namespacesEnabled) return {};
|
|
14414
|
-
const memoryDir =
|
|
14415
|
-
const storageDir =
|
|
14645
|
+
const memoryDir = path3.resolve(this.config.memoryDir);
|
|
14646
|
+
const storageDir = path3.resolve(targetStorage.dir);
|
|
14416
14647
|
if (storageDir === memoryDir) {
|
|
14417
14648
|
return { pathExcludePrefixes: ["namespaces/"] };
|
|
14418
14649
|
}
|
|
14419
|
-
let rel =
|
|
14650
|
+
let rel = path3.relative(memoryDir, storageDir);
|
|
14420
14651
|
if (!rel || rel.startsWith("..")) {
|
|
14421
14652
|
log.debug(
|
|
14422
14653
|
`semantic dedup: target storage dir ${storageDir} is outside memoryDir ${memoryDir}; scoping lookup to absolute path prefix`
|
|
@@ -14435,7 +14666,7 @@ ${lines.join("\n\n")}`;
|
|
|
14435
14666
|
if (hits.length === 0) return [];
|
|
14436
14667
|
const results = [];
|
|
14437
14668
|
for (const hit of hits) {
|
|
14438
|
-
const fullPath =
|
|
14669
|
+
const fullPath = path3.isAbsolute(hit.path) ? hit.path : path3.join(this.config.memoryDir, hit.path);
|
|
14439
14670
|
const memory = await this.storage.readMemoryByPath(fullPath);
|
|
14440
14671
|
if (!memory) continue;
|
|
14441
14672
|
results.push({
|
|
@@ -14639,7 +14870,7 @@ ${lines.join("\n\n")}`;
|
|
|
14639
14870
|
const storage = await this.storageRouter.storageFor(namespace);
|
|
14640
14871
|
const storageDir = typeof storage.dir === "string" && storage.dir ? storage.dir : null;
|
|
14641
14872
|
if (!storageDir) continue;
|
|
14642
|
-
const recallRoot =
|
|
14873
|
+
const recallRoot = path3.resolve(storageDir);
|
|
14643
14874
|
if (seenRecallRoots.has(recallRoot)) continue;
|
|
14644
14875
|
seenRecallRoots.add(recallRoot);
|
|
14645
14876
|
recallRoots.push(recallRoot);
|
|
@@ -14663,8 +14894,8 @@ ${lines.join("\n\n")}`;
|
|
|
14663
14894
|
if (resolvedCold) scopedResults.push(resolvedCold.result);
|
|
14664
14895
|
continue;
|
|
14665
14896
|
}
|
|
14666
|
-
if (
|
|
14667
|
-
const resolvedPath =
|
|
14897
|
+
if (path3.isAbsolute(result.path)) {
|
|
14898
|
+
const resolvedPath = path3.resolve(result.path);
|
|
14668
14899
|
if (recallRoots.some(
|
|
14669
14900
|
(recallRoot) => isPathInsideStorageRoot(recallRoot, resolvedPath)
|
|
14670
14901
|
)) {
|
|
@@ -14745,7 +14976,7 @@ ${lines.join("\n\n")}`;
|
|
|
14745
14976
|
} else {
|
|
14746
14977
|
log.debug("cold-tier recall boost skipped: shared assembly deadline already expired");
|
|
14747
14978
|
}
|
|
14748
|
-
if (
|
|
14979
|
+
if (caps.rerank && this.config.rerankProvider === "local") {
|
|
14749
14980
|
const ranked = await rerankLocalOrNoop({
|
|
14750
14981
|
query: options.prompt,
|
|
14751
14982
|
candidates: results.slice(0, this.config.rerankMaxCandidates).map((r) => ({
|
|
@@ -14774,12 +15005,22 @@ ${lines.join("\n\n")}`;
|
|
|
14774
15005
|
results = reordered;
|
|
14775
15006
|
}
|
|
14776
15007
|
}
|
|
14777
|
-
if (
|
|
15008
|
+
if (caps.rerank && this.config.rerankProvider === "cloud") {
|
|
14778
15009
|
log.debug(
|
|
14779
15010
|
"rerankProvider=cloud is reserved/experimental in v2.2.0; skipping rerank"
|
|
14780
15011
|
);
|
|
14781
15012
|
}
|
|
14782
|
-
if (caps.
|
|
15013
|
+
if (caps.recallTrustScore && results.length > 0) {
|
|
15014
|
+
try {
|
|
15015
|
+
const trustOutcome = await this.applyTrustScoreRerank(results, options.recallNamespaces);
|
|
15016
|
+
results = trustOutcome.results;
|
|
15017
|
+
if (options.trustByPathSink) options.trustByPathSink.trustByPath = trustOutcome.trustByPath;
|
|
15018
|
+
} catch (err) {
|
|
15019
|
+
log.debug("trust-score stage (cold) failed open", {
|
|
15020
|
+
error: err.message
|
|
15021
|
+
});
|
|
15022
|
+
}
|
|
15023
|
+
} else if (caps.recallMemoryWorthFilter && results.length > 0) {
|
|
14783
15024
|
try {
|
|
14784
15025
|
results = await this.applyMemoryWorthRerank(results, options.recallNamespaces);
|
|
14785
15026
|
} catch (err) {
|
|
@@ -15552,4 +15793,4 @@ export {
|
|
|
15552
15793
|
resolvePersistedMemoryRelativePath,
|
|
15553
15794
|
Orchestrator
|
|
15554
15795
|
};
|
|
15555
|
-
//# sourceMappingURL=chunk-
|
|
15796
|
+
//# sourceMappingURL=chunk-LA3HZKES.js.map
|