@remnic/core 10.0.193 → 10.0.195

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 (277) hide show
  1. package/dist/access-admin-ops-surface.js +58 -59
  2. package/dist/access-cli.js +58 -59
  3. package/dist/access-cli.js.map +1 -1
  4. package/dist/access-extraction-force-flush-preempt.js +58 -59
  5. package/dist/access-extraction-force-flush.js +58 -59
  6. package/dist/access-http-briefing.js +58 -59
  7. package/dist/access-http-query.js +58 -59
  8. package/dist/access-http.js +58 -59
  9. package/dist/access-identity-continuity-surface.js +58 -59
  10. package/dist/access-lcm-surface.js +58 -59
  11. package/dist/access-mcp.js +58 -59
  12. package/dist/access-observe-write-surface.js +58 -59
  13. package/dist/access-operations-batch.js +58 -59
  14. package/dist/access-operations.js +58 -59
  15. package/dist/access-recall-concurrency.js +58 -59
  16. package/dist/access-recall-diagnostics.js +2 -2
  17. package/dist/access-recall-response.js +58 -59
  18. package/dist/access-recall-surface.js +58 -59
  19. package/dist/access-service.js +58 -59
  20. package/dist/active-recall.js +7 -6
  21. package/dist/active-recall.js.map +1 -1
  22. package/dist/{auto-sync-BJUAGKI5.js → auto-sync-BEW65FDT.js} +6 -5
  23. package/dist/{auto-sync-BJUAGKI5.js.map → auto-sync-BEW65FDT.js.map} +1 -1
  24. package/dist/briefing.js +7 -6
  25. package/dist/buffer.d.ts +1 -0
  26. package/dist/buffer.d.ts.map +1 -1
  27. package/dist/buffer.js +3 -3
  28. package/dist/calibration.js +5 -4
  29. package/dist/calibration.js.map +1 -1
  30. package/dist/causal-consolidation.js +8 -7
  31. package/dist/causal-consolidation.js.map +1 -1
  32. package/dist/{chunk-FZU62GIV.js → chunk-2X5I5C3M.js} +27 -10
  33. package/dist/chunk-2X5I5C3M.js.map +1 -0
  34. package/dist/{chunk-DYUPSTCV.js → chunk-3EXG2KPK.js} +3 -3
  35. package/dist/{chunk-FGFU6J26.js → chunk-4FTYKZ77.js} +3 -3
  36. package/dist/{chunk-4EAVEDLG.js → chunk-4GVSMPBP.js} +8 -8
  37. package/dist/{chunk-QIPRDRGM.js → chunk-4HEJDVPU.js} +1 -1
  38. package/dist/chunk-4HEJDVPU.js.map +1 -0
  39. package/dist/{chunk-EEA2RM4B.js → chunk-4I6A3SDL.js} +2 -2
  40. package/dist/{chunk-SKJM4PKE.js → chunk-4JI5PPFW.js} +2 -2
  41. package/dist/{chunk-TDG5NZAZ.js → chunk-65JA7LWV.js} +2 -2
  42. package/dist/{chunk-3YID7KZ6.js → chunk-6QMKUWXH.js} +2 -2
  43. package/dist/{chunk-7SOKOEAZ.js → chunk-6RRHTHKQ.js} +2 -2
  44. package/dist/{chunk-VHQNJW4Q.js → chunk-6W62D4MC.js} +2 -2
  45. package/dist/{chunk-2QW5HPKU.js → chunk-76LBLH62.js} +35 -28
  46. package/dist/chunk-76LBLH62.js.map +1 -0
  47. package/dist/{chunk-NN3LMWKA.js → chunk-7TQ3EDQ3.js} +1 -1
  48. package/dist/chunk-7TQ3EDQ3.js.map +1 -0
  49. package/dist/{chunk-KJ65WZHB.js → chunk-A7DIZOTF.js} +2 -2
  50. package/dist/{chunk-TZ7ZA2LM.js → chunk-AD3JOG2Q.js} +2 -2
  51. package/dist/{chunk-KZ4BJRGQ.js → chunk-BD26CK6T.js} +2 -2
  52. package/dist/{chunk-BDFSVUUZ.js → chunk-C3H2QZOZ.js} +2 -1
  53. package/dist/chunk-C3H2QZOZ.js.map +1 -0
  54. package/dist/{chunk-7EP4FURO.js → chunk-C72YQM7E.js} +2 -2
  55. package/dist/{chunk-CJSTQNE5.js → chunk-CTOMDCCA.js} +2 -2
  56. package/dist/{chunk-PSQ347YP.js → chunk-DSKII2W4.js} +3 -3
  57. package/dist/{chunk-KOVQZJ27.js → chunk-E7LDTUWK.js} +2 -2
  58. package/dist/{chunk-SPAKBUJY.js → chunk-EWLMEYLF.js} +2 -2
  59. package/dist/{chunk-3BICT225.js → chunk-FGNBUUPX.js} +2 -2
  60. package/dist/{chunk-QZMGZBTF.js → chunk-HBG6CQEX.js} +2 -2
  61. package/dist/{chunk-FKHXXL42.js → chunk-HD7M55OI.js} +2 -2
  62. package/dist/{chunk-7V6GNQC2.js → chunk-HINQENZG.js} +2 -2
  63. package/dist/{chunk-WRVKI6ZO.js → chunk-HLQXSX4F.js} +2 -2
  64. package/dist/{chunk-T765HQ5U.js → chunk-IIDAN7XJ.js} +2 -2
  65. package/dist/{chunk-G2MS56KM.js → chunk-IT4G6HTG.js} +2 -2
  66. package/dist/{chunk-M7Q7Z6V5.js → chunk-JDZ5JPYG.js} +38 -8
  67. package/dist/chunk-JDZ5JPYG.js.map +1 -0
  68. package/dist/{chunk-MMRTPH3J.js → chunk-KQYGUFMQ.js} +5 -3
  69. package/dist/chunk-KQYGUFMQ.js.map +1 -0
  70. package/dist/{chunk-TWYYUMYO.js → chunk-KXAGZRJV.js} +2 -2
  71. package/dist/{chunk-JITK24KX.js → chunk-LJNCJK7B.js} +10 -10
  72. package/dist/{chunk-Z6EFSXU3.js → chunk-LMM2LRVQ.js} +2 -2
  73. package/dist/{chunk-V65H7MI6.js → chunk-M42UFQZY.js} +51 -4
  74. package/dist/chunk-M42UFQZY.js.map +1 -0
  75. package/dist/{chunk-UAEJKURK.js → chunk-ME63JKWJ.js} +61 -59
  76. package/dist/{chunk-UAEJKURK.js.map → chunk-ME63JKWJ.js.map} +1 -1
  77. package/dist/{chunk-AALJHIKH.js → chunk-OHJ5PNYB.js} +3 -3
  78. package/dist/{chunk-XZMQLON4.js → chunk-OK726OF4.js} +7 -5
  79. package/dist/chunk-OK726OF4.js.map +1 -0
  80. package/dist/{chunk-Q6S67LHR.js → chunk-OOMFFMX3.js} +2 -2
  81. package/dist/{chunk-ODI4K32P.js → chunk-Q2GDUJSK.js} +5 -5
  82. package/dist/{chunk-JNDMIAJ4.js → chunk-QEVZKJM6.js} +2 -2
  83. package/dist/{chunk-ZNCCX7P6.js → chunk-QW5LZTKA.js} +2 -2
  84. package/dist/{chunk-5GIYIYJI.js → chunk-QZPAOOU7.js} +2 -2
  85. package/dist/{chunk-NKHRIDYP.js → chunk-RTXW6E6X.js} +3 -3
  86. package/dist/{chunk-5WDUY2ZZ.js → chunk-S4QWAWR6.js} +4 -4
  87. package/dist/{chunk-STSORBX5.js → chunk-SFUS2V2V.js} +1 -1
  88. package/dist/{chunk-HEJFE3BC.js → chunk-SJCN7ESG.js} +2 -2
  89. package/dist/{chunk-AJ7JHHRY.js → chunk-SPPWVMP4.js} +2 -2
  90. package/dist/{chunk-QSF5SJAM.js → chunk-STQNKDKZ.js} +9 -3
  91. package/dist/chunk-STQNKDKZ.js.map +1 -0
  92. package/dist/{chunk-QFKNIKUF.js → chunk-SXR7L57Z.js} +2 -2
  93. package/dist/{chunk-GYCUX3N4.js → chunk-TGMIJABS.js} +2 -2
  94. package/dist/{chunk-GH7IKABD.js → chunk-UFJJMQDV.js} +2 -2
  95. package/dist/{chunk-UH2VY2QQ.js → chunk-WCW7I7ZM.js} +2 -2
  96. package/dist/{chunk-3RZ4GDOH.js → chunk-XDNVWY7I.js} +93 -23
  97. package/dist/chunk-XDNVWY7I.js.map +1 -0
  98. package/dist/{chunk-LR6LWX33.js → chunk-XXDIPAUE.js} +2 -2
  99. package/dist/{chunk-YCJJODER.js → chunk-YCTD3XET.js} +10 -3
  100. package/dist/chunk-YCTD3XET.js.map +1 -0
  101. package/dist/{chunk-WEI6HEUX.js → chunk-YXAH5TSN.js} +2 -2
  102. package/dist/{chunk-75K6DRPN.js → chunk-ZAVFAGBE.js} +2 -2
  103. package/dist/{chunk-7KTORRIK.js → chunk-ZNJU3NBJ.js} +2 -2
  104. package/dist/cli.js +58 -59
  105. package/dist/coding/export-okf-codegraph.js +6 -5
  106. package/dist/coding/export-okf-codegraph.js.map +1 -1
  107. package/dist/compounding/engine.js +8 -7
  108. package/dist/config.d.ts.map +1 -1
  109. package/dist/config.js +7 -6
  110. package/dist/connectors/codex-materialize-runner.js +7 -6
  111. package/dist/connectors/index.js +7 -6
  112. package/dist/convergence-refresh.js +9 -8
  113. package/dist/corpus-watermark.js +9 -8
  114. package/dist/deep-recall-policy-llm.js +4 -3
  115. package/dist/entity-retrieval.js +7 -6
  116. package/dist/explicit-capture.js +58 -59
  117. package/dist/extraction-error-classification.d.ts +40 -5
  118. package/dist/extraction-error-classification.d.ts.map +1 -1
  119. package/dist/extraction-error-classification.js +5 -2
  120. package/dist/extraction-faithfulness.js +4 -3
  121. package/dist/extraction-judge.js +4 -3
  122. package/dist/extraction.d.ts.map +1 -1
  123. package/dist/extraction.js +17 -18
  124. package/dist/fallback-llm-codex-subscription.d.ts +3 -1
  125. package/dist/fallback-llm-codex-subscription.d.ts.map +1 -1
  126. package/dist/fallback-llm-codex-subscription.js +2 -1
  127. package/dist/fallback-llm.d.ts.map +1 -1
  128. package/dist/fallback-llm.js +3 -2
  129. package/dist/harmonic-retrieval.js +7 -6
  130. package/dist/index.js +58 -59
  131. package/dist/live-connectors-runner.js +1 -2
  132. package/dist/local-llm-helpers.d.ts +1 -0
  133. package/dist/local-llm-helpers.d.ts.map +1 -1
  134. package/dist/local-llm-helpers.js +1 -1
  135. package/dist/local-llm.d.ts.map +1 -1
  136. package/dist/local-llm.js +4 -3
  137. package/dist/location/index.js +8 -7
  138. package/dist/maintenance/memory-governance.js +7 -6
  139. package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +7 -6
  140. package/dist/maintenance/rebuild-memory-projection-runner.js +9 -8
  141. package/dist/maintenance/rebuild-memory-projection.js +8 -7
  142. package/dist/memory-browse.js +3 -3
  143. package/dist/namespaces/migrate.js +8 -7
  144. package/dist/namespaces/storage.js +7 -6
  145. package/dist/operator-doctor-corpus.js +10 -9
  146. package/dist/operator-toolkit.js +14 -13
  147. package/dist/orchestration/backlog-scheduler.js +59 -60
  148. package/dist/orchestration/backlog-scheduler.js.map +1 -1
  149. package/dist/orchestration/buffer-drain-runner.js +59 -60
  150. package/dist/orchestration/extraction-drain.d.ts +1 -0
  151. package/dist/orchestration/extraction-drain.d.ts.map +1 -1
  152. package/dist/orchestration/extraction-persist-failure.d.ts +0 -2
  153. package/dist/orchestration/extraction-persist-failure.d.ts.map +1 -1
  154. package/dist/orchestration/extraction-persist.d.ts +6 -2
  155. package/dist/orchestration/extraction-persist.d.ts.map +1 -1
  156. package/dist/orchestration/extraction-run-helpers.d.ts +41 -4
  157. package/dist/orchestration/extraction-run-helpers.d.ts.map +1 -1
  158. package/dist/orchestration/extraction-run.d.ts +4 -0
  159. package/dist/orchestration/extraction-run.d.ts.map +1 -1
  160. package/dist/orchestration/maintenance.js +17 -16
  161. package/dist/orchestrator.js +58 -59
  162. package/dist/recall-explain-renderer.js +3 -3
  163. package/dist/recall-navigate-access.js +2 -2
  164. package/dist/recall-navigate-disclosure.js +2 -2
  165. package/dist/recall-navigate.js +2 -2
  166. package/dist/recall-navigation.js +58 -59
  167. package/dist/recall-planner-llm.js +3 -2
  168. package/dist/recall-planner-llm.js.map +1 -1
  169. package/dist/recall-state-view-admission.js +3 -3
  170. package/dist/recall-why-service.js +3 -3
  171. package/dist/recall-xray-cli.js +4 -4
  172. package/dist/recall-xray-renderer.js +3 -3
  173. package/dist/recall-xray.js +2 -2
  174. package/dist/resume-bundles.js +8 -7
  175. package/dist/semantic-consolidation.js +8 -7
  176. package/dist/semantic-rule-promotion.js +7 -6
  177. package/dist/semantic-rule-verifier.js +7 -6
  178. package/dist/source-agent-qualifier.js +10 -9
  179. package/dist/standup/build.js +7 -6
  180. package/dist/storage.d.ts.map +1 -1
  181. package/dist/storage.js +6 -5
  182. package/dist/summarizer.js +6 -5
  183. package/dist/support-passport/index.js +6 -5
  184. package/dist/transfer/export-okf.js +7 -6
  185. package/dist/types-extraction-failure.d.ts +7 -1
  186. package/dist/types-extraction-failure.d.ts.map +1 -1
  187. package/dist/types.d.ts +6 -6
  188. package/dist/types.d.ts.map +1 -1
  189. package/dist/types.js +1 -1
  190. package/dist/verified-recall.js +7 -6
  191. package/dist/who-knows-cli.js +8 -7
  192. package/dist/who-knows.js +7 -6
  193. package/package.json +2 -2
  194. package/src/buffer-incremental-persistence.test.ts +23 -0
  195. package/src/buffer.ts +30 -28
  196. package/src/config.ts +2 -0
  197. package/src/extraction-error-classification.ts +88 -8
  198. package/src/extraction-local-failure-class.test.ts +117 -3
  199. package/src/extraction-reply-diagnostic-wiring.test.ts +3 -1
  200. package/src/extraction.test.ts +73 -3
  201. package/src/extraction.ts +26 -25
  202. package/src/fallback-llm-codex-subscription.ts +17 -3
  203. package/src/fallback-llm.test.ts +70 -0
  204. package/src/fallback-llm.ts +17 -18
  205. package/src/local-llm-headers-timeout.test.ts +151 -0
  206. package/src/local-llm-helpers.ts +1 -1
  207. package/src/local-llm.ts +44 -43
  208. package/src/orchestration/extraction-drain.ts +11 -5
  209. package/src/orchestration/extraction-persist-declaration.test.ts +35 -0
  210. package/src/orchestration/extraction-persist-failure.ts +0 -3
  211. package/src/orchestration/extraction-persist.ts +3 -3
  212. package/src/orchestration/extraction-run-helpers.ts +110 -4
  213. package/src/orchestration/extraction-run.test.ts +408 -3
  214. package/src/orchestration/extraction-run.ts +75 -75
  215. package/src/storage.ts +5 -4
  216. package/src/types-extraction-failure.ts +12 -1
  217. package/src/types.ts +6 -6
  218. package/dist/chunk-2QW5HPKU.js.map +0 -1
  219. package/dist/chunk-3RZ4GDOH.js.map +0 -1
  220. package/dist/chunk-BDFSVUUZ.js.map +0 -1
  221. package/dist/chunk-C7SRUWBW.js +0 -54
  222. package/dist/chunk-C7SRUWBW.js.map +0 -1
  223. package/dist/chunk-FZU62GIV.js.map +0 -1
  224. package/dist/chunk-M7Q7Z6V5.js.map +0 -1
  225. package/dist/chunk-MMRTPH3J.js.map +0 -1
  226. package/dist/chunk-NN3LMWKA.js.map +0 -1
  227. package/dist/chunk-QIPRDRGM.js.map +0 -1
  228. package/dist/chunk-QSF5SJAM.js.map +0 -1
  229. package/dist/chunk-V65H7MI6.js.map +0 -1
  230. package/dist/chunk-XZMQLON4.js.map +0 -1
  231. package/dist/chunk-YCJJODER.js.map +0 -1
  232. /package/dist/{chunk-DYUPSTCV.js.map → chunk-3EXG2KPK.js.map} +0 -0
  233. /package/dist/{chunk-FGFU6J26.js.map → chunk-4FTYKZ77.js.map} +0 -0
  234. /package/dist/{chunk-4EAVEDLG.js.map → chunk-4GVSMPBP.js.map} +0 -0
  235. /package/dist/{chunk-EEA2RM4B.js.map → chunk-4I6A3SDL.js.map} +0 -0
  236. /package/dist/{chunk-SKJM4PKE.js.map → chunk-4JI5PPFW.js.map} +0 -0
  237. /package/dist/{chunk-TDG5NZAZ.js.map → chunk-65JA7LWV.js.map} +0 -0
  238. /package/dist/{chunk-3YID7KZ6.js.map → chunk-6QMKUWXH.js.map} +0 -0
  239. /package/dist/{chunk-7SOKOEAZ.js.map → chunk-6RRHTHKQ.js.map} +0 -0
  240. /package/dist/{chunk-VHQNJW4Q.js.map → chunk-6W62D4MC.js.map} +0 -0
  241. /package/dist/{chunk-KJ65WZHB.js.map → chunk-A7DIZOTF.js.map} +0 -0
  242. /package/dist/{chunk-TZ7ZA2LM.js.map → chunk-AD3JOG2Q.js.map} +0 -0
  243. /package/dist/{chunk-KZ4BJRGQ.js.map → chunk-BD26CK6T.js.map} +0 -0
  244. /package/dist/{chunk-7EP4FURO.js.map → chunk-C72YQM7E.js.map} +0 -0
  245. /package/dist/{chunk-CJSTQNE5.js.map → chunk-CTOMDCCA.js.map} +0 -0
  246. /package/dist/{chunk-PSQ347YP.js.map → chunk-DSKII2W4.js.map} +0 -0
  247. /package/dist/{chunk-KOVQZJ27.js.map → chunk-E7LDTUWK.js.map} +0 -0
  248. /package/dist/{chunk-SPAKBUJY.js.map → chunk-EWLMEYLF.js.map} +0 -0
  249. /package/dist/{chunk-3BICT225.js.map → chunk-FGNBUUPX.js.map} +0 -0
  250. /package/dist/{chunk-QZMGZBTF.js.map → chunk-HBG6CQEX.js.map} +0 -0
  251. /package/dist/{chunk-FKHXXL42.js.map → chunk-HD7M55OI.js.map} +0 -0
  252. /package/dist/{chunk-7V6GNQC2.js.map → chunk-HINQENZG.js.map} +0 -0
  253. /package/dist/{chunk-WRVKI6ZO.js.map → chunk-HLQXSX4F.js.map} +0 -0
  254. /package/dist/{chunk-T765HQ5U.js.map → chunk-IIDAN7XJ.js.map} +0 -0
  255. /package/dist/{chunk-G2MS56KM.js.map → chunk-IT4G6HTG.js.map} +0 -0
  256. /package/dist/{chunk-TWYYUMYO.js.map → chunk-KXAGZRJV.js.map} +0 -0
  257. /package/dist/{chunk-JITK24KX.js.map → chunk-LJNCJK7B.js.map} +0 -0
  258. /package/dist/{chunk-Z6EFSXU3.js.map → chunk-LMM2LRVQ.js.map} +0 -0
  259. /package/dist/{chunk-AALJHIKH.js.map → chunk-OHJ5PNYB.js.map} +0 -0
  260. /package/dist/{chunk-Q6S67LHR.js.map → chunk-OOMFFMX3.js.map} +0 -0
  261. /package/dist/{chunk-ODI4K32P.js.map → chunk-Q2GDUJSK.js.map} +0 -0
  262. /package/dist/{chunk-JNDMIAJ4.js.map → chunk-QEVZKJM6.js.map} +0 -0
  263. /package/dist/{chunk-ZNCCX7P6.js.map → chunk-QW5LZTKA.js.map} +0 -0
  264. /package/dist/{chunk-5GIYIYJI.js.map → chunk-QZPAOOU7.js.map} +0 -0
  265. /package/dist/{chunk-NKHRIDYP.js.map → chunk-RTXW6E6X.js.map} +0 -0
  266. /package/dist/{chunk-5WDUY2ZZ.js.map → chunk-S4QWAWR6.js.map} +0 -0
  267. /package/dist/{chunk-STSORBX5.js.map → chunk-SFUS2V2V.js.map} +0 -0
  268. /package/dist/{chunk-HEJFE3BC.js.map → chunk-SJCN7ESG.js.map} +0 -0
  269. /package/dist/{chunk-AJ7JHHRY.js.map → chunk-SPPWVMP4.js.map} +0 -0
  270. /package/dist/{chunk-QFKNIKUF.js.map → chunk-SXR7L57Z.js.map} +0 -0
  271. /package/dist/{chunk-GYCUX3N4.js.map → chunk-TGMIJABS.js.map} +0 -0
  272. /package/dist/{chunk-GH7IKABD.js.map → chunk-UFJJMQDV.js.map} +0 -0
  273. /package/dist/{chunk-UH2VY2QQ.js.map → chunk-WCW7I7ZM.js.map} +0 -0
  274. /package/dist/{chunk-LR6LWX33.js.map → chunk-XXDIPAUE.js.map} +0 -0
  275. /package/dist/{chunk-WEI6HEUX.js.map → chunk-YXAH5TSN.js.map} +0 -0
  276. /package/dist/{chunk-75K6DRPN.js.map → chunk-ZAVFAGBE.js.map} +0 -0
  277. /package/dist/{chunk-7KTORRIK.js.map → chunk-ZNJU3NBJ.js.map} +0 -0
