@remnic/core 10.0.73 → 10.0.75
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 -48
- package/dist/access-authorization-probe.js +50 -49
- package/dist/access-boundary.js +49 -48
- package/dist/access-cli.js +105 -104
- package/dist/access-cli.js.map +1 -1
- package/dist/access-extraction-force-flush.js +49 -48
- package/dist/access-http-briefing.js +50 -49
- package/dist/access-http-query.js +51 -50
- package/dist/access-http.js +68 -67
- package/dist/access-identity-continuity-surface.js +49 -48
- package/dist/access-lcm-surface.js +49 -48
- package/dist/access-mcp.js +58 -57
- package/dist/access-namespace-preflight.js +49 -48
- package/dist/access-observe-helpers.d.ts.map +1 -1
- package/dist/access-observe-helpers.js +1 -1
- package/dist/access-observe-write-category.js +6 -6
- package/dist/access-observe-write-surface.js +49 -48
- package/dist/access-offline-manifest.js +5 -5
- package/dist/access-operations-batch.js +50 -49
- package/dist/access-operations.js +57 -56
- package/dist/access-recall-concurrency.js +49 -48
- package/dist/access-recall-response.js +49 -48
- package/dist/access-recall-surface.js +49 -48
- package/dist/access-schema.js +5 -5
- package/dist/access-service.js +49 -48
- package/dist/access-surface-catalog.js +51 -50
- package/dist/access-surface-catalog.js.map +1 -1
- package/dist/active-recall.js +18 -18
- package/dist/adapters/index.js +4 -4
- package/dist/adapters/registry.js +2 -2
- package/dist/{auto-sync-ANOJDQD4.js → auto-sync-XHSS3XPL.js} +5 -5
- package/dist/briefing.js +15 -15
- package/dist/buffer-turn-helpers.d.ts +18 -0
- package/dist/buffer-turn-helpers.d.ts.map +1 -1
- package/dist/buffer-turn-helpers.js +5 -1
- package/dist/buffer.js +4 -4
- package/dist/calibration.js +5 -4
- package/dist/calibration.js.map +1 -1
- package/dist/causal-consolidation.js +16 -16
- package/dist/{chunk-7WFY2L5J.js → chunk-233S3MXC.js} +3 -3
- package/dist/{chunk-N7NAGECH.js → chunk-36B5VPRU.js} +2 -2
- package/dist/{chunk-5ORJHH43.js → chunk-3GGCMRO7.js} +2 -2
- package/dist/{chunk-RZED7FAU.js → chunk-3M7YP42P.js} +2 -2
- package/dist/{chunk-ICBUTKLL.js → chunk-3MBSD53O.js} +2 -2
- package/dist/{chunk-J72ZY7NU.js → chunk-4DLZ2ITE.js} +2 -2
- package/dist/{chunk-OUBEJWVI.js → chunk-4KLQI3L2.js} +42 -1
- package/dist/chunk-4KLQI3L2.js.map +1 -0
- package/dist/{chunk-WN2DASTS.js → chunk-5BE3FLKL.js} +4 -4
- package/dist/{chunk-S73ZVU37.js → chunk-5IQL4N37.js} +10 -10
- package/dist/{chunk-CIL4GHMD.js → chunk-6Q6AQ36B.js} +2 -2
- package/dist/{chunk-W4V7P5HP.js → chunk-6RPPZL7W.js} +2 -2
- package/dist/{chunk-EQ6EMJRG.js → chunk-6Y5ANLDH.js} +2 -2
- package/dist/{chunk-YPYSC3TX.js → chunk-7FFGWIBN.js} +2 -2
- package/dist/{chunk-VNTQU6KB.js → chunk-7PMOCQOL.js} +8 -13
- package/dist/chunk-7PMOCQOL.js.map +1 -0
- package/dist/{chunk-5RW247F5.js → chunk-AY2UK5XK.js} +14 -9
- package/dist/chunk-AY2UK5XK.js.map +1 -0
- package/dist/{chunk-5QV6CE6K.js → chunk-B36ACJG7.js} +2 -2
- package/dist/{chunk-ZBET3W26.js → chunk-BZTA7DR4.js} +3 -3
- package/dist/{chunk-JY4LXMZR.js → chunk-C44DRDZM.js} +2 -2
- package/dist/{chunk-UIFWZMO7.js → chunk-CLVILSBR.js} +7 -7
- package/dist/{chunk-OGQGDOYK.js → chunk-COIQ5N4J.js} +2 -2
- package/dist/{chunk-UAOJVQXC.js → chunk-DANFOVQG.js} +2 -2
- package/dist/{chunk-2R44BBPK.js → chunk-DEGE32C3.js} +2 -2
- package/dist/{chunk-YIJECSIX.js → chunk-DJDJBMFX.js} +9 -2
- package/dist/chunk-DJDJBMFX.js.map +1 -0
- package/dist/{chunk-LHMCZ6VW.js → chunk-E22CQZ3H.js} +14 -14
- package/dist/{chunk-JGLZ46JS.js → chunk-ELUG6NKQ.js} +2 -2
- package/dist/{chunk-X4DHAXFO.js → chunk-F3FNXE7C.js} +3 -3
- package/dist/{chunk-YIXWY4OZ.js → chunk-FETPTCQZ.js} +2 -2
- package/dist/{chunk-N2Y6COEM.js → chunk-FGUWCE5I.js} +2 -2
- package/dist/{chunk-FDUCIUQ5.js → chunk-FJ2VJTGA.js} +2 -2
- package/dist/{chunk-ENPJX3BB.js → chunk-FMFCQRDM.js} +3 -3
- package/dist/{chunk-BNU5TQLR.js → chunk-FOQ7TW2T.js} +2 -2
- package/dist/{chunk-4PMFSYH7.js → chunk-FP2AT4WL.js} +2 -2
- package/dist/{chunk-DLZGSZVC.js → chunk-FYQUUIPI.js} +4 -4
- package/dist/{chunk-XTN54NML.js → chunk-G3T6YMBO.js} +4 -4
- package/dist/{chunk-MUH7RR6T.js → chunk-G5NH3SSX.js} +5 -5
- package/dist/{chunk-DC3DWF2M.js → chunk-GCJA5KKT.js} +2 -2
- package/dist/{chunk-U6IL4724.js → chunk-GWOFCHPN.js} +2 -2
- package/dist/{chunk-TJ5YGCPV.js → chunk-GXVK754R.js} +2 -2
- package/dist/{chunk-FGGLVCHI.js → chunk-HB5TNQMM.js} +2 -2
- package/dist/{chunk-GXAZ4Q2S.js → chunk-HCFNZWFB.js} +2 -2
- package/dist/{chunk-F4ZHKDBW.js → chunk-HLWXCDUQ.js} +2 -2
- package/dist/{chunk-IQXQ3KWR.js → chunk-HTDXNIO6.js} +2 -2
- package/dist/{chunk-4RASUAN3.js → chunk-HXFIILGF.js} +4 -4
- package/dist/{chunk-S37O4S6E.js → chunk-I4LJJ44E.js} +2 -2
- package/dist/{chunk-USX5YIKB.js → chunk-IBQ7LGUJ.js} +6 -6
- package/dist/{chunk-UKQFCOGT.js → chunk-IPHIIRDN.js} +3 -3
- package/dist/chunk-IPHIIRDN.js.map +1 -0
- package/dist/{chunk-VSJ3ARFS.js → chunk-IRFQKR4Y.js} +2 -2
- package/dist/{chunk-BCBY5GYZ.js → chunk-IVXOYE43.js} +2 -2
- package/dist/{chunk-WXPBDEMW.js → chunk-JDQEQE2R.js} +2 -2
- package/dist/{chunk-2WPWEVAH.js → chunk-KAED7IBB.js} +2 -2
- package/dist/{chunk-OWZXDBV4.js → chunk-KNZDGZSY.js} +2 -2
- package/dist/{chunk-6KBCUIZP.js → chunk-L4QYW2HO.js} +2 -2
- package/dist/{chunk-LYOCAUI6.js → chunk-LJUQPT5G.js} +3 -3
- package/dist/{chunk-XPZM7GP6.js → chunk-MBENRPMY.js} +10 -10
- package/dist/chunk-MJFL75J6.js +42 -0
- package/dist/chunk-MJFL75J6.js.map +1 -0
- package/dist/{chunk-VK5HKVQ7.js → chunk-N6GEGRCT.js} +2 -2
- package/dist/{chunk-U2A56LLF.js → chunk-OBQ2NZAR.js} +10 -10
- package/dist/{chunk-WGRAB3KB.js → chunk-ORVPS4ZW.js} +2 -2
- package/dist/{chunk-PFUXPTBT.js → chunk-P3AQ2YSX.js} +4 -4
- package/dist/{chunk-DE4U5PTV.js → chunk-P4TEQSIZ.js} +2 -2
- package/dist/{chunk-UE5JYPU6.js → chunk-P7HNMNN2.js} +7 -7
- package/dist/{chunk-ZG4GNPRE.js → chunk-PBE7NFB5.js} +5 -5
- package/dist/{chunk-LN7CWLAU.js → chunk-PLGBPFEO.js} +2 -2
- package/dist/{chunk-5MA7ZLPD.js → chunk-QNUNAXBE.js} +35 -1
- package/dist/chunk-QNUNAXBE.js.map +1 -0
- package/dist/{chunk-23BA3USG.js → chunk-R24RYSQX.js} +43 -43
- package/dist/{chunk-WYOHQJKC.js → chunk-RXGFITWS.js} +4 -4
- package/dist/{chunk-JEX2JL3U.js → chunk-SHVLNI4L.js} +2 -2
- package/dist/{chunk-QUPTDKSX.js → chunk-SY4AFWUZ.js} +31 -31
- package/dist/{chunk-H2X32F2K.js → chunk-SYDPJUFR.js} +2 -2
- package/dist/{chunk-QIOQI7QZ.js → chunk-SZBZOUHR.js} +2 -2
- package/dist/{chunk-EGKDONTC.js → chunk-T6C3G67T.js} +10 -10
- package/dist/chunk-T6C3G67T.js.map +1 -0
- package/dist/{chunk-E3NBMTTX.js → chunk-TLTBACYX.js} +2 -2
- package/dist/{chunk-AVVCPA7U.js → chunk-UCPH56YX.js} +2 -2
- package/dist/{chunk-ZODKV27J.js → chunk-URS56HGW.js} +6 -6
- package/dist/{chunk-PJAMFIDE.js → chunk-VEQVXNWR.js} +4 -4
- package/dist/{chunk-AGRMXXVA.js → chunk-VEWTHVX2.js} +2 -2
- package/dist/{chunk-WNQ3B3Q5.js → chunk-VPEMGBTI.js} +2 -2
- package/dist/{chunk-DSSTOV5M.js → chunk-VYOAYFDV.js} +66 -49
- package/dist/chunk-VYOAYFDV.js.map +1 -0
- package/dist/{chunk-5JBVPJCT.js → chunk-WIAXVBQH.js} +2 -2
- package/dist/{chunk-BTU77RB5.js → chunk-X53HJENJ.js} +2 -2
- package/dist/{chunk-KY3KJUNN.js → chunk-XC7OYOQC.js} +6 -6
- package/dist/{chunk-43FLJLT2.js → chunk-Y5HZFIQO.js} +1 -1
- package/dist/{chunk-DOJBV6WR.js → chunk-YK6SFDP2.js} +4 -4
- package/dist/{chunk-QVZZE6VH.js → chunk-Z3CKK5RR.js} +3 -3
- package/dist/{chunk-AZNE2H6D.js → chunk-ZG57BEUS.js} +2 -2
- package/dist/{chunk-7P5VBRBS.js → chunk-ZZSFRWKD.js} +2 -2
- package/dist/cli.js +81 -80
- package/dist/coding/export-okf-codegraph.js +14 -14
- package/dist/compounding/engine.js +16 -16
- package/dist/config.js +18 -18
- package/dist/connectors/codex-materialize-runner.js +15 -15
- package/dist/connectors/index.js +15 -15
- package/dist/convergence-refresh.js +17 -17
- package/dist/corpus-watermark.js +17 -17
- package/dist/deep-recall-http-glue.js +6 -6
- package/dist/deep-recall-policy-llm.js +3 -3
- package/dist/deep-recall.js +2 -2
- package/dist/entity-retrieval.js +15 -15
- package/dist/external-wiki-access.js +50 -49
- package/dist/extraction-faithfulness.js +3 -3
- package/dist/extraction-judge.js +3 -3
- package/dist/extraction.js +23 -22
- package/dist/fallback-llm-codex-subscription.d.ts.map +1 -1
- package/dist/fallback-llm-codex-subscription.js +1 -1
- package/dist/fallback-llm.js +2 -2
- package/dist/{first-start-migration-A6PHIBUQ.js → first-start-migration-QVD22WWS.js} +4 -4
- package/dist/harmonic-retrieval.js +15 -15
- package/dist/index.js +130 -129
- package/dist/lcm/engine.js +2 -2
- package/dist/lcm/index.js +5 -5
- package/dist/local-llm-native-schema.d.ts +50 -0
- package/dist/local-llm-native-schema.d.ts.map +1 -0
- package/dist/local-llm-native-schema.js +8 -0
- package/dist/local-llm-native-schema.js.map +1 -0
- package/dist/local-llm.d.ts +1 -0
- package/dist/local-llm.d.ts.map +1 -1
- package/dist/local-llm.js +4 -3
- package/dist/location/index.js +17 -17
- package/dist/maintenance/memory-governance.js +15 -15
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +15 -15
- package/dist/maintenance/rebuild-memory-projection-runner.js +17 -17
- package/dist/maintenance/rebuild-memory-projection.js +16 -16
- package/dist/memory-browse-operations.js +50 -49
- package/dist/memory-browse.js +3 -3
- package/dist/model-registry.d.ts +11 -0
- package/dist/model-registry.d.ts.map +1 -1
- package/dist/model-registry.js +1 -1
- package/dist/namespaces/migrate.js +16 -16
- package/dist/namespaces/search.js +7 -7
- package/dist/namespaces/storage.js +15 -15
- package/dist/offline-sync-changeset-generations.js +3 -3
- package/dist/offline-sync-embedding-generation.js +2 -2
- package/dist/offline-sync-snapshot-stream.js +5 -5
- package/dist/offline-sync.js +7 -7
- package/dist/operator-doctor-corpus.js +18 -18
- package/dist/operator-toolkit.js +27 -27
- package/dist/orchestration/backlog-scheduler.d.ts +8 -0
- package/dist/orchestration/backlog-scheduler.d.ts.map +1 -1
- package/dist/orchestration/backlog-scheduler.js +118 -106
- package/dist/orchestration/backlog-scheduler.js.map +1 -1
- package/dist/orchestration/buffer-drain-runner.js +106 -105
- package/dist/orchestration/extraction-queue-coordinator.d.ts +6 -0
- package/dist/orchestration/extraction-queue-coordinator.d.ts.map +1 -1
- package/dist/orchestration/maintenance.js +28 -27
- package/dist/orchestrator.js +105 -104
- package/dist/recall-navigation-operations.js +50 -49
- package/dist/recall-navigation.js +49 -48
- package/dist/recall-planner-llm.js +2 -2
- package/dist/recall-state-view-admission.js +3 -3
- package/dist/recall-why-service.js +3 -3
- package/dist/resume-bundles.js +18 -18
- package/dist/search/factory.js +6 -6
- package/dist/search/index.js +11 -11
- package/dist/search/lancedb-backend.js +2 -2
- package/dist/search/meilisearch-backend.js +2 -2
- package/dist/search/orama-backend.js +2 -2
- package/dist/semantic-consolidation.js +16 -16
- package/dist/semantic-rule-promotion.js +15 -15
- package/dist/semantic-rule-verifier.js +15 -15
- package/dist/source-agent-qualifier.js +18 -18
- package/dist/standup/build.js +15 -15
- package/dist/storage/buffer-drain-claims.d.ts.map +1 -1
- package/dist/storage/buffer-drain-claims.js +2 -2
- package/dist/storage/buffer-session-files.js +2 -2
- package/dist/storage.js +14 -14
- package/dist/summarizer.js +7 -6
- package/dist/support-passport/index.js +52 -51
- package/dist/transfer/export-okf.js +15 -15
- package/dist/verified-recall.js +15 -15
- package/dist/who-knows-cli.js +16 -16
- package/dist/who-knows.js +15 -15
- package/package.json +2 -2
- package/src/access-observe-acceptance-boundary.test.ts +24 -18
- package/src/access-observe-helpers.test.ts +72 -0
- package/src/access-observe-helpers.ts +5 -2
- package/src/access-service-observe-lcm-parity.test.ts +9 -2
- package/src/access-service-observe-scope.test.ts +8 -1
- package/src/backlog-scheduler.test.ts +104 -0
- package/src/buffer-record-snapshots.test.ts +195 -0
- package/src/buffer-turn-helpers.test.ts +205 -0
- package/src/buffer-turn-helpers.ts +62 -0
- package/src/buffer.ts +8 -8
- package/src/fallback-llm-codex-subscription.ts +10 -1
- package/src/local-llm-json-schema-fallback.test.ts +315 -0
- package/src/local-llm-native-schema.ts +78 -0
- package/src/local-llm.ts +8 -9
- package/src/model-registry.ts +40 -0
- package/src/orchestration/backlog-scheduler.ts +32 -0
- package/src/orchestration/extraction-queue-coordinator.ts +18 -1
- package/src/orchestrator-extraction-queue.test.ts +142 -0
- package/src/storage/buffer-drain-claims.ts +5 -11
- package/dist/chunk-5MA7ZLPD.js.map +0 -1
- package/dist/chunk-5RW247F5.js.map +0 -1
- package/dist/chunk-DSSTOV5M.js.map +0 -1
- package/dist/chunk-EGKDONTC.js.map +0 -1
- package/dist/chunk-OUBEJWVI.js.map +0 -1
- package/dist/chunk-UKQFCOGT.js.map +0 -1
- package/dist/chunk-VNTQU6KB.js.map +0 -1
- package/dist/chunk-YIJECSIX.js.map +0 -1
- /package/dist/{auto-sync-ANOJDQD4.js.map → auto-sync-XHSS3XPL.js.map} +0 -0
- /package/dist/{chunk-7WFY2L5J.js.map → chunk-233S3MXC.js.map} +0 -0
- /package/dist/{chunk-N7NAGECH.js.map → chunk-36B5VPRU.js.map} +0 -0
- /package/dist/{chunk-5ORJHH43.js.map → chunk-3GGCMRO7.js.map} +0 -0
- /package/dist/{chunk-RZED7FAU.js.map → chunk-3M7YP42P.js.map} +0 -0
- /package/dist/{chunk-ICBUTKLL.js.map → chunk-3MBSD53O.js.map} +0 -0
- /package/dist/{chunk-J72ZY7NU.js.map → chunk-4DLZ2ITE.js.map} +0 -0
- /package/dist/{chunk-WN2DASTS.js.map → chunk-5BE3FLKL.js.map} +0 -0
- /package/dist/{chunk-S73ZVU37.js.map → chunk-5IQL4N37.js.map} +0 -0
- /package/dist/{chunk-CIL4GHMD.js.map → chunk-6Q6AQ36B.js.map} +0 -0
- /package/dist/{chunk-W4V7P5HP.js.map → chunk-6RPPZL7W.js.map} +0 -0
- /package/dist/{chunk-EQ6EMJRG.js.map → chunk-6Y5ANLDH.js.map} +0 -0
- /package/dist/{chunk-YPYSC3TX.js.map → chunk-7FFGWIBN.js.map} +0 -0
- /package/dist/{chunk-5QV6CE6K.js.map → chunk-B36ACJG7.js.map} +0 -0
- /package/dist/{chunk-ZBET3W26.js.map → chunk-BZTA7DR4.js.map} +0 -0
- /package/dist/{chunk-JY4LXMZR.js.map → chunk-C44DRDZM.js.map} +0 -0
- /package/dist/{chunk-UIFWZMO7.js.map → chunk-CLVILSBR.js.map} +0 -0
- /package/dist/{chunk-OGQGDOYK.js.map → chunk-COIQ5N4J.js.map} +0 -0
- /package/dist/{chunk-UAOJVQXC.js.map → chunk-DANFOVQG.js.map} +0 -0
- /package/dist/{chunk-2R44BBPK.js.map → chunk-DEGE32C3.js.map} +0 -0
- /package/dist/{chunk-LHMCZ6VW.js.map → chunk-E22CQZ3H.js.map} +0 -0
- /package/dist/{chunk-JGLZ46JS.js.map → chunk-ELUG6NKQ.js.map} +0 -0
- /package/dist/{chunk-X4DHAXFO.js.map → chunk-F3FNXE7C.js.map} +0 -0
- /package/dist/{chunk-YIXWY4OZ.js.map → chunk-FETPTCQZ.js.map} +0 -0
- /package/dist/{chunk-N2Y6COEM.js.map → chunk-FGUWCE5I.js.map} +0 -0
- /package/dist/{chunk-FDUCIUQ5.js.map → chunk-FJ2VJTGA.js.map} +0 -0
- /package/dist/{chunk-ENPJX3BB.js.map → chunk-FMFCQRDM.js.map} +0 -0
- /package/dist/{chunk-BNU5TQLR.js.map → chunk-FOQ7TW2T.js.map} +0 -0
- /package/dist/{chunk-4PMFSYH7.js.map → chunk-FP2AT4WL.js.map} +0 -0
- /package/dist/{chunk-DLZGSZVC.js.map → chunk-FYQUUIPI.js.map} +0 -0
- /package/dist/{chunk-XTN54NML.js.map → chunk-G3T6YMBO.js.map} +0 -0
- /package/dist/{chunk-MUH7RR6T.js.map → chunk-G5NH3SSX.js.map} +0 -0
- /package/dist/{chunk-DC3DWF2M.js.map → chunk-GCJA5KKT.js.map} +0 -0
- /package/dist/{chunk-U6IL4724.js.map → chunk-GWOFCHPN.js.map} +0 -0
- /package/dist/{chunk-TJ5YGCPV.js.map → chunk-GXVK754R.js.map} +0 -0
- /package/dist/{chunk-FGGLVCHI.js.map → chunk-HB5TNQMM.js.map} +0 -0
- /package/dist/{chunk-GXAZ4Q2S.js.map → chunk-HCFNZWFB.js.map} +0 -0
- /package/dist/{chunk-F4ZHKDBW.js.map → chunk-HLWXCDUQ.js.map} +0 -0
- /package/dist/{chunk-IQXQ3KWR.js.map → chunk-HTDXNIO6.js.map} +0 -0
- /package/dist/{chunk-4RASUAN3.js.map → chunk-HXFIILGF.js.map} +0 -0
- /package/dist/{chunk-S37O4S6E.js.map → chunk-I4LJJ44E.js.map} +0 -0
- /package/dist/{chunk-USX5YIKB.js.map → chunk-IBQ7LGUJ.js.map} +0 -0
- /package/dist/{chunk-VSJ3ARFS.js.map → chunk-IRFQKR4Y.js.map} +0 -0
- /package/dist/{chunk-BCBY5GYZ.js.map → chunk-IVXOYE43.js.map} +0 -0
- /package/dist/{chunk-WXPBDEMW.js.map → chunk-JDQEQE2R.js.map} +0 -0
- /package/dist/{chunk-2WPWEVAH.js.map → chunk-KAED7IBB.js.map} +0 -0
- /package/dist/{chunk-OWZXDBV4.js.map → chunk-KNZDGZSY.js.map} +0 -0
- /package/dist/{chunk-6KBCUIZP.js.map → chunk-L4QYW2HO.js.map} +0 -0
- /package/dist/{chunk-LYOCAUI6.js.map → chunk-LJUQPT5G.js.map} +0 -0
- /package/dist/{chunk-XPZM7GP6.js.map → chunk-MBENRPMY.js.map} +0 -0
- /package/dist/{chunk-VK5HKVQ7.js.map → chunk-N6GEGRCT.js.map} +0 -0
- /package/dist/{chunk-U2A56LLF.js.map → chunk-OBQ2NZAR.js.map} +0 -0
- /package/dist/{chunk-WGRAB3KB.js.map → chunk-ORVPS4ZW.js.map} +0 -0
- /package/dist/{chunk-PFUXPTBT.js.map → chunk-P3AQ2YSX.js.map} +0 -0
- /package/dist/{chunk-DE4U5PTV.js.map → chunk-P4TEQSIZ.js.map} +0 -0
- /package/dist/{chunk-UE5JYPU6.js.map → chunk-P7HNMNN2.js.map} +0 -0
- /package/dist/{chunk-ZG4GNPRE.js.map → chunk-PBE7NFB5.js.map} +0 -0
- /package/dist/{chunk-LN7CWLAU.js.map → chunk-PLGBPFEO.js.map} +0 -0
- /package/dist/{chunk-23BA3USG.js.map → chunk-R24RYSQX.js.map} +0 -0
- /package/dist/{chunk-WYOHQJKC.js.map → chunk-RXGFITWS.js.map} +0 -0
- /package/dist/{chunk-JEX2JL3U.js.map → chunk-SHVLNI4L.js.map} +0 -0
- /package/dist/{chunk-QUPTDKSX.js.map → chunk-SY4AFWUZ.js.map} +0 -0
- /package/dist/{chunk-H2X32F2K.js.map → chunk-SYDPJUFR.js.map} +0 -0
- /package/dist/{chunk-QIOQI7QZ.js.map → chunk-SZBZOUHR.js.map} +0 -0
- /package/dist/{chunk-E3NBMTTX.js.map → chunk-TLTBACYX.js.map} +0 -0
- /package/dist/{chunk-AVVCPA7U.js.map → chunk-UCPH56YX.js.map} +0 -0
- /package/dist/{chunk-ZODKV27J.js.map → chunk-URS56HGW.js.map} +0 -0
- /package/dist/{chunk-PJAMFIDE.js.map → chunk-VEQVXNWR.js.map} +0 -0
- /package/dist/{chunk-AGRMXXVA.js.map → chunk-VEWTHVX2.js.map} +0 -0
- /package/dist/{chunk-WNQ3B3Q5.js.map → chunk-VPEMGBTI.js.map} +0 -0
- /package/dist/{chunk-5JBVPJCT.js.map → chunk-WIAXVBQH.js.map} +0 -0
- /package/dist/{chunk-BTU77RB5.js.map → chunk-X53HJENJ.js.map} +0 -0
- /package/dist/{chunk-KY3KJUNN.js.map → chunk-XC7OYOQC.js.map} +0 -0
- /package/dist/{chunk-43FLJLT2.js.map → chunk-Y5HZFIQO.js.map} +0 -0
- /package/dist/{chunk-DOJBV6WR.js.map → chunk-YK6SFDP2.js.map} +0 -0
- /package/dist/{chunk-QVZZE6VH.js.map → chunk-Z3CKK5RR.js.map} +0 -0
- /package/dist/{chunk-AZNE2H6D.js.map → chunk-ZG57BEUS.js.map} +0 -0
- /package/dist/{chunk-7P5VBRBS.js.map → chunk-ZZSFRWKD.js.map} +0 -0
- /package/dist/{first-start-migration-A6PHIBUQ.js.map → first-start-migration-QVD22WWS.js.map} +0 -0
|
@@ -37,6 +37,24 @@ export interface BufferEntryCounts {
|
|
|
37
37
|
}
|
|
38
38
|
export declare function bufferEntryCounts(state: BufferState): Map<string, BufferEntryCounts>;
|
|
39
39
|
export declare function bufferTurnsEqual(left: BufferTurn | undefined, right: BufferTurn): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Canonical identity key for a turn, injective over `bufferTurnsEqual`
|
|
42
|
+
* equality classes. Every compared field is a primitive (or the #3251 plan
|
|
43
|
+
* identity string), so set-membership replaces pairwise comparison and turn
|
|
44
|
+
* merges run O(n + m) instead of O(n × m). JSON.stringify of a string is
|
|
45
|
+
* injective (it escapes control characters), and the raw `\u0001` sentinels
|
|
46
|
+
* distinguish undefined from null — a distinction `===` makes and plain
|
|
47
|
+
* stringification would lose.
|
|
48
|
+
*/
|
|
49
|
+
export declare function bufferTurnIdentityKey(turn: BufferTurn): string;
|
|
50
|
+
/**
|
|
51
|
+
* Identity-dedupe `incoming` turns into `existing` (same contract as the
|
|
52
|
+
* claim-merge `mergeTurns`): identical turns are dropped — the EXISTING
|
|
53
|
+
* entry is kept — genuinely-new turns append in arrival order, and
|
|
54
|
+
* duplicates within `incoming` collapse to their first occurrence. O(n + m)
|
|
55
|
+
* via `bufferTurnIdentityKey` membership instead of pairwise equality.
|
|
56
|
+
*/
|
|
57
|
+
export declare function mergeBufferTurnsByIdentity(existing: readonly BufferTurn[], incoming: readonly BufferTurn[]): BufferTurn[];
|
|
40
58
|
/** Replace only the processed snapshot; callers without one retain legacy whole-slot semantics. */
|
|
41
59
|
export declare function selectRetainedDeferredTurns(existing: readonly BufferTurn[], turns: BufferTurn[], max: number, originalTurns?: readonly BufferTurn[]): BufferTurn[];
|
|
42
60
|
export declare function hasPinnedCaptureScope(turn: BufferTurn): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buffer-turn-helpers.d.ts","sourceRoot":"","sources":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
bufferTurnsEqual,
|
|
7
8
|
copyBufferTurn,
|
|
8
9
|
describeError,
|
|
@@ -10,17 +11,19 @@ import {
|
|
|
10
11
|
hasPinnedCaptureScope,
|
|
11
12
|
liveTurnsFromExtractionSnapshot,
|
|
12
13
|
matchingQueuedExtractionPrefixLength,
|
|
14
|
+
mergeBufferTurnsByIdentity,
|
|
13
15
|
probeWithTimeout,
|
|
14
16
|
scopeProfilePlanIdentity,
|
|
15
17
|
selectRetainedDeferredTurns,
|
|
16
18
|
subtractBufferTurns
|
|
17
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-4KLQI3L2.js";
|
|
18
20
|
import "./chunk-PZ5AY32C.js";
|
|
19
21
|
export {
|
|
20
22
|
ProbeTimeoutError,
|
|
21
23
|
bufferEntryCounts,
|
|
22
24
|
bufferTurnArrayIsSuffixOfSnapshot,
|
|
23
25
|
bufferTurnArraysEqual,
|
|
26
|
+
bufferTurnIdentityKey,
|
|
24
27
|
bufferTurnsEqual,
|
|
25
28
|
copyBufferTurn,
|
|
26
29
|
describeError,
|
|
@@ -28,6 +31,7 @@ export {
|
|
|
28
31
|
hasPinnedCaptureScope,
|
|
29
32
|
liveTurnsFromExtractionSnapshot,
|
|
30
33
|
matchingQueuedExtractionPrefixLength,
|
|
34
|
+
mergeBufferTurnsByIdentity,
|
|
31
35
|
probeWithTimeout,
|
|
32
36
|
scopeProfilePlanIdentity,
|
|
33
37
|
selectRetainedDeferredTurns,
|
package/dist/buffer.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SmartBuffer
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-T6C3G67T.js";
|
|
4
4
|
import "./chunk-MPDLLLOG.js";
|
|
5
5
|
import "./chunk-H3FZVNRN.js";
|
|
6
6
|
import "./chunk-KASJJGRG.js";
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-
|
|
7
|
+
import "./chunk-P4TEQSIZ.js";
|
|
8
|
+
import "./chunk-Y5HZFIQO.js";
|
|
9
9
|
import "./chunk-CSAKJVXW.js";
|
|
10
10
|
import "./chunk-K2XUWZBM.js";
|
|
11
11
|
import "./chunk-OD4FM2U7.js";
|
|
@@ -19,7 +19,7 @@ import "./chunk-IUM3VSHI.js";
|
|
|
19
19
|
import "./chunk-C64XATK7.js";
|
|
20
20
|
import "./chunk-42JKGUFJ.js";
|
|
21
21
|
import "./chunk-23G5P7TA.js";
|
|
22
|
-
import "./chunk-
|
|
22
|
+
import "./chunk-4KLQI3L2.js";
|
|
23
23
|
import "./chunk-TBBDFYXW.js";
|
|
24
24
|
import "./chunk-2D7BTSDW.js";
|
|
25
25
|
import "./chunk-353C5UNV.js";
|
package/dist/calibration.js
CHANGED
|
@@ -4,18 +4,19 @@ import {
|
|
|
4
4
|
import "./chunk-QW27DOHG.js";
|
|
5
5
|
import {
|
|
6
6
|
LocalLlmClient
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-AY2UK5XK.js";
|
|
8
|
+
import "./chunk-QEDLJDHP.js";
|
|
8
9
|
import "./chunk-U4LUIE6Y.js";
|
|
9
10
|
import "./chunk-T6OZW2WR.js";
|
|
10
11
|
import "./chunk-5YQXWVCP.js";
|
|
11
|
-
import "./chunk-
|
|
12
|
+
import "./chunk-MJFL75J6.js";
|
|
12
13
|
import {
|
|
13
14
|
FallbackLlmClient
|
|
14
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-UCPH56YX.js";
|
|
15
16
|
import "./chunk-I55KAVET.js";
|
|
16
17
|
import "./chunk-L2EXJQJP.js";
|
|
17
18
|
import "./chunk-45GF7Y3V.js";
|
|
18
|
-
import "./chunk-
|
|
19
|
+
import "./chunk-DJDJBMFX.js";
|
|
19
20
|
import "./chunk-E2AWJ7KQ.js";
|
|
20
21
|
import "./chunk-TOTT6S2V.js";
|
|
21
22
|
import "./chunk-YBA52OKG.js";
|
package/dist/calibration.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/calibration.ts"],"sourcesContent":["/**\n * calibration.ts — Prediction-Error-Driven Model-User Calibration\n *\n * Analyzes patterns in user corrections to identify systematic miscalibration\n * between the model's predictions and the user's actual expectations.\n * During consolidation, replays chains of similar corrections through an LLM\n * to synthesize CalibrationRules that adjust model behavior for this specific user.\n *\n * Inspired by:\n * - Cerebellar motor calibration (prediction errors drive lasting adjustments)\n * - Temporal difference learning (dopamine signals prediction error)\n * - Tesla FSD shadow mode (divergence between prediction and reality = training signal)\n */\n\nimport { createHash } from \"node:crypto\";\nimport { mkdir, readFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { resolveLocalLlmCapabilities } from \"./capabilities.js\";\nimport { OUTPUT_LANGUAGE_POLICY } from \"./extraction-prompt.js\";\nimport { FallbackLlmClient } from \"./fallback-llm.js\";\nimport { listJsonFiles } from \"./json-store.js\";\nimport { isMacOsReplicationJunkBasename } from \"./utils/macos-replication-junk.js\";\nimport { LocalLlmClient } from \"./local-llm.js\";\nimport { log } from \"./logger.js\";\nimport { writeFileAtomically } from \"./maintenance/atomic-file.js\";\nimport type { AgentPersonaModelConfig, GatewayConfig, PluginConfig } from \"./types.js\";\n\n// ─── Types ───────────────────────────────────────────────────────────────────\n\nexport interface CalibrationRule {\n id: string;\n ruleType: \"model_tendency\" | \"user_expectation\" | \"scope_boundary\" | \"verification_required\";\n condition: string;\n modelTendency: string;\n userExpectation: string;\n calibration: string;\n confidence: number;\n evidenceCount: number;\n evidenceCorrectionIds: string[];\n createdAt: string;\n lastReinforcedAt: string;\n}\n\nexport interface CalibrationIndex {\n rules: CalibrationRule[];\n updatedAt: string;\n totalCorrectionsAnalyzed: number;\n /**\n * Weeks whose rule reinforcement is already committed. A retry of any of\n * these weeks must not increment `evidenceCount` again. Older indexes\n * persisted a single `appliedWeekId`; reads fold it into this list.\n */\n appliedWeekIds?: string[];\n}\n\n// ─── Storage ─────────────────────────────────────────────────────────────────\n\nfunction calibrationDir(memoryDir: string): string {\n return path.join(memoryDir, \"state\", \"calibration\");\n}\n\nfunction calibrationIndexPath(memoryDir: string): string {\n return path.join(calibrationDir(memoryDir), \"calibration-index.json\");\n}\n\n/** Week ids are short (`YYYY-Www`). Longer values are not used as stamps. */\nconst MAX_APPLIED_WEEK_ID_LENGTH = 32;\n\nexport function appliedCalibrationWeekId(value: unknown): string | undefined {\n if (typeof value !== \"string\") return undefined;\n const trimmed = value.trim();\n if (trimmed.length === 0 || trimmed.length > MAX_APPLIED_WEEK_ID_LENGTH) return undefined;\n return trimmed;\n}\n\nexport async function readCalibrationIndex(memoryDir: string): Promise<CalibrationIndex> {\n try {\n const raw = JSON.parse(await readFile(calibrationIndexPath(memoryDir), \"utf8\"));\n const appliedWeekIds = normalizeAppliedWeekIds(raw.appliedWeekIds, raw.appliedWeekId);\n return {\n rules: Array.isArray(raw.rules) ? raw.rules : [],\n updatedAt: typeof raw.updatedAt === \"string\" ? raw.updatedAt : new Date().toISOString(),\n totalCorrectionsAnalyzed: typeof raw.totalCorrectionsAnalyzed === \"number\" ? raw.totalCorrectionsAnalyzed : 0,\n ...(appliedWeekIds.length > 0 ? { appliedWeekIds } : {}),\n };\n } catch {\n return { rules: [], updatedAt: new Date().toISOString(), totalCorrectionsAnalyzed: 0 };\n }\n}\n\nfunction normalizeAppliedWeekIds(list: unknown, additional: unknown): string[] {\n const weeks: string[] = [];\n if (Array.isArray(list)) {\n for (const entry of list) {\n const week = appliedCalibrationWeekId(entry);\n if (week && !weeks.includes(week)) weeks.push(week);\n }\n }\n const extra = appliedCalibrationWeekId(additional);\n if (extra && !weeks.includes(extra)) weeks.push(extra);\n return weeks;\n}\n\n/**\n * Attach the week stamp to the index that will be written with the reinforced\n * rules. The stamp and the evidence increment commit together. Every\n * previously applied week stays in the list so an out-of-order retry of an\n * older week is still recognized as already applied.\n */\nexport function withAppliedCalibrationWeek(\n index: CalibrationIndex,\n idempotencyKey: string | undefined,\n): CalibrationIndex {\n const appliedWeekIds = normalizeAppliedWeekIds(index.appliedWeekIds, idempotencyKey);\n return {\n rules: index.rules,\n updatedAt: index.updatedAt,\n totalCorrectionsAnalyzed: index.totalCorrectionsAnalyzed,\n ...(appliedWeekIds.length > 0 ? { appliedWeekIds } : {}),\n };\n}\n\nasync function writeCalibrationIndex(memoryDir: string, index: CalibrationIndex): Promise<void> {\n const dir = calibrationDir(memoryDir);\n await mkdir(dir, { recursive: true });\n const appliedWeekIds = normalizeAppliedWeekIds(index.appliedWeekIds, undefined);\n const stamped: CalibrationIndex = {\n rules: index.rules,\n updatedAt: new Date().toISOString(),\n totalCorrectionsAnalyzed: index.totalCorrectionsAnalyzed,\n ...(appliedWeekIds.length > 0 ? { appliedWeekIds } : {}),\n };\n await writeFileAtomically(calibrationIndexPath(memoryDir), JSON.stringify(stamped, null, 2));\n}\n\n// ─── Correction Reading ──────────────────────────────────────────────────────\n\nexport interface CorrectionMemory {\n id: string;\n content: string;\n created: string;\n confidence: number;\n entityRefs: string[];\n tags: string[];\n}\n\nconst CALIBRATION_RULE_TYPES = new Set([\n \"model_tendency\",\n \"user_expectation\",\n \"scope_boundary\",\n \"verification_required\",\n]);\n\nfunction parseConfidence(value: unknown): number | undefined {\n if (typeof value !== \"number\" || !Number.isFinite(value)) return undefined;\n return Math.max(0, Math.min(1, value));\n}\n\nfunction parseEvidenceIds(value: unknown): string[] {\n if (!Array.isArray(value)) return [];\n return value.filter((item): item is string => typeof item === \"string\" && item.trim().length > 0);\n}\n\nfunction nonEmptyString(value: unknown): string | undefined {\n if (typeof value !== \"string\") return undefined;\n const trimmed = value.trim();\n return trimmed.length > 0 ? trimmed : undefined;\n}\n\n/**\n * Exported for entity-contamination R-11 regression coverage (#682\n * PR 2/3 — codex review). Tests can drive the real correction-reading\n * path instead of duplicating the regex inline, so calibration parser\n * regressions surface via the contamination suite.\n */\nexport async function readCalibrationCorrections(memoryDir: string): Promise<CorrectionMemory[]> {\n return readCorrectionsImpl(memoryDir);\n}\n\nasync function readCorrections(memoryDir: string): Promise<CorrectionMemory[]> {\n return readCorrectionsImpl(memoryDir);\n}\n\nasync function readCorrectionsImpl(memoryDir: string): Promise<CorrectionMemory[]> {\n const correctionsDir = path.join(memoryDir, \"corrections\");\n const files = await listJsonFiles(correctionsDir).catch(() => {\n // Corrections might be in facts/ directories too\n return [] as string[];\n });\n\n // Also scan facts directories for correction-category files\n const factsDir = path.join(memoryDir, \"facts\");\n try {\n const { readdir } = await import(\"node:fs/promises\");\n const dayDirs = (await readdir(factsDir)).filter((d: string) => /^\\d{4}-\\d{2}-\\d{2}$/.test(d));\n for (const day of dayDirs) {\n const dayPath = path.join(factsDir, day);\n const dayFiles = (await readdir(dayPath))\n .filter((f: string) => !isMacOsReplicationJunkBasename(f) && f.startsWith(\"correction-\") && f.endsWith(\".md\"))\n .map((f: string) => path.join(dayPath, f));\n files.push(...dayFiles);\n }\n } catch {\n // facts dir might not exist\n }\n\n // Also check the dedicated corrections directory\n try {\n const { readdir } = await import(\"node:fs/promises\");\n const corrFiles = (await readdir(correctionsDir))\n .filter((f: string) => !isMacOsReplicationJunkBasename(f) && f.endsWith(\".md\"))\n .map((f: string) => path.join(correctionsDir, f));\n files.push(...corrFiles);\n } catch {\n // corrections dir might not exist\n }\n\n const corrections: CorrectionMemory[] = [];\n const seen = new Set<string>();\n\n for (const filePath of files) {\n try {\n const raw = await readFile(filePath, \"utf8\");\n\n // Parse frontmatter\n const fmMatch = raw.match(/^---\\n([\\s\\S]*?)\\n---\\n([\\s\\S]*)$/);\n if (!fmMatch) continue;\n\n const content = fmMatch[2].trim();\n if (!content || content.length < 10) continue;\n\n // Extract id from frontmatter\n const idMatch = fmMatch[1].match(/^id:\\s*(.+)$/m);\n const id = idMatch?.[1]?.trim() ?? path.basename(filePath, \".md\");\n\n if (seen.has(id)) continue;\n seen.add(id);\n\n const confMatch = fmMatch[1].match(/^confidence:\\s*(.+)$/m);\n const confidence = confMatch ? parseFloat(confMatch[1]) : 0.9;\n\n const entityMatch = fmMatch[1].match(/^entityRef:\\s*(.+)$/m);\n const entityRefs = entityMatch ? [entityMatch[1].trim()] : [];\n\n corrections.push({ id, content, created: \"\", confidence, entityRefs, tags: [] });\n } catch {\n // skip unparseable files\n }\n }\n\n return corrections;\n}\n\n// ─── LLM-Assisted Clustering and Replay ──────────────────────────────────────\n\nexport const CLUSTER_PROMPT = `You are analyzing user corrections to an AI assistant. Each correction represents a moment where the assistant's prediction of what the user wanted was WRONG.\n\nYour job: Group these corrections into clusters where the SAME TYPE of misunderstanding is happening. Then for each cluster, synthesize a CalibrationRule.\n\nA CalibrationRule describes:\n- condition: When does this type of mistake happen?\n- modelTendency: What does the model tend to assume or do wrong?\n- userExpectation: What does the user actually want instead?\n- calibration: How should the model adjust its behavior?\n- ruleType: One of \"model_tendency\", \"user_expectation\", \"scope_boundary\", \"verification_required\"\n\nFocus on PATTERNS, not individual corrections. A cluster needs at least 2 corrections to be worth a rule.\n${OUTPUT_LANGUAGE_POLICY}\n\nOutput valid JSON only:\n{\n \"rules\": [\n {\n \"ruleType\": \"model_tendency\",\n \"condition\": \"When discussing project scope or task boundaries\",\n \"modelTendency\": \"The model tends to assume broader scope than the user intends\",\n \"userExpectation\": \"The user prefers narrow, specific task definitions and wants to be asked before scope expansion\",\n \"calibration\": \"When uncertain about scope, ask for clarification rather than assuming. Default to the narrower interpretation.\",\n \"confidence\": 0.85,\n \"evidenceIds\": [\"correction-id-1\", \"correction-id-2\"]\n }\n ]\n}`;\n\ninterface CalibrationChatClient {\n chatCompletion(\n messages: Array<{ role: \"system\" | \"user\" | \"assistant\"; content: string }>,\n options?: {\n temperature?: number;\n maxTokens?: number;\n agentId?: string;\n modelChain?: AgentPersonaModelConfig;\n }\n ): Promise<{ content?: string | null } | null>;\n}\n\ninterface CalibrationLlmOptions {\n gatewayConfig?: GatewayConfig;\n gatewayAgentId?: string;\n modelChain?: AgentPersonaModelConfig;\n workspaceDir?: string;\n /** Plugin config. Supplies `localLlm*` settings when the gateway chain is empty. */\n pluginConfig?: PluginConfig;\n}\n\nfunction resolveCalibrationChatClient(options: CalibrationLlmOptions): CalibrationChatClient | null {\n const gateway = new FallbackLlmClient(options.gatewayConfig, {\n workspaceDir: options.workspaceDir,\n });\n if (gateway.isAvailable({ agentId: options.gatewayAgentId, modelChain: options.modelChain })) {\n return gateway;\n }\n const pluginConfig = options.pluginConfig;\n if (pluginConfig && resolveLocalLlmCapabilities(pluginConfig).localLlm) {\n log.info(`[calibration] using configured local LLM (model=${pluginConfig.localLlmModel})`);\n const local = new LocalLlmClient(pluginConfig);\n return {\n chatCompletion(messages, chatOptions) {\n return local.chatCompletion(messages, {\n temperature: chatOptions?.temperature,\n maxTokens: chatOptions?.maxTokens,\n });\n },\n };\n }\n log.warn(\"[calibration] no LLM available — skipping consolidation\");\n return null;\n}\n\nexport async function synthesizeCalibrationRules(\n corrections: CorrectionMemory[],\n llm: CalibrationChatClient,\n existingRules: CalibrationRule[],\n agentId?: string,\n modelChain?: AgentPersonaModelConfig\n): Promise<CalibrationRule[]> {\n if (corrections.length < 2) return [];\n\n // Format corrections for the LLM\n const correctionText = corrections\n .slice(0, 50) // limit to avoid huge prompts\n .map((c, i) => `[${c.id}] ${c.content}`)\n .join(\"\\n\\n\");\n\n const existingRulesText =\n existingRules.length > 0\n ? `\\n\\nExisting calibration rules (avoid duplicating these):\\n${existingRules.map((r) => `- ${r.condition}: ${r.calibration}`).join(\"\\n\")}`\n : \"\";\n\n const response = await llm.chatCompletion(\n [\n { role: \"system\", content: CLUSTER_PROMPT },\n {\n role: \"user\",\n content: `Here are ${corrections.length} corrections from this user:\\n\\n${correctionText}${existingRulesText}`,\n },\n ],\n { temperature: 0.3, maxTokens: 3000, agentId, modelChain }\n );\n\n if (!response?.content) return [];\n\n try {\n let jsonStr = response.content.trim();\n const fenceMatch = jsonStr.match(/```(?:json)?\\s*\\n?([\\s\\S]*?)\\n?\\s*```/);\n if (fenceMatch) jsonStr = fenceMatch[1];\n\n const parsed = JSON.parse(jsonStr);\n if (!Array.isArray(parsed.rules)) return [];\n\n const now = new Date().toISOString();\n const rawRules: unknown[] = Array.isArray(parsed.rules) ? parsed.rules : [];\n return rawRules\n .map((r: unknown): CalibrationRule | undefined => {\n if (!r || typeof r !== \"object\" || Array.isArray(r)) return undefined;\n const raw = r as Record<string, unknown>;\n const ruleType = nonEmptyString(raw.ruleType);\n const condition = nonEmptyString(raw.condition);\n const modelTendency = nonEmptyString(raw.modelTendency);\n const calibration = nonEmptyString(raw.calibration);\n const confidence = parseConfidence(raw.confidence);\n if (\n !ruleType ||\n !CALIBRATION_RULE_TYPES.has(ruleType) ||\n !condition ||\n !modelTendency ||\n !calibration ||\n confidence === undefined\n ) {\n return undefined;\n }\n const evidenceCorrectionIds = parseEvidenceIds(raw.evidenceIds);\n return {\n id: `cal-${createHash(\"sha256\")\n .update(condition + calibration)\n .digest(\"hex\")\n .slice(0, 12)}`,\n ruleType: ruleType as CalibrationRule[\"ruleType\"],\n condition,\n modelTendency,\n userExpectation: nonEmptyString(raw.userExpectation) ?? \"\",\n calibration,\n confidence,\n evidenceCount: evidenceCorrectionIds.length,\n evidenceCorrectionIds,\n createdAt: now,\n lastReinforcedAt: now,\n };\n })\n .filter((rule): rule is CalibrationRule => !!rule);\n } catch {\n log.warn(\"[calibration] failed to parse LLM response\");\n return [];\n }\n}\n\n// ─── Recall Section ──────────────────────────────────────────────────────────\n\n/**\n * Build a recall section from calibration rules relevant to the current query.\n * Uses the LLM to select which rules apply to the current context.\n */\nexport function buildCalibrationRecallSection(\n rules: CalibrationRule[],\n query: string,\n maxChars: number = 1200,\n): string | null {\n if (rules.length === 0) return null;\n\n // Simple relevance: include all rules (they're already filtered to this user)\n // In production, could use embedding similarity to filter\n const lines: string[] = [\n \"## Model Calibration (learned from past corrections)\",\n \"\",\n \"Adjustments for this specific user, learned from patterns in their corrections:\",\n \"\",\n ];\n\n let totalChars = lines.join(\"\\n\").length;\n\n for (const rule of rules) {\n const line = `- **${rule.condition}**: ${rule.modelTendency} → Instead: ${rule.calibration}`;\n if (totalChars + line.length + 1 > maxChars) break;\n lines.push(line);\n totalChars += line.length + 1;\n }\n\n if (lines.length <= 4) return null;\n lines.push(\"\");\n return lines.join(\"\\n\");\n}\n\n// ─── Public API ──────────────────────────────────────────────────────────────\n\n/**\n * Options weekly compounding passes into calibration. Gateway agent and task\n * chain fields stay limited to `modelSource: \"gateway\"`. `pluginConfig` carries\n * the `localLlm*` settings used when that chain is empty.\n */\nexport function calibrationConsolidationInput(config: PluginConfig): {\n memoryDir: string;\n gatewayConfig?: GatewayConfig;\n gatewayAgentId?: string;\n modelChain?: AgentPersonaModelConfig;\n workspaceDir?: string;\n pluginConfig: PluginConfig;\n} {\n const gateway = config.modelSource === \"gateway\";\n return {\n memoryDir: config.memoryDir,\n gatewayConfig: config.gatewayConfig,\n gatewayAgentId: gateway ? (config.gatewayAgentId || undefined) : undefined,\n modelChain: gateway ? config.taskModelChain : undefined,\n workspaceDir: config.workspaceDir,\n pluginConfig: config,\n };\n}\n\n/**\n * Run the full calibration pipeline:\n * 1. Read all corrections\n * 2. Send to LLM for clustering and rule synthesis\n * 3. Merge with existing rules\n * 4. Write updated index\n */\nexport async function runCalibrationConsolidation(options: {\n memoryDir: string;\n gatewayConfig?: GatewayConfig;\n gatewayAgentId?: string;\n modelChain?: AgentPersonaModelConfig;\n workspaceDir?: string;\n pluginConfig?: PluginConfig;\n /**\n * When set, a week whose reinforcement is already in the index is returned\n * as-is. Weekly synthesis passes the ISO week id so a retry after a later\n * artifact failure does not count the same corrections twice.\n */\n idempotencyKey?: string;\n}): Promise<CalibrationRule[]> {\n try {\n const idempotencyKey = appliedCalibrationWeekId(options.idempotencyKey);\n const existingIndex = await readCalibrationIndex(options.memoryDir);\n if (idempotencyKey && (existingIndex.appliedWeekIds ?? []).includes(idempotencyKey)) {\n log.debug(`[calibration] week ${idempotencyKey} already applied — skipping`);\n return existingIndex.rules;\n }\n\n const llm = resolveCalibrationChatClient(options);\n if (!llm) return [];\n\n const corrections = await readCorrections(options.memoryDir);\n if (corrections.length < 3) {\n log.info(`[calibration] only ${corrections.length} corrections — need at least 3`);\n return [];\n }\n\n const newRules = await synthesizeCalibrationRules(\n corrections,\n llm,\n existingIndex.rules,\n options.gatewayAgentId,\n options.modelChain\n );\n if (newRules.length === 0) {\n log.info(\"[calibration] no new calibration rules synthesized\");\n return existingIndex.rules;\n }\n\n // Merge: keep existing rules, add new ones (deduplicate by id)\n const ruleMap = new Map(existingIndex.rules.map((r) => [r.id, r]));\n for (const rule of newRules) {\n if (ruleMap.has(rule.id)) {\n // Reinforce existing rule\n const existing = ruleMap.get(rule.id)!;\n existing.lastReinforcedAt = new Date().toISOString();\n existing.evidenceCount += rule.evidenceCount;\n existing.confidence = Math.min(1, existing.confidence + 0.05);\n } else {\n ruleMap.set(rule.id, rule);\n }\n }\n\n const allRules = [...ruleMap.values()];\n await writeCalibrationIndex(options.memoryDir, withAppliedCalibrationWeek({\n rules: allRules,\n updatedAt: existingIndex.updatedAt,\n totalCorrectionsAnalyzed: corrections.length,\n appliedWeekIds: existingIndex.appliedWeekIds,\n }, idempotencyKey));\n\n log.debug(`[calibration] synthesized ${newRules.length} new rule(s), ${allRules.length} total`);\n return allRules;\n } catch (error) {\n log.warn(\n `[calibration] consolidation failed (non-fatal): ${error instanceof Error ? error.message : String(error)}`\n );\n return [];\n }\n}\n\n/**\n * Standalone entry point for calibration consolidation that can be called\n * independently of weekly compounding. The compounding engine's\n * `synthesizeWeekly()` is one trigger, but orchestrators or periodic\n * maintenance jobs should call this directly so calibration is not gated\n * on weekly compounding being enabled.\n */\nexport async function runCalibrationIfEnabled(options: {\n memoryDir: string;\n calibrationEnabled: boolean;\n gatewayConfig?: GatewayConfig;\n gatewayAgentId?: string;\n modelChain?: AgentPersonaModelConfig;\n workspaceDir?: string;\n pluginConfig?: PluginConfig;\n}): Promise<CalibrationRule[]> {\n if (!options.calibrationEnabled) {\n return [];\n }\n return runCalibrationConsolidation({\n memoryDir: options.memoryDir,\n gatewayConfig: options.gatewayConfig,\n gatewayAgentId: options.gatewayAgentId,\n modelChain: options.modelChain,\n workspaceDir: options.workspaceDir,\n pluginConfig: options.pluginConfig,\n });\n}\n\n/**\n * Get calibration rules for recall injection.\n * Reads the pre-computed calibration index.\n */\nexport async function getCalibrationRulesForRecall(\n memoryDir: string,\n): Promise<CalibrationRule[]> {\n const index = await readCalibrationIndex(memoryDir);\n return index.rules;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,SAAS,kBAAkB;AAC3B,SAAS,OAAO,gBAAgB;AAChC,OAAO,UAAU;AAyCjB,SAAS,eAAe,WAA2B;AACjD,SAAO,KAAK,KAAK,WAAW,SAAS,aAAa;AACpD;AAEA,SAAS,qBAAqB,WAA2B;AACvD,SAAO,KAAK,KAAK,eAAe,SAAS,GAAG,wBAAwB;AACtE;AAGA,IAAM,6BAA6B;AAE5B,SAAS,yBAAyB,OAAoC;AAC3E,MAAI,OAAO,UAAU,SAAU,QAAO;AACtC,QAAM,UAAU,MAAM,KAAK;AAC3B,MAAI,QAAQ,WAAW,KAAK,QAAQ,SAAS,2BAA4B,QAAO;AAChF,SAAO;AACT;AAEA,eAAsB,qBAAqB,WAA8C;AACvF,MAAI;AACF,UAAM,MAAM,KAAK,MAAM,MAAM,SAAS,qBAAqB,SAAS,GAAG,MAAM,CAAC;AAC9E,UAAM,iBAAiB,wBAAwB,IAAI,gBAAgB,IAAI,aAAa;AACpF,WAAO;AAAA,MACL,OAAO,MAAM,QAAQ,IAAI,KAAK,IAAI,IAAI,QAAQ,CAAC;AAAA,MAC/C,WAAW,OAAO,IAAI,cAAc,WAAW,IAAI,aAAY,oBAAI,KAAK,GAAE,YAAY;AAAA,MACtF,0BAA0B,OAAO,IAAI,6BAA6B,WAAW,IAAI,2BAA2B;AAAA,MAC5G,GAAI,eAAe,SAAS,IAAI,EAAE,eAAe,IAAI,CAAC;AAAA,IACxD;AAAA,EACF,QAAQ;AACN,WAAO,EAAE,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,MAAM,UAAU,OAAO,KAAK,CAAC;AAAA,IAC3G;AACA,WAAO,CAAC;AAAA,EACV;AACF;AASA,eAAsB,wBAAwB,SAQf;AAC7B,MAAI,CAAC,QAAQ,oBAAoB;AAC/B,WAAO,CAAC;AAAA,EACV;AACA,SAAO,4BAA4B;AAAA,IACjC,WAAW,QAAQ;AAAA,IACnB,eAAe,QAAQ;AAAA,IACvB,gBAAgB,QAAQ;AAAA,IACxB,YAAY,QAAQ;AAAA,IACpB,cAAc,QAAQ;AAAA,IACtB,cAAc,QAAQ;AAAA,EACxB,CAAC;AACH;AAMA,eAAsB,6BACpB,WAC4B;AAC5B,QAAM,QAAQ,MAAM,qBAAqB,SAAS;AAClD,SAAO,MAAM;AACf;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/calibration.ts"],"sourcesContent":["/**\n * calibration.ts — Prediction-Error-Driven Model-User Calibration\n *\n * Analyzes patterns in user corrections to identify systematic miscalibration\n * between the model's predictions and the user's actual expectations.\n * During consolidation, replays chains of similar corrections through an LLM\n * to synthesize CalibrationRules that adjust model behavior for this specific user.\n *\n * Inspired by:\n * - Cerebellar motor calibration (prediction errors drive lasting adjustments)\n * - Temporal difference learning (dopamine signals prediction error)\n * - Tesla FSD shadow mode (divergence between prediction and reality = training signal)\n */\n\nimport { createHash } from \"node:crypto\";\nimport { mkdir, readFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { resolveLocalLlmCapabilities } from \"./capabilities.js\";\nimport { OUTPUT_LANGUAGE_POLICY } from \"./extraction-prompt.js\";\nimport { FallbackLlmClient } from \"./fallback-llm.js\";\nimport { listJsonFiles } from \"./json-store.js\";\nimport { isMacOsReplicationJunkBasename } from \"./utils/macos-replication-junk.js\";\nimport { LocalLlmClient } from \"./local-llm.js\";\nimport { log } from \"./logger.js\";\nimport { writeFileAtomically } from \"./maintenance/atomic-file.js\";\nimport type { AgentPersonaModelConfig, GatewayConfig, PluginConfig } from \"./types.js\";\n\n// ─── Types ───────────────────────────────────────────────────────────────────\n\nexport interface CalibrationRule {\n id: string;\n ruleType: \"model_tendency\" | \"user_expectation\" | \"scope_boundary\" | \"verification_required\";\n condition: string;\n modelTendency: string;\n userExpectation: string;\n calibration: string;\n confidence: number;\n evidenceCount: number;\n evidenceCorrectionIds: string[];\n createdAt: string;\n lastReinforcedAt: string;\n}\n\nexport interface CalibrationIndex {\n rules: CalibrationRule[];\n updatedAt: string;\n totalCorrectionsAnalyzed: number;\n /**\n * Weeks whose rule reinforcement is already committed. A retry of any of\n * these weeks must not increment `evidenceCount` again. Older indexes\n * persisted a single `appliedWeekId`; reads fold it into this list.\n */\n appliedWeekIds?: string[];\n}\n\n// ─── Storage ─────────────────────────────────────────────────────────────────\n\nfunction calibrationDir(memoryDir: string): string {\n return path.join(memoryDir, \"state\", \"calibration\");\n}\n\nfunction calibrationIndexPath(memoryDir: string): string {\n return path.join(calibrationDir(memoryDir), \"calibration-index.json\");\n}\n\n/** Week ids are short (`YYYY-Www`). Longer values are not used as stamps. */\nconst MAX_APPLIED_WEEK_ID_LENGTH = 32;\n\nexport function appliedCalibrationWeekId(value: unknown): string | undefined {\n if (typeof value !== \"string\") return undefined;\n const trimmed = value.trim();\n if (trimmed.length === 0 || trimmed.length > MAX_APPLIED_WEEK_ID_LENGTH) return undefined;\n return trimmed;\n}\n\nexport async function readCalibrationIndex(memoryDir: string): Promise<CalibrationIndex> {\n try {\n const raw = JSON.parse(await readFile(calibrationIndexPath(memoryDir), \"utf8\"));\n const appliedWeekIds = normalizeAppliedWeekIds(raw.appliedWeekIds, raw.appliedWeekId);\n return {\n rules: Array.isArray(raw.rules) ? raw.rules : [],\n updatedAt: typeof raw.updatedAt === \"string\" ? raw.updatedAt : new Date().toISOString(),\n totalCorrectionsAnalyzed: typeof raw.totalCorrectionsAnalyzed === \"number\" ? raw.totalCorrectionsAnalyzed : 0,\n ...(appliedWeekIds.length > 0 ? { appliedWeekIds } : {}),\n };\n } catch {\n return { rules: [], updatedAt: new Date().toISOString(), totalCorrectionsAnalyzed: 0 };\n }\n}\n\nfunction normalizeAppliedWeekIds(list: unknown, additional: unknown): string[] {\n const weeks: string[] = [];\n if (Array.isArray(list)) {\n for (const entry of list) {\n const week = appliedCalibrationWeekId(entry);\n if (week && !weeks.includes(week)) weeks.push(week);\n }\n }\n const extra = appliedCalibrationWeekId(additional);\n if (extra && !weeks.includes(extra)) weeks.push(extra);\n return weeks;\n}\n\n/**\n * Attach the week stamp to the index that will be written with the reinforced\n * rules. The stamp and the evidence increment commit together. Every\n * previously applied week stays in the list so an out-of-order retry of an\n * older week is still recognized as already applied.\n */\nexport function withAppliedCalibrationWeek(\n index: CalibrationIndex,\n idempotencyKey: string | undefined,\n): CalibrationIndex {\n const appliedWeekIds = normalizeAppliedWeekIds(index.appliedWeekIds, idempotencyKey);\n return {\n rules: index.rules,\n updatedAt: index.updatedAt,\n totalCorrectionsAnalyzed: index.totalCorrectionsAnalyzed,\n ...(appliedWeekIds.length > 0 ? { appliedWeekIds } : {}),\n };\n}\n\nasync function writeCalibrationIndex(memoryDir: string, index: CalibrationIndex): Promise<void> {\n const dir = calibrationDir(memoryDir);\n await mkdir(dir, { recursive: true });\n const appliedWeekIds = normalizeAppliedWeekIds(index.appliedWeekIds, undefined);\n const stamped: CalibrationIndex = {\n rules: index.rules,\n updatedAt: new Date().toISOString(),\n totalCorrectionsAnalyzed: index.totalCorrectionsAnalyzed,\n ...(appliedWeekIds.length > 0 ? { appliedWeekIds } : {}),\n };\n await writeFileAtomically(calibrationIndexPath(memoryDir), JSON.stringify(stamped, null, 2));\n}\n\n// ─── Correction Reading ──────────────────────────────────────────────────────\n\nexport interface CorrectionMemory {\n id: string;\n content: string;\n created: string;\n confidence: number;\n entityRefs: string[];\n tags: string[];\n}\n\nconst CALIBRATION_RULE_TYPES = new Set([\n \"model_tendency\",\n \"user_expectation\",\n \"scope_boundary\",\n \"verification_required\",\n]);\n\nfunction parseConfidence(value: unknown): number | undefined {\n if (typeof value !== \"number\" || !Number.isFinite(value)) return undefined;\n return Math.max(0, Math.min(1, value));\n}\n\nfunction parseEvidenceIds(value: unknown): string[] {\n if (!Array.isArray(value)) return [];\n return value.filter((item): item is string => typeof item === \"string\" && item.trim().length > 0);\n}\n\nfunction nonEmptyString(value: unknown): string | undefined {\n if (typeof value !== \"string\") return undefined;\n const trimmed = value.trim();\n return trimmed.length > 0 ? trimmed : undefined;\n}\n\n/**\n * Exported for entity-contamination R-11 regression coverage (#682\n * PR 2/3 — codex review). Tests can drive the real correction-reading\n * path instead of duplicating the regex inline, so calibration parser\n * regressions surface via the contamination suite.\n */\nexport async function readCalibrationCorrections(memoryDir: string): Promise<CorrectionMemory[]> {\n return readCorrectionsImpl(memoryDir);\n}\n\nasync function readCorrections(memoryDir: string): Promise<CorrectionMemory[]> {\n return readCorrectionsImpl(memoryDir);\n}\n\nasync function readCorrectionsImpl(memoryDir: string): Promise<CorrectionMemory[]> {\n const correctionsDir = path.join(memoryDir, \"corrections\");\n const files = await listJsonFiles(correctionsDir).catch(() => {\n // Corrections might be in facts/ directories too\n return [] as string[];\n });\n\n // Also scan facts directories for correction-category files\n const factsDir = path.join(memoryDir, \"facts\");\n try {\n const { readdir } = await import(\"node:fs/promises\");\n const dayDirs = (await readdir(factsDir)).filter((d: string) => /^\\d{4}-\\d{2}-\\d{2}$/.test(d));\n for (const day of dayDirs) {\n const dayPath = path.join(factsDir, day);\n const dayFiles = (await readdir(dayPath))\n .filter((f: string) => !isMacOsReplicationJunkBasename(f) && f.startsWith(\"correction-\") && f.endsWith(\".md\"))\n .map((f: string) => path.join(dayPath, f));\n files.push(...dayFiles);\n }\n } catch {\n // facts dir might not exist\n }\n\n // Also check the dedicated corrections directory\n try {\n const { readdir } = await import(\"node:fs/promises\");\n const corrFiles = (await readdir(correctionsDir))\n .filter((f: string) => !isMacOsReplicationJunkBasename(f) && f.endsWith(\".md\"))\n .map((f: string) => path.join(correctionsDir, f));\n files.push(...corrFiles);\n } catch {\n // corrections dir might not exist\n }\n\n const corrections: CorrectionMemory[] = [];\n const seen = new Set<string>();\n\n for (const filePath of files) {\n try {\n const raw = await readFile(filePath, \"utf8\");\n\n // Parse frontmatter\n const fmMatch = raw.match(/^---\\n([\\s\\S]*?)\\n---\\n([\\s\\S]*)$/);\n if (!fmMatch) continue;\n\n const content = fmMatch[2].trim();\n if (!content || content.length < 10) continue;\n\n // Extract id from frontmatter\n const idMatch = fmMatch[1].match(/^id:\\s*(.+)$/m);\n const id = idMatch?.[1]?.trim() ?? path.basename(filePath, \".md\");\n\n if (seen.has(id)) continue;\n seen.add(id);\n\n const confMatch = fmMatch[1].match(/^confidence:\\s*(.+)$/m);\n const confidence = confMatch ? parseFloat(confMatch[1]) : 0.9;\n\n const entityMatch = fmMatch[1].match(/^entityRef:\\s*(.+)$/m);\n const entityRefs = entityMatch ? [entityMatch[1].trim()] : [];\n\n corrections.push({ id, content, created: \"\", confidence, entityRefs, tags: [] });\n } catch {\n // skip unparseable files\n }\n }\n\n return corrections;\n}\n\n// ─── LLM-Assisted Clustering and Replay ──────────────────────────────────────\n\nexport const CLUSTER_PROMPT = `You are analyzing user corrections to an AI assistant. Each correction represents a moment where the assistant's prediction of what the user wanted was WRONG.\n\nYour job: Group these corrections into clusters where the SAME TYPE of misunderstanding is happening. Then for each cluster, synthesize a CalibrationRule.\n\nA CalibrationRule describes:\n- condition: When does this type of mistake happen?\n- modelTendency: What does the model tend to assume or do wrong?\n- userExpectation: What does the user actually want instead?\n- calibration: How should the model adjust its behavior?\n- ruleType: One of \"model_tendency\", \"user_expectation\", \"scope_boundary\", \"verification_required\"\n\nFocus on PATTERNS, not individual corrections. A cluster needs at least 2 corrections to be worth a rule.\n${OUTPUT_LANGUAGE_POLICY}\n\nOutput valid JSON only:\n{\n \"rules\": [\n {\n \"ruleType\": \"model_tendency\",\n \"condition\": \"When discussing project scope or task boundaries\",\n \"modelTendency\": \"The model tends to assume broader scope than the user intends\",\n \"userExpectation\": \"The user prefers narrow, specific task definitions and wants to be asked before scope expansion\",\n \"calibration\": \"When uncertain about scope, ask for clarification rather than assuming. Default to the narrower interpretation.\",\n \"confidence\": 0.85,\n \"evidenceIds\": [\"correction-id-1\", \"correction-id-2\"]\n }\n ]\n}`;\n\ninterface CalibrationChatClient {\n chatCompletion(\n messages: Array<{ role: \"system\" | \"user\" | \"assistant\"; content: string }>,\n options?: {\n temperature?: number;\n maxTokens?: number;\n agentId?: string;\n modelChain?: AgentPersonaModelConfig;\n }\n ): Promise<{ content?: string | null } | null>;\n}\n\ninterface CalibrationLlmOptions {\n gatewayConfig?: GatewayConfig;\n gatewayAgentId?: string;\n modelChain?: AgentPersonaModelConfig;\n workspaceDir?: string;\n /** Plugin config. Supplies `localLlm*` settings when the gateway chain is empty. */\n pluginConfig?: PluginConfig;\n}\n\nfunction resolveCalibrationChatClient(options: CalibrationLlmOptions): CalibrationChatClient | null {\n const gateway = new FallbackLlmClient(options.gatewayConfig, {\n workspaceDir: options.workspaceDir,\n });\n if (gateway.isAvailable({ agentId: options.gatewayAgentId, modelChain: options.modelChain })) {\n return gateway;\n }\n const pluginConfig = options.pluginConfig;\n if (pluginConfig && resolveLocalLlmCapabilities(pluginConfig).localLlm) {\n log.info(`[calibration] using configured local LLM (model=${pluginConfig.localLlmModel})`);\n const local = new LocalLlmClient(pluginConfig);\n return {\n chatCompletion(messages, chatOptions) {\n return local.chatCompletion(messages, {\n temperature: chatOptions?.temperature,\n maxTokens: chatOptions?.maxTokens,\n });\n },\n };\n }\n log.warn(\"[calibration] no LLM available — skipping consolidation\");\n return null;\n}\n\nexport async function synthesizeCalibrationRules(\n corrections: CorrectionMemory[],\n llm: CalibrationChatClient,\n existingRules: CalibrationRule[],\n agentId?: string,\n modelChain?: AgentPersonaModelConfig\n): Promise<CalibrationRule[]> {\n if (corrections.length < 2) return [];\n\n // Format corrections for the LLM\n const correctionText = corrections\n .slice(0, 50) // limit to avoid huge prompts\n .map((c, i) => `[${c.id}] ${c.content}`)\n .join(\"\\n\\n\");\n\n const existingRulesText =\n existingRules.length > 0\n ? `\\n\\nExisting calibration rules (avoid duplicating these):\\n${existingRules.map((r) => `- ${r.condition}: ${r.calibration}`).join(\"\\n\")}`\n : \"\";\n\n const response = await llm.chatCompletion(\n [\n { role: \"system\", content: CLUSTER_PROMPT },\n {\n role: \"user\",\n content: `Here are ${corrections.length} corrections from this user:\\n\\n${correctionText}${existingRulesText}`,\n },\n ],\n { temperature: 0.3, maxTokens: 3000, agentId, modelChain }\n );\n\n if (!response?.content) return [];\n\n try {\n let jsonStr = response.content.trim();\n const fenceMatch = jsonStr.match(/```(?:json)?\\s*\\n?([\\s\\S]*?)\\n?\\s*```/);\n if (fenceMatch) jsonStr = fenceMatch[1];\n\n const parsed = JSON.parse(jsonStr);\n if (!Array.isArray(parsed.rules)) return [];\n\n const now = new Date().toISOString();\n const rawRules: unknown[] = Array.isArray(parsed.rules) ? parsed.rules : [];\n return rawRules\n .map((r: unknown): CalibrationRule | undefined => {\n if (!r || typeof r !== \"object\" || Array.isArray(r)) return undefined;\n const raw = r as Record<string, unknown>;\n const ruleType = nonEmptyString(raw.ruleType);\n const condition = nonEmptyString(raw.condition);\n const modelTendency = nonEmptyString(raw.modelTendency);\n const calibration = nonEmptyString(raw.calibration);\n const confidence = parseConfidence(raw.confidence);\n if (\n !ruleType ||\n !CALIBRATION_RULE_TYPES.has(ruleType) ||\n !condition ||\n !modelTendency ||\n !calibration ||\n confidence === undefined\n ) {\n return undefined;\n }\n const evidenceCorrectionIds = parseEvidenceIds(raw.evidenceIds);\n return {\n id: `cal-${createHash(\"sha256\")\n .update(condition + calibration)\n .digest(\"hex\")\n .slice(0, 12)}`,\n ruleType: ruleType as CalibrationRule[\"ruleType\"],\n condition,\n modelTendency,\n userExpectation: nonEmptyString(raw.userExpectation) ?? \"\",\n calibration,\n confidence,\n evidenceCount: evidenceCorrectionIds.length,\n evidenceCorrectionIds,\n createdAt: now,\n lastReinforcedAt: now,\n };\n })\n .filter((rule): rule is CalibrationRule => !!rule);\n } catch {\n log.warn(\"[calibration] failed to parse LLM response\");\n return [];\n }\n}\n\n// ─── Recall Section ──────────────────────────────────────────────────────────\n\n/**\n * Build a recall section from calibration rules relevant to the current query.\n * Uses the LLM to select which rules apply to the current context.\n */\nexport function buildCalibrationRecallSection(\n rules: CalibrationRule[],\n query: string,\n maxChars: number = 1200,\n): string | null {\n if (rules.length === 0) return null;\n\n // Simple relevance: include all rules (they're already filtered to this user)\n // In production, could use embedding similarity to filter\n const lines: string[] = [\n \"## Model Calibration (learned from past corrections)\",\n \"\",\n \"Adjustments for this specific user, learned from patterns in their corrections:\",\n \"\",\n ];\n\n let totalChars = lines.join(\"\\n\").length;\n\n for (const rule of rules) {\n const line = `- **${rule.condition}**: ${rule.modelTendency} → Instead: ${rule.calibration}`;\n if (totalChars + line.length + 1 > maxChars) break;\n lines.push(line);\n totalChars += line.length + 1;\n }\n\n if (lines.length <= 4) return null;\n lines.push(\"\");\n return lines.join(\"\\n\");\n}\n\n// ─── Public API ──────────────────────────────────────────────────────────────\n\n/**\n * Options weekly compounding passes into calibration. Gateway agent and task\n * chain fields stay limited to `modelSource: \"gateway\"`. `pluginConfig` carries\n * the `localLlm*` settings used when that chain is empty.\n */\nexport function calibrationConsolidationInput(config: PluginConfig): {\n memoryDir: string;\n gatewayConfig?: GatewayConfig;\n gatewayAgentId?: string;\n modelChain?: AgentPersonaModelConfig;\n workspaceDir?: string;\n pluginConfig: PluginConfig;\n} {\n const gateway = config.modelSource === \"gateway\";\n return {\n memoryDir: config.memoryDir,\n gatewayConfig: config.gatewayConfig,\n gatewayAgentId: gateway ? (config.gatewayAgentId || undefined) : undefined,\n modelChain: gateway ? config.taskModelChain : undefined,\n workspaceDir: config.workspaceDir,\n pluginConfig: config,\n };\n}\n\n/**\n * Run the full calibration pipeline:\n * 1. Read all corrections\n * 2. Send to LLM for clustering and rule synthesis\n * 3. Merge with existing rules\n * 4. Write updated index\n */\nexport async function runCalibrationConsolidation(options: {\n memoryDir: string;\n gatewayConfig?: GatewayConfig;\n gatewayAgentId?: string;\n modelChain?: AgentPersonaModelConfig;\n workspaceDir?: string;\n pluginConfig?: PluginConfig;\n /**\n * When set, a week whose reinforcement is already in the index is returned\n * as-is. Weekly synthesis passes the ISO week id so a retry after a later\n * artifact failure does not count the same corrections twice.\n */\n idempotencyKey?: string;\n}): Promise<CalibrationRule[]> {\n try {\n const idempotencyKey = appliedCalibrationWeekId(options.idempotencyKey);\n const existingIndex = await readCalibrationIndex(options.memoryDir);\n if (idempotencyKey && (existingIndex.appliedWeekIds ?? []).includes(idempotencyKey)) {\n log.debug(`[calibration] week ${idempotencyKey} already applied — skipping`);\n return existingIndex.rules;\n }\n\n const llm = resolveCalibrationChatClient(options);\n if (!llm) return [];\n\n const corrections = await readCorrections(options.memoryDir);\n if (corrections.length < 3) {\n log.info(`[calibration] only ${corrections.length} corrections — need at least 3`);\n return [];\n }\n\n const newRules = await synthesizeCalibrationRules(\n corrections,\n llm,\n existingIndex.rules,\n options.gatewayAgentId,\n options.modelChain\n );\n if (newRules.length === 0) {\n log.info(\"[calibration] no new calibration rules synthesized\");\n return existingIndex.rules;\n }\n\n // Merge: keep existing rules, add new ones (deduplicate by id)\n const ruleMap = new Map(existingIndex.rules.map((r) => [r.id, r]));\n for (const rule of newRules) {\n if (ruleMap.has(rule.id)) {\n // Reinforce existing rule\n const existing = ruleMap.get(rule.id)!;\n existing.lastReinforcedAt = new Date().toISOString();\n existing.evidenceCount += rule.evidenceCount;\n existing.confidence = Math.min(1, existing.confidence + 0.05);\n } else {\n ruleMap.set(rule.id, rule);\n }\n }\n\n const allRules = [...ruleMap.values()];\n await writeCalibrationIndex(options.memoryDir, withAppliedCalibrationWeek({\n rules: allRules,\n updatedAt: existingIndex.updatedAt,\n totalCorrectionsAnalyzed: corrections.length,\n appliedWeekIds: existingIndex.appliedWeekIds,\n }, idempotencyKey));\n\n log.debug(`[calibration] synthesized ${newRules.length} new rule(s), ${allRules.length} total`);\n return allRules;\n } catch (error) {\n log.warn(\n `[calibration] consolidation failed (non-fatal): ${error instanceof Error ? error.message : String(error)}`\n );\n return [];\n }\n}\n\n/**\n * Standalone entry point for calibration consolidation that can be called\n * independently of weekly compounding. The compounding engine's\n * `synthesizeWeekly()` is one trigger, but orchestrators or periodic\n * maintenance jobs should call this directly so calibration is not gated\n * on weekly compounding being enabled.\n */\nexport async function runCalibrationIfEnabled(options: {\n memoryDir: string;\n calibrationEnabled: boolean;\n gatewayConfig?: GatewayConfig;\n gatewayAgentId?: string;\n modelChain?: AgentPersonaModelConfig;\n workspaceDir?: string;\n pluginConfig?: PluginConfig;\n}): Promise<CalibrationRule[]> {\n if (!options.calibrationEnabled) {\n return [];\n }\n return runCalibrationConsolidation({\n memoryDir: options.memoryDir,\n gatewayConfig: options.gatewayConfig,\n gatewayAgentId: options.gatewayAgentId,\n modelChain: options.modelChain,\n workspaceDir: options.workspaceDir,\n pluginConfig: options.pluginConfig,\n });\n}\n\n/**\n * Get calibration rules for recall injection.\n * Reads the pre-computed calibration index.\n */\nexport async function getCalibrationRulesForRecall(\n memoryDir: string,\n): Promise<CalibrationRule[]> {\n const index = await readCalibrationIndex(memoryDir);\n return index.rules;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,SAAS,kBAAkB;AAC3B,SAAS,OAAO,gBAAgB;AAChC,OAAO,UAAU;AAyCjB,SAAS,eAAe,WAA2B;AACjD,SAAO,KAAK,KAAK,WAAW,SAAS,aAAa;AACpD;AAEA,SAAS,qBAAqB,WAA2B;AACvD,SAAO,KAAK,KAAK,eAAe,SAAS,GAAG,wBAAwB;AACtE;AAGA,IAAM,6BAA6B;AAE5B,SAAS,yBAAyB,OAAoC;AAC3E,MAAI,OAAO,UAAU,SAAU,QAAO;AACtC,QAAM,UAAU,MAAM,KAAK;AAC3B,MAAI,QAAQ,WAAW,KAAK,QAAQ,SAAS,2BAA4B,QAAO;AAChF,SAAO;AACT;AAEA,eAAsB,qBAAqB,WAA8C;A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AAI,GAAG,SAAS,aAAa,IAAI;AAAA,MAC9D,OAAO;AACL,gBAAQ,IAAI,KAAK,IAAI,IAAI;AAAA,MAC3B;AAAA,IACF;AAEA,UAAM,WAAW,CAAC,GAAG,QAAQ,OAAO,CAAC;AACrC,UAAM,sBAAsB,QAAQ,WAAW,2BAA2B;AAAA,MACxE,OAAO;AAAA,MACP,WAAW,cAAc;AAAA,MACzB,0BAA0B,YAAY;AAAA,MACtC,gBAAgB,cAAc;AAAA,IAChC,GAAG,cAAc,CAAC;AAElB,QAAI,MAAM,6BAA6B,SAAS,MAAM,iBAAiB,SAAS,MAAM,QAAQ;AAC9F,WAAO;AAAA,EACT,SAAS,OAAO;AACd,QAAI;AAAA,MACF,mDAAmD,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;AAAA,IAC3G;AACA,WAAO,CAAC;AAAA,EACV;AACF;AASA,eAAsB,wBAAwB,SAQf;AAC7B,MAAI,CAAC,QAAQ,oBAAoB;AAC/B,WAAO,CAAC;AAAA,EACV;AACA,SAAO,4BAA4B;AAAA,IACjC,WAAW,QAAQ;AAAA,IACnB,eAAe,QAAQ;AAAA,IACvB,gBAAgB,QAAQ;AAAA,IACxB,YAAY,QAAQ;AAAA,IACpB,cAAc,QAAQ;AAAA,IACtB,cAAc,QAAQ;AAAA,EACxB,CAAC;AACH;AAMA,eAAsB,6BACpB,WAC4B;AAC5B,QAAM,QAAQ,MAAM,qBAAqB,SAAS;AAClD,SAAO,MAAM;AACf;","names":[]}
|
|
@@ -4,12 +4,12 @@ import {
|
|
|
4
4
|
} from "./chunk-66JOLMWS.js";
|
|
5
5
|
import {
|
|
6
6
|
buildExtensionsBlockForConsolidation
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-L4QYW2HO.js";
|
|
8
8
|
import "./chunk-5JMAGU26.js";
|
|
9
9
|
import "./chunk-B7RWBZXW.js";
|
|
10
10
|
import {
|
|
11
11
|
runPostConsolidationMaterialize
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-IVXOYE43.js";
|
|
13
13
|
import "./chunk-3UXOZBHV.js";
|
|
14
14
|
import "./chunk-J6GZ2254.js";
|
|
15
15
|
import "./chunk-236PXYG7.js";
|
|
@@ -18,22 +18,22 @@ import "./chunk-QDW3E4RD.js";
|
|
|
18
18
|
import {
|
|
19
19
|
resolveCausalTrajectoryStoreDir
|
|
20
20
|
} from "./chunk-6L63IN3M.js";
|
|
21
|
-
import "./chunk-
|
|
22
|
-
import "./chunk-QGVCFVX6.js";
|
|
21
|
+
import "./chunk-5IQL4N37.js";
|
|
23
22
|
import "./chunk-UHVXE24Y.js";
|
|
23
|
+
import "./chunk-QGVCFVX6.js";
|
|
24
24
|
import "./chunk-IGOW4TJE.js";
|
|
25
25
|
import "./chunk-G6OFEGUR.js";
|
|
26
|
-
import "./chunk-
|
|
27
|
-
import "./chunk-
|
|
28
|
-
import "./chunk-
|
|
29
|
-
import "./chunk-DOJBV6WR.js";
|
|
30
|
-
import "./chunk-PFUXPTBT.js";
|
|
31
|
-
import "./chunk-CYEPCZN5.js";
|
|
32
|
-
import "./chunk-DLZGSZVC.js";
|
|
26
|
+
import "./chunk-7PMOCQOL.js";
|
|
27
|
+
import "./chunk-SHVLNI4L.js";
|
|
28
|
+
import "./chunk-OBQ2NZAR.js";
|
|
33
29
|
import "./chunk-OVZIYLBZ.js";
|
|
34
|
-
import "./chunk-WNEVEMJ3.js";
|
|
35
30
|
import "./chunk-EXYT52NR.js";
|
|
31
|
+
import "./chunk-YK6SFDP2.js";
|
|
32
|
+
import "./chunk-P3AQ2YSX.js";
|
|
33
|
+
import "./chunk-CYEPCZN5.js";
|
|
34
|
+
import "./chunk-FYQUUIPI.js";
|
|
36
35
|
import "./chunk-Y5NLBXPV.js";
|
|
36
|
+
import "./chunk-WNEVEMJ3.js";
|
|
37
37
|
import "./chunk-TFA6HPOA.js";
|
|
38
38
|
import "./chunk-F4TWWUMP.js";
|
|
39
39
|
import "./chunk-72A4L5JJ.js";
|
|
@@ -46,7 +46,7 @@ import "./chunk-S2HLHAZ4.js";
|
|
|
46
46
|
import "./chunk-DM2T26WE.js";
|
|
47
47
|
import "./chunk-LDXUBPMO.js";
|
|
48
48
|
import "./chunk-FF6N7BXC.js";
|
|
49
|
-
import "./chunk-
|
|
49
|
+
import "./chunk-JDQEQE2R.js";
|
|
50
50
|
import "./chunk-AAD2ZS6P.js";
|
|
51
51
|
import "./chunk-BV2BRHD4.js";
|
|
52
52
|
import "./chunk-ZIKENA2C.js";
|
|
@@ -77,16 +77,16 @@ import "./chunk-IUM3VSHI.js";
|
|
|
77
77
|
import "./chunk-C64XATK7.js";
|
|
78
78
|
import "./chunk-42JKGUFJ.js";
|
|
79
79
|
import "./chunk-23G5P7TA.js";
|
|
80
|
-
import "./chunk-
|
|
80
|
+
import "./chunk-4KLQI3L2.js";
|
|
81
81
|
import {
|
|
82
82
|
FallbackLlmClient
|
|
83
|
-
} from "./chunk-
|
|
83
|
+
} from "./chunk-UCPH56YX.js";
|
|
84
84
|
import "./chunk-I55KAVET.js";
|
|
85
85
|
import "./chunk-L2EXJQJP.js";
|
|
86
86
|
import "./chunk-45GF7Y3V.js";
|
|
87
87
|
import {
|
|
88
88
|
fallbackLlmRuntimeContextFromConfig
|
|
89
|
-
} from "./chunk-
|
|
89
|
+
} from "./chunk-DJDJBMFX.js";
|
|
90
90
|
import "./chunk-E2AWJ7KQ.js";
|
|
91
91
|
import "./chunk-W5BIQOAJ.js";
|
|
92
92
|
import "./chunk-HADD45AR.js";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
resolveDefaultNamespaceRoot
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-DANFOVQG.js";
|
|
4
4
|
import {
|
|
5
5
|
StorageManager
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-5IQL4N37.js";
|
|
7
7
|
import {
|
|
8
8
|
composeLocationDayBody,
|
|
9
9
|
composeLocationDayMeta,
|
|
@@ -728,4 +728,4 @@ export {
|
|
|
728
728
|
runLocationBackfill,
|
|
729
729
|
runLocationCliCommand
|
|
730
730
|
};
|
|
731
|
-
//# sourceMappingURL=chunk-
|
|
731
|
+
//# sourceMappingURL=chunk-233S3MXC.js.map
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-DBB5JPSL.js";
|
|
4
4
|
import {
|
|
5
5
|
isGenericRecallExcludedPath
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-ORVPS4ZW.js";
|
|
7
7
|
import {
|
|
8
8
|
isChangeOrientedQuery
|
|
9
9
|
} from "./chunk-EH3HNCAM.js";
|
|
@@ -69,4 +69,4 @@ export {
|
|
|
69
69
|
filterRecentScanMemoriesForStateView,
|
|
70
70
|
indexStateViewAnnotatedResults
|
|
71
71
|
};
|
|
72
|
-
//# sourceMappingURL=chunk-
|
|
72
|
+
//# sourceMappingURL=chunk-36B5VPRU.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
defineOperation
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-R24RYSQX.js";
|
|
4
4
|
import {
|
|
5
5
|
EngramAccessInputError
|
|
6
6
|
} from "./chunk-LGEH473S.js";
|
|
@@ -71,4 +71,4 @@ defineOperation({
|
|
|
71
71
|
})
|
|
72
72
|
})
|
|
73
73
|
});
|
|
74
|
-
//# sourceMappingURL=chunk-
|
|
74
|
+
//# sourceMappingURL=chunk-3GGCMRO7.js.map
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-5HFVWYHL.js";
|
|
4
4
|
import {
|
|
5
5
|
isGenericRecallExcludedPath
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-ORVPS4ZW.js";
|
|
7
7
|
import {
|
|
8
8
|
planRecallMode
|
|
9
9
|
} from "./chunk-CSAKJVXW.js";
|
|
@@ -132,4 +132,4 @@ async function findExpectedMemory(orchestrator, namespaces, expect) {
|
|
|
132
132
|
export {
|
|
133
133
|
runRecallWhy
|
|
134
134
|
};
|
|
135
|
-
//# sourceMappingURL=chunk-
|
|
135
|
+
//# sourceMappingURL=chunk-3M7YP42P.js.map
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-KJTKLXTH.js";
|
|
4
4
|
import {
|
|
5
5
|
StorageManager
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-5IQL4N37.js";
|
|
7
7
|
import {
|
|
8
8
|
assertInjectedStorageRooted
|
|
9
9
|
} from "./chunk-BNZAR6PO.js";
|
|
@@ -260,4 +260,4 @@ export {
|
|
|
260
260
|
backupExistingLedger,
|
|
261
261
|
rebuildMemoryLifecycleLedger
|
|
262
262
|
};
|
|
263
|
-
//# sourceMappingURL=chunk-
|
|
263
|
+
//# sourceMappingURL=chunk-3MBSD53O.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
rebuildMemoryProjection,
|
|
3
3
|
watchProjectionRebuildParent
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-F3FNXE7C.js";
|
|
5
5
|
import {
|
|
6
6
|
initLogger,
|
|
7
7
|
log
|
|
@@ -77,4 +77,4 @@ if (invokedAsRunner) {
|
|
|
77
77
|
export {
|
|
78
78
|
PROJECTION_REBUILD_RUNNER_FLAG
|
|
79
79
|
};
|
|
80
|
-
//# sourceMappingURL=chunk-
|
|
80
|
+
//# sourceMappingURL=chunk-4DLZ2ITE.js.map
|
|
@@ -100,6 +100,45 @@ function bufferTurnsEqual(left, right) {
|
|
|
100
100
|
// restart-rehydrated plan must still match the pin it was accepted under.
|
|
101
101
|
left.writeNamespaceOverride === right.writeNamespaceOverride && left.principalOverride === right.principalOverride && scopeProfilePlanIdentity(left.scopeProfileWritePlan) === scopeProfilePlanIdentity(right.scopeProfileWritePlan);
|
|
102
102
|
}
|
|
103
|
+
function bufferTurnIdentityKey(turn) {
|
|
104
|
+
const opt = (value) => value === void 0 ? "undefined" : value === null ? "null" : JSON.stringify(value);
|
|
105
|
+
const optFlag = (value) => value === void 0 ? "undefined" : String(value);
|
|
106
|
+
const ctx = turn.codingContext;
|
|
107
|
+
return JSON.stringify([
|
|
108
|
+
turn.role,
|
|
109
|
+
turn.content,
|
|
110
|
+
turn.timestamp,
|
|
111
|
+
opt(turn.sessionKey),
|
|
112
|
+
opt(turn.sessionOwnerPrincipal),
|
|
113
|
+
opt(turn.logicalSessionKey),
|
|
114
|
+
turn.providerThreadId === void 0 ? "undefined" : turn.providerThreadId === null ? "null" : JSON.stringify(turn.providerThreadId),
|
|
115
|
+
opt(turn.turnFingerprint),
|
|
116
|
+
optFlag(turn.persistProcessedFingerprint),
|
|
117
|
+
opt(turn.sourceConnector),
|
|
118
|
+
opt(turn.originRole),
|
|
119
|
+
optFlag(turn.ambientCapture),
|
|
120
|
+
opt(turn.sourceValidAt),
|
|
121
|
+
optFlag(turn.acceptedCapture),
|
|
122
|
+
opt(ctx?.projectId),
|
|
123
|
+
opt(ctx?.rootPath),
|
|
124
|
+
opt(ctx?.branch),
|
|
125
|
+
opt(ctx?.defaultBranch),
|
|
126
|
+
opt(turn.writeNamespaceOverride),
|
|
127
|
+
opt(turn.principalOverride),
|
|
128
|
+
opt(turn.scopeProfileWritePlan ? scopeProfilePlanIdentity(turn.scopeProfileWritePlan) : void 0)
|
|
129
|
+
]);
|
|
130
|
+
}
|
|
131
|
+
function mergeBufferTurnsByIdentity(existing, incoming) {
|
|
132
|
+
const merged = [...existing];
|
|
133
|
+
const seen = new Set(merged.map(bufferTurnIdentityKey));
|
|
134
|
+
for (const turn of incoming) {
|
|
135
|
+
const key = bufferTurnIdentityKey(turn);
|
|
136
|
+
if (seen.has(key)) continue;
|
|
137
|
+
seen.add(key);
|
|
138
|
+
merged.push(turn);
|
|
139
|
+
}
|
|
140
|
+
return merged;
|
|
141
|
+
}
|
|
103
142
|
function selectRetainedDeferredTurns(existing, turns, max, originalTurns) {
|
|
104
143
|
const others = originalTurns === void 0 ? [] : existing.filter(
|
|
105
144
|
(turn) => !originalTurns.some((original) => bufferTurnsEqual(turn, original))
|
|
@@ -209,6 +248,8 @@ export {
|
|
|
209
248
|
subtractBufferTurns,
|
|
210
249
|
bufferEntryCounts,
|
|
211
250
|
bufferTurnsEqual,
|
|
251
|
+
bufferTurnIdentityKey,
|
|
252
|
+
mergeBufferTurnsByIdentity,
|
|
212
253
|
selectRetainedDeferredTurns,
|
|
213
254
|
hasPinnedCaptureScope,
|
|
214
255
|
scopeProfilePlanIdentity,
|
|
@@ -220,4 +261,4 @@ export {
|
|
|
220
261
|
ProbeTimeoutError,
|
|
221
262
|
probeWithTimeout
|
|
222
263
|
};
|
|
223
|
-
//# sourceMappingURL=chunk-
|
|
264
|
+
//# sourceMappingURL=chunk-4KLQI3L2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/buffer-turn-helpers.ts"],"sourcesContent":["import type { BufferEntryState, BufferState, BufferTurn } from \"./types.js\";\n\nexport interface BufferTurnOwner {\n /**\n * Server-resolved principal that owns this session at the authenticated\n * observe/write boundary. Persisted with the buffered turn so lifecycle\n * flushes do not have to infer ownership from a client-chosen session key.\n */\n sessionOwnerPrincipal?: string;\n}\n\nexport interface AmbientCaptureProvenance {\n /**\n * True when this turn's content came from an always-on ambient capture\n * device (a wearable recorder, a room microphone) and may therefore carry\n * speech the user never authored: TV, podcasts, music, overheard\n * conversation (issue #2294). Set by the ingesting subsystem, never from\n * tool arguments — extraction reads it to warn the model about media audio\n * and to clamp high-impact personal facts to the speculative tier.\n */\n ambientCapture?: boolean;\n}\n\nexport function describeError(err: unknown): string {\n if (err instanceof Error) return err.message;\n if (err === null) return \"null\";\n if (err === undefined) return \"undefined\";\n if (typeof err === \"string\") return err;\n try {\n return JSON.stringify(err);\n } catch {\n return String(err);\n }\n}\n\nexport function copyBufferTurn(turn: BufferTurn): BufferTurn {\n const copy: BufferTurn = {\n role: turn.role,\n content: turn.content,\n timestamp: turn.timestamp,\n };\n if (typeof turn.sessionKey === \"string\") copy.sessionKey = turn.sessionKey;\n if (typeof turn.logicalSessionKey === \"string\") {\n copy.logicalSessionKey = turn.logicalSessionKey;\n }\n if (turn.providerThreadId === null || typeof turn.providerThreadId === \"string\") {\n copy.providerThreadId = turn.providerThreadId;\n }\n if (typeof turn.sessionOwnerPrincipal === \"string\") {\n copy.sessionOwnerPrincipal = turn.sessionOwnerPrincipal;\n }\n if (typeof turn.turnFingerprint === \"string\") {\n copy.turnFingerprint = turn.turnFingerprint;\n }\n if (typeof turn.persistProcessedFingerprint === \"boolean\") {\n copy.persistProcessedFingerprint = turn.persistProcessedFingerprint;\n }\n if (typeof turn.sourceConnector === \"string\") {\n copy.sourceConnector = turn.sourceConnector;\n }\n if (turn.originRole === \"user\" || turn.originRole === \"assistant\" || turn.originRole === \"tool\") {\n copy.originRole = turn.originRole;\n }\n if (typeof turn.ambientCapture === \"boolean\") {\n copy.ambientCapture = turn.ambientCapture;\n }\n if (turn.sourceValidAt !== undefined) {\n copy.sourceValidAt = turn.sourceValidAt;\n }\n if (turn.parts !== undefined) {\n copy.parts = turn.parts;\n }\n if (turn.rawContent !== undefined) {\n copy.rawContent = turn.rawContent;\n }\n if (turn.sourceFormat !== undefined) {\n copy.sourceFormat = turn.sourceFormat;\n }\n // #3251 scope pins: strings copy by value; the plan object is an immutable\n // config-derived identity passed by reference.\n if (turn.writeNamespaceOverride !== undefined) {\n copy.writeNamespaceOverride = turn.writeNamespaceOverride;\n }\n if (turn.principalOverride !== undefined) {\n copy.principalOverride = turn.principalOverride;\n }\n if (turn.scopeProfileWritePlan !== undefined) {\n copy.scopeProfileWritePlan = turn.scopeProfileWritePlan;\n }\n if (turn.acceptedCapture === true) {\n copy.acceptedCapture = true;\n }\n const ctx = turn.codingContext;\n if (ctx) {\n // All four fields are identity inputs (branchScope uses branch) — copy\n // explicitly as-is; never a spread of external input.\n copy.codingContext = {\n projectId: ctx.projectId,\n branch: ctx.branch,\n rootPath: ctx.rootPath,\n defaultBranch: ctx.defaultBranch,\n };\n }\n return copy;\n}\n\n/**\n * Remove the turns that a drain already extracted (`drained`) from `turns`.\n * Identity-based (role/content/timestamp/session/...): the same comparison\n * the buffer uses to match live turns, so a stale owner can subtract exactly\n * what the drain took and keep everything else.\n */\nexport function subtractBufferTurns(turns: readonly BufferTurn[], drained: readonly BufferTurn[]): BufferTurn[] {\n if (drained.length === 0) return [...turns];\n const kept = [...turns];\n for (const gone of drained) {\n const at = kept.findIndex((live) => bufferTurnsEqual(live, gone));\n if (at >= 0) kept.splice(at, 1);\n }\n return kept;\n}\n\n/** Per-key pending counts over the IN-MEMORY buffer state (counts only — no\n * turn payloads). The claim store's answer stays authoritative for claimed\n * keys; callers must filter through `BufferDrainClaims.isClaimed` before\n * treating a count here as work. */\nexport interface BufferEntryCounts {\n turns: number;\n retainedTurns: number;\n}\n\nexport function bufferEntryCounts(state: BufferState): Map<string, BufferEntryCounts> {\n const out = new Map<string, BufferEntryCounts>();\n const entries = state.entries;\n if (!entries) return out;\n for (const [key, entry] of Object.entries(entries)) {\n out.set(key, { turns: entry.turns.length, retainedTurns: entry.retainedTurns?.length ?? 0 });\n }\n return out;\n}\n\nexport function bufferTurnsEqual(left: BufferTurn | undefined, right: BufferTurn): boolean {\n if (!left) return false;\n return (\n left.role === right.role &&\n left.content === right.content &&\n left.timestamp === right.timestamp &&\n left.sessionKey === right.sessionKey &&\n left.sessionOwnerPrincipal === right.sessionOwnerPrincipal &&\n left.logicalSessionKey === right.logicalSessionKey &&\n left.providerThreadId === right.providerThreadId &&\n left.turnFingerprint === right.turnFingerprint &&\n left.persistProcessedFingerprint === right.persistProcessedFingerprint &&\n left.sourceConnector === right.sourceConnector &&\n left.originRole === right.originRole &&\n left.ambientCapture === right.ambientCapture &&\n left.sourceValidAt === right.sourceValidAt &&\n left.acceptedCapture === right.acceptedCapture &&\n left.codingContext?.projectId === right.codingContext?.projectId &&\n left.codingContext?.rootPath === right.codingContext?.rootPath &&\n left.codingContext?.branch === right.codingContext?.branch &&\n left.codingContext?.defaultBranch === right.codingContext?.defaultBranch &&\n // #3251 scope pins compare by identity triple, not deep plan equality: a\n // restart-rehydrated plan must still match the pin it was accepted under.\n left.writeNamespaceOverride === right.writeNamespaceOverride &&\n left.principalOverride === right.principalOverride &&\n scopeProfilePlanIdentity(left.scopeProfileWritePlan) ===\n scopeProfilePlanIdentity(right.scopeProfileWritePlan)\n );\n}\n\n/**\n * Canonical identity key for a turn, injective over `bufferTurnsEqual`\n * equality classes. Every compared field is a primitive (or the #3251 plan\n * identity string), so set-membership replaces pairwise comparison and turn\n * merges run O(n + m) instead of O(n × m). JSON.stringify of a string is\n * injective (it escapes control characters), and the raw `\\u0001` sentinels\n * distinguish undefined from null — a distinction `===` makes and plain\n * stringification would lose.\n */\nexport function bufferTurnIdentityKey(turn: BufferTurn): string {\n const opt = (value: string | null | undefined): string =>\n value === undefined ? \"\\u0001undefined\" : value === null ? \"\\u0001null\" : JSON.stringify(value);\n const optFlag = (value: boolean | undefined): string =>\n value === undefined ? \"\\u0001undefined\" : String(value);\n const ctx = turn.codingContext;\n return JSON.stringify([\n turn.role,\n turn.content,\n turn.timestamp,\n opt(turn.sessionKey),\n opt(turn.sessionOwnerPrincipal),\n opt(turn.logicalSessionKey),\n turn.providerThreadId === undefined ? \"\\u0001undefined\" : turn.providerThreadId === null ? \"\\u0001null\" : JSON.stringify(turn.providerThreadId),\n opt(turn.turnFingerprint),\n optFlag(turn.persistProcessedFingerprint),\n opt(turn.sourceConnector),\n opt(turn.originRole),\n optFlag(turn.ambientCapture),\n opt(turn.sourceValidAt),\n optFlag(turn.acceptedCapture),\n opt(ctx?.projectId),\n opt(ctx?.rootPath),\n opt(ctx?.branch),\n opt(ctx?.defaultBranch),\n opt(turn.writeNamespaceOverride),\n opt(turn.principalOverride),\n opt(turn.scopeProfileWritePlan ? scopeProfilePlanIdentity(turn.scopeProfileWritePlan) : undefined),\n ]);\n}\n\n/**\n * Identity-dedupe `incoming` turns into `existing` (same contract as the\n * claim-merge `mergeTurns`): identical turns are dropped — the EXISTING\n * entry is kept — genuinely-new turns append in arrival order, and\n * duplicates within `incoming` collapse to their first occurrence. O(n + m)\n * via `bufferTurnIdentityKey` membership instead of pairwise equality.\n */\nexport function mergeBufferTurnsByIdentity(\n existing: readonly BufferTurn[],\n incoming: readonly BufferTurn[],\n): BufferTurn[] {\n const merged = [...existing];\n const seen = new Set(merged.map(bufferTurnIdentityKey));\n for (const turn of incoming) {\n const key = bufferTurnIdentityKey(turn);\n if (seen.has(key)) continue;\n seen.add(key);\n merged.push(turn);\n }\n return merged;\n}\n\n/** Replace only the processed snapshot; callers without one retain legacy whole-slot semantics. */\nexport function selectRetainedDeferredTurns(\n existing: readonly BufferTurn[],\n turns: BufferTurn[],\n max: number,\n originalTurns?: readonly BufferTurn[],\n): BufferTurn[] {\n const others = originalTurns === undefined ? [] : existing.filter(\n (turn) => !originalTurns.some((original) => bufferTurnsEqual(turn, original)),\n );\n if (!Array.isArray(turns) || max <= 0) return others;\n return [...others, ...turns.slice(-max).map(copyBufferTurn)];\n}\n\nexport function hasPinnedCaptureScope(turn: BufferTurn): boolean {\n return turn.acceptedCapture === true ||\n turn.writeNamespaceOverride !== undefined ||\n turn.scopeProfileWritePlan !== undefined;\n}\n\n/** Stable identity string for a pinned scope-profile plan (#3251). */\nexport function scopeProfilePlanIdentity(\n plan: BufferTurn[\"scopeProfileWritePlan\"],\n): string {\n if (!plan) return \"\";\n return `${plan.profileId}\\u0000${plan.writeLayer}\\u0000${plan.writeNamespace}`;\n}\n\nexport interface ExtractionScopeGroup {\n writeNamespaceOverride?: string;\n principalOverride?: string;\n scopeProfileWritePlan?: BufferTurn[\"scopeProfileWritePlan\"];\n codingContext?: BufferTurn[\"codingContext\"];\n turns: BufferTurn[];\n}\n\n/**\n * Partition extraction turns by their durable scope pins (#3251). Turns\n * captured under different namespaces / principals / scope profiles /\n * project bindings must never be extracted together — each group runs its\n * own extraction under its own scope. Native (unpinned) turns form their own\n * group and keep today's single-store routing.\n */\nexport function groupTurnsByExtractionScope(turns: BufferTurn[]): ExtractionScopeGroup[] {\n const groups = new Map<string, ExtractionScopeGroup>();\n for (const turn of turns) {\n const key = [\n turn.writeNamespaceOverride ?? \"\",\n turn.principalOverride ?? \"\",\n scopeProfilePlanIdentity(turn.scopeProfileWritePlan),\n // Accepted captures are deliberately accepted content: they must never\n // share a scope group with ordinary turns, or a group-level capture\n // policy (the explicit-mode gate, the planless-accepted null pin) is\n // applied to ordinary conversation turns because `.some(acceptedCapture)`\n // only looked at the merged group.\n turn.acceptedCapture === true ? \"accepted\" : \"\",\n turn.codingContext?.projectId ?? \"\",\n turn.codingContext?.rootPath ?? \"\",\n turn.codingContext?.branch ?? \"\",\n turn.codingContext?.defaultBranch ?? \"\",\n ].join(\"\\u0000\");\n const group = groups.get(key);\n if (group) {\n group.turns.push(turn);\n } else {\n const created: ExtractionScopeGroup = { turns: [turn] };\n if (turn.writeNamespaceOverride !== undefined) created.writeNamespaceOverride = turn.writeNamespaceOverride;\n if (turn.principalOverride !== undefined) created.principalOverride = turn.principalOverride;\n if (turn.scopeProfileWritePlan !== undefined) created.scopeProfileWritePlan = turn.scopeProfileWritePlan;\n if (turn.codingContext !== undefined) created.codingContext = turn.codingContext;\n groups.set(key, created);\n }\n }\n return [...groups.values()];\n}\n\nexport function bufferTurnArraysEqual(\n left: readonly BufferTurn[],\n right: readonly BufferTurn[],\n): boolean {\n return left.length === right.length && left.every((turn, index) => bufferTurnsEqual(turn, right[index]));\n}\n\nexport function bufferTurnArrayIsSuffixOfSnapshot(\n liveTurns: readonly BufferTurn[],\n snapshot: readonly BufferTurn[],\n): boolean {\n if (liveTurns.length === 0 || liveTurns.length > snapshot.length) {\n return false;\n }\n const offset = snapshot.length - liveTurns.length;\n return liveTurns.every((turn, index) => bufferTurnsEqual(turn, snapshot[offset + index]));\n}\n\nexport function liveTurnsFromExtractionSnapshot(\n entry: BufferEntryState,\n extractedTurns: readonly BufferTurn[],\n): readonly BufferTurn[] {\n const retainedTurns = entry.retainedTurns ?? [];\n if (\n retainedTurns.length > 0 &&\n extractedTurns.length >= retainedTurns.length &&\n retainedTurns.every((turn, index) => bufferTurnsEqual(extractedTurns[index], turn))\n ) {\n const withoutRetainedPrefix = extractedTurns.slice(retainedTurns.length);\n if (withoutRetainedPrefix.length > 0 && matchingPrefixLength(entry.turns, withoutRetainedPrefix) > 0) {\n return withoutRetainedPrefix;\n }\n }\n return extractedTurns;\n}\n\nfunction matchingPrefixLength(\n liveTurns: readonly BufferTurn[],\n extractedTurns: readonly BufferTurn[],\n): number {\n let index = 0;\n while (\n index < liveTurns.length &&\n index < extractedTurns.length &&\n bufferTurnsEqual(liveTurns[index], extractedTurns[index])\n ) {\n index += 1;\n }\n return index;\n}\n\nexport function matchingQueuedExtractionPrefixLength(\n liveTurns: readonly BufferTurn[],\n extractedTurns: readonly BufferTurn[],\n): number {\n let bestMatchedCount = 0;\n for (let start = 0; start < extractedTurns.length; start += 1) {\n const matchedCount = matchingPrefixLength(liveTurns, extractedTurns.slice(start));\n if (matchedCount > bestMatchedCount) {\n bestMatchedCount = matchedCount;\n if (bestMatchedCount === liveTurns.length) break;\n }\n }\n return bestMatchedCount;\n}\n\nexport class ProbeTimeoutError extends Error {\n constructor(timeoutMs: number) {\n super(`probe exceeded ${timeoutMs}ms`);\n this.name = \"ProbeTimeoutError\";\n }\n}\n\nexport function probeWithTimeout<T>(inflight: Promise<T>, timeoutMs: number): Promise<T> {\n let timer: NodeJS.Timeout | null = null;\n const timeout = new Promise<T>((_, reject) => {\n timer = setTimeout(() => reject(new ProbeTimeoutError(timeoutMs)), timeoutMs);\n if (typeof (timer as NodeJS.Timeout).unref === \"function\") {\n (timer as NodeJS.Timeout).unref();\n }\n });\n return Promise.race([inflight, timeout]).finally(() => {\n if (timer) clearTimeout(timer);\n });\n}\n"],"mappings":";AAuBO,SAAS,cAAc,KAAs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B,UAAU,YAAY;AACzD,MAAC,MAAyB,MAAM;AAAA,IAClC;AAAA,EACF,CAAC;AACD,SAAO,QAAQ,KAAK,CAAC,UAAU,OAAO,CAAC,EAAE,QAAQ,MAAM;AACrD,QAAI,MAAO,cAAa,KAAK;AAAA,EAC/B,CAAC;AACH;","names":[]}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
matchesOfflineSyncDefaultExclude
|
|
3
|
+
} from "./chunk-63LFM77Z.js";
|
|
1
4
|
import {
|
|
2
5
|
EMBEDDING_SHARD_FILE_PATTERN
|
|
3
6
|
} from "./chunk-LDWE7OZS.js";
|
|
@@ -5,9 +8,6 @@ import {
|
|
|
5
8
|
prepareSafeArchiveRoot,
|
|
6
9
|
resolveSafeArchiveTarget
|
|
7
10
|
} from "./chunk-GCGJW34D.js";
|
|
8
|
-
import {
|
|
9
|
-
matchesOfflineSyncDefaultExclude
|
|
10
|
-
} from "./chunk-63LFM77Z.js";
|
|
11
11
|
import {
|
|
12
12
|
assertEmbeddingGenerationLockHeld,
|
|
13
13
|
embeddingGenerationLockPath,
|
|
@@ -709,4 +709,4 @@ export {
|
|
|
709
709
|
divergedEmbeddingGenerationDeferrals,
|
|
710
710
|
applyIncomingEmbeddingGenerations
|
|
711
711
|
};
|
|
712
|
-
//# sourceMappingURL=chunk-
|
|
712
|
+
//# sourceMappingURL=chunk-5BE3FLKL.js.map
|