@remnic/core 10.0.161 → 10.0.163

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 (246) hide show
  1. package/dist/access-admin-ops-surface.js +68 -68
  2. package/dist/access-cli.js +68 -68
  3. package/dist/access-extraction-force-flush-preempt.js +68 -68
  4. package/dist/access-extraction-force-flush.js +68 -68
  5. package/dist/access-http-briefing.js +68 -68
  6. package/dist/access-http-query.js +68 -68
  7. package/dist/access-http.js +68 -68
  8. package/dist/access-identity-continuity-surface.js +68 -68
  9. package/dist/access-lcm-surface.js +68 -68
  10. package/dist/access-mcp.js +68 -68
  11. package/dist/access-observe-write-category.js +5 -5
  12. package/dist/access-observe-write-surface.js +68 -68
  13. package/dist/access-operations-batch.js +68 -68
  14. package/dist/access-operations.js +68 -68
  15. package/dist/access-recall-concurrency.js +68 -68
  16. package/dist/access-recall-diagnostics.js +2 -2
  17. package/dist/access-recall-response.js +68 -68
  18. package/dist/access-recall-surface.js +68 -68
  19. package/dist/access-schema.js +4 -4
  20. package/dist/access-service.js +68 -68
  21. package/dist/active-recall.js +10 -10
  22. package/dist/briefing.js +9 -9
  23. package/dist/buffer.js +2 -2
  24. package/dist/{capsule-crypto-YO5QJ6L3.js → capsule-crypto-GWVG7LGC.js} +2 -2
  25. package/dist/causal-consolidation.js +10 -10
  26. package/dist/{chunk-HIPHLFIQ.js → chunk-22VXXA67.js} +2 -2
  27. package/dist/{chunk-IFFCHE3O.js → chunk-2S3M2GLC.js} +8 -2
  28. package/dist/{chunk-IFFCHE3O.js.map → chunk-2S3M2GLC.js.map} +1 -1
  29. package/dist/{chunk-VGCK2RV3.js → chunk-3QLAOYBL.js} +2 -2
  30. package/dist/{chunk-6NPLVV6M.js → chunk-4HKK5HUI.js} +2 -2
  31. package/dist/{chunk-XTAGZXOM.js → chunk-4LPTSB5V.js} +2 -2
  32. package/dist/{chunk-HKOGDSNS.js → chunk-4NBUHYUV.js} +2 -2
  33. package/dist/{chunk-VVVFT435.js → chunk-5D4NBANY.js} +5 -5
  34. package/dist/{chunk-VVVFT435.js.map → chunk-5D4NBANY.js.map} +1 -1
  35. package/dist/{chunk-K3KSTSGM.js → chunk-5LTXYM7D.js} +2 -2
  36. package/dist/{chunk-M7BCA43N.js → chunk-5MXKS25U.js} +5 -5
  37. package/dist/{chunk-KTZNXQWL.js → chunk-6ARSFTLD.js} +2 -2
  38. package/dist/{chunk-773QSFFN.js → chunk-6TPWIPE3.js} +2 -2
  39. package/dist/{chunk-L2DACC2T.js → chunk-ARJ3KCX4.js} +2 -2
  40. package/dist/{chunk-6PVS6JET.js → chunk-AU6AEUFD.js} +2 -2
  41. package/dist/{chunk-R45L4TV6.js → chunk-BUKK5SWA.js} +6 -6
  42. package/dist/{chunk-JUYTXFDV.js → chunk-CGOPDXLK.js} +2 -2
  43. package/dist/{chunk-TGH7AU5U.js → chunk-DBVSU3HE.js} +8 -8
  44. package/dist/{chunk-3UKPFFMS.js → chunk-E5RJPLNL.js} +2 -2
  45. package/dist/{chunk-TLJV42SZ.js → chunk-EDA6CDBT.js} +2 -2
  46. package/dist/{chunk-ZWSSUWKO.js → chunk-EI2M2CFJ.js} +2 -2
  47. package/dist/{chunk-V24YLFJW.js → chunk-FNV6ZPCY.js} +6 -4
  48. package/dist/chunk-FNV6ZPCY.js.map +1 -0
  49. package/dist/{chunk-BDFOBNLX.js → chunk-FSI45NUK.js} +2 -2
  50. package/dist/{chunk-BFJQBCDL.js → chunk-GDAFI6HH.js} +239 -156
  51. package/dist/chunk-GDAFI6HH.js.map +1 -0
  52. package/dist/{chunk-DFK6AQWM.js → chunk-IC35ZYLM.js} +2 -2
  53. package/dist/{chunk-PJFSSXXY.js → chunk-JJEQRSYU.js} +2 -2
  54. package/dist/{chunk-5UE45DLK.js → chunk-JVIWVJ2A.js} +2 -2
  55. package/dist/{chunk-BNQJKWWZ.js → chunk-K3FH3LAQ.js} +4 -4
  56. package/dist/{chunk-UADAXWUJ.js → chunk-KR6PEAM4.js} +7 -7
  57. package/dist/{chunk-YKAQKIPR.js → chunk-L6BLTV4D.js} +2 -2
  58. package/dist/{chunk-2YJYBAR3.js → chunk-OAGTKS73.js} +2 -2
  59. package/dist/{chunk-BXLOS5AJ.js → chunk-OWHERGF2.js} +2 -2
  60. package/dist/{chunk-CA7XVRHZ.js → chunk-PCUDFWX5.js} +2 -2
  61. package/dist/{chunk-I6IKSDUO.js → chunk-PRE7R3RQ.js} +2 -2
  62. package/dist/{chunk-MWEJL436.js → chunk-QBREZ4QL.js} +2 -2
  63. package/dist/{chunk-TFA6HPOA.js → chunk-QCP75JGO.js} +5 -5
  64. package/dist/{chunk-MZETCZJF.js → chunk-QFPNWSVH.js} +5 -5
  65. package/dist/{chunk-52EM4UQU.js → chunk-QUC4S2D2.js} +10 -9
  66. package/dist/chunk-QUC4S2D2.js.map +1 -0
  67. package/dist/{chunk-7PCWJZXG.js → chunk-RDO6AMDL.js} +2 -2
  68. package/dist/{chunk-QDY4TSKK.js → chunk-RH6XWXMA.js} +3 -3
  69. package/dist/{chunk-BT5TAOXG.js → chunk-SBU5GDOT.js} +3 -3
  70. package/dist/{chunk-KJ3Z7JHF.js → chunk-SOGOHLWN.js} +1 -1
  71. package/dist/chunk-SOGOHLWN.js.map +1 -0
  72. package/dist/{chunk-TBOCVPXL.js → chunk-SRN5M4LQ.js} +3 -3
  73. package/dist/{chunk-NBHMEYM4.js → chunk-TFNZXOXK.js} +2 -2
  74. package/dist/{chunk-O7CHKXSF.js → chunk-UGQEJWR3.js} +2 -2
  75. package/dist/{chunk-DQEMWVMT.js → chunk-UVYI6VIX.js} +1 -1
  76. package/dist/{chunk-H6OTEBPK.js → chunk-V6M6N3EE.js} +2 -2
  77. package/dist/{chunk-AQ6GV5MU.js → chunk-VXMWTRQX.js} +2 -2
  78. package/dist/{chunk-PCCNK3RX.js → chunk-VXUO5JZC.js} +11 -13
  79. package/dist/chunk-VXUO5JZC.js.map +1 -0
  80. package/dist/{chunk-UR6COSJN.js → chunk-WAJL65KW.js} +3 -3
  81. package/dist/{chunk-V3D2OOVE.js → chunk-WRAK5LLB.js} +2 -2
  82. package/dist/{chunk-BTCZVBV3.js → chunk-XE4UYWW3.js} +3 -3
  83. package/dist/{chunk-VXKPZ6BO.js → chunk-Y7HLGKKU.js} +2 -2
  84. package/dist/{chunk-YAFMWQRL.js → chunk-YMC4AYJK.js} +4 -4
  85. package/dist/chunk-YMC4AYJK.js.map +1 -0
  86. package/dist/{chunk-B7F2G57I.js → chunk-YWPCDR3I.js} +2 -2
  87. package/dist/{chunk-NFTFMMKT.js → chunk-Z3SXC3MP.js} +2 -2
  88. package/dist/{chunk-DS24H6M4.js → chunk-ZRLTQ2Y7.js} +2 -2
  89. package/dist/cli.js +68 -68
  90. package/dist/coding/export-okf-codegraph.js +8 -8
  91. package/dist/compounding/engine.js +10 -10
  92. package/dist/config.js +10 -10
  93. package/dist/connectors/codex-materialize-runner.js +9 -9
  94. package/dist/connectors/index.js +9 -9
  95. package/dist/convergence-refresh.js +11 -11
  96. package/dist/conversation-index/backend.js +2 -2
  97. package/dist/corpus-watermark.js +11 -11
  98. package/dist/deep-recall-http-glue.js +5 -5
  99. package/dist/entity-retrieval.js +9 -9
  100. package/dist/explicit-capture.js +68 -68
  101. package/dist/extraction-error-classification.d.ts +11 -2
  102. package/dist/extraction-error-classification.d.ts.map +1 -1
  103. package/dist/extraction-error-classification.js +3 -1
  104. package/dist/extraction-reply-diagnostic.d.ts +4 -2
  105. package/dist/extraction-reply-diagnostic.d.ts.map +1 -1
  106. package/dist/extraction-reply-diagnostic.js +1 -1
  107. package/dist/extraction.js +14 -14
  108. package/dist/harmonic-retrieval.js +9 -9
  109. package/dist/index.js +74 -74
  110. package/dist/lcm/engine.js +2 -2
  111. package/dist/lcm/index.js +2 -2
  112. package/dist/location/index.js +10 -10
  113. package/dist/maintenance/memory-governance.js +9 -9
  114. package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +9 -9
  115. package/dist/maintenance/rebuild-memory-projection-runner.js +11 -11
  116. package/dist/maintenance/rebuild-memory-projection.js +10 -10
  117. package/dist/namespaces/migrate.js +10 -10
  118. package/dist/namespaces/search.js +6 -6
  119. package/dist/namespaces/storage.js +9 -9
  120. package/dist/operator-doctor-corpus.js +12 -12
  121. package/dist/operator-toolkit.js +17 -17
  122. package/dist/orchestration/backlog-scheduler.js +69 -69
  123. package/dist/orchestration/buffer-drain-runner.js +69 -69
  124. package/dist/orchestration/extraction-drain.d.ts.map +1 -1
  125. package/dist/orchestration/extraction-run-helpers.d.ts +7 -0
  126. package/dist/orchestration/extraction-run-helpers.d.ts.map +1 -1
  127. package/dist/orchestration/extraction-run.d.ts.map +1 -1
  128. package/dist/orchestration/maintenance.js +17 -17
  129. package/dist/orchestration/orchestrator-init.d.ts +28 -1
  130. package/dist/orchestration/orchestrator-init.d.ts.map +1 -1
  131. package/dist/orchestrator.d.ts +13 -9
  132. package/dist/orchestrator.d.ts.map +1 -1
  133. package/dist/orchestrator.js +68 -68
  134. package/dist/recall-explain-renderer.js +3 -3
  135. package/dist/recall-navigate-access.js +2 -2
  136. package/dist/recall-navigate-disclosure.js +2 -2
  137. package/dist/recall-navigate.js +2 -2
  138. package/dist/recall-navigation.js +68 -68
  139. package/dist/recall-xray-cli.js +4 -4
  140. package/dist/recall-xray-renderer.js +3 -3
  141. package/dist/recall-xray.js +2 -2
  142. package/dist/resume-bundles.js +11 -11
  143. package/dist/search/factory.js +5 -5
  144. package/dist/search/index.js +9 -9
  145. package/dist/semantic-consolidation.js +10 -10
  146. package/dist/semantic-rule-promotion.js +9 -9
  147. package/dist/semantic-rule-verifier.js +9 -9
  148. package/dist/source-agent-qualifier.js +11 -11
  149. package/dist/standup/build.js +9 -9
  150. package/dist/storage.js +8 -8
  151. package/dist/transfer/autodetect.js +1 -1
  152. package/dist/transfer/backup.js +2 -2
  153. package/dist/transfer/capsule-export.js +3 -3
  154. package/dist/transfer/capsule-import.js +2 -2
  155. package/dist/transfer/export-okf.js +9 -9
  156. package/dist/types-extraction-failure.d.ts +12 -0
  157. package/dist/types-extraction-failure.d.ts.map +1 -0
  158. package/dist/types-extraction-failure.js +1 -0
  159. package/dist/types-extraction-failure.js.map +1 -0
  160. package/dist/types.d.ts +3 -9
  161. package/dist/types.d.ts.map +1 -1
  162. package/dist/types.js +1 -1
  163. package/dist/verified-recall.js +9 -9
  164. package/dist/who-knows-cli.js +10 -10
  165. package/dist/who-knows.js +9 -9
  166. package/package.json +2 -2
  167. package/src/access-observe-replay-durability.test.ts +23 -3
  168. package/src/buffer-admission-idempotency.test.ts +1 -1
  169. package/src/buffer-ingress-invariant.test.ts +1 -1
  170. package/src/config.test.ts +3 -2
  171. package/src/config.ts +1 -1
  172. package/src/extraction-error-classification.ts +13 -2
  173. package/src/extraction-queue-concurrency-default.test.ts +107 -0
  174. package/src/extraction-reply-diagnostic-wiring.test.ts +4 -4
  175. package/src/extraction-reply-diagnostic.test.ts +3 -1
  176. package/src/extraction-reply-diagnostic.ts +9 -1
  177. package/src/extraction.ts +6 -6
  178. package/src/orchestration/extraction-drain-parts.test.ts +33 -0
  179. package/src/orchestration/extraction-drain.ts +7 -1
  180. package/src/orchestration/extraction-queue-coordinator.ts +1 -1
  181. package/src/orchestration/extraction-run-helpers.ts +14 -0
  182. package/src/orchestration/extraction-run.test.ts +28 -5
  183. package/src/orchestration/extraction-run.ts +11 -13
  184. package/src/orchestration/orchestrator-init.ts +259 -111
  185. package/src/orchestrator-extraction-queue.test.ts +3 -3
  186. package/src/orchestrator-flush.test.ts +43 -34
  187. package/src/orchestrator-init.test.ts +66 -3
  188. package/src/orchestrator-startup-ready-path.test.ts +506 -0
  189. package/src/orchestrator.ts +18 -9
  190. package/src/storage.ts +1 -1
  191. package/src/types-extraction-failure.ts +11 -0
  192. package/src/types.ts +3 -9
  193. package/dist/chunk-52EM4UQU.js.map +0 -1
  194. package/dist/chunk-BFJQBCDL.js.map +0 -1
  195. package/dist/chunk-KJ3Z7JHF.js.map +0 -1
  196. package/dist/chunk-PCCNK3RX.js.map +0 -1
  197. package/dist/chunk-V24YLFJW.js.map +0 -1
  198. package/dist/chunk-YAFMWQRL.js.map +0 -1
  199. /package/dist/{capsule-crypto-YO5QJ6L3.js.map → capsule-crypto-GWVG7LGC.js.map} +0 -0
  200. /package/dist/{chunk-HIPHLFIQ.js.map → chunk-22VXXA67.js.map} +0 -0
  201. /package/dist/{chunk-VGCK2RV3.js.map → chunk-3QLAOYBL.js.map} +0 -0
  202. /package/dist/{chunk-6NPLVV6M.js.map → chunk-4HKK5HUI.js.map} +0 -0
  203. /package/dist/{chunk-XTAGZXOM.js.map → chunk-4LPTSB5V.js.map} +0 -0
  204. /package/dist/{chunk-HKOGDSNS.js.map → chunk-4NBUHYUV.js.map} +0 -0
  205. /package/dist/{chunk-K3KSTSGM.js.map → chunk-5LTXYM7D.js.map} +0 -0
  206. /package/dist/{chunk-M7BCA43N.js.map → chunk-5MXKS25U.js.map} +0 -0
  207. /package/dist/{chunk-KTZNXQWL.js.map → chunk-6ARSFTLD.js.map} +0 -0
  208. /package/dist/{chunk-773QSFFN.js.map → chunk-6TPWIPE3.js.map} +0 -0
  209. /package/dist/{chunk-L2DACC2T.js.map → chunk-ARJ3KCX4.js.map} +0 -0
  210. /package/dist/{chunk-6PVS6JET.js.map → chunk-AU6AEUFD.js.map} +0 -0
  211. /package/dist/{chunk-R45L4TV6.js.map → chunk-BUKK5SWA.js.map} +0 -0
  212. /package/dist/{chunk-JUYTXFDV.js.map → chunk-CGOPDXLK.js.map} +0 -0
  213. /package/dist/{chunk-TGH7AU5U.js.map → chunk-DBVSU3HE.js.map} +0 -0
  214. /package/dist/{chunk-3UKPFFMS.js.map → chunk-E5RJPLNL.js.map} +0 -0
  215. /package/dist/{chunk-TLJV42SZ.js.map → chunk-EDA6CDBT.js.map} +0 -0
  216. /package/dist/{chunk-ZWSSUWKO.js.map → chunk-EI2M2CFJ.js.map} +0 -0
  217. /package/dist/{chunk-BDFOBNLX.js.map → chunk-FSI45NUK.js.map} +0 -0
  218. /package/dist/{chunk-DFK6AQWM.js.map → chunk-IC35ZYLM.js.map} +0 -0
  219. /package/dist/{chunk-PJFSSXXY.js.map → chunk-JJEQRSYU.js.map} +0 -0
  220. /package/dist/{chunk-5UE45DLK.js.map → chunk-JVIWVJ2A.js.map} +0 -0
  221. /package/dist/{chunk-BNQJKWWZ.js.map → chunk-K3FH3LAQ.js.map} +0 -0
  222. /package/dist/{chunk-UADAXWUJ.js.map → chunk-KR6PEAM4.js.map} +0 -0
  223. /package/dist/{chunk-YKAQKIPR.js.map → chunk-L6BLTV4D.js.map} +0 -0
  224. /package/dist/{chunk-2YJYBAR3.js.map → chunk-OAGTKS73.js.map} +0 -0
  225. /package/dist/{chunk-BXLOS5AJ.js.map → chunk-OWHERGF2.js.map} +0 -0
  226. /package/dist/{chunk-CA7XVRHZ.js.map → chunk-PCUDFWX5.js.map} +0 -0
  227. /package/dist/{chunk-I6IKSDUO.js.map → chunk-PRE7R3RQ.js.map} +0 -0
  228. /package/dist/{chunk-MWEJL436.js.map → chunk-QBREZ4QL.js.map} +0 -0
  229. /package/dist/{chunk-TFA6HPOA.js.map → chunk-QCP75JGO.js.map} +0 -0
  230. /package/dist/{chunk-MZETCZJF.js.map → chunk-QFPNWSVH.js.map} +0 -0
  231. /package/dist/{chunk-7PCWJZXG.js.map → chunk-RDO6AMDL.js.map} +0 -0
  232. /package/dist/{chunk-QDY4TSKK.js.map → chunk-RH6XWXMA.js.map} +0 -0
  233. /package/dist/{chunk-BT5TAOXG.js.map → chunk-SBU5GDOT.js.map} +0 -0
  234. /package/dist/{chunk-TBOCVPXL.js.map → chunk-SRN5M4LQ.js.map} +0 -0
  235. /package/dist/{chunk-NBHMEYM4.js.map → chunk-TFNZXOXK.js.map} +0 -0
  236. /package/dist/{chunk-O7CHKXSF.js.map → chunk-UGQEJWR3.js.map} +0 -0
  237. /package/dist/{chunk-DQEMWVMT.js.map → chunk-UVYI6VIX.js.map} +0 -0
  238. /package/dist/{chunk-H6OTEBPK.js.map → chunk-V6M6N3EE.js.map} +0 -0
  239. /package/dist/{chunk-AQ6GV5MU.js.map → chunk-VXMWTRQX.js.map} +0 -0
  240. /package/dist/{chunk-UR6COSJN.js.map → chunk-WAJL65KW.js.map} +0 -0
  241. /package/dist/{chunk-V3D2OOVE.js.map → chunk-WRAK5LLB.js.map} +0 -0
  242. /package/dist/{chunk-BTCZVBV3.js.map → chunk-XE4UYWW3.js.map} +0 -0
  243. /package/dist/{chunk-VXKPZ6BO.js.map → chunk-Y7HLGKKU.js.map} +0 -0
  244. /package/dist/{chunk-B7F2G57I.js.map → chunk-YWPCDR3I.js.map} +0 -0
  245. /package/dist/{chunk-NFTFMMKT.js.map → chunk-Z3SXC3MP.js.map} +0 -0
  246. /package/dist/{chunk-DS24H6M4.js.map → chunk-ZRLTQ2Y7.js.map} +0 -0