@@ -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 {
package/src/local-llm.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { log } from "./logger.js";
2
+ import { isParameterConfigRejection } from "./extraction-error-classification.js";
2
3
  import { isUnsupportedJsonSchemaError } from "./fallback-llm-codex-subscription.js";
3
4
  import { estimateTokenCount } from "./token-estimate.js";
4
5
  import type { PluginConfig } from "./types.js";
@@ -525,8 +526,7 @@ export class LocalLlmClient {
525
526
  */
526
527
  private getContextFromLmsCli(modelId: string): number | null {
527
528
  try {
528
- // Check if lms CLI exists in common locations.
529
- // HOME may be absent in launchd environments, so prefer the resolved helper.
529
+ // Prefer the resolved helper: HOME may be absent in launchd environments.
530
530
  const homeDir = this.resolveHomeDir();
531
531
  const lmsPaths = [
532
532
  this.config.localLmsCliPath || "",
@@ -541,8 +541,7 @@ export class LocalLlmClient {
541
541
  return null;
542
542
  }
543
543
 
544
- // Run lms ps --json to get loaded models with context
545
- // Use spawnSync with shell and explicit PATH to ensure lms can find its dependencies
544
+ // Run `lms ps --json` for loaded models; explicit PATH so lms finds its deps
546
545
  log.debug(`LMS CLI: running: ${lmsPath} ps --json`);
547
546
  const existingPath = readEnvVar("PATH") || "";
548
547
  const result = launchProcessSync(lmsPath, ["ps", "--json"], {
@@ -902,23 +901,12 @@ export class LocalLlmClient {
902
901
  };
903
902
  this.nativeSchemaGate.attach(requestBody, options, requestModel);
904
903
 
905
- // Suppress thinking/reasoning for operations that benefit from terse,
906
- // structured output. Thinking-capable models (Qwen 3.5, Gemma 4,
907
- // DeepSeek) default to thinking-on via their chat template; sending
908
- // `chat_template_kwargs: { enable_thinking: false }` tells the template
909
- // to skip reasoning tokens. Consolidation operations on the main client
910
- // intentionally keep thinking enabled so entity resolution and
911
- // deduplication can use the model's reasoning path. Fast-tier callers can
912
- // still force suppression per request to preserve their low-latency
913
- // contract.
914
- //
915
- // Gate the injection on detected backend support (issue #548,
916
- // Codex P1 on PR #550): `chat_template_kwargs` is an LM Studio /
917
- // vLLM / llama.cpp extension, not part of standard OpenAI chat
918
- // completions. Strict OpenAI-compatible backends reject
919
- // unknown fields with 400, which trips the 400-cooldown path and
920
- // can effectively disable local extraction. Fail open when the
921
- // backend hasn't been positively identified as thinking-capable.
904
+ // Suppress thinking for operations that benefit from terse output:
905
+ // thinking-capable models default to thinking-on; `chat_template_kwargs:
906
+ // { enable_thinking: false }` skips it. Consolidation keeps thinking on;
907
+ // fast-tier callers can force suppression. Gate on detected backend
908
+ // support (issue #548): strict OpenAI backends reject the extension with
909
+ // 400 — fail open when unidentified.
922
910
  const shouldSuppressThinking =
923
911
  options.forceDisableThinking === true ||
924
912
  ((options.disableThinking ?? this._disableThinking) &&
@@ -930,15 +918,11 @@ export class LocalLlmClient {
930
918
  ) {
931
919
  requestBody.chat_template_kwargs = { enable_thinking: false };
932
920
  } else if (shouldSuppressThinking && this.detectedType === "ollama") {
933
- // Ollama's /v1 endpoint silently drops `chat_template_kwargs` AND
934
- // `enable_thinking` — the ONLY field it maps to think-off is
935
- // `reasoning_effort` ("none" → ThinkValue{false} in openai.go;
936
- // verified against Ollama 0.32.0 source and live probes,
937
- // issue #1996). Without this, thinking-capable models (Gemma 4,
938
- // Qwen 3.5+) burn 1,700-2,000 reasoning tokens per extraction on
939
- // Ollama, exceed the client timeout, and retry forever. The effort
940
- // is configurable via `localLlmReasoningEffort` (default "none");
941
- // an empty value disables injection (pre-#1996 behavior).
921
+ // Ollama's /v1 endpoint silently drops `chat_template_kwargs` and
922
+ // `enable_thinking` — only `reasoning_effort` maps to think-off (issue
923
+ // #1996). Without it thinking models burn reasoning tokens per
924
+ // extraction and retry forever. Empty `localLlmReasoningEffort`
925
+ // disables injection (pre-#1996).
942
926
  const effort = this.config.localLlmReasoningEffort;
943
927
  if (effort) {
944
928
  requestBody.reasoning_effort = effort;
@@ -956,11 +940,10 @@ export class LocalLlmClient {
956
940
  // (issue #2148 root cause); the sizing lives with the transport budgets.
957
941
  const { effectiveTimeoutMs, transportBudgetMs } = routeBudgets(operation, this.config.localLlmTimeoutMs, options.timeoutMs);
958
942
  const maxAttempts = 1 + Math.max(0, this.config.localLlmRetry5xxCount);
959
- // COS-447: rate-limit responses (429/503/408, LiteLLM cooldown) get
960
- // their own retry budget with exponential full-jitter backoff, and a
961
- // process-wide semaphore caps concurrent HTTP attempts across clients.
962
- // Waits are bounded by the request timeout so a short caller budget
963
- // (e.g. rerankTimeoutMs) is never stretched by a long cooldown.
943
+ // COS-447: rate-limit responses (429/503/408, LiteLLM cooldown) get their
944
+ // own retry budget with exponential full-jitter backoff, and a process-wide
945
+ // semaphore caps concurrent HTTP attempts. Waits stay bounded by the
946
+ // request timeout so a short caller budget is never stretched.
964
947
  const rateLimit = new LocalLlmRateLimitSession(
965
948
  formatLocalLlmPoolKey(chatUrl, operation),
966
949
  resolveRateLimitSettings(this.config),
@@ -979,8 +962,10 @@ export class LocalLlmClient {
979
962
  log.warn(gate.reason === "queue"
980
963
  ? `local LLM concurrency queue exceeded the ${effectiveTimeoutMs}ms request budget; skipping request (op=${operation})`
981
964
  : `local LLM rate-limit backoff active (${gate.remainingMs}ms remaining); skipping request (op=${operation})`);
982
- if (options.failureDiag)
965
+ if (options.failureDiag) {
983
966
  options.failureDiag.lastError = Object.assign(new Error("local LLM rate limited"), { status: 429 });
967
+ options.failureDiag.sawTransientAttempt = true;
968
+ }
984
969
  return null;
985
970
  }
986
971
  if (gate.kind === "aborted") return null;
@@ -1032,8 +1017,12 @@ export class LocalLlmClient {
1032
1017
  log.debug(`local LLM failed to read ${response.status} response body: ${options.redactProviderErrors ? "details redacted" : error.message}`);
1033
1018
  } else {
1034
1019
  response = null;
1035
- if (!isAbortError(err)) throw err;
1020
+ if (!isAbortError(err)) {
1021
+ if (options.failureDiag) options.failureDiag.sawTransientAttempt = true;
1022
+ throw err;
1023
+ }
1036
1024
  lastAbortError = error;
1025
+ if (options.failureDiag) options.failureDiag.sawTransientAttempt = true;
1037
1026
  if (attempt >= maxAttempts) break;
1038
1027
  const backoffMs = this.config.localLlmRetryBackoffMs * attempt;
1039
1028
  log.warn(
@@ -1052,6 +1041,9 @@ export class LocalLlmClient {
1052
1041
  rateLimit.onSuccess();
1053
1042
  break;
1054
1043
  }
1044
+ // A transient attempt stays evidence even when a later attempt fails terminally (#3757).
1045
+ if (options.failureDiag && (response.status === 408 || response.status === 429 || response.status >= 500))
1046
+ options.failureDiag.sawTransientAttempt = true;
1055
1047
  if (response.status >= 500 && attempt < maxAttempts) {
1056
1048
  const nonRecoverableReason = extractNonRecoverableBackendReasonFromErrorText(responseBody);
1057
1049
  if (nonRecoverableReason) {
@@ -1103,9 +1095,14 @@ export class LocalLlmClient {
1103
1095
  if (lastRateLimitDelayMs !== null)
1104
1096
  log.warn(`local LLM rate-limit retries exhausted: op=${operation} retries=${rateLimit.retryCount} nextBackoffMs=${lastRateLimitDelayMs}`);
1105
1097
  let reason = "";
1098
+ let providerMessage: string | undefined;
1099
+ let providerCode: string | undefined;
1106
1100
  try {
1107
- const parsed = JSON.parse(responseBody) as { error?: { message?: string } };
1108
- reason = parsed?.error?.message ? ` — ${parsed.error.message}` : "";
1101
+ // SAFETY: OpenAI-compatible error envelope; optional fields read defensively.
1102
+ const parsed = JSON.parse(responseBody) as { error?: { message?: string; code?: unknown } };
1103
+ providerMessage = parsed?.error?.message;
1104
+ providerCode = parsed?.error?.code === undefined ? undefined : String(parsed.error.code);
1105
+ reason = providerMessage ? ` — ${providerMessage}` : "";
1109
1106
  } catch {
1110
1107
  if (!options.redactProviderErrors) log.debug(`local LLM error body: ${responseBody.slice(0, 500)}`);
1111
1108
  }
@@ -1139,10 +1136,14 @@ export class LocalLlmClient {
1139
1136
  } else {
1140
1137
  this.consecutive400s = 0;
1141
1138
  }
1142
- if (options.failureDiag)
1143
- options.failureDiag.lastError = Object.assign(new Error("local LLM http failure"), {
1144
- status: response.status,
1145
- });
1139
+ if (options.failureDiag) {
1140
+ const lastError = Object.assign(new Error("local LLM http failure"), { status: response.status });
1141
+ // Tag a parameter-refusing rejection so classification parks the
1142
+ // window as a config failure; sanitized — no provider text (#3757).
1143
+ if (isParameterConfigRejection({ code: providerCode, message: providerMessage }))
1144
+ Object.assign(lastError, { code: "unsupported_parameter" });
1145
+ options.failureDiag.lastError = lastError;
1146
+ }
1146
1147
  return null;
1147
1148
  }
1148
1149
  this.consecutive400s = 0;
@@ -110,8 +110,14 @@ export class ExtractionDrain {
110
110
  constructor(deps: ExtractionDrainDeps, options?: { dropFailedChunks?: boolean }) {
111
111
  this.deps = deps;
112
112
  this.dropFailedChunks = options?.dropFailedChunks !== false;
113
+ // Forward the drain's drop policy so the run layer dead-letters a
114
+ // permanently-failing window only where dropping failures is permitted.
115
+ this.runExtraction = (turns, runOptions) =>
116
+ deps.runExtraction(turns, { ...runOptions, dropFailedChunks: this.dropFailedChunks && runOptions?.dropFailedChunks !== false });
113
117
  }
114
118
 
119
+ private readonly runExtraction: ExtractionDrainDeps["runExtraction"];
120
+
115
121
  /** Characters the coordinator would count for this window: user/assistant text, trimmed and capped per turn, context-only turns left out. */
116
122
  private windowChars(turns: readonly BufferTurn[]): number {
117
123
  let total = 0;
@@ -204,14 +210,14 @@ export class ExtractionDrain {
204
210
  if (plan.singleRun) {
205
211
  // Without duplicates this is today's single-run path: the run judges its own
206
212
  // thresholds on the raw window.
207
- if (collapsed.duplicateCount === 0) return await this.deps.runExtraction(turns, runOptions);
213
+ if (collapsed.duplicateCount === 0) return await this.runExtraction(turns, runOptions);
208
214
  // With duplicates, eligibility belongs to the RAW window — duplicate inflation
209
215
  // must not change whether a window qualifies (#3443). Below the threshold,
210
216
  // today's skip path runs on the raw window (unmarked, so skip/capture/clear
211
217
  // judge every identity exactly as before); above it, the representative subset
212
218
  // is never re-judged — the same rule the chunk loop applies to chunks.
213
- if (this.windowBelowThreshold(turns, runOptions)) return await this.deps.runExtraction(turns, runOptions);
214
- return await this.deps.runExtraction(window, {
219
+ if (this.windowBelowThreshold(turns, runOptions)) return await this.runExtraction(turns, runOptions);
220
+ return await this.runExtraction(window, {
215
221
  ...runOptions,
216
222
  skipCharThreshold: true,
217
223
  skipUserTurnThreshold: true,
@@ -221,7 +227,7 @@ export class ExtractionDrain {
221
227
  // window: a window that never qualified keeps the single-run path, which
222
228
  // judges it exactly as before.
223
229
  if (!plan.resumed && this.windowBelowThreshold(turns, runOptions)) {
224
- return await this.deps.runExtraction(turns, runOptions);
230
+ return await this.runExtraction(turns, runOptions);
225
231
  }
226
232
  // A deduped window is never re-judged on its representative subset inside the
227
233
  // run: eligibility above (or the caller's skip flags) already decided it.
@@ -360,7 +366,7 @@ export class ExtractionDrain {
360
366
  const failures = this.failureCount(bufferKey, chunk);
361
367
  let result: ExtractionRunResult;
362
368
  try {
363
- result = await this.deps.runExtraction(chunk, chunkOptions);
369
+ result = await this.runExtraction(chunk, { ...chunkOptions, partParents });
364
370
  } catch (err) {
365
371
  this.rethrowChunkAbort(err, preempt, runOptions.abortSignal?.aborted === true);
366
372
  // A successfully dropped thrown chunk does not end the drain: later
@@ -0,0 +1,35 @@
1
+ import assert from "node:assert/strict";
2
+ import { readFileSync } from "node:fs";
3
+ import test from "node:test";
4
+ import ts from "typescript";
5
+
6
+ const sourcePath = new URL("./extraction-persist.ts", import.meta.url);
7
+
8
+ function coordinatorMethod(sourceFile: ts.SourceFile, name: string): ts.MethodDeclaration {
9
+ for (const statement of sourceFile.statements) {
10
+ if (!ts.isClassDeclaration(statement) || statement.name?.text !== "ExtractionPersistCoordinator") continue;
11
+ for (const member of statement.members) {
12
+ if (ts.isMethodDeclaration(member) && member.name.getText(sourceFile) === name) return member;
13
+ }
14
+ }
15
+ assert.fail(`ExtractionPersistCoordinator.${name} not found`);
16
+ }
17
+
18
+ function parameterSignature(sourceFile: ts.SourceFile, method: ts.MethodDeclaration): string[] {
19
+ return method.parameters.map((p) => `${p.name.getText(sourceFile)}: ${p.type?.getText(sourceFile) ?? "<untyped>"}`);
20
+ }
21
+
22
+ test("#3395: the emitted persistExtraction declaration spells out the pass parameters", () => {
23
+ const source = readFileSync(sourcePath, "utf8");
24
+ const sourceFile = ts.createSourceFile("extraction-persist.ts", source, ts.ScriptTarget.ES2022, true);
25
+ const { outputText } = ts.transpileDeclaration(source, { fileName: "extraction-persist.ts" });
26
+ const declarationFile = ts.createSourceFile("extraction-persist.d.ts", outputText, ts.ScriptTarget.ES2022, true);
27
+
28
+ // The private pass is emitted without a type, so the public signature must not derive from it.
29
+ const declared = coordinatorMethod(declarationFile, "persistExtraction");
30
+ assert.doesNotMatch(declared.getText(declarationFile), /persistExtractionPass/);
31
+
32
+ const passParameters = parameterSignature(sourceFile, coordinatorMethod(sourceFile, "persistExtractionPass"));
33
+ assert.equal(passParameters[0], "finalization: CommittedWriteFinalization");
34
+ assert.deepEqual(parameterSignature(declarationFile, declared), passParameters.slice(1));
35
+ });
@@ -52,6 +52,3 @@ export class CommittedWriteFinalization {
52
52
  }
53
53
  }
54
54
  }
55
-
56
- /** A pass method's parameter list without its leading CommittedWriteFinalization. */
57
- export type ArgsAfterFinalization<Params> = Params extends [CommittedWriteFinalization, ...infer Rest] ? Rest : never;
@@ -1,7 +1,7 @@
1
1
  import { classifyExtractionOrigin, type ExtractionSourceContext } from "./extraction-origin-context.js";
2
2
  import { confirmActiveFactDuplicate, persistUnderFactDedupWindow } from "./fact-dedup-window.js";
3
3
  import { writePromotionUnderFactDedupWindow } from "./promotion-dedup-window.js";
4
- import { type ArgsAfterFinalization, CommittedWriteFinalization, rethrowAfterCommittedWriteFinalization } from "./extraction-persist-failure.js";
4
+ import { CommittedWriteFinalization, rethrowAfterCommittedWriteFinalization } from "./extraction-persist-failure.js";
5
5
  import { evaluateInjectionScreen, screenEntityForIndex, screenPersistStrings } from "./extraction-injection-gate.js";
6
6
  /**
7
7
  * Extraction persistence coordinator (issue #1526, seam 16).
@@ -152,9 +152,9 @@ export class ExtractionPersistCoordinator {
152
152
  return this.deps.getDependencyPropagationDelivery();
153
153
  }
154
154
 
155
- persistExtraction(...args: ArgsAfterFinalization<Parameters<ExtractionPersistCoordinator["persistExtractionPass"]>>): Promise<ExtractionPersistResult> {
155
+ persistExtraction(result: ExtractionResult, storage: StorageManager, threadIdForExtraction?: string | null, sourceContext?: ExtractionSourceContext, baseNamespace?: string, scopeProfileWritePlan?: ResolvedScopeProfilePlan | null, sourceText?: string, graphCaps?: GraphConstructionCapabilitySet, lifecycleCaps?: MemoryLifecycleCapabilitySet): Promise<ExtractionPersistResult> {
156
156
  const finalization = new CommittedWriteFinalization(); // #3288: one batch-end finalization boundary per pass
157
- return finalization.run(() => this.persistExtractionPass(finalization, ...args));
157
+ return finalization.run(() => this.persistExtractionPass(finalization, result, storage, threadIdForExtraction, sourceContext, baseNamespace, scopeProfileWritePlan, sourceText, graphCaps, lifecycleCaps));
158
158
  }
159
159
 
160
160
  private async persistExtractionPass(