@remnic/core 9.3.719 → 9.3.720
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 +18 -17
- package/dist/access-cli.js +39 -37
- package/dist/access-cli.js.map +1 -1
- package/dist/access-http.d.ts +11 -8
- package/dist/access-http.js +25 -24
- package/dist/access-mcp.d.ts +11 -8
- package/dist/access-mcp.js +21 -20
- package/dist/access-operations-batch.js +19 -18
- package/dist/access-operations.d.ts +11 -8
- package/dist/access-operations.js +20 -19
- package/dist/access-schema.d.ts +19 -19
- package/dist/{access-service-CZbnt0t2.d.ts → access-service-Dw-tK1pa.d.ts} +3 -3
- package/dist/access-service.d.ts +11 -8
- package/dist/access-service.js +17 -16
- 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 +1 -1
- package/dist/adapters/index.js +7 -7
- package/dist/adapters/registry.js +3 -3
- 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 +4 -4
- 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/capabilities.d.ts +30 -2
- package/dist/capabilities.js +3 -1
- package/dist/{catalog-CEYlMs9X.d.ts → catalog-B9SPfcsE.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 +7 -7
- package/dist/causal-retrieval.js +2 -2
- package/dist/causal-trajectory-graph.d.ts +4 -0
- package/dist/causal-trajectory-graph.js +1 -1
- package/dist/causal-trajectory.js +1 -1
- package/dist/{chunk-7EEVXW7X.js → chunk-2RBMGTK4.js} +2 -2
- package/dist/{chunk-L5ASZA2F.js → chunk-3XEGHEQ2.js} +17 -2
- package/dist/chunk-3XEGHEQ2.js.map +1 -0
- package/dist/{chunk-YYOK4GVF.js → chunk-422TIKIH.js} +3 -3
- package/dist/{chunk-KRGC4EDX.js → chunk-5YQN2XYC.js} +2 -2
- package/dist/{chunk-ANI5DUAE.js → chunk-6S5ZI7HB.js} +7 -7
- package/dist/{chunk-JIZGYQYH.js → chunk-ATGRQ2NE.js} +4 -4
- package/dist/chunk-BCDKBDSY.js +173 -0
- package/dist/chunk-BCDKBDSY.js.map +1 -0
- package/dist/{chunk-P5IPFZVH.js → chunk-BGQ7WKMT.js} +5 -5
- package/dist/{chunk-JAKYZGV4.js → chunk-CYJV5AYC.js} +3 -3
- package/dist/{chunk-APUJIMDM.js → chunk-DG3ORVCU.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-H2AGJ5SV.js} +2 -2
- package/dist/{chunk-A66YRSOS.js → chunk-HAPVZ4CO.js} +2 -2
- package/dist/{chunk-4KZGLDJJ.js → chunk-HHSO6VCQ.js} +2 -2
- package/dist/{chunk-2VHMVWPU.js → chunk-HTIL3EJK.js} +2 -2
- package/dist/{chunk-UCJ5CDTK.js → chunk-HU4EBIXO.js} +22 -14
- package/dist/chunk-HU4EBIXO.js.map +1 -0
- package/dist/{chunk-CTOQEZSN.js → chunk-IPJD7WJH.js} +2 -2
- package/dist/{chunk-DIFU33GU.js → chunk-JV7Q226R.js} +2 -2
- package/dist/{chunk-U5H7WHTS.js → chunk-KNN6DAZQ.js} +4 -4
- package/dist/{chunk-3JJWNZTT.js → chunk-L2B3EE7B.js} +102 -42
- package/dist/chunk-L2B3EE7B.js.map +1 -0
- package/dist/{chunk-5RHM43BJ.js → chunk-LLLG5PTE.js} +3 -3
- package/dist/{chunk-F3PVXKHP.js → chunk-M3GBOKUX.js} +22 -16
- package/dist/chunk-M3GBOKUX.js.map +1 -0
- package/dist/{chunk-2PTBLS2S.js → chunk-NBYXOEO7.js} +2 -2
- package/dist/{chunk-URM3HW2R.js → chunk-NE5WFIY6.js} +2 -2
- package/dist/{chunk-REWQAFSA.js → chunk-NERBFQNY.js} +2 -2
- package/dist/{chunk-773DPI6T.js → chunk-NO4DWSQE.js} +10 -10
- package/dist/{chunk-OZ2KQ7HF.js → chunk-O6SEGJNV.js} +2 -2
- package/dist/{chunk-IF362TF6.js → chunk-PMBWVQ7D.js} +2 -2
- package/dist/chunk-PMBWVQ7D.js.map +1 -0
- package/dist/{chunk-OJU73BUX.js → chunk-PPVCZPYA.js} +2 -2
- package/dist/{chunk-S3OPGGZB.js → chunk-RIW3UDDY.js} +2 -2
- package/dist/{chunk-AU7Q3LSC.js → chunk-RKNJBZ55.js} +7 -7
- package/dist/{chunk-EH27LHML.js → chunk-RX7EBFFJ.js} +2 -2
- package/dist/{chunk-2COL35PK.js → chunk-T3XSXAWK.js} +2 -2
- package/dist/{chunk-2KAYTPPT.js → chunk-UUMYB3FR.js} +4 -4
- package/dist/{chunk-72VDBALG.js → chunk-V5EGLYXE.js} +52 -43
- package/dist/chunk-V5EGLYXE.js.map +1 -0
- package/dist/{chunk-LXSG4L55.js → chunk-V7UUIIR7.js} +2 -2
- package/dist/{chunk-HLIR3RJ7.js → chunk-WBHQ5LP5.js} +2 -2
- package/dist/{chunk-YGKUAX2B.js → chunk-XROP4ZHB.js} +8 -8
- package/dist/chunk-XROP4ZHB.js.map +1 -0
- package/dist/{chunk-NFRBADNR.js → chunk-Y4I7SOJN.js} +559 -318
- package/dist/chunk-Y4I7SOJN.js.map +1 -0
- package/dist/{chunk-YTZLBBEB.js → chunk-YMPEGBLL.js} +3 -3
- package/dist/chunk-YN2UN7N3.js +217 -0
- package/dist/chunk-YN2UN7N3.js.map +1 -0
- package/dist/{chunk-YI7RZO7Y.js → chunk-ZE7GJ76H.js} +1 -1
- package/dist/{chunk-74MYJSKB.js → chunk-ZG2WP425.js} +2 -2
- package/dist/{chunk-A5TUPZ3N.js → chunk-ZKUW2MJG.js} +43 -1
- package/dist/chunk-ZKUW2MJG.js.map +1 -0
- package/dist/{chunk-N3DUH6OO.js → chunk-ZW5I3UNP.js} +1 -1
- package/dist/chunk-ZW5I3UNP.js.map +1 -0
- package/dist/{cli-1orcdXOY.d.ts → cli-qcLCJlOD.d.ts} +3 -3
- package/dist/cli.d.ts +9 -6
- package/dist/cli.js +43 -42
- package/dist/compounding/engine.d.ts +1 -1
- package/dist/compounding/engine.js +4 -4
- 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 +1 -1
- package/dist/connectors/codex-materialize-runner.d.ts +1 -1
- package/dist/connectors/codex-materialize-runner.js +4 -4
- package/dist/connectors/codex-materialize.d.ts +1 -1
- package/dist/connectors/index.d.ts +1 -1
- package/dist/connectors/index.js +4 -4
- 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/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 +4 -4
- package/dist/entity-schema.d.ts +1 -1
- package/dist/explicit-capture.d.ts +11 -8
- package/dist/extraction-faithfulness.d.ts +1 -1
- 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.d.ts +1 -1
- package/dist/fallback-llm.d.ts +1 -1
- 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-QDDC6AVV.js} +2 -2
- package/dist/graph-edge-reinforcement.d.ts +4 -0
- package/dist/graph-snapshot.d.ts +7 -3
- package/dist/graph-snapshot.js +2 -2
- package/dist/graph.d.ts +7 -1
- package/dist/graph.js +1 -1
- 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 +57 -55
- 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 +4 -4
- package/dist/lcm/index.d.ts +1 -1
- package/dist/lcm/index.js +8 -8
- 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/maintenance/memory-governance.d.ts +1 -1
- package/dist/maintenance/memory-governance.js +4 -4
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +4 -4
- package/dist/maintenance/rebuild-memory-projection.js +5 -5
- 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 +9 -9
- package/dist/namespaces/principal.d.ts +1 -1
- package/dist/namespaces/search.d.ts +1 -1
- package/dist/namespaces/search.js +4 -4
- package/dist/namespaces/storage.d.ts +2 -2
- package/dist/namespaces/storage.js +4 -4
- package/dist/native-knowledge.d.ts +1 -1
- package/dist/operator-toolkit.d.ts +3 -2
- package/dist/operator-toolkit.js +16 -15
- package/dist/orchestration/maintenance.d.ts +2 -2
- package/dist/orchestration/maintenance.js +6 -6
- package/dist/{orchestrator-kOxredSr.d.ts → orchestrator-Bg5Fnza6.d.ts} +178 -81
- package/dist/orchestrator.d.ts +8 -5
- package/dist/orchestrator.js +31 -29
- 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/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-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 +2 -2
- 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 +3 -3
- package/dist/search/index.d.ts +1 -1
- package/dist/search/index.js +7 -7
- package/dist/search/lancedb-backend.d.ts +1 -1
- package/dist/search/meilisearch-backend.d.ts +1 -1
- package/dist/search/noop-backend.d.ts +1 -1
- package/dist/search/orama-backend.d.ts +1 -1
- 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-ClOiS6KP.d.ts} +1 -1
- package/dist/semantic-consolidation.d.ts +2 -2
- package/dist/semantic-consolidation.js +5 -5
- package/dist/semantic-rule-promotion.js +4 -4
- package/dist/semantic-rule-verifier.d.ts +1 -1
- package/dist/semantic-rule-verifier.js +4 -4
- 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 +3 -3
- package/dist/summarizer.d.ts +1 -1
- 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/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-BSdUWePh.d.ts} +37 -1
- 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 +4 -4
- 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 +51 -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/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 +42 -0
- 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-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-UCJ5CDTK.js.map +0 -1
- package/dist/chunk-YGKUAX2B.js.map +0 -1
- /package/dist/{chunk-7EEVXW7X.js.map → chunk-2RBMGTK4.js.map} +0 -0
- /package/dist/{chunk-YYOK4GVF.js.map → chunk-422TIKIH.js.map} +0 -0
- /package/dist/{chunk-KRGC4EDX.js.map → chunk-5YQN2XYC.js.map} +0 -0
- /package/dist/{chunk-ANI5DUAE.js.map → chunk-6S5ZI7HB.js.map} +0 -0
- /package/dist/{chunk-JIZGYQYH.js.map → chunk-ATGRQ2NE.js.map} +0 -0
- /package/dist/{chunk-P5IPFZVH.js.map → chunk-BGQ7WKMT.js.map} +0 -0
- /package/dist/{chunk-JAKYZGV4.js.map → chunk-CYJV5AYC.js.map} +0 -0
- /package/dist/{chunk-APUJIMDM.js.map → chunk-DG3ORVCU.js.map} +0 -0
- /package/dist/{chunk-S35FX6MU.js.map → chunk-H2AGJ5SV.js.map} +0 -0
- /package/dist/{chunk-A66YRSOS.js.map → chunk-HAPVZ4CO.js.map} +0 -0
- /package/dist/{chunk-4KZGLDJJ.js.map → chunk-HHSO6VCQ.js.map} +0 -0
- /package/dist/{chunk-2VHMVWPU.js.map → chunk-HTIL3EJK.js.map} +0 -0
- /package/dist/{chunk-CTOQEZSN.js.map → chunk-IPJD7WJH.js.map} +0 -0
- /package/dist/{chunk-DIFU33GU.js.map → chunk-JV7Q226R.js.map} +0 -0
- /package/dist/{chunk-U5H7WHTS.js.map → chunk-KNN6DAZQ.js.map} +0 -0
- /package/dist/{chunk-5RHM43BJ.js.map → chunk-LLLG5PTE.js.map} +0 -0
- /package/dist/{chunk-2PTBLS2S.js.map → chunk-NBYXOEO7.js.map} +0 -0
- /package/dist/{chunk-URM3HW2R.js.map → chunk-NE5WFIY6.js.map} +0 -0
- /package/dist/{chunk-REWQAFSA.js.map → chunk-NERBFQNY.js.map} +0 -0
- /package/dist/{chunk-773DPI6T.js.map → chunk-NO4DWSQE.js.map} +0 -0
- /package/dist/{chunk-OZ2KQ7HF.js.map → chunk-O6SEGJNV.js.map} +0 -0
- /package/dist/{chunk-OJU73BUX.js.map → chunk-PPVCZPYA.js.map} +0 -0
- /package/dist/{chunk-S3OPGGZB.js.map → chunk-RIW3UDDY.js.map} +0 -0
- /package/dist/{chunk-AU7Q3LSC.js.map → chunk-RKNJBZ55.js.map} +0 -0
- /package/dist/{chunk-EH27LHML.js.map → chunk-RX7EBFFJ.js.map} +0 -0
- /package/dist/{chunk-2COL35PK.js.map → chunk-T3XSXAWK.js.map} +0 -0
- /package/dist/{chunk-2KAYTPPT.js.map → chunk-UUMYB3FR.js.map} +0 -0
- /package/dist/{chunk-LXSG4L55.js.map → chunk-V7UUIIR7.js.map} +0 -0
- /package/dist/{chunk-HLIR3RJ7.js.map → chunk-WBHQ5LP5.js.map} +0 -0
- /package/dist/{chunk-YTZLBBEB.js.map → chunk-YMPEGBLL.js.map} +0 -0
- /package/dist/{chunk-YI7RZO7Y.js.map → chunk-ZE7GJ76H.js.map} +0 -0
- /package/dist/{chunk-74MYJSKB.js.map → chunk-ZG2WP425.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-QDDC6AVV.js.map} +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
NamespaceStorageRouter
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-JV7Q226R.js";
|
|
4
4
|
import {
|
|
5
5
|
namespaceCollectionName
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-IPJD7WJH.js";
|
|
7
7
|
import {
|
|
8
8
|
namespaceIdentityFromToken,
|
|
9
9
|
namespaceIdentityToken
|
|
@@ -204,4 +204,4 @@ export {
|
|
|
204
204
|
verifyNamespaces,
|
|
205
205
|
runNamespaceMigration
|
|
206
206
|
};
|
|
207
|
-
//# sourceMappingURL=chunk-
|
|
207
|
+
//# sourceMappingURL=chunk-YMPEGBLL.js.map
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
// src/trust-score.ts
|
|
2
|
+
var DEFAULT_TRUST_WEIGHTS = {
|
|
3
|
+
memoryWorth: 0.28,
|
|
4
|
+
provenance: 0.16,
|
|
5
|
+
faithfulness: 0.2,
|
|
6
|
+
corroboration: 0.12,
|
|
7
|
+
contradiction: 0.1,
|
|
8
|
+
domainCalibration: 0.04,
|
|
9
|
+
feedback: 0.05,
|
|
10
|
+
recency: 0.05
|
|
11
|
+
};
|
|
12
|
+
var TRUST_BAND_THRESHOLDS = {
|
|
13
|
+
high: 0.7,
|
|
14
|
+
medium: 0.45,
|
|
15
|
+
low: 0.2
|
|
16
|
+
};
|
|
17
|
+
var NEUTRAL_TRUST_SCORE = 0.5;
|
|
18
|
+
function sanitizeWeight(value) {
|
|
19
|
+
if (value === void 0) return void 0;
|
|
20
|
+
if (typeof value !== "number") return void 0;
|
|
21
|
+
if (!Number.isFinite(value)) return void 0;
|
|
22
|
+
if (value < 0 || value > 1) return void 0;
|
|
23
|
+
return value;
|
|
24
|
+
}
|
|
25
|
+
function resolveTrustWeights(override) {
|
|
26
|
+
const out = { ...DEFAULT_TRUST_WEIGHTS };
|
|
27
|
+
if (!override) return out;
|
|
28
|
+
Object.keys(DEFAULT_TRUST_WEIGHTS).forEach((key) => {
|
|
29
|
+
const v = sanitizeWeight(override[key]);
|
|
30
|
+
if (v !== void 0) out[key] = v;
|
|
31
|
+
});
|
|
32
|
+
return out;
|
|
33
|
+
}
|
|
34
|
+
function clampUnit(value) {
|
|
35
|
+
if (typeof value !== "number" || !Number.isFinite(value)) return NEUTRAL_TRUST_SCORE;
|
|
36
|
+
if (value < 0) return 0;
|
|
37
|
+
if (value > 1) return 1;
|
|
38
|
+
return value;
|
|
39
|
+
}
|
|
40
|
+
function unitValue(value) {
|
|
41
|
+
if (value === void 0) return void 0;
|
|
42
|
+
if (typeof value !== "number" || !Number.isFinite(value)) return void 0;
|
|
43
|
+
if (value < 0 || value > 1) return void 0;
|
|
44
|
+
return value;
|
|
45
|
+
}
|
|
46
|
+
function provenanceValue(tag) {
|
|
47
|
+
if (tag === void 0) return void 0;
|
|
48
|
+
if (tag === "verified") return 1;
|
|
49
|
+
if (tag === "unverified") return 0.5;
|
|
50
|
+
if (tag === "none") return 0.25;
|
|
51
|
+
return void 0;
|
|
52
|
+
}
|
|
53
|
+
function faithfulnessValue(verdict) {
|
|
54
|
+
if (verdict === void 0) return void 0;
|
|
55
|
+
if (verdict === "entailed") return 1;
|
|
56
|
+
if (verdict === "unchecked") return void 0;
|
|
57
|
+
if (verdict === "unsupported") return 0.35;
|
|
58
|
+
if (verdict === "contradicted") return 0;
|
|
59
|
+
return void 0;
|
|
60
|
+
}
|
|
61
|
+
function contradictionValue(status) {
|
|
62
|
+
if (status === void 0) return void 0;
|
|
63
|
+
if (status === "none") return NEUTRAL_TRUST_SCORE;
|
|
64
|
+
if (status === "resolved_kept") return 0.7;
|
|
65
|
+
if (status === "resolved_superseded") return 0.1;
|
|
66
|
+
if (status === "pending_review") return 0.15;
|
|
67
|
+
return void 0;
|
|
68
|
+
}
|
|
69
|
+
function feedbackValue(fb) {
|
|
70
|
+
if (fb === void 0) return void 0;
|
|
71
|
+
const up = typeof fb.up === "number" && Number.isFinite(fb.up) && fb.up >= 0 ? fb.up : 0;
|
|
72
|
+
const down = typeof fb.down === "number" && Number.isFinite(fb.down) && fb.down >= 0 ? fb.down : 0;
|
|
73
|
+
if (up === 0 && down === 0) return void 0;
|
|
74
|
+
return clampUnit((up + 1) / (up + down + 2));
|
|
75
|
+
}
|
|
76
|
+
function corroborationValue(count) {
|
|
77
|
+
if (count === void 0) return void 0;
|
|
78
|
+
if (typeof count !== "number" || !Number.isFinite(count) || count < 0) return void 0;
|
|
79
|
+
if (count === 0) return 0.3;
|
|
80
|
+
return clampUnit(Math.log2(1 + count) / 2);
|
|
81
|
+
}
|
|
82
|
+
function recencyValue(signals) {
|
|
83
|
+
if (signals.ageDays === void 0) return void 0;
|
|
84
|
+
if (typeof signals.ageDays !== "number" || !Number.isFinite(signals.ageDays) || signals.ageDays < 0)
|
|
85
|
+
return void 0;
|
|
86
|
+
const halfLife = signals.recencyHalfLifeDays;
|
|
87
|
+
if (typeof halfLife !== "number" || !Number.isFinite(halfLife) || halfLife <= 0) return void 0;
|
|
88
|
+
return clampUnit(Math.pow(2, -signals.ageDays / halfLife));
|
|
89
|
+
}
|
|
90
|
+
function isHardNegative(signals) {
|
|
91
|
+
if (signals.faithfulness === "contradicted") return true;
|
|
92
|
+
if (signals.contradiction === "pending_review") return true;
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
function computeTrustScore(signals = {}, weights = DEFAULT_TRUST_WEIGHTS) {
|
|
96
|
+
const resolved = resolveTrustWeights(weights);
|
|
97
|
+
const candidates = [];
|
|
98
|
+
const push = (key, value) => {
|
|
99
|
+
if (value === void 0) return;
|
|
100
|
+
candidates.push({ key, value: clampUnit(value) });
|
|
101
|
+
};
|
|
102
|
+
push("memoryWorth", signals.memoryWorth ? clampUnit(signals.memoryWorth.score) : void 0);
|
|
103
|
+
push("provenance", provenanceValue(signals.provenance));
|
|
104
|
+
push("faithfulness", faithfulnessValue(signals.faithfulness));
|
|
105
|
+
push("corroboration", corroborationValue(signals.corroborationCount));
|
|
106
|
+
push("contradiction", contradictionValue(signals.contradiction));
|
|
107
|
+
push("domainCalibration", unitValue(signals.domainCalibration));
|
|
108
|
+
push("feedback", feedbackValue(signals.feedback));
|
|
109
|
+
push("recency", recencyValue(signals));
|
|
110
|
+
if (candidates.length === 0) {
|
|
111
|
+
return {
|
|
112
|
+
score: NEUTRAL_TRUST_SCORE,
|
|
113
|
+
band: "medium",
|
|
114
|
+
components: {},
|
|
115
|
+
neutral: true
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
const activeWeightSum = candidates.reduce((acc, c) => acc + resolved[c.key], 0);
|
|
119
|
+
if (activeWeightSum <= 0) {
|
|
120
|
+
return {
|
|
121
|
+
score: NEUTRAL_TRUST_SCORE,
|
|
122
|
+
band: "medium",
|
|
123
|
+
components: {},
|
|
124
|
+
neutral: true
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
const safeWeightSum = activeWeightSum;
|
|
128
|
+
let blended = 0;
|
|
129
|
+
const components = {};
|
|
130
|
+
for (const c of candidates) {
|
|
131
|
+
const w = resolved[c.key] / safeWeightSum;
|
|
132
|
+
blended += c.value * w;
|
|
133
|
+
components[c.key] = { value: c.value, weight: w };
|
|
134
|
+
}
|
|
135
|
+
const score = clampUnit(blended);
|
|
136
|
+
const band = bandForScore(score, isHardNegative(signals));
|
|
137
|
+
return { score, band, components, neutral: false };
|
|
138
|
+
}
|
|
139
|
+
function bandForScore(score, hardNegative) {
|
|
140
|
+
if (hardNegative) return "quarantine";
|
|
141
|
+
const s = clampUnit(score);
|
|
142
|
+
if (s >= TRUST_BAND_THRESHOLDS.high) return "high";
|
|
143
|
+
if (s >= TRUST_BAND_THRESHOLDS.medium) return "medium";
|
|
144
|
+
if (s >= TRUST_BAND_THRESHOLDS.low) return "low";
|
|
145
|
+
return "low";
|
|
146
|
+
}
|
|
147
|
+
function trustMultiplier(score, minMultiplier = 0.5, maxMultiplier = 1.25) {
|
|
148
|
+
const min = typeof minMultiplier === "number" && Number.isFinite(minMultiplier) ? minMultiplier : 0.5;
|
|
149
|
+
const max = typeof maxMultiplier === "number" && Number.isFinite(maxMultiplier) ? maxMultiplier : 1.25;
|
|
150
|
+
const lo = Math.min(min, max);
|
|
151
|
+
const hi = Math.max(min, max);
|
|
152
|
+
const s = clampUnit(score);
|
|
153
|
+
if (s === NEUTRAL_TRUST_SCORE) return 1;
|
|
154
|
+
if (s < NEUTRAL_TRUST_SCORE) {
|
|
155
|
+
const t2 = s / NEUTRAL_TRUST_SCORE;
|
|
156
|
+
return lo + (1 - lo) * t2;
|
|
157
|
+
}
|
|
158
|
+
const t = (s - NEUTRAL_TRUST_SCORE) / (1 - NEUTRAL_TRUST_SCORE);
|
|
159
|
+
return 1 + (hi - 1) * t;
|
|
160
|
+
}
|
|
161
|
+
function renderEpistemicHedge(result) {
|
|
162
|
+
if (result.neutral) return "";
|
|
163
|
+
switch (result.band) {
|
|
164
|
+
case "high":
|
|
165
|
+
return "";
|
|
166
|
+
case "quarantine":
|
|
167
|
+
case "low":
|
|
168
|
+
return `(low confidence \u2014 ${describeWeakness(result.components)})`;
|
|
169
|
+
case "medium":
|
|
170
|
+
return `(unconfirmed \u2014 ${describeWeakness(result.components)})`;
|
|
171
|
+
default:
|
|
172
|
+
return "";
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
function describeWeakness(components) {
|
|
176
|
+
const parts = [];
|
|
177
|
+
const f = components.faithfulness;
|
|
178
|
+
if (f && f.value <= 0.35) parts.push(f.value === 0 ? "contradicted" : "unsupported");
|
|
179
|
+
const c = components.contradiction;
|
|
180
|
+
if (c && c.value <= 0.2) parts.push("under review");
|
|
181
|
+
const cor = components.corroboration;
|
|
182
|
+
if (cor && cor.value <= 0.4) parts.push("single mention");
|
|
183
|
+
const prov = components.provenance;
|
|
184
|
+
if (prov && prov.value <= 0.3) parts.push("unprovenanced");
|
|
185
|
+
const rec = components.recency;
|
|
186
|
+
if (rec && rec.value <= 0.3) parts.push("stale");
|
|
187
|
+
if (parts.length === 0) {
|
|
188
|
+
let weakest = null;
|
|
189
|
+
for (const [key, comp] of Object.entries(components)) {
|
|
190
|
+
if (!weakest || comp.value < weakest.value) weakest = { key, value: comp.value };
|
|
191
|
+
}
|
|
192
|
+
if (weakest) parts.push(`weak ${humanizeComponentName(weakest.key)}`);
|
|
193
|
+
}
|
|
194
|
+
return parts.slice(0, 2).join(", ");
|
|
195
|
+
}
|
|
196
|
+
function humanizeComponentName(key) {
|
|
197
|
+
switch (key) {
|
|
198
|
+
case "memoryWorth":
|
|
199
|
+
return "outcome history";
|
|
200
|
+
case "domainCalibration":
|
|
201
|
+
return "domain calibration";
|
|
202
|
+
default:
|
|
203
|
+
return key;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export {
|
|
208
|
+
DEFAULT_TRUST_WEIGHTS,
|
|
209
|
+
TRUST_BAND_THRESHOLDS,
|
|
210
|
+
NEUTRAL_TRUST_SCORE,
|
|
211
|
+
resolveTrustWeights,
|
|
212
|
+
computeTrustScore,
|
|
213
|
+
bandForScore,
|
|
214
|
+
trustMultiplier,
|
|
215
|
+
renderEpistemicHedge
|
|
216
|
+
};
|
|
217
|
+
//# sourceMappingURL=chunk-YN2UN7N3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/trust-score.ts"],"sourcesContent":["/**\n * trust-score.ts — unified TrustScore pure module (issue #1577 PR 1).\n *\n * Combines the trust-relevant signals Remnic already computes — memory worth\n * (Laplace-smoothed outcome probability + recency decay), provenance strength,\n * faithfulness verdict, corroboration count, contradiction status, and optional\n * domain calibration — into ONE deterministic score in `[0, 1]` plus a band\n * (`high` / `medium` / `low` / `quarantine`) and a fully-explained component\n * breakdown for X-ray.\n *\n * Contract rules (mirror the battle-tested `memory-worth.ts` \"corrupt inputs\n * fail safely\" header — read it before changing anything here):\n *\n * 1. **No signals → neutral.** An empty `TrustSignals` yields score `0.5`,\n * band `medium`, and a recall multiplier of exactly `1.0`. Uninstrumented\n * memories are NEVER penalized (rule 39 — byte-identical ranking when the\n * feature is off; neutral prior when on but a memory has no data).\n * 2. **Corrupt / out-of-range component → that component collapses to\n * neutral**, never to an extreme. A `NaN` weight or a `corroborationCount`\n * of `-3` is treated as \"no signal\", not as damning evidence. Precedent:\n * `memory-worth.ts` `classifyCounter`.\n * 3. **Deterministic.** Same inputs → identical result. All weights come from\n * the caller (config); no wall clock, no RNG, no hidden constants.\n * 4. **Explainable.** Every active component is echoed in the result with its\n * normalized weight and contribution, so X-ray can render the basis\n * without re-deriving the math.\n * 5. **`quarantine` is reserved for hard negatives** — `faithfulness:\n * \"contradicted\"` or `contradiction: \"pending_review\"`. Quarantined items\n * are excluded from injection but MUST stay visible in X-ray with the\n * reason (rule 34 — exclusion must never look like \"no result\").\n *\n * This module is deliberately framework-free: it takes already-collected\n * signals and config weights, returns a score. The signal ADAPTERS (reading\n * frontmatter / counters / review queues) live in `trust-score-stage.ts` so\n * this file stays pure and trivially property-testable.\n */\n\n/**\n * Per-component weights. Defined canonically in `types.ts` (the PluginConfig\n * home) and re-exported here so callers of the pure scorer don't need a second\n * import path. Every field is optional and defaults to\n * `DEFAULT_TRUST_WEIGHTS`; weights are sum-normalized at score time, so only\n * their relative magnitudes matter (rule 51: invalid weight rejected at config\n * parse, here we only defend against runtime corruption).\n */\nexport type { TrustWeights } from \"./types.js\";\nimport type { TrustWeights } from \"./types.js\";\n\n/**\n * Default per-component weights. Chosen so that, with all signals at neutral,\n * the score is exactly `0.5`. Sum-normalized at compute time. These are the\n * documented defaults; operators override via `trustScore.weights.*` config.\n */\nexport const DEFAULT_TRUST_WEIGHTS: Required<TrustWeights> = {\n memoryWorth: 0.28,\n provenance: 0.16,\n faithfulness: 0.20,\n corroboration: 0.12,\n contradiction: 0.10,\n domainCalibration: 0.04,\n feedback: 0.05,\n recency: 0.05,\n};\n\n/**\n * All trust-relevant signals for ONE memory. Every field is optional — the\n * scorer degrades to neutral for any absent or corrupt signal (rule 34).\n */\nexport interface TrustSignals {\n /** Memory-worth result (Laplace success prob + confidence). */\n memoryWorth?: { score: number; confidence: number };\n /** Thumbs feedback tallies. */\n feedback?: { up: number; down: number };\n /** Contradiction review queue status. */\n contradiction?: \"none\" | \"pending_review\" | \"resolved_kept\" | \"resolved_superseded\";\n /** Claim-level provenance strength (#1575). */\n provenance?: \"verified\" | \"unverified\" | \"none\";\n /** Faithfulness gate verdict (#1576). */\n faithfulness?: \"entailed\" | \"contradicted\" | \"unsupported\" | \"unchecked\";\n /** Count of distinct source turns/sessions corroborating the fact. */\n corroborationCount?: number;\n /** Belief-ledger accuracy for the memory's domain, `0..1`. */\n domainCalibration?: number;\n /** Age in days vs a per-category half-life (caller computes). */\n ageDays?: number;\n /** Half-life (days) for recency decay; the caller supplies the per-category value. */\n recencyHalfLifeDays?: number;\n}\n\n/** Trust band, coarse-grained for injection hedging and X-ray grouping. */\nexport type TrustBand = \"high\" | \"medium\" | \"low\" | \"quarantine\";\n\n/**\n * One component's contribution to the final score, for full explainability.\n * `value` is the normalized `[0,1]` signal contribution; `weight` is the\n * sum-normalized weight that was applied.\n */\nexport interface TrustScoreComponent {\n value: number;\n weight: number;\n}\n\n/**\n * Full TrustScore result. `score` is the weighted blend in `[0,1]`; `band` is\n * the coarse category; `components` echoes every active component so X-ray /\n * epistemic rendering can explain the basis without re-deriving it.\n */\nexport interface TrustScoreResult {\n score: number;\n band: TrustBand;\n components: Record<string, TrustScoreComponent>;\n /**\n * `true` when the result is the neutral prior (no usable signals). Lets the\n * multiplier short-circuit to exactly `1.0` and the epistemic renderer skip\n * the hedge for the common uninstrumented case.\n */\n neutral: boolean;\n}\n\n/** Band thresholds on the blended score. */\nexport const TRUST_BAND_THRESHOLDS = {\n high: 0.7,\n medium: 0.45,\n low: 0.2,\n} as const;\n\n/** Neutral prior: the score an empty-signal memory receives. */\nexport const NEUTRAL_TRUST_SCORE = 0.5;\n\n/**\n * Validate a single weight: a finite number in `[0, 1]`. Returns the value or\n * `undefined` when corrupt (the caller falls back to the default).\n */\nfunction sanitizeWeight(value: number | undefined): number | undefined {\n if (value === undefined) return undefined;\n if (typeof value !== \"number\") return undefined;\n if (!Number.isFinite(value)) return undefined;\n if (value < 0 || value > 1) return undefined;\n return value;\n}\n\n/**\n * Merge caller weights over the defaults, dropping corrupt entries. Exposed for\n * config parse so an invalid weight is rejected once at the boundary (rule 51\n * spirit) — but the scorer defends again here so a hand-built bench fixture\n * cannot poison the math.\n */\nexport function resolveTrustWeights(\n override: Readonly<TrustWeights> | undefined,\n): Required<TrustWeights> {\n const out: Required<TrustWeights> = { ...DEFAULT_TRUST_WEIGHTS };\n if (!override) return out;\n (Object.keys(DEFAULT_TRUST_WEIGHTS) as Array<keyof TrustWeights>).forEach((key) => {\n const v = sanitizeWeight(override[key]);\n if (v !== undefined) out[key] = v;\n });\n return out;\n}\n\n/** Clamp a value to `[0,1]`; NaN/Infinity collapse to the neutral `0.5`. */\nfunction clampUnit(value: number): number {\n if (typeof value !== \"number\" || !Number.isFinite(value)) return NEUTRAL_TRUST_SCORE;\n if (value < 0) return 0;\n if (value > 1) return 1;\n return value;\n}\n\n/**\n * Coerce an already-`[0,1]` signal (domain calibration, etc.) for the scorer.\n * Returns `undefined` when absent or corrupt so the component is DROPPED — a\n * single corrupt signal must not be read as damning evidence nor as a neutral\n * contribution that masquerades as \"we measured this\". Mirrors the\n * `classifyCounter` precedent from `memory-worth.ts`.\n */\nfunction unitValue(value: number | undefined): number | undefined {\n if (value === undefined) return undefined;\n if (typeof value !== \"number\" || !Number.isFinite(value)) return undefined;\n if (value < 0 || value > 1) return undefined;\n return value;\n}\n\n/** Map a provenance tag to a `[0,1]` contribution. Absent → neutral. */\nfunction provenanceValue(tag: TrustSignals[\"provenance\"]): number | undefined {\n if (tag === undefined) return undefined;\n if (tag === \"verified\") return 1;\n if (tag === \"unverified\") return 0.5;\n // \"none\" is meaningful negative evidence (no surviving source span), not\n // neutral. It pulls toward 0 but gently so a single unprovenanced fact is\n // not damned on its own.\n if (tag === \"none\") return 0.25;\n return undefined;\n}\n\n/** Map a faithfulness verdict to a `[0,1]` contribution. Absent → dropped. */\nfunction faithfulnessValue(verdict: TrustSignals[\"faithfulness\"]): number | undefined {\n if (verdict === undefined) return undefined;\n if (verdict === \"entailed\") return 1;\n // \"unchecked\" means the gate ran but could not verify — it carries NO signal.\n // Return undefined (absent) so a memory whose ONLY signal is unchecked\n // faithfulness scores truly neutral, not \"active 0.5\". This stops the\n // epistemic hedge from spuriously firing on unverifiable memories (review\n // Oqg_0: unchecked-as-absent for hedging) and stops the component from\n // masquerading as measured evidence.\n if (verdict === \"unchecked\") return undefined;\n if (verdict === \"unsupported\") return 0.35;\n // \"contradicted\" is a hard negative — it also forces quarantine (see below),\n // but as a component it contributes 0 so the blended score sinks.\n if (verdict === \"contradicted\") return 0;\n return undefined;\n}\n\n/** Map contradiction review status to a `[0,1]` contribution. */\nfunction contradictionValue(\n status: TrustSignals[\"contradiction\"],\n): number | undefined {\n if (status === undefined) return undefined;\n if (status === \"none\") return NEUTRAL_TRUST_SCORE;\n if (status === \"resolved_kept\") return 0.7;\n if (status === \"resolved_superseded\") return 0.1;\n if (status === \"pending_review\") return 0.15;\n return undefined;\n}\n\n/** Feedback balance → `[0,1]` via Laplace smoothing (mirrors memory-worth). */\nfunction feedbackValue(fb: TrustSignals[\"feedback\"]): number | undefined {\n if (fb === undefined) return undefined;\n const up = typeof fb.up === \"number\" && Number.isFinite(fb.up) && fb.up >= 0 ? fb.up : 0;\n const down =\n typeof fb.down === \"number\" && Number.isFinite(fb.down) && fb.down >= 0 ? fb.down : 0;\n if (up === 0 && down === 0) return undefined;\n // Laplace: (up+1)/(up+down+2). Clamped defensively.\n return clampUnit((up + 1) / (up + down + 2));\n}\n\n/** Corroboration count → `[0,1]` via log-saturation (3+ sources ≈ 1.0). */\nfunction corroborationValue(count: TrustSignals[\"corroborationCount\"]): number | undefined {\n if (count === undefined) return undefined;\n if (typeof count !== \"number\" || !Number.isFinite(count) || count < 0) return undefined;\n if (count === 0) return 0.3; // single mention is mild negative evidence vs neutral\n // log2(1 + count) saturates: 1→0.5, 2→0.63, 3→0.66, 4→0.68 ... capped at 1.\n return clampUnit(Math.log2(1 + count) / 2);\n}\n\n/** Recency decay vs a half-life, mapped so \"fresh\" → high, \"stale\" → low. */\nfunction recencyValue(signals: TrustSignals): number | undefined {\n if (signals.ageDays === undefined) return undefined;\n if (typeof signals.ageDays !== \"number\" || !Number.isFinite(signals.ageDays) || signals.ageDays < 0)\n return undefined;\n const halfLife = signals.recencyHalfLifeDays;\n if (typeof halfLife !== \"number\" || !Number.isFinite(halfLife) || halfLife <= 0) return undefined;\n // 2^(-age/halfLife): age 0 → 1, age=halfLife → 0.5, age≫halfLife → ~0.\n return clampUnit(Math.pow(2, -signals.ageDays / halfLife));\n}\n\n/**\n * Determine whether the signals warrant the `quarantine` band: a hard negative\n * that excludes the item from injection (but never from X-ray — rule 34).\n */\nfunction isHardNegative(signals: TrustSignals): boolean {\n if (signals.faithfulness === \"contradicted\") return true;\n if (signals.contradiction === \"pending_review\") return true;\n return false;\n}\n\n/**\n * Compute the unified TrustScore for one memory.\n *\n * Returns the neutral prior (`0.5`, band `medium`, `neutral: true`) when no\n * usable signal is present, so uninstrumented memories are untouched.\n */\nexport function computeTrustScore(\n signals: TrustSignals = {},\n weights: Readonly<TrustWeights> = DEFAULT_TRUST_WEIGHTS,\n): TrustScoreResult {\n const resolved = resolveTrustWeights(weights);\n\n // Build the (component → value) map, skipping absent/corrupt signals.\n // Each value is already clamped to [0,1] by its mapper.\n const candidates: Array<{ key: keyof TrustWeights; value: number }> = [];\n const push = (key: keyof TrustWeights, value: number | undefined) => {\n if (value === undefined) return;\n candidates.push({ key, value: clampUnit(value) });\n };\n\n push(\"memoryWorth\", signals.memoryWorth ? clampUnit(signals.memoryWorth.score) : undefined);\n push(\"provenance\", provenanceValue(signals.provenance));\n push(\"faithfulness\", faithfulnessValue(signals.faithfulness));\n push(\"corroboration\", corroborationValue(signals.corroborationCount));\n push(\"contradiction\", contradictionValue(signals.contradiction));\n push(\"domainCalibration\", unitValue(signals.domainCalibration));\n push(\"feedback\", feedbackValue(signals.feedback));\n push(\"recency\", recencyValue(signals));\n\n // No usable signal → neutral prior, multiplier exactly 1.0.\n if (candidates.length === 0) {\n return {\n score: NEUTRAL_TRUST_SCORE,\n band: \"medium\",\n components: {},\n neutral: true,\n };\n }\n\n // Sum-normalize the active weights so absent components redistribute their\n // weight to the present ones (a memory with only memory-worth data is scored\n // purely on memory-worth, not half-scored because other signals are absent).\n const activeWeightSum = candidates.reduce((acc, c) => acc + resolved[c.key], 0);\n // When every present signal's weight is 0 (operator explicitly disabled\n // the only components the memory has), fall back to the neutral prior\n // rather than damning the memory to score 0. A disabled signal is not a\n // negative signal — it carries no information (review P2: zero-weight).\n if (activeWeightSum <= 0) {\n return {\n score: NEUTRAL_TRUST_SCORE,\n band: \"medium\",\n components: {},\n neutral: true,\n };\n }\n const safeWeightSum = activeWeightSum;\n\n let blended = 0;\n const components: Record<string, TrustScoreComponent> = {};\n for (const c of candidates) {\n const w = resolved[c.key] / safeWeightSum;\n blended += c.value * w;\n components[c.key] = { value: c.value, weight: w };\n }\n\n // Clamp the blend: floating-point noise can drift a hair outside [0,1].\n const score = clampUnit(blended);\n\n // Hard negatives are quarantined regardless of the blended score, so a\n // corroborated-but-contradicted fact is still excluded from injection.\n const band = bandForScore(score, isHardNegative(signals));\n\n return { score, band, components, neutral: false };\n}\n\n/**\n * Resolve the band from the blended score, accounting for hard-negative\n * quarantine. Extracted so the thresholds live in ONE place (X-ray, injection,\n * and tests all agree on the mapping).\n */\nexport function bandForScore(score: number, hardNegative: boolean): TrustBand {\n if (hardNegative) return \"quarantine\";\n const s = clampUnit(score);\n if (s >= TRUST_BAND_THRESHOLDS.high) return \"high\";\n if (s >= TRUST_BAND_THRESHOLDS.medium) return \"medium\";\n if (s >= TRUST_BAND_THRESHOLDS.low) return \"low\";\n return \"low\";\n}\n\n/**\n * Map a `[0,1]` trust score to a recall multiplier in\n * `[minMultiplier, maxMultiplier]`. The neutral prior (`0.5`) maps to exactly\n * `1.0` so uninstrumented memories are untouched. Linear interpolation centered\n * at neutral:\n *\n * score < 0.5 → multiplier in [min, 1)\n * score = 0.5 → 1.0\n * score > 0.5 → multiplier in (1, max]\n */\nexport function trustMultiplier(\n score: number,\n minMultiplier: number = 0.5,\n maxMultiplier: number = 1.25,\n): number {\n const min = typeof minMultiplier === \"number\" && Number.isFinite(minMultiplier) ? minMultiplier : 0.5;\n const max = typeof maxMultiplier === \"number\" && Number.isFinite(maxMultiplier) ? maxMultiplier : 1.25;\n // Defend against an inverted contract (min > max): pick the tighter bound.\n const lo = Math.min(min, max);\n const hi = Math.max(min, max);\n const s = clampUnit(score);\n if (s === NEUTRAL_TRUST_SCORE) return 1;\n if (s < NEUTRAL_TRUST_SCORE) {\n // Map [0, 0.5) → [lo, 1). score 0 → lo, score →0.5 → 1.\n const t = s / NEUTRAL_TRUST_SCORE; // [0,1)\n return lo + (1 - lo) * t;\n }\n // Map (0.5, 1] → (1, hi]. score 0.5 → 1, score 1 → hi.\n const t = (s - NEUTRAL_TRUST_SCORE) / (1 - NEUTRAL_TRUST_SCORE); // (0,1]\n return 1 + (hi - 1) * t;\n}\n\n/**\n * Deterministic epistemic hedge suffix for an injected memory line, generated\n * from the trust components (template, not LLM). Returns the empty string for\n * the `high` band and for neutral results so the common case wastes no tokens.\n *\n * Examples:\n * high → \"\"\n * medium → \"(unconfirmed — single mention, 2025-11)\"\n * low → \"(low confidence — contradicted once, uncorroborated)\"\n */\nexport function renderEpistemicHedge(result: TrustScoreResult): string {\n if (result.neutral) return \"\";\n switch (result.band) {\n case \"high\":\n return \"\";\n case \"quarantine\":\n case \"low\":\n return `(low confidence — ${describeWeakness(result.components)})`;\n case \"medium\":\n return `(unconfirmed — ${describeWeakness(result.components)})`;\n default:\n return \"\";\n }\n}\n\n/**\n * Build a short, deterministic weakness description from the components. Reads\n * the lowest-contributing signals so the hedge names the actual reason the\n * model should hedge. Pure and order-stable.\n */\nfunction describeWeakness(components: Record<string, TrustScoreComponent>): string {\n const parts: string[] = [];\n const f = components.faithfulness;\n if (f && f.value <= 0.35) parts.push(f.value === 0 ? \"contradicted\" : \"unsupported\");\n const c = components.contradiction;\n if (c && c.value <= 0.2) parts.push(\"under review\");\n const cor = components.corroboration;\n if (cor && cor.value <= 0.4) parts.push(\"single mention\");\n const prov = components.provenance;\n if (prov && prov.value <= 0.3) parts.push(\"unprovenanced\");\n const rec = components.recency;\n if (rec && rec.value <= 0.3) parts.push(\"stale\");\n if (parts.length === 0) {\n // No single component is weak but the blend is below high — name the\n // weakest one explicitly so the hedge is never vacuous.\n let weakest: { key: string; value: number } | null = null;\n for (const [key, comp] of Object.entries(components)) {\n if (!weakest || comp.value < weakest.value) weakest = { key, value: comp.value };\n }\n if (weakest) parts.push(`weak ${humanizeComponentName(weakest.key)}`);\n }\n return parts.slice(0, 2).join(\", \");\n}\n\nfunction humanizeComponentName(key: string): string {\n switch (key) {\n case \"memoryWorth\":\n return \"outcome history\";\n case \"domainCalibration\":\n return \"domain calibration\";\n default:\n return key;\n }\n}\n"],"mappings":";AAqDO,IAAM,wBAAgD;AAAA,EAC3D,aAAa;AAAA,EACb,YAAY;AAAA,EACZ,cAAc;AAAA,EACd,eAAe;AAAA,EACf,eAAe;AAAA,EACf,mBAAmB;AAAA,EACnB,UAAU;AAAA,EACV,SAAS;AACX;AA0DO,IAAM,wBAAwB;AAAA,EACnC,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,KAAK;AACP;AAGO,IAAM,sBAAsB;AAMnC,SAAS,eAAe,OAA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,MAAI,KAAK,EAAE,SAAS,KAAM,OAAM,KAAK,EAAE,UAAU,IAAI,iBAAiB,aAAa;AACnF,QAAM,IAAI,WAAW;AACrB,MAAI,KAAK,EAAE,SAAS,IAAK,OAAM,KAAK,cAAc;AAClD,QAAM,MAAM,WAAW;AACvB,MAAI,OAAO,IAAI,SAAS,IAAK,OAAM,KAAK,gBAAgB;AACxD,QAAM,OAAO,WAAW;AACxB,MAAI,QAAQ,KAAK,SAAS,IAAK,OAAM,KAAK,eAAe;AACzD,QAAM,MAAM,WAAW;AACvB,MAAI,OAAO,IAAI,SAAS,IAAK,OAAM,KAAK,OAAO;AAC/C,MAAI,MAAM,WAAW,GAAG;AAGtB,QAAI,UAAiD;AACrD,eAAW,CAAC,KAAK,IAAI,KAAK,OAAO,QAAQ,UAAU,GAAG;AACpD,UAAI,CAAC,WAAW,KAAK,QAAQ,QAAQ,MAAO,WAAU,EAAE,KAAK,OAAO,KAAK,MAAM;AAAA,IACjF;AACA,QAAI,QAAS,OAAM,KAAK,QAAQ,sBAAsB,QAAQ,GAAG,CAAC,EAAE;AAAA,EACtE;AACA,SAAO,MAAM,MAAM,GAAG,CAAC,EAAE,KAAK,IAAI;AACpC;AAEA,SAAS,sBAAsB,KAAqB;AAClD,UAAQ,KAAK;AAAA,IACX,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT;AACE,aAAO;AAAA,EACX;AACF;","names":["t"]}
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-7FL4CNPV.js";
|
|
4
4
|
import {
|
|
5
5
|
resolveCausalTrajectoryStoreDir
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-ZE7GJ76H.js";
|
|
7
7
|
import {
|
|
8
8
|
normalizeRecallTokens
|
|
9
9
|
} from "./chunk-ZBJMUXZH.js";
|
|
@@ -339,4 +339,4 @@ export {
|
|
|
339
339
|
scoreStitchCandidate,
|
|
340
340
|
stitchCausalChain
|
|
341
341
|
};
|
|
342
|
-
//# sourceMappingURL=chunk-
|
|
342
|
+
//# sourceMappingURL=chunk-ZG2WP425.js.map
|
|
@@ -1961,6 +1961,27 @@ function parseConfig(raw, rawOperatorConfig, runtimeSet) {
|
|
|
1961
1961
|
const n = coerceNumber(cfg.recallMemoryWorthHalfLifeMs);
|
|
1962
1962
|
return n !== void 0 && n >= 0 ? n : 0;
|
|
1963
1963
|
})(),
|
|
1964
|
+
// Unified TrustScore recall stage (issue #1577). Default off: the stage
|
|
1965
|
+
// is absent and ranking is byte-identical to the pre-feature pipeline
|
|
1966
|
+
// (rule 39). Flip the master gate via #1574 ablation evidence only.
|
|
1967
|
+
trustScoreEnabled: coerceBool(cfg.trustScoreEnabled) ?? false,
|
|
1968
|
+
// Epistemic rendering ships behind its own gate so scoring can land first.
|
|
1969
|
+
trustScoreEpistemicRendering: coerceBool(cfg.trustScoreEpistemicRendering) ?? false,
|
|
1970
|
+
// Quarantine defaults on (only effective under the master gate); keeps
|
|
1971
|
+
// hard negatives out of injection but visible in X-ray (rule 34).
|
|
1972
|
+
trustScoreQuarantine: coerceBool(cfg.trustScoreQuarantine) ?? true,
|
|
1973
|
+
trustScoreMinMultiplier: (() => {
|
|
1974
|
+
const n = coerceNumber(cfg.trustScoreMinMultiplier);
|
|
1975
|
+
return n !== void 0 && n >= 0 && n <= 1 ? n : 0.5;
|
|
1976
|
+
})(),
|
|
1977
|
+
trustScoreMaxMultiplier: (() => {
|
|
1978
|
+
const n = coerceNumber(cfg.trustScoreMaxMultiplier);
|
|
1979
|
+
return n !== void 0 && n >= 1 && n <= 4 ? n : 1.25;
|
|
1980
|
+
})(),
|
|
1981
|
+
// Per-component weights. Accept a nested object from config; invalid
|
|
1982
|
+
// entries (non-finite, outside [0,1]) are dropped by resolveTrustWeights,
|
|
1983
|
+
// which falls back to the documented defaults (rule 51).
|
|
1984
|
+
trustScoreWeights: parseTrustScoreWeights(cfg.trustScoreWeights),
|
|
1964
1985
|
// Memory Linking (Phase 3A)
|
|
1965
1986
|
memoryLinkingEnabled: cfg.memoryLinkingEnabled === true,
|
|
1966
1987
|
// Off by default initially
|
|
@@ -3362,6 +3383,27 @@ function buildRecallPipelineConfig(cfg) {
|
|
|
3362
3383
|
const pipeline = Array.isArray(rawPipeline) ? rawPipeline.map(parseRecallSectionEntry).filter((entry) => entry.id.length > 0) : buildDefaultRecallPipeline(cfg);
|
|
3363
3384
|
return { recallBudgetChars, pipeline };
|
|
3364
3385
|
}
|
|
3386
|
+
function parseTrustScoreWeights(value) {
|
|
3387
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return {};
|
|
3388
|
+
const src = value;
|
|
3389
|
+
const out = {};
|
|
3390
|
+
const keys = [
|
|
3391
|
+
"memoryWorth",
|
|
3392
|
+
"provenance",
|
|
3393
|
+
"faithfulness",
|
|
3394
|
+
"corroboration",
|
|
3395
|
+
"contradiction",
|
|
3396
|
+
"domainCalibration",
|
|
3397
|
+
"feedback",
|
|
3398
|
+
"recency"
|
|
3399
|
+
];
|
|
3400
|
+
for (const key of keys) {
|
|
3401
|
+
const raw = src[key];
|
|
3402
|
+
if (typeof raw !== "number" || !Number.isFinite(raw) || raw < 0 || raw > 1) continue;
|
|
3403
|
+
out[key] = raw;
|
|
3404
|
+
}
|
|
3405
|
+
return out;
|
|
3406
|
+
}
|
|
3365
3407
|
|
|
3366
3408
|
export {
|
|
3367
3409
|
KNOWN_WEARABLE_SOURCE_IDS,
|
|
@@ -3375,4 +3417,4 @@ export {
|
|
|
3375
3417
|
VALID_MEMORY_CATEGORIES,
|
|
3376
3418
|
parseConfig
|
|
3377
3419
|
};
|
|
3378
|
-
//# sourceMappingURL=chunk-
|
|
3420
|
+
//# sourceMappingURL=chunk-ZKUW2MJG.js.map
|