@@ -88,16 +88,27 @@ export function formatExtractionParseFailureLog(input: {
88
88
 
89
89
  /**
90
90
  * The local endpoint answered, and what it said rejects this input (unusable content, or a client error that is not
91
- * auth, timeout or rate limiting): the chunk's problem, not an outage. Retried like an empty parse, and a trigger-drain
91
+ * auth, timeout or rate limiting): the chunk's problem, not an outage. A `finish_reason=length` reply classifies as
92
+ * `output_truncated` (#3521); every other rejection retries like an empty parse, and a trigger-drain
92
93
  * chunk that keeps drawing it is dropped after its recovery copy is saved.
93
94
  */
94
95
  export class LocalLlmRejectedError extends Error {
95
- constructor(readonly httpStatus?: number) {
96
+ constructor(readonly httpStatus?: number, readonly finishReason?: string) {
96
97
  super(httpStatus === undefined ? "local LLM answered with unusable content" : `local LLM rejected the input (HTTP ${httpStatus})`);
97
98
  this.name = "LocalLlmRejectedError";
98
99
  }
99
100
  }
100
101
 
102
+ /**
103
+ * Map a local-endpoint rejection to its failure class: a reply cut off at the
104
+ * output ceiling (`finish_reason=length`) is `output_truncated` — retries at
105
+ * the same `maxOutputTokens` can never complete (#3521). Every other unusable
106
+ * or refused reply stays `parse_empty`.
107
+ */
108
+ export function classifyLocalLlmRejected(err: LocalLlmRejectedError): ExtractionFailureClass {
109
+ return err.finishReason === "length" ? "output_truncated" : "parse_empty";
110
+ }
111
+
101
112
  /** What the local client recorded about a failed call (`failureDiag`). */
102
113
  export interface LocalFailureDiag {
103
114
  lastError?: unknown;
@@ -0,0 +1,107 @@
1
+ import assert from "node:assert/strict";
2
+ import test from "node:test";
3
+
4
+ import { parseConfig } from "./config.js";
5
+ import {
6
+ ExtractionQueueCoordinator,
7
+ type ExtractionQueueTask,
8
+ } from "./orchestration/extraction-queue-coordinator.js";
9
+
10
+ /**
11
+ * Bounded-concurrency default regressions: the extraction queue ships
12
+ * bounded-parallel instead of serial, an explicit operator value — including
13
+ * a deployed serial `1` — always wins over the default, and the default
14
+ * limit still serializes work sharing a session key.
15
+ */
16
+
17
+ /** Parked queue task with deterministic start/release handles. */
18
+ function makeParkedTask() {
19
+ const started = Promise.withResolvers<void>();
20
+ const release = Promise.withResolvers<void>();
21
+ let didStart = false;
22
+ const task: ExtractionQueueTask = async () => {
23
+ didStart = true;
24
+ started.resolve();
25
+ await release.promise;
26
+ };
27
+ return {
28
+ task,
29
+ startedPromise: started.promise,
30
+ release: () => release.resolve(),
31
+ get started() {
32
+ return didStart;
33
+ },
34
+ };
35
+ }
36
+
37
+ async function startedWithin(promise: Promise<void>, timeoutMs = 1_000): Promise<boolean> {
38
+ const result = Promise.withResolvers<boolean>();
39
+ const timeout = setTimeout(() => result.resolve(false), timeoutMs);
40
+ void promise.then(() => result.resolve(true));
41
+ try {
42
+ return await result.promise;
43
+ } finally {
44
+ clearTimeout(timeout);
45
+ }
46
+ }
47
+
48
+ test("parseConfig: extractionQueueConcurrency defaults to bounded-parallel 2", () => {
49
+ assert.equal(parseConfig({}).extractionQueueConcurrency, 2);
50
+ });
51
+
52
+ test("parseConfig: an explicit operator value wins over the default (serial 1 stays serial)", () => {
53
+ assert.equal(parseConfig({ extractionQueueConcurrency: 1 }).extractionQueueConcurrency, 1);
54
+ assert.equal(parseConfig({ extractionQueueConcurrency: 4 }).extractionQueueConcurrency, 4);
55
+ for (const invalid of [0, -1, 1.5, "two"]) {
56
+ assert.throws(
57
+ () => parseConfig({ extractionQueueConcurrency: invalid }),
58
+ /extractionQueueConcurrency must be a positive integer/,
59
+ `expected rejection for ${JSON.stringify(invalid)}`,
60
+ );
61
+ }
62
+ });
63
+
64
+ test("default coordinator limit is 2", () => {
65
+ assert.equal(new ExtractionQueueCoordinator().maxConcurrency, 2);
66
+ });
67
+
68
+ test("default coordinator runs two distinct sessions concurrently, not three", async () => {
69
+ const coordinator = new ExtractionQueueCoordinator();
70
+ const first = makeParkedTask();
71
+ const second = makeParkedTask();
72
+ const third = makeParkedTask();
73
+ coordinator.enqueue(first.task, { key: "session-a" });
74
+ coordinator.enqueue(second.task, { key: "session-b" });
75
+ coordinator.enqueue(third.task, { key: "session-c" });
76
+ try {
77
+ assert.equal(await startedWithin(first.startedPromise), true, "first session should start");
78
+ assert.equal(await startedWithin(second.startedPromise), true, "second session should start in parallel");
79
+ assert.equal(third.started, false, "the third task must stay queued: the default limit is 2, not unbounded");
80
+ first.release();
81
+ assert.equal(await startedWithin(third.startedPromise), true, "a freed slot should start the third task");
82
+ } finally {
83
+ first.release();
84
+ second.release();
85
+ third.release();
86
+ assert.equal(await coordinator.waitForIdle(5_000), true);
87
+ }
88
+ assert.equal(coordinator.isProcessing, false);
89
+ });
90
+
91
+ test("default coordinator still serializes tasks sharing a session key", async () => {
92
+ const coordinator = new ExtractionQueueCoordinator();
93
+ const busy = makeParkedTask();
94
+ const sameKey = makeParkedTask();
95
+ coordinator.enqueue(busy.task, { key: "s1" });
96
+ await busy.startedPromise;
97
+ coordinator.enqueue(sameKey.task, { key: "s1" });
98
+ assert.equal(
99
+ sameKey.started,
100
+ false,
101
+ "same-session work must never run concurrently, even under the default limit",
102
+ );
103
+ busy.release();
104
+ await sameKey.startedPromise;
105
+ sameKey.release();
106
+ assert.equal(await coordinator.waitForIdle(5_000), true);
107
+ });
@@ -40,18 +40,18 @@ async function extractCapturingWarns(local: LocalStub) {
40
40
  }
41
41
  }
42
42
 
43
- /** End-to-end pin: exactly one diagnostic on the unusable-reply path, the parse_empty class unchanged, and no reply fragment in any warn line. */
44
- test("an unusable reply logs one content-free diagnostic; the rejection and parse_empty class are unchanged", async () => {
43
+ /** End-to-end pin: a length-truncated reply is its own class (#3521), exactly one diagnostic carrying the output ceiling, and no reply fragment in any warn line. */
44
+ test("a length-truncated unusable reply classifies output_truncated and logs the ceiling", async () => {
45
45
  const reply = `Here is my analysis of ${SECRET}: nothing durable was said.`;
46
46
  const { result, warns } = await extractCapturingWarns(async (_messages, options) => {
47
47
  if (options.failureDiag) options.failureDiag.finishReason = "length";
48
48
  return { content: reply };
49
49
  });
50
50
  assert.equal(result.extractionFailure, "local_llm_error");
51
- assert.equal(result.extractionFailureClass, "parse_empty");
51
+ assert.equal(result.extractionFailureClass, "output_truncated");
52
52
  const lines = warns.filter((w) => w.includes(MARKER));
53
53
  assert.equal(lines.length, 1);
54
- assert.match(lines[0]!, new RegExp(`replyChars=${reply.length} finishReason=length startsWithBrace=false jsonCandidates=1 parsedAnyJson=false unrecognizedPayloads=0 topLevelKeys= partialFacts=0`));
54
+ assert.match(lines[0]!, new RegExp(`replyChars=${reply.length} finishReason=length startsWithBrace=false jsonCandidates=1 parsedAnyJson=false unrecognizedPayloads=0 topLevelKeys= partialFacts=0 maxOutputTokens=1000`));
55
55
  assert.ok(warns.some((w) => w.includes("LocalLlmRejectedError: local LLM answered with unusable content")));
56
56
  for (const warn of warns) {
57
57
  assert.equal(warn.includes(SECRET), false);
@@ -32,6 +32,7 @@ test("commentary: no braces, nothing parses (the whole reply is the one candidat
32
32
  unrecognizedPayloads: 0,
33
33
  topLevelKeys: [],
34
34
  partialFacts: 0,
35
+ maxOutputTokens: undefined,
35
36
  });
36
37
  assertNoContent(reply, [SECRET, "durable facts", "conversation"]);
37
38
  });
@@ -97,6 +98,7 @@ test("empty reply", () => {
97
98
  unrecognizedPayloads: 0,
98
99
  topLevelKeys: [],
99
100
  partialFacts: 0,
101
+ maxOutputTokens: undefined,
100
102
  });
101
103
  });
102
104
 
@@ -125,6 +127,6 @@ test("rendered line has a stable greppable shape", () => {
125
127
  );
126
128
  assert.equal(
127
129
  line,
128
- "extractWithLocalLlm: unusable local reply replyChars=14 finishReason=stop startsWithBrace=true jsonCandidates=1 parsedAnyJson=true unrecognizedPayloads=1 topLevelKeys=answer partialFacts=0",
130
+ "extractWithLocalLlm: unusable local reply replyChars=14 finishReason=stop startsWithBrace=true jsonCandidates=1 parsedAnyJson=true unrecognizedPayloads=1 topLevelKeys=answer partialFacts=0 maxOutputTokens=none",
129
131
  );
130
132
  });
@@ -49,13 +49,16 @@ export interface UnusableReplyDiagnostic {
49
49
  /** From the first candidate that parsed. */
50
50
  topLevelKeys: string[];
51
51
  partialFacts: number;
52
+ /** The effective output ceiling the reply was cut at (`contextSizes.maxOutputTokens`); a number, never content. */
53
+ maxOutputTokens: number | undefined;
52
54
  }
53
55
 
54
- /** `content` is the trimmed reply; `finishReason` is whatever the client recorded (validated here). */
56
+ /** `content` is the trimmed reply; `finishReason` is whatever the client recorded (validated here). `maxOutputTokens` is the call's output ceiling. */
55
57
  export function buildUnusableReplyDiagnostic(
56
58
  content: string,
57
59
  finishReason: string | undefined,
58
60
  partialFacts: number,
61
+ maxOutputTokens?: number,
59
62
  ): UnusableReplyDiagnostic {
60
63
  const candidates = extractJsonCandidates(content);
61
64
  let parsedAnyJson = false;
@@ -82,6 +85,10 @@ export function buildUnusableReplyDiagnostic(
82
85
  unrecognizedPayloads,
83
86
  topLevelKeys,
84
87
  partialFacts,
88
+ maxOutputTokens:
89
+ maxOutputTokens !== undefined && Number.isFinite(maxOutputTokens) && maxOutputTokens > 0
90
+ ? Math.floor(maxOutputTokens)
91
+ : undefined,
85
92
  };
86
93
  }
87
94
 
@@ -101,5 +108,6 @@ export function formatUnusableReplyDiagnostic(d: UnusableReplyDiagnostic): strin
101
108
  `unrecognizedPayloads=${d.unrecognizedPayloads}`,
102
109
  `topLevelKeys=${d.topLevelKeys.join(",")}`,
103
110
  `partialFacts=${d.partialFacts}`,
111
+ `maxOutputTokens=${d.maxOutputTokens ?? "none"}`,
104
112
  ].join(" ");
105
113
  }
