@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.
Files changed (323) hide show
  1. package/dist/access-admin-ops-surface.js +65 -66
  2. package/dist/access-cli.js +65 -66
  3. package/dist/access-cli.js.map +1 -1
  4. package/dist/access-coding-context-resolution.js +2 -2
  5. package/dist/access-extraction-force-flush-preempt.js +65 -66
  6. package/dist/access-extraction-force-flush.js +65 -66
  7. package/dist/access-http-briefing.js +65 -66
  8. package/dist/access-http-query.js +65 -66
  9. package/dist/access-http.js +65 -66
  10. package/dist/access-identity-continuity-surface.js +65 -66
  11. package/dist/access-lcm-surface.js +65 -66
  12. package/dist/access-mcp.d.ts.map +1 -1
  13. package/dist/access-mcp.js +65 -66
  14. package/dist/access-observe-write-category.js +2 -2
  15. package/dist/access-observe-write-surface.js +65 -66
  16. package/dist/access-operations-batch.js +65 -66
  17. package/dist/access-operations.js +65 -66
  18. package/dist/access-recall-concurrency.d.ts +4 -0
  19. package/dist/access-recall-concurrency.d.ts.map +1 -1
  20. package/dist/access-recall-concurrency.js +65 -66
  21. package/dist/access-recall-diagnostics.js +2 -2
  22. package/dist/access-recall-response.d.ts.map +1 -1
  23. package/dist/access-recall-response.js +65 -66
  24. package/dist/access-recall-surface.d.ts.map +1 -1
  25. package/dist/access-recall-surface.js +65 -66
  26. package/dist/access-schema.d.ts +1 -0
  27. package/dist/access-schema.d.ts.map +1 -1
  28. package/dist/access-schema.js +1 -1
  29. package/dist/access-service.d.ts.map +1 -1
  30. package/dist/access-service.js +65 -66
  31. package/dist/active-recall.js +7 -6
  32. package/dist/active-recall.js.map +1 -1
  33. package/dist/{auto-sync-BJUAGKI5.js → auto-sync-BEW65FDT.js} +6 -5
  34. package/dist/{auto-sync-BJUAGKI5.js.map → auto-sync-BEW65FDT.js.map} +1 -1
  35. package/dist/briefing.js +7 -6
  36. package/dist/buffer.d.ts +1 -0
  37. package/dist/buffer.d.ts.map +1 -1
  38. package/dist/buffer.js +3 -3
  39. package/dist/calibration.js +5 -4
  40. package/dist/calibration.js.map +1 -1
  41. package/dist/causal-consolidation.js +8 -7
  42. package/dist/causal-consolidation.js.map +1 -1
  43. package/dist/{chunk-FZU62GIV.js → chunk-2X5I5C3M.js} +27 -10
  44. package/dist/chunk-2X5I5C3M.js.map +1 -0
  45. package/dist/{chunk-F2MVWUNF.js → chunk-374E2HYZ.js} +10 -2
  46. package/dist/chunk-374E2HYZ.js.map +1 -0
  47. package/dist/{chunk-3ZS3NUEI.js → chunk-3DSLTUK6.js} +2 -2
  48. package/dist/{chunk-DYUPSTCV.js → chunk-3EXG2KPK.js} +3 -3
  49. package/dist/{chunk-FGFU6J26.js → chunk-4FTYKZ77.js} +3 -3
  50. package/dist/{chunk-QIPRDRGM.js → chunk-4HEJDVPU.js} +1 -1
  51. package/dist/chunk-4HEJDVPU.js.map +1 -0
  52. package/dist/{chunk-EEA2RM4B.js → chunk-4I6A3SDL.js} +2 -2
  53. package/dist/{chunk-SKJM4PKE.js → chunk-4JI5PPFW.js} +2 -2
  54. package/dist/{chunk-TDG5NZAZ.js → chunk-65JA7LWV.js} +2 -2
  55. package/dist/{chunk-3YID7KZ6.js → chunk-6QMKUWXH.js} +2 -2
  56. package/dist/{chunk-7SOKOEAZ.js → chunk-6RRHTHKQ.js} +2 -2
  57. package/dist/{chunk-VHQNJW4Q.js → chunk-6W62D4MC.js} +2 -2
  58. package/dist/{chunk-CRS2NY44.js → chunk-7O6H7BPW.js} +2 -2
  59. package/dist/{chunk-VSLV3EEP.js → chunk-7TK5Q6LQ.js} +112 -81
  60. package/dist/chunk-7TK5Q6LQ.js.map +1 -0
  61. package/dist/{chunk-NN3LMWKA.js → chunk-7TQ3EDQ3.js} +1 -1
  62. package/dist/chunk-7TQ3EDQ3.js.map +1 -0
  63. package/dist/{chunk-KJ65WZHB.js → chunk-A7DIZOTF.js} +2 -2
  64. package/dist/{chunk-TZ7ZA2LM.js → chunk-AD3JOG2Q.js} +2 -2
  65. package/dist/{chunk-2QW5HPKU.js → chunk-AUDLHIHI.js} +35 -28
  66. package/dist/chunk-AUDLHIHI.js.map +1 -0
  67. package/dist/{chunk-BDFSVUUZ.js → chunk-C3H2QZOZ.js} +2 -1
  68. package/dist/chunk-C3H2QZOZ.js.map +1 -0
  69. package/dist/{chunk-7EP4FURO.js → chunk-C72YQM7E.js} +2 -2
  70. package/dist/{chunk-4EAVEDLG.js → chunk-CRKT2JXN.js} +9 -9
  71. package/dist/{chunk-CJSTQNE5.js → chunk-CTOMDCCA.js} +2 -2
  72. package/dist/{chunk-PSQ347YP.js → chunk-DSKII2W4.js} +3 -3
  73. package/dist/{chunk-KOVQZJ27.js → chunk-E7LDTUWK.js} +2 -2
  74. package/dist/{chunk-SPAKBUJY.js → chunk-EWLMEYLF.js} +2 -2
  75. package/dist/{chunk-JJ42IDJU.js → chunk-FEGQI5KR.js} +2 -2
  76. package/dist/{chunk-3BICT225.js → chunk-FGNBUUPX.js} +2 -2
  77. package/dist/{chunk-QZMGZBTF.js → chunk-HBG6CQEX.js} +2 -2
  78. package/dist/{chunk-7V6GNQC2.js → chunk-HINQENZG.js} +2 -2
  79. package/dist/{chunk-WRVKI6ZO.js → chunk-HLQXSX4F.js} +2 -2
  80. package/dist/{chunk-KQIOW3TG.js → chunk-HUDE2SQA.js} +2 -2
  81. package/dist/{chunk-T765HQ5U.js → chunk-IIDAN7XJ.js} +2 -2
  82. package/dist/{chunk-M7Q7Z6V5.js → chunk-JDZ5JPYG.js} +38 -8
  83. package/dist/chunk-JDZ5JPYG.js.map +1 -0
  84. package/dist/{chunk-VMNX2UV7.js → chunk-JRUOIEFL.js} +5 -5
  85. package/dist/{chunk-JKMIGCK6.js → chunk-KDGEEZOI.js} +3 -2
  86. package/dist/chunk-KDGEEZOI.js.map +1 -0
  87. package/dist/{chunk-MMRTPH3J.js → chunk-KQYGUFMQ.js} +5 -3
  88. package/dist/chunk-KQYGUFMQ.js.map +1 -0
  89. package/dist/{chunk-TWYYUMYO.js → chunk-KXAGZRJV.js} +2 -2
  90. package/dist/{chunk-JITK24KX.js → chunk-LJNCJK7B.js} +10 -10
  91. package/dist/{chunk-Z6EFSXU3.js → chunk-LMM2LRVQ.js} +2 -2
  92. package/dist/{chunk-V65H7MI6.js → chunk-M42UFQZY.js} +51 -4
  93. package/dist/chunk-M42UFQZY.js.map +1 -0
  94. package/dist/{chunk-KZ4BJRGQ.js → chunk-ODGVLSCQ.js} +2 -2
  95. package/dist/{chunk-AALJHIKH.js → chunk-OHJ5PNYB.js} +3 -3
  96. package/dist/{chunk-XZMQLON4.js → chunk-OK726OF4.js} +7 -5
  97. package/dist/chunk-OK726OF4.js.map +1 -0
  98. package/dist/{chunk-Q6S67LHR.js → chunk-OOMFFMX3.js} +2 -2
  99. package/dist/{chunk-YCJJODER.js → chunk-PNDTRIOI.js} +10 -3
  100. package/dist/chunk-PNDTRIOI.js.map +1 -0
  101. package/dist/{chunk-3RZ4GDOH.js → chunk-PX4AMRAN.js} +93 -23
  102. package/dist/chunk-PX4AMRAN.js.map +1 -0
  103. package/dist/{chunk-JNDMIAJ4.js → chunk-QEVZKJM6.js} +2 -2
  104. package/dist/{chunk-ZNCCX7P6.js → chunk-QO5QZR2U.js} +2 -2
  105. package/dist/{chunk-NFQKIZK3.js → chunk-QXEF66SC.js} +2 -2
  106. package/dist/{chunk-NKHRIDYP.js → chunk-RTXW6E6X.js} +3 -3
  107. package/dist/{chunk-5WDUY2ZZ.js → chunk-S4QWAWR6.js} +4 -4
  108. package/dist/{chunk-HEJFE3BC.js → chunk-SJCN7ESG.js} +2 -2
  109. package/dist/{chunk-AJ7JHHRY.js → chunk-SPPWVMP4.js} +2 -2
  110. package/dist/{chunk-QSF5SJAM.js → chunk-STQNKDKZ.js} +9 -3
  111. package/dist/chunk-STQNKDKZ.js.map +1 -0
  112. package/dist/{chunk-QFKNIKUF.js → chunk-SXR7L57Z.js} +2 -2
  113. package/dist/{chunk-GYCUX3N4.js → chunk-TGMIJABS.js} +2 -2
  114. package/dist/{chunk-GH7IKABD.js → chunk-UFJJMQDV.js} +2 -2
  115. package/dist/{chunk-FKHXXL42.js → chunk-VAE6QCZQ.js} +2 -2
  116. package/dist/{chunk-UH2VY2QQ.js → chunk-WCW7I7ZM.js} +2 -2
  117. package/dist/{chunk-5GIYIYJI.js → chunk-WLP3XJCO.js} +2 -2
  118. package/dist/{chunk-STSORBX5.js → chunk-XII23FXP.js} +1 -1
  119. package/dist/chunk-XII23FXP.js.map +1 -0
  120. package/dist/{chunk-LR6LWX33.js → chunk-XXDIPAUE.js} +2 -2
  121. package/dist/{chunk-G2MS56KM.js → chunk-YQUGYQRY.js} +2 -2
  122. package/dist/{chunk-WEI6HEUX.js → chunk-YXAH5TSN.js} +2 -2
  123. package/dist/{chunk-75K6DRPN.js → chunk-ZAVFAGBE.js} +2 -2
  124. package/dist/{chunk-7KTORRIK.js → chunk-ZNJU3NBJ.js} +2 -2
  125. package/dist/cli.js +65 -66
  126. package/dist/coding/export-okf-codegraph.js +9 -8
  127. package/dist/coding/export-okf-codegraph.js.map +1 -1
  128. package/dist/compounding/engine.js +8 -7
  129. package/dist/config.d.ts.map +1 -1
  130. package/dist/config.js +7 -6
  131. package/dist/connectors/codex-materialize-runner.js +7 -6
  132. package/dist/connectors/index.js +7 -6
  133. package/dist/convergence-refresh.js +9 -8
  134. package/dist/corpus-watermark.js +9 -8
  135. package/dist/deep-recall-http-glue.js +2 -2
  136. package/dist/deep-recall-policy-llm.js +4 -3
  137. package/dist/entity-retrieval.js +7 -6
  138. package/dist/eval-trajectory-store.js +2 -2
  139. package/dist/eval-trajectory.js +2 -2
  140. package/dist/evals.d.ts.map +1 -1
  141. package/dist/evals.js +1 -1
  142. package/dist/explicit-capture.js +65 -66
  143. package/dist/extraction-error-classification.d.ts +40 -5
  144. package/dist/extraction-error-classification.d.ts.map +1 -1
  145. package/dist/extraction-error-classification.js +5 -2
  146. package/dist/extraction-faithfulness.js +4 -3
  147. package/dist/extraction-judge.js +4 -3
  148. package/dist/extraction.d.ts.map +1 -1
  149. package/dist/extraction.js +17 -18
  150. package/dist/fallback-llm-codex-subscription.d.ts +3 -1
  151. package/dist/fallback-llm-codex-subscription.d.ts.map +1 -1
  152. package/dist/fallback-llm-codex-subscription.js +2 -1
  153. package/dist/fallback-llm.d.ts.map +1 -1
  154. package/dist/fallback-llm.js +3 -2
  155. package/dist/harmonic-retrieval.js +7 -6
  156. package/dist/index.js +65 -66
  157. package/dist/live-connectors-runner.js +1 -2
  158. package/dist/local-llm-helpers.d.ts +1 -0
  159. package/dist/local-llm-helpers.d.ts.map +1 -1
  160. package/dist/local-llm-helpers.js +1 -1
  161. package/dist/local-llm.d.ts.map +1 -1
  162. package/dist/local-llm.js +4 -3
  163. package/dist/location/index.js +8 -7
  164. package/dist/maintenance/memory-governance.js +7 -6
  165. package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +7 -6
  166. package/dist/maintenance/rebuild-memory-projection-runner.js +9 -8
  167. package/dist/maintenance/rebuild-memory-projection.js +8 -7
  168. package/dist/memory-browse.js +3 -3
  169. package/dist/namespaces/migrate.js +8 -7
  170. package/dist/namespaces/storage.js +7 -6
  171. package/dist/operator-doctor-corpus.js +10 -9
  172. package/dist/operator-toolkit.js +15 -14
  173. package/dist/orchestration/backlog-scheduler.js +66 -67
  174. package/dist/orchestration/backlog-scheduler.js.map +1 -1
  175. package/dist/orchestration/buffer-drain-runner.js +66 -67
  176. package/dist/orchestration/extraction-drain.d.ts +1 -0
  177. package/dist/orchestration/extraction-drain.d.ts.map +1 -1
  178. package/dist/orchestration/extraction-run-helpers.d.ts +41 -4
  179. package/dist/orchestration/extraction-run-helpers.d.ts.map +1 -1
  180. package/dist/orchestration/extraction-run.d.ts +4 -0
  181. package/dist/orchestration/extraction-run.d.ts.map +1 -1
  182. package/dist/orchestration/maintenance.js +17 -16
  183. package/dist/orchestration/orchestrator-helpers.d.ts +2 -0
  184. package/dist/orchestration/orchestrator-helpers.d.ts.map +1 -1
  185. package/dist/orchestration/recall-entry.d.ts +2 -2
  186. package/dist/orchestration/recall-entry.d.ts.map +1 -1
  187. package/dist/orchestration/recall-internal.d.ts.map +1 -1
  188. package/dist/orchestrator.d.ts.map +1 -1
  189. package/dist/orchestrator.js +65 -66
  190. package/dist/recall-explain-renderer.js +3 -3
  191. package/dist/recall-navigate-access.js +2 -2
  192. package/dist/recall-navigate-disclosure.js +2 -2
  193. package/dist/recall-navigate.js +2 -2
  194. package/dist/recall-navigation.js +65 -66
  195. package/dist/recall-planner-llm.js +3 -2
  196. package/dist/recall-planner-llm.js.map +1 -1
  197. package/dist/recall-state-view-admission.js +3 -3
  198. package/dist/recall-why-service.js +3 -3
  199. package/dist/recall-xray-cli.js +4 -4
  200. package/dist/recall-xray-renderer.js +3 -3
  201. package/dist/recall-xray.js +2 -2
  202. package/dist/resume-bundles.js +8 -7
  203. package/dist/semantic-consolidation.js +8 -7
  204. package/dist/semantic-rule-promotion.js +7 -6
  205. package/dist/semantic-rule-verifier.js +7 -6
  206. package/dist/source-agent-qualifier.js +10 -9
  207. package/dist/standup/build.js +7 -6
  208. package/dist/storage.d.ts.map +1 -1
  209. package/dist/storage.js +6 -5
  210. package/dist/summarizer.js +6 -5
  211. package/dist/support-passport/index.js +6 -5
  212. package/dist/transfer/export-okf.js +7 -6
  213. package/dist/types-extraction-failure.d.ts +7 -1
  214. package/dist/types-extraction-failure.d.ts.map +1 -1
  215. package/dist/types.d.ts +6 -6
  216. package/dist/types.d.ts.map +1 -1
  217. package/dist/types.js +1 -1
  218. package/dist/verified-recall.js +7 -6
  219. package/dist/who-knows-cli.js +8 -7
  220. package/dist/who-knows.js +7 -6
  221. package/package.json +2 -2
  222. package/src/access-mcp.ts +8 -0
  223. package/src/access-recall-concurrency.ts +35 -2
  224. package/src/access-recall-response.ts +3 -1
  225. package/src/access-recall-surface.ts +1 -0
  226. package/src/access-schema.ts +8 -0
  227. package/src/access-service-recall-concurrency.test.ts +65 -0
  228. package/src/access-service.ts +4 -3
  229. package/src/buffer-incremental-persistence.test.ts +23 -0
  230. package/src/buffer.ts +30 -28
  231. package/src/config.ts +2 -0
  232. package/src/evals.ts +6 -6
  233. package/src/extraction-error-classification.ts +88 -8
  234. package/src/extraction-local-failure-class.test.ts +117 -3
  235. package/src/extraction-reply-diagnostic-wiring.test.ts +3 -1
  236. package/src/extraction.test.ts +73 -3
  237. package/src/extraction.ts +26 -25
  238. package/src/fallback-llm-codex-subscription.ts +17 -3
  239. package/src/fallback-llm.test.ts +70 -0
  240. package/src/fallback-llm.ts +17 -18
  241. package/src/local-llm-headers-timeout.test.ts +151 -0
  242. package/src/local-llm-helpers.ts +1 -1
  243. package/src/local-llm.ts +44 -43
  244. package/src/orchestration/extraction-drain.ts +11 -5
  245. package/src/orchestration/extraction-run-helpers.ts +110 -4
  246. package/src/orchestration/extraction-run.test.ts +408 -3
  247. package/src/orchestration/extraction-run.ts +75 -75
  248. package/src/orchestration/orchestrator-helpers.ts +2 -0
  249. package/src/orchestration/recall-entry.ts +7 -7
  250. package/src/orchestration/recall-internal.ts +14 -4
  251. package/src/orchestrator.ts +3 -2
  252. package/src/recall-client-deadline-trace.test.ts +209 -0
  253. package/src/storage.ts +5 -4
  254. package/src/types-extraction-failure.ts +12 -1
  255. package/src/types.ts +6 -6
  256. package/dist/chunk-2QW5HPKU.js.map +0 -1
  257. package/dist/chunk-3RZ4GDOH.js.map +0 -1
  258. package/dist/chunk-BDFSVUUZ.js.map +0 -1
  259. package/dist/chunk-C7SRUWBW.js +0 -54
  260. package/dist/chunk-C7SRUWBW.js.map +0 -1
  261. package/dist/chunk-F2MVWUNF.js.map +0 -1
  262. package/dist/chunk-FZU62GIV.js.map +0 -1
  263. package/dist/chunk-JKMIGCK6.js.map +0 -1
  264. package/dist/chunk-M7Q7Z6V5.js.map +0 -1
  265. package/dist/chunk-MMRTPH3J.js.map +0 -1
  266. package/dist/chunk-NN3LMWKA.js.map +0 -1
  267. package/dist/chunk-QIPRDRGM.js.map +0 -1
  268. package/dist/chunk-QSF5SJAM.js.map +0 -1
  269. package/dist/chunk-STSORBX5.js.map +0 -1
  270. package/dist/chunk-V65H7MI6.js.map +0 -1
  271. package/dist/chunk-VSLV3EEP.js.map +0 -1
  272. package/dist/chunk-XZMQLON4.js.map +0 -1
  273. package/dist/chunk-YCJJODER.js.map +0 -1
  274. /package/dist/{chunk-3ZS3NUEI.js.map → chunk-3DSLTUK6.js.map} +0 -0
  275. /package/dist/{chunk-DYUPSTCV.js.map → chunk-3EXG2KPK.js.map} +0 -0
  276. /package/dist/{chunk-FGFU6J26.js.map → chunk-4FTYKZ77.js.map} +0 -0
  277. /package/dist/{chunk-EEA2RM4B.js.map → chunk-4I6A3SDL.js.map} +0 -0
  278. /package/dist/{chunk-SKJM4PKE.js.map → chunk-4JI5PPFW.js.map} +0 -0
  279. /package/dist/{chunk-TDG5NZAZ.js.map → chunk-65JA7LWV.js.map} +0 -0
  280. /package/dist/{chunk-3YID7KZ6.js.map → chunk-6QMKUWXH.js.map} +0 -0
  281. /package/dist/{chunk-7SOKOEAZ.js.map → chunk-6RRHTHKQ.js.map} +0 -0
  282. /package/dist/{chunk-VHQNJW4Q.js.map → chunk-6W62D4MC.js.map} +0 -0
  283. /package/dist/{chunk-CRS2NY44.js.map → chunk-7O6H7BPW.js.map} +0 -0
  284. /package/dist/{chunk-KJ65WZHB.js.map → chunk-A7DIZOTF.js.map} +0 -0
  285. /package/dist/{chunk-TZ7ZA2LM.js.map → chunk-AD3JOG2Q.js.map} +0 -0
  286. /package/dist/{chunk-7EP4FURO.js.map → chunk-C72YQM7E.js.map} +0 -0
  287. /package/dist/{chunk-4EAVEDLG.js.map → chunk-CRKT2JXN.js.map} +0 -0
  288. /package/dist/{chunk-CJSTQNE5.js.map → chunk-CTOMDCCA.js.map} +0 -0
  289. /package/dist/{chunk-PSQ347YP.js.map → chunk-DSKII2W4.js.map} +0 -0
  290. /package/dist/{chunk-KOVQZJ27.js.map → chunk-E7LDTUWK.js.map} +0 -0
  291. /package/dist/{chunk-SPAKBUJY.js.map → chunk-EWLMEYLF.js.map} +0 -0
  292. /package/dist/{chunk-JJ42IDJU.js.map → chunk-FEGQI5KR.js.map} +0 -0
  293. /package/dist/{chunk-3BICT225.js.map → chunk-FGNBUUPX.js.map} +0 -0
  294. /package/dist/{chunk-QZMGZBTF.js.map → chunk-HBG6CQEX.js.map} +0 -0
  295. /package/dist/{chunk-7V6GNQC2.js.map → chunk-HINQENZG.js.map} +0 -0
  296. /package/dist/{chunk-WRVKI6ZO.js.map → chunk-HLQXSX4F.js.map} +0 -0
  297. /package/dist/{chunk-KQIOW3TG.js.map → chunk-HUDE2SQA.js.map} +0 -0
  298. /package/dist/{chunk-T765HQ5U.js.map → chunk-IIDAN7XJ.js.map} +0 -0
  299. /package/dist/{chunk-VMNX2UV7.js.map → chunk-JRUOIEFL.js.map} +0 -0
  300. /package/dist/{chunk-TWYYUMYO.js.map → chunk-KXAGZRJV.js.map} +0 -0
  301. /package/dist/{chunk-JITK24KX.js.map → chunk-LJNCJK7B.js.map} +0 -0
  302. /package/dist/{chunk-Z6EFSXU3.js.map → chunk-LMM2LRVQ.js.map} +0 -0
  303. /package/dist/{chunk-KZ4BJRGQ.js.map → chunk-ODGVLSCQ.js.map} +0 -0
  304. /package/dist/{chunk-AALJHIKH.js.map → chunk-OHJ5PNYB.js.map} +0 -0
  305. /package/dist/{chunk-Q6S67LHR.js.map → chunk-OOMFFMX3.js.map} +0 -0
  306. /package/dist/{chunk-JNDMIAJ4.js.map → chunk-QEVZKJM6.js.map} +0 -0
  307. /package/dist/{chunk-ZNCCX7P6.js.map → chunk-QO5QZR2U.js.map} +0 -0
  308. /package/dist/{chunk-NFQKIZK3.js.map → chunk-QXEF66SC.js.map} +0 -0
  309. /package/dist/{chunk-NKHRIDYP.js.map → chunk-RTXW6E6X.js.map} +0 -0
  310. /package/dist/{chunk-5WDUY2ZZ.js.map → chunk-S4QWAWR6.js.map} +0 -0
  311. /package/dist/{chunk-HEJFE3BC.js.map → chunk-SJCN7ESG.js.map} +0 -0
  312. /package/dist/{chunk-AJ7JHHRY.js.map → chunk-SPPWVMP4.js.map} +0 -0
  313. /package/dist/{chunk-QFKNIKUF.js.map → chunk-SXR7L57Z.js.map} +0 -0
  314. /package/dist/{chunk-GYCUX3N4.js.map → chunk-TGMIJABS.js.map} +0 -0
  315. /package/dist/{chunk-GH7IKABD.js.map → chunk-UFJJMQDV.js.map} +0 -0
  316. /package/dist/{chunk-FKHXXL42.js.map → chunk-VAE6QCZQ.js.map} +0 -0
  317. /package/dist/{chunk-UH2VY2QQ.js.map → chunk-WCW7I7ZM.js.map} +0 -0
  318. /package/dist/{chunk-5GIYIYJI.js.map → chunk-WLP3XJCO.js.map} +0 -0
  319. /package/dist/{chunk-LR6LWX33.js.map → chunk-XXDIPAUE.js.map} +0 -0
  320. /package/dist/{chunk-G2MS56KM.js.map → chunk-YQUGYQRY.js.map} +0 -0
  321. /package/dist/{chunk-WEI6HEUX.js.map → chunk-YXAH5TSN.js.map} +0 -0
  322. /package/dist/{chunk-75K6DRPN.js.map → chunk-ZAVFAGBE.js.map} +0 -0
  323. /package/dist/{chunk-7KTORRIK.js.map → chunk-ZNJU3NBJ.js.map} +0 -0
