@remnic/core 10.0.122 → 10.0.124

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 (319) hide show
  1. package/dist/access-admin-ops-surface.js +146 -144
  2. package/dist/access-cli.js +146 -144
  3. package/dist/access-cli.js.map +1 -1
  4. package/dist/access-extraction-force-flush.js +146 -144
  5. package/dist/access-http-admission.js +1 -1
  6. package/dist/access-http-briefing.js +146 -144
  7. package/dist/access-http-query.js +146 -144
  8. package/dist/access-http.js +146 -144
  9. package/dist/access-identity-continuity-surface.js +146 -144
  10. package/dist/access-lcm-surface.js +146 -144
  11. package/dist/access-mcp.js +146 -144
  12. package/dist/access-observe-write-category.js +9 -9
  13. package/dist/access-observe-write-surface.js +146 -144
  14. package/dist/access-offline-manifest.js +6 -6
  15. package/dist/access-operations-batch.js +146 -144
  16. package/dist/access-operations.js +146 -144
  17. package/dist/access-recall-concurrency.js +146 -144
  18. package/dist/access-recall-diagnostics.js +2 -2
  19. package/dist/access-recall-response.js +146 -144
  20. package/dist/access-recall-surface.js +146 -144
  21. package/dist/access-schema.js +8 -8
  22. package/dist/access-service.js +146 -144
  23. package/dist/active-recall.js +23 -23
  24. package/dist/adapters/index.js +7 -7
  25. package/dist/adapters/registry.js +3 -3
  26. package/dist/briefing.js +16 -16
  27. package/dist/buffer-admission.d.ts +9 -0
  28. package/dist/buffer-admission.d.ts.map +1 -1
  29. package/dist/buffer-admission.js +3 -1
  30. package/dist/buffer-session-cap.d.ts +15 -0
  31. package/dist/buffer-session-cap.d.ts.map +1 -0
  32. package/dist/buffer-session-cap.js +19 -0
  33. package/dist/buffer.d.ts +1 -1
  34. package/dist/buffer.d.ts.map +1 -1
  35. package/dist/buffer.js +7 -4
  36. package/dist/calibration.js +4 -4
  37. package/dist/{capsule-crypto-GWVG7LGC.js → capsule-crypto-7FJQINUR.js} +2 -2
  38. package/dist/causal-behavior.js +2 -2
  39. package/dist/causal-chain.js +2 -2
  40. package/dist/causal-consolidation.js +19 -19
  41. package/dist/causal-retrieval.js +2 -2
  42. package/dist/causal-trajectory-graph.js +3 -3
  43. package/dist/causal-trajectory.js +1 -1
  44. package/dist/{chunk-A6KNCOHQ.js → chunk-2AVPRUML.js} +2 -2
  45. package/dist/{chunk-CLF4TBUS.js → chunk-2GSPNTOU.js} +2 -2
  46. package/dist/{chunk-OWHERGF2.js → chunk-2NLLXCJG.js} +2 -2
  47. package/dist/{chunk-43AA5FVD.js → chunk-3IZQFNIV.js} +1 -1
  48. package/dist/chunk-3IZQFNIV.js.map +1 -0
  49. package/dist/{chunk-IARHAE4J.js → chunk-42JE2CF4.js} +2 -2
  50. package/dist/{chunk-7POUQFKI.js → chunk-47W3ALIS.js} +3 -3
  51. package/dist/{chunk-FGI6GJA5.js → chunk-4VCASS3Q.js} +3 -3
  52. package/dist/{chunk-NLYLOLQW.js → chunk-4VWZ4HPL.js} +5 -5
  53. package/dist/{chunk-K4P2MUVI.js → chunk-5DCCVEKT.js} +2 -2
  54. package/dist/{chunk-C5PEYREE.js → chunk-5DP4GVKR.js} +2 -2
  55. package/dist/{chunk-FAAWURSH.js → chunk-6IRJWKR5.js} +2 -2
  56. package/dist/{chunk-QOWLC5P6.js → chunk-6VAN7VZR.js} +14 -14
  57. package/dist/{chunk-ZZ5S2SFB.js → chunk-7QDB7P3V.js} +3 -3
  58. package/dist/{chunk-4VAUQBFJ.js → chunk-7TJMXZPO.js} +3 -3
  59. package/dist/{chunk-SEOJHETP.js → chunk-ASINXIKX.js} +10 -9
  60. package/dist/{chunk-SEOJHETP.js.map → chunk-ASINXIKX.js.map} +1 -1
  61. package/dist/{chunk-ZMIRHXJE.js → chunk-AYWW6JEH.js} +211 -211
  62. package/dist/{chunk-ZMIRHXJE.js.map → chunk-AYWW6JEH.js.map} +1 -1
  63. package/dist/{chunk-73TPOGS4.js → chunk-BFBS7OFQ.js} +9 -9
  64. package/dist/{chunk-Z6EMZNKI.js → chunk-BFDXJHYG.js} +2 -2
  65. package/dist/{chunk-IFYWNSSU.js → chunk-BNRKSJMO.js} +2 -2
  66. package/dist/{chunk-TNPUVR6U.js → chunk-C7BTGSCY.js} +13 -13
  67. package/dist/{chunk-ZDE54VUB.js → chunk-CQMH65IP.js} +2 -2
  68. package/dist/{chunk-R4BBGPI2.js → chunk-CS66BCED.js} +2 -2
  69. package/dist/{chunk-ZQLJNZZ7.js → chunk-CUKYV5O3.js} +7 -7
  70. package/dist/{chunk-W2B25HUU.js → chunk-DB4THCGN.js} +6 -6
  71. package/dist/{chunk-DWUKVXMU.js → chunk-DH2CDGAE.js} +2 -2
  72. package/dist/{chunk-ZDZJNXL6.js → chunk-DK2VBJ6Q.js} +4 -4
  73. package/dist/{chunk-744WDDFX.js → chunk-DL7K5PMQ.js} +2 -2
  74. package/dist/{chunk-5RONA5FF.js → chunk-DTTDMK7Q.js} +4 -4
  75. package/dist/{chunk-P7FC7N5Z.js → chunk-EFHM4VDG.js} +2 -2
  76. package/dist/{chunk-CPWYYRJ2.js → chunk-ELBZT6RU.js} +2 -2
  77. package/dist/{chunk-HOYYVQN2.js → chunk-ERR7ZFPJ.js} +2 -2
  78. package/dist/{chunk-CNCN5UN4.js → chunk-FBXU7X27.js} +2 -2
  79. package/dist/{chunk-3SL52JKD.js → chunk-FZVROZKC.js} +5 -5
  80. package/dist/{chunk-5PCUUGLT.js → chunk-G53I363P.js} +2 -2
  81. package/dist/{chunk-V2KGDESV.js → chunk-GS2TT2YE.js} +2 -2
  82. package/dist/{chunk-EMMJQASU.js → chunk-GSCIRMPR.js} +2 -2
  83. package/dist/{chunk-OM5ESBES.js → chunk-HQPFACXO.js} +2 -2
  84. package/dist/{chunk-HBNMJ26J.js → chunk-HRMOKGQM.js} +2 -2
  85. package/dist/{chunk-EHJI3L7T.js → chunk-HURBXNNB.js} +2 -2
  86. package/dist/{chunk-4RASUAN3.js → chunk-HXFIILGF.js} +4 -4
  87. package/dist/{chunk-XYZXO6VO.js → chunk-IB4TDPCC.js} +20 -20
  88. package/dist/{chunk-IMULTENA.js → chunk-ID65XTF3.js} +2 -2
  89. package/dist/{chunk-3COGVB3C.js → chunk-IDCZEKK6.js} +14 -3
  90. package/dist/chunk-IDCZEKK6.js.map +1 -0
  91. package/dist/{chunk-L5PM7B3I.js → chunk-IFFCHE3O.js} +1 -1
  92. package/dist/{chunk-L5PM7B3I.js.map → chunk-IFFCHE3O.js.map} +1 -1
  93. package/dist/{chunk-VPARMYWA.js → chunk-J6U6KUMK.js} +8 -8
  94. package/dist/{chunk-6GQFMR6A.js → chunk-JTY3NA3I.js} +2 -2
  95. package/dist/{chunk-TH6OYP6I.js → chunk-K36RMINQ.js} +3 -3
  96. package/dist/{chunk-BUKK5SWA.js → chunk-KQAFEZQX.js} +2 -2
  97. package/dist/{chunk-X6QQNDIW.js → chunk-KWVGRNKL.js} +9 -5
  98. package/dist/chunk-KWVGRNKL.js.map +1 -0
  99. package/dist/{chunk-B2RECSSR.js → chunk-LKGTTX74.js} +2 -2
  100. package/dist/chunk-LWZNSQN3.js +44 -0
  101. package/dist/chunk-LWZNSQN3.js.map +1 -0
  102. package/dist/{chunk-WRTLTOHA.js → chunk-O62MMJWV.js} +2 -2
  103. package/dist/{chunk-K3FH3LAQ.js → chunk-OJXK5C6Z.js} +4 -4
  104. package/dist/{chunk-SH4R3FVM.js → chunk-PAGVXEWG.js} +2 -2
  105. package/dist/{chunk-WEDE4DXL.js → chunk-PUKLCFCU.js} +4 -4
  106. package/dist/{chunk-WEDE4DXL.js.map → chunk-PUKLCFCU.js.map} +1 -1
  107. package/dist/{chunk-GMO3BGOF.js → chunk-QC2MHZDD.js} +1 -1
  108. package/dist/{chunk-KNAF3A7Y.js → chunk-QF64W4YM.js} +2 -2
  109. package/dist/{chunk-PH5ZQM35.js → chunk-R6BNDA67.js} +2 -2
  110. package/dist/{chunk-P5KJOXWH.js → chunk-RRHLI6VU.js} +2 -2
  111. package/dist/{chunk-NHVAX7MH.js → chunk-RSKZWXQO.js} +3 -3
  112. package/dist/{chunk-UCD7NQKZ.js → chunk-RTIHO7AJ.js} +2 -2
  113. package/dist/{chunk-I3V3JJS7.js → chunk-SRDWJPET.js} +2 -2
  114. package/dist/{chunk-I3V3JJS7.js.map → chunk-SRDWJPET.js.map} +1 -1
  115. package/dist/{chunk-RDCKC5MI.js → chunk-SU42FIJ7.js} +3 -3
  116. package/dist/{chunk-WQUGCOKF.js → chunk-TFA6HPOA.js} +4 -4
  117. package/dist/{chunk-OYHEVL4A.js → chunk-UGCLNASV.js} +3 -3
  118. package/dist/{chunk-XNRLRNQF.js → chunk-UPYEFL7J.js} +2 -2
  119. package/dist/chunk-V24YLFJW.js +72 -0
  120. package/dist/chunk-V24YLFJW.js.map +1 -0
  121. package/dist/{chunk-U2PSE7MB.js → chunk-VPEIWMUT.js} +2 -2
  122. package/dist/{chunk-RB7NXZ2E.js → chunk-W4Q65VJL.js} +2 -2
  123. package/dist/{chunk-SVP57SAR.js → chunk-WRGW76LI.js} +9 -9
  124. package/dist/{chunk-FA7SLQ5X.js → chunk-WUQH7BDU.js} +1 -1
  125. package/dist/chunk-WUQH7BDU.js.map +1 -0
  126. package/dist/{chunk-SED6JMID.js → chunk-WYABF2WA.js} +7 -7
  127. package/dist/{chunk-UVYI6VIX.js → chunk-X7Y7WX73.js} +1 -1
  128. package/dist/{chunk-ENQCH3SW.js → chunk-XAIRTELU.js} +10 -1
  129. package/dist/chunk-XAIRTELU.js.map +1 -0
  130. package/dist/{chunk-5JDLDYST.js → chunk-XLHLZALR.js} +3 -3
  131. package/dist/{chunk-OJPCASE5.js → chunk-XN43HAIV.js} +2 -2
  132. package/dist/{chunk-YGFHQT3E.js → chunk-YJEOQ72B.js} +2 -2
  133. package/dist/{chunk-N72KBIZ2.js → chunk-YKUW2EZF.js} +18 -12
  134. package/dist/chunk-YKUW2EZF.js.map +1 -0
  135. package/dist/{chunk-65HWAQ4F.js → chunk-ZDCSFRIU.js} +2 -2
  136. package/dist/cli.js +146 -144
  137. package/dist/coding/export-okf-codegraph.js +15 -15
  138. package/dist/coding/pre-action-gate.js +2 -2
  139. package/dist/compounding/engine.js +17 -17
  140. package/dist/config.d.ts.map +1 -1
  141. package/dist/config.js +23 -23
  142. package/dist/connectors/codex-materialize-runner.js +16 -16
  143. package/dist/connectors/index.js +16 -16
  144. package/dist/convergence-refresh.js +18 -18
  145. package/dist/conversation-index/backend.js +2 -2
  146. package/dist/corpus-watermark.js +18 -18
  147. package/dist/deep-recall-http-glue.js +9 -9
  148. package/dist/deep-recall.js +2 -2
  149. package/dist/embedding-fallback.js +1 -1
  150. package/dist/entity-retrieval.js +17 -17
  151. package/dist/event-order-recall.js +3 -3
  152. package/dist/explicit-capture.js +146 -144
  153. package/dist/extraction-error-classification.d.ts +2 -0
  154. package/dist/extraction-error-classification.d.ts.map +1 -1
  155. package/dist/extraction-error-classification.js +1 -1
  156. package/dist/extraction-reply-diagnostic.d.ts +31 -0
  157. package/dist/extraction-reply-diagnostic.d.ts.map +1 -0
  158. package/dist/extraction-reply-diagnostic.js +13 -0
  159. package/dist/extraction-reply-diagnostic.js.map +1 -0
  160. package/dist/extraction-span-materialize.js +2 -2
  161. package/dist/extraction.d.ts +0 -1
  162. package/dist/extraction.d.ts.map +1 -1
  163. package/dist/extraction.js +28 -27
  164. package/dist/{graph-edge-decay-BC3IO2J4.js → graph-edge-decay-CXTNJ7IQ.js} +6 -6
  165. package/dist/graph-edge-decay-CXTNJ7IQ.js.map +1 -0
  166. package/dist/graph-jsonl.js +4 -4
  167. package/dist/graph-snapshot.js +4 -4
  168. package/dist/graph.js +5 -5
  169. package/dist/harmonic-retrieval.js +16 -16
  170. package/dist/index.js +236 -234
  171. package/dist/lcm/engine.js +2 -2
  172. package/dist/lcm/index.js +7 -7
  173. package/dist/local-llm-helpers.d.ts +1 -0
  174. package/dist/local-llm-helpers.d.ts.map +1 -1
  175. package/dist/local-llm-helpers.js +1 -1
  176. package/dist/local-llm.js +4 -4
  177. package/dist/location/index.js +17 -17
  178. package/dist/maintenance/memory-governance.js +16 -16
  179. package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +16 -16
  180. package/dist/maintenance/rebuild-memory-projection-runner.js +18 -18
  181. package/dist/maintenance/rebuild-memory-projection.js +17 -17
  182. package/dist/namespaces/migrate.js +17 -17
  183. package/dist/namespaces/search.js +7 -7
  184. package/dist/namespaces/storage.js +16 -16
  185. package/dist/offline-sync-changeset-generations.js +4 -4
  186. package/dist/offline-sync-embedding-generation.js +3 -3
  187. package/dist/offline-sync-snapshot-stream.js +6 -6
  188. package/dist/offline-sync.js +8 -8
  189. package/dist/operator-doctor-corpus.js +19 -19
  190. package/dist/operator-toolkit.js +34 -34
  191. package/dist/orchestration/backlog-scheduler.js +147 -145
  192. package/dist/orchestration/backlog-scheduler.js.map +1 -1
  193. package/dist/orchestration/buffer-drain-runner.js +147 -145
  194. package/dist/orchestration/extraction-run.d.ts.map +1 -1
  195. package/dist/orchestration/maintenance.js +28 -28
  196. package/dist/orchestrator.js +146 -144
  197. package/dist/recall-explain-renderer.js +3 -3
  198. package/dist/recall-navigate-access.js +2 -2
  199. package/dist/recall-navigate-disclosure.js +2 -2
  200. package/dist/recall-navigate.js +2 -2
  201. package/dist/recall-navigation.js +146 -144
  202. package/dist/recall-xray-cli.js +4 -4
  203. package/dist/recall-xray-renderer.js +3 -3
  204. package/dist/recall-xray.js +2 -2
  205. package/dist/resume-bundles.js +26 -26
  206. package/dist/search/factory.js +6 -6
  207. package/dist/search/index.js +12 -12
  208. package/dist/semantic-consolidation.js +17 -17
  209. package/dist/semantic-rule-promotion.js +16 -16
  210. package/dist/semantic-rule-verifier.js +16 -16
  211. package/dist/source-agent-qualifier.js +18 -18
  212. package/dist/standup/build.js +16 -16
  213. package/dist/storage.js +15 -15
  214. package/dist/summarizer.js +5 -5
  215. package/dist/support-passport/index.js +5 -5
  216. package/dist/transcript.js +2 -2
  217. package/dist/transfer/backup.js +2 -2
  218. package/dist/transfer/capsule-export.js +2 -2
  219. package/dist/transfer/capsule-import.js +2 -2
  220. package/dist/transfer/export-okf.js +16 -16
  221. package/dist/types.d.ts +2 -0
  222. package/dist/types.d.ts.map +1 -1
  223. package/dist/types.js +1 -1
  224. package/dist/verified-recall.js +16 -16
  225. package/dist/who-knows-cli.js +17 -17
  226. package/dist/who-knows.js +16 -16
  227. package/package.json +2 -2
  228. package/src/access-http-admission.ts +1 -1
  229. package/src/access-mcp.ts +1 -1
  230. package/src/buffer-admission.ts +16 -0
  231. package/src/buffer-session-cap.ts +49 -0
  232. package/src/buffer-session.test.ts +75 -1
  233. package/src/buffer.ts +7 -2
  234. package/src/config.ts +4 -0
  235. package/src/extraction-error-classification.ts +2 -0
  236. package/src/extraction-reply-diagnostic-wiring.test.ts +87 -0
  237. package/src/extraction-reply-diagnostic.test.ts +130 -0
  238. package/src/extraction-reply-diagnostic.ts +105 -0
  239. package/src/extraction.ts +7 -16
  240. package/src/local-llm-headers-timeout.test.ts +24 -1
  241. package/src/local-llm-helpers.ts +1 -1
  242. package/src/local-llm.ts +3 -3
  243. package/src/orchestration/extraction-run.ts +7 -3
  244. package/src/orchestrator-flush.test.ts +72 -4
  245. package/src/types.ts +2 -0
  246. package/dist/chunk-3COGVB3C.js.map +0 -1
  247. package/dist/chunk-43AA5FVD.js.map +0 -1
  248. package/dist/chunk-ENQCH3SW.js.map +0 -1
  249. package/dist/chunk-FA7SLQ5X.js.map +0 -1
  250. package/dist/chunk-N72KBIZ2.js.map +0 -1
  251. package/dist/chunk-X6QQNDIW.js.map +0 -1
  252. /package/dist/{capsule-crypto-GWVG7LGC.js.map → buffer-session-cap.js.map} +0 -0
  253. /package/dist/{graph-edge-decay-BC3IO2J4.js.map → capsule-crypto-7FJQINUR.js.map} +0 -0
  254. /package/dist/{chunk-A6KNCOHQ.js.map → chunk-2AVPRUML.js.map} +0 -0
  255. /package/dist/{chunk-CLF4TBUS.js.map → chunk-2GSPNTOU.js.map} +0 -0
  256. /package/dist/{chunk-OWHERGF2.js.map → chunk-2NLLXCJG.js.map} +0 -0
  257. /package/dist/{chunk-IARHAE4J.js.map → chunk-42JE2CF4.js.map} +0 -0
  258. /package/dist/{chunk-7POUQFKI.js.map → chunk-47W3ALIS.js.map} +0 -0
  259. /package/dist/{chunk-FGI6GJA5.js.map → chunk-4VCASS3Q.js.map} +0 -0
  260. /package/dist/{chunk-NLYLOLQW.js.map → chunk-4VWZ4HPL.js.map} +0 -0
  261. /package/dist/{chunk-K4P2MUVI.js.map → chunk-5DCCVEKT.js.map} +0 -0
  262. /package/dist/{chunk-C5PEYREE.js.map → chunk-5DP4GVKR.js.map} +0 -0
  263. /package/dist/{chunk-FAAWURSH.js.map → chunk-6IRJWKR5.js.map} +0 -0
  264. /package/dist/{chunk-QOWLC5P6.js.map → chunk-6VAN7VZR.js.map} +0 -0
  265. /package/dist/{chunk-ZZ5S2SFB.js.map → chunk-7QDB7P3V.js.map} +0 -0
  266. /package/dist/{chunk-4VAUQBFJ.js.map → chunk-7TJMXZPO.js.map} +0 -0
  267. /package/dist/{chunk-73TPOGS4.js.map → chunk-BFBS7OFQ.js.map} +0 -0
  268. /package/dist/{chunk-Z6EMZNKI.js.map → chunk-BFDXJHYG.js.map} +0 -0
  269. /package/dist/{chunk-IFYWNSSU.js.map → chunk-BNRKSJMO.js.map} +0 -0
  270. /package/dist/{chunk-TNPUVR6U.js.map → chunk-C7BTGSCY.js.map} +0 -0
  271. /package/dist/{chunk-ZDE54VUB.js.map → chunk-CQMH65IP.js.map} +0 -0
  272. /package/dist/{chunk-R4BBGPI2.js.map → chunk-CS66BCED.js.map} +0 -0
  273. /package/dist/{chunk-ZQLJNZZ7.js.map → chunk-CUKYV5O3.js.map} +0 -0
  274. /package/dist/{chunk-W2B25HUU.js.map → chunk-DB4THCGN.js.map} +0 -0
  275. /package/dist/{chunk-DWUKVXMU.js.map → chunk-DH2CDGAE.js.map} +0 -0
  276. /package/dist/{chunk-ZDZJNXL6.js.map → chunk-DK2VBJ6Q.js.map} +0 -0
  277. /package/dist/{chunk-744WDDFX.js.map → chunk-DL7K5PMQ.js.map} +0 -0
  278. /package/dist/{chunk-5RONA5FF.js.map → chunk-DTTDMK7Q.js.map} +0 -0
  279. /package/dist/{chunk-P7FC7N5Z.js.map → chunk-EFHM4VDG.js.map} +0 -0
  280. /package/dist/{chunk-CPWYYRJ2.js.map → chunk-ELBZT6RU.js.map} +0 -0
  281. /package/dist/{chunk-HOYYVQN2.js.map → chunk-ERR7ZFPJ.js.map} +0 -0
  282. /package/dist/{chunk-CNCN5UN4.js.map → chunk-FBXU7X27.js.map} +0 -0
  283. /package/dist/{chunk-3SL52JKD.js.map → chunk-FZVROZKC.js.map} +0 -0
  284. /package/dist/{chunk-5PCUUGLT.js.map → chunk-G53I363P.js.map} +0 -0
  285. /package/dist/{chunk-V2KGDESV.js.map → chunk-GS2TT2YE.js.map} +0 -0
  286. /package/dist/{chunk-EMMJQASU.js.map → chunk-GSCIRMPR.js.map} +0 -0
  287. /package/dist/{chunk-OM5ESBES.js.map → chunk-HQPFACXO.js.map} +0 -0
  288. /package/dist/{chunk-HBNMJ26J.js.map → chunk-HRMOKGQM.js.map} +0 -0
  289. /package/dist/{chunk-EHJI3L7T.js.map → chunk-HURBXNNB.js.map} +0 -0
  290. /package/dist/{chunk-4RASUAN3.js.map → chunk-HXFIILGF.js.map} +0 -0
  291. /package/dist/{chunk-XYZXO6VO.js.map → chunk-IB4TDPCC.js.map} +0 -0
  292. /package/dist/{chunk-IMULTENA.js.map → chunk-ID65XTF3.js.map} +0 -0
  293. /package/dist/{chunk-VPARMYWA.js.map → chunk-J6U6KUMK.js.map} +0 -0
  294. /package/dist/{chunk-6GQFMR6A.js.map → chunk-JTY3NA3I.js.map} +0 -0
  295. /package/dist/{chunk-TH6OYP6I.js.map → chunk-K36RMINQ.js.map} +0 -0
  296. /package/dist/{chunk-BUKK5SWA.js.map → chunk-KQAFEZQX.js.map} +0 -0
  297. /package/dist/{chunk-B2RECSSR.js.map → chunk-LKGTTX74.js.map} +0 -0
  298. /package/dist/{chunk-WRTLTOHA.js.map → chunk-O62MMJWV.js.map} +0 -0
  299. /package/dist/{chunk-K3FH3LAQ.js.map → chunk-OJXK5C6Z.js.map} +0 -0
  300. /package/dist/{chunk-SH4R3FVM.js.map → chunk-PAGVXEWG.js.map} +0 -0
  301. /package/dist/{chunk-GMO3BGOF.js.map → chunk-QC2MHZDD.js.map} +0 -0
  302. /package/dist/{chunk-KNAF3A7Y.js.map → chunk-QF64W4YM.js.map} +0 -0
  303. /package/dist/{chunk-PH5ZQM35.js.map → chunk-R6BNDA67.js.map} +0 -0
  304. /package/dist/{chunk-P5KJOXWH.js.map → chunk-RRHLI6VU.js.map} +0 -0
  305. /package/dist/{chunk-NHVAX7MH.js.map → chunk-RSKZWXQO.js.map} +0 -0
  306. /package/dist/{chunk-UCD7NQKZ.js.map → chunk-RTIHO7AJ.js.map} +0 -0
  307. /package/dist/{chunk-RDCKC5MI.js.map → chunk-SU42FIJ7.js.map} +0 -0
  308. /package/dist/{chunk-WQUGCOKF.js.map → chunk-TFA6HPOA.js.map} +0 -0
  309. /package/dist/{chunk-OYHEVL4A.js.map → chunk-UGCLNASV.js.map} +0 -0
  310. /package/dist/{chunk-XNRLRNQF.js.map → chunk-UPYEFL7J.js.map} +0 -0
  311. /package/dist/{chunk-U2PSE7MB.js.map → chunk-VPEIWMUT.js.map} +0 -0
  312. /package/dist/{chunk-RB7NXZ2E.js.map → chunk-W4Q65VJL.js.map} +0 -0
  313. /package/dist/{chunk-SVP57SAR.js.map → chunk-WRGW76LI.js.map} +0 -0
  314. /package/dist/{chunk-SED6JMID.js.map → chunk-WYABF2WA.js.map} +0 -0
  315. /package/dist/{chunk-UVYI6VIX.js.map → chunk-X7Y7WX73.js.map} +0 -0
  316. /package/dist/{chunk-5JDLDYST.js.map → chunk-XLHLZALR.js.map} +0 -0
  317. /package/dist/{chunk-OJPCASE5.js.map → chunk-XN43HAIV.js.map} +0 -0
  318. /package/dist/{chunk-YGFHQT3E.js.map → chunk-YJEOQ72B.js.map} +0 -0
  319. /package/dist/{chunk-65HWAQ4F.js.map → chunk-ZDCSFRIU.js.map} +0 -0