package/src/extraction.ts CHANGED
@@ -38,7 +38,7 @@ import {
38
38
  import { applyGroundingWithConnector, headerConnector, renderExtractionConversation, resolveSourceConnector, type ExtractionGroundingContext } from "./source-agent-qualifier.js";
39
39
  import { isMemoryCategory } from "./write-envelope.js";
40
40
  export { classifyExtractionThrownError, classifyFallbackParseFailure, formatExtractionParseFailureLog } from "./extraction-error-classification.js";
41
- import { LocalLlmRejectedError, classifyExtractionThrownError, classifyFallbackParseFailure, formatExtractionParseFailureLog, localRejectionStatus, type LocalFailureDiag } from "./extraction-error-classification.js";
41
+ import { LocalLlmRejectedError, classifyExtractionThrownError, classifyFallbackParseFailure, classifyLocalLlmRejected, formatExtractionParseFailureLog, localRejectionStatus, type LocalFailureDiag } from "./extraction-error-classification.js";
42
42
  import { buildUnusableReplyDiagnostic, formatUnusableReplyDiagnostic, looksLikeExtractionResultPayload } from "./extraction-reply-diagnostic.js";
43
43
  import { AMBIENT_CAPTURE_PROMPT_SECTION_COMPACT, clampAmbientCaptureConfidence } from "./ambient-provenance.js";
44
44
  import {
@@ -1230,7 +1230,7 @@ export class ExtractionEngine {
1230
1230
  entities: [],
1231
1231
  questions: [],
1232
1232
  extractionFailure: "local_llm_error",
1233
- extractionFailureClass: err instanceof LocalLlmRejectedError ? "parse_empty" : classifyExtractionThrownError(err),
1233
+ extractionFailureClass: err instanceof LocalLlmRejectedError ? classifyLocalLlmRejected(err) : classifyExtractionThrownError(err),
1234
1234
  };
1235
1235
  }
1236
1236
  log.info("extraction: local LLM error, falling back to gateway default AI:", err);
@@ -1503,8 +1503,8 @@ ${truncatedConversation}`;
1503
1503
  if (!response?.content) {
1504
1504
  const rejected = localRejectionStatus(failureDiag);
1505
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
1506
+ log.warn(formatUnusableReplyDiagnostic(buildUnusableReplyDiagnostic("", failureDiag.finishReason, 0, contextSizes.maxOutputTokens)));
1507
+ throw new LocalLlmRejectedError(rejected, failureDiag.finishReason); // the endpoint is up and refuses this input
1508
1508
  }
1509
1509
  log.debug("extractWithLocalLlm: chatCompletion returned null or empty content");
1510
1510
  return null;
@@ -1541,8 +1541,8 @@ ${truncatedConversation}`;
1541
1541
  log.debug(`extractWithLocalLlm: extracted ${partial.facts.length} partial facts from truncated JSON`);
1542
1542
  return partial;
1543
1543
  }
