@remnic/core 10.0.145 → 10.0.146
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 +151 -147
- package/dist/access-cli.js +151 -147
- package/dist/access-cli.js.map +1 -1
- package/dist/access-correlation.d.ts +4 -0
- package/dist/access-correlation.d.ts.map +1 -0
- package/dist/access-correlation.js +10 -0
- package/dist/access-extraction-force-flush-preempt.js +151 -147
- package/dist/access-extraction-force-flush.js +151 -147
- package/dist/access-http-briefing.js +151 -147
- package/dist/access-http-query.js +151 -147
- package/dist/access-http.d.ts.map +1 -1
- package/dist/access-http.js +151 -147
- package/dist/access-identity-continuity-surface.js +151 -147
- package/dist/access-lcm-surface.js +151 -147
- package/dist/access-mcp.js +151 -147
- package/dist/access-observe-write-category.js +11 -11
- package/dist/access-observe-write-surface.js +151 -147
- package/dist/access-offline-manifest.js +10 -10
- package/dist/access-operations-batch.js +151 -147
- package/dist/access-operations.js +151 -147
- package/dist/access-recall-concurrency.js +151 -147
- package/dist/access-recall-response.js +151 -147
- package/dist/access-recall-surface.js +151 -147
- package/dist/access-schema.js +7 -7
- package/dist/access-service.d.ts.map +1 -1
- package/dist/access-service.js +151 -147
- package/dist/active-recall.js +28 -28
- package/dist/adapters/index.js +7 -7
- package/dist/adapters/registry.js +3 -3
- package/dist/auto-sync-PSZJHHXB.js +2 -2
- package/dist/briefing.js +19 -19
- package/dist/buffer.js +1 -1
- package/dist/calibration.js +3 -3
- package/dist/{capsule-crypto-GWVG7LGC.js → capsule-crypto-7FJQINUR.js} +2 -2
- package/dist/causal-behavior.js +2 -2
- package/dist/causal-chain.js +2 -2
- package/dist/causal-consolidation.js +22 -22
- package/dist/causal-retrieval.js +2 -2
- package/dist/causal-trajectory-graph.js +2 -2
- package/dist/causal-trajectory.js +1 -1
- package/dist/{chunk-GB442ZFG.js → chunk-2NGTY22Z.js} +5 -5
- package/dist/{chunk-OWHERGF2.js → chunk-2NLLXCJG.js} +2 -2
- package/dist/{chunk-KBMJWNSY.js → chunk-2WD2TRTJ.js} +2 -2
- package/dist/{chunk-2UOU6CZZ.js → chunk-3MXQ5XJT.js} +2 -2
- package/dist/{chunk-ETUMOYGL.js → chunk-3NLBDM7V.js} +2 -2
- package/dist/{chunk-XVZA6VXC.js → chunk-3SL52JKD.js} +4 -4
- package/dist/chunk-4IJBNRMZ.js +45 -0
- package/dist/chunk-4IJBNRMZ.js.map +1 -0
- package/dist/{chunk-QCJ7Q5BM.js → chunk-4N4BAO66.js} +2 -2
- package/dist/{chunk-YGPRFYV6.js → chunk-4WX32RLU.js} +3 -3
- package/dist/{chunk-WN2DASTS.js → chunk-5BE3FLKL.js} +4 -4
- package/dist/chunk-5JD4DXQX.js +91 -0
- package/dist/chunk-5JD4DXQX.js.map +1 -0
- package/dist/{chunk-M4IEZGCK.js → chunk-73TPOGS4.js} +6 -6
- package/dist/{chunk-XIWRF7TG.js → chunk-7P72BY4F.js} +2 -2
- package/dist/{chunk-SV6OLWPF.js → chunk-7YHU3NJD.js} +15 -15
- package/dist/{chunk-D3ZISMKY.js → chunk-AIDFYS4Z.js} +10 -10
- package/dist/{chunk-YIOP7IFD.js → chunk-AO5LKFGO.js} +4 -4
- package/dist/{chunk-G4NKURT4.js → chunk-C6S353AG.js} +30 -1
- package/dist/chunk-C6S353AG.js.map +1 -0
- package/dist/{chunk-T3M5KJRV.js → chunk-C6Z3H23R.js} +2 -2
- package/dist/{chunk-Z2OKWO35.js → chunk-CAWVPY6E.js} +325 -316
- package/dist/chunk-CAWVPY6E.js.map +1 -0
- package/dist/{chunk-IBPE3Q5M.js → chunk-CJ2SYU4S.js} +2 -2
- package/dist/{chunk-UIFWZMO7.js → chunk-CLVILSBR.js} +7 -7
- package/dist/{chunk-7TY5ZHFA.js → chunk-COJBTRTQ.js} +2 -2
- package/dist/{chunk-LS5VJO5O.js → chunk-CVCKYMVX.js} +2 -2
- package/dist/{chunk-DCLOMXQL.js → chunk-EJ6EPEMP.js} +30 -30
- package/dist/{chunk-ENPJX3BB.js → chunk-FMFCQRDM.js} +3 -3
- package/dist/{chunk-IJVU4ILJ.js → chunk-GCHM5BYL.js} +7 -7
- package/dist/{chunk-KCU2ZWBS.js → chunk-GCQIXPWZ.js} +2 -2
- package/dist/{chunk-GKL6QYZO.js → chunk-GMO3BGOF.js} +1 -1
- package/dist/{chunk-OMPX3KLG.js → chunk-H6OTEBPK.js} +2 -2
- package/dist/{chunk-DK3T3Q6A.js → chunk-HADCITEA.js} +8 -8
- package/dist/{chunk-F4ZHKDBW.js → chunk-HLWXCDUQ.js} +2 -2
- package/dist/{chunk-E7WMDXAW.js → chunk-HOGSBSCH.js} +2 -2
- package/dist/{chunk-4RASUAN3.js → chunk-HXFIILGF.js} +4 -4
- package/dist/{chunk-CIEEYVUB.js → chunk-IMULTENA.js} +2 -2
- package/dist/{chunk-ADBON4FI.js → chunk-IOMWNBMH.js} +9 -9
- package/dist/{chunk-QFBBSKEU.js → chunk-IXR3SNHL.js} +2 -2
- package/dist/{chunk-UWP6PGWN.js → chunk-J3EU5H7W.js} +2 -2
- package/dist/{chunk-EUL3S3LE.js → chunk-J5WI4QRP.js} +4 -4
- package/dist/{chunk-DBNZYQCL.js → chunk-JXAHMR5L.js} +2 -2
- package/dist/{chunk-U62EINFH.js → chunk-KG7RO5XU.js} +3 -3
- package/dist/{chunk-BUKK5SWA.js → chunk-KQAFEZQX.js} +2 -2
- package/dist/{chunk-PDVEY4QS.js → chunk-LD7I5AZW.js} +9 -9
- package/dist/{chunk-ODHFX5JX.js → chunk-LKXED2DT.js} +13 -13
- package/dist/{chunk-FZ6QUOTL.js → chunk-LYM65HMS.js} +2 -2
- package/dist/{chunk-BKR2YCQ5.js → chunk-MKJBZR7J.js} +2 -2
- package/dist/{chunk-G3ZUQZGM.js → chunk-ND7ZKKVK.js} +2 -2
- package/dist/{chunk-7TDJZV2S.js → chunk-O7CHKXSF.js} +4 -4
- package/dist/{chunk-W7K5BP3M.js → chunk-OM5ESBES.js} +2 -2
- package/dist/{chunk-GQDO6KHO.js → chunk-OSM5MKAU.js} +2 -2
- package/dist/chunk-PXY2B7BG.js +51 -0
- package/dist/chunk-PXY2B7BG.js.map +1 -0
- package/dist/{chunk-MVTMKFBW.js → chunk-QDY4TSKK.js} +2 -2
- package/dist/{chunk-X2FEUBKD.js → chunk-QP6CBFYL.js} +2 -2
- package/dist/{chunk-4XINO77L.js → chunk-RB7NXZ2E.js} +2 -2
- package/dist/{chunk-MEYPQLXV.js → chunk-RMPHPB6B.js} +2 -2
- package/dist/{chunk-SEIFDQ6U.js → chunk-RXXXT5PA.js} +3 -3
- package/dist/{chunk-GTW6GPQU.js → chunk-S627NPRV.js} +6 -6
- package/dist/{chunk-FBV4QGXT.js → chunk-SXVU57SW.js} +2 -2
- package/dist/{chunk-TFHL4WWY.js → chunk-TAUBEJ37.js} +5 -5
- package/dist/{chunk-WQUGCOKF.js → chunk-TFA6HPOA.js} +4 -4
- package/dist/{chunk-6P7U3HWG.js → chunk-TH6OYP6I.js} +3 -3
- package/dist/{chunk-P4YYUDR5.js → chunk-TNACU47L.js} +3 -3
- package/dist/{chunk-IHCXMYSE.js → chunk-U2PSE7MB.js} +2 -2
- package/dist/{chunk-PCMGMPQZ.js → chunk-X4EF7IG3.js} +4 -4
- package/dist/{chunk-UVYI6VIX.js → chunk-X7Y7WX73.js} +1 -1
- package/dist/{chunk-GA3Y7GZR.js → chunk-XCJDDXJX.js} +2 -2
- package/dist/{chunk-GDREJ32D.js → chunk-XPDMJC5O.js} +3 -3
- package/dist/{chunk-KYZFW4LW.js → chunk-XTGQTSZZ.js} +2 -2
- package/dist/chunk-YRHBSYQR.js +15 -0
- package/dist/chunk-YRHBSYQR.js.map +1 -0
- package/dist/{chunk-63MKTHYT.js → chunk-YVK7WZYC.js} +2 -2
- package/dist/{chunk-5JW2QIFH.js → chunk-ZDWZYKCL.js} +2 -2
- package/dist/{chunk-K3FH3LAQ.js → chunk-ZG4GNPRE.js} +10 -10
- package/dist/cli.js +151 -147
- package/dist/coding/export-okf-codegraph.js +18 -18
- package/dist/coding/pre-action-gate.js +2 -2
- package/dist/compounding/engine.js +20 -20
- package/dist/config.js +28 -28
- package/dist/connectors/codex-materialize-runner.js +19 -19
- package/dist/connectors/index.js +19 -19
- package/dist/contradiction/index.js +7 -7
- package/dist/convergence-refresh.js +21 -21
- package/dist/conversation-index/backend.js +2 -2
- package/dist/corpus-watermark.js +21 -21
- package/dist/deep-recall-http-glue.js +8 -8
- package/dist/deep-recall.js +2 -2
- package/dist/entity-retrieval.js +20 -20
- package/dist/explicit-capture.js +151 -147
- package/dist/extraction-span-materialize.js +2 -2
- package/dist/extraction.js +25 -25
- package/dist/{graph-edge-decay-OEX5OGMI.js → graph-edge-decay-BC3IO2J4.js} +5 -5
- package/dist/graph-jsonl.js +3 -3
- package/dist/graph-snapshot.js +3 -3
- package/dist/graph.js +4 -4
- package/dist/harmonic-retrieval.js +19 -19
- package/dist/index.js +260 -256
- package/dist/lcm/engine.js +4 -4
- package/dist/lcm/index.js +10 -10
- package/dist/local-llm.js +2 -2
- package/dist/location/index.js +20 -20
- package/dist/maintenance/memory-governance.js +19 -19
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +19 -19
- package/dist/maintenance/rebuild-memory-projection-runner.js +21 -21
- package/dist/maintenance/rebuild-memory-projection.js +20 -20
- package/dist/memory-browse.js +1 -1
- package/dist/memory-subject.js +1 -1
- package/dist/namespaces/migrate.js +20 -20
- package/dist/namespaces/search.js +7 -7
- package/dist/namespaces/storage.js +19 -19
- 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 +22 -22
- package/dist/operator-toolkit.js +37 -37
- package/dist/orchestration/backlog-scheduler.js +152 -148
- package/dist/orchestration/backlog-scheduler.js.map +1 -1
- package/dist/orchestration/buffer-drain-runner.js +152 -148
- package/dist/orchestration/maintenance.js +30 -30
- package/dist/orchestration/recall-internal.d.ts.map +1 -1
- package/dist/orchestrator.js +151 -147
- package/dist/recall-attempt-timing.d.ts +18 -0
- package/dist/recall-attempt-timing.d.ts.map +1 -0
- package/dist/recall-attempt-timing.js +14 -0
- package/dist/recall-attempt-timing.js.map +1 -0
- package/dist/recall-enrichment-promise.d.ts +22 -0
- package/dist/recall-enrichment-promise.d.ts.map +1 -0
- package/dist/recall-enrichment-promise.js +10 -0
- package/dist/recall-enrichment-promise.js.map +1 -0
- package/dist/recall-explain-renderer.js +3 -3
- package/dist/recall-navigation.js +151 -147
- package/dist/recall-phase2-timing.d.ts +44 -0
- package/dist/recall-phase2-timing.d.ts.map +1 -0
- package/dist/recall-phase2-timing.js +22 -0
- package/dist/recall-phase2-timing.js.map +1 -0
- package/dist/recall-timings.d.ts +35 -0
- package/dist/recall-timings.d.ts.map +1 -1
- package/dist/recall-timings.js +2 -1
- package/dist/recall-why-service.js +2 -2
- package/dist/recall-xray-cli.js +4 -4
- package/dist/recall-xray-renderer.js +3 -3
- package/dist/recall-xray.js +2 -2
- package/dist/reconcile/manifest.js +3 -3
- package/dist/{resolution-A3NAI3YE.js → resolution-TCO63RRC.js} +8 -8
- package/dist/resolution-TCO63RRC.js.map +1 -0
- package/dist/resume-bundles.js +29 -29
- package/dist/salvage-envelope.js +1 -1
- package/dist/search/factory.js +6 -6
- package/dist/search/index.js +12 -12
- package/dist/semantic-consolidation.js +20 -20
- package/dist/semantic-rule-promotion.js +19 -19
- package/dist/semantic-rule-verifier.js +19 -19
- package/dist/source-agent-qualifier.js +19 -19
- package/dist/standup/build.js +19 -19
- package/dist/storage.js +18 -18
- package/dist/subject-config.js +1 -1
- package/dist/summarizer.js +4 -4
- package/dist/support-passport/index.js +7 -7
- package/dist/transfer/backup.js +2 -2
- package/dist/transfer/capsule-export.js +2 -2
- package/dist/transfer/capsule-import.js +2 -2
- package/dist/transfer/export-okf.js +19 -19
- package/dist/verified-recall.js +19 -19
- package/dist/who-knows-cli.js +20 -20
- package/dist/who-knows.js +19 -19
- package/dist/write-envelope.js +1 -1
- package/package.json +2 -2
- package/src/access-correlation.ts +17 -0
- package/src/access-http.ts +7 -8
- package/src/access-service.ts +3 -1
- package/src/orchestration/recall-internal.ts +63 -75
- package/src/recall-attempt-timing.ts +78 -0
- package/src/recall-enrichment-promise.ts +62 -0
- package/src/recall-phase2-timing.ts +146 -0
- package/src/recall-timings-access.test.ts +140 -2
- package/src/recall-timings-request-contract.test.ts +488 -0
- package/src/recall-timings.ts +70 -0
- package/dist/chunk-G4NKURT4.js.map +0 -1
- package/dist/chunk-Z2OKWO35.js.map +0 -1
- /package/dist/{capsule-crypto-GWVG7LGC.js.map → access-correlation.js.map} +0 -0
- /package/dist/{graph-edge-decay-OEX5OGMI.js.map → capsule-crypto-7FJQINUR.js.map} +0 -0
- /package/dist/{chunk-GB442ZFG.js.map → chunk-2NGTY22Z.js.map} +0 -0
- /package/dist/{chunk-OWHERGF2.js.map → chunk-2NLLXCJG.js.map} +0 -0
- /package/dist/{chunk-KBMJWNSY.js.map → chunk-2WD2TRTJ.js.map} +0 -0
- /package/dist/{chunk-2UOU6CZZ.js.map → chunk-3MXQ5XJT.js.map} +0 -0
- /package/dist/{chunk-ETUMOYGL.js.map → chunk-3NLBDM7V.js.map} +0 -0
- /package/dist/{chunk-XVZA6VXC.js.map → chunk-3SL52JKD.js.map} +0 -0
- /package/dist/{chunk-QCJ7Q5BM.js.map → chunk-4N4BAO66.js.map} +0 -0
- /package/dist/{chunk-YGPRFYV6.js.map → chunk-4WX32RLU.js.map} +0 -0
- /package/dist/{chunk-WN2DASTS.js.map → chunk-5BE3FLKL.js.map} +0 -0
- /package/dist/{chunk-M4IEZGCK.js.map → chunk-73TPOGS4.js.map} +0 -0
- /package/dist/{chunk-XIWRF7TG.js.map → chunk-7P72BY4F.js.map} +0 -0
- /package/dist/{chunk-SV6OLWPF.js.map → chunk-7YHU3NJD.js.map} +0 -0
- /package/dist/{chunk-D3ZISMKY.js.map → chunk-AIDFYS4Z.js.map} +0 -0
- /package/dist/{chunk-YIOP7IFD.js.map → chunk-AO5LKFGO.js.map} +0 -0
- /package/dist/{chunk-T3M5KJRV.js.map → chunk-C6Z3H23R.js.map} +0 -0
- /package/dist/{chunk-IBPE3Q5M.js.map → chunk-CJ2SYU4S.js.map} +0 -0
- /package/dist/{chunk-UIFWZMO7.js.map → chunk-CLVILSBR.js.map} +0 -0
- /package/dist/{chunk-7TY5ZHFA.js.map → chunk-COJBTRTQ.js.map} +0 -0
- /package/dist/{chunk-LS5VJO5O.js.map → chunk-CVCKYMVX.js.map} +0 -0
- /package/dist/{chunk-DCLOMXQL.js.map → chunk-EJ6EPEMP.js.map} +0 -0
- /package/dist/{chunk-ENPJX3BB.js.map → chunk-FMFCQRDM.js.map} +0 -0
- /package/dist/{chunk-IJVU4ILJ.js.map → chunk-GCHM5BYL.js.map} +0 -0
- /package/dist/{chunk-KCU2ZWBS.js.map → chunk-GCQIXPWZ.js.map} +0 -0
- /package/dist/{chunk-GKL6QYZO.js.map → chunk-GMO3BGOF.js.map} +0 -0
- /package/dist/{chunk-OMPX3KLG.js.map → chunk-H6OTEBPK.js.map} +0 -0
- /package/dist/{chunk-DK3T3Q6A.js.map → chunk-HADCITEA.js.map} +0 -0
- /package/dist/{chunk-F4ZHKDBW.js.map → chunk-HLWXCDUQ.js.map} +0 -0
- /package/dist/{chunk-E7WMDXAW.js.map → chunk-HOGSBSCH.js.map} +0 -0
- /package/dist/{chunk-4RASUAN3.js.map → chunk-HXFIILGF.js.map} +0 -0
- /package/dist/{chunk-CIEEYVUB.js.map → chunk-IMULTENA.js.map} +0 -0
- /package/dist/{chunk-ADBON4FI.js.map → chunk-IOMWNBMH.js.map} +0 -0
- /package/dist/{chunk-QFBBSKEU.js.map → chunk-IXR3SNHL.js.map} +0 -0
- /package/dist/{chunk-UWP6PGWN.js.map → chunk-J3EU5H7W.js.map} +0 -0
- /package/dist/{chunk-EUL3S3LE.js.map → chunk-J5WI4QRP.js.map} +0 -0
- /package/dist/{chunk-DBNZYQCL.js.map → chunk-JXAHMR5L.js.map} +0 -0
- /package/dist/{chunk-U62EINFH.js.map → chunk-KG7RO5XU.js.map} +0 -0
- /package/dist/{chunk-BUKK5SWA.js.map → chunk-KQAFEZQX.js.map} +0 -0
- /package/dist/{chunk-PDVEY4QS.js.map → chunk-LD7I5AZW.js.map} +0 -0
- /package/dist/{chunk-ODHFX5JX.js.map → chunk-LKXED2DT.js.map} +0 -0
- /package/dist/{chunk-FZ6QUOTL.js.map → chunk-LYM65HMS.js.map} +0 -0
- /package/dist/{chunk-BKR2YCQ5.js.map → chunk-MKJBZR7J.js.map} +0 -0
- /package/dist/{chunk-G3ZUQZGM.js.map → chunk-ND7ZKKVK.js.map} +0 -0
- /package/dist/{chunk-7TDJZV2S.js.map → chunk-O7CHKXSF.js.map} +0 -0
- /package/dist/{chunk-W7K5BP3M.js.map → chunk-OM5ESBES.js.map} +0 -0
- /package/dist/{chunk-GQDO6KHO.js.map → chunk-OSM5MKAU.js.map} +0 -0
- /package/dist/{chunk-MVTMKFBW.js.map → chunk-QDY4TSKK.js.map} +0 -0
- /package/dist/{chunk-X2FEUBKD.js.map → chunk-QP6CBFYL.js.map} +0 -0
- /package/dist/{chunk-4XINO77L.js.map → chunk-RB7NXZ2E.js.map} +0 -0
- /package/dist/{chunk-MEYPQLXV.js.map → chunk-RMPHPB6B.js.map} +0 -0
- /package/dist/{chunk-SEIFDQ6U.js.map → chunk-RXXXT5PA.js.map} +0 -0
- /package/dist/{chunk-GTW6GPQU.js.map → chunk-S627NPRV.js.map} +0 -0
- /package/dist/{chunk-FBV4QGXT.js.map → chunk-SXVU57SW.js.map} +0 -0
- /package/dist/{chunk-TFHL4WWY.js.map → chunk-TAUBEJ37.js.map} +0 -0
- /package/dist/{chunk-WQUGCOKF.js.map → chunk-TFA6HPOA.js.map} +0 -0
- /package/dist/{chunk-6P7U3HWG.js.map → chunk-TH6OYP6I.js.map} +0 -0
- /package/dist/{chunk-P4YYUDR5.js.map → chunk-TNACU47L.js.map} +0 -0
- /package/dist/{chunk-IHCXMYSE.js.map → chunk-U2PSE7MB.js.map} +0 -0
- /package/dist/{chunk-PCMGMPQZ.js.map → chunk-X4EF7IG3.js.map} +0 -0
- /package/dist/{chunk-UVYI6VIX.js.map → chunk-X7Y7WX73.js.map} +0 -0
- /package/dist/{chunk-GA3Y7GZR.js.map → chunk-XCJDDXJX.js.map} +0 -0
- /package/dist/{chunk-GDREJ32D.js.map → chunk-XPDMJC5O.js.map} +0 -0
- /package/dist/{chunk-KYZFW4LW.js.map → chunk-XTGQTSZZ.js.map} +0 -0
- /package/dist/{chunk-63MKTHYT.js.map → chunk-YVK7WZYC.js.map} +0 -0
- /package/dist/{chunk-5JW2QIFH.js.map → chunk-ZDWZYKCL.js.map} +0 -0
- /package/dist/{chunk-K3FH3LAQ.js.map → chunk-ZG4GNPRE.js.map} +0 -0
- /package/dist/{resolution-A3NAI3YE.js.map → graph-edge-decay-BC3IO2J4.js.map} +0 -0
|
@@ -65,7 +65,10 @@ import {
|
|
|
65
65
|
type RecallXrayScoreDecomposition,
|
|
66
66
|
buildXraySnapshot,
|
|
67
67
|
} from "../recall-xray.js";
|
|
68
|
-
import { foldQueueWaitTiming
|
|
68
|
+
import { foldQueueWaitTiming } from "../recall-timings.js";
|
|
69
|
+
import { emitRecallTiming } from "../recall-attempt-timing.js";
|
|
70
|
+
import { createPhase2Timer, type Phase2AwaitStatus } from "../recall-phase2-timing.js";
|
|
71
|
+
import { createEnrichmentAbortHandle, observeEnrichmentPromise, type DeferredEnrichmentOutcome, type ObservedDeferredEnrichmentPromise } from "../recall-enrichment-promise.js";
|
|
69
72
|
import { findUnresolvedEntityRefs } from "../reconstruct.js";
|
|
70
73
|
import { rerankLocalOrNoop, reorderByRankedKeys } from "../rerank.js";
|
|
71
74
|
import { buildResponseGuidanceRecallSection, shouldRecallResponseGuidance } from "../response-guidance-recall.js";
|
|
@@ -145,6 +148,10 @@ export class RecallInternalCoordinator {
|
|
|
145
148
|
if (Number.isFinite(parsed)) asOfMs = parsed;
|
|
146
149
|
}
|
|
147
150
|
const timings = foldQueueWaitTiming(options.queueWaitMs); // #1906 queue-wait phase
|
|
151
|
+
// Phase-2 await timings (#1830): separate from `timings` so traces and the
|
|
152
|
+
// eval shadow keep their payloads; folded into the recall-timings record only.
|
|
153
|
+
const phase2Timings: Record<string, string> = {};
|
|
154
|
+
const phase2Timer = createPhase2Timer(phase2Timings, () => options.abortSignal?.aborted === true);
|
|
148
155
|
const profileTraceId = this.deps.profiler.startTrace("recall", sessionKey, {
|
|
149
156
|
qmdEnabled: resolveQmdCapabilities(this.deps.config).qmd,
|
|
150
157
|
rerankEnabled: caps.rerank,
|
|
@@ -169,55 +176,6 @@ export class RecallInternalCoordinator {
|
|
|
169
176
|
// Wrap entire recall body in try/finally so profiling trace is always closed,
|
|
170
177
|
// even on unexpected exceptions (e.g., throwIfRecallAborted, phase-1 errors).
|
|
171
178
|
try {
|
|
172
|
-
type DeferredEnrichmentOutcome<T> =
|
|
173
|
-
| { status: "resolved"; value: T }
|
|
174
|
-
| { status: "rejected"; error: unknown };
|
|
175
|
-
type ObservedDeferredEnrichmentPromise<T> =
|
|
176
|
-
Promise<DeferredEnrichmentOutcome<T>> & {
|
|
177
|
-
getSettledOutcome: () => DeferredEnrichmentOutcome<T> | undefined;
|
|
178
|
-
cancel: () => void;
|
|
179
|
-
};
|
|
180
|
-
const createEnrichmentAbortHandle = (parentSignal?: AbortSignal) => {
|
|
181
|
-
const controller = new AbortController();
|
|
182
|
-
const onAbort = () => controller.abort();
|
|
183
|
-
if (parentSignal?.aborted) {
|
|
184
|
-
controller.abort();
|
|
185
|
-
} else if (parentSignal) {
|
|
186
|
-
parentSignal.addEventListener("abort", onAbort, { once: true });
|
|
187
|
-
}
|
|
188
|
-
let disposed = false;
|
|
189
|
-
const dispose = () => {
|
|
190
|
-
if (disposed) return;
|
|
191
|
-
disposed = true;
|
|
192
|
-
parentSignal?.removeEventListener("abort", onAbort);
|
|
193
|
-
};
|
|
194
|
-
return {
|
|
195
|
-
signal: controller.signal,
|
|
196
|
-
cancel: () => {
|
|
197
|
-
controller.abort();
|
|
198
|
-
dispose();
|
|
199
|
-
},
|
|
200
|
-
dispose,
|
|
201
|
-
};
|
|
202
|
-
};
|
|
203
|
-
const observeEnrichmentPromise = <T>(
|
|
204
|
-
promise: Promise<T>,
|
|
205
|
-
cancel: () => void = () => {},
|
|
206
|
-
): ObservedDeferredEnrichmentPromise<T> => {
|
|
207
|
-
let settledOutcome: DeferredEnrichmentOutcome<T> | undefined;
|
|
208
|
-
const observed = promise
|
|
209
|
-
.then<DeferredEnrichmentOutcome<T>, DeferredEnrichmentOutcome<T>>(
|
|
210
|
-
(value) => ({ status: "resolved", value }),
|
|
211
|
-
(error) => ({ status: "rejected", error }),
|
|
212
|
-
)
|
|
213
|
-
.then((outcome) => {
|
|
214
|
-
settledOutcome = outcome;
|
|
215
|
-
return outcome;
|
|
216
|
-
}) as ObservedDeferredEnrichmentPromise<T>;
|
|
217
|
-
observed.getSettledOutcome = () => settledOutcome;
|
|
218
|
-
observed.cancel = cancel;
|
|
219
|
-
return observed;
|
|
220
|
-
};
|
|
221
179
|
const recordRecallSectionMetric = createRecallSectionMetricRecorder({
|
|
222
180
|
timings,
|
|
223
181
|
logger: log,
|
|
@@ -548,7 +506,7 @@ export class RecallInternalCoordinator {
|
|
|
548
506
|
const earlySessionKey = sessionKey ?? "default";
|
|
549
507
|
this.deps._recallWorkspaceOverrides.delete(earlySessionKey);
|
|
550
508
|
timings.total = `${Date.now() - recallStart}ms`;
|
|
551
|
-
|
|
509
|
+
emitRecallTiming(this.deps.config, {
|
|
552
510
|
...timings,
|
|
553
511
|
timestamp: new Date().toISOString(),
|
|
554
512
|
namespace: selfNamespace,
|
|
@@ -1487,6 +1445,7 @@ export class RecallInternalCoordinator {
|
|
|
1487
1445
|
return results.length > 0 ? this.deps.formatTrustZoneResults(results) : null;
|
|
1488
1446
|
})();
|
|
1489
1447
|
|
|
1448
|
+
const harmonicStartedMs = performance.now();
|
|
1490
1449
|
const harmonicRetrievalAbort = createEnrichmentAbortHandle(
|
|
1491
1450
|
options.abortSignal,
|
|
1492
1451
|
);
|
|
@@ -1835,6 +1794,7 @@ export class RecallInternalCoordinator {
|
|
|
1835
1794
|
return results.length > 0 ? this.deps.formatWorkProductResults(results) : null;
|
|
1836
1795
|
})();
|
|
1837
1796
|
|
|
1797
|
+
const prefilterStartedMs = performance.now();
|
|
1838
1798
|
const queryAwarePrefilterPromise =
|
|
1839
1799
|
(async (): Promise<QueryAwarePrefilter> => {
|
|
1840
1800
|
const t0 = Date.now();
|
|
@@ -2698,6 +2658,7 @@ export class RecallInternalCoordinator {
|
|
|
2698
2658
|
}
|
|
2699
2659
|
})();
|
|
2700
2660
|
|
|
2661
|
+
const compoundingStartedMs = performance.now();
|
|
2701
2662
|
const compoundingPromise = observeEnrichmentPromise(
|
|
2702
2663
|
(async (): Promise<string | null> => {
|
|
2703
2664
|
const t0 = Date.now();
|
|
@@ -2889,6 +2850,7 @@ export class RecallInternalCoordinator {
|
|
|
2889
2850
|
const awaitEnrichmentSection = async <T>(
|
|
2890
2851
|
name: string,
|
|
2891
2852
|
promise: ObservedDeferredEnrichmentPromise<T>,
|
|
2853
|
+
onStatus?: (status: Phase2AwaitStatus) => void,
|
|
2892
2854
|
): Promise<T | null> => {
|
|
2893
2855
|
const finalizeEnrichmentOutcome = (
|
|
2894
2856
|
outcome: DeferredEnrichmentOutcome<T>,
|
|
@@ -2897,6 +2859,7 @@ export class RecallInternalCoordinator {
|
|
|
2897
2859
|
log.debug(
|
|
2898
2860
|
`recall phase-1 enrichment [${name}]: resolved at +${Date.now() - phase1Start}ms`,
|
|
2899
2861
|
);
|
|
2862
|
+
onStatus?.("ok");
|
|
2900
2863
|
return outcome.value;
|
|
2901
2864
|
}
|
|
2902
2865
|
|
|
@@ -2904,12 +2867,14 @@ export class RecallInternalCoordinator {
|
|
|
2904
2867
|
log.debug(
|
|
2905
2868
|
`recall phase-1 enrichment [${name}]: skipped after abort at +${Date.now() - phase1Start}ms`,
|
|
2906
2869
|
);
|
|
2870
|
+
onStatus?.("skipped");
|
|
2907
2871
|
return null;
|
|
2908
2872
|
}
|
|
2909
2873
|
log.warn(
|
|
2910
2874
|
`recall phase-1 enrichment [${name}] failed open: ` +
|
|
2911
2875
|
`${outcome.error instanceof Error ? outcome.error.message : String(outcome.error)}`,
|
|
2912
2876
|
);
|
|
2877
|
+
onStatus?.("error");
|
|
2913
2878
|
return null;
|
|
2914
2879
|
};
|
|
2915
2880
|
|
|
@@ -2918,6 +2883,7 @@ export class RecallInternalCoordinator {
|
|
|
2918
2883
|
log.debug(
|
|
2919
2884
|
`recall phase-1 enrichment [${name}]: skipped after abort at +${Date.now() - phase1Start}ms`,
|
|
2920
2885
|
);
|
|
2886
|
+
onStatus?.("skipped");
|
|
2921
2887
|
return null;
|
|
2922
2888
|
}
|
|
2923
2889
|
|
|
@@ -2940,6 +2906,7 @@ export class RecallInternalCoordinator {
|
|
|
2940
2906
|
`at +${Date.now() - phase1Start}ms`,
|
|
2941
2907
|
);
|
|
2942
2908
|
promise.cancel();
|
|
2909
|
+
onStatus?.("timeout");
|
|
2943
2910
|
return null;
|
|
2944
2911
|
}
|
|
2945
2912
|
|
|
@@ -2962,6 +2929,7 @@ export class RecallInternalCoordinator {
|
|
|
2962
2929
|
`at +${Date.now() - phase1Start}ms`,
|
|
2963
2930
|
);
|
|
2964
2931
|
promise.cancel();
|
|
2932
|
+
onStatus?.("timeout");
|
|
2965
2933
|
return null;
|
|
2966
2934
|
}
|
|
2967
2935
|
|
|
@@ -4768,9 +4736,11 @@ export class RecallInternalCoordinator {
|
|
|
4768
4736
|
}
|
|
4769
4737
|
const phase2AfterQmdMs = Date.now() - recallStart;
|
|
4770
4738
|
|
|
4771
|
-
const harmonicRetrievalSection = await
|
|
4772
|
-
"
|
|
4773
|
-
|
|
4739
|
+
const harmonicRetrievalSection = await phase2Timer.enrichment(
|
|
4740
|
+
"Harmonic",
|
|
4741
|
+
harmonicStartedMs,
|
|
4742
|
+
() => timings.harmonicRetrieval?.startsWith("skip") === true,
|
|
4743
|
+
(onStatus) => awaitEnrichmentSection("harmonic", harmonicRetrievalPromise, onStatus),
|
|
4774
4744
|
);
|
|
4775
4745
|
if (harmonicRetrievalSection) {
|
|
4776
4746
|
this.deps.appendRecallSection(
|
|
@@ -4794,35 +4764,39 @@ export class RecallInternalCoordinator {
|
|
|
4794
4764
|
if (!graphDecisionReason) {
|
|
4795
4765
|
graphDecisionReason = graphSnapshotReason;
|
|
4796
4766
|
}
|
|
4797
|
-
|
|
4767
|
+
const persistedGraphSnapshotStatus = graphSnapshotStatus;
|
|
4768
|
+
await phase2Timer.step("GraphSnapshot", () => this.deps.recordLastGraphRecallSnapshot({
|
|
4798
4769
|
storage: profileStorage,
|
|
4799
4770
|
prompt: retrievalQuery,
|
|
4800
4771
|
recallMode,
|
|
4801
4772
|
recallNamespaces,
|
|
4802
4773
|
seedPaths: graphSnapshotSeedPaths,
|
|
4803
4774
|
expandedPaths: graphSnapshotExpandedPaths,
|
|
4804
|
-
status:
|
|
4775
|
+
status: persistedGraphSnapshotStatus,
|
|
4805
4776
|
reason: graphSnapshotReason,
|
|
4806
4777
|
shadowMode: graphDecisionShadowMode,
|
|
4807
4778
|
queryIntent,
|
|
4808
4779
|
seedResults: graphSnapshotSeedResults,
|
|
4809
4780
|
finalResults: graphSnapshotFinalResults,
|
|
4810
4781
|
shadowComparison: graphSnapshotShadowComparison,
|
|
4811
|
-
});
|
|
4782
|
+
}));
|
|
4783
|
+
} else {
|
|
4784
|
+
phase2Timer.skipped("GraphSnapshot");
|
|
4812
4785
|
}
|
|
4813
|
-
await this.deps.recordLastIntentSnapshot({
|
|
4786
|
+
await phase2Timer.step("IntentSnapshot", () => this.deps.recordLastIntentSnapshot({
|
|
4814
4787
|
storage: profileStorage,
|
|
4815
4788
|
snapshot: buildIntentDebugSnapshot(),
|
|
4816
|
-
});
|
|
4789
|
+
}));
|
|
4817
4790
|
// 2.5. Compression guideline recall section (v8.11 Task 5)
|
|
4818
|
-
|
|
4819
|
-
|
|
4820
|
-
|
|
4821
|
-
|
|
4822
|
-
|
|
4823
|
-
|
|
4824
|
-
|
|
4825
|
-
|
|
4791
|
+
const compressionEnabled = this.deps.isRecallSectionEnabled(
|
|
4792
|
+
"compression-guidelines",
|
|
4793
|
+
resolveCompressionCapabilities(this.deps.config).compressionGuidelineLearning === true,
|
|
4794
|
+
);
|
|
4795
|
+
if (compressionEnabled) {
|
|
4796
|
+
const compressionGuidelineSection = await phase2Timer.step(
|
|
4797
|
+
"Compression",
|
|
4798
|
+
() => this.deps.buildCompressionGuidelineRecallSection(),
|
|
4799
|
+
);
|
|
4826
4800
|
if (compressionGuidelineSection) {
|
|
4827
4801
|
this.deps.appendRecallSection(
|
|
4828
4802
|
sectionBuckets,
|
|
@@ -4830,6 +4804,8 @@ export class RecallInternalCoordinator {
|
|
|
4830
4804
|
compressionGuidelineSection,
|
|
4831
4805
|
);
|
|
4832
4806
|
}
|
|
4807
|
+
} else {
|
|
4808
|
+
phase2Timer.skipped("Compression");
|
|
4833
4809
|
}
|
|
4834
4810
|
// 3. Transcript/summaries/conversation/compounding are fetched in parallel above,
|
|
4835
4811
|
// then assembled here according to recallPipeline order.
|
|
@@ -4854,9 +4830,11 @@ export class RecallInternalCoordinator {
|
|
|
4854
4830
|
conversationRecallSection,
|
|
4855
4831
|
);
|
|
4856
4832
|
}
|
|
4857
|
-
const compoundingSection = await
|
|
4858
|
-
"
|
|
4859
|
-
|
|
4833
|
+
const compoundingSection = await phase2Timer.enrichment(
|
|
4834
|
+
"Compounding",
|
|
4835
|
+
compoundingStartedMs,
|
|
4836
|
+
() => timings.compounding?.startsWith("skip") === true,
|
|
4837
|
+
(onStatus) => awaitEnrichmentSection("compounding", compoundingPromise, onStatus),
|
|
4860
4838
|
);
|
|
4861
4839
|
if (compoundingSection) {
|
|
4862
4840
|
this.deps.appendRecallSection(
|
|
@@ -4866,10 +4844,14 @@ export class RecallInternalCoordinator {
|
|
|
4866
4844
|
);
|
|
4867
4845
|
}
|
|
4868
4846
|
let curiosityFooter: string | undefined, curiosityQuestionSelected = false, curiosityFooterTruncated = false;
|
|
4869
|
-
const
|
|
4870
|
-
this.deps.isRecallSectionEnabled("questions", true)
|
|
4871
|
-
|
|
4847
|
+
const questionsEnabled = this.deps.config.injectQuestions &&
|
|
4848
|
+
this.deps.isRecallSectionEnabled("questions", true);
|
|
4849
|
+
const topQuestion = questionsEnabled
|
|
4850
|
+
? selectCuriosityQuestion(
|
|
4851
|
+
await phase2Timer.step("Questions", () => profileStorage.readQuestions({ unresolvedOnly: true })),
|
|
4852
|
+
)
|
|
4872
4853
|
: undefined;
|
|
4854
|
+
if (!questionsEnabled) phase2Timer.skipped("Questions");
|
|
4873
4855
|
if (topQuestion) {
|
|
4874
4856
|
curiosityQuestionSelected = true;
|
|
4875
4857
|
const formattedFooter = formatCuriosityFooter(topQuestion);
|
|
@@ -4882,7 +4864,12 @@ export class RecallInternalCoordinator {
|
|
|
4882
4864
|
}
|
|
4883
4865
|
}
|
|
4884
4866
|
const phase2QuestionsDoneMs = Date.now() - recallStart;
|
|
4885
|
-
const finalizedQueryAwarePrefilter = await
|
|
4867
|
+
const finalizedQueryAwarePrefilter = await phase2Timer.enrichment(
|
|
4868
|
+
"Prefilter",
|
|
4869
|
+
prefilterStartedMs,
|
|
4870
|
+
() => timings.queryAware?.startsWith("skip") === true,
|
|
4871
|
+
() => queryAwarePrefilterPromise,
|
|
4872
|
+
);
|
|
4886
4873
|
const phase2QapDoneMs = Date.now() - recallStart;
|
|
4887
4874
|
throwIfRecallAborted(options.abortSignal);
|
|
4888
4875
|
if (
|
|
@@ -4904,8 +4891,9 @@ export class RecallInternalCoordinator {
|
|
|
4904
4891
|
.map(([k, v]) => `${k}=${v}`)
|
|
4905
4892
|
.join(", ");
|
|
4906
4893
|
log.info(`recall timings: ${timingParts}`);
|
|
4907
|
-
|
|
4894
|
+
emitRecallTiming(this.deps.config, {
|
|
4908
4895
|
...timings,
|
|
4896
|
+
...phase2Timings,
|
|
4909
4897
|
timestamp: new Date().toISOString(),
|
|
4910
4898
|
namespace: selfNamespace,
|
|
4911
4899
|
total: timings.total,
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
+
import { randomUUID } from "node:crypto";
|
|
3
|
+
|
|
4
|
+
import { isAbortError } from "./abort-error.js";
|
|
5
|
+
import { currentCorrelationId } from "./access-correlation.js";
|
|
6
|
+
import {
|
|
7
|
+
recordRecallTiming,
|
|
8
|
+
type RecallTimingEmission,
|
|
9
|
+
type RecallTimingOutcome,
|
|
10
|
+
} from "./recall-timings.js";
|
|
11
|
+
import type { PluginConfig } from "./types.js";
|
|
12
|
+
|
|
13
|
+
// Receives the recall pipeline's per-phase timing payload for the attempt in
|
|
14
|
+
// flight, so the attempt's single record (requestId + outcome + httpTotalMs +
|
|
15
|
+
// phases) is pushed once, from recordRecallAttempt's `finally`. Scoped per
|
|
16
|
+
// attempt via AsyncLocalStorage: no recall option or signature carries it.
|
|
17
|
+
const attemptSinkStore = new AsyncLocalStorage<(payload: RecallTimingEmission) => void>();
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Pipeline side. Inside a recorded attempt the payload folds into that
|
|
21
|
+
* attempt's record; outside one (x-ray, daemon hooks, direct orchestrator
|
|
22
|
+
* callers) it keeps the legacy success-only push.
|
|
23
|
+
*/
|
|
24
|
+
export function emitRecallTiming(config: PluginConfig, payload: RecallTimingEmission): void {
|
|
25
|
+
const sink = attemptSinkStore.getStore();
|
|
26
|
+
if (sink) {
|
|
27
|
+
sink(payload);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
recordRecallTiming(config, payload);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Run one executed recall and leave exactly one timing record for it, pushed
|
|
35
|
+
* in `finally` so denials, disconnects and assembly failures carry the same
|
|
36
|
+
* trail as successes. `requestId` is the HTTP request's server-generated
|
|
37
|
+
* correlation id (x-request-id); outside HTTP dispatch it falls back to a
|
|
38
|
+
* generated `local:<uuid>` id in the same field, so a record says whether it
|
|
39
|
+
* has an HTTP request behind it. Never derived from client input.
|
|
40
|
+
*/
|
|
41
|
+
export async function recordRecallAttempt<T>(
|
|
42
|
+
config: PluginConfig,
|
|
43
|
+
abortSignal: AbortSignal | undefined,
|
|
44
|
+
run: () => Promise<T>,
|
|
45
|
+
): Promise<T> {
|
|
46
|
+
const requestId = currentCorrelationId() ?? `local:${randomUUID()}`;
|
|
47
|
+
const startedMs = performance.now();
|
|
48
|
+
const emitted: RecallTimingEmission[] = [];
|
|
49
|
+
let failure: { abortError: boolean } | undefined;
|
|
50
|
+
try {
|
|
51
|
+
return await attemptSinkStore.run((payload) => {
|
|
52
|
+
emitted.push(payload);
|
|
53
|
+
}, run);
|
|
54
|
+
} catch (err) {
|
|
55
|
+
failure = { abortError: isAbortError(err) };
|
|
56
|
+
throw err;
|
|
57
|
+
} finally {
|
|
58
|
+
const phases = emitted.at(-1);
|
|
59
|
+
// aborted: the request/flight signal fired, or an abort error was thrown
|
|
60
|
+
// (the pipeline's soft abort returns normally with the signal already
|
|
61
|
+
// aborted). error: any other throw, or a normal return from a pipeline
|
|
62
|
+
// that never reached its timing emit (the entry coordinator swallows
|
|
63
|
+
// outer timeouts, init-gate aborts and internal failures into a degraded
|
|
64
|
+
// context). ok: the pipeline ran to completion.
|
|
65
|
+
const outcome: RecallTimingOutcome =
|
|
66
|
+
abortSignal?.aborted === true || failure?.abortError === true
|
|
67
|
+
? "aborted"
|
|
68
|
+
: failure !== undefined || phases === undefined
|
|
69
|
+
? "error"
|
|
70
|
+
: "ok";
|
|
71
|
+
recordRecallTiming(config, {
|
|
72
|
+
...phases,
|
|
73
|
+
requestId,
|
|
74
|
+
outcome,
|
|
75
|
+
httpTotalMs: performance.now() - startedMs,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export type DeferredEnrichmentOutcome<T> =
|
|
2
|
+
| { status: "resolved"; value: T }
|
|
3
|
+
| { status: "rejected"; error: unknown };
|
|
4
|
+
|
|
5
|
+
export type ObservedDeferredEnrichmentPromise<T> =
|
|
6
|
+
Promise<DeferredEnrichmentOutcome<T>> & {
|
|
7
|
+
getSettledOutcome: () => DeferredEnrichmentOutcome<T> | undefined;
|
|
8
|
+
cancel: () => void;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
/** Cancelable child abort signal owned by one enrichment promise. */
|
|
12
|
+
export interface EnrichmentAbortHandle {
|
|
13
|
+
signal: AbortSignal;
|
|
14
|
+
cancel: () => void;
|
|
15
|
+
dispose: () => void;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** Child abort controller that follows `parentSignal`; `dispose` detaches the listener. */
|
|
19
|
+
export function createEnrichmentAbortHandle(parentSignal?: AbortSignal): EnrichmentAbortHandle {
|
|
20
|
+
const controller = new AbortController();
|
|
21
|
+
const onAbort = () => controller.abort();
|
|
22
|
+
if (parentSignal?.aborted) {
|
|
23
|
+
controller.abort();
|
|
24
|
+
} else if (parentSignal) {
|
|
25
|
+
parentSignal.addEventListener("abort", onAbort, { once: true });
|
|
26
|
+
}
|
|
27
|
+
let disposed = false;
|
|
28
|
+
const dispose = () => {
|
|
29
|
+
if (disposed) return;
|
|
30
|
+
disposed = true;
|
|
31
|
+
parentSignal?.removeEventListener("abort", onAbort);
|
|
32
|
+
};
|
|
33
|
+
return {
|
|
34
|
+
signal: controller.signal,
|
|
35
|
+
cancel: () => {
|
|
36
|
+
controller.abort();
|
|
37
|
+
dispose();
|
|
38
|
+
},
|
|
39
|
+
dispose,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Never-rejecting view of `promise` that also exposes its settled outcome and a cancel hook. */
|
|
44
|
+
export function observeEnrichmentPromise<T>(
|
|
45
|
+
promise: Promise<T>,
|
|
46
|
+
cancel: () => void = () => {},
|
|
47
|
+
): ObservedDeferredEnrichmentPromise<T> {
|
|
48
|
+
let settledOutcome: DeferredEnrichmentOutcome<T> | undefined;
|
|
49
|
+
const settled = promise
|
|
50
|
+
.then<DeferredEnrichmentOutcome<T>, DeferredEnrichmentOutcome<T>>(
|
|
51
|
+
(value) => ({ status: "resolved", value }),
|
|
52
|
+
(error) => ({ status: "rejected", error }),
|
|
53
|
+
)
|
|
54
|
+
.then((outcome) => {
|
|
55
|
+
settledOutcome = outcome;
|
|
56
|
+
return outcome;
|
|
57
|
+
});
|
|
58
|
+
return Object.assign(settled, {
|
|
59
|
+
getSettledOutcome: () => settledOutcome,
|
|
60
|
+
cancel,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phase-2 await timing fields for the recall-timings attempt record (issue
|
|
3
|
+
* #1830). Each instrumented phase-2 await contributes three optionally-named
|
|
4
|
+
* fields: `phase2<Name>Ms` (monotonic elapsed of the await itself),
|
|
5
|
+
* `phase2<Name>Status` (ok | timeout | error | skipped), and — for promises
|
|
6
|
+
* started earlier in phase 1 and awaited later — `phase2<Name>TotalMs`
|
|
7
|
+
* (monotonic time since the promise was created). The await fields are
|
|
8
|
+
* OVERLAPPING, not additive: awaits of promises started earlier include time
|
|
9
|
+
* spent doing other phase-2 work.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export type Phase2AwaitStatus = "ok" | "timeout" | "error" | "skipped";
|
|
13
|
+
|
|
14
|
+
export const PHASE2_AWAIT_NAMES = [
|
|
15
|
+
"Harmonic",
|
|
16
|
+
"GraphSnapshot",
|
|
17
|
+
"IntentSnapshot",
|
|
18
|
+
"Compression",
|
|
19
|
+
"Compounding",
|
|
20
|
+
"Questions",
|
|
21
|
+
"Prefilter",
|
|
22
|
+
] as const;
|
|
23
|
+
|
|
24
|
+
export type Phase2AwaitName = (typeof PHASE2_AWAIT_NAMES)[number];
|
|
25
|
+
|
|
26
|
+
/** Awaits of promises started earlier in phase 1; their await time overlaps earlier work. */
|
|
27
|
+
export const PHASE2_AWAIT_TOTAL_NAMES: readonly Phase2AwaitName[] = [
|
|
28
|
+
"Harmonic",
|
|
29
|
+
"Compounding",
|
|
30
|
+
"Prefilter",
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
export const PHASE2_AWAIT_STATUSES: readonly Phase2AwaitStatus[] = [
|
|
34
|
+
"ok",
|
|
35
|
+
"timeout",
|
|
36
|
+
"error",
|
|
37
|
+
"skipped",
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
export function phase2MsField(name: Phase2AwaitName): string {
|
|
41
|
+
return `phase2${name}Ms`;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function phase2StatusField(name: Phase2AwaitName): string {
|
|
45
|
+
return `phase2${name}Status`;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function phase2TotalField(name: Phase2AwaitName): string {
|
|
49
|
+
return `phase2${name}TotalMs`;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface Phase2AwaitTiming {
|
|
53
|
+
status: Phase2AwaitStatus;
|
|
54
|
+
/** Monotonic elapsed ms of the await itself (measured at the await site). */
|
|
55
|
+
ms: number;
|
|
56
|
+
/** Monotonic ms since the awaited promise was created (started-earlier awaits only). */
|
|
57
|
+
totalMs?: number;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Fold one await's timing into the recall pipeline's flat timing payload. Values stay string-encoded ("12ms") so the recall-timings sanitizer parses them like every other phase. */
|
|
61
|
+
export function recordPhase2Await(
|
|
62
|
+
sink: Record<string, string>,
|
|
63
|
+
name: Phase2AwaitName,
|
|
64
|
+
timing: Phase2AwaitTiming,
|
|
65
|
+
): void {
|
|
66
|
+
sink[phase2MsField(name)] = `${Math.max(0, Math.round(timing.ms))}ms`;
|
|
67
|
+
sink[phase2StatusField(name)] = timing.status;
|
|
68
|
+
if (timing.totalMs !== undefined) {
|
|
69
|
+
sink[phase2TotalField(name)] = `${Math.max(0, Math.round(timing.totalMs))}ms`;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface Phase2Timer {
|
|
74
|
+
/** Time one direct phase-2 await. A throw is re-thrown unchanged after its status is recorded. */
|
|
75
|
+
step<T>(name: Phase2AwaitName, run: () => Promise<T>): Promise<T>;
|
|
76
|
+
/** Record a phase-2 await that did not run (section disabled): 0 ms, status skipped. */
|
|
77
|
+
skipped(name: Phase2AwaitName): void;
|
|
78
|
+
/**
|
|
79
|
+
* Time one await of an enrichment promise started earlier (`startedMs` is its
|
|
80
|
+
* performance.now() creation time). `run` reports the await's own outcome
|
|
81
|
+
* through `onStatus`; `isSkipped` is read after the await so a section that
|
|
82
|
+
* skipped itself (disabled / limit 0) is recorded as skipped, not ok.
|
|
83
|
+
*/
|
|
84
|
+
enrichment<T>(
|
|
85
|
+
name: Phase2AwaitName,
|
|
86
|
+
startedMs: number,
|
|
87
|
+
isSkipped: () => boolean,
|
|
88
|
+
run: (onStatus: (status: Phase2AwaitStatus) => void) => Promise<T>,
|
|
89
|
+
): Promise<T>;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** Per-recall phase-2 await timer; all durations are performance.now() deltas, never wall clock. */
|
|
93
|
+
export function createPhase2Timer(
|
|
94
|
+
sink: Record<string, string>,
|
|
95
|
+
isAborted: () => boolean,
|
|
96
|
+
): Phase2Timer {
|
|
97
|
+
return {
|
|
98
|
+
async step<T>(name: Phase2AwaitName, run: () => Promise<T>): Promise<T> {
|
|
99
|
+
const awaitStartMs = performance.now();
|
|
100
|
+
try {
|
|
101
|
+
const value = await run();
|
|
102
|
+
recordPhase2Await(sink, name, { status: "ok", ms: performance.now() - awaitStartMs });
|
|
103
|
+
return value;
|
|
104
|
+
} catch (err) {
|
|
105
|
+
recordPhase2Await(sink, name, {
|
|
106
|
+
status: isAborted() ? "skipped" : "error",
|
|
107
|
+
ms: performance.now() - awaitStartMs,
|
|
108
|
+
});
|
|
109
|
+
throw err;
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
skipped(name: Phase2AwaitName): void {
|
|
113
|
+
recordPhase2Await(sink, name, { status: "skipped", ms: 0 });
|
|
114
|
+
},
|
|
115
|
+
async enrichment<T>(
|
|
116
|
+
name: Phase2AwaitName,
|
|
117
|
+
startedMs: number,
|
|
118
|
+
isSkipped: () => boolean,
|
|
119
|
+
run: (onStatus: (status: Phase2AwaitStatus) => void) => Promise<T>,
|
|
120
|
+
): Promise<T> {
|
|
121
|
+
const awaitStartMs = performance.now();
|
|
122
|
+
const reported: Phase2AwaitStatus[] = [];
|
|
123
|
+
let threw = false;
|
|
124
|
+
try {
|
|
125
|
+
return await run((status) => {
|
|
126
|
+
reported.push(status);
|
|
127
|
+
});
|
|
128
|
+
} catch (err) {
|
|
129
|
+
threw = true;
|
|
130
|
+
throw err;
|
|
131
|
+
} finally {
|
|
132
|
+
const nowMs = performance.now();
|
|
133
|
+
const status: Phase2AwaitStatus = threw
|
|
134
|
+
? (isAborted() ? "skipped" : "error")
|
|
135
|
+
: (reported.at(-1) ?? "ok");
|
|
136
|
+
recordPhase2Await(
|
|
137
|
+
sink,
|
|
138
|
+
name,
|
|
139
|
+
status === "ok" && isSkipped()
|
|
140
|
+
? { status: "skipped", ms: 0, totalMs: 0 }
|
|
141
|
+
: { status, ms: nowMs - awaitStartMs, totalMs: nowMs - startedMs },
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
};
|
|
146
|
+
}
|