@remnic/core 10.0.4 → 10.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/access-admin-ops-surface.js +49 -49
- package/dist/access-authorization-probe.js +50 -50
- package/dist/access-boundary.js +49 -49
- package/dist/access-cli.d.ts.map +1 -1
- package/dist/access-cli.js +120 -115
- package/dist/access-cli.js.map +1 -1
- package/dist/access-extraction-force-flush.js +49 -49
- package/dist/access-http-briefing.js +50 -50
- package/dist/access-http-query.js +51 -51
- package/dist/access-http.d.ts.map +1 -1
- package/dist/access-http.js +72 -71
- package/dist/access-identity-continuity-surface.js +49 -49
- package/dist/access-lcm-surface.js +49 -49
- package/dist/access-mcp-correction-tools.d.ts +10 -0
- package/dist/access-mcp-correction-tools.d.ts.map +1 -0
- package/dist/access-mcp-correction-tools.js +8 -0
- package/dist/access-mcp.d.ts.map +1 -1
- package/dist/access-mcp.js +63 -62
- package/dist/access-namespace-preflight.js +49 -49
- package/dist/access-observe-write-category.js +3 -3
- package/dist/access-observe-write-surface.js +49 -49
- package/dist/access-offline-manifest.js +5 -5
- package/dist/access-operations-batch.js +52 -52
- package/dist/access-operations.d.ts +1 -0
- package/dist/access-operations.d.ts.map +1 -1
- package/dist/access-operations.js +59 -59
- package/dist/access-recall-concurrency.js +49 -49
- package/dist/access-recall-diagnostics.js +2 -2
- package/dist/access-recall-response.js +49 -49
- package/dist/access-recall-surface.js +49 -49
- package/dist/access-service.d.ts.map +1 -1
- package/dist/access-service.js +49 -49
- package/dist/access-surface-catalog.js +51 -51
- package/dist/active-recall.js +22 -22
- package/dist/adapters/index.js +4 -4
- package/dist/adapters/registry.js +2 -2
- package/dist/auto-sync-FN7E3OTO.js +2 -2
- package/dist/briefing.js +18 -18
- package/dist/buffer.js +1 -1
- package/dist/calibration.d.ts +31 -3
- package/dist/calibration.d.ts.map +1 -1
- package/dist/calibration.js +67 -16
- package/dist/calibration.js.map +1 -1
- package/dist/causal-consolidation.js +18 -18
- package/dist/{chunk-5YDWSWBU.js → chunk-2CP577K6.js} +2 -2
- package/dist/{chunk-QVBB2CLG.js → chunk-2UF42WXV.js} +27 -26
- package/dist/chunk-2UF42WXV.js.map +1 -0
- package/dist/{chunk-ABET5LA5.js → chunk-37HCPM56.js} +23 -23
- package/dist/{chunk-HSZBALHV.js → chunk-4JNTGPBR.js} +2 -2
- package/dist/{chunk-H6FA36LC.js → chunk-4K2H4KTR.js} +5 -5
- package/dist/{chunk-H7BZBSP6.js → chunk-52II7PB6.js} +4 -4
- package/dist/{chunk-RH6MQ5NG.js → chunk-5BPXMAUP.js} +17 -68
- package/dist/chunk-5BPXMAUP.js.map +1 -0
- package/dist/{chunk-U3LVARGV.js → chunk-5X4ZJESN.js} +2 -2
- package/dist/{chunk-SNGNGH53.js → chunk-63UNVGZW.js} +4 -4
- package/dist/{chunk-2KB7TTAP.js → chunk-64S6X4IU.js} +4 -4
- package/dist/{chunk-MEMH5NKJ.js → chunk-6C76FZRM.js} +2 -2
- package/dist/{chunk-3QAIX7TV.js → chunk-6KHF6PAB.js} +2 -2
- package/dist/{chunk-MYBCB4AT.js → chunk-6T42L5FI.js} +2 -2
- package/dist/{chunk-XTWF5XR6.js → chunk-7CZIKCJR.js} +69 -69
- package/dist/{chunk-R6EOFKZG.js → chunk-7LYRFI5A.js} +2 -2
- package/dist/{chunk-4NFRYOHT.js → chunk-ANZXWOYD.js} +2 -2
- package/dist/{chunk-5XXTZ4Y7.js → chunk-B657ZGDH.js} +2 -2
- package/dist/{chunk-5QHTQMRL.js → chunk-CCMXCZLT.js} +8 -6
- package/dist/chunk-CCMXCZLT.js.map +1 -0
- package/dist/{chunk-NSQ3GUVO.js → chunk-CYEK6Z3P.js} +4 -4
- package/dist/{chunk-4DXVWBDB.js → chunk-D6M3VKMY.js} +4 -10
- package/dist/chunk-D6M3VKMY.js.map +1 -0
- package/dist/{chunk-IRYKRBEX.js → chunk-DJMVSUPK.js} +3 -3
- package/dist/{chunk-7OOW72QA.js → chunk-DTXN4NVD.js} +307 -138
- package/dist/chunk-DTXN4NVD.js.map +1 -0
- package/dist/{chunk-UCCB7RKF.js → chunk-EMVJU7WC.js} +2 -2
- package/dist/{chunk-IY7ZISXV.js → chunk-ENNC3RZ6.js} +2 -2
- package/dist/{chunk-QLK3SL7Q.js → chunk-ETSJD5IV.js} +131 -12
- package/dist/chunk-ETSJD5IV.js.map +1 -0
- package/dist/{chunk-PTFL3INS.js → chunk-FC6RCOIU.js} +2 -2
- package/dist/{chunk-CQQTEDHS.js → chunk-FLV7M7CT.js} +2 -2
- package/dist/{chunk-3SL52JKD.js → chunk-FZVROZKC.js} +5 -5
- package/dist/{chunk-Z2EVKNZR.js → chunk-GEGUBU3D.js} +2 -2
- package/dist/{chunk-LIGP5M2C.js → chunk-GF4H3B3R.js} +8 -8
- package/dist/{chunk-FMIVV5SV.js → chunk-I56MTWE7.js} +2 -2
- package/dist/{chunk-EUL3S3LE.js → chunk-J5WI4QRP.js} +4 -4
- package/dist/{chunk-436IRJUD.js → chunk-JA54KIYD.js} +2 -2
- package/dist/{chunk-QWNBQ2T5.js → chunk-JMF5Q4JY.js} +10 -10
- package/dist/{chunk-IDSSDL4W.js → chunk-JXSYWTFK.js} +21 -4
- package/dist/{chunk-IDSSDL4W.js.map → chunk-JXSYWTFK.js.map} +1 -1
- package/dist/{chunk-ABDTBGI2.js → chunk-KCCZFDJD.js} +2 -2
- package/dist/chunk-KIUVEMBI.js +49 -0
- package/dist/chunk-KIUVEMBI.js.map +1 -0
- package/dist/{chunk-IINXHPCV.js → chunk-KQI2PKYP.js} +2 -2
- package/dist/{chunk-ZOGZMAGI.js → chunk-KQT4DRKF.js} +2 -2
- package/dist/{chunk-RGPPNNDJ.js → chunk-KSUOM3YU.js} +9 -9
- package/dist/{chunk-CXG2T7BJ.js → chunk-KZEMFD6E.js} +3 -3
- package/dist/{chunk-O57VUN4U.js → chunk-L2VS27PZ.js} +2 -2
- package/dist/{chunk-IVGJXS5F.js → chunk-L34W4W4I.js} +2 -2
- package/dist/{chunk-MEP3POVW.js → chunk-L3PWXD73.js} +2 -2
- package/dist/{chunk-NQHSXHJP.js → chunk-L6GNS5GB.js} +2 -2
- package/dist/{chunk-QDKABMUE.js → chunk-MH2DXDN6.js} +2 -2
- package/dist/{chunk-DQJCQHII.js → chunk-MQNOIH2C.js} +6 -6
- package/dist/{chunk-IDSZNHIP.js → chunk-MULNBSPP.js} +4 -4
- package/dist/{chunk-BDHWKFGM.js → chunk-OFEHITAZ.js} +2 -2
- package/dist/{chunk-RYN4AIRM.js → chunk-OZABSIOV.js} +4 -4
- package/dist/{chunk-IXF7TRMQ.js → chunk-Q562GF7J.js} +2 -2
- package/dist/{chunk-H2XCCUOT.js → chunk-QEPL7KIZ.js} +15 -15
- package/dist/{chunk-WLC6XA6C.js → chunk-QGLEM46C.js} +16 -53
- package/dist/chunk-QGLEM46C.js.map +1 -0
- package/dist/{chunk-Y7CXM7UM.js → chunk-QMFKW4OU.js} +3 -3
- package/dist/{chunk-Z63GU5NN.js → chunk-QWWMS4AE.js} +1 -1
- package/dist/chunk-QWWMS4AE.js.map +1 -0
- package/dist/{chunk-R4O2G6ML.js → chunk-RSMIRLKM.js} +2 -2
- package/dist/{chunk-6AH2DDHI.js → chunk-S5TGRZWY.js} +2 -2
- package/dist/{chunk-TYOBAFCY.js → chunk-SNXBXYUE.js} +3 -3
- package/dist/{chunk-IHIP7TJ3.js → chunk-SWRN6U7Q.js} +2 -2
- package/dist/{chunk-DBA2W6VV.js → chunk-SZXPKUMN.js} +6 -6
- package/dist/{chunk-WQUGCOKF.js → chunk-TFA6HPOA.js} +4 -4
- package/dist/{chunk-DYRXRQHV.js → chunk-TL4PM7PC.js} +2 -2
- package/dist/{chunk-TSEUVMJL.js → chunk-TRBLJU6Y.js} +39 -39
- package/dist/{chunk-VWCFR4NR.js → chunk-U6OXJQEH.js} +5 -5
- package/dist/{chunk-YMXCJ7SE.js → chunk-VUEG3TZ4.js} +2 -2
- package/dist/{chunk-ORAL4HJC.js → chunk-WG4TMZJ2.js} +2 -2
- package/dist/{chunk-CV5AMCPX.js → chunk-XPRAOTJY.js} +2 -2
- package/dist/{chunk-RZCRXCLI.js → chunk-XQSJXNWC.js} +2 -2
- package/dist/{chunk-GLS3A4SQ.js → chunk-YGPXV546.js} +2 -2
- package/dist/{chunk-P22M3DX3.js → chunk-YJAOYEWI.js} +2 -2
- package/dist/{chunk-OAFRMLL4.js → chunk-YJEUHGZZ.js} +2 -2
- package/dist/cli.js +92 -91
- package/dist/coding/export-okf-codegraph.js +16 -16
- package/dist/compounding/engine.d.ts.map +1 -1
- package/dist/compounding/engine.js +17 -17
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +22 -22
- package/dist/connectors/codex-materialize-runner.js +17 -17
- package/dist/connectors/index.js +17 -17
- package/dist/consolidation-provenance-check.js +2 -2
- package/dist/contradiction/index.js +7 -7
- package/dist/convergence-refresh.js +19 -19
- package/dist/conversation-index/backend.js +2 -2
- package/dist/corpus-watermark.js +19 -19
- package/dist/correction/correction-access-wiring.d.ts +6 -6
- package/dist/correction/correction-access-wiring.d.ts.map +1 -1
- package/dist/correction/correction-classify.d.ts +25 -0
- package/dist/correction/correction-classify.d.ts.map +1 -0
- package/dist/correction/correction-config.d.ts +11 -0
- package/dist/correction/correction-config.d.ts.map +1 -0
- package/dist/correction/correction-contract.d.ts +13 -1
- package/dist/correction/correction-contract.d.ts.map +1 -1
- package/dist/correction/correction-executor.d.ts +2 -0
- package/dist/correction/correction-executor.d.ts.map +1 -1
- package/dist/correction/correction-planner.d.ts +24 -3
- package/dist/correction/correction-planner.d.ts.map +1 -1
- package/dist/entity-retrieval.js +17 -17
- package/dist/event-order-recall.js +2 -2
- package/dist/explicit-capture.js +2 -2
- package/dist/external-wiki-access.js +50 -50
- package/dist/extraction-span-materialize.js +2 -2
- package/dist/extraction.js +25 -25
- package/dist/harmonic-retrieval.js +17 -17
- package/dist/index.js +192 -191
- package/dist/lcm/index.js +3 -3
- package/dist/local-llm.d.ts.map +1 -1
- package/dist/local-llm.js +1 -1
- package/dist/location/index.js +19 -19
- package/dist/maintenance/memory-governance.js +17 -17
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +17 -17
- package/dist/maintenance/rebuild-memory-projection-runner.js +19 -19
- package/dist/maintenance/rebuild-memory-projection.js +18 -18
- package/dist/memory-browse-operations.js +50 -50
- package/dist/memory-browse.js +1 -1
- package/dist/memory-subject.js +1 -1
- package/dist/namespaces/migrate.js +18 -18
- package/dist/namespaces/search.js +6 -6
- package/dist/namespaces/storage.js +17 -17
- package/dist/operator-doctor-corpus.js +20 -20
- package/dist/operator-toolkit.js +32 -32
- package/dist/orchestration/maintenance.js +28 -28
- package/dist/orchestration/session-context.d.ts.map +1 -1
- package/dist/orchestrator.js +116 -115
- package/dist/recall-explain-renderer.js +3 -3
- package/dist/recall-navigate-access.js +2 -2
- package/dist/recall-navigate-disclosure.js +2 -2
- package/dist/recall-navigate.js +2 -2
- package/dist/recall-navigation-operations.js +50 -50
- package/dist/recall-navigation.js +49 -49
- package/dist/recall-why-service.js +2 -2
- package/dist/recall-xray-cli.js +4 -4
- package/dist/recall-xray-renderer.js +3 -3
- package/dist/recall-xray.js +2 -2
- package/dist/reconcile/manifest.js +3 -3
- package/dist/{resolution-RSG4HZTL.js → resolution-TV3F7ZTH.js} +7 -7
- package/dist/resolution-TV3F7ZTH.js.map +1 -0
- package/dist/resume-bundles.js +23 -23
- package/dist/salvage-envelope.js +1 -1
- package/dist/search/factory.js +5 -5
- package/dist/search/index.js +9 -9
- package/dist/semantic-consolidation.js +23 -23
- package/dist/semantic-rule-promotion.js +17 -17
- package/dist/semantic-rule-verifier.js +17 -17
- package/dist/source-agent-qualifier.js +17 -17
- package/dist/standup/build.js +17 -17
- package/dist/storage.js +16 -16
- package/dist/subject-config.js +1 -1
- package/dist/summarizer.js +3 -3
- package/dist/support-passport/index.js +66 -66
- package/dist/transfer/export-okf.js +17 -17
- package/dist/types.d.ts +6 -23
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -1
- package/dist/verified-recall.js +17 -17
- package/dist/who-knows-cli.js +18 -18
- package/dist/who-knows.js +17 -17
- package/dist/write-envelope.js +1 -1
- package/package.json +2 -2
- package/src/access-cli.ts +4 -0
- package/src/access-http.ts +1 -0
- package/src/access-mcp-correction-tools.ts +56 -0
- package/src/access-mcp.ts +4 -49
- package/src/access-operations.ts +3 -0
- package/src/access-service.ts +12 -21
- package/src/calibration-local-llm.test.ts +361 -0
- package/src/calibration.ts +109 -26
- package/src/compounding/engine.ts +2 -8
- package/src/config.test.ts +26 -0
- package/src/config.ts +4 -60
- package/src/correction/correction-access-wiring.ts +56 -16
- package/src/correction/correction-classify.test.ts +185 -0
- package/src/correction/correction-classify.ts +157 -0
- package/src/correction/correction-config.ts +93 -0
- package/src/correction/correction-contract.ts +61 -14
- package/src/correction/correction-executor.test.ts +102 -2
- package/src/correction/correction-executor.ts +19 -1
- package/src/correction/correction-planner.test.ts +141 -0
- package/src/correction/correction-planner.ts +117 -11
- package/src/correction/correction-surfaces.test.ts +22 -1
- package/src/local-llm-qos.test.ts +36 -0
- package/src/local-llm.ts +20 -3
- package/src/orchestration/session-context.ts +0 -15
- package/src/recall-handles-wiring.test.ts +24 -0
- package/src/types.ts +6 -23
- package/dist/chunk-4DXVWBDB.js.map +0 -1
- package/dist/chunk-5QHTQMRL.js.map +0 -1
- package/dist/chunk-7OOW72QA.js.map +0 -1
- package/dist/chunk-QLK3SL7Q.js.map +0 -1
- package/dist/chunk-QVBB2CLG.js.map +0 -1
- package/dist/chunk-RH6MQ5NG.js.map +0 -1
- package/dist/chunk-WLC6XA6C.js.map +0 -1
- package/dist/chunk-Z63GU5NN.js.map +0 -1
- /package/dist/{resolution-RSG4HZTL.js.map → access-mcp-correction-tools.js.map} +0 -0
- /package/dist/{chunk-5YDWSWBU.js.map → chunk-2CP577K6.js.map} +0 -0
- /package/dist/{chunk-ABET5LA5.js.map → chunk-37HCPM56.js.map} +0 -0
- /package/dist/{chunk-HSZBALHV.js.map → chunk-4JNTGPBR.js.map} +0 -0
- /package/dist/{chunk-H6FA36LC.js.map → chunk-4K2H4KTR.js.map} +0 -0
- /package/dist/{chunk-H7BZBSP6.js.map → chunk-52II7PB6.js.map} +0 -0
- /package/dist/{chunk-U3LVARGV.js.map → chunk-5X4ZJESN.js.map} +0 -0
- /package/dist/{chunk-SNGNGH53.js.map → chunk-63UNVGZW.js.map} +0 -0
- /package/dist/{chunk-2KB7TTAP.js.map → chunk-64S6X4IU.js.map} +0 -0
- /package/dist/{chunk-MEMH5NKJ.js.map → chunk-6C76FZRM.js.map} +0 -0
- /package/dist/{chunk-3QAIX7TV.js.map → chunk-6KHF6PAB.js.map} +0 -0
- /package/dist/{chunk-MYBCB4AT.js.map → chunk-6T42L5FI.js.map} +0 -0
- /package/dist/{chunk-XTWF5XR6.js.map → chunk-7CZIKCJR.js.map} +0 -0
- /package/dist/{chunk-R6EOFKZG.js.map → chunk-7LYRFI5A.js.map} +0 -0
- /package/dist/{chunk-4NFRYOHT.js.map → chunk-ANZXWOYD.js.map} +0 -0
- /package/dist/{chunk-5XXTZ4Y7.js.map → chunk-B657ZGDH.js.map} +0 -0
- /package/dist/{chunk-NSQ3GUVO.js.map → chunk-CYEK6Z3P.js.map} +0 -0
- /package/dist/{chunk-IRYKRBEX.js.map → chunk-DJMVSUPK.js.map} +0 -0
- /package/dist/{chunk-UCCB7RKF.js.map → chunk-EMVJU7WC.js.map} +0 -0
- /package/dist/{chunk-IY7ZISXV.js.map → chunk-ENNC3RZ6.js.map} +0 -0
- /package/dist/{chunk-PTFL3INS.js.map → chunk-FC6RCOIU.js.map} +0 -0
- /package/dist/{chunk-CQQTEDHS.js.map → chunk-FLV7M7CT.js.map} +0 -0
- /package/dist/{chunk-3SL52JKD.js.map → chunk-FZVROZKC.js.map} +0 -0
- /package/dist/{chunk-Z2EVKNZR.js.map → chunk-GEGUBU3D.js.map} +0 -0
- /package/dist/{chunk-LIGP5M2C.js.map → chunk-GF4H3B3R.js.map} +0 -0
- /package/dist/{chunk-FMIVV5SV.js.map → chunk-I56MTWE7.js.map} +0 -0
- /package/dist/{chunk-EUL3S3LE.js.map → chunk-J5WI4QRP.js.map} +0 -0
- /package/dist/{chunk-436IRJUD.js.map → chunk-JA54KIYD.js.map} +0 -0
- /package/dist/{chunk-QWNBQ2T5.js.map → chunk-JMF5Q4JY.js.map} +0 -0
- /package/dist/{chunk-ABDTBGI2.js.map → chunk-KCCZFDJD.js.map} +0 -0
- /package/dist/{chunk-IINXHPCV.js.map → chunk-KQI2PKYP.js.map} +0 -0
- /package/dist/{chunk-ZOGZMAGI.js.map → chunk-KQT4DRKF.js.map} +0 -0
- /package/dist/{chunk-RGPPNNDJ.js.map → chunk-KSUOM3YU.js.map} +0 -0
- /package/dist/{chunk-CXG2T7BJ.js.map → chunk-KZEMFD6E.js.map} +0 -0
- /package/dist/{chunk-O57VUN4U.js.map → chunk-L2VS27PZ.js.map} +0 -0
- /package/dist/{chunk-IVGJXS5F.js.map → chunk-L34W4W4I.js.map} +0 -0
- /package/dist/{chunk-MEP3POVW.js.map → chunk-L3PWXD73.js.map} +0 -0
- /package/dist/{chunk-NQHSXHJP.js.map → chunk-L6GNS5GB.js.map} +0 -0
- /package/dist/{chunk-QDKABMUE.js.map → chunk-MH2DXDN6.js.map} +0 -0
- /package/dist/{chunk-DQJCQHII.js.map → chunk-MQNOIH2C.js.map} +0 -0
- /package/dist/{chunk-IDSZNHIP.js.map → chunk-MULNBSPP.js.map} +0 -0
- /package/dist/{chunk-BDHWKFGM.js.map → chunk-OFEHITAZ.js.map} +0 -0
- /package/dist/{chunk-RYN4AIRM.js.map → chunk-OZABSIOV.js.map} +0 -0
- /package/dist/{chunk-IXF7TRMQ.js.map → chunk-Q562GF7J.js.map} +0 -0
- /package/dist/{chunk-H2XCCUOT.js.map → chunk-QEPL7KIZ.js.map} +0 -0
- /package/dist/{chunk-Y7CXM7UM.js.map → chunk-QMFKW4OU.js.map} +0 -0
- /package/dist/{chunk-R4O2G6ML.js.map → chunk-RSMIRLKM.js.map} +0 -0
- /package/dist/{chunk-6AH2DDHI.js.map → chunk-S5TGRZWY.js.map} +0 -0
- /package/dist/{chunk-TYOBAFCY.js.map → chunk-SNXBXYUE.js.map} +0 -0
- /package/dist/{chunk-IHIP7TJ3.js.map → chunk-SWRN6U7Q.js.map} +0 -0
- /package/dist/{chunk-DBA2W6VV.js.map → chunk-SZXPKUMN.js.map} +0 -0
- /package/dist/{chunk-WQUGCOKF.js.map → chunk-TFA6HPOA.js.map} +0 -0
- /package/dist/{chunk-DYRXRQHV.js.map → chunk-TL4PM7PC.js.map} +0 -0
- /package/dist/{chunk-TSEUVMJL.js.map → chunk-TRBLJU6Y.js.map} +0 -0
- /package/dist/{chunk-VWCFR4NR.js.map → chunk-U6OXJQEH.js.map} +0 -0
- /package/dist/{chunk-YMXCJ7SE.js.map → chunk-VUEG3TZ4.js.map} +0 -0
- /package/dist/{chunk-ORAL4HJC.js.map → chunk-WG4TMZJ2.js.map} +0 -0
- /package/dist/{chunk-CV5AMCPX.js.map → chunk-XPRAOTJY.js.map} +0 -0
- /package/dist/{chunk-RZCRXCLI.js.map → chunk-XQSJXNWC.js.map} +0 -0
- /package/dist/{chunk-GLS3A4SQ.js.map → chunk-YGPXV546.js.map} +0 -0
- /package/dist/{chunk-P22M3DX3.js.map → chunk-YJAOYEWI.js.map} +0 -0
- /package/dist/{chunk-OAFRMLL4.js.map → chunk-YJEUHGZZ.js.map} +0 -0
package/src/calibration.ts
CHANGED
|
@@ -13,14 +13,15 @@
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
import { createHash } from "node:crypto";
|
|
16
|
-
import path from "node:path";
|
|
17
16
|
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
17
|
+
import path from "node:path";
|
|
18
|
+
import { resolveLocalLlmCapabilities } from "./capabilities.js";
|
|
19
|
+
import { OUTPUT_LANGUAGE_POLICY } from "./extraction-prompt.js";
|
|
18
20
|
import { FallbackLlmClient } from "./fallback-llm.js";
|
|
19
|
-
import
|
|
20
|
-
import {
|
|
21
|
-
import { isRecord } from "./store-contract.js";
|
|
21
|
+
import { listJsonFiles } from "./json-store.js";
|
|
22
|
+
import { LocalLlmClient } from "./local-llm.js";
|
|
22
23
|
import { log } from "./logger.js";
|
|
23
|
-
import {
|
|
24
|
+
import type { AgentPersonaModelConfig, GatewayConfig, PluginConfig } from "./types.js";
|
|
24
25
|
|
|
25
26
|
// ─── Types ───────────────────────────────────────────────────────────────────
|
|
26
27
|
|
|
@@ -223,12 +224,57 @@ Output valid JSON only:
|
|
|
223
224
|
]
|
|
224
225
|
}`;
|
|
225
226
|
|
|
227
|
+
interface CalibrationChatClient {
|
|
228
|
+
chatCompletion(
|
|
229
|
+
messages: Array<{ role: "system" | "user" | "assistant"; content: string }>,
|
|
230
|
+
options?: {
|
|
231
|
+
temperature?: number;
|
|
232
|
+
maxTokens?: number;
|
|
233
|
+
agentId?: string;
|
|
234
|
+
modelChain?: AgentPersonaModelConfig;
|
|
235
|
+
}
|
|
236
|
+
): Promise<{ content?: string | null } | null>;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
interface CalibrationLlmOptions {
|
|
240
|
+
gatewayConfig?: GatewayConfig;
|
|
241
|
+
gatewayAgentId?: string;
|
|
242
|
+
modelChain?: AgentPersonaModelConfig;
|
|
243
|
+
workspaceDir?: string;
|
|
244
|
+
/** Plugin config. Supplies `localLlm*` settings when the gateway chain is empty. */
|
|
245
|
+
pluginConfig?: PluginConfig;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
function resolveCalibrationChatClient(options: CalibrationLlmOptions): CalibrationChatClient | null {
|
|
249
|
+
const gateway = new FallbackLlmClient(options.gatewayConfig, {
|
|
250
|
+
workspaceDir: options.workspaceDir,
|
|
251
|
+
});
|
|
252
|
+
if (gateway.isAvailable({ agentId: options.gatewayAgentId, modelChain: options.modelChain })) {
|
|
253
|
+
return gateway;
|
|
254
|
+
}
|
|
255
|
+
const pluginConfig = options.pluginConfig;
|
|
256
|
+
if (pluginConfig && resolveLocalLlmCapabilities(pluginConfig).localLlm) {
|
|
257
|
+
log.info(`[calibration] using configured local LLM (model=${pluginConfig.localLlmModel})`);
|
|
258
|
+
const local = new LocalLlmClient(pluginConfig);
|
|
259
|
+
return {
|
|
260
|
+
chatCompletion(messages, chatOptions) {
|
|
261
|
+
return local.chatCompletion(messages, {
|
|
262
|
+
temperature: chatOptions?.temperature,
|
|
263
|
+
maxTokens: chatOptions?.maxTokens,
|
|
264
|
+
});
|
|
265
|
+
},
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
log.warn("[calibration] no LLM available — skipping consolidation");
|
|
269
|
+
return null;
|
|
270
|
+
}
|
|
271
|
+
|
|
226
272
|
export async function synthesizeCalibrationRules(
|
|
227
273
|
corrections: CorrectionMemory[],
|
|
228
|
-
llm:
|
|
274
|
+
llm: CalibrationChatClient,
|
|
229
275
|
existingRules: CalibrationRule[],
|
|
230
276
|
agentId?: string,
|
|
231
|
-
modelChain?: AgentPersonaModelConfig
|
|
277
|
+
modelChain?: AgentPersonaModelConfig
|
|
232
278
|
): Promise<CalibrationRule[]> {
|
|
233
279
|
if (corrections.length < 2) return [];
|
|
234
280
|
|
|
@@ -238,16 +284,20 @@ export async function synthesizeCalibrationRules(
|
|
|
238
284
|
.map((c, i) => `[${c.id}] ${c.content}`)
|
|
239
285
|
.join("\n\n");
|
|
240
286
|
|
|
241
|
-
const existingRulesText =
|
|
242
|
-
|
|
243
|
-
|
|
287
|
+
const existingRulesText =
|
|
288
|
+
existingRules.length > 0
|
|
289
|
+
? `\n\nExisting calibration rules (avoid duplicating these):\n${existingRules.map((r) => `- ${r.condition}: ${r.calibration}`).join("\n")}`
|
|
290
|
+
: "";
|
|
244
291
|
|
|
245
292
|
const response = await llm.chatCompletion(
|
|
246
293
|
[
|
|
247
294
|
{ role: "system", content: CLUSTER_PROMPT },
|
|
248
|
-
{
|
|
295
|
+
{
|
|
296
|
+
role: "user",
|
|
297
|
+
content: `Here are ${corrections.length} corrections from this user:\n\n${correctionText}${existingRulesText}`,
|
|
298
|
+
},
|
|
249
299
|
],
|
|
250
|
-
{ temperature: 0.3, maxTokens: 3000, agentId, modelChain }
|
|
300
|
+
{ temperature: 0.3, maxTokens: 3000, agentId, modelChain }
|
|
251
301
|
);
|
|
252
302
|
|
|
253
303
|
if (!response?.content) return [];
|
|
@@ -283,7 +333,10 @@ export async function synthesizeCalibrationRules(
|
|
|
283
333
|
}
|
|
284
334
|
const evidenceCorrectionIds = parseEvidenceIds(raw.evidenceIds);
|
|
285
335
|
return {
|
|
286
|
-
id: `cal-${createHash("sha256")
|
|
336
|
+
id: `cal-${createHash("sha256")
|
|
337
|
+
.update(condition + calibration)
|
|
338
|
+
.digest("hex")
|
|
339
|
+
.slice(0, 12)}`,
|
|
287
340
|
ruleType: ruleType as CalibrationRule["ruleType"],
|
|
288
341
|
condition,
|
|
289
342
|
modelTendency,
|
|
@@ -292,8 +345,8 @@ export async function synthesizeCalibrationRules(
|
|
|
292
345
|
confidence,
|
|
293
346
|
evidenceCount: evidenceCorrectionIds.length,
|
|
294
347
|
evidenceCorrectionIds,
|
|
295
|
-
|
|
296
|
-
|
|
348
|
+
createdAt: now,
|
|
349
|
+
lastReinforcedAt: now,
|
|
297
350
|
};
|
|
298
351
|
})
|
|
299
352
|
.filter((rule): rule is CalibrationRule => !!rule);
|
|
@@ -341,6 +394,30 @@ export function buildCalibrationRecallSection(
|
|
|
341
394
|
|
|
342
395
|
// ─── Public API ──────────────────────────────────────────────────────────────
|
|
343
396
|
|
|
397
|
+
/**
|
|
398
|
+
* Options weekly compounding passes into calibration. Gateway agent and task
|
|
399
|
+
* chain fields stay limited to `modelSource: "gateway"`. `pluginConfig` carries
|
|
400
|
+
* the `localLlm*` settings used when that chain is empty.
|
|
401
|
+
*/
|
|
402
|
+
export function calibrationConsolidationInput(config: PluginConfig): {
|
|
403
|
+
memoryDir: string;
|
|
404
|
+
gatewayConfig?: GatewayConfig;
|
|
405
|
+
gatewayAgentId?: string;
|
|
406
|
+
modelChain?: AgentPersonaModelConfig;
|
|
407
|
+
workspaceDir?: string;
|
|
408
|
+
pluginConfig: PluginConfig;
|
|
409
|
+
} {
|
|
410
|
+
const gateway = config.modelSource === "gateway";
|
|
411
|
+
return {
|
|
412
|
+
memoryDir: config.memoryDir,
|
|
413
|
+
gatewayConfig: config.gatewayConfig,
|
|
414
|
+
gatewayAgentId: gateway ? (config.gatewayAgentId || undefined) : undefined,
|
|
415
|
+
modelChain: gateway ? config.taskModelChain : undefined,
|
|
416
|
+
workspaceDir: config.workspaceDir,
|
|
417
|
+
pluginConfig: config,
|
|
418
|
+
};
|
|
419
|
+
}
|
|
420
|
+
|
|
344
421
|
/**
|
|
345
422
|
* Run the full calibration pipeline:
|
|
346
423
|
* 1. Read all corrections
|
|
@@ -354,27 +431,29 @@ export async function runCalibrationConsolidation(options: {
|
|
|
354
431
|
gatewayAgentId?: string;
|
|
355
432
|
modelChain?: AgentPersonaModelConfig;
|
|
356
433
|
workspaceDir?: string;
|
|
434
|
+
pluginConfig?: PluginConfig;
|
|
357
435
|
}): Promise<CalibrationRule[]> {
|
|
358
436
|
try {
|
|
359
|
-
const llm =
|
|
360
|
-
|
|
361
|
-
});
|
|
362
|
-
if (!llm.isAvailable({ agentId: options.gatewayAgentId, modelChain: options.modelChain })) {
|
|
363
|
-
log.debug("[calibration] no LLM available — skipping consolidation");
|
|
364
|
-
return [];
|
|
365
|
-
}
|
|
437
|
+
const llm = resolveCalibrationChatClient(options);
|
|
438
|
+
if (!llm) return [];
|
|
366
439
|
|
|
367
440
|
const corrections = await readCorrections(options.memoryDir);
|
|
368
441
|
if (corrections.length < 3) {
|
|
369
|
-
log.
|
|
442
|
+
log.info(`[calibration] only ${corrections.length} corrections — need at least 3`);
|
|
370
443
|
return [];
|
|
371
444
|
}
|
|
372
445
|
|
|
373
446
|
const existingIndex = await readCalibrationIndex(options.memoryDir);
|
|
374
447
|
|
|
375
|
-
const newRules = await synthesizeCalibrationRules(
|
|
448
|
+
const newRules = await synthesizeCalibrationRules(
|
|
449
|
+
corrections,
|
|
450
|
+
llm,
|
|
451
|
+
existingIndex.rules,
|
|
452
|
+
options.gatewayAgentId,
|
|
453
|
+
options.modelChain
|
|
454
|
+
);
|
|
376
455
|
if (newRules.length === 0) {
|
|
377
|
-
log.
|
|
456
|
+
log.info("[calibration] no new calibration rules synthesized");
|
|
378
457
|
return existingIndex.rules;
|
|
379
458
|
}
|
|
380
459
|
|
|
@@ -402,7 +481,9 @@ export async function runCalibrationConsolidation(options: {
|
|
|
402
481
|
log.debug(`[calibration] synthesized ${newRules.length} new rule(s), ${allRules.length} total`);
|
|
403
482
|
return allRules;
|
|
404
483
|
} catch (error) {
|
|
405
|
-
log.warn(
|
|
484
|
+
log.warn(
|
|
485
|
+
`[calibration] consolidation failed (non-fatal): ${error instanceof Error ? error.message : String(error)}`
|
|
486
|
+
);
|
|
406
487
|
return [];
|
|
407
488
|
}
|
|
408
489
|
}
|
|
@@ -421,6 +502,7 @@ export async function runCalibrationIfEnabled(options: {
|
|
|
421
502
|
gatewayAgentId?: string;
|
|
422
503
|
modelChain?: AgentPersonaModelConfig;
|
|
423
504
|
workspaceDir?: string;
|
|
505
|
+
pluginConfig?: PluginConfig;
|
|
424
506
|
}): Promise<CalibrationRule[]> {
|
|
425
507
|
if (!options.calibrationEnabled) {
|
|
426
508
|
return [];
|
|
@@ -431,6 +513,7 @@ export async function runCalibrationIfEnabled(options: {
|
|
|
431
513
|
gatewayAgentId: options.gatewayAgentId,
|
|
432
514
|
modelChain: options.modelChain,
|
|
433
515
|
workspaceDir: options.workspaceDir,
|
|
516
|
+
pluginConfig: options.pluginConfig,
|
|
434
517
|
});
|
|
435
518
|
}
|
|
436
519
|
|
|
@@ -552,14 +552,8 @@ export class CompoundingEngine {
|
|
|
552
552
|
// PEDC: Run calibration consolidation during weekly synthesis
|
|
553
553
|
if (resolveConsolidationCapabilities(this.config).calibration) {
|
|
554
554
|
try {
|
|
555
|
-
const { runCalibrationConsolidation } = await import("../calibration.js");
|
|
556
|
-
const calRules = await runCalibrationConsolidation(
|
|
557
|
-
memoryDir: this.config.memoryDir,
|
|
558
|
-
gatewayConfig: this.config.gatewayConfig,
|
|
559
|
-
gatewayAgentId: this.config.modelSource === "gateway" ? (this.config.gatewayAgentId || undefined) : undefined,
|
|
560
|
-
modelChain: this.config.modelSource === "gateway" ? this.config.taskModelChain : undefined,
|
|
561
|
-
workspaceDir: this.config.workspaceDir,
|
|
562
|
-
});
|
|
555
|
+
const { calibrationConsolidationInput, runCalibrationConsolidation } = await import("../calibration.js");
|
|
556
|
+
const calRules = await runCalibrationConsolidation(calibrationConsolidationInput(this.config));
|
|
563
557
|
log.debug(`[calibration] weekly synthesis produced ${calRules.length} calibration rule(s)`);
|
|
564
558
|
} catch (error) {
|
|
565
559
|
log.warn(`[calibration] weekly consolidation failed (non-fatal): ${error instanceof Error ? error.message : String(error)}`);
|
package/src/config.test.ts
CHANGED
|
@@ -2463,6 +2463,32 @@ test("parseConfig rejects invalid correction.planTtlHours instead of silently de
|
|
|
2463
2463
|
assert.equal(parseConfig({}).correctionPlanTtlHours, 24, "absent → documented default");
|
|
2464
2464
|
});
|
|
2465
2465
|
|
|
2466
|
+
test("parseConfig correction.classifyTimeoutMs defaults to 45000 and rejects invalid values", () => {
|
|
2467
|
+
assert.equal(parseConfig({}).correctionClassifyTimeoutMs, 45_000);
|
|
2468
|
+
assert.equal(parseConfig({ correction: { classifyTimeoutMs: 12000 } }).correctionClassifyTimeoutMs, 12_000);
|
|
2469
|
+
assert.equal(
|
|
2470
|
+
parseConfig({
|
|
2471
|
+
correction: { classifyTimeoutMs: 8000 },
|
|
2472
|
+
correctionClassifyTimeoutMs: 1000,
|
|
2473
|
+
}).correctionClassifyTimeoutMs,
|
|
2474
|
+
8000,
|
|
2475
|
+
"nested correction.classifyTimeoutMs wins",
|
|
2476
|
+
);
|
|
2477
|
+
assert.equal(parseConfig({ correctionClassifyTimeoutMs: 15000 }).correctionClassifyTimeoutMs, 15_000);
|
|
2478
|
+
for (const value of [0, -1, 3.7, "abc", 300_001, true]) {
|
|
2479
|
+
assert.throws(
|
|
2480
|
+
() => parseConfig({ correctionClassifyTimeoutMs: value } as Record<string, unknown>),
|
|
2481
|
+
/Invalid correction\.classifyTimeoutMs/,
|
|
2482
|
+
`correctionClassifyTimeoutMs=${JSON.stringify(value)} should throw`,
|
|
2483
|
+
);
|
|
2484
|
+
assert.throws(
|
|
2485
|
+
() => parseConfig({ correction: { classifyTimeoutMs: value } } as Record<string, unknown>),
|
|
2486
|
+
/Invalid correction\.classifyTimeoutMs/,
|
|
2487
|
+
`nested classifyTimeoutMs=${JSON.stringify(value)} should throw`,
|
|
2488
|
+
);
|
|
2489
|
+
}
|
|
2490
|
+
});
|
|
2491
|
+
|
|
2466
2492
|
test("parseConfig correction.maxAffected rejects non-integers (Number.isInteger, #1678)", () => {
|
|
2467
2493
|
// The error message says "integer" — 3.7 must be rejected, not silently floored to 3.
|
|
2468
2494
|
for (const value of [3.7, 2.5, "1.5", 0.99]) {
|
package/src/config.ts
CHANGED
|
@@ -28,6 +28,7 @@ import type {
|
|
|
28
28
|
import { parseBackgroundGeneration } from "./background-generation-config.js";
|
|
29
29
|
import { parseSearchBackend } from "./config-search-backend.js";
|
|
30
30
|
import { parseLocalLlmConfig } from "./local-llm-config.js";
|
|
31
|
+
import { parseCorrectionConfig } from "./correction/correction-config.js";
|
|
31
32
|
import { parseConvergeConfig } from "./converge-config.js";
|
|
32
33
|
import { parseExternalWikiRecallGuard } from "./external-wiki-guard.js";
|
|
33
34
|
import { log } from "./logger.js";
|
|
@@ -1855,66 +1856,9 @@ export function parseConfig(
|
|
|
1855
1856
|
// (docs kept honest — review: wire resolver before exposing the gate).
|
|
1856
1857
|
temporalBiTemporal: coerceBool(cfg.temporalBiTemporal) ?? false,
|
|
1857
1858
|
temporalExpiredInInjection: coerceBool(cfg.temporalExpiredInInjection) ?? false,
|
|
1858
|
-
// Correction Contract (
|
|
1859
|
-
//
|
|
1860
|
-
|
|
1861
|
-
// flat legacy keys are dropped and the runtime always sees defaults. Nested
|
|
1862
|
-
// `correction.<key>` wins; flat `correction<Key>` is the legacy fallback.
|
|
1863
|
-
correctionEnabled: (() => {
|
|
1864
|
-
const nested = (cfg.correction as Record<string, unknown> | undefined)?.enabled;
|
|
1865
|
-
const raw = nested !== undefined ? nested : cfg.correctionEnabled;
|
|
1866
|
-
if (raw === undefined || raw === null) return true;
|
|
1867
|
-
const v = coerceBool(raw);
|
|
1868
|
-
if (v === undefined) {
|
|
1869
|
-
throw new Error(`Invalid correction.enabled: expected a boolean, got ${JSON.stringify(raw)}`);
|
|
1870
|
-
}
|
|
1871
|
-
return v;
|
|
1872
|
-
})(),
|
|
1873
|
-
correctionApplyRequiresConfirm: (() => {
|
|
1874
|
-
const nested = (cfg.correction as Record<string, unknown> | undefined)?.applyRequiresConfirm;
|
|
1875
|
-
const raw = nested !== undefined ? nested : cfg.correctionApplyRequiresConfirm;
|
|
1876
|
-
if (raw === undefined || raw === null) return true;
|
|
1877
|
-
const v = coerceBool(raw);
|
|
1878
|
-
if (v === undefined) {
|
|
1879
|
-
throw new Error(`Invalid correction.applyRequiresConfirm: expected a boolean, got ${JSON.stringify(raw)}`);
|
|
1880
|
-
}
|
|
1881
|
-
return v;
|
|
1882
|
-
})(),
|
|
1883
|
-
correctionMaxAffected: (() => {
|
|
1884
|
-
const rawNested = (cfg.correction as Record<string, unknown> | undefined)?.maxAffected;
|
|
1885
|
-
const raw = rawNested !== undefined ? rawNested : cfg.correctionMaxAffected;
|
|
1886
|
-
if (raw === undefined || raw === null) return 10;
|
|
1887
|
-
const n = coerceNumber(raw);
|
|
1888
|
-
// #1678 (thread Oiup6): the error message says "integer" — enforce it
|
|
1889
|
-
// with Number.isInteger so 3.7 is rejected rather than silently floored.
|
|
1890
|
-
if (n === undefined || !Number.isFinite(n) || n < 1 || !Number.isInteger(n)) {
|
|
1891
|
-
throw new Error(`Invalid correction.maxAffected: expected an integer >= 1, got ${JSON.stringify(raw)}`);
|
|
1892
|
-
}
|
|
1893
|
-
return n;
|
|
1894
|
-
})(),
|
|
1895
|
-
correctionPlanTtlHours: (() => {
|
|
1896
|
-
const nested = (cfg.correction as Record<string, unknown> | undefined)?.planTtlHours;
|
|
1897
|
-
const fromNested = nested !== undefined ? coerceNumber(nested) : undefined;
|
|
1898
|
-
if (fromNested !== undefined && fromNested >= 1) return fromNested;
|
|
1899
|
-
// #1678 (threads Ohtvi/Ohyvf): reject invalid (0/negative/non-numeric)
|
|
1900
|
-
// instead of silently defaulting to 24h — completes the config-reject
|
|
1901
|
-
// class already enforced for enabled/applyRequiresConfirm/maxAffected.
|
|
1902
|
-
if (nested !== undefined && fromNested === undefined) {
|
|
1903
|
-
throw new Error(`Invalid correction.planTtlHours: expected a number >= 1, got ${JSON.stringify(nested)}`);
|
|
1904
|
-
}
|
|
1905
|
-
if (fromNested !== undefined && fromNested < 1) {
|
|
1906
|
-
throw new Error(`Invalid correction.planTtlHours: expected a number >= 1, got ${JSON.stringify(nested)}`);
|
|
1907
|
-
}
|
|
1908
|
-
const fromFlat = coerceNumber(cfg.correctionPlanTtlHours);
|
|
1909
|
-
if (fromFlat !== undefined && fromFlat >= 1) return fromFlat;
|
|
1910
|
-
if (cfg.correctionPlanTtlHours !== undefined && fromFlat === undefined) {
|
|
1911
|
-
throw new Error(`Invalid correction.planTtlHours: expected a number >= 1, got ${JSON.stringify(cfg.correctionPlanTtlHours)}`);
|
|
1912
|
-
}
|
|
1913
|
-
if (fromFlat !== undefined && fromFlat < 1) {
|
|
1914
|
-
throw new Error(`Invalid correction.planTtlHours: expected a number >= 1, got ${JSON.stringify(cfg.correctionPlanTtlHours)}`);
|
|
1915
|
-
}
|
|
1916
|
-
return 24;
|
|
1917
|
-
})(),
|
|
1859
|
+
// Correction Contract (#1580). Nested `correction.<key>` wins over flat
|
|
1860
|
+
// `correction<Key>`. Parser lives in correction/correction-config.ts.
|
|
1861
|
+
...parseCorrectionConfig(cfg),
|
|
1918
1862
|
// Passive correction capture (issue #1581). Parsed from
|
|
1919
1863
|
// `correctionCapture.<key>` (nested) or flat legacy keys. Default "off" —
|
|
1920
1864
|
// operators opt in (rule 48). Invalid mode → rejected listing options (rule 51).
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
*/
|
|
22
22
|
|
|
23
23
|
import path from "node:path";
|
|
24
|
-
import { throwIfAborted } from "../abort-error.js";
|
|
24
|
+
import { abortError, isAbortError, throwIfAborted } from "../abort-error.js";
|
|
25
25
|
import { composeMemoryEnvelope, isMemoryCategory } from "../write-envelope.js";
|
|
26
26
|
import { log } from "../logger.js";
|
|
27
27
|
import { createHash } from "node:crypto";
|
|
@@ -48,6 +48,7 @@ import {
|
|
|
48
48
|
} from "./correction-planner.js";
|
|
49
49
|
import { type ExecutorDeps, type ExecutorMemory } from "./correction-executor.js";
|
|
50
50
|
import { CorrectionService, type CorrectionServiceDeps } from "./correction-service.js";
|
|
51
|
+
import { completeCorrectionClassify } from "./correction-classify.js";
|
|
51
52
|
import { resolveRecallAuxiliaryCapabilities } from "../capabilities.js";
|
|
52
53
|
import { isSupportPassportPrivateMemory } from "../support-passport/card-projection.js";
|
|
53
54
|
|
|
@@ -81,15 +82,15 @@ export interface CorrectionAccessWiring {
|
|
|
81
82
|
principal?: string;
|
|
82
83
|
}): Promise<boolean>;
|
|
83
84
|
/**
|
|
84
|
-
* Optional
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
* ships with the safe fallback.
|
|
85
|
+
* Optional test override for classify+draft. Production leaves this unset
|
|
86
|
+
* and uses completeCorrectionClassify: a short per-attempt timeout, caller
|
|
87
|
+
* abort, then the gateway/fallback model. A caller abort propagates; every
|
|
88
|
+
* other failure becomes the deterministic empty-action plan.
|
|
89
89
|
*/
|
|
90
90
|
llmComplete?(request: {
|
|
91
91
|
system: string;
|
|
92
92
|
user: string;
|
|
93
|
+
abortSignal?: AbortSignal;
|
|
93
94
|
}): Promise<string>;
|
|
94
95
|
}
|
|
95
96
|
|
|
@@ -144,10 +145,12 @@ function makePlannerDeps(
|
|
|
144
145
|
searchMemories(wiring, text, namespaces, limit),
|
|
145
146
|
resolveTargets: async ({ targetIds, namespaces }) =>
|
|
146
147
|
resolveTargetMemories(wiring, targetIds, namespaces),
|
|
148
|
+
inspectMemory: async ({ memoryId, namespaces }) =>
|
|
149
|
+
inspectCorrectionMemory(wiring, memoryId, namespaces),
|
|
147
150
|
expandNeighbors: async ({ seedIds, namespaces, limit }) =>
|
|
148
151
|
expandEntityNeighbors(wiring, seedIds, namespaces, limit),
|
|
149
|
-
classifyAndDraft: async ({ text, candidates }) =>
|
|
150
|
-
classifyAndDraft(wiring, text, candidates),
|
|
152
|
+
classifyAndDraft: async ({ text, candidates, abortSignal }) =>
|
|
153
|
+
classifyAndDraft(wiring, text, candidates, abortSignal),
|
|
151
154
|
renderDiff: async ({ candidates, actions }) =>
|
|
152
155
|
renderCorrectionDiff(wiring, candidates, actions),
|
|
153
156
|
storageDir: async (namespace) => (await wiring.orchestrator.getStorage(namespace)).dir,
|
|
@@ -294,22 +297,54 @@ async function classifyAndDraft(
|
|
|
294
297
|
wiring: CorrectionAccessWiring,
|
|
295
298
|
text: string,
|
|
296
299
|
candidates: PlannerCandidate[],
|
|
300
|
+
abortSignal?: AbortSignal,
|
|
297
301
|
): Promise<LlmClassificationResult> {
|
|
298
|
-
//
|
|
299
|
-
//
|
|
300
|
-
//
|
|
302
|
+
// Injected llmComplete stays as a test override. Production uses
|
|
303
|
+
// completeCorrectionClassify: short timeout, caller abort, gateway fallback.
|
|
304
|
+
// Abort throws. Every other failure is the deterministic empty-action plan.
|
|
301
305
|
try {
|
|
302
|
-
|
|
303
|
-
return fallbackClassification(candidates, "no LLM client available");
|
|
304
|
-
}
|
|
306
|
+
throwIfAborted(abortSignal, "correction classify aborted");
|
|
305
307
|
const user = buildClassifyPrompt(text, candidates);
|
|
306
|
-
const raw =
|
|
308
|
+
const raw = wiring.llmComplete
|
|
309
|
+
? await wiring.llmComplete({ system: CLASSIFY_SYSTEM_PROMPT, user, abortSignal })
|
|
310
|
+
: await completeCorrectionClassify(
|
|
311
|
+
[
|
|
312
|
+
{ role: "system", content: CLASSIFY_SYSTEM_PROMPT },
|
|
313
|
+
{ role: "user", content: user },
|
|
314
|
+
],
|
|
315
|
+
{ config: wiring.orchestrator.config, localLlm: wiring.orchestrator.localLlm },
|
|
316
|
+
abortSignal,
|
|
317
|
+
);
|
|
318
|
+
if (raw == null) return fallbackClassification(candidates, "correction classify unavailable");
|
|
319
|
+
throwIfAborted(abortSignal, "correction classify aborted");
|
|
307
320
|
return parseClassifyResponse(raw, candidates);
|
|
308
321
|
} catch (err) {
|
|
322
|
+
if (isAbortError(err) || abortSignal?.aborted) {
|
|
323
|
+
throw isAbortError(err) ? err : abortError("correction classify aborted");
|
|
324
|
+
}
|
|
309
325
|
return fallbackClassification(candidates, `LLM unavailable: ${errMsg(err)}`);
|
|
310
326
|
}
|
|
311
327
|
}
|
|
312
328
|
|
|
329
|
+
async function inspectCorrectionMemory(
|
|
330
|
+
wiring: CorrectionAccessWiring,
|
|
331
|
+
memoryId: string,
|
|
332
|
+
namespaces: readonly string[],
|
|
333
|
+
): Promise<{ candidate: PlannerCandidate; status: string } | null> {
|
|
334
|
+
for (const ns of namespaces) {
|
|
335
|
+
const storage = await wiring.orchestrator.getStorage(ns);
|
|
336
|
+
const memory = await storage.getMemoryByIdIncludingArchived(memoryId);
|
|
337
|
+
if (!memory || memory.frontmatter.id !== memoryId) continue;
|
|
338
|
+
const candidate = toCandidate(memory, ns, 1);
|
|
339
|
+
if (isSupportPassportPrivateMemory(memory)) return { candidate, status: "ineligible" };
|
|
340
|
+
if (typeof memory.frontmatter.archivedAt === "string" && memory.frontmatter.archivedAt.length > 0) {
|
|
341
|
+
return { candidate, status: "archived" };
|
|
342
|
+
}
|
|
343
|
+
return { candidate, status: memory.frontmatter.status ?? "active" };
|
|
344
|
+
}
|
|
345
|
+
return null;
|
|
346
|
+
}
|
|
347
|
+
|
|
313
348
|
async function renderCorrectionDiff(
|
|
314
349
|
_wiring: CorrectionAccessWiring,
|
|
315
350
|
candidates: PlannerCandidate[],
|
|
@@ -339,7 +374,10 @@ async function renderCorrectionDiff(
|
|
|
339
374
|
function describeAfterState(action: CorrectionAction): string {
|
|
340
375
|
switch (action.kind) {
|
|
341
376
|
case "supersede":
|
|
342
|
-
return action.replacement?.content
|
|
377
|
+
return action.replacement?.content
|
|
378
|
+
?? (action.winnerId
|
|
379
|
+
? `(superseded by ${action.winnerId}; recoverable)`
|
|
380
|
+
: "(superseded without replacement)");
|
|
343
381
|
case "edit":
|
|
344
382
|
return action.patch;
|
|
345
383
|
case "retract":
|
|
@@ -899,6 +937,7 @@ function toExecutorMemory(m: MemoryFile): ExecutorMemory {
|
|
|
899
937
|
...(typeof fm.contentHash === "string" && fm.contentHash.length > 0
|
|
900
938
|
? { contentHash: fm.contentHash }
|
|
901
939
|
: {}),
|
|
940
|
+
status: fm.status ?? "active",
|
|
902
941
|
} satisfies ExecutorMemory;
|
|
903
942
|
}
|
|
904
943
|
|
|
@@ -987,6 +1026,7 @@ Given a correction statement and candidate memories, respond with a JSON object:
|
|
|
987
1026
|
|
|
988
1027
|
Action shapes:
|
|
989
1028
|
- {"kind":"supersede","loserId":"<id>","replacement":{"content":"<new fact>"}}
|
|
1029
|
+
- {"kind":"supersede","loserId":"<id>","winnerId":"<existing id>"}
|
|
990
1030
|
- {"kind":"edit","memoryId":"<id>","patch":"<new full content>"}
|
|
991
1031
|
- {"kind":"retract","memoryId":"<id>"}
|
|
992
1032
|
- {"kind":"rescope","memoryId":"<id>","toNamespace":"<ns>"}
|