1544
- log.warn(formatUnusableReplyDiagnostic(buildUnusableReplyDiagnostic(content, failureDiag.finishReason, partial.facts.length)));
1545
- throw new LocalLlmRejectedError(); // the endpoint answered and nothing in the answer is usable
1544
+ log.warn(formatUnusableReplyDiagnostic(buildUnusableReplyDiagnostic(content, failureDiag.finishReason, partial.facts.length, contextSizes.maxOutputTokens)));
1545
+ throw new LocalLlmRejectedError(undefined, failureDiag.finishReason); // the endpoint answered and nothing in the answer is usable
1546
1546
  }
1547
1547
 
1548
1548
  /**
@@ -23,6 +23,14 @@ const DEFERRED: ExtractionRunResult = {
23
23
  persistedCount: 0,
24
24
  durableOutputCount: 0,
25
25
  };
26
+ const TRUNCATED: ExtractionRunResult = {
27
+ status: "skipped",
28
+ reason: "empty_extraction_result",
29
+ retainedBuffer: true,
30
+ failureClass: "output_truncated",
31
+ persistedCount: 0,
32
+ durableOutputCount: 0,
33
+ };
26
34
  const FAILED: ExtractionRunResult = {
27
35
  status: "skipped",
28
36
  reason: "empty_extraction_result",
@@ -258,3 +266,28 @@ test("a window of exact duplicates that is also oversized extracts every copy's
258
266
  });
259
267
  assert.deepEqual(buffer.getTurns("s1"), [], "both buffered identities drain");
260
268
  });
269
+
270
+ test("output_truncated never counts toward chunk drops: the run layer already long-parks", async () => {
271
+ // finish_reason=length retries at the same ceiling can never complete, so
272
+ // the run layer long-parks the fingerprint on the first failure. The drain
273
+ // keeps the chunk like a provider failure — it must not count toward a drop.
274
+ // Two 60-char turns at a 100-char budget force the multi-chunk path, where
275
+ // settleVerdict counts failures; the single-run path skips it entirely.
276
+ const first = makeTurn("a".repeat(60));
277
+ const second = makeTurn("b".repeat(60));
278
+ const saveCopies: { reason: string; contents: string }[] = [];
279
+ const { buffer, calls } = await withDrain({
280
+ turns: [first, second],
281
+ results: [TRUNCATED, TRUNCATED, TRUNCATED],
282
+ runs: 3,
283
+ dropAfter: 2,
284
+ saveCopies,
285
+ });
286
+ assert.equal(calls.length, 3, "each run attempts the truncated chunk and returns");
287
+ assert.deepEqual(
288
+ buffer.getTurns("s1").map((seen) => seen.content),
289
+ [first.content, second.content],
290
+ "three truncated runs keep the chunk buffered",
291
+ );
292
+ assert.equal(saveCopies.length, 0, "no recovery copy — nothing was dropped");
293
+ });
@@ -497,7 +497,13 @@ export class ExtractionDrain {
497
497
  // Provider breaker/backoff retention: keep everything for retry.
498
498
  if (verdict === "deferred") return { action: "return", result: mergeDrainResults(aggregate, result), aggregate };
499
499
  // An outage or a bad key is not the chunk's fault: keep the chunk and do not count toward dropping it.
500
- if (result.failureClass === "provider_retryable" || result.failureClass === "auth_config") {
500
+ // A reply cut at the output ceiling long-parks in the run layer on the first failure — the chunk
501
+ // stays buffered so a raised ceiling can drain it, and retries never count toward a drop (#3521).
502
+ if (
503
+ result.failureClass === "provider_retryable" ||
504
+ result.failureClass === "auth_config" ||
505
+ result.failureClass === "output_truncated"
506
+ ) {
501
507
  return { action: "return", result: mergeDrainResults(aggregate, result), aggregate };
502
508
  }
503
509
  return { action: "failed", result, aggregate };
@@ -92,7 +92,7 @@ export class ExtractionQueueCoordinator {
92
92
  /** Resolves the processor's park while a new task arrives mid-drain. */
