@remnic/core 10.0.194 → 10.0.196
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 +65 -66
- package/dist/access-cli.js +65 -66
- package/dist/access-cli.js.map +1 -1
- package/dist/access-coding-context-resolution.js +2 -2
- package/dist/access-extraction-force-flush-preempt.js +65 -66
- package/dist/access-extraction-force-flush.js +65 -66
- package/dist/access-http-briefing.js +65 -66
- package/dist/access-http-query.js +65 -66
- package/dist/access-http.js +65 -66
- package/dist/access-identity-continuity-surface.js +65 -66
- package/dist/access-lcm-surface.js +65 -66
- package/dist/access-mcp.d.ts.map +1 -1
- package/dist/access-mcp.js +65 -66
- package/dist/access-observe-write-category.js +2 -2
- package/dist/access-observe-write-surface.js +65 -66
- package/dist/access-operations-batch.js +65 -66
- package/dist/access-operations.js +65 -66
- package/dist/access-recall-concurrency.d.ts +4 -0
- package/dist/access-recall-concurrency.d.ts.map +1 -1
- package/dist/access-recall-concurrency.js +65 -66
- package/dist/access-recall-diagnostics.js +2 -2
- package/dist/access-recall-response.d.ts.map +1 -1
- package/dist/access-recall-response.js +65 -66
- package/dist/access-recall-surface.d.ts.map +1 -1
- package/dist/access-recall-surface.js +65 -66
- package/dist/access-schema.d.ts +1 -0
- package/dist/access-schema.d.ts.map +1 -1
- package/dist/access-schema.js +1 -1
- package/dist/access-service.d.ts.map +1 -1
- package/dist/access-service.js +65 -66
- package/dist/active-recall.js +7 -6
- package/dist/active-recall.js.map +1 -1
- package/dist/{auto-sync-BJUAGKI5.js → auto-sync-BEW65FDT.js} +6 -5
- package/dist/{auto-sync-BJUAGKI5.js.map → auto-sync-BEW65FDT.js.map} +1 -1
- package/dist/briefing.js +7 -6
- package/dist/buffer.d.ts +1 -0
- package/dist/buffer.d.ts.map +1 -1
- package/dist/buffer.js +3 -3
- package/dist/calibration.js +5 -4
- package/dist/calibration.js.map +1 -1
- package/dist/causal-consolidation.js +8 -7
- package/dist/causal-consolidation.js.map +1 -1
- package/dist/{chunk-FZU62GIV.js → chunk-2X5I5C3M.js} +27 -10
- package/dist/chunk-2X5I5C3M.js.map +1 -0
- package/dist/{chunk-F2MVWUNF.js → chunk-374E2HYZ.js} +10 -2
- package/dist/chunk-374E2HYZ.js.map +1 -0
- package/dist/{chunk-3ZS3NUEI.js → chunk-3DSLTUK6.js} +2 -2
- package/dist/{chunk-DYUPSTCV.js → chunk-3EXG2KPK.js} +3 -3
- package/dist/{chunk-FGFU6J26.js → chunk-4FTYKZ77.js} +3 -3
- package/dist/{chunk-QIPRDRGM.js → chunk-4HEJDVPU.js} +1 -1
- package/dist/chunk-4HEJDVPU.js.map +1 -0
- package/dist/{chunk-EEA2RM4B.js → chunk-4I6A3SDL.js} +2 -2
- package/dist/{chunk-SKJM4PKE.js → chunk-4JI5PPFW.js} +2 -2
- package/dist/{chunk-TDG5NZAZ.js → chunk-65JA7LWV.js} +2 -2
- package/dist/{chunk-3YID7KZ6.js → chunk-6QMKUWXH.js} +2 -2
- package/dist/{chunk-7SOKOEAZ.js → chunk-6RRHTHKQ.js} +2 -2
- package/dist/{chunk-VHQNJW4Q.js → chunk-6W62D4MC.js} +2 -2
- package/dist/{chunk-CRS2NY44.js → chunk-7O6H7BPW.js} +2 -2
- package/dist/{chunk-VSLV3EEP.js → chunk-7TK5Q6LQ.js} +112 -81
- package/dist/chunk-7TK5Q6LQ.js.map +1 -0
- package/dist/{chunk-NN3LMWKA.js → chunk-7TQ3EDQ3.js} +1 -1
- package/dist/chunk-7TQ3EDQ3.js.map +1 -0
- package/dist/{chunk-KJ65WZHB.js → chunk-A7DIZOTF.js} +2 -2
- package/dist/{chunk-TZ7ZA2LM.js → chunk-AD3JOG2Q.js} +2 -2
- package/dist/{chunk-2QW5HPKU.js → chunk-AUDLHIHI.js} +35 -28
- package/dist/chunk-AUDLHIHI.js.map +1 -0
- package/dist/{chunk-BDFSVUUZ.js → chunk-C3H2QZOZ.js} +2 -1
- package/dist/chunk-C3H2QZOZ.js.map +1 -0
- package/dist/{chunk-7EP4FURO.js → chunk-C72YQM7E.js} +2 -2
- package/dist/{chunk-4EAVEDLG.js → chunk-CRKT2JXN.js} +9 -9
- package/dist/{chunk-CJSTQNE5.js → chunk-CTOMDCCA.js} +2 -2
- package/dist/{chunk-PSQ347YP.js → chunk-DSKII2W4.js} +3 -3
- package/dist/{chunk-KOVQZJ27.js → chunk-E7LDTUWK.js} +2 -2
- package/dist/{chunk-SPAKBUJY.js → chunk-EWLMEYLF.js} +2 -2
- package/dist/{chunk-JJ42IDJU.js → chunk-FEGQI5KR.js} +2 -2
- package/dist/{chunk-3BICT225.js → chunk-FGNBUUPX.js} +2 -2
- package/dist/{chunk-QZMGZBTF.js → chunk-HBG6CQEX.js} +2 -2
- package/dist/{chunk-7V6GNQC2.js → chunk-HINQENZG.js} +2 -2
- package/dist/{chunk-WRVKI6ZO.js → chunk-HLQXSX4F.js} +2 -2
- package/dist/{chunk-KQIOW3TG.js → chunk-HUDE2SQA.js} +2 -2
- package/dist/{chunk-T765HQ5U.js → chunk-IIDAN7XJ.js} +2 -2
- package/dist/{chunk-M7Q7Z6V5.js → chunk-JDZ5JPYG.js} +38 -8
- package/dist/chunk-JDZ5JPYG.js.map +1 -0
- package/dist/{chunk-VMNX2UV7.js → chunk-JRUOIEFL.js} +5 -5
- package/dist/{chunk-JKMIGCK6.js → chunk-KDGEEZOI.js} +3 -2
- package/dist/chunk-KDGEEZOI.js.map +1 -0
- package/dist/{chunk-MMRTPH3J.js → chunk-KQYGUFMQ.js} +5 -3
- package/dist/chunk-KQYGUFMQ.js.map +1 -0
- package/dist/{chunk-TWYYUMYO.js → chunk-KXAGZRJV.js} +2 -2
- package/dist/{chunk-JITK24KX.js → chunk-LJNCJK7B.js} +10 -10
- package/dist/{chunk-Z6EFSXU3.js → chunk-LMM2LRVQ.js} +2 -2
- package/dist/{chunk-V65H7MI6.js → chunk-M42UFQZY.js} +51 -4
- package/dist/chunk-M42UFQZY.js.map +1 -0
- package/dist/{chunk-KZ4BJRGQ.js → chunk-ODGVLSCQ.js} +2 -2
- package/dist/{chunk-AALJHIKH.js → chunk-OHJ5PNYB.js} +3 -3
- package/dist/{chunk-XZMQLON4.js → chunk-OK726OF4.js} +7 -5
- package/dist/chunk-OK726OF4.js.map +1 -0
- package/dist/{chunk-Q6S67LHR.js → chunk-OOMFFMX3.js} +2 -2
- package/dist/{chunk-YCJJODER.js → chunk-PNDTRIOI.js} +10 -3
- package/dist/chunk-PNDTRIOI.js.map +1 -0
- package/dist/{chunk-3RZ4GDOH.js → chunk-PX4AMRAN.js} +93 -23
- package/dist/chunk-PX4AMRAN.js.map +1 -0
- package/dist/{chunk-JNDMIAJ4.js → chunk-QEVZKJM6.js} +2 -2
- package/dist/{chunk-ZNCCX7P6.js → chunk-QO5QZR2U.js} +2 -2
- package/dist/{chunk-NFQKIZK3.js → chunk-QXEF66SC.js} +2 -2
- package/dist/{chunk-NKHRIDYP.js → chunk-RTXW6E6X.js} +3 -3
- package/dist/{chunk-5WDUY2ZZ.js → chunk-S4QWAWR6.js} +4 -4
- package/dist/{chunk-HEJFE3BC.js → chunk-SJCN7ESG.js} +2 -2
- package/dist/{chunk-AJ7JHHRY.js → chunk-SPPWVMP4.js} +2 -2
- package/dist/{chunk-QSF5SJAM.js → chunk-STQNKDKZ.js} +9 -3
- package/dist/chunk-STQNKDKZ.js.map +1 -0
- package/dist/{chunk-QFKNIKUF.js → chunk-SXR7L57Z.js} +2 -2
- package/dist/{chunk-GYCUX3N4.js → chunk-TGMIJABS.js} +2 -2
- package/dist/{chunk-GH7IKABD.js → chunk-UFJJMQDV.js} +2 -2
- package/dist/{chunk-FKHXXL42.js → chunk-VAE6QCZQ.js} +2 -2
- package/dist/{chunk-UH2VY2QQ.js → chunk-WCW7I7ZM.js} +2 -2
- package/dist/{chunk-5GIYIYJI.js → chunk-WLP3XJCO.js} +2 -2
- package/dist/{chunk-STSORBX5.js → chunk-XII23FXP.js} +1 -1
- package/dist/chunk-XII23FXP.js.map +1 -0
- package/dist/{chunk-LR6LWX33.js → chunk-XXDIPAUE.js} +2 -2
- package/dist/{chunk-G2MS56KM.js → chunk-YQUGYQRY.js} +2 -2
- package/dist/{chunk-WEI6HEUX.js → chunk-YXAH5TSN.js} +2 -2
- package/dist/{chunk-75K6DRPN.js → chunk-ZAVFAGBE.js} +2 -2
- package/dist/{chunk-7KTORRIK.js → chunk-ZNJU3NBJ.js} +2 -2
- package/dist/cli.js +65 -66
- package/dist/coding/export-okf-codegraph.js +9 -8
- package/dist/coding/export-okf-codegraph.js.map +1 -1
- package/dist/compounding/engine.js +8 -7
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +7 -6
- package/dist/connectors/codex-materialize-runner.js +7 -6
- package/dist/connectors/index.js +7 -6
- package/dist/convergence-refresh.js +9 -8
- package/dist/corpus-watermark.js +9 -8
- package/dist/deep-recall-http-glue.js +2 -2
- package/dist/deep-recall-policy-llm.js +4 -3
- package/dist/entity-retrieval.js +7 -6
- package/dist/eval-trajectory-store.js +2 -2
- package/dist/eval-trajectory.js +2 -2
- package/dist/evals.d.ts.map +1 -1
- package/dist/evals.js +1 -1
- package/dist/explicit-capture.js +65 -66
- package/dist/extraction-error-classification.d.ts +40 -5
- package/dist/extraction-error-classification.d.ts.map +1 -1
- package/dist/extraction-error-classification.js +5 -2
- package/dist/extraction-faithfulness.js +4 -3
- package/dist/extraction-judge.js +4 -3
- package/dist/extraction.d.ts.map +1 -1
- package/dist/extraction.js +17 -18
- package/dist/fallback-llm-codex-subscription.d.ts +3 -1
- package/dist/fallback-llm-codex-subscription.d.ts.map +1 -1
- package/dist/fallback-llm-codex-subscription.js +2 -1
- package/dist/fallback-llm.d.ts.map +1 -1
- package/dist/fallback-llm.js +3 -2
- package/dist/harmonic-retrieval.js +7 -6
- package/dist/index.js +65 -66
- package/dist/live-connectors-runner.js +1 -2
- package/dist/local-llm-helpers.d.ts +1 -0
- package/dist/local-llm-helpers.d.ts.map +1 -1
- package/dist/local-llm-helpers.js +1 -1
- package/dist/local-llm.d.ts.map +1 -1
- package/dist/local-llm.js +4 -3
- package/dist/location/index.js +8 -7
- package/dist/maintenance/memory-governance.js +7 -6
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +7 -6
- package/dist/maintenance/rebuild-memory-projection-runner.js +9 -8
- package/dist/maintenance/rebuild-memory-projection.js +8 -7
- package/dist/memory-browse.js +3 -3
- package/dist/namespaces/migrate.js +8 -7
- package/dist/namespaces/storage.js +7 -6
- package/dist/operator-doctor-corpus.js +10 -9
- package/dist/operator-toolkit.js +15 -14
- package/dist/orchestration/backlog-scheduler.js +66 -67
- package/dist/orchestration/backlog-scheduler.js.map +1 -1
- package/dist/orchestration/buffer-drain-runner.js +66 -67
- package/dist/orchestration/extraction-drain.d.ts +1 -0
- package/dist/orchestration/extraction-drain.d.ts.map +1 -1
- package/dist/orchestration/extraction-run-helpers.d.ts +41 -4
- package/dist/orchestration/extraction-run-helpers.d.ts.map +1 -1
- package/dist/orchestration/extraction-run.d.ts +4 -0
- package/dist/orchestration/extraction-run.d.ts.map +1 -1
- package/dist/orchestration/maintenance.js +17 -16
- package/dist/orchestration/orchestrator-helpers.d.ts +2 -0
- package/dist/orchestration/orchestrator-helpers.d.ts.map +1 -1
- package/dist/orchestration/recall-entry.d.ts +2 -2
- package/dist/orchestration/recall-entry.d.ts.map +1 -1
- package/dist/orchestration/recall-internal.d.ts.map +1 -1
- package/dist/orchestrator.d.ts.map +1 -1
- package/dist/orchestrator.js +65 -66
- package/dist/recall-explain-renderer.js +3 -3
- package/dist/recall-navigate-access.js +2 -2
- package/dist/recall-navigate-disclosure.js +2 -2
- package/dist/recall-navigate.js +2 -2
- package/dist/recall-navigation.js +65 -66
- package/dist/recall-planner-llm.js +3 -2
- package/dist/recall-planner-llm.js.map +1 -1
- package/dist/recall-state-view-admission.js +3 -3
- package/dist/recall-why-service.js +3 -3
- 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/resume-bundles.js +8 -7
- package/dist/semantic-consolidation.js +8 -7
- package/dist/semantic-rule-promotion.js +7 -6
- package/dist/semantic-rule-verifier.js +7 -6
- package/dist/source-agent-qualifier.js +10 -9
- package/dist/standup/build.js +7 -6
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +6 -5
- package/dist/summarizer.js +6 -5
- package/dist/support-passport/index.js +6 -5
- package/dist/transfer/export-okf.js +7 -6
- package/dist/types-extraction-failure.d.ts +7 -1
- package/dist/types-extraction-failure.d.ts.map +1 -1
- package/dist/types.d.ts +6 -6
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -1
- package/dist/verified-recall.js +7 -6
- package/dist/who-knows-cli.js +8 -7
- package/dist/who-knows.js +7 -6
- package/package.json +2 -2
- package/src/access-mcp.ts +8 -0
- package/src/access-recall-concurrency.ts +35 -2
- package/src/access-recall-response.ts +3 -1
- package/src/access-recall-surface.ts +1 -0
- package/src/access-schema.ts +8 -0
- package/src/access-service-recall-concurrency.test.ts +65 -0
- package/src/access-service.ts +4 -3
- package/src/buffer-incremental-persistence.test.ts +23 -0
- package/src/buffer.ts +30 -28
- package/src/config.ts +2 -0
- package/src/evals.ts +6 -6
- package/src/extraction-error-classification.ts +88 -8
- package/src/extraction-local-failure-class.test.ts +117 -3
- package/src/extraction-reply-diagnostic-wiring.test.ts +3 -1
- package/src/extraction.test.ts +73 -3
- package/src/extraction.ts +26 -25
- package/src/fallback-llm-codex-subscription.ts +17 -3
- package/src/fallback-llm.test.ts +70 -0
- package/src/fallback-llm.ts +17 -18
- package/src/local-llm-headers-timeout.test.ts +151 -0
- package/src/local-llm-helpers.ts +1 -1
- package/src/local-llm.ts +44 -43
- package/src/orchestration/extraction-drain.ts +11 -5
- package/src/orchestration/extraction-run-helpers.ts +110 -4
- package/src/orchestration/extraction-run.test.ts +408 -3
- package/src/orchestration/extraction-run.ts +75 -75
- package/src/orchestration/orchestrator-helpers.ts +2 -0
- package/src/orchestration/recall-entry.ts +7 -7
- package/src/orchestration/recall-internal.ts +14 -4
- package/src/orchestrator.ts +3 -2
- package/src/recall-client-deadline-trace.test.ts +209 -0
- package/src/storage.ts +5 -4
- package/src/types-extraction-failure.ts +12 -1
- package/src/types.ts +6 -6
- package/dist/chunk-2QW5HPKU.js.map +0 -1
- package/dist/chunk-3RZ4GDOH.js.map +0 -1
- package/dist/chunk-BDFSVUUZ.js.map +0 -1
- package/dist/chunk-C7SRUWBW.js +0 -54
- package/dist/chunk-C7SRUWBW.js.map +0 -1
- package/dist/chunk-F2MVWUNF.js.map +0 -1
- package/dist/chunk-FZU62GIV.js.map +0 -1
- package/dist/chunk-JKMIGCK6.js.map +0 -1
- package/dist/chunk-M7Q7Z6V5.js.map +0 -1
- package/dist/chunk-MMRTPH3J.js.map +0 -1
- package/dist/chunk-NN3LMWKA.js.map +0 -1
- package/dist/chunk-QIPRDRGM.js.map +0 -1
- package/dist/chunk-QSF5SJAM.js.map +0 -1
- package/dist/chunk-STSORBX5.js.map +0 -1
- package/dist/chunk-V65H7MI6.js.map +0 -1
- package/dist/chunk-VSLV3EEP.js.map +0 -1
- package/dist/chunk-XZMQLON4.js.map +0 -1
- package/dist/chunk-YCJJODER.js.map +0 -1
- /package/dist/{chunk-3ZS3NUEI.js.map → chunk-3DSLTUK6.js.map} +0 -0
- /package/dist/{chunk-DYUPSTCV.js.map → chunk-3EXG2KPK.js.map} +0 -0
- /package/dist/{chunk-FGFU6J26.js.map → chunk-4FTYKZ77.js.map} +0 -0
- /package/dist/{chunk-EEA2RM4B.js.map → chunk-4I6A3SDL.js.map} +0 -0
- /package/dist/{chunk-SKJM4PKE.js.map → chunk-4JI5PPFW.js.map} +0 -0
- /package/dist/{chunk-TDG5NZAZ.js.map → chunk-65JA7LWV.js.map} +0 -0
- /package/dist/{chunk-3YID7KZ6.js.map → chunk-6QMKUWXH.js.map} +0 -0
- /package/dist/{chunk-7SOKOEAZ.js.map → chunk-6RRHTHKQ.js.map} +0 -0
- /package/dist/{chunk-VHQNJW4Q.js.map → chunk-6W62D4MC.js.map} +0 -0
- /package/dist/{chunk-CRS2NY44.js.map → chunk-7O6H7BPW.js.map} +0 -0
- /package/dist/{chunk-KJ65WZHB.js.map → chunk-A7DIZOTF.js.map} +0 -0
- /package/dist/{chunk-TZ7ZA2LM.js.map → chunk-AD3JOG2Q.js.map} +0 -0
- /package/dist/{chunk-7EP4FURO.js.map → chunk-C72YQM7E.js.map} +0 -0
- /package/dist/{chunk-4EAVEDLG.js.map → chunk-CRKT2JXN.js.map} +0 -0
- /package/dist/{chunk-CJSTQNE5.js.map → chunk-CTOMDCCA.js.map} +0 -0
- /package/dist/{chunk-PSQ347YP.js.map → chunk-DSKII2W4.js.map} +0 -0
- /package/dist/{chunk-KOVQZJ27.js.map → chunk-E7LDTUWK.js.map} +0 -0
- /package/dist/{chunk-SPAKBUJY.js.map → chunk-EWLMEYLF.js.map} +0 -0
- /package/dist/{chunk-JJ42IDJU.js.map → chunk-FEGQI5KR.js.map} +0 -0
- /package/dist/{chunk-3BICT225.js.map → chunk-FGNBUUPX.js.map} +0 -0
- /package/dist/{chunk-QZMGZBTF.js.map → chunk-HBG6CQEX.js.map} +0 -0
- /package/dist/{chunk-7V6GNQC2.js.map → chunk-HINQENZG.js.map} +0 -0
- /package/dist/{chunk-WRVKI6ZO.js.map → chunk-HLQXSX4F.js.map} +0 -0
- /package/dist/{chunk-KQIOW3TG.js.map → chunk-HUDE2SQA.js.map} +0 -0
- /package/dist/{chunk-T765HQ5U.js.map → chunk-IIDAN7XJ.js.map} +0 -0
- /package/dist/{chunk-VMNX2UV7.js.map → chunk-JRUOIEFL.js.map} +0 -0
- /package/dist/{chunk-TWYYUMYO.js.map → chunk-KXAGZRJV.js.map} +0 -0
- /package/dist/{chunk-JITK24KX.js.map → chunk-LJNCJK7B.js.map} +0 -0
- /package/dist/{chunk-Z6EFSXU3.js.map → chunk-LMM2LRVQ.js.map} +0 -0
- /package/dist/{chunk-KZ4BJRGQ.js.map → chunk-ODGVLSCQ.js.map} +0 -0
- /package/dist/{chunk-AALJHIKH.js.map → chunk-OHJ5PNYB.js.map} +0 -0
- /package/dist/{chunk-Q6S67LHR.js.map → chunk-OOMFFMX3.js.map} +0 -0
- /package/dist/{chunk-JNDMIAJ4.js.map → chunk-QEVZKJM6.js.map} +0 -0
- /package/dist/{chunk-ZNCCX7P6.js.map → chunk-QO5QZR2U.js.map} +0 -0
- /package/dist/{chunk-NFQKIZK3.js.map → chunk-QXEF66SC.js.map} +0 -0
- /package/dist/{chunk-NKHRIDYP.js.map → chunk-RTXW6E6X.js.map} +0 -0
- /package/dist/{chunk-5WDUY2ZZ.js.map → chunk-S4QWAWR6.js.map} +0 -0
- /package/dist/{chunk-HEJFE3BC.js.map → chunk-SJCN7ESG.js.map} +0 -0
- /package/dist/{chunk-AJ7JHHRY.js.map → chunk-SPPWVMP4.js.map} +0 -0
- /package/dist/{chunk-QFKNIKUF.js.map → chunk-SXR7L57Z.js.map} +0 -0
- /package/dist/{chunk-GYCUX3N4.js.map → chunk-TGMIJABS.js.map} +0 -0
- /package/dist/{chunk-GH7IKABD.js.map → chunk-UFJJMQDV.js.map} +0 -0
- /package/dist/{chunk-FKHXXL42.js.map → chunk-VAE6QCZQ.js.map} +0 -0
- /package/dist/{chunk-UH2VY2QQ.js.map → chunk-WCW7I7ZM.js.map} +0 -0
- /package/dist/{chunk-5GIYIYJI.js.map → chunk-WLP3XJCO.js.map} +0 -0
- /package/dist/{chunk-LR6LWX33.js.map → chunk-XXDIPAUE.js.map} +0 -0
- /package/dist/{chunk-G2MS56KM.js.map → chunk-YQUGYQRY.js.map} +0 -0
- /package/dist/{chunk-WEI6HEUX.js.map → chunk-YXAH5TSN.js.map} +0 -0
- /package/dist/{chunk-75K6DRPN.js.map → chunk-ZAVFAGBE.js.map} +0 -0
- /package/dist/{chunk-7KTORRIK.js.map → chunk-ZNJU3NBJ.js.map} +0 -0
|
@@ -65,6 +65,13 @@ function stubResponse(results: unknown[]): EngramAccessRecallResponse {
|
|
|
65
65
|
return { results } as unknown as EngramAccessRecallResponse;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
// Single trusted cast point for the private seams a stub replaces.
|
|
69
|
+
function asHostSeam<T>(cause: unknown): T {
|
|
70
|
+
// SAFETY: the caller supplies the locally-declared seam contract; the cast
|
|
71
|
+
// re-labels the EngramAccessService prototype instance to that contract.
|
|
72
|
+
return cause as T;
|
|
73
|
+
}
|
|
74
|
+
|
|
68
75
|
function readResults(response: EngramAccessRecallResponse): unknown[] {
|
|
69
76
|
assert.ok(response && typeof response === "object" && "results" in response);
|
|
70
77
|
const { results } = response as { results: unknown[] };
|
|
@@ -2230,3 +2237,61 @@ test("a keyed follower does not inherit its leader's queued-deadline rejection (
|
|
|
2230
2237
|
assert.equal(pipelineRuns, 2, "holder + the one shared pipeline");
|
|
2231
2238
|
await holder;
|
|
2232
2239
|
});
|
|
2240
|
+
|
|
2241
|
+
test("coalesced followers echo their own caller traceId, not the leader's", async () => {
|
|
2242
|
+
const { service } = makeService({
|
|
2243
|
+
limit: 0,
|
|
2244
|
+
singleFlight: true,
|
|
2245
|
+
pipeline: async (request) => ({
|
|
2246
|
+
...stubResponse([{ id: "m1" }]),
|
|
2247
|
+
traceId: request.traceId,
|
|
2248
|
+
}),
|
|
2249
|
+
});
|
|
2250
|
+
|
|
2251
|
+
const req: EngramAccessRecallRequest = { query: "same", sessionKey: "s1" };
|
|
2252
|
+
const [leader, followerA, followerB] = await Promise.all([
|
|
2253
|
+
service.recall({ ...req, traceId: "leader-tid" }),
|
|
2254
|
+
service.recall({ ...req, traceId: "follower-a" }),
|
|
2255
|
+
service.recall({ ...req }),
|
|
2256
|
+
]);
|
|
2257
|
+
|
|
2258
|
+
assert.equal(leader.traceId, "leader-tid");
|
|
2259
|
+
assert.equal(followerA.traceId, "follower-a", "a caller-supplied traceId must survive single-flight coalescing");
|
|
2260
|
+
assert.equal(followerB.traceId, "leader-tid", "a caller without traceId keeps the pipeline's value");
|
|
2261
|
+
});
|
|
2262
|
+
|
|
2263
|
+
test("an idempotent replay echoes the REPLAYING caller's traceId, not the original attempt's", async () => {
|
|
2264
|
+
const store = new Map<string, EngramAccessRecallResponse>();
|
|
2265
|
+
const h = makeService({
|
|
2266
|
+
limit: 0,
|
|
2267
|
+
singleFlight: false,
|
|
2268
|
+
crossNamespace: true,
|
|
2269
|
+
pipeline: async (request) => ({
|
|
2270
|
+
...stubResponse([{ id: "m1" }]),
|
|
2271
|
+
traceId: request.traceId,
|
|
2272
|
+
}),
|
|
2273
|
+
});
|
|
2274
|
+
const host = asHostSeam<{
|
|
2275
|
+
handleIdempotentRead: (options: {
|
|
2276
|
+
idempotencyKey?: string;
|
|
2277
|
+
execute: () => Promise<EngramAccessRecallResponse>;
|
|
2278
|
+
}) => Promise<EngramAccessRecallResponse>;
|
|
2279
|
+
}>(h.service);
|
|
2280
|
+
host.handleIdempotentRead = async (options) => {
|
|
2281
|
+
const key = options.idempotencyKey ?? "";
|
|
2282
|
+
const cached = store.get(key);
|
|
2283
|
+
if (cached) return cached;
|
|
2284
|
+
const response = await options.execute();
|
|
2285
|
+
store.set(key, response);
|
|
2286
|
+
return response;
|
|
2287
|
+
};
|
|
2288
|
+
|
|
2289
|
+
const first = await h.service.recall({ query: "same", idempotencyKey: "k", traceId: "first-tid" });
|
|
2290
|
+
const replay = await h.service.recall({ query: "same", idempotencyKey: "k", traceId: "second-tid" });
|
|
2291
|
+
const replayAgain = await h.service.recall({ query: "same", idempotencyKey: "k", traceId: "third-tid" });
|
|
2292
|
+
|
|
2293
|
+
assert.equal(first.traceId, "first-tid");
|
|
2294
|
+
assert.equal(replay.traceId, "second-tid", "a replay must echo the replaying caller's trace ID");
|
|
2295
|
+
assert.equal(replayAgain.traceId, "third-tid", "an earlier replay's stamp must not corrupt the stored record");
|
|
2296
|
+
assert.equal(store.get("k")!.traceId, "first-tid", "the stored record keeps the original attempt's ID");
|
|
2297
|
+
});
|
package/src/access-service.ts
CHANGED
|
@@ -2640,9 +2640,10 @@ export class EngramAccessService extends SupportPassportAccessServiceBase {
|
|
|
2640
2640
|
const deadlineAtMs = resolveClientDeadlineAtMs(request.deadlineMs, Date.now());
|
|
2641
2641
|
const normalizedRequest = { ...request, query };
|
|
2642
2642
|
if (deadlineAtMs !== null) normalizedRequest.deadlineMs = deadlineAtMs;
|
|
2643
|
-
// `deadlineMs`
|
|
2644
|
-
// carrying different
|
|
2645
|
-
|
|
2643
|
+
// `deadlineMs`/`traceId` are per-call QoS + correlation, not work
|
|
2644
|
+
// identity: two identical recalls carrying different values must still
|
|
2645
|
+
// coalesce (#3514 review, #3499 trace plumbing).
|
|
2646
|
+
const { abortSignal: _abortSignal, deadlineMs: _deadlineMs, traceId: _traceId, ...requestFingerprint } = normalizedRequest;
|
|
2646
2647
|
const authenticatedPrincipal = request.authenticatedPrincipal?.trim();
|
|
2647
2648
|
const principal = this.resolveRequestPrincipal(request.sessionKey, authenticatedPrincipal);
|
|
2648
2649
|
if (resolveNamespaceCapabilities(this.orchestrator.config).namespaces && !principal) {
|
|
@@ -232,6 +232,29 @@ test("retained turns survive the per-session persist", async () => {
|
|
|
232
232
|
assert.equal(record?.entry.retainedTurns?.[0]?.content, "alpha");
|
|
233
233
|
});
|
|
234
234
|
|
|
235
|
+
test("retained-only dead-letter clear persists the removal on session-capable storage (#3757)", async () => {
|
|
236
|
+
const retained = makeTurn("thread-a", "judge-deferred copy");
|
|
237
|
+
const storage = new IncrementalStorage({
|
|
238
|
+
turns: [],
|
|
239
|
+
lastExtractionAt: null,
|
|
240
|
+
extractionCount: 0,
|
|
241
|
+
entries: {
|
|
242
|
+
"thread-a": { turns: [], retainedTurns: [retained], lastExtractionAt: null, extractionCount: 0 },
|
|
243
|
+
},
|
|
244
|
+
});
|
|
245
|
+
const buffer = new SmartBuffer(parseConfig({ triggerMode: "every_n", bufferMaxTurns: 100 }), storage);
|
|
246
|
+
|
|
247
|
+
// The window contains only the retained copy — no live turn matches. The
|
|
248
|
+
// removal must still mark the session dirty: per-session persist writes
|
|
249
|
+
// only dirty keys, so a silent in-memory drop would resurrect the copies
|
|
250
|
+
// on restart and re-poison the next extraction window.
|
|
251
|
+
await buffer.clearAfterExtraction("thread-a", [retained], { dropRetainedTurns: true });
|
|
252
|
+
|
|
253
|
+
const record = storage.sessions.get("thread-a");
|
|
254
|
+
assert.ok(record, "retained-only removal never reached saveBufferSession — restart resurrects the copies");
|
|
255
|
+
assert.equal(record.entry.retainedTurns, undefined, "dropped retained copies must not be persisted");
|
|
256
|
+
});
|
|
257
|
+
|
|
235
258
|
test("buffer state survives a restart through per-session files", async () => {
|
|
236
259
|
const root = await mkdtemp(path.join(os.tmpdir(), "remnic-bufio-restart-"));
|
|
237
260
|
try {
|
package/src/buffer.ts
CHANGED
|
@@ -314,14 +314,12 @@ export class SmartBuffer {
|
|
|
314
314
|
this.pendingSave = true;
|
|
315
315
|
if (this.firstPendingAtMs === null) this.firstPendingAtMs = now;
|
|
316
316
|
if (now - this.firstPendingAtMs >= ms * BUFFER_SAVE_MAX_DEFER_MULTIPLIER) {
|
|
317
|
-
// Staleness cap hit: run the persist pass inline rather than re-arming
|
|
318
|
-
//
|
|
319
|
-
//
|
|
320
|
-
//
|
|
321
|
-
//
|
|
322
|
-
//
|
|
323
|
-
// failure keeps the save pending + re-arms so shutdown/the next timer
|
|
324
|
-
// retries (issue #1909 review round 2), never diverging memory from disk.
|
|
317
|
+
// Staleness cap hit: run the persist pass inline rather than re-arming the
|
|
318
|
+
// debounce. Session-level deferral (#3389) may still rate-limit a large
|
|
319
|
+
// rewrite; armDeferredRetry retries at the session's eligibility, so the
|
|
320
|
+
// pass's tail cannot wait on a turn that may never come (3481 review).
|
|
321
|
+
// Drop the armed timer and only mark clean on success — a failure keeps
|
|
322
|
+
// the save pending + re-arms (#1909 review 2).
|
|
325
323
|
clearTimeout(this.saveTimer ?? undefined);
|
|
326
324
|
this.saveTimer = null;
|
|
327
325
|
try {
|
|
@@ -717,18 +715,16 @@ export class SmartBuffer {
|
|
|
717
715
|
// trailing-edge timer (issue #1909) instead of rewriting per turn.
|
|
718
716
|
await this.scheduleSave();
|
|
719
717
|
} else {
|
|
720
|
-
// Persist immediately within this mutation (awaited) when either
|
|
721
|
-
//
|
|
722
|
-
//
|
|
723
|
-
//
|
|
718
|
+
// Persist immediately within this mutation (awaited) when either the turn
|
|
719
|
+
// triggered extraction (the buffer must be durable) or debounce is
|
|
720
|
+
// disabled (bufferSaveDebounceMs <= 0), which reproduces the legacy
|
|
721
|
+
// save-every-turn behavior byte-for-byte.
|
|
724
722
|
// Round 8 thread 4: the write is attempted BEFORE the pending state is
|
|
725
723
|
// cleared, and a failed write leaves it pending (+ a re-armed timer) for
|
|
726
724
|
// shutdown/timer retry instead of dropping the in-memory turns.
|
|
727
725
|
// #3389: a keep_buffering turn has no extraction barrier, so this pass
|
|
728
|
-
// may defer rewriting a large session file that was just persisted
|
|
729
|
-
//
|
|
730
|
-
// once per BUFFER_SESSION_DEFER_INTERVAL_MS. A triggering turn is a
|
|
731
|
-
// durability barrier and passes allowDeferral: false.
|
|
726
|
+
// may defer rewriting a large session file that was just persisted. A
|
|
727
|
+
// triggering turn is a durability barrier and passes allowDeferral: false.
|
|
732
728
|
await this.saveNowRetainingPendingOnFailure("recordTurn", { allowDeferral: decision === "keep_buffering" });
|
|
733
729
|
}
|
|
734
730
|
return {
|
|
@@ -844,13 +840,9 @@ export class SmartBuffer {
|
|
|
844
840
|
): Promise<number | null> {
|
|
845
841
|
if (!this.surpriseProbe) return null;
|
|
846
842
|
try {
|
|
847
|
-
// Hard timeout around the probe
|
|
848
|
-
// `addTurn()` before `save()`.
|
|
849
|
-
//
|
|
850
|
-
// timeout is a soft bound — we race it against the probe, take
|
|
851
|
-
// whichever settles first, and treat the timeout as
|
|
852
|
-
// "probe unavailable, fall through" rather than an error that
|
|
853
|
-
// surfaces to the caller.
|
|
843
|
+
// Hard timeout around the probe: a hung embedder must not stall
|
|
844
|
+
// `addTurn()` before `save()`. Soft bound — on timeout we treat the
|
|
845
|
+
// probe as unavailable and fall through rather than erroring.
|
|
854
846
|
const score = await probeWithTimeout(
|
|
855
847
|
this.surpriseProbe.scoreTurn(bufferKey, turn, priorTurns),
|
|
856
848
|
this.config.bufferSurpriseProbeTimeoutMs,
|
|
@@ -1050,16 +1042,15 @@ export class SmartBuffer {
|
|
|
1050
1042
|
async clearAfterExtraction(
|
|
1051
1043
|
bufferKey = "default",
|
|
1052
1044
|
extractedTurns?: readonly BufferTurn[],
|
|
1053
|
-
options?: { allowNonPrefix?: boolean },
|
|
1045
|
+
options?: { allowNonPrefix?: boolean; dropRetainedTurns?: boolean },
|
|
1054
1046
|
): Promise<void> {
|
|
1055
1047
|
await this.enqueueMutation(async () => {
|
|
1056
1048
|
// Drop any armed debounce TIMER so it cannot fire mid-mutation and race
|
|
1057
1049
|
// our post-clear write, but KEEP the pending-save state (issue #1909
|
|
1058
1050
|
// review round 13): the post-clear save below can fail, and clearing the
|
|
1059
1051
|
// pending flag here would strand buffered turns — including turns from
|
|
1060
|
-
//
|
|
1061
|
-
//
|
|
1062
|
-
// pending state only after a durable write, or re-arms it on failure.
|
|
1052
|
+
// other sessions only ever in the debounced pending state — with nothing
|
|
1053
|
+
// left to retry them. saveNowRetainingPendingOnFailure re-arms on failure.
|
|
1063
1054
|
if (this.saveTimer) {
|
|
1064
1055
|
clearTimeout(this.saveTimer);
|
|
1065
1056
|
this.saveTimer = null;
|
|
@@ -1101,7 +1092,18 @@ export class SmartBuffer {
|
|
|
1101
1092
|
);
|
|
1102
1093
|
}
|
|
1103
1094
|
}
|
|
1104
|
-
|
|
1095
|
+
// Dead-letter callers also drop the retained (judge-deferred) copies in
|
|
1096
|
+
// the window: survivors would be prepended into later windows and could
|
|
1097
|
+
// re-poison them (#3757). Normal clears keep retainedTurns as intended.
|
|
1098
|
+
// A retained-only removal must not early-return: session persistence
|
|
1099
|
+
// writes only dirty keys, so markDirty below is what persists it.
|
|
1100
|
+
let droppedRetained = false;
|
|
1101
|
+
if (options?.dropRetainedTurns === true && entry.retainedTurns && entry.retainedTurns.length > 0) {
|
|
1102
|
+
const kept = subtractBufferTurns(entry.retainedTurns, extractedTurns);
|
|
1103
|
+
droppedRetained = kept.length !== entry.retainedTurns.length;
|
|
1104
|
+
if (kept.length > 0) entry.retainedTurns = kept; else delete entry.retainedTurns;
|
|
1105
|
+
}
|
|
1106
|
+
if (!clearedLiveTurns && !droppedRetained) {
|
|
1105
1107
|
await this.saveNowRetainingPendingOnFailure("clearAfterExtraction");
|
|
1106
1108
|
return;
|
|
1107
1109
|
}
|
package/src/config.ts
CHANGED
|
@@ -2864,6 +2864,8 @@ export function parseConfig(
|
|
|
2864
2864
|
typeof cfg.extractionParseEmptyMaxAttempts === "number" &&
|
|
2865
2865
|
Number.isInteger(cfg.extractionParseEmptyMaxAttempts) && cfg.extractionParseEmptyMaxAttempts > 0
|
|
2866
2866
|
? cfg.extractionParseEmptyMaxAttempts : 3,
|
|
2867
|
+
extractionProviderPermanentMaxAttempts:
|
|
2868
|
+
parsePositiveInteger(cfg.extractionProviderPermanentMaxAttempts, "extractionProviderPermanentMaxAttempts") ?? 3,
|
|
2867
2869
|
extractionBreakerFailureThreshold:
|
|
2868
2870
|
typeof cfg.extractionBreakerFailureThreshold === "number" &&
|
|
2869
2871
|
Number.isInteger(cfg.extractionBreakerFailureThreshold) && cfg.extractionBreakerFailureThreshold > 0
|
package/src/evals.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
2
3
|
import { cp, mkdir, readFile, readdir, rm, stat, writeFile } from "node:fs/promises";
|
|
3
4
|
import { listJsonFiles, listNamedFiles, readJsonFile } from "./json-store.js";
|
|
4
5
|
|
|
@@ -925,17 +926,16 @@ export async function importEvalBenchmarkPack(options: {
|
|
|
925
926
|
};
|
|
926
927
|
}
|
|
927
928
|
|
|
928
|
-
export async function recordEvalShadowRecall(
|
|
929
|
-
memoryDir: string;
|
|
930
|
-
|
|
931
|
-
record: EvalShadowRecallRecord;
|
|
932
|
-
}): Promise<string> {
|
|
929
|
+
export async function recordEvalShadowRecall(
|
|
930
|
+
options: { memoryDir: string; evalStoreDir?: string; record: EvalShadowRecallRecord },
|
|
931
|
+
): Promise<string> {
|
|
933
932
|
const rootDir = resolveEvalStoreDir(options.memoryDir, options.evalStoreDir);
|
|
934
933
|
const validated = validateEvalShadowRecallRecord(options.record);
|
|
935
934
|
const day = validated.recordedAt.slice(0, 10);
|
|
936
935
|
const shadowRoot = path.join(rootDir, "shadow");
|
|
937
936
|
const shadowDir = path.join(shadowRoot, day);
|
|
938
|
-
|
|
937
|
+
// Filename is a deterministic hash, not the raw ID: caller-supplied IDs may carry filename-unsafe chars (#3499).
|
|
938
|
+
const targetPath = path.join(shadowDir, `${createHash("sha256").update(validated.traceId).digest("hex").slice(0, 24)}.json`);
|
|
939
939
|
assertPathWithin(shadowRoot, targetPath, "shadow recall record path");
|
|
940
940
|
await mkdir(shadowDir, { recursive: true });
|
|
941
941
|
await writeFile(targetPath, JSON.stringify(validated, null, 2), "utf-8");
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { ExtractionFailureClass, ExtractionResult } from "./types.js";
|
|
2
|
-
import { isTransientHttpError } from "./connectors/live/transient-errors.js";
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* Read a numeric HTTP status off a thrown error without re-implementing the
|
|
@@ -16,22 +15,91 @@ function httpStatusFromError(err: unknown): number | undefined {
|
|
|
16
15
|
|
|
17
16
|
/**
|
|
18
17
|
* Map a thrown extraction error to a coarse failure class for the retry/breaker
|
|
19
|
-
* layer.
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
18
|
+
* layer. Never throws.
|
|
19
|
+
*
|
|
20
|
+
* - 401/403 → `auth_config` (misconfigured provider, open the breaker).
|
|
21
|
+
* - transient (429/5xx/network, per the shared `isTransientHttpError`) →
|
|
22
|
+
* `provider_retryable` (back off; a provider that comes back drains the window).
|
|
23
|
+
* - a terminal status that refuses THIS input (400/413/422 — the same droppable
|
|
24
|
+
* set `localRejectionStatus` uses) → `provider_permanent`: a resend of the
|
|
25
|
+
* identical request can never succeed, so the fingerprint dead-letters after
|
|
26
|
+
* `extractionProviderPermanentMaxAttempts` instead of looping the drain forever.
|
|
27
|
+
* EXCEPTION: a 400 that refuses a request PARAMETER (`unsupported parameter:
|
|
28
|
+
* temperature`, `unknown field`, `…not supported with this model`) is the
|
|
29
|
+
* setup's problem — the identical request fails for every future window, so
|
|
30
|
+
* it is `auth_config` (retained), not the chunk's.
|
|
31
|
+
* - any other terminal status (404/405/410/…) → `auth_config`: a missing route or
|
|
32
|
+
* model is the endpoint setup's problem, not the chunk's — innocent windows are
|
|
33
|
+
* never dropped for it.
|
|
34
|
+
* - no status and not transient → `provider_retryable` (unknown failure; fail
|
|
35
|
+
* open toward retry rather than silently dead-lettering a buffered window).
|
|
23
36
|
*/
|
|
24
37
|
export function classifyExtractionThrownError(err: unknown): ExtractionFailureClass {
|
|
25
38
|
try {
|
|
26
39
|
const status = httpStatusFromError(err);
|
|
27
40
|
if (status === 401 || status === 403) return "auth_config";
|
|
28
|
-
|
|
41
|
+
// A recognized status resolves retryability directly: `isTransientHttpError`
|
|
42
|
+
// cannot read every status property name (e.g. `statusCode`), so deferring to
|
|
43
|
+
// it would mis-bucket terminal local statuses (404/405/410) as retryable.
|
|
44
|
+
if (status !== undefined) {
|
|
45
|
+
if (status === 400 && isParameterConfigRejection(err)) return "auth_config";
|
|
46
|
+
if (status === 400 || status === 413 || status === 422) {
|
|
47
|
+
// A permanent-looking refusal alongside a transient sibling attempt is
|
|
48
|
+
// not conclusive proof the window is unextractable — retry under the
|
|
49
|
+
// drain's own bound instead of dead-lettering (#3757).
|
|
50
|
+
return err instanceof Object && "transientAttemptSeen" in err && err.transientAttemptSeen === true
|
|
51
|
+
? "provider_retryable"
|
|
52
|
+
: "provider_permanent";
|
|
53
|
+
}
|
|
54
|
+
return status === 408 || status === 429 || status >= 500 ? "provider_retryable" : "auth_config";
|
|
55
|
+
}
|
|
29
56
|
return "provider_retryable";
|
|
30
57
|
} catch {
|
|
31
58
|
return "provider_retryable";
|
|
32
59
|
}
|
|
33
60
|
}
|
|
34
61
|
|
|
62
|
+
/**
|
|
63
|
+
* A refusal that classifies `provider_permanent` is inconclusive when a
|
|
64
|
+
* transient attempt was seen elsewhere in the request chain (a timeout/5xx
|
|
65
|
+
* primary before a 400 gateway refusal proves nothing about the window) —
|
|
66
|
+
* downgrade it to `provider_retryable` so the drain's own bound applies
|
|
67
|
+
* instead of the dead-letter cap (#3757).
|
|
68
|
+
*/
|
|
69
|
+
export function downgradePermanentOnTransientAttempt(cls: ExtractionFailureClass, transientAttemptSeen: boolean): ExtractionFailureClass {
|
|
70
|
+
return transientAttemptSeen && cls === "provider_permanent" ? "provider_retryable" : cls;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** Provider error codes that name a rejected request parameter rather than the payload. `http_4xx_parameter` is the fallback transport's own token. */
|
|
74
|
+
const PARAMETER_CONFIG_CODE =
|
|
75
|
+
/^(?:unsupported_parameter|unsupported_value|unknown_parameter|invalid_parameter|parameter_not_supported|http_4xx_parameter)$/i;
|
|
76
|
+
/** Provider message shapes that blame the request shape/setup, not the content. `value` is deliberately not a subject — a content refusal like `unexpected value in messages[0].content` must stay an input refusal, not park the window as a config problem (#3757). */
|
|
77
|
+
const PARAMETER_CONFIG_MESSAGE =
|
|
78
|
+
/(?:unsupported|unknown|unexpected|unrecognized) (?:parameter|param|field|option)\b|not supported (?:with|for|by) this model|additional propert(?:y|ies) (?:are )?not allowed/i;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* True when a provider 400 refuses the request's configuration — an unsupported
|
|
82
|
+
* or unknown parameter/field (`temperature` on a model that forbids it, an
|
|
83
|
+
* extra property the schema rejects) — rather than this input. Reads `code`,
|
|
84
|
+
* `type`, `errorClass`, a nested `error.code`, and the message; never throws.
|
|
85
|
+
* An ambiguous 400 stays an input refusal, so genuinely refused content still
|
|
86
|
+
* dead-letters instead of parking the drain forever.
|
|
87
|
+
*/
|
|
88
|
+
export function isParameterConfigRejection(cause: unknown): boolean {
|
|
89
|
+
try {
|
|
90
|
+
if (!(cause instanceof Object)) return false;
|
|
91
|
+
if ("code" in cause && PARAMETER_CONFIG_CODE.test(String(cause.code))) return true;
|
|
92
|
+
if ("type" in cause && PARAMETER_CONFIG_CODE.test(String(cause.type))) return true;
|
|
93
|
+
if ("errorClass" in cause && PARAMETER_CONFIG_CODE.test(String(cause.errorClass))) return true;
|
|
94
|
+
const nested = "error" in cause && cause.error instanceof Object ? cause.error : undefined;
|
|
95
|
+
if (nested && "code" in nested && PARAMETER_CONFIG_CODE.test(String(nested.code))) return true;
|
|
96
|
+
const msg = "message" in cause ? String(cause.message) : undefined;
|
|
97
|
+
return msg !== undefined && PARAMETER_CONFIG_MESSAGE.test(msg);
|
|
98
|
+
} catch {
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
35
103
|
const CONTEXT_LIMIT_MESSAGE = /maximum context|context length|context window|request entity/i;
|
|
36
104
|
const SIZE_LIMIT_PHRASE = /too large|too long|exceed/i;
|
|
37
105
|
const INPUT_SUBJECT_TERM =
|
|
@@ -153,7 +221,7 @@ export function formatExtractionParseFailureLog(input: {
|
|
|
153
221
|
* chunk that keeps drawing it is dropped after its recovery copy is saved.
|
|
154
222
|
*/
|
|
155
223
|
export class LocalLlmRejectedError extends Error {
|
|
156
|
-
constructor(readonly httpStatus?: number, readonly finishReason?: string) {
|
|
224
|
+
constructor(readonly httpStatus?: number, readonly finishReason?: string, readonly parameterRefusal?: boolean, readonly sawTransientAttempt?: boolean) {
|
|
157
225
|
super(httpStatus === undefined ? "local LLM answered with unusable content" : `local LLM rejected the input (HTTP ${httpStatus})`);
|
|
158
226
|
this.name = "LocalLlmRejectedError";
|
|
159
227
|
}
|
|
@@ -166,7 +234,17 @@ export class LocalLlmRejectedError extends Error {
|
|
|
166
234
|
* or refused reply stays `parse_empty`.
|
|
167
235
|
*/
|
|
168
236
|
export function classifyLocalLlmRejected(err: LocalLlmRejectedError): ExtractionFailureClass {
|
|
169
|
-
|
|
237
|
+
if (err.finishReason === "length") return "output_truncated";
|
|
238
|
+
// A 400 that refuses a request PARAMETER is the endpoint setup's problem, not
|
|
239
|
+
// the chunk's — retain it parked instead of dead-lettering valid turns.
|
|
240
|
+
if (err.parameterRefusal) return "auth_config";
|
|
241
|
+
// A status-bearing rejection after a transient sibling attempt is inconclusive:
|
|
242
|
+
// the window is not proven unextractable, so it stays retryable (#3757).
|
|
243
|
+
if (err.sawTransientAttempt === true && err.httpStatus !== undefined) return "provider_retryable";
|
|
244
|
+
// A status-bearing rejection refuses THIS input (400/413/422 — `localRejectionStatus`
|
|
245
|
+
// already filtered the droppable set): dead-letter at the permanent cap instead
|
|
246
|
+
// of parking at the parse_empty cap. Only the statusless unusable reply stays parse_empty.
|
|
247
|
+
return err.httpStatus !== undefined ? "provider_permanent" : "parse_empty";
|
|
170
248
|
}
|
|
171
249
|
|
|
172
250
|
/** What the local client recorded about a failed call (`failureDiag`). */
|
|
@@ -174,6 +252,8 @@ export interface LocalFailureDiag {
|
|
|
174
252
|
lastError?: unknown;
|
|
175
253
|
/** The completion's `finish_reason` as the client received it (validated before it is logged). */
|
|
176
254
|
finishReason?: string;
|
|
255
|
+
/** A transient attempt (timeout, network error, 408/429/5xx) was consumed inside the local retry loop before the final failure. */
|
|
256
|
+
sawTransientAttempt?: boolean;
|
|
177
257
|
}
|
|
178
258
|
|
|
179
259
|
/** The HTTP status when the local endpoint answered and refuses this input (400, 413, 422); else undefined. A wrong model name or route (404, 405, 410), auth, timeout and rate limiting are the setup's problem, not the chunk's. */
|
|
@@ -3,6 +3,7 @@ import test from "node:test";
|
|
|
3
3
|
|
|
4
4
|
import { parseConfig } from "./config.js";
|
|
5
5
|
import { ExtractionEngine } from "./extraction.js";
|
|
6
|
+
import { LocalLlmRejectedError } from "./extraction-error-classification.js";
|
|
6
7
|
import type { BufferTurn } from "./types.js";
|
|
7
8
|
|
|
8
9
|
// Follow-up to #3266: the trigger drain drops a chunk after N failures, but not for an outage. Whether a local-model failure
|
|
@@ -13,7 +14,7 @@ const TURNS: BufferTurn[] = [
|
|
|
13
14
|
];
|
|
14
15
|
|
|
15
16
|
type LocalMessages = Array<{ role: string; content: string }>;
|
|
16
|
-
type LocalStub = (messages: LocalMessages, options: { failureDiag?: { lastError?: Error } }) => Promise<{ content: string } | null>;
|
|
17
|
+
type LocalStub = (messages: LocalMessages, options: { failureDiag?: { lastError?: Error; sawTransientAttempt?: boolean } }) => Promise<{ content: string } | null>;
|
|
17
18
|
|
|
18
19
|
async function extractWith(local: LocalStub) {
|
|
19
20
|
const engine = new ExtractionEngine(parseConfig({ localLlmEnabled: true, localLlmModel: "fixture-local", localLlmFallback: false }));
|
|
@@ -31,13 +32,15 @@ test("a local endpoint that answers with something unusable rejects the chunk: p
|
|
|
31
32
|
assert.equal(result.extractionFailureClass, "parse_empty");
|
|
32
33
|
});
|
|
33
34
|
|
|
34
|
-
test("a local endpoint that answers with a client error rejects the chunk:
|
|
35
|
+
test("a local endpoint that answers with a client error rejects the chunk: provider_permanent", async () => {
|
|
36
|
+
// Status-bearing rejections (400/413/422 — the droppable set) dead-letter at
|
|
37
|
+
// the permanent cap instead of parking at the parse_empty cap (#3757).
|
|
35
38
|
for (const status of [400, 413, 422]) {
|
|
36
39
|
const result = await extractWith(async (_messages, options) => {
|
|
37
40
|
if (options.failureDiag) options.failureDiag.lastError = withStatus(status);
|
|
38
41
|
return null;
|
|
39
42
|
});
|
|
40
|
-
assert.equal(result.extractionFailureClass, "
|
|
43
|
+
assert.equal(result.extractionFailureClass, "provider_permanent", `HTTP ${status}`);
|
|
41
44
|
}
|
|
42
45
|
});
|
|
43
46
|
|
|
@@ -53,3 +56,114 @@ test("not the chunk's fault: unreachable, timeout, 5xx, 429, auth and a wrong mo
|
|
|
53
56
|
assert.equal(result.extractionFailureClass, "provider_retryable", `HTTP ${status}`);
|
|
54
57
|
}
|
|
55
58
|
});
|
|
59
|
+
|
|
60
|
+
const GATEWAY_400 = { result: null, failureReason: "http_error" as const, httpStatus: 400, errorClass: "http_4xx", sawTransientAttempt: false };
|
|
61
|
+
|
|
62
|
+
// A transient primary failure (timeout/5xx/429) makes a later terminal-looking
|
|
63
|
+
// gateway refusal inconclusive — the window must stay retryable under the
|
|
64
|
+
// drain's own bound instead of dead-lettering (#3757, codex P1).
|
|
65
|
+
test("transient primary + terminal-looking gateway refusal stays provider_retryable", async () => {
|
|
66
|
+
for (const status of [408, 429, 500, 503]) {
|
|
67
|
+
const engine = new ExtractionEngine(parseConfig({ localLlmEnabled: true, localLlmModel: "fixture-local", localLlmFallback: true, openaiApiKey: false }));
|
|
68
|
+
const modelRegistry = { calculateContextSizes: () => ({ maxInputChars: 8_000, maxOutputTokens: 1_000, description: "fixture" }) };
|
|
69
|
+
assert.equal(Reflect.set(engine, "modelRegistry", modelRegistry), true);
|
|
70
|
+
assert.equal(Reflect.set(engine, "localLlm", { async chatCompletion() { throw withStatus(status); } }), true);
|
|
71
|
+
assert.equal(Reflect.set(engine, "fallbackLlm", { async parseWithSchemaDetailed() { return GATEWAY_400; } }), true);
|
|
72
|
+
const result = await engine.extract(TURNS);
|
|
73
|
+
assert.equal(result.extractionFailure, "fallback_no_parsed_output", `HTTP ${status}`);
|
|
74
|
+
assert.equal(result.extractionFailureClass, "provider_retryable", `HTTP ${status}`);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
test("transient direct-client failure + terminal-looking gateway refusal stays provider_retryable", async () => {
|
|
79
|
+
const engine = new ExtractionEngine(parseConfig({ openaiApiKey: "fixture-key" }));
|
|
80
|
+
const client = { chat: { completions: { async create() { throw withStatus(503); } } } };
|
|
81
|
+
assert.equal(Reflect.set(engine, "client", client), true);
|
|
82
|
+
assert.equal(Reflect.set(engine, "fallbackLlm", { async parseWithSchemaDetailed() { return GATEWAY_400; } }), true);
|
|
83
|
+
const result = await engine.extract(TURNS);
|
|
84
|
+
assert.equal(result.extractionFailureClass, "provider_retryable");
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
test("a permanent primary refusal does not rescue a terminal gateway refusal", async () => {
|
|
88
|
+
// A droppable-status local rejection is permanent evidence about the window
|
|
89
|
+
// itself — two refusals agree, so the class stays provider_permanent.
|
|
90
|
+
const engine = new ExtractionEngine(parseConfig({ localLlmEnabled: true, localLlmModel: "fixture-local", localLlmFallback: true, openaiApiKey: false }));
|
|
91
|
+
const modelRegistry = { calculateContextSizes: () => ({ maxInputChars: 8_000, maxOutputTokens: 1_000, description: "fixture" }) };
|
|
92
|
+
assert.equal(Reflect.set(engine, "modelRegistry", modelRegistry), true);
|
|
93
|
+
assert.equal(Reflect.set(engine, "localLlm", { async chatCompletion() { throw new LocalLlmRejectedError(400); } }), true);
|
|
94
|
+
assert.equal(Reflect.set(engine, "fallbackLlm", { async parseWithSchemaDetailed() { return GATEWAY_400; } }), true);
|
|
95
|
+
const result = await engine.extract(TURNS);
|
|
96
|
+
assert.equal(result.extractionFailureClass, "provider_permanent");
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
// The null-return path carries the same evidence as a throw: LocalLlmClient
|
|
100
|
+
// records transient attempts on failureDiag.sawTransientAttempt and returns
|
|
101
|
+
// null (#3757).
|
|
102
|
+
test("a null local reply carrying transient diag evidence keeps a terminal gateway refusal retryable", async () => {
|
|
103
|
+
for (const status of [429, 500, 503]) {
|
|
104
|
+
const engine = new ExtractionEngine(parseConfig({ localLlmEnabled: true, localLlmModel: "fixture-local", localLlmFallback: true, openaiApiKey: false }));
|
|
105
|
+
const modelRegistry = { calculateContextSizes: () => ({ maxInputChars: 8_000, maxOutputTokens: 1_000, description: "fixture" }) };
|
|
106
|
+
assert.equal(Reflect.set(engine, "modelRegistry", modelRegistry), true);
|
|
107
|
+
const local = {
|
|
108
|
+
async chatCompletion(_messages: LocalMessages, options: { failureDiag?: { lastError?: Error; sawTransientAttempt?: boolean } }) {
|
|
109
|
+
if (options.failureDiag) {
|
|
110
|
+
options.failureDiag.lastError = withStatus(status);
|
|
111
|
+
options.failureDiag.sawTransientAttempt = true;
|
|
112
|
+
}
|
|
113
|
+
return null;
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
assert.equal(Reflect.set(engine, "localLlm", local), true);
|
|
117
|
+
assert.equal(Reflect.set(engine, "fallbackLlm", { async parseWithSchemaDetailed() { return GATEWAY_400; } }), true);
|
|
118
|
+
const result = await engine.extract(TURNS);
|
|
119
|
+
assert.equal(result.extractionFailureClass, "provider_retryable", `HTTP ${status}`);
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
test("an empty local reply with no diag evidence keeps a gateway refusal permanent", async () => {
|
|
124
|
+
// An HTTP-200 empty completion records nothing on the diagnostic — an absent
|
|
125
|
+
// lastError is NOT a transient attempt, so the refusal dead-letters (#3757).
|
|
126
|
+
const engine = new ExtractionEngine(parseConfig({ localLlmEnabled: true, localLlmModel: "fixture-local", localLlmFallback: true, openaiApiKey: false }));
|
|
127
|
+
const modelRegistry = { calculateContextSizes: () => ({ maxInputChars: 8_000, maxOutputTokens: 1_000, description: "fixture" }) };
|
|
128
|
+
assert.equal(Reflect.set(engine, "modelRegistry", modelRegistry), true);
|
|
129
|
+
assert.equal(Reflect.set(engine, "localLlm", { async chatCompletion() { return null; } }), true);
|
|
130
|
+
assert.equal(Reflect.set(engine, "fallbackLlm", { async parseWithSchemaDetailed() { return GATEWAY_400; } }), true);
|
|
131
|
+
const result = await engine.extract(TURNS);
|
|
132
|
+
assert.equal(result.extractionFailureClass, "provider_permanent");
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
test("a throw after a recorded transient attempt keeps a gateway refusal retryable", async () => {
|
|
136
|
+
// A retried 5xx followed by an unusable reply throws a statusless rejection:
|
|
137
|
+
// the class is parse_empty but the diagnostic flag still proves the attempt.
|
|
138
|
+
const engine = new ExtractionEngine(parseConfig({ localLlmEnabled: true, localLlmModel: "fixture-local", localLlmFallback: true, openaiApiKey: false }));
|
|
139
|
+
const modelRegistry = { calculateContextSizes: () => ({ maxInputChars: 8_000, maxOutputTokens: 1_000, description: "fixture" }) };
|
|
140
|
+
assert.equal(Reflect.set(engine, "modelRegistry", modelRegistry), true);
|
|
141
|
+
const local = {
|
|
142
|
+
async chatCompletion(_messages: LocalMessages, options: { failureDiag?: { sawTransientAttempt?: boolean } }) {
|
|
143
|
+
if (options.failureDiag) options.failureDiag.sawTransientAttempt = true;
|
|
144
|
+
throw new LocalLlmRejectedError(undefined);
|
|
145
|
+
},
|
|
146
|
+
};
|
|
147
|
+
assert.equal(Reflect.set(engine, "localLlm", local), true);
|
|
148
|
+
assert.equal(Reflect.set(engine, "fallbackLlm", { async parseWithSchemaDetailed() { return GATEWAY_400; } }), true);
|
|
149
|
+
const result = await engine.extract(TURNS);
|
|
150
|
+
assert.equal(result.extractionFailureClass, "provider_retryable");
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
test("a null local reply carrying non-transient diag evidence keeps the refusal permanent", async () => {
|
|
154
|
+
// A missing route/model (404) is the endpoint setup's problem, not a
|
|
155
|
+
// transient attempt — the gateway refusal must still dead-letter.
|
|
156
|
+
const engine = new ExtractionEngine(parseConfig({ localLlmEnabled: true, localLlmModel: "fixture-local", localLlmFallback: true, openaiApiKey: false }));
|
|
157
|
+
const modelRegistry = { calculateContextSizes: () => ({ maxInputChars: 8_000, maxOutputTokens: 1_000, description: "fixture" }) };
|
|
158
|
+
assert.equal(Reflect.set(engine, "modelRegistry", modelRegistry), true);
|
|
159
|
+
const local = {
|
|
160
|
+
async chatCompletion(_messages: LocalMessages, options: { failureDiag?: { lastError?: Error } }) {
|
|
161
|
+
if (options.failureDiag) options.failureDiag.lastError = withStatus(404);
|
|
162
|
+
return null;
|
|
163
|
+
},
|
|
164
|
+
};
|
|
165
|
+
assert.equal(Reflect.set(engine, "localLlm", local), true);
|
|
166
|
+
assert.equal(Reflect.set(engine, "fallbackLlm", { async parseWithSchemaDetailed() { return GATEWAY_400; } }), true);
|
|
167
|
+
const result = await engine.extract(TURNS);
|
|
168
|
+
assert.equal(result.extractionFailureClass, "provider_permanent");
|
|
169
|
+
});
|
|
@@ -79,7 +79,9 @@ test("a rejected request (HTTP 400, no reply) logs the same diagnostic once and
|
|
|
79
79
|
if (options.failureDiag) options.failureDiag.lastError = Object.assign(new Error("local LLM http failure"), { status: 400 });
|
|
80
80
|
return null;
|
|
81
81
|
});
|
|
82
|
-
|
|
82
|
+
// A status-bearing refusal is provider_permanent (#3757): the status still
|
|
83
|
+
// classifies the window even though no reply text arrived to parse.
|
|
84
|
+
assert.equal(result.extractionFailureClass, "provider_permanent");
|
|
83
85
|
const lines = warns.filter((w) => w.includes(MARKER));
|
|
84
86
|
assert.equal(lines.length, 1);
|
|
85
87
|
assert.match(lines[0]!, /replyChars=0 /);
|