@@ -0,0 +1,130 @@
1
+ import assert from "node:assert/strict";
2
+ import test from "node:test";
3
+
4
+ import {
5
+ buildUnusableReplyDiagnostic,
6
+ formatUnusableReplyDiagnostic,
7
+ } from "./extraction-reply-diagnostic.js";
8
+
9
+ const SECRET = "SECRETVALUE-4821";
10
+
11
+ /**
12
+ * Builds and renders the diagnostic for `reply`, then asserts no sentinel
13
+ * substring appears anywhere in either form; `allowedKeys` lists the key names
14
+ * expected to survive, and any other extracted key fails the assert.
15
+ */
16
+ function assertNoContent(reply: string, sentinels: string[], allowedKeys: string[] = []): void {
17
+ const diag = buildUnusableReplyDiagnostic(reply, undefined, 0);
18
+ const rendered = `${JSON.stringify(diag)} ${formatUnusableReplyDiagnostic(diag)}`;
19
+ for (const sentinel of sentinels) assert.equal(rendered.includes(sentinel), false, `leaked ${sentinel}`);
20
+ assert.deepEqual(diag.topLevelKeys.filter((k) => !allowedKeys.includes(k)), []);
21
+ }
22
+
23
+ /** The most common failure mode: prose with no JSON. Pins that the whole reply is exactly one candidate and every rendered field is content-free. */
24
+ test("commentary: no braces, nothing parses (the whole reply is the one candidate the extractor tries)", () => {
25
+ const reply = `I read the conversation about ${SECRET} and have no durable facts to report.`;
26
+ assert.deepEqual(buildUnusableReplyDiagnostic(reply, "stop", 0), {
27
+ replyChars: reply.length,
28
+ finishReason: "stop",
29
+ startsWithBrace: false,
30
+ jsonCandidates: 1,
31
+ parsedAnyJson: false,
32
+ unrecognizedPayloads: 0,
33
+ topLevelKeys: [],
34
+ partialFacts: 0,
35
+ });
36
+ assertNoContent(reply, [SECRET, "durable facts", "conversation"]);
37
+ });
38
+
39
+ /** A refusal is textually indistinguishable from commentary; only the client-supplied finish reason lets an operator tell them apart. */
40
+ test("refusal: no JSON, finish reason carried", () => {
41
+ const reply = `I'm sorry, I can't help with ${SECRET}.`;
42
+ const diag = buildUnusableReplyDiagnostic(reply, "content_filter", 0);
43
+ assert.equal(diag.finishReason, "content_filter");
44
+ assert.equal(diag.parsedAnyJson, false);
45
+ assert.equal(diag.startsWithBrace, false);
46
+ assertNoContent(reply, [SECRET, "sorry"]);
47
+ });
48
+
49
+ /** Key names may be logged but values must never be: hostile key shapes are filtered and values are never read at all. */
50
+ test("valid JSON of the wrong shape: parsed, shape rejected, safe keys kept, hostile keys omitted", () => {
51
+ const long = "k".repeat(33);
52
+ const reply = JSON.stringify({ summary: SECRET, "user@example.com": 1, [long]: 2, "has space": 3, result_set: [SECRET] });
53
+ const diag = buildUnusableReplyDiagnostic(reply, "stop", 0);
54
+ assert.equal(diag.startsWithBrace, true);
55
+ assert.equal(diag.parsedAnyJson, true);
56
+ assert.ok(diag.unrecognizedPayloads >= 1);
57
+ assert.deepEqual(diag.topLevelKeys, ["summary", "result_set"]);
58
+ assertNoContent(reply, [SECRET, "user@example.com", long, "has space"], ["summary", "result_set"]);
59
+ });
60
+
61
+ /** Bounds the worst case so a model echoing many keys cannot bloat the warn line; keys come from the first parse so repeated runs stay stable. */
62
+ test("top-level keys are capped at 8 and come from the first parsed candidate", () => {
63
+ const first = Object.fromEntries(Array.from({ length: 12 }, (_, i) => [`key${i}`, i]));
64
+ const reply = `${JSON.stringify(first)}\n${JSON.stringify({ other: 1 })}`;
65
+ const diag = buildUnusableReplyDiagnostic(reply, undefined, 0);
66
+ assert.deepEqual(diag.topLevelKeys, ["key0", "key1", "key2", "key3", "key4", "key5", "key6", "key7"]);
67
+ });
68
+
69
+ /** Pins the parser treating a top-level array as keyless: index keys like "0" must not surface as if they were payload names. */
70
+ test("a JSON array parses but exposes no keys", () => {
71
+ const diag = buildUnusableReplyDiagnostic(`[{"a":"${SECRET}"}]`, undefined, 0);
72
+ assert.equal(diag.parsedAnyJson, true);
73
+ assert.deepEqual(diag.topLevelKeys, []);
74
+ assert.equal(diag.startsWithBrace, false);
75
+ });
76
+
77
+ /** The cut-off case from the issue: brace at position zero but nothing parseable, with partialFacts echoing what upstream salvage already recovered. */
78
+ test("truncated JSON: starts with a brace, never parses", () => {
79
+ const reply = `{"facts":[{"content":"${SECRET} is the`;
80
+ const diag = buildUnusableReplyDiagnostic(reply, "length", 2);
81
+ assert.equal(diag.startsWithBrace, true);
82
+ assert.equal(diag.parsedAnyJson, false);
83
+ assert.equal(diag.finishReason, "length");
84
+ assert.equal(diag.partialFacts, 2);
85
+ assert.deepEqual(diag.topLevelKeys, []);
86
+ assertNoContent(reply, [SECRET, "is the"]);
87
+ });
88
+
89
+ /** Zero state: the HTTP-refusal site builds this from an empty reply, so the line reads "no candidates tried" without implying a malformed one. */
90
+ test("empty reply", () => {
91
+ assert.deepEqual(buildUnusableReplyDiagnostic("", undefined, 0), {
92
+ replyChars: 0,
93
+ finishReason: undefined,
94
+ startsWithBrace: false,
95
+ jsonCandidates: 0,
96
+ parsedAnyJson: false,
97
+ unrecognizedPayloads: 0,
98
+ topLevelKeys: [],
99
+ partialFacts: 0,
100
+ });
101
+ });
102
+
103
+ /** Fenced JSON parses through the fence but starts with a backtick, so startsWithBrace stays false — the signature of "JSON arrived, wrapped". */
104
+ test("fenced json block of the wrong shape: parsed through the fence, content absent", () => {
105
+ const reply = "```json\n" + JSON.stringify({ note: SECRET }) + "\n```";
106
+ const diag = buildUnusableReplyDiagnostic(reply, "stop", 0);
107
+ assert.equal(diag.startsWithBrace, false);
108
+ assert.equal(diag.parsedAnyJson, true);
109
+ assert.ok(diag.unrecognizedPayloads >= 1);
110
+ assert.deepEqual(diag.topLevelKeys, ["note"]);
111
+ assertNoContent(reply, [SECRET], ["note"]);
112
+ });
113
+
114
+ /** finish_reason is untrusted wire data from the local server; only identifier-shaped values survive validation, everything else is omitted rather than logged. */
115
+ test("finish reason that is not identifier-shaped is omitted", () => {
116
+ for (const hostile of ["x y", "a".repeat(33), `${SECRET}!`]) {
117
+ assert.equal(buildUnusableReplyDiagnostic("hello", hostile, 0).finishReason, undefined);
118
+ }
119
+ });
120
+
121
+ /** Pins the exact rendering so log greps and parsers survive refactors of either module. */
122
+ test("rendered line has a stable greppable shape", () => {
123
+ const line = formatUnusableReplyDiagnostic(
124
+ buildUnusableReplyDiagnostic('{"answer":"x"}', "stop", 0),
125
+ );
126
+ assert.equal(
127
+ line,
128
+ "extractWithLocalLlm: unusable local reply replyChars=14 finishReason=stop startsWithBrace=true jsonCandidates=1 parsedAnyJson=true unrecognizedPayloads=1 topLevelKeys=answer partialFacts=0",
129
+ );
130
+ });
@@ -0,0 +1,105 @@
1
+ import { z } from "zod";
2
+
3
+ import { extractJsonCandidates } from "./json-extract.js";
4
+
5
+ const PAYLOAD_KEYS = ["facts", "entities", "profileUpdates", "questions", "relationships", "identityReflection"];
6
+ const SAFE_NAME = z.string().regex(/^[A-Za-z_][A-Za-z0-9_]{0,31}$/);
7
+ const JsonObject = z.record(z.string(), z.unknown());
8
+ const MAX_TOP_LEVEL_KEYS = 8;
9
+
10
+ export type JsonValue = z.infer<ReturnType<typeof z.json>>;
11
+
12
+ /** True when a parsed JSON value is an object carrying at least one extraction-result key. */
13
+ export function looksLikeExtractionResultPayload(parsed: JsonValue): boolean {
14
+ const object = JsonObject.safeParse(parsed);
15
+ return object.success && PAYLOAD_KEYS.some((key) => key in object.data);
16
+ }
17
+
18
+ /**
19
+ * Identifier-shaped top-level key names of a parsed object, in insertion order,
20
+ * capped at MAX_TOP_LEVEL_KEYS. Keys failing the identifier shape (emails,
21
+ * long strings, anything that could carry or point at content) are dropped, so
22
+ * the array is safe to log by construction.
23
+ */
24
+ function safeTopLevelKeys(parsed: JsonValue): string[] {
25
+ const object = JsonObject.safeParse(parsed);
26
+ const keys: string[] = [];
27
+ if (!object.success) return keys;
28
+ for (const key of Object.keys(object.data)) {
29
+ if (keys.length === MAX_TOP_LEVEL_KEYS) break;
30
+ if (SAFE_NAME.safeParse(key).success) keys.push(key);
31
+ }
32
+ return keys;
33
+ }
34
+
35
+ /**
36
+ * What an unusable local-LLM extraction reply looked like, without any of its
37
+ * content (the reply may hold user data). Every field is a count, a boolean, or
38
+ * an identifier-shaped name (`finishReason`, JSON key names); anything else is omitted.
39
+ */
40
+ export interface UnusableReplyDiagnostic {
41
+ replyChars: number;
42
+ finishReason: string | undefined;
43
+ startsWithBrace: boolean;
44
+ /** Candidates the extractor tried; the whole reply counts as one when non-empty. */
45
+ jsonCandidates: number;
46
+ parsedAnyJson: boolean;
47
+ /** Candidates that parsed as JSON but carry no extraction-result key. */
48
+ unrecognizedPayloads: number;
49
+ /** From the first candidate that parsed. */
50
+ topLevelKeys: string[];
51
+ partialFacts: number;
52
+ }
53
+
54
+ /** `content` is the trimmed reply; `finishReason` is whatever the client recorded (validated here). */
55
+ export function buildUnusableReplyDiagnostic(
56
+ content: string,
57
+ finishReason: string | undefined,
58
+ partialFacts: number,
59
+ ): UnusableReplyDiagnostic {
60
+ const candidates = extractJsonCandidates(content);
61
+ let parsedAnyJson = false;
62
+ let unrecognizedPayloads = 0;
63
+ let topLevelKeys: string[] = [];
64
+ for (const candidate of candidates) {
65
+ let parsed: JsonValue;
66
+ try {
67
+ parsed = JSON.parse(candidate);
68
+ } catch {
69
+ continue;
70
+ }
71
+ if (!parsedAnyJson) topLevelKeys = safeTopLevelKeys(parsed);
72
+ parsedAnyJson = true;
73
+ if (!looksLikeExtractionResultPayload(parsed)) unrecognizedPayloads++;
74
+ }
75
+ const reason = SAFE_NAME.safeParse(finishReason);
76
+ return {
77
+ replyChars: content.length,
78
+ finishReason: reason.success ? reason.data : undefined,
79
+ startsWithBrace: content.startsWith("{"),
80
+ jsonCandidates: candidates.length,
81
+ parsedAnyJson,
82
+ unrecognizedPayloads,
83
+ topLevelKeys,
84
+ partialFacts,
85
+ };
86
+ }
87
+
88
+ /**
89
+ * Render one greppable warn line from a diagnostic. Only reads fields already
90
+ * reduced to counts, booleans, and validated names, so reply content cannot
91
+ * reach the log through formatting.
92
+ */
93
+ export function formatUnusableReplyDiagnostic(d: UnusableReplyDiagnostic): string {
94
+ return [
95
+ "extractWithLocalLlm: unusable local reply",
96
+ `replyChars=${d.replyChars}`,
97
+ `finishReason=${d.finishReason ?? "none"}`,
98
+ `startsWithBrace=${d.startsWithBrace}`,
99
+ `jsonCandidates=${d.jsonCandidates}`,
100
+ `parsedAnyJson=${d.parsedAnyJson}`,
101
+ `unrecognizedPayloads=${d.unrecognizedPayloads}`,
102
+ `topLevelKeys=${d.topLevelKeys.join(",")}`,
103
+ `partialFacts=${d.partialFacts}`,
104
+ ].join(" ");
105
+ }
package/src/extraction.ts CHANGED
@@ -39,6 +39,7 @@ import { applyGroundingWithConnector, headerConnector, renderExtractionConversat
39
39
  import { isMemoryCategory } from "./write-envelope.js";
40
40
  export { classifyExtractionThrownError, classifyFallbackParseFailure, formatExtractionParseFailureLog } from "./extraction-error-classification.js";
41
41
  import { LocalLlmRejectedError, classifyExtractionThrownError, classifyFallbackParseFailure, formatExtractionParseFailureLog, localRejectionStatus, type LocalFailureDiag } from "./extraction-error-classification.js";
42
+ import { buildUnusableReplyDiagnostic, formatUnusableReplyDiagnostic, looksLikeExtractionResultPayload } from "./extraction-reply-diagnostic.js";
42
43
  import { AMBIENT_CAPTURE_PROMPT_SECTION_COMPACT, clampAmbientCaptureConfidence } from "./ambient-provenance.js";
43
44
  import {
44
45
  CONSOLIDATION_RESPONSE_SCHEMA,
@@ -275,20 +276,6 @@ export class ExtractionEngine {
275
276
  || (result.relationships?.length ?? 0) > 0;
276
277
  }
277
278
 
278
- private looksLikeExtractionResultPayload(parsed: any): boolean {
279
- return !!parsed &&
280
- typeof parsed === "object" &&
281
- !Array.isArray(parsed) &&
282
- (
283
- "facts" in parsed ||
284
- "entities" in parsed ||
285
- "profileUpdates" in parsed ||
286
- "questions" in parsed ||
287
- "relationships" in parsed ||
288
- "identityReflection" in parsed
289
- );
290
- }
291
-
292
279
  private normalizeExtractionResultPayload(parsed: any): ExtractionResult {
293
280
  const entities: ExtractedEntityResult[] = Array.isArray(parsed?.entities)
294
281
  ? parsed.entities
@@ -1515,7 +1502,10 @@ ${truncatedConversation}`;
1515
1502
  );
1516
1503
  if (!response?.content) {
1517
1504
  const rejected = localRejectionStatus(failureDiag);
1518
- if (rejected !== undefined) throw new LocalLlmRejectedError(rejected); // the endpoint is up and refuses this input
1505
+ if (rejected !== undefined) {
1506
+ log.warn(formatUnusableReplyDiagnostic(buildUnusableReplyDiagnostic("", failureDiag.finishReason, 0)));
1507
+ throw new LocalLlmRejectedError(rejected); // the endpoint is up and refuses this input
1508
+ }
1519
1509
  log.debug("extractWithLocalLlm: chatCompletion returned null or empty content");
1520
1510
  return null;
1521
1511
  }
@@ -1528,7 +1518,7 @@ ${truncatedConversation}`;
1528
1518
  try {
1529
1519
  log.debug(`extractWithLocalLlm: attempting JSON parse, candidate length=${candidate.length}`);
1530
1520
  const parsed = JSON.parse(candidate);
1531
- if (!this.looksLikeExtractionResultPayload(parsed)) {
1521
+ if (!looksLikeExtractionResultPayload(parsed)) {
1532
1522
  continue;
1533
1523
  }
1534
1524
 
@@ -1551,6 +1541,7 @@ ${truncatedConversation}`;
1551
1541
  log.debug(`extractWithLocalLlm: extracted ${partial.facts.length} partial facts from truncated JSON`);
1552
1542
  return partial;
1553
1543
  }
1544
+ log.warn(formatUnusableReplyDiagnostic(buildUnusableReplyDiagnostic(content, failureDiag.finishReason, partial.facts.length)));
1554
1545
  throw new LocalLlmRejectedError(); // the endpoint answered and nothing in the answer is usable
1555
1546
  }
1556
1547
 
@@ -12,7 +12,7 @@ import {
12
12
  } from "undici";
13
13
 
14
14
  import { LocalLlmClient } from "./local-llm.js";
15
- import { probeFetch } from "./local-llm-helpers.js";
15
+ import { probeFetch, type LocalLlmChatCompletionOptions } from "./local-llm-helpers.js";
16
16
  import { classifyAnalysisProviderError } from "./activity/timeline/analysis-provider.js";
17
17
  import { ChatTransport } from "./local-llm-transport.js";
18
18
  import { initLogger, resetLogger } from "./logger.js";
@@ -214,6 +214,29 @@ test("chat completion passes an undici dispatcher to fetch", async () => {
214
214
  }
215
215
  });
216
216
 
217
+ /** finish_reason must land on the failureDiag object the caller handed in, not only on the return value — the extraction diagnostic reads it there after a null or unusable reply. */
218
+ test("failureDiag carries the completion's finish_reason (issue #3387)", { concurrency: false }, async () => {
219
+ const original = globalThis.fetch;
220
+ // SAFETY: the stub satisfies the only fetch call this client makes.
221
+ globalThis.fetch = (async () =>
222
+ new Response(JSON.stringify({ choices: [{ message: { content: "partial" }, finish_reason: "length" }] }), {
223
+ status: 200,
224
+ headers: { "content-type": "application/json" },
225
+ })) as typeof fetch;
226
+ const client = new LocalLlmClient(createConfig());
227
+
228
+ try {
229
+ primeClient(client);
230
+ const options: LocalLlmChatCompletionOptions = { failureDiag: {} };
231
+ const result = await client.chatCompletion([{ role: "user", content: "test" }], options);
232
+ assert.equal(result?.content, "partial");
233
+ assert.equal(options.failureDiag?.finishReason, "length");
234
+ } finally {
235
+ globalThis.fetch = original;
236
+ await dispatcherOf(client).close();
237
+ }
238
+ });
239
+
217
240
  test("runtime honors a per-request dispatcher (regression canary for #2148)", async () => {
218
241
  // The fix assumes fetch applies `init.dispatcher`. If a future runtime
219
242
  // silently ignores it, the 300s cap returns with no other signal — so
@@ -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 };
26
+ failureDiag?: { lastError?: unknown; finishReason?: string };
27
27
  }
28
28
 
29
29
  export interface LocalLlmChatCompletionResult {
package/src/local-llm.ts CHANGED
@@ -1151,10 +1151,9 @@ export class LocalLlmClient {
1151
1151
  this.consecutive400s = 0;
1152
1152
  this.nativeSchemaGate.recordSuccess(requestBody, requestModel);
1153
1153
 
1154
+ // SAFETY: OpenAI-compatible wire format; every field is optional and read defensively below.
1154
1155
  const data = JSON.parse(responseBody) as {
1155
- choices?: Array<{
1156
- message?: { content?: string; reasoning_content?: string };
1157
- }>;
1156
+ choices?: Array<{ message?: { content?: string; reasoning_content?: string }; finish_reason?: string }>;
1158
1157
  usage?: {
1159
1158
  prompt_tokens?: number;
1160
1159
  completion_tokens?: number;
@@ -1170,6 +1169,7 @@ export class LocalLlmClient {
1170
1169
  // `reasoning_content` and leave `content` empty. Fall back to
1171
1170
  // reasoning_content so engram still gets a usable result.
1172
1171
  const msg = data.choices?.[0]?.message;
1172
+ if (options.failureDiag) options.failureDiag.finishReason = data.choices?.[0]?.finish_reason;
1173
1173
  const content = msg?.content || msg?.reasoning_content || "";
1174
1174
  if (!content) {
1175
1175
  log.warn(`local LLM returned empty content.${options.redactProviderErrors ? "" : ` choices=${JSON.stringify(data.choices)?.slice(0, 200)}`}`);
@@ -1029,15 +1029,19 @@ export class ExtractionRunCoordinator {
1029
1029
  bufferKey,
1030
1030
  isLiveSession: clearBufferAfterExtraction,
1031
1031
  });
1032
- if (recordedRetryFailure) {
1033
- log.debug("runExtraction: retaining buffer for backoff retry after failure");
1032
+ // Issue #3415: retention follows the actual extraction failure, not the
1033
+ // retry bookkeeping. With retry disabled no backoff state is recorded,
1034
+ // but the failed turns are still kept for the next attempt — clearing
1035
+ // them is silent loss. A successful empty result still clears below.
1036
+ if (extractionFailure) {
1037
+ log.debug("runExtraction: retaining buffer after failed extraction", { extractionFailure });
1034
1038
  } else {
1035
1039
  await clearBuffer();
1036
1040
  }
1037
1041
  if (!shouldPersistProcessedFingerprint) {
1038
1042
  await commitEmptySuccessExtraction(emptySuccessCommit);
1039
1043
  }
1040
- return emptyExtractionResult(recordedRetryFailure, result.extractionFailureClass);
1044
+ return emptyExtractionResult(Boolean(extractionFailure), result.extractionFailureClass);
1041
1045
  }
1042
1046
 
1043
1047
  let threadIdForExtraction: string | null = null;
@@ -1534,6 +1534,8 @@ test("runExtraction writes buffered turns to active scope profile write layer",
1534
1534
  ...makeTurn("pi-observer:abc123", "remember the team profile target"),
1535
1535
  persistProcessedFingerprint: true,
1536
1536
  };
1537
+ // SAFETY: runExtraction is driven only through the stub members assigned below;
1538
+ // the prototype harness leaves the rest of Orchestrator unreachable in this test.
1537
1539
  const orchestrator = Object.create(Orchestrator.prototype) as any;
1538
1540
  orchestrator.config = config;
1539
1541
  orchestrator.buffer = { clearAfterExtraction: async () => undefined };
@@ -1853,13 +1855,16 @@ test("runExtraction does not persist processed fingerprints for failed empty ext
1853
1855
  assert.deepEqual(meta.processedExtractionFingerprints, []);
1854
1856
  });
1855
1857
 
1856
- test("runExtraction clears the buffer on a failed extraction when extractionRetryEnabled=false (behavior parity)", async () => {
1857
- // With retry disabled the failure path must match pre-#1908 behavior: the
1858
- // buffer is cleared (no retry state is recorded, so there is nothing to retain).
1858
+ test("runExtraction retains the buffer on a failed extraction when extractionRetryEnabled=false (issue #3415)", async () => {
1859
+ // Retention follows the actual extraction failure, not the retry bookkeeping:
1860
+ // with retry disabled no retry state is recorded, but the turns must still
1861
+ // be kept for the next attempt. Dropped turns are silent loss.
1859
1862
  const config = parseConfig({ extractionRetryEnabled: false });
1860
1863
  config.extractionMinChars = 0;
1861
1864
  config.extractionMinUserTurns = 1;
1862
1865
  let clearCalls = 0;
1866
+ // SAFETY: runExtraction is driven only through the stub members assigned below;
1867
+ // the prototype harness leaves the rest of Orchestrator unreachable in this test.
1863
1868
  const orchestrator = Object.create(Orchestrator.prototype) as any;
1864
1869
  orchestrator.config = config;
1865
1870
  orchestrator.buffer = { clearAfterExtraction: async () => { clearCalls += 1; } };
@@ -1878,7 +1883,68 @@ test("runExtraction clears the buffer on a failed extraction when extractionRetr
1878
1883
  const result = await orchestrator.runExtraction(turns, { bufferKey: "logical-thread:retry-off" });
1879
1884
  assert.equal(result.status, "skipped");
1880
1885
  assert.equal(result.reason, "empty_extraction_result");
1881
- assert.equal(clearCalls, 1, "retry disabled → buffer cleared (pre-#1908 behavior)");
1886
+ assert.equal(clearCalls, 0, "failed extraction retains the buffer even with retry disabled");
1887
+ assert.equal(result.retainedBuffer, true);
1888
+ assert.equal(result.failureClass, "provider_retryable");
1889
+ });
1890
+
1891
+ test("runExtraction retains the buffer on a parse_empty failure when extractionRetryEnabled=false (issue #3415)", async () => {
1892
+ const config = parseConfig({ extractionRetryEnabled: false });
1893
+ config.extractionMinChars = 0;
1894
+ config.extractionMinUserTurns = 1;
1895
+ let clearCalls = 0;
1896
+ // SAFETY: runExtraction is driven only through the stub members assigned below;
1897
+ // the prototype harness leaves the rest of Orchestrator unreachable in this test.
1898
+ const orchestrator = Object.create(Orchestrator.prototype) as any;
1899
+ orchestrator.config = config;
1900
+ orchestrator.buffer = { clearAfterExtraction: async () => { clearCalls += 1; } };
1901
+ orchestrator.storageRouter = {
1902
+ storageFor: async () => withMetaSeam({
1903
+ listEntityNames: async () => [],
1904
+ loadMeta: async () => ({ extractionCount: 0, lastExtractionAt: null, lastConsolidationAt: null, totalMemories: 0, totalEntities: 0, processedExtractionFingerprints: [] }),
1905
+ saveMeta: async () => {},
1906
+ }),
1907
+ };
1908
+ orchestrator.extraction = {
1909
+ extract: async () => ({ facts: [], entities: [], questions: [], profileUpdates: [], extractionFailure: "local_llm_unusable", extractionFailureClass: "parse_empty" }),
1910
+ };
1911
+ stubPersistExtraction(orchestrator);
1912
+ const turns = [{ ...makeTurn("session-retry-off-empty", "unparseable reply"), logicalSessionKey: "logical-thread:retry-off-empty", turnFingerprint: "fp-retry-off-empty", persistProcessedFingerprint: true }];
1913
+ const result = await orchestrator.runExtraction(turns, { bufferKey: "logical-thread:retry-off-empty" });
1914
+ assert.equal(result.status, "skipped");
1915
+ assert.equal(result.reason, "empty_extraction_result");
1916
+ assert.equal(clearCalls, 0);
1917
+ assert.equal(result.retainedBuffer, true);
1918
+ assert.equal(result.failureClass, "parse_empty");
1919
+ });
1920
+
1921
+ test("runExtraction still clears the buffer on a successful empty extraction when extractionRetryEnabled=false", async () => {
1922
+ const config = parseConfig({ extractionRetryEnabled: false });
1923
+ config.extractionMinChars = 0;
1924
+ config.extractionMinUserTurns = 1;
1925
+ let clearCalls = 0;
1926
+ // SAFETY: runExtraction is driven only through the stub members assigned below;
1927
+ // the prototype harness leaves the rest of Orchestrator unreachable in this test.
1928
+ const orchestrator = Object.create(Orchestrator.prototype) as any;
1929
+ orchestrator.config = config;
1930
+ orchestrator.buffer = { clearAfterExtraction: async () => { clearCalls += 1; } };
1931
+ orchestrator.storageRouter = {
1932
+ storageFor: async () => withMetaSeam({
1933
+ listEntityNames: async () => [],
1934
+ loadMeta: async () => ({ extractionCount: 0, lastExtractionAt: null, lastConsolidationAt: null, totalMemories: 0, totalEntities: 0, processedExtractionFingerprints: [] }),
1935
+ saveMeta: async () => {},
1936
+ }),
1937
+ };
1938
+ orchestrator.extraction = {
1939
+ extract: async () => ({ facts: [], entities: [], questions: [], profileUpdates: [] }),
1940
+ };
1941
+ stubPersistExtraction(orchestrator);
1942
+ const turns = [{ ...makeTurn("session-retry-off-ok", "nothing to remember"), logicalSessionKey: "logical-thread:retry-off-ok", turnFingerprint: "fp-retry-off-ok", persistProcessedFingerprint: true }];
1943
+ const result = await orchestrator.runExtraction(turns, { bufferKey: "logical-thread:retry-off-ok" });
1944
+ assert.equal(result.status, "skipped");
1945
+ assert.equal(result.reason, "empty_extraction_result");
1946
+ assert.equal(clearCalls, 1, "a successful empty extraction still clears the buffer");
1947
+ assert.equal(result.retainedBuffer, undefined);
1882
1948
  });
1883
1949
 
1884
1950
  test("runExtraction retains buffers and keeps in-memory backoff when the meta lock is unavailable", async () => {
@@ -1894,6 +1960,8 @@ test("runExtraction retains buffers and keeps in-memory backoff when the meta lo
1894
1960
  let updateMetaCalls = 0;
1895
1961
  // SAFETY: runExtraction is driven only through the stub members assigned below;
1896
1962
  // the prototype harness leaves the rest of Orchestrator unreachable in this test.
1963
+ // SAFETY: runExtraction is driven only through the stub members assigned below;
1964
+ // the prototype harness leaves the rest of Orchestrator unreachable in this test.
1897
1965
  const orchestrator = Object.create(Orchestrator.prototype) as any;
1898
1966
  orchestrator.config = config;
1899
1967
  orchestrator.buffer = { clearAfterExtraction: async () => { clearCalls += 1; } };
package/src/types.ts CHANGED
@@ -722,6 +722,8 @@ export interface PluginConfig
722
722
  bufferMaxTurns: number;
723
723
  /** Distinct sessions the extraction buffer admits before backpressure (#3303). */
724
724
  bufferMaxSessions: number;
725
+ /** Retained turns admitted per session before live backpressure (#3415 bound). */
726
+ bufferMaxTurnsPerSession: number;
725
727
  bufferMaxMinutes: number;
726
728
  /** Queue depth cap; default 1 = serial queue, same-buffer tasks never overlap. Applies at daemon start. */
727
729
  extractionQueueConcurrency: number;