93
93
  private wake?: () => void;
94
94
 
95
- constructor(concurrency = 1) {
95
+ constructor(concurrency = 2) {
96
96
  this.concurrency = Number.isInteger(concurrency) && concurrency >= 1 ? concurrency : 1;
97
97
  }
98
98
 
@@ -131,6 +131,20 @@ export function computeExtractionRetryNextEligibleMs(
131
131
  return safeNow + Math.max(0, Math.round(base * jitter));
132
132
  }
133
133
 
134
+ /**
135
+ * Whether a recorded failure long-parks the fingerprint: `output_truncated`
136
+ * can never succeed at the same output ceiling, and `parse_empty` past its
137
+ * attempt cap has shown this window unparseable — both park to max backoff.
138
+ * The retained window still drains under a raised ceiling (#3521).
139
+ */
140
+ export function extractionFailureLongParks(
141
+ cls: ExtractionFailureClass,
142
+ attempts: number,
143
+ parseEmptyMaxAttempts: number,
144
+ ): boolean {
145
+ return cls === "output_truncated" || (cls === "parse_empty" && attempts > parseEmptyMaxAttempts);
146
+ }
147
+
134
148
  /**
135
149
  * Cap the persisted retry-state array to the newest `maxEntries` by
136
150
  * firstFailedAt. Guards invalid caps so they cannot turn `slice(-maxEntries)`
@@ -905,15 +905,38 @@ test("parse_empty: long-parks a fingerprint after extractionParseEmptyMaxAttempt
905
905
  }
906
906
  });
907
907
 
908
- // ---------------------------------------------------------------------------
909
- // Invariant guard (regression): never mark processed on failure
910
- // ---------------------------------------------------------------------------
908
+ test("output_truncated: long-parks on the first failure — a retry at the same ceiling can never succeed", async () => {
909
+ const h = await makeHarness({
910
+ extractionRetryScheduleMs: [1000],
911
+ extractionRetryMaxBackoffMs: 9_000_000,
912
+ extractionParseEmptyMaxAttempts: 2,
913
+ extractionBreakerFailureThreshold: 100,
914
+ extractionRetryJitterRatio: 0,
915
+ });
916
+ try {
917
+ const coord = h.newCoordinator();
918
+ h.setRespond(() => failureResult("output_truncated"));
919
+ await h.run(coord, "fp-1", { force: true }); // attempt 1 → long-park immediately
920
+
921
+ const storage = await h.storageForNs("default");
922
+ const meta = await storage.loadMeta();
923
+ const entry = (meta.extractionRetryState ?? [])[0];
924
+ assert.ok(entry, "retry state entry exists");
925
+ assert.equal(entry.attempts, 1);
926
+ assert.equal(entry.lastFailureClass, "output_truncated");
927
+ const parkMs = Date.parse(entry.nextEligibleAt) - Date.now();
928
+ assert.ok(parkMs > 8_000_000, `long-parked to ~maxBackoff (got ${parkMs}ms)`);
929
+ assert.equal(h.recordedProcessedCount(), 0, "output_truncated fingerprint is never marked processed");
930
+ } finally {
931
+ await h.cleanup();
932
+ }
933
+ });
911
934
 
912
935
  test("invariant: a failing extraction never records a processed fingerprint", async () => {
913
936
  const h = await makeHarness({ extractionBreakerFailureThreshold: 100 });
914
937
  try {
915
938
  const coord = h.newCoordinator();
916
- for (const cls of ["provider_retryable", "parse_empty", "auth_config"] as ExtractionFailureClass[]) {
939
+ for (const cls of ["provider_retryable", "parse_empty", "output_truncated", "auth_config"] as const) {
917
940
  h.setRespond(() => failureResult(cls));
918
941
  await h.run(coord, `fp-${cls}`, { force: true });
919
942
  }
@@ -1346,7 +1369,7 @@ test("#3140: a successful flush heals the recorded LLM health", async () => {
1346
1369
  // ---------------------------------------------------------------------------
1347
1370
 
1348
1371
  test("a retained failure carries the extraction's failure class, so the drain can tell an outage from a bad chunk", async () => {
1349
- for (const cls of ["provider_retryable", "auth_config", "parse_empty"] as const) {
1372
+ for (const cls of ["provider_retryable", "auth_config", "parse_empty", "output_truncated"] as const) {
1350
1373
  const h = await makeHarness({ extractionRetryScheduleMs: [3_600_000], extractionBreakerFailureThreshold: 100 });
1351
1374
  try {
1352
1375
  h.setRespond(() => failureResult(cls));
@@ -134,6 +134,7 @@ import {
134
134
  countRequestedDurableOutputs,
135
135
  deriveSourceConnector,
136
136
  deriveTopicsFromExtraction, emptyExtractionResult,
137
+ extractionFailureLongParks,
137
138
  runExtractionPostPersist,
138
139
  runExtractionPostPersistBestEffort,
139
140
  EXTRACTION_RETRY_STATE_MAX_ENTRIES,
@@ -351,19 +352,16 @@ export class ExtractionRunCoordinator {
351
352
  const prev = nsMap.get(fingerprint);
352
353
  const attempts = (prev?.attempts ?? 0) + 1;
353
354
  const firstFailedAtMs = prev?.firstFailedAtMs ?? now;
354
- let nextEligibleAtMs: number;
355
- if (cls === "parse_empty" && attempts > this.config.extractionParseEmptyMaxAttempts) {
356
- // parse_empty budget exhausted → long-park (still never marked processed).
357
- nextEligibleAtMs = now + Math.max(0, this.config.extractionRetryMaxBackoffMs);
358
- } else {
359
- nextEligibleAtMs = computeExtractionRetryNextEligibleMs(
360
- attempts,
361
- this.config.extractionRetryScheduleMs,
362
- this.config.extractionRetryMaxBackoffMs,
363
- this.config.extractionRetryJitterRatio,
364
- now,
365
- );
366
- }
355
+ // output_truncated or parse_empty past its cap → long-park; the window survives a raised ceiling (#3521).
356
+ const nextEligibleAtMs = extractionFailureLongParks(cls, attempts, this.config.extractionParseEmptyMaxAttempts)
357
+ ? now + Math.max(0, this.config.extractionRetryMaxBackoffMs)
358
+ : computeExtractionRetryNextEligibleMs(
359
+ attempts,
360
+ this.config.extractionRetryScheduleMs,
361
+ this.config.extractionRetryMaxBackoffMs,
362
+ this.config.extractionRetryJitterRatio,
363
+ now,
364
+ );
367
365
  nsMap.set(fingerprint, { attempts, nextEligibleAtMs, firstFailedAtMs, lastFailureClass: cls });
368
366
  this.extractionRetryState.set(namespace, nsMap);
369
367
  this.providerBreaker.failure(cls, now, {