@remnic/core 9.3.693 → 9.3.695
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 +13 -12
- package/dist/access-boundary.js +36 -28
- package/dist/access-cli.js +62 -59
- package/dist/access-cli.js.map +1 -1
- package/dist/access-http.d.ts +12 -11
- package/dist/access-http.js +40 -32
- package/dist/access-mcp.d.ts +19 -11
- package/dist/access-mcp.js +39 -31
- package/dist/access-operations.d.ts +56 -13
- package/dist/access-operations.js +66 -30
- package/dist/access-schema.js +3 -3
- package/dist/{access-service-DxCpgyVW.d.ts → access-service-BqBQeUJd.d.ts} +99 -3
- package/dist/access-service.d.ts +8 -7
- package/dist/access-service.js +35 -27
- package/dist/access-surface-catalog.d.ts +12 -11
- package/dist/access-surface-catalog.js +15 -0
- package/dist/access-surface-catalog.js.map +1 -1
- 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/{auto-sync-RWXT6P5M.js → auto-sync-PFW2NJZY.js} +8 -8
- package/dist/behavior-learner.d.ts +1 -1
- package/dist/behavior-signals.d.ts +1 -1
- package/dist/bootstrap.d.ts +9 -8
- package/dist/briefing.d.ts +1 -1
- package/dist/briefing.js +12 -5
- 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 +1 -1
- package/dist/{capsule-crypto-7FJQINUR.js → capsule-crypto-YO5QJ6L3.js} +2 -2
- package/dist/{catalog-BEWLjdOr.d.ts → catalog-D7YDNNF7.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 +17 -16
- package/dist/causal-consolidation.js.map +1 -1
- package/dist/causal-retrieval.js +2 -2
- package/dist/causal-trajectory-graph.js +2 -2
- package/dist/causal-trajectory.js +1 -1
- package/dist/{chunk-UPTZYUYJ.js → chunk-24D66MMN.js} +2 -1
- package/dist/chunk-24D66MMN.js.map +1 -0
- package/dist/{chunk-THKNO6OX.js → chunk-32XTY2DQ.js} +52 -51
- package/dist/chunk-32XTY2DQ.js.map +1 -0
- package/dist/{chunk-YN4ZT4CW.js → chunk-3LYJIA76.js} +1 -1
- package/dist/{chunk-ADUAF5EV.js → chunk-3P2XEQSV.js} +2 -2
- package/dist/{chunk-KYH53EFD.js → chunk-4NNDJOAO.js} +8 -8
- package/dist/{chunk-QFG23CRE.js → chunk-52QIAN76.js} +2 -2
- package/dist/chunk-5AT62NQH.js +553 -0
- package/dist/chunk-5AT62NQH.js.map +1 -0
- package/dist/{chunk-TAPSNIMA.js → chunk-5CEJH5ZN.js} +4 -4
- package/dist/{chunk-4RGWCRIJ.js → chunk-5TYA4OCF.js} +4 -4
- package/dist/{chunk-FM7KLRKN.js → chunk-6GAUF4OU.js} +3 -3
- package/dist/{chunk-6C2BMUZA.js → chunk-AF6DSAWD.js} +2 -2
- package/dist/{chunk-2NLLXCJG.js → chunk-BXLOS5AJ.js} +2 -2
- package/dist/{chunk-32KD5IHZ.js → chunk-CLXTDOKV.js} +2 -2
- package/dist/{chunk-ARV3AUOM.js → chunk-DL6H3D7S.js} +2 -2
- package/dist/{chunk-X7Y7WX73.js → chunk-DQEMWVMT.js} +1 -1
- package/dist/{chunk-3BRA3N5A.js → chunk-EC3A6M43.js} +2 -2
- package/dist/{chunk-UTUYAPLY.js → chunk-EK6FYL2E.js} +38 -3
- package/dist/chunk-EK6FYL2E.js.map +1 -0
- package/dist/{chunk-ZLXGFAML.js → chunk-FZMH66NT.js} +2 -2
- package/dist/{chunk-HXNMDPHN.js → chunk-G663XUEG.js} +2 -2
- package/dist/{chunk-TYEOAFH3.js → chunk-G6SVZWPB.js} +10 -1
- package/dist/chunk-G6SVZWPB.js.map +1 -0
- package/dist/chunk-HKET3ZOI.js +381 -0
- package/dist/chunk-HKET3ZOI.js.map +1 -0
- package/dist/{chunk-YOI3ELXF.js → chunk-IF362TF6.js} +2 -2
- package/dist/{chunk-WIKNVFBS.js → chunk-J45OCIVH.js} +2 -2
- package/dist/{chunk-UDJLF3BO.js → chunk-JI6HWBYL.js} +2 -2
- package/dist/{chunk-ECZPWSB5.js → chunk-JJT3AGL4.js} +4 -4
- package/dist/{chunk-RHWFMBO5.js → chunk-JMAKCWJ3.js} +96 -7
- package/dist/chunk-JMAKCWJ3.js.map +1 -0
- package/dist/{chunk-4NFVPDIL.js → chunk-LM6JB2EG.js} +2 -2
- package/dist/{chunk-AFWEUTMS.js → chunk-LPIWEKZ3.js} +2 -2
- package/dist/{chunk-LD53WPMU.js → chunk-LQ6JI4VH.js} +4 -4
- package/dist/{chunk-U2OBZSGG.js → chunk-MNFAGE5D.js} +2 -2
- package/dist/{chunk-VFVG4NS2.js → chunk-MOBRVKWE.js} +23 -12
- package/dist/chunk-MOBRVKWE.js.map +1 -0
- package/dist/{chunk-MQTPUPLP.js → chunk-N4PD5IY3.js} +834 -51
- package/dist/chunk-N4PD5IY3.js.map +1 -0
- package/dist/{chunk-5HGPDRQZ.js → chunk-NFMDHE45.js} +2 -2
- package/dist/chunk-NFMDHE45.js.map +1 -0
- package/dist/{chunk-MCV2DD6F.js → chunk-NLZO5NO6.js} +2 -2
- package/dist/{chunk-3VVH6ZQW.js → chunk-Q6ZHGGNJ.js} +2 -2
- package/dist/{chunk-4IQNAOP3.js → chunk-Q7SFJURX.js} +2 -2
- package/dist/{chunk-MXZWKOOR.js → chunk-QJM2XAJD.js} +11 -11
- package/dist/{chunk-6ZNIUGXB.js → chunk-QQW2LIEA.js} +4 -4
- package/dist/{chunk-GCOSQBQ2.js → chunk-QVTSLRKT.js} +3 -3
- package/dist/{chunk-F7BVJ3IE.js → chunk-RWST6NOL.js} +166 -102
- package/dist/chunk-RWST6NOL.js.map +1 -0
- package/dist/{chunk-NUZ3N445.js → chunk-SPVIG2R3.js} +10 -10
- package/dist/{chunk-2D27ODNX.js → chunk-TIVZ4MCG.js} +2 -2
- package/dist/{chunk-5KBNNUXS.js → chunk-TT7BJWGI.js} +2 -2
- package/dist/{chunk-KQAFEZQX.js → chunk-VDX2J7OX.js} +2 -2
- package/dist/{chunk-E6BOD3UJ.js → chunk-VPAFWWCL.js} +2 -2
- package/dist/chunk-VQ7B2Q6M.js +112 -0
- package/dist/chunk-VQ7B2Q6M.js.map +1 -0
- package/dist/{chunk-UOCLRM74.js → chunk-W54EAJT4.js} +2 -2
- package/dist/{chunk-QVG4LAQO.js → chunk-WR6KFJKA.js} +7 -7
- package/dist/{chunk-YQGHW5ML.js → chunk-WRFKZEO6.js} +4 -4
- package/dist/{chunk-WYB44HHV.js → chunk-XUNQLJT2.js} +20 -8
- package/dist/chunk-XUNQLJT2.js.map +1 -0
- package/dist/{chunk-66HROLW5.js → chunk-XWT4JXXA.js} +2 -2
- package/dist/{chunk-SAC5V6JT.js → chunk-XXA6T3O4.js} +2 -2
- package/dist/{chunk-KF74X62T.js → chunk-YGKUAX2B.js} +4 -4
- package/dist/{chunk-W4ELOUNX.js → chunk-YOZNTNNA.js} +2 -2
- package/dist/{chunk-DQHZA7Y3.js → chunk-ZXUOAFUG.js} +1 -1
- package/dist/chunk-ZXUOAFUG.js.map +1 -0
- package/dist/{cli-DoQsv4ut.d.ts → cli-DBDgdvh9.d.ts} +3 -3
- package/dist/cli.d.ts +11 -10
- package/dist/cli.js +58 -50
- package/dist/coding/optional-coding-graph.js +7 -104
- package/dist/coding/optional-coding-graph.js.map +1 -1
- package/dist/compounding/engine.d.ts +1 -1
- package/dist/compounding/engine.js +12 -5
- 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 +12 -5
- package/dist/connectors/codex-materialize.d.ts +1 -1
- package/dist/connectors/index.d.ts +1 -1
- package/dist/connectors/index.js +12 -5
- package/dist/consolidation-provenance-check.d.ts +3 -3
- package/dist/consolidation-undo.d.ts +2 -2
- 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 +13 -5
- package/dist/entity-schema.d.ts +1 -1
- package/dist/explicit-capture.d.ts +9 -8
- package/dist/extraction-faithfulness.d.ts +211 -0
- package/dist/extraction-faithfulness.js +35 -0
- 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 +4 -4
- package/dist/extraction.d.ts +1 -1
- package/dist/extraction.js +7 -7
- package/dist/fallback-llm.d.ts +1 -1
- package/dist/fallback-llm.js +2 -2
- package/dist/{graph-edge-decay-D7OESCBR.js → graph-edge-decay-JLOF3YW4.js} +3 -3
- package/dist/graph-snapshot.js +3 -3
- 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 +12 -11
- package/dist/index.js +101 -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/index.d.ts +1 -1
- package/dist/lcm/index.js +3 -3
- 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-llm.js +1 -1
- package/dist/maintenance/memory-governance.d.ts +1 -1
- package/dist/maintenance/memory-governance.js +13 -5
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +13 -5
- package/dist/maintenance/rebuild-memory-projection.js +14 -6
- package/dist/mcp-memory-inspector-app.d.ts +12 -11
- 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 +20 -12
- package/dist/namespaces/principal.d.ts +1 -1
- package/dist/namespaces/search.d.ts +1 -1
- package/dist/namespaces/search.js +6 -6
- package/dist/namespaces/storage.d.ts +2 -2
- package/dist/namespaces/storage.js +13 -5
- package/dist/native-knowledge.d.ts +1 -1
- package/dist/operator-toolkit.d.ts +1 -1
- package/dist/operator-toolkit.js +26 -19
- package/dist/orchestration/maintenance.d.ts +2 -2
- package/dist/orchestration/maintenance.js +15 -7
- package/dist/{orchestrator-CNJCYjZ1.d.ts → orchestrator-Dv8JQu3-.d.ts} +20 -3
- package/dist/orchestrator.d.ts +6 -5
- package/dist/orchestrator.js +47 -46
- 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-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 +1 -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 +5 -5
- package/dist/search/index.d.ts +1 -1
- package/dist/search/index.js +5 -5
- 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-D5U0Mrdb.d.ts → semantic-consolidation-CgREi9E0.d.ts} +1 -1
- package/dist/semantic-consolidation.d.ts +2 -2
- package/dist/semantic-consolidation.js +13 -6
- package/dist/semantic-rule-promotion.js +13 -5
- package/dist/semantic-rule-verifier.d.ts +1 -1
- package/dist/semantic-rule-verifier.js +13 -5
- 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/{state-NCHQ4TRG.js → state-ITXJKXRE.js} +2 -2
- package/dist/storage.d.ts +11 -1
- package/dist/storage.js +12 -4
- package/dist/summarizer.d.ts +1 -1
- package/dist/summarizer.js +6 -6
- 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/{trace-WM7V4CKI.js → trace-ZFVRH4GO.js} +3 -3
- 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 +2 -2
- package/dist/{tui-RI7P6PBS.js → tui-55UJMJX7.js} +3 -3
- package/dist/tui-55UJMJX7.js.map +1 -0
- package/dist/{types-2NoBoRBM.d.ts → types-CeZYSC-E.d.ts} +51 -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 +13 -5
- package/package.json +2 -2
- package/src/access-boundary.ts +17 -0
- package/src/access-http.ts +27 -3
- package/src/access-mcp.ts +99 -2
- package/src/access-operations.ts +259 -0
- package/src/access-service.ts +82 -0
- package/src/access-surface-catalog.test.ts +1 -1
- package/src/access-surface-catalog.ts +15 -0
- package/src/cli.ts +1 -0
- package/src/coding/architecture-surfaces.test.ts +2 -0
- package/src/coding/codegraph-runtime.ts +773 -0
- package/src/coding/codegraph-surfaces.test.ts +880 -0
- package/src/coding/codegraph-surfaces.ts +771 -0
- package/src/coding/coding-knowledge-config.ts +7 -0
- package/src/coding/decision-surfaces.test.ts +2 -0
- package/src/coding/session-delta-surfaces.test.ts +2 -0
- package/src/config.test.ts +18 -0
- package/src/config.ts +30 -0
- package/src/console/state.ts +32 -0
- package/src/extraction-faithfulness.test.ts +1112 -0
- package/src/extraction-faithfulness.ts +993 -0
- package/src/faithfulness-graph-guard.test.ts +252 -0
- package/src/local-llm.ts +1 -0
- package/src/orchestrator.ts +169 -45
- package/src/storage.ts +19 -0
- package/src/types.ts +61 -0
- package/dist/chunk-5HGPDRQZ.js.map +0 -1
- package/dist/chunk-DQHZA7Y3.js.map +0 -1
- package/dist/chunk-F7BVJ3IE.js.map +0 -1
- package/dist/chunk-JNKH2XWQ.js +0 -183
- package/dist/chunk-JNKH2XWQ.js.map +0 -1
- package/dist/chunk-MQTPUPLP.js.map +0 -1
- package/dist/chunk-RHWFMBO5.js.map +0 -1
- package/dist/chunk-THKNO6OX.js.map +0 -1
- package/dist/chunk-TYEOAFH3.js.map +0 -1
- package/dist/chunk-UPTZYUYJ.js.map +0 -1
- package/dist/chunk-UTUYAPLY.js.map +0 -1
- package/dist/chunk-VFVG4NS2.js.map +0 -1
- package/dist/chunk-WYB44HHV.js.map +0 -1
- /package/dist/{auto-sync-RWXT6P5M.js.map → auto-sync-PFW2NJZY.js.map} +0 -0
- /package/dist/{capsule-crypto-7FJQINUR.js.map → capsule-crypto-YO5QJ6L3.js.map} +0 -0
- /package/dist/{chunk-YN4ZT4CW.js.map → chunk-3LYJIA76.js.map} +0 -0
- /package/dist/{chunk-ADUAF5EV.js.map → chunk-3P2XEQSV.js.map} +0 -0
- /package/dist/{chunk-KYH53EFD.js.map → chunk-4NNDJOAO.js.map} +0 -0
- /package/dist/{chunk-QFG23CRE.js.map → chunk-52QIAN76.js.map} +0 -0
- /package/dist/{chunk-TAPSNIMA.js.map → chunk-5CEJH5ZN.js.map} +0 -0
- /package/dist/{chunk-4RGWCRIJ.js.map → chunk-5TYA4OCF.js.map} +0 -0
- /package/dist/{chunk-FM7KLRKN.js.map → chunk-6GAUF4OU.js.map} +0 -0
- /package/dist/{chunk-6C2BMUZA.js.map → chunk-AF6DSAWD.js.map} +0 -0
- /package/dist/{chunk-2NLLXCJG.js.map → chunk-BXLOS5AJ.js.map} +0 -0
- /package/dist/{chunk-32KD5IHZ.js.map → chunk-CLXTDOKV.js.map} +0 -0
- /package/dist/{chunk-ARV3AUOM.js.map → chunk-DL6H3D7S.js.map} +0 -0
- /package/dist/{chunk-X7Y7WX73.js.map → chunk-DQEMWVMT.js.map} +0 -0
- /package/dist/{chunk-3BRA3N5A.js.map → chunk-EC3A6M43.js.map} +0 -0
- /package/dist/{chunk-ZLXGFAML.js.map → chunk-FZMH66NT.js.map} +0 -0
- /package/dist/{chunk-HXNMDPHN.js.map → chunk-G663XUEG.js.map} +0 -0
- /package/dist/{chunk-YOI3ELXF.js.map → chunk-IF362TF6.js.map} +0 -0
- /package/dist/{chunk-WIKNVFBS.js.map → chunk-J45OCIVH.js.map} +0 -0
- /package/dist/{chunk-UDJLF3BO.js.map → chunk-JI6HWBYL.js.map} +0 -0
- /package/dist/{chunk-ECZPWSB5.js.map → chunk-JJT3AGL4.js.map} +0 -0
- /package/dist/{chunk-4NFVPDIL.js.map → chunk-LM6JB2EG.js.map} +0 -0
- /package/dist/{chunk-AFWEUTMS.js.map → chunk-LPIWEKZ3.js.map} +0 -0
- /package/dist/{chunk-LD53WPMU.js.map → chunk-LQ6JI4VH.js.map} +0 -0
- /package/dist/{chunk-U2OBZSGG.js.map → chunk-MNFAGE5D.js.map} +0 -0
- /package/dist/{chunk-MCV2DD6F.js.map → chunk-NLZO5NO6.js.map} +0 -0
- /package/dist/{chunk-3VVH6ZQW.js.map → chunk-Q6ZHGGNJ.js.map} +0 -0
- /package/dist/{chunk-4IQNAOP3.js.map → chunk-Q7SFJURX.js.map} +0 -0
- /package/dist/{chunk-MXZWKOOR.js.map → chunk-QJM2XAJD.js.map} +0 -0
- /package/dist/{chunk-6ZNIUGXB.js.map → chunk-QQW2LIEA.js.map} +0 -0
- /package/dist/{chunk-GCOSQBQ2.js.map → chunk-QVTSLRKT.js.map} +0 -0
- /package/dist/{chunk-NUZ3N445.js.map → chunk-SPVIG2R3.js.map} +0 -0
- /package/dist/{chunk-2D27ODNX.js.map → chunk-TIVZ4MCG.js.map} +0 -0
- /package/dist/{chunk-5KBNNUXS.js.map → chunk-TT7BJWGI.js.map} +0 -0
- /package/dist/{chunk-KQAFEZQX.js.map → chunk-VDX2J7OX.js.map} +0 -0
- /package/dist/{chunk-E6BOD3UJ.js.map → chunk-VPAFWWCL.js.map} +0 -0
- /package/dist/{chunk-UOCLRM74.js.map → chunk-W54EAJT4.js.map} +0 -0
- /package/dist/{chunk-QVG4LAQO.js.map → chunk-WR6KFJKA.js.map} +0 -0
- /package/dist/{chunk-YQGHW5ML.js.map → chunk-WRFKZEO6.js.map} +0 -0
- /package/dist/{chunk-66HROLW5.js.map → chunk-XWT4JXXA.js.map} +0 -0
- /package/dist/{chunk-SAC5V6JT.js.map → chunk-XXA6T3O4.js.map} +0 -0
- /package/dist/{chunk-KF74X62T.js.map → chunk-YGKUAX2B.js.map} +0 -0
- /package/dist/{chunk-W4ELOUNX.js.map → chunk-YOZNTNNA.js.map} +0 -0
- /package/dist/{state-NCHQ4TRG.js.map → extraction-faithfulness.js.map} +0 -0
- /package/dist/{graph-edge-decay-D7OESCBR.js.map → graph-edge-decay-JLOF3YW4.js.map} +0 -0
- /package/dist/{tui-RI7P6PBS.js.map → state-ITXJKXRE.js.map} +0 -0
- /package/dist/{trace-WM7V4CKI.js.map → trace-ZFVRH4GO.js.map} +0 -0
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from "./chunk-3UXOZBHV.js";
|
|
8
8
|
import {
|
|
9
9
|
StorageManager
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-MOBRVKWE.js";
|
|
11
11
|
import {
|
|
12
12
|
isSafeRouteNamespace
|
|
13
13
|
} from "./chunk-U3PN77QT.js";
|
|
@@ -118,4 +118,4 @@ export {
|
|
|
118
118
|
runCodexMaterialize,
|
|
119
119
|
runPostConsolidationMaterialize
|
|
120
120
|
};
|
|
121
|
-
//# sourceMappingURL=chunk-
|
|
121
|
+
//# sourceMappingURL=chunk-3P2XEQSV.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
listNamespaces
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-6GAUF4OU.js";
|
|
4
4
|
import {
|
|
5
5
|
runConsolidationProvenanceCheck
|
|
6
6
|
} from "./chunk-7XH7VJN4.js";
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
} from "./chunk-YBPYIAA5.js";
|
|
10
10
|
import {
|
|
11
11
|
summarizeNamespaceMaintenanceHealth
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-G663XUEG.js";
|
|
13
13
|
import {
|
|
14
14
|
analyzeSessionIntegrity,
|
|
15
15
|
applySessionRepair,
|
|
@@ -35,17 +35,17 @@ import {
|
|
|
35
35
|
} from "./chunk-3PY7VHV7.js";
|
|
36
36
|
import {
|
|
37
37
|
parseConfig
|
|
38
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-EK6FYL2E.js";
|
|
39
39
|
import {
|
|
40
40
|
listMemoryGovernanceRuns,
|
|
41
41
|
readMemoryGovernanceRunArtifact
|
|
42
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-XXA6T3O4.js";
|
|
43
43
|
import {
|
|
44
44
|
analyzeGraphHealth
|
|
45
|
-
} from "./chunk-
|
|
45
|
+
} from "./chunk-YGKUAX2B.js";
|
|
46
46
|
import {
|
|
47
47
|
StorageManager
|
|
48
|
-
} from "./chunk-
|
|
48
|
+
} from "./chunk-MOBRVKWE.js";
|
|
49
49
|
import {
|
|
50
50
|
lintWorkspaceFiles
|
|
51
51
|
} from "./chunk-DM2T26WE.js";
|
|
@@ -788,7 +788,7 @@ async function summarizeBufferSurpriseDistribution(storage, config) {
|
|
|
788
788
|
}
|
|
789
789
|
}
|
|
790
790
|
async function summarizeGraphEdgeDecayStatus(config) {
|
|
791
|
-
const { readGraphEdgeDecayStatus } = await import("./graph-edge-decay-
|
|
791
|
+
const { readGraphEdgeDecayStatus } = await import("./graph-edge-decay-JLOF3YW4.js");
|
|
792
792
|
const enabled = config.graphEdgeDecayEnabled === true;
|
|
793
793
|
if (!enabled) {
|
|
794
794
|
return {
|
|
@@ -1347,4 +1347,4 @@ export {
|
|
|
1347
1347
|
runBenchmarkRecall,
|
|
1348
1348
|
runOperatorRepair
|
|
1349
1349
|
};
|
|
1350
|
-
//# sourceMappingURL=chunk-
|
|
1350
|
+
//# sourceMappingURL=chunk-4NNDJOAO.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
runPostConsolidationMaterialize
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-3P2XEQSV.js";
|
|
4
4
|
import {
|
|
5
5
|
discoverMemoryExtensions,
|
|
6
6
|
renderExtensionsBlock,
|
|
@@ -217,4 +217,4 @@ export {
|
|
|
217
217
|
buildExtensionsBlockForConsolidation,
|
|
218
218
|
materializeAfterSemanticConsolidation
|
|
219
219
|
};
|
|
220
|
-
//# sourceMappingURL=chunk-
|
|
220
|
+
//# sourceMappingURL=chunk-52QIAN76.js.map
|
|
@@ -0,0 +1,553 @@
|
|
|
1
|
+
import {
|
|
2
|
+
gatewayTaskChainOptions
|
|
3
|
+
} from "./chunk-5TYA4OCF.js";
|
|
4
|
+
import {
|
|
5
|
+
extractJsonCandidates
|
|
6
|
+
} from "./chunk-RGMVMVMF.js";
|
|
7
|
+
import {
|
|
8
|
+
log
|
|
9
|
+
} from "./chunk-NU3CSQ4H.js";
|
|
10
|
+
|
|
11
|
+
// src/extraction-faithfulness.ts
|
|
12
|
+
import { createHash } from "crypto";
|
|
13
|
+
var FAITHFULNESS_SYSTEM_PROMPT = `You are a faithfulness verifier for a memory system. Given a QUOTE from the source conversation and an extracted FACT, determine whether the FACT is supported by the QUOTE.
|
|
14
|
+
|
|
15
|
+
Rules:
|
|
16
|
+
- "entailed" \u2014 the FACT directly follows from the QUOTE (paraphrase is OK).
|
|
17
|
+
- "contradicted" \u2014 the FACT asserts something the QUOTE directly negates.
|
|
18
|
+
- "unsupported" \u2014 the FACT introduces information not present in the QUOTE.
|
|
19
|
+
|
|
20
|
+
Answer with a JSON array. Each element: {"index": <int>, "verdict": "entailed"|"contradicted"|"unsupported", "rationale": "<one sentence>"}.
|
|
21
|
+
|
|
22
|
+
Examples:
|
|
23
|
+
QUOTE: "I've been using Vim for about ten years now."
|
|
24
|
+
FACT: "The user has used Vim for approximately a decade."
|
|
25
|
+
{"index": 0, "verdict": "entailed", "rationale": "Paraphrase of the same duration."}
|
|
26
|
+
|
|
27
|
+
QUOTE: "I've been using Vim for about ten years now."
|
|
28
|
+
FACT: "The user prefers Emacs."
|
|
29
|
+
{"index": 0, "verdict": "unsupported", "rationale": "QUOTE mentions Vim, not Emacs."}
|
|
30
|
+
|
|
31
|
+
QUOTE: "I stopped drinking coffee last month."
|
|
32
|
+
FACT: "The user drinks coffee regularly."
|
|
33
|
+
{"index": 0, "verdict": "contradicted", "rationale": "QUOTE says they stopped; FACT claims the opposite."}`;
|
|
34
|
+
var FAITHFULNESS_PROMPT_HASH = createHash("sha256").update(FAITHFULNESS_SYSTEM_PROMPT).digest("hex");
|
|
35
|
+
function buildBatchPrompt(inputs, contextChars) {
|
|
36
|
+
const parts = [];
|
|
37
|
+
for (let i = 0; i < inputs.length; i++) {
|
|
38
|
+
const inp = inputs[i];
|
|
39
|
+
if (!inp) continue;
|
|
40
|
+
parts.push(`--- Item ${i} ---
|
|
41
|
+
QUOTE: "${inp.quote}"`);
|
|
42
|
+
if (inp.context && inp.context.trim().length > 0) {
|
|
43
|
+
parts.push(`CONTEXT: "${inp.context.slice(0, contextChars)}"`);
|
|
44
|
+
}
|
|
45
|
+
parts.push(`FACT: "${inp.factText}"
|
|
46
|
+
|
|
47
|
+
Respond with the JSON array entry for index ${i}.`);
|
|
48
|
+
}
|
|
49
|
+
parts.push(`
|
|
50
|
+
Respond now with a single JSON array covering indexes 0\u2013${inputs.length - 1}.`);
|
|
51
|
+
return parts.join("\n");
|
|
52
|
+
}
|
|
53
|
+
var VALID_VERDICTS = /* @__PURE__ */ new Set(["entailed", "contradicted", "unsupported"]);
|
|
54
|
+
function parseFaithfulnessResponse(raw, expectedCount) {
|
|
55
|
+
if (!raw || typeof raw !== "string" || raw.trim().length === 0) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
const candidates = extractJsonCandidates(raw);
|
|
59
|
+
for (const candidate of candidates) {
|
|
60
|
+
let parsed;
|
|
61
|
+
try {
|
|
62
|
+
parsed = JSON.parse(candidate);
|
|
63
|
+
} catch {
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
const map = parseEntries(parsed, expectedCount);
|
|
67
|
+
if (map) return map;
|
|
68
|
+
}
|
|
69
|
+
try {
|
|
70
|
+
const single = JSON.parse(raw.trim());
|
|
71
|
+
const map = parseEntries([single], expectedCount);
|
|
72
|
+
if (map) return map;
|
|
73
|
+
} catch {
|
|
74
|
+
}
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
function parseEntries(data, expectedCount) {
|
|
78
|
+
if (!Array.isArray(data)) {
|
|
79
|
+
if (data && typeof data === "object") {
|
|
80
|
+
for (const key of ["results", "verdicts", "entries", "facts"]) {
|
|
81
|
+
const inner = data[key];
|
|
82
|
+
if (Array.isArray(inner)) return parseEntries(inner, expectedCount);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
const map = /* @__PURE__ */ new Map();
|
|
88
|
+
for (const entry of data) {
|
|
89
|
+
if (!entry || typeof entry !== "object") continue;
|
|
90
|
+
const obj = entry;
|
|
91
|
+
const idx = typeof obj.index === "number" ? obj.index : void 0;
|
|
92
|
+
if (idx === void 0 || idx < 0 || idx >= expectedCount) continue;
|
|
93
|
+
const verdictRaw = typeof obj.verdict === "string" ? obj.verdict : void 0;
|
|
94
|
+
if (!verdictRaw || !VALID_VERDICTS.has(verdictRaw)) continue;
|
|
95
|
+
const rationale = typeof obj.rationale === "string" && obj.rationale.trim().length > 0 ? obj.rationale.trim().slice(0, 500) : void 0;
|
|
96
|
+
map.set(idx, {
|
|
97
|
+
index: idx,
|
|
98
|
+
verdict: verdictRaw,
|
|
99
|
+
rationale
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
return map.size > 0 ? map : null;
|
|
103
|
+
}
|
|
104
|
+
async function callFaithfulnessLlm(systemPrompt, userPrompt, config, localLlm, fallbackLlm, timeoutMs, signal) {
|
|
105
|
+
const messages = [
|
|
106
|
+
{ role: "system", content: systemPrompt },
|
|
107
|
+
{ role: "user", content: userPrompt }
|
|
108
|
+
];
|
|
109
|
+
const modelOverride = config.extractionFaithfulnessModel || void 0;
|
|
110
|
+
const skipLocal = config.modelSource === "gateway" || Boolean(modelOverride);
|
|
111
|
+
const gatewayChain = gatewayTaskChainOptions(config);
|
|
112
|
+
let modelUsed = null;
|
|
113
|
+
if (localLlm && !skipLocal) {
|
|
114
|
+
try {
|
|
115
|
+
const result = await callLocalLlm(localLlm, messages, {
|
|
116
|
+
temperature: 0.1,
|
|
117
|
+
maxTokens: 2048,
|
|
118
|
+
responseFormat: { type: "json_object" },
|
|
119
|
+
timeoutMs,
|
|
120
|
+
operation: "extraction-faithfulness"
|
|
121
|
+
});
|
|
122
|
+
if (result.content) {
|
|
123
|
+
return { content: result.content, modelUsed: result.modelUsed ?? "local" };
|
|
124
|
+
}
|
|
125
|
+
} catch (err) {
|
|
126
|
+
log.debug(
|
|
127
|
+
`extraction-faithfulness: local LLM failed, trying fallback: ${err instanceof Error ? err.message : String(err)}`
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
if (fallbackLlm) {
|
|
132
|
+
try {
|
|
133
|
+
const result = await fallbackLlm.chatCompletion(
|
|
134
|
+
messages,
|
|
135
|
+
{
|
|
136
|
+
temperature: 0.1,
|
|
137
|
+
maxTokens: 2048,
|
|
138
|
+
timeoutMs,
|
|
139
|
+
...modelOverride ? { model: modelOverride } : {},
|
|
140
|
+
...gatewayChain,
|
|
141
|
+
...signal ? { signal } : {}
|
|
142
|
+
}
|
|
143
|
+
);
|
|
144
|
+
if (result?.content) {
|
|
145
|
+
return { content: result.content, modelUsed: result.modelUsed ?? "fallback" };
|
|
146
|
+
}
|
|
147
|
+
} catch (err) {
|
|
148
|
+
log.debug(
|
|
149
|
+
`extraction-faithfulness: fallback LLM failed: ${err instanceof Error ? err.message : String(err)}`
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return { content: null, modelUsed: null };
|
|
154
|
+
}
|
|
155
|
+
async function callLocalLlm(client, messages, options) {
|
|
156
|
+
const result = await client.chatCompletion(messages, options);
|
|
157
|
+
return {
|
|
158
|
+
content: result?.content ?? null
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
async function checkFaithfulnessBatch(inputs, config, localLlm, fallbackLlm) {
|
|
162
|
+
const timeoutMs = typeof config.extractionFaithfulnessTimeoutMs === "number" && Number.isFinite(config.extractionFaithfulnessTimeoutMs) && config.extractionFaithfulnessTimeoutMs > 0 ? config.extractionFaithfulnessTimeoutMs : 8e3;
|
|
163
|
+
const contextChars = typeof config.extractionFaithfulnessContextChars === "number" && Number.isFinite(config.extractionFaithfulnessContextChars) && config.extractionFaithfulnessContextChars > 0 ? config.extractionFaithfulnessContextChars : 400;
|
|
164
|
+
const results = new Array(inputs.length);
|
|
165
|
+
const checkableIndices = [];
|
|
166
|
+
const checkableInputs = [];
|
|
167
|
+
for (let i = 0; i < inputs.length; i++) {
|
|
168
|
+
const inp = inputs[i];
|
|
169
|
+
if (!inp || !inp.quote || inp.quote.trim().length === 0) {
|
|
170
|
+
results[i] = { ok: false, error: { code: "no_span" } };
|
|
171
|
+
} else if (!inp.factText || inp.factText.trim().length === 0) {
|
|
172
|
+
results[i] = { ok: false, error: { code: "no_span" } };
|
|
173
|
+
} else {
|
|
174
|
+
checkableIndices.push(i);
|
|
175
|
+
checkableInputs.push(inp);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
if (checkableInputs.length === 0) {
|
|
179
|
+
return { results, elapsedMs: 0 };
|
|
180
|
+
}
|
|
181
|
+
const userPrompt = buildBatchPrompt(checkableInputs, contextChars);
|
|
182
|
+
const startedAt = Date.now();
|
|
183
|
+
let timedOut = false;
|
|
184
|
+
const controller = new AbortController();
|
|
185
|
+
let resolveTimeout;
|
|
186
|
+
const racedTimeout = new Promise((resolve) => {
|
|
187
|
+
resolveTimeout = resolve;
|
|
188
|
+
});
|
|
189
|
+
const timer = setTimeout(() => {
|
|
190
|
+
timedOut = true;
|
|
191
|
+
controller.abort();
|
|
192
|
+
resolveTimeout(true);
|
|
193
|
+
}, timeoutMs);
|
|
194
|
+
try {
|
|
195
|
+
const callPromise = callFaithfulnessLlm(
|
|
196
|
+
FAITHFULNESS_SYSTEM_PROMPT,
|
|
197
|
+
userPrompt,
|
|
198
|
+
config,
|
|
199
|
+
localLlm,
|
|
200
|
+
fallbackLlm,
|
|
201
|
+
timeoutMs,
|
|
202
|
+
controller.signal
|
|
203
|
+
);
|
|
204
|
+
const settled = await Promise.race([
|
|
205
|
+
callPromise.then(
|
|
206
|
+
(r) => ({ done: true, result: r }),
|
|
207
|
+
// An unexpected throw is treated as "no content" (backend_unavailable)
|
|
208
|
+
// so the race never rejects and the outer catch is the final safety net.
|
|
209
|
+
() => ({ done: true, result: { content: null, modelUsed: null } })
|
|
210
|
+
),
|
|
211
|
+
racedTimeout.then(() => ({ done: false }))
|
|
212
|
+
]);
|
|
213
|
+
const elapsedMs = Date.now() - startedAt;
|
|
214
|
+
if (!settled.done) {
|
|
215
|
+
for (const idx of checkableIndices) {
|
|
216
|
+
results[idx] = { ok: false, error: { code: "timeout" } };
|
|
217
|
+
}
|
|
218
|
+
return { results, elapsedMs };
|
|
219
|
+
}
|
|
220
|
+
const llmResult = settled.result;
|
|
221
|
+
if (timedOut && !llmResult.content) {
|
|
222
|
+
for (const idx of checkableIndices) {
|
|
223
|
+
results[idx] = { ok: false, error: { code: "timeout" } };
|
|
224
|
+
}
|
|
225
|
+
return { results, elapsedMs };
|
|
226
|
+
}
|
|
227
|
+
if (!llmResult.content) {
|
|
228
|
+
for (const idx of checkableIndices) {
|
|
229
|
+
results[idx] = { ok: false, error: { code: "backend_unavailable" } };
|
|
230
|
+
}
|
|
231
|
+
return { results, elapsedMs };
|
|
232
|
+
}
|
|
233
|
+
const parsed = parseFaithfulnessResponse(llmResult.content, checkableInputs.length);
|
|
234
|
+
if (!parsed) {
|
|
235
|
+
for (const idx of checkableIndices) {
|
|
236
|
+
results[idx] = { ok: false, error: { code: "malformed_output" } };
|
|
237
|
+
}
|
|
238
|
+
return { results, elapsedMs };
|
|
239
|
+
}
|
|
240
|
+
for (let j = 0; j < checkableIndices.length; j++) {
|
|
241
|
+
const inputIdx = checkableIndices[j];
|
|
242
|
+
if (inputIdx === void 0) continue;
|
|
243
|
+
const entry = parsed.get(j);
|
|
244
|
+
if (entry) {
|
|
245
|
+
results[inputIdx] = {
|
|
246
|
+
ok: true,
|
|
247
|
+
verdict: entry.verdict,
|
|
248
|
+
model: llmResult.modelUsed ?? "unknown",
|
|
249
|
+
...entry.rationale ? { rationale: entry.rationale } : {}
|
|
250
|
+
};
|
|
251
|
+
} else {
|
|
252
|
+
results[inputIdx] = { ok: false, error: { code: "malformed_output" } };
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
return { results, elapsedMs };
|
|
256
|
+
} catch (err) {
|
|
257
|
+
const elapsedMs = Date.now() - startedAt;
|
|
258
|
+
if (timedOut || isAbortError(err)) {
|
|
259
|
+
for (const idx of checkableIndices) {
|
|
260
|
+
results[idx] = { ok: false, error: { code: "timeout" } };
|
|
261
|
+
}
|
|
262
|
+
return { results, elapsedMs };
|
|
263
|
+
}
|
|
264
|
+
log.warn(
|
|
265
|
+
`extraction-faithfulness: batch check threw unexpectedly: ${err instanceof Error ? err.message : String(err)}`
|
|
266
|
+
);
|
|
267
|
+
for (const idx of checkableIndices) {
|
|
268
|
+
results[idx] = { ok: false, error: { code: "backend_unavailable" } };
|
|
269
|
+
}
|
|
270
|
+
return { results, elapsedMs };
|
|
271
|
+
} finally {
|
|
272
|
+
clearTimeout(timer);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
function isAbortError(err) {
|
|
276
|
+
if (!err || typeof err !== "object") return false;
|
|
277
|
+
const maybe = err;
|
|
278
|
+
return maybe.name === "AbortError" || maybe.message === "This operation was aborted" || maybe.message === "The operation was aborted";
|
|
279
|
+
}
|
|
280
|
+
function createFaithfulnessCounters() {
|
|
281
|
+
return { entailed: 0, contradicted: 0, unsupported: 0, unchecked: 0, skippedNoSpan: 0 };
|
|
282
|
+
}
|
|
283
|
+
var STOPWORDS = /* @__PURE__ */ new Set([
|
|
284
|
+
"the",
|
|
285
|
+
"a",
|
|
286
|
+
"an",
|
|
287
|
+
"and",
|
|
288
|
+
"or",
|
|
289
|
+
"but",
|
|
290
|
+
"is",
|
|
291
|
+
"are",
|
|
292
|
+
"was",
|
|
293
|
+
"were",
|
|
294
|
+
"be",
|
|
295
|
+
"been",
|
|
296
|
+
"being",
|
|
297
|
+
"to",
|
|
298
|
+
"of",
|
|
299
|
+
"in",
|
|
300
|
+
"on",
|
|
301
|
+
"at",
|
|
302
|
+
"for",
|
|
303
|
+
"with",
|
|
304
|
+
"from",
|
|
305
|
+
"by",
|
|
306
|
+
"as",
|
|
307
|
+
"it",
|
|
308
|
+
"its",
|
|
309
|
+
"this",
|
|
310
|
+
"that",
|
|
311
|
+
"these",
|
|
312
|
+
"those",
|
|
313
|
+
"i",
|
|
314
|
+
"you",
|
|
315
|
+
"he",
|
|
316
|
+
"she",
|
|
317
|
+
"we",
|
|
318
|
+
"they",
|
|
319
|
+
"my",
|
|
320
|
+
"your",
|
|
321
|
+
"his",
|
|
322
|
+
"her",
|
|
323
|
+
"our",
|
|
324
|
+
"their",
|
|
325
|
+
"has",
|
|
326
|
+
"have",
|
|
327
|
+
"had",
|
|
328
|
+
"do",
|
|
329
|
+
"does",
|
|
330
|
+
"did",
|
|
331
|
+
"will",
|
|
332
|
+
"would",
|
|
333
|
+
"can",
|
|
334
|
+
"could",
|
|
335
|
+
"should",
|
|
336
|
+
"not",
|
|
337
|
+
"no",
|
|
338
|
+
"s",
|
|
339
|
+
"very",
|
|
340
|
+
"really",
|
|
341
|
+
"just",
|
|
342
|
+
"so",
|
|
343
|
+
"than",
|
|
344
|
+
"then",
|
|
345
|
+
"there",
|
|
346
|
+
"here",
|
|
347
|
+
"about",
|
|
348
|
+
"into",
|
|
349
|
+
"over",
|
|
350
|
+
"under"
|
|
351
|
+
]);
|
|
352
|
+
function crudeStem(word) {
|
|
353
|
+
if (word.length > 5 && word.endsWith("ing")) return word.slice(0, -3);
|
|
354
|
+
if (word.length > 4 && word.endsWith("ed")) return word.slice(0, -2);
|
|
355
|
+
if (word.length > 3 && word.endsWith("s") && !word.endsWith("ss")) return word.slice(0, -1);
|
|
356
|
+
return word;
|
|
357
|
+
}
|
|
358
|
+
function tokenize(text) {
|
|
359
|
+
const tokens = /* @__PURE__ */ new Set();
|
|
360
|
+
for (const raw of text.toLowerCase().split(/[^a-z0-9]+/)) {
|
|
361
|
+
if (raw.length <= 1) continue;
|
|
362
|
+
if (STOPWORDS.has(raw)) continue;
|
|
363
|
+
tokens.add(crudeStem(raw));
|
|
364
|
+
}
|
|
365
|
+
return tokens;
|
|
366
|
+
}
|
|
367
|
+
function overlapCoefficient(a, b) {
|
|
368
|
+
if (a.size === 0 || b.size === 0) return 0;
|
|
369
|
+
let intersection = 0;
|
|
370
|
+
const [small, large] = a.size <= b.size ? [a, b] : [b, a];
|
|
371
|
+
for (const t of small) if (large.has(t)) intersection++;
|
|
372
|
+
return intersection / small.size;
|
|
373
|
+
}
|
|
374
|
+
var LOCATE_QUOTE_MIN_OVERLAP = 0.3;
|
|
375
|
+
function extractContextWindow(sourceText, quote, contextChars) {
|
|
376
|
+
if (!sourceText || !quote || !(contextChars > 0)) return void 0;
|
|
377
|
+
const idx = sourceText.indexOf(quote);
|
|
378
|
+
if (idx < 0) return void 0;
|
|
379
|
+
const quoteEnd = idx + quote.length;
|
|
380
|
+
const center = Math.floor((idx + quoteEnd) / 2);
|
|
381
|
+
const half = Math.floor(contextChars / 2);
|
|
382
|
+
let start = Math.max(0, center - half);
|
|
383
|
+
const end = Math.min(sourceText.length, start + contextChars);
|
|
384
|
+
start = Math.max(0, end - contextChars);
|
|
385
|
+
const window = sourceText.slice(start, end).trim();
|
|
386
|
+
return window.length > 0 ? window : void 0;
|
|
387
|
+
}
|
|
388
|
+
function locateFactQuote(factText, sourceText, maxQuoteChars = 600) {
|
|
389
|
+
if (!factText || !sourceText) return void 0;
|
|
390
|
+
const factTokens = tokenize(factText);
|
|
391
|
+
if (factTokens.size === 0) return void 0;
|
|
392
|
+
const candidates = [];
|
|
393
|
+
for (const sentence of sourceText.split(/(?<=[.!?])\s+|\n+/)) {
|
|
394
|
+
const s = sentence.trim();
|
|
395
|
+
if (s.length > 0) candidates.push(s);
|
|
396
|
+
}
|
|
397
|
+
if (candidates.length === 0) return void 0;
|
|
398
|
+
let best = null;
|
|
399
|
+
for (const candidate of candidates) {
|
|
400
|
+
const score = overlapCoefficient(factTokens, tokenize(candidate));
|
|
401
|
+
if (!best || score > best.score) best = { quote: candidate, score };
|
|
402
|
+
}
|
|
403
|
+
if (!best || best.score < LOCATE_QUOTE_MIN_OVERLAP) return void 0;
|
|
404
|
+
return best.quote.length > maxQuoteChars ? best.quote.slice(0, maxQuoteChars) : best.quote;
|
|
405
|
+
}
|
|
406
|
+
async function runFaithfulnessGateBatch(facts, mode, config, localLlm, fallbackLlm, counters, sourceText = "") {
|
|
407
|
+
const inputs = [];
|
|
408
|
+
for (let fi = 0; fi < facts.length; fi++) {
|
|
409
|
+
const f = facts[fi];
|
|
410
|
+
if (!f || typeof f.content !== "string" || !f.content.trim()) continue;
|
|
411
|
+
const sources = Array.isArray(f.sources) ? f.sources : [];
|
|
412
|
+
const sourceQuotes = sources.map((s) => s && typeof s.quote === "string" ? s.quote.trim() : "").filter((q) => q.length > 0);
|
|
413
|
+
const usingFallbackLocator = sourceQuotes.length === 0;
|
|
414
|
+
const quote = sourceQuotes.length > 0 ? sourceQuotes.join("\n") : locateFactQuote(f.content, sourceText);
|
|
415
|
+
if (!quote) continue;
|
|
416
|
+
const fallbackContext = usingFallbackLocator ? extractContextWindow(
|
|
417
|
+
sourceText,
|
|
418
|
+
quote,
|
|
419
|
+
config.extractionFaithfulnessContextChars
|
|
420
|
+
) : void 0;
|
|
421
|
+
inputs.push({
|
|
422
|
+
factIndex: fi,
|
|
423
|
+
input: {
|
|
424
|
+
factText: f.content,
|
|
425
|
+
quote,
|
|
426
|
+
...fallbackContext ? { context: fallbackContext } : {}
|
|
427
|
+
}
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
const resultsByFactIndex = /* @__PURE__ */ new Map();
|
|
431
|
+
if (inputs.length === 0) return resultsByFactIndex;
|
|
432
|
+
try {
|
|
433
|
+
const batch = await checkFaithfulnessBatch(
|
|
434
|
+
inputs.map((x) => x.input),
|
|
435
|
+
config,
|
|
436
|
+
localLlm,
|
|
437
|
+
fallbackLlm
|
|
438
|
+
);
|
|
439
|
+
for (let j = 0; j < inputs.length; j++) {
|
|
440
|
+
const entry = inputs[j];
|
|
441
|
+
if (entry) resultsByFactIndex.set(entry.factIndex, batch.results[j]);
|
|
442
|
+
}
|
|
443
|
+
log.info(
|
|
444
|
+
`extraction-faithfulness[${mode}]: ${inputs.length} facts checked, ${batch.elapsedMs}ms`
|
|
445
|
+
);
|
|
446
|
+
} catch (err) {
|
|
447
|
+
log.warn(
|
|
448
|
+
`extraction-faithfulness: pipeline error, tagging ${inputs.length} checkable facts as unchecked (fail-open): ${err instanceof Error ? err.message : String(err)}`
|
|
449
|
+
);
|
|
450
|
+
for (const { factIndex } of inputs) {
|
|
451
|
+
resultsByFactIndex.set(factIndex, { ok: false, error: { code: "backend_unavailable" } });
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
return resultsByFactIndex;
|
|
455
|
+
}
|
|
456
|
+
function applyFaithfulnessVerdict(resultsByFactIndex, factLoopIndex, mode, factContent, counters) {
|
|
457
|
+
if (!resultsByFactIndex) {
|
|
458
|
+
return { faithfulness: void 0, enforceStatus: void 0 };
|
|
459
|
+
}
|
|
460
|
+
const result = resultsByFactIndex.get(factLoopIndex);
|
|
461
|
+
if (!result) {
|
|
462
|
+
counters.skippedNoSpan++;
|
|
463
|
+
return {
|
|
464
|
+
faithfulness: { verdict: "skipped_no_span", at: (/* @__PURE__ */ new Date()).toISOString() },
|
|
465
|
+
enforceStatus: void 0
|
|
466
|
+
};
|
|
467
|
+
}
|
|
468
|
+
if (result.ok) {
|
|
469
|
+
if (result.verdict === "entailed") counters.entailed++;
|
|
470
|
+
else if (result.verdict === "contradicted") counters.contradicted++;
|
|
471
|
+
else if (result.verdict === "unsupported") counters.unsupported++;
|
|
472
|
+
const fm = {
|
|
473
|
+
verdict: result.verdict,
|
|
474
|
+
...result.model ? { model: result.model } : {},
|
|
475
|
+
...result.rationale ? { rationale: result.rationale } : {},
|
|
476
|
+
at: (/* @__PURE__ */ new Date()).toISOString()
|
|
477
|
+
};
|
|
478
|
+
let enforceStatus;
|
|
479
|
+
if (mode === "enforce" && (result.verdict === "unsupported" || result.verdict === "contradicted")) {
|
|
480
|
+
enforceStatus = "pending_review";
|
|
481
|
+
log.info(
|
|
482
|
+
`extraction-faithfulness[enforce]: routing "${factContent.slice(0, 60)}\u2026" to pending_review (verdict=${result.verdict})`
|
|
483
|
+
);
|
|
484
|
+
}
|
|
485
|
+
return { faithfulness: fm, enforceStatus };
|
|
486
|
+
}
|
|
487
|
+
counters.unchecked++;
|
|
488
|
+
return {
|
|
489
|
+
faithfulness: { verdict: "unchecked", at: (/* @__PURE__ */ new Date()).toISOString() },
|
|
490
|
+
enforceStatus: void 0
|
|
491
|
+
};
|
|
492
|
+
}
|
|
493
|
+
var FAITHFULNESS_KEY_ORDER = ["verdict", "model", "rationale", "at"];
|
|
494
|
+
function serializeFaithfulnessFields(fm, lines) {
|
|
495
|
+
if (!fm.faithfulness) return;
|
|
496
|
+
const fm2 = fm.faithfulness;
|
|
497
|
+
const canonical = {};
|
|
498
|
+
for (const key of FAITHFULNESS_KEY_ORDER) {
|
|
499
|
+
const val = fm2[key];
|
|
500
|
+
if (val !== void 0 && val !== null && val !== "") {
|
|
501
|
+
canonical[key] = val;
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
if (!canonical.verdict) return;
|
|
505
|
+
lines.push(`faithfulness: ${JSON.stringify(canonical)}`);
|
|
506
|
+
}
|
|
507
|
+
function parseFaithfulnessField(raw) {
|
|
508
|
+
if (!raw || typeof raw !== "string" || raw.trim().length === 0) return void 0;
|
|
509
|
+
try {
|
|
510
|
+
const parsed = JSON.parse(raw);
|
|
511
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return void 0;
|
|
512
|
+
const obj = parsed;
|
|
513
|
+
const verdictRaw = typeof obj.verdict === "string" ? obj.verdict : void 0;
|
|
514
|
+
if (!verdictRaw) return void 0;
|
|
515
|
+
const validVerdicts = /* @__PURE__ */ new Set([
|
|
516
|
+
"entailed",
|
|
517
|
+
"contradicted",
|
|
518
|
+
"unsupported",
|
|
519
|
+
"unchecked",
|
|
520
|
+
"skipped_no_span"
|
|
521
|
+
]);
|
|
522
|
+
if (!validVerdicts.has(verdictRaw)) return void 0;
|
|
523
|
+
const result = {
|
|
524
|
+
verdict: verdictRaw
|
|
525
|
+
};
|
|
526
|
+
if (typeof obj.model === "string" && obj.model.length > 0) {
|
|
527
|
+
result.model = obj.model;
|
|
528
|
+
}
|
|
529
|
+
if (typeof obj.rationale === "string" && obj.rationale.length > 0) {
|
|
530
|
+
result.rationale = obj.rationale.slice(0, 500);
|
|
531
|
+
}
|
|
532
|
+
if (typeof obj.at === "string" && obj.at.length > 0) {
|
|
533
|
+
result.at = obj.at;
|
|
534
|
+
}
|
|
535
|
+
return result;
|
|
536
|
+
} catch {
|
|
537
|
+
return void 0;
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
export {
|
|
542
|
+
FAITHFULNESS_PROMPT_HASH,
|
|
543
|
+
parseFaithfulnessResponse,
|
|
544
|
+
checkFaithfulnessBatch,
|
|
545
|
+
createFaithfulnessCounters,
|
|
546
|
+
extractContextWindow,
|
|
547
|
+
locateFactQuote,
|
|
548
|
+
runFaithfulnessGateBatch,
|
|
549
|
+
applyFaithfulnessVerdict,
|
|
550
|
+
serializeFaithfulnessFields,
|
|
551
|
+
parseFaithfulnessField
|
|
552
|
+
};
|
|
553
|
+
//# sourceMappingURL=chunk-5AT62NQH.js.map
|