@@ -11,6 +11,7 @@ import assert from "node:assert/strict";
11
11
  import test from "node:test";
12
12
 
13
13
  import { classifyExtractionThrownError, classifyFallbackParseFailure, formatExtractionParseFailureLog } from "./extraction.js";
14
+ import { classifyLocalLlmRejected, LocalLlmRejectedError } from "./extraction-error-classification.js";
14
15
 
15
16
  test("classifyExtractionThrownError: 401/403 → auth_config", () => {
16
17
  assert.equal(classifyExtractionThrownError({ status: 401 }), "auth_config");
@@ -24,14 +25,83 @@ test("classifyExtractionThrownError: 429/5xx → provider_retryable", () => {
24
25
  assert.equal(classifyExtractionThrownError({ status: 503 }), "provider_retryable");
25
26
  });
26
27
 
27
- test("classifyExtractionThrownError: bare network error / unknown → provider_retryable (fail-open toward retry)", () => {
28
+ test("classifyExtractionThrownError: bare network error / statusless failure → provider_retryable (fail-open toward retry)", () => {
28
29
  assert.equal(classifyExtractionThrownError(new Error("socket hang up")), "provider_retryable");
29
- // A terminal non-auth 4xx still defaults to retryable (capped by the attempt budget).
30
- assert.equal(classifyExtractionThrownError({ status: 400 }), "provider_retryable");
30
+ // A bare Error carries no status — the shared classifier treats it as a plain
31
+ // network failure (a local endpoint coming back up drains it).
32
+ assert.equal(classifyExtractionThrownError(new Error("model produced unparseable output")), "provider_retryable");
33
+ // Unknown non-HTTP failures stay retryable: an innocent buffered window is
34
+ // never silently dead-lettered for a failure shape nobody classified.
31
35
  assert.equal(classifyExtractionThrownError(null), "provider_retryable");
32
36
  assert.equal(classifyExtractionThrownError("not an object"), "provider_retryable");
33
37
  });
34
38
 
39
+ test("classifyExtractionThrownError: input-refusing terminal status → provider_permanent", () => {
40
+ // 400/413/422 refuse THIS request — a resend of the identical payload can
41
+ // never succeed, so the fingerprint dead-letters at its attempt cap.
42
+ assert.equal(classifyExtractionThrownError({ status: 400 }), "provider_permanent");
43
+ assert.equal(classifyExtractionThrownError({ status: 413 }), "provider_permanent");
44
+ assert.equal(classifyExtractionThrownError({ status: 422 }), "provider_permanent");
45
+ assert.equal(classifyExtractionThrownError({ statusCode: 400 }), "provider_permanent");
46
+ });
47
+
48
+ test("classifyExtractionThrownError: other terminal status → auth_config (setup problem, not the chunk's)", () => {
49
+ // A missing route or model is the endpoint setup's problem — the breaker
50
+ // opens instead of dropping innocent windows.
51
+ assert.equal(classifyExtractionThrownError({ status: 404 }), "auth_config");
52
+ assert.equal(classifyExtractionThrownError({ status: 405 }), "auth_config");
53
+ assert.equal(classifyExtractionThrownError({ status: 410 }), "auth_config");
54
+ // `statusCode` spellings resolve the same way: the recognized status — not a
55
+ // statusless transient fallback — decides retryability (405/410 included).
56
+ assert.equal(classifyExtractionThrownError({ statusCode: 404 }), "auth_config");
57
+ assert.equal(classifyExtractionThrownError({ statusCode: 405 }), "auth_config");
58
+ assert.equal(classifyExtractionThrownError({ statusCode: 410 }), "auth_config");
59
+ });
60
+
61
+ test("classifyExtractionThrownError: statusCode transient statuses stay provider_retryable", () => {
62
+ assert.equal(classifyExtractionThrownError({ statusCode: 429 }), "provider_retryable");
63
+ assert.equal(classifyExtractionThrownError({ statusCode: 503 }), "provider_retryable");
64
+ });
65
+
66
+ test("classifyExtractionThrownError: parameter/config 400 stays auth_config; input-refusal 400 stays provider_permanent", () => {
67
+ // The fallback-llm unsupported-`temperature` shape — a setup failure, retained.
68
+ assert.equal(
69
+ classifyExtractionThrownError({ status: 400, message: "Unsupported parameter: 'temperature' is not supported with this model." }),
70
+ "auth_config",
71
+ );
72
+ assert.equal(classifyExtractionThrownError({ statusCode: 400, message: "unknown parameter: 'top_k'" }), "auth_config");
73
+ assert.equal(classifyExtractionThrownError({ status: 400, code: "unsupported_parameter", param: "temperature" }), "auth_config");
74
+ assert.equal(classifyExtractionThrownError({ status: 400, code: "http_4xx_parameter" }), "auth_config");
75
+ assert.equal(classifyExtractionThrownError({ status: 400, error: { code: "unknown_parameter" } }), "auth_config");
76
+ // Ambiguous and content-refusing 400s still dead-letter as input refusals —
77
+ // including a bare `unexpected value` phrase that names the payload, not a
78
+ // request parameter (#3757).
79
+ assert.equal(classifyExtractionThrownError({ status: 400, message: "content violates the provider usage policy" }), "provider_permanent");
80
+ assert.equal(classifyExtractionThrownError({ status: 400, message: "Input content rejected: unexpected value in messages[0].content" }), "provider_permanent");
81
+ assert.equal(classifyExtractionThrownError({ status: 400 }), "provider_permanent");
82
+ });
83
+
84
+ test("classifyExtractionThrownError: a refusal beside a transient sibling attempt stays retryable", () => {
85
+ // Model-chain exhaustion where an earlier attempt failed transiently is not
86
+ // conclusive proof the window is unextractable — the drain's own bound governs.
87
+ assert.equal(classifyExtractionThrownError({ status: 413, transientAttemptSeen: true }), "provider_retryable");
88
+ assert.equal(classifyExtractionThrownError({ status: 422, transientAttemptSeen: true }), "provider_retryable");
89
+ assert.equal(classifyExtractionThrownError({ status: 413, transientAttemptSeen: false }), "provider_permanent");
90
+ assert.equal(classifyExtractionThrownError({ status: 413 }), "provider_permanent");
91
+ });
92
+
93
+ test("classifyLocalLlmRejected: status-bearing rejections dead-letter, statusless stays parse_empty", () => {
94
+ // 400/413/422 refuse THIS input (localRejectionStatus already filtered the set):
95
+ // bounded by the permanent cap, not by the parse_empty long-park.
96
+ assert.equal(classifyLocalLlmRejected(new LocalLlmRejectedError(400)), "provider_permanent");
97
+ assert.equal(classifyLocalLlmRejected(new LocalLlmRejectedError(413)), "provider_permanent");
98
+ assert.equal(classifyLocalLlmRejected(new LocalLlmRejectedError(422)), "provider_permanent");
99
+ assert.equal(classifyLocalLlmRejected(new LocalLlmRejectedError(undefined)), "parse_empty");
100
+ assert.equal(classifyLocalLlmRejected(new LocalLlmRejectedError(400, "length")), "output_truncated");
101
+ // A parameter-refusing 400 is the endpoint setup's problem: retained, never dropped.
102
+ assert.equal(classifyLocalLlmRejected(new LocalLlmRejectedError(400, undefined, true)), "auth_config");
103
+ });
104
+
35
105
  test("classifyFallbackParseFailure: maps the gateway parse-failure reasons", () => {
36
106
  assert.equal(classifyFallbackParseFailure("no_models"), "auth_config");
37
107
  assert.equal(classifyFallbackParseFailure("http_error"), "provider_retryable");
package/src/extraction.ts CHANGED
@@ -38,7 +38,7 @@ import {
38
38
  import { applyGroundingWithConnector, headerConnector, renderExtractionConversation, resolveSourceConnector, type ExtractionGroundingContext } from "./source-agent-qualifier.js";
39
39
  import { isMemoryCategory } from "./write-envelope.js";
40
40
  export { classifyExtractionThrownError, classifyFallbackParseFailure, formatExtractionParseFailureLog } from "./extraction-error-classification.js";
41
- import { LocalLlmRejectedError, classifyExtractionThrownError, classifyFallbackParseFailure, classifyLocalLlmRejected, formatExtractionParseFailureLog, directInputTooLargeResult, formatDirectInputTooLargeLog, isRequestTooLargeError, localRejectionStatus, type LocalFailureDiag } from "./extraction-error-classification.js";
41
+ import { LocalLlmRejectedError, classifyExtractionThrownError, classifyFallbackParseFailure, classifyLocalLlmRejected, downgradePermanentOnTransientAttempt, formatExtractionParseFailureLog, directInputTooLargeResult, formatDirectInputTooLargeLog, isParameterConfigRejection, isRequestTooLargeError, localRejectionStatus, type LocalFailureDiag } from "./extraction-error-classification.js";
42
42
  import { buildUnusableReplyDiagnostic, formatUnusableReplyDiagnostic, looksLikeExtractionResultPayload } from "./extraction-reply-diagnostic.js";
43
43
  import { AMBIENT_CAPTURE_PROMPT_SECTION_COMPACT, clampAmbientCaptureConfidence } from "./ambient-provenance.js";
44
44
  import {
@@ -810,9 +810,8 @@ export class ExtractionEngine {
810
810
  ? '- Source quotes: For each fact, include a "quote" field with the EXACT verbatim words from the conversation that support the fact (a contiguous span from a single turn, not a paraphrase). Cap at ~300 chars.'
811
811
  : "",
812
812
  // #1578: emit the same event-time guidance as the primary extraction
813
- // paths so proactive-recovered facts also carry an optional eventTime
814
- // (chatgpt-codex thread on extraction.ts:1607). Returns "" when the
815
- // bi-temporal gate is off, keeping the prompt unchanged by default.
813
+ // paths so proactive-recovered facts also carry an optional eventTime.
814
+ // Returns "" when the bi-temporal gate is off.
816
815
  eventTimePromptInstruction(this.config),
817
816
  headerConnector(sourceConnector) !== undefined && resolveMemoryLifecycleCapabilities(this.config).extractionScopeClassification
818
817
  ? `Tool, command, or CLI-flag instructions tied to the ${sourceConnector} agent are "project" scope; when you recover one, begin the fact with a leading "In ${sourceConnector}, " clause naming that agent (e.g. "In ${sourceConnector}, use the search tool with a repository path.").`
@@ -1091,10 +1090,9 @@ export class ExtractionEngine {
1091
1090
  : turn.content,
1092
1091
  }))
1093
1092
  .filter((turn) => turn.content.trim().length > 0);
1094
- // One derivation, over the turns the model actually sees (boundedTurns) —
1095
- // the same set the qualifier, grounding source, and telemetry filter
1096
- // operate on. result.sourceConnector carries it to persistence so the
1097
- // orchestrator does not recompute over a different turn set (#2183).
1093
+ // One derivation over the turns the model sees (boundedTurns) — the same
1094
+ // set the qualifier, grounding source, and telemetry filter use. Carried
1095
+ // to persistence via result.sourceConnector (#2183).
1098
1096
  const resolvedConnector = resolveSourceConnector(boundedTurns);
1099
1097
  // Ambient-capture provenance (issue #2294): true when any contributing turn
1100
1098
  // came from an always-on recorder, so the prompt warns about media audio
@@ -1179,10 +1177,10 @@ export class ExtractionEngine {
1179
1177
  localLlm: resolveLocalLlmCapabilities(this.config).localLlm,
1180
1178
  });
1181
1179
  this.profiler.startSpan("total", extractionTraceId);
1182
- // True when a local or direct extractor was attempted before the gateway
1183
- // fallback, so a gateway "no models" result doesn't re-classify a real
1184
- // primary failure as auth_config (codex review: preserve direct/local failures).
1185
- let primaryExtractorAttempted = false;
1180
+ // True when a primary extractor ran before the gateway fallback: a gateway
1181
+ // "no models" isn't auth_config then (codex review), and a transient
1182
+ // primary attempt makes a terminal-looking refusal inconclusive (#3757).
1183
+ let primaryExtractorAttempted = false, primaryTransientAttemptSeen = false;
1186
1184
  // Direct client refused the request as too large (#3531): report that if the gateway fails too.
1187
1185
  let directInputTooLarge = false;
1188
1186
 
@@ -1191,8 +1189,9 @@ export class ExtractionEngine {
1191
1189
  if (this.shouldUseLocalLlm) {
1192
1190
  this.profiler.startSpan("local-llm", extractionTraceId);
1193
1191
  primaryExtractorAttempted = true;
1192
+ const localDiag: LocalFailureDiag = {};
1194
1193
  try {
1195
- const localResult = await this.extractWithLocalLlm(conversation, signal, ambientCapture);
1194
+ const localResult = await this.extractWithLocalLlm(conversation, signal, ambientCapture, localDiag);
1196
1195
  throwIfExtractionAborted(signal);
1197
1196
  if (localResult) {
1198
1197
  const durationMs = Date.now() - startTime;
@@ -1225,6 +1224,7 @@ export class ExtractionEngine {
1225
1224
  extractionFailureClass: "provider_retryable",
1226
1225
  };
1227
1226
  }
1227
+ primaryTransientAttemptSeen ||= localDiag.sawTransientAttempt === true;
1228
1228
  log.info("extraction: local LLM unavailable, falling back to gateway default AI");
1229
1229
  } catch (err) {
1230
1230
  if (signal?.aborted) throw err;
@@ -1239,6 +1239,7 @@ export class ExtractionEngine {
1239
1239
  extractionFailureClass: err instanceof LocalLlmRejectedError ? classifyLocalLlmRejected(err) : classifyExtractionThrownError(err),
1240
1240
  };
1241
1241
  }
1242
+ primaryTransientAttemptSeen ||= localDiag.sawTransientAttempt === true || (err instanceof LocalLlmRejectedError ? classifyLocalLlmRejected(err) : classifyExtractionThrownError(err)) === "provider_retryable";
1242
1243
  log.info("extraction: local LLM error, falling back to gateway default AI:", err);
1243
1244
  } finally {
1244
1245
  // End local-llm span if it wasn't ended on the success path
@@ -1262,8 +1263,7 @@ export class ExtractionEngine {
1262
1263
  const finalResult = await this.applyProactiveQuestionPass(conversation, grounded, groundingContext, signal);
1263
1264
  return this.finalizeExtractionResult(finalResult, boundedTurns, resolvedConnector, ambientCapture);
1264
1265
  }
1265
- // Emit error event so Opik sees the direct client failure before fallback.
1266
- // Wrapped in try/catch so a subscriber error doesn't break the fallback path.
1266
+ // Emit llm_error for Opik before fallback; a subscriber error must not break it.
1267
1267
  try {
1268
1268
  this.emit({
1269
1269
  kind: "llm_error", traceId, model: this.config.model, operation: "extraction",
@@ -1283,6 +1283,7 @@ export class ExtractionEngine {
1283
1283
  closedDirectTrace = true;
1284
1284
  directInputTooLarge = err instanceof Object && isRequestTooLargeError(err);
1285
1285
  if (directInputTooLarge) log.warn(formatDirectInputTooLargeLog(conversation.length));
1286
+ primaryTransientAttemptSeen ||= classifyExtractionThrownError(err) === "provider_retryable";
1286
1287
  log.info("extraction: direct client failed, falling back to gateway AI:", err);
1287
1288
  } finally {
1288
1289
  try { this.profiler.endSpan("direct-client", extractionTraceId); } catch { /* span may already be closed */ }
@@ -1299,10 +1300,7 @@ export class ExtractionEngine {
1299
1300
  } catch { /* trace emit must not block fallback */ }
1300
1301
  }
1301
1302
 
1302
- // In gateway mode this is the primary extraction path. In plugin mode it is the
1303
- // final fallback after local/direct attempts fail. Emit a fresh llm_start so the
1304
- // gateway-backed call gets its own trace rather than being orphaned under the
1305
- // direct-client traceId.
1303
+ // Gateway mode: primary path; plugin mode: final fallback — a fresh llm_start gives the gateway call its own trace.
1306
1304
  const fallbackTraceId = crypto.randomUUID();
1307
1305
  const fallbackStartTime = Date.now();
1308
1306
  if (this.useGatewayModelSource) {
@@ -1386,10 +1384,12 @@ export class ExtractionEngine {
1386
1384
  const fallbackParseFailureClass: ExtractionFailureClass =
1387
1385
  detailed.result === null
1388
1386
  ? detailed.failureReason === "no_models" && primaryExtractorAttempted
1389
- ? // Gateway had no models, but a local/direct extractor already failed —
1390
- // the root cause is the primary (transient), not gateway auth/config.
1387
+ ? // The root cause is the primary's failure, not gateway auth/config.
1391
1388
  "provider_retryable"
1392
- : classifyFallbackParseFailure(detailed.failureReason)
1389
+ : // Status-bearing refusals classify via the thrown-error classifier — no unbounded retry (#3757).
1390
+ detailed.failureReason === "http_error" && detailed.httpStatus !== undefined
1391
+ ? classifyExtractionThrownError({ status: detailed.httpStatus, code: detailed.errorClass, transientAttemptSeen: detailed.sawTransientAttempt === true || primaryTransientAttemptSeen })
1392
+ : classifyFallbackParseFailure(detailed.failureReason)
1393
1393
  : "parse_empty";
1394
1394
  if (directInputTooLarge) return directInputTooLargeResult();
1395
1395
  return {
@@ -1414,7 +1414,7 @@ export class ExtractionEngine {
1414
1414
  entities: [],
1415
1415
  questions: [],
1416
1416
  extractionFailure: "fallback_failed",
1417
- extractionFailureClass: classifyExtractionThrownError(err),
1417
+ extractionFailureClass: downgradePermanentOnTransientAttempt(classifyExtractionThrownError(err), primaryTransientAttemptSeen),
1418
1418
  };
1419
1419
  } finally {
1420
1420
  try { this.profiler.endSpan("gateway-fallback", extractionTraceId); } catch { /* span may already be closed */ }
@@ -1435,6 +1435,7 @@ export class ExtractionEngine {
1435
1435
  conversation: string,
1436
1436
  signal?: AbortSignal,
1437
1437
  ambientCapture = false,
1438
+ diag?: LocalFailureDiag,
1438
1439
  ): Promise<ExtractionResult | null> {
1439
1440
  const lifecycleCaps = resolveMemoryLifecycleCapabilities(this.config);
1440
1441
  log.debug(
@@ -1490,7 +1491,7 @@ Conversation:
1490
1491
  ${truncatedConversation}`;
1491
1492
 
1492
1493
  log.debug(`extractWithLocalLlm: calling localLlm.chatCompletion with prompt length ${localPrompt.length}...`);
1493
- const failureDiag: LocalFailureDiag = {};
1494
+ const failureDiag: LocalFailureDiag = diag ?? {};
1494
1495
  const response = await this.localLlm.chatCompletion(
1495
1496
  [
1496
1497
  { role: "system", content: "You are a memory extraction system. Output valid JSON only." },
@@ -1513,7 +1514,7 @@ ${truncatedConversation}`;
1513
1514
  const rejected = localRejectionStatus(failureDiag);
1514
1515
  if (rejected !== undefined) {
1515
1516
  log.warn(formatUnusableReplyDiagnostic(buildUnusableReplyDiagnostic("", failureDiag.finishReason, 0, contextSizes.maxOutputTokens)));
1516
- throw new LocalLlmRejectedError(rejected, failureDiag.finishReason); // the endpoint is up and refuses this input
1517
+ throw new LocalLlmRejectedError(rejected, failureDiag.finishReason, rejected === 400 && isParameterConfigRejection(failureDiag.lastError), failureDiag.sawTransientAttempt); // the endpoint is up and refuses this input
1517
1518
  }
1518
1519
  log.debug("extractWithLocalLlm: chatCompletion returned null or empty content");
1519
1520
  return null;
@@ -19,6 +19,7 @@ import {
19
19
  getCodexSubscriptionShutdownSignal,
20
20
  isDefaultRegisteredCodexSubscriptionRunner,
21
21
  } from "./providers/codex-subscription.js";
22
+ import { isParameterConfigRejection } from "./extraction-error-classification.js";
22
23
  import type { GetRuntimeAuthForModelFn, ResolveApiKeyFn } from "./resolve-provider-secret.js";
23
24
  import { resolveHomeDir } from "./runtime/env.js";
24
25
  import type { GatewayConfig, ModelProviderConfig } from "./types.js";
@@ -267,8 +268,10 @@ export interface StructuredParseFailure {
267
268
  attemptedModel?: string;
268
269
  /** HTTP status when known. Never a response body. */
269
270
  httpStatus?: number;
270
- /** Coarse class: http_4xx / http_5xx / timeout / network / empty / schema_rejection / no_models. */
271
+ /** Coarse class: http_4xx / http_4xx_parameter / http_5xx / timeout / network / empty / schema_rejection / no_models. */
271
272
  errorClass?: string;
273
+ /** An earlier model in the chain failed transiently (5xx/408/429/timeout/network) — the last-attempt refusal is not conclusive proof the window is unextractable. */
274
+ sawTransientAttempt?: boolean;
272
275
  }
273
276
 
274
277
  export type StructuredParseResult<T> =
@@ -306,7 +309,14 @@ export function fallbackLlmRuntimeContextFromConfig(
306
309
  };
307
310
  }
308
311
 
309
- const HTTP_STATUS_IN_MESSAGE = /\b([1-5]\d{2})\b/;
312
+ // Only trust a status token at the message start (`400 {...}` SDK shape) or
313
+ // beside an HTTP/status keyword — a bare 3-digit token elsewhere is usually
314
+ // part of prose (e.g. "after 400 attempts") and must not masquerade as an
315
+ // HTTP refusal (#3757). No status → `provider_retryable`, the safe direction.
316
+ // Every quantifier is bounded so the scan stays linear on hostile messages
317
+ // (CodeQL polynomial-regex alert on uncontrolled data).
318
+ const HTTP_STATUS_IN_MESSAGE =
319
+ /(?:^\s{0,4}\(?\s{0,4}|(?:https?[\w./]{0,16}|status\s{0,4}code|status|error)\b\s{0,4}[:=]?\s{0,4}\(?\s{0,4})([1-5]\d{2})\b/i;
310
320
 
311
321
  export function isTimeoutError(err: unknown): boolean {
312
322
  const msg = err instanceof Error ? err.message : String(err);
@@ -359,7 +369,11 @@ export function classifyThrownProviderError(err: unknown): Omit<StructuredParseF
359
369
  return {
360
370
  failureReason: "http_error",
361
371
  httpStatus,
362
- errorClass: errorClassForHttpStatus(httpStatus),
372
+ // A 400 that refuses a request parameter (unsupported `temperature`,
373
+ // unknown field) is a setup failure — tag it so the failure-class
374
+ // mapping retains the window instead of dead-lettering it.
375
+ errorClass:
376
+ httpStatus === 400 && isParameterConfigRejection(err) ? "http_4xx_parameter" : errorClassForHttpStatus(httpStatus),
363
377
  };
364
378
  }
365
379
  return { failureReason: "http_error", errorClass: "network" };
@@ -1,6 +1,7 @@
1
1
  import assert from "node:assert/strict";
2
2
  import path from "node:path";
3
3
  import test from "node:test";
4
+ import { z } from "zod";
4
5
 
5
6
  import { FallbackLlmClient, gatewayTaskChainOptions } from "./fallback-llm.js";
6
7
  import { classifyAnalysisProviderError } from "./activity/timeline/analysis-provider.js";
@@ -13,6 +14,7 @@ import {
13
14
  clearSecretCache,
14
15
  } from "./resolve-provider-secret.js";
15
16
  import { CodexSubscriptionTimeoutError } from "./providers/codex-subscription.js";
17
+ import { classifyThrownProviderError } from "./fallback-llm-codex-subscription.js";
16
18
 
17
19
  test("fallback llm sends native JSON schema to chat completions", { concurrency: false }, async () => {
18
20
  clearModelsJsonCache();
@@ -2216,3 +2218,71 @@ test("fallback llm adds reasoningHeadroomTokens to the Chat Completions token li
2216
2218
  clearSecretCache();
2217
2219
  }
2218
2220
  });
2221
+
2222
+ test("classifyThrownProviderError tags a parameter-refusing 400 as http_4xx_parameter", () => {
2223
+ // The unsupported-`temperature` shape the transport deliberately does not
2224
+ // recover: tagging it keeps the failure-class mapping from dead-lettering
2225
+ // valid windows for a setup error.
2226
+ const parameterRefusal = classifyThrownProviderError(
2227
+ Object.assign(new Error("Unsupported parameter: 'temperature' is not supported with this model."), { status: 400 }),
2228
+ );
2229
+ assert.equal(parameterRefusal.failureReason, "http_error");
2230
+ assert.equal(parameterRefusal.httpStatus, 400);
2231
+ assert.equal(parameterRefusal.errorClass, "http_4xx_parameter");
2232
+
2233
+ const inputRefusal = classifyThrownProviderError(
2234
+ Object.assign(new Error("content violates the provider usage policy"), { status: 400 }),
2235
+ );
2236
+ assert.equal(inputRefusal.errorClass, "http_4xx");
2237
+ });
2238
+
2239
+ test("classifyThrownProviderError only trusts status-shaped message tokens", () => {
2240
+ // Prose numbers are not HTTP statuses — an unresolved-secret style message
2241
+ // must not masquerade as an input refusal.
2242
+ assert.equal(
2243
+ classifyThrownProviderError(new Error("provider key lookup failed after 400 attempts")).httpStatus,
2244
+ undefined,
2245
+ );
2246
+ assert.equal(
2247
+ classifyThrownProviderError(new Error('400 {"error":{"message":"bad request"}}')).httpStatus,
2248
+ 400,
2249
+ );
2250
+ assert.equal(
2251
+ classifyThrownProviderError(new Error("Request failed with status code 429")).httpStatus,
2252
+ 429,
2253
+ );
2254
+ });
2255
+
2256
+ test("a chain failure preserves a transient sibling attempt for classification", { concurrency: false }, async () => {
2257
+ clearModelsJsonCache();
2258
+ clearSecretCache();
2259
+ const llm = new FallbackLlmClient({
2260
+ agents: { defaults: { model: { primary: "openai/model-a", fallbacks: ["openai/model-b"] } } },
2261
+ models: { providers: { openai: { baseUrl: "https://openai.example/v1", api: "openai-completions", apiKey: "key", models: [] } } },
2262
+ });
2263
+ const originalFetch = globalThis.fetch;
2264
+ let call = 0;
2265
+ // SAFETY: the stub returns the status sequence the chain classifier reads.
2266
+ globalThis.fetch = (async () => {
2267
+ call += 1;
2268
+ return new Response("{}", { status: call === 1 ? 503 : 413 });
2269
+ }) as typeof fetch;
2270
+ try {
2271
+ const detailed = await llm.parseWithSchemaDetailed(
2272
+ [{ role: "user", content: "test" }],
2273
+ { parse: (data) => z.object({ ok: z.literal(true) }).parse(data) },
2274
+ { temperature: 0, maxTokens: 16 },
2275
+ );
2276
+ assert.ok(detailed && "failureReason" in detailed);
2277
+ assert.equal(detailed.httpStatus, 413, "the last attempt's failure surfaces");
2278
+ assert.equal(
2279
+ detailed.sawTransientAttempt,
2280
+ true,
2281
+ "the earlier 503 marks the refusal as inconclusive for dead-lettering",
2282
+ );
2283
+ } finally {
2284
+ globalThis.fetch = originalFetch;
2285
+ clearModelsJsonCache();
2286
+ clearSecretCache();
2287
+ }
2288
+ });
@@ -223,10 +223,15 @@ export class FallbackLlmClient {
223
223
  errorClass: "network",
224
224
  };
225
225
 
226
+ let sawTransientAttempt = false;
226
227
  const recordFailure = (
227
228
  failure: Omit<StructuredParseFailure, "result">,
228
229
  attemptedModel?: string,
229
230
  ): void => {
231
+ // A transient sibling attempt (5xx/408/429/timeout/network) means the surviving
232
+ // last failure — even a permanent-looking refusal — is inconclusive (#3757).
233
+ sawTransientAttempt ||= failure.failureReason === "timeout" || failure.errorClass === "network" ||
234
+ failure.errorClass === "http_5xx" || failure.httpStatus === 408 || failure.httpStatus === 429;
230
235
  lastFailure = attemptedModel ? { ...failure, attemptedModel } : failure;
231
236
  };
232
237
 
@@ -368,7 +373,7 @@ export class FallbackLlmClient {
368
373
 
369
374
  const toOutcome = (response: FallbackLlmResponse | null): ChatCompletionOutcome => {
370
375
  if (response) return { ok: true, response };
371
- return { ok: false, failure: lastFailure };
376
+ return { ok: false, failure: sawTransientAttempt ? { ...lastFailure, sawTransientAttempt: true } : lastFailure };
372
377
  };
373
378
 
374
379
  if (typeof options.timeoutMs === "number") {
@@ -442,11 +447,9 @@ export class FallbackLlmClient {
442
447
  try {
443
448
  outcome = await this.completeChat(messages, options);
444
449
  } catch (err) {
445
- // Caller aborts must propagate (e.g. recall planner cancellation) — do
446
- // not swallow them as a provider failure, or abort-driven callers lose
447
- // cancellation and treat it as an extraction error (codex review).
448
- // Terminal codex-subscription failures propagate for the same reason:
449
- // their TimeoutError/auth guidance is the documented contract.
450
+ // Caller aborts and terminal codex-subscription failures propagate (the
451
+ // TimeoutError/auth guidance is their documented contract) — swallowing
452
+ // them as provider failures would lose abort-driven cancellation.
450
453
  if (options.signal?.aborted || isTerminalCodexSubscriptionError(err)) throw err;
451
454
  if (isTimeoutError(err)) {
452
455
  return { result: null, failureReason: "timeout", errorClass: "timeout" };
@@ -586,11 +589,9 @@ export class FallbackLlmClient {
586
589
 
587
590
  // Implicit last-resort: when a task-specific modelChain override is active,
588
591
  // append the gateway default model so a stale or exhausted taskModelChain
589
- // never leaves the chain empty — Remnic should never be the reason a chat is
590
- // interrupted by a flush failure. Keyed on `modelChainOverride?.primary` —
591
- // the SAME activation condition chain resolution uses above — so a
592
- // primary-less override (e.g. {}) that falls through to a persona/default
593
- // chain does NOT get the default appended (gotcha #39). Issue #1365 / PR #1370.
592
+ // never interrupts a chat on a flush failure. Keyed on `modelChainOverride?.primary`
593
+ // (the same activation condition used above) so a primary-less override falling
594
+ // through to a persona/default chain does NOT get the default appended (gotcha #39). Issue #1365 / PR #1370.
594
595
  if (includeDefaultModelFallback && modelChainOverride?.primary && modelStrings.length > 0) {
595
596
  // Append the FULL gateway default chain (primary + fallbacks), not just
596
597
  // the primary — if the default primary is also unreachable, a listed
@@ -636,9 +637,8 @@ export class FallbackLlmClient {
636
637
  const modelId = parts.slice(1).join("/"); // Handle cases like "openai/gpt-5.5"
637
638
 
638
639
  // Respect the active gateway config first so profile-local overrides and
639
- // credentials win. Fall back to the materialized models.json only when
640
- // the provider is absent from the loaded config (for built-in providers
641
- // registered by the gateway at runtime).
640
+ // credentials win; materialized models.json only when the provider is
641
+ // absent from the loaded config (runtime-registered built-ins).
642
642
  const resolvedProvider = this.resolveProviderConfig(requestedProviderId, providers);
643
643
  const providerConfig = resolvedProvider?.config;
644
644
  if (!providerConfig) {
@@ -777,10 +777,9 @@ export class FallbackLlmClient {
777
777
  return await this.callOpenAIResponses(effectiveConfig, model.modelId, messages, capped);
778
778
  }
779
779
 
780
- // For OpenAI-compatible chat-completions APIs (openai-completions,
781
- // ollama, etc.) and unknown formats, use chat completions — the gateway's
782
- // runtime auth resolver returns request-ready base URL and credentials for
783
- // most providers.
780
+ // For OpenAI-compatible chat-completions APIs (openai-completions, ollama,
781
+ // etc.) and unknown formats, use chat completions — the gateway's runtime
782
+ // auth resolver returns request-ready base URL and credentials for most providers.
784
783
  return await this.callOpenAI(
785
784
  effectiveConfig,
786
785
  model.modelId,
@@ -13,6 +13,11 @@ import {
13
13
  } from "undici";
14
14
 
15
15
  import { LocalLlmClient } from "./local-llm.js";
16
+ import {
17
+ classifyLocalLlmRejected,
18
+ isParameterConfigRejection,
19
+ LocalLlmRejectedError,
20
+ } from "./extraction-error-classification.js";
16
21
  import { probeFetch, type LocalLlmChatCompletionOptions } from "./local-llm-helpers.js";
17
22
  import { classifyAnalysisProviderError } from "./activity/timeline/analysis-provider.js";
18
23
  import { ChatTransport, EXTRACTION_MIN_TRANSPORT_BUDGET_MS, isInvalidDispatcherArg, resolveProxyEnv, routeBudgets } from "./local-llm-transport.js";
@@ -900,3 +905,149 @@ test("the extraction transport floor is fifteen minutes, well past undici's 300s
900
905
  assert.equal(EXTRACTION_MIN_TRANSPORT_BUDGET_MS, 900_000);
901
906
  assert.ok(EXTRACTION_MIN_TRANSPORT_BUDGET_MS >= 301_000);
902
907
  });
908
+
909
+ test("a local parameter-refusing 400 tags lastError so classification parks the window as auth_config (#3757)", { concurrency: false }, async () => {
910
+ const original = globalThis.fetch;
911
+ // SAFETY: the stub satisfies the only fetch call this client makes.
912
+ globalThis.fetch = (async () =>
913
+ new Response(
914
+ JSON.stringify({ error: { message: "Unsupported parameter: 'temperature' is not supported with this model." } }),
915
+ { status: 400, headers: { "content-type": "application/json" } },
916
+ )) as typeof fetch;
917
+ // Unique endpoint: the rate-limit backoff state is process-wide and keyed by
918
+ // URL, so earlier tests' 429s must not short-circuit this request.
919
+ const client = new LocalLlmClient(createConfig({ localLlmUrl: "http://127.0.0.1:43701" }));
920
+ try {
921
+ primeClient(client);
922
+ const options: LocalLlmChatCompletionOptions = { failureDiag: {} };
923
+ assert.equal(
924
+ await client.chatCompletion([{ role: "user", content: "test" }], options),
925
+ null,
926
+ );
927
+ const lastError = options.failureDiag?.lastError;
928
+ assert.ok(lastError instanceof Error, "expected the terminal provider error to survive the request");
929
+ assert.equal("status" in lastError ? lastError.status : undefined, 400, "the request reached the endpoint and was refused");
930
+ // The sanitized code survives the producer's diagnostic (no provider text),
931
+ // so the extraction-layer classification parks the window for a config fix
932
+ // instead of dead-lettering valid turns at the permanent-attempt cap.
933
+ assert.equal("code" in lastError ? lastError.code : undefined, "unsupported_parameter");
934
+ assert.equal(
935
+ classifyLocalLlmRejected(new LocalLlmRejectedError(400, undefined, isParameterConfigRejection(lastError))),
936
+ "auth_config",
937
+ );
938
+ } finally {
939
+ globalThis.fetch = original;
940
+ await dispatcherOf(client).close();
941
+ }
942
+ });
943
+
944
+ test("a local content-refusing 400 carries no parameter tag and still dead-letters as provider_permanent (#3757)", { concurrency: false }, async () => {
945
+ const original = globalThis.fetch;
946
+ // SAFETY: the stub satisfies the only fetch call this client makes.
947
+ globalThis.fetch = (async () =>
948
+ new Response(
949
+ JSON.stringify({ error: { message: "Input content rejected: unexpected value in messages[0].content" } }),
950
+ { status: 400, headers: { "content-type": "application/json" } },
951
+ )) as typeof fetch;
952
+ // Unique endpoint: the rate-limit backoff state is process-wide and keyed by
953
+ // URL, so earlier tests' 429s must not short-circuit this request.
954
+ const client = new LocalLlmClient(createConfig({ localLlmUrl: "http://127.0.0.1:43702" }));
955
+ try {
956
+ primeClient(client);
957
+ const options: LocalLlmChatCompletionOptions = { failureDiag: {} };
958
+ assert.equal(
959
+ await client.chatCompletion([{ role: "user", content: "test" }], options),
960
+ null,
961
+ );
962
+ const lastError = options.failureDiag?.lastError;
963
+ assert.ok(lastError instanceof Error, "expected the terminal provider error to survive the request");
964
+ assert.equal("status" in lastError ? lastError.status : undefined, 400, "the request reached the endpoint and was refused");
965
+ // `unexpected value` names the payload, not a request parameter — the bare
966
+ // phrase must not reclassify an input refusal as a setup problem.
967
+ assert.equal("code" in lastError ? lastError.code : undefined, undefined);
968
+ assert.equal(isParameterConfigRejection(lastError), false);
969
+ assert.equal(
970
+ classifyLocalLlmRejected(new LocalLlmRejectedError(400, undefined, isParameterConfigRejection(lastError))),
971
+ "provider_permanent",
972
+ );
973
+ } finally {
974
+ globalThis.fetch = original;
975
+ await dispatcherOf(client).close();
976
+ }
977
+ });
978
+
979
+ test("a local 400 carrying a provider error code tags lastError so classification parks the window as auth_config (#3757)", { concurrency: false }, async () => {
980
+ const original = globalThis.fetch;
981
+ // SAFETY: the stub satisfies the only fetch call this client makes.
982
+ globalThis.fetch = (async () =>
983
+ new Response(
984
+ JSON.stringify({ error: { code: "unsupported_value", message: "the request could not be processed" } }),
985
+ { status: 400, headers: { "content-type": "application/json" } },
986
+ )) as typeof fetch;
987
+ // Unique endpoint: the rate-limit backoff state is process-wide and keyed by
988
+ // URL, so earlier tests' 429s must not short-circuit this request.
989
+ const client = new LocalLlmClient(createConfig({ localLlmUrl: "http://127.0.0.1:43703" }));
990
+ try {
991
+ primeClient(client);
992
+ const options: LocalLlmChatCompletionOptions = { failureDiag: {} };
993
+ assert.equal(
994
+ await client.chatCompletion([{ role: "user", content: "test" }], options),
995
+ null,
996
+ );
997
+ const lastError = options.failureDiag?.lastError;
998
+ assert.ok(lastError instanceof Error, "expected the terminal provider error to survive the request");
999
+ assert.equal("status" in lastError ? lastError.status : undefined, 400, "the request reached the endpoint and was refused");
1000
+ // The provider's machine-readable `code` field is parsed alongside the
1001
+ // message — `unsupported_value` names the request setup, not the payload.
1002
+ assert.equal("code" in lastError ? lastError.code : undefined, "unsupported_parameter");
1003
+ assert.equal(
1004
+ classifyLocalLlmRejected(new LocalLlmRejectedError(400, undefined, isParameterConfigRejection(lastError))),
1005
+ "auth_config",
1006
+ );
1007
+ } finally {
1008
+ globalThis.fetch = original;
1009
+ await dispatcherOf(client).close();
1010
+ }
1011
+ });
1012
+
1013
+ test("a retried transient 5xx keeps evidence when a later 413 refusal returns null (#3757)", { concurrency: false }, async () => {
1014
+ const original = globalThis.fetch;
1015
+ let calls = 0;
1016
+ // SAFETY: the stub satisfies the only fetch calls this client makes.
1017
+ globalThis.fetch = (async () => {
1018
+ calls += 1;
1019
+ return calls === 1
1020
+ ? new Response("backend unavailable", { status: 500 })
1021
+ : new Response(JSON.stringify({ error: { message: "request too large" } }), {
1022
+ status: 413,
1023
+ headers: { "content-type": "application/json" },
1024
+ });
1025
+ }) as typeof fetch;
1026
+ const client = new LocalLlmClient(
1027
+ createConfig({ localLlmUrl: "http://127.0.0.1:43704", localLlmRetry5xxCount: 1, localLlmRetryBackoffMs: 1 }),
1028
+ );
1029
+ try {
1030
+ primeClient(client);
1031
+ const options: LocalLlmChatCompletionOptions = { failureDiag: {} };
1032
+ assert.equal(
1033
+ await client.chatCompletion([{ role: "user", content: "test" }], options),
1034
+ null,
1035
+ );
1036
+ assert.equal(calls, 2, "the retried 5xx must reach the endpoint before the refusal");
1037
+ const lastError = options.failureDiag?.lastError;
1038
+ assert.ok(lastError instanceof Error, "expected the terminal provider error to survive the request");
1039
+ assert.equal("status" in lastError ? lastError.status : undefined, 413);
1040
+ // The retried 500 must survive on the diagnostic — the terminal 413 alone
1041
+ // would read as a lone refusal and dead-letter the window at the cap.
1042
+ assert.equal(options.failureDiag?.sawTransientAttempt, true);
1043
+ assert.equal(
1044
+ classifyLocalLlmRejected(new LocalLlmRejectedError(413, undefined, false, options.failureDiag?.sawTransientAttempt)),
1045
+ "provider_retryable",
1046
+ );
1047
+ // A lone 413 with no transient sibling stays permanent.
1048
+ assert.equal(classifyLocalLlmRejected(new LocalLlmRejectedError(413, undefined, false, undefined)), "provider_permanent");
1049
+ } finally {
1050
+ globalThis.fetch = original;
1051
+ await dispatcherOf(client).close();
1052
+ }
1053
+ });
@@ -23,7 +23,7 @@ export interface LocalLlmChatCompletionOptions {
23
23
  * callers can classify it (e.g. HTTP 429 → rate-limited) in memory
24
24
  * instead of seeing only null. Never logged.
25
25
  */
26
- failureDiag?: { lastError?: unknown; finishReason?: string };
26
+ failureDiag?: { lastError?: unknown; finishReason?: string; sawTransientAttempt?: boolean };
27
27
  }
28
28
 
29
29
  export interface LocalLlmChatCompletionResult {