@remnic/core 10.0.165 → 10.0.167

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 (430) hide show
  1. package/dist/access-admin-ops-surface.js +129 -128
  2. package/dist/access-authorization-probe.js +4 -4
  3. package/dist/access-boundary.js +3 -3
  4. package/dist/access-cli.d.ts.map +1 -1
  5. package/dist/access-cli.js +145 -138
  6. package/dist/access-cli.js.map +1 -1
  7. package/dist/access-coding-context-resolution.d.ts +37 -0
  8. package/dist/access-coding-context-resolution.d.ts.map +1 -1
  9. package/dist/access-coding-context-resolution.js +48 -4
  10. package/dist/access-errors.d.ts +5 -0
  11. package/dist/access-errors.d.ts.map +1 -1
  12. package/dist/access-errors.js +3 -1
  13. package/dist/access-extraction-force-flush-preempt.js +129 -128
  14. package/dist/access-extraction-force-flush.js +129 -128
  15. package/dist/access-http-briefing.js +129 -128
  16. package/dist/access-http-query.js +129 -128
  17. package/dist/access-http.d.ts.map +1 -1
  18. package/dist/access-http.js +129 -128
  19. package/dist/access-identity-continuity-surface.js +129 -128
  20. package/dist/access-lcm-surface.js +129 -128
  21. package/dist/access-mcp.js +129 -128
  22. package/dist/access-memory-search-fanout.js +2 -2
  23. package/dist/access-namespace-preflight.js +4 -4
  24. package/dist/access-observe-transcript.js +3 -2
  25. package/dist/access-observe-write-category.js +9 -9
  26. package/dist/access-observe-write-surface.d.ts +1 -0
  27. package/dist/access-observe-write-surface.d.ts.map +1 -1
  28. package/dist/access-observe-write-surface.js +129 -128
  29. package/dist/access-offline-manifest.js +9 -8
  30. package/dist/access-operations-batch.js +129 -128
  31. package/dist/access-operations.d.ts +1 -1
  32. package/dist/access-operations.js +129 -128
  33. package/dist/access-recall-concurrency.d.ts +3 -16
  34. package/dist/access-recall-concurrency.d.ts.map +1 -1
  35. package/dist/access-recall-concurrency.js +129 -128
  36. package/dist/access-recall-corpus-versions.d.ts +4 -1
  37. package/dist/access-recall-corpus-versions.d.ts.map +1 -1
  38. package/dist/access-recall-corpus-versions.js +4 -1
  39. package/dist/access-recall-diagnostics.js +3 -3
  40. package/dist/access-recall-response.d.ts.map +1 -1
  41. package/dist/access-recall-response.js +129 -128
  42. package/dist/access-recall-surface.d.ts +1 -0
  43. package/dist/access-recall-surface.d.ts.map +1 -1
  44. package/dist/access-recall-surface.js +129 -128
  45. package/dist/access-schema.d.ts +1 -0
  46. package/dist/access-schema.d.ts.map +1 -1
  47. package/dist/access-schema.js +2 -2
  48. package/dist/access-service.d.ts +3 -15
  49. package/dist/access-service.d.ts.map +1 -1
  50. package/dist/access-service.js +131 -128
  51. package/dist/access-surface-catalog.js +5 -5
  52. package/dist/access-token-capabilities.js +2 -2
  53. package/dist/active-recall.js +21 -21
  54. package/dist/artifact-search.js +2 -2
  55. package/dist/auto-sync-L3M4RKJD.js +1 -1
  56. package/dist/briefing.js +19 -19
  57. package/dist/buffer-add-turns-bounded.js +2 -2
  58. package/dist/buffer-turn-helpers.d.ts.map +1 -1
  59. package/dist/buffer-turn-helpers.js +1 -1
  60. package/dist/buffer.js +11 -10
  61. package/dist/calibration.js +2 -2
  62. package/dist/capsule-import-gate.js +2 -2
  63. package/dist/causal-consolidation.js +20 -20
  64. package/dist/{chunk-5V3IBSVB.js → chunk-22V3CMIW.js} +4 -4
  65. package/dist/{chunk-7IWRLYFJ.js → chunk-2TJSGIKT.js} +2 -2
  66. package/dist/{chunk-V6M6N3EE.js → chunk-333SBFXB.js} +2 -2
  67. package/dist/{chunk-XBW7U7GM.js → chunk-3PNJZTDV.js} +5 -2
  68. package/dist/chunk-3PNJZTDV.js.map +1 -0
  69. package/dist/{chunk-XE4UYWW3.js → chunk-3YOX2BQD.js} +3 -3
  70. package/dist/{chunk-XEBNSY7N.js → chunk-4D2EY4WM.js} +2 -2
  71. package/dist/{chunk-5HFCXTGY.js → chunk-4D77BI3J.js} +29 -189
  72. package/dist/chunk-4D77BI3J.js.map +1 -0
  73. package/dist/{chunk-LPV72KRQ.js → chunk-4IMOGAFF.js} +3 -3
  74. package/dist/{chunk-QBREZ4QL.js → chunk-4L25GAYL.js} +2 -2
  75. package/dist/{chunk-HADD45AR.js → chunk-4WCLZBM2.js} +2 -2
  76. package/dist/{chunk-B3GKQ6DU.js → chunk-5MA6ZQ4Z.js} +2 -2
  77. package/dist/{chunk-V4ASAWRP.js → chunk-5PUZV73Z.js} +3 -3
  78. package/dist/{chunk-3QLAOYBL.js → chunk-5QDTZIGH.js} +3 -3
  79. package/dist/{chunk-WXDTOE6F.js → chunk-5VMRM2X3.js} +2 -2
  80. package/dist/{chunk-VE23DIBH.js → chunk-6QWFZ3X5.js} +2 -2
  81. package/dist/{chunk-SDGD6MYV.js → chunk-7F7HRJI2.js} +2 -2
  82. package/dist/{chunk-QFPNWSVH.js → chunk-7OCKK5M5.js} +6 -6
  83. package/dist/{chunk-WAJL65KW.js → chunk-7VIJUZYW.js} +3 -3
  84. package/dist/{chunk-EI2M2CFJ.js → chunk-A5UOREWD.js} +3 -3
  85. package/dist/{chunk-32CA7B6L.js → chunk-AQZL7JBZ.js} +2 -2
  86. package/dist/{chunk-EDA6CDBT.js → chunk-AVWOULJH.js} +2 -2
  87. package/dist/{chunk-4HKK5HUI.js → chunk-B3M56D2A.js} +2 -2
  88. package/dist/{chunk-YAVIBVCU.js → chunk-BFPQJNFZ.js} +5 -5
  89. package/dist/{chunk-YAVIBVCU.js.map → chunk-BFPQJNFZ.js.map} +1 -1
  90. package/dist/{chunk-SRN5M4LQ.js → chunk-BKTCVXMK.js} +4 -4
  91. package/dist/{chunk-TXVTNDQT.js → chunk-BPCR5DZP.js} +2 -2
  92. package/dist/{chunk-6S4DM53Y.js → chunk-C5QYWM6F.js} +6 -6
  93. package/dist/chunk-CKELO7Q6.js +113 -0
  94. package/dist/chunk-CKELO7Q6.js.map +1 -0
  95. package/dist/{chunk-IEB6XYW6.js → chunk-CKZWLAHN.js} +2 -2
  96. package/dist/{chunk-JVIWVJ2A.js → chunk-CUPILBIP.js} +3 -3
  97. package/dist/{chunk-274UY54Z.js → chunk-DFZYZOLH.js} +3 -3
  98. package/dist/{chunk-FSI45NUK.js → chunk-EZG54YDS.js} +2 -2
  99. package/dist/{chunk-7ZFB4VZS.js → chunk-FFWFFAP3.js} +2 -2
  100. package/dist/{chunk-22VXXA67.js → chunk-FGT7CUYZ.js} +2 -2
  101. package/dist/{chunk-Z3SXC3MP.js → chunk-FOTFLHBN.js} +2 -2
  102. package/dist/{chunk-RH6XWXMA.js → chunk-FRYCXXTB.js} +3 -3
  103. package/dist/{chunk-B377OKUP.js → chunk-G64WYD2S.js} +4 -4
  104. package/dist/{chunk-JJEQRSYU.js → chunk-GBSXTTLP.js} +2 -2
  105. package/dist/{chunk-2YODOG2O.js → chunk-GIL2M2OI.js} +3 -3
  106. package/dist/{chunk-YVRQ5JRA.js → chunk-GYOKVJPB.js} +14 -8
  107. package/dist/chunk-GYOKVJPB.js.map +1 -0
  108. package/dist/{chunk-ARJ3KCX4.js → chunk-HDLNSDLK.js} +2 -2
  109. package/dist/{chunk-VXUO5JZC.js → chunk-HDWISXFH.js} +6 -6
  110. package/dist/{chunk-RNFMFC37.js → chunk-IDYYGOOQ.js} +28 -1
  111. package/dist/chunk-IDYYGOOQ.js.map +1 -0
  112. package/dist/{chunk-IHOKB3L3.js → chunk-IE2ZLO3R.js} +785 -515
  113. package/dist/chunk-IE2ZLO3R.js.map +1 -0
  114. package/dist/{chunk-EZ47HOJ6.js → chunk-IXI6S2VJ.js} +4 -4
  115. package/dist/{chunk-VXMWTRQX.js → chunk-J74YOBB3.js} +4 -4
  116. package/dist/{chunk-AMW3IDCO.js → chunk-JFMMEHVG.js} +2 -2
  117. package/dist/{chunk-XKZBZOKV.js → chunk-JIF22AXI.js} +18 -1
  118. package/dist/chunk-JIF22AXI.js.map +1 -0
  119. package/dist/{chunk-JTSSSR4L.js → chunk-KIUFT2WZ.js} +3 -3
  120. package/dist/{chunk-L6BLTV4D.js → chunk-L7SEYUHS.js} +2 -2
  121. package/dist/{chunk-WRAK5LLB.js → chunk-LPUEBFX2.js} +3 -3
  122. package/dist/{chunk-DBVSU3HE.js → chunk-LVGTH6IQ.js} +9 -9
  123. package/dist/{chunk-33VVVP57.js → chunk-MEVBSF6T.js} +4 -1
  124. package/dist/chunk-MEVBSF6T.js.map +1 -0
  125. package/dist/{chunk-CJCTKL6Y.js → chunk-MGKCKY7X.js} +4 -1
  126. package/dist/chunk-MGKCKY7X.js.map +1 -0
  127. package/dist/{chunk-SOGOHLWN.js → chunk-N7AIFTSH.js} +1 -1
  128. package/dist/chunk-N7AIFTSH.js.map +1 -0
  129. package/dist/chunk-O3XGASU5.js +197 -0
  130. package/dist/chunk-O3XGASU5.js.map +1 -0
  131. package/dist/{chunk-OGBQMY46.js → chunk-O544TUJO.js} +2 -2
  132. package/dist/{chunk-TFNZXOXK.js → chunk-OAQRZ4SV.js} +2 -2
  133. package/dist/{chunk-IEEV27BC.js → chunk-OO2HEUZ4.js} +2 -2
  134. package/dist/{chunk-YMC4AYJK.js → chunk-OWM2VWNX.js} +10 -10
  135. package/dist/{chunk-4LPTSB5V.js → chunk-PFLN6TTW.js} +2 -2
  136. package/dist/{chunk-YOR5QBEU.js → chunk-QFTK6EDM.js} +4 -4
  137. package/dist/{chunk-A2WFUMUN.js → chunk-QKDXO4FD.js} +4 -4
  138. package/dist/{chunk-Y7HLGKKU.js → chunk-QLQUAVVP.js} +4 -4
  139. package/dist/{chunk-MUMQWCE2.js → chunk-QPFM6DHY.js} +2 -2
  140. package/dist/{chunk-YWPCDR3I.js → chunk-QVXEXGIM.js} +3 -3
  141. package/dist/{chunk-UPE7TJWN.js → chunk-QWWHYBPT.js} +2 -2
  142. package/dist/{chunk-NZHZQGLB.js → chunk-QXTKN25V.js} +2 -2
  143. package/dist/{chunk-OAGTKS73.js → chunk-RFLC6PKQ.js} +2 -2
  144. package/dist/{chunk-ZRLTQ2Y7.js → chunk-RO5EGRAI.js} +2 -2
  145. package/dist/{chunk-5D4NBANY.js → chunk-SIONKXLU.js} +2 -2
  146. package/dist/{chunk-6XTUZKCZ.js → chunk-SMDZTJ2D.js} +2 -2
  147. package/dist/{chunk-OFSAKEZB.js → chunk-T4BT4FQN.js} +2 -2
  148. package/dist/{chunk-IC35ZYLM.js → chunk-TAD6QMMD.js} +4 -4
  149. package/dist/{chunk-EAHNSQ7H.js → chunk-TB6VFEHQ.js} +2 -2
  150. package/dist/{chunk-6ARSFTLD.js → chunk-TNRGWJYT.js} +2 -2
  151. package/dist/{chunk-6TPWIPE3.js → chunk-U3BCW7GX.js} +3 -3
  152. package/dist/{chunk-JCAMHTS2.js → chunk-UBG65KEY.js} +7 -5
  153. package/dist/{chunk-JCAMHTS2.js.map → chunk-UBG65KEY.js.map} +1 -1
  154. package/dist/{chunk-CGOPDXLK.js → chunk-UMEUU66X.js} +2 -2
  155. package/dist/{chunk-5LTXYM7D.js → chunk-UYIBNDQE.js} +2 -2
  156. package/dist/{chunk-UGQEJWR3.js → chunk-VHXRLD6S.js} +2 -2
  157. package/dist/{chunk-WJ6S54ES.js → chunk-VOLTQNAP.js} +2 -2
  158. package/dist/{chunk-SBU5GDOT.js → chunk-VRHY7Y5A.js} +7 -7
  159. package/dist/{chunk-E5RJPLNL.js → chunk-W7N7NWG5.js} +3 -3
  160. package/dist/{chunk-UPWOMMVU.js → chunk-WECKZ3KT.js} +7 -7
  161. package/dist/{chunk-PCUDFWX5.js → chunk-WEFFO2MJ.js} +2 -2
  162. package/dist/{chunk-QCP75JGO.js → chunk-WQUGCOKF.js} +5 -5
  163. package/dist/{chunk-FKBGK3NC.js → chunk-WWUQ6CP3.js} +2 -2
  164. package/dist/{chunk-KR6PEAM4.js → chunk-X67XNZ64.js} +8 -8
  165. package/dist/{chunk-UYHDMCY2.js → chunk-XUVCQ4YZ.js} +2 -2
  166. package/dist/{chunk-7IJ2H43M.js → chunk-YY57TRKN.js} +2 -2
  167. package/dist/{chunk-AU6AEUFD.js → chunk-YYXYZM2I.js} +2 -2
  168. package/dist/{chunk-3FBAEPCU.js → chunk-ZDUE44CC.js} +2 -2
  169. package/dist/{chunk-PRE7R3RQ.js → chunk-ZQUOUPP3.js} +12 -3
  170. package/dist/chunk-ZQUOUPP3.js.map +1 -0
  171. package/dist/{chunk-RDO6AMDL.js → chunk-ZWDDY4WF.js} +2 -2
  172. package/dist/{chunk-QASTQVGK.js → chunk-ZX546Y3Y.js} +2 -2
  173. package/dist/chunk-ZX546Y3Y.js.map +1 -0
  174. package/dist/cli.js +129 -128
  175. package/dist/coding/architecture-surfaces.d.ts +0 -24
  176. package/dist/coding/architecture-surfaces.d.ts.map +1 -1
  177. package/dist/coding/codegraph-surfaces.d.ts.map +1 -1
  178. package/dist/coding/export-okf-codegraph.js +51 -24
  179. package/dist/coding/export-okf-codegraph.js.map +1 -1
  180. package/dist/coding/git-context.d.ts +23 -0
  181. package/dist/coding/git-context.d.ts.map +1 -1
  182. package/dist/coding/git-context.js +31 -0
  183. package/dist/coding/git-context.js.map +1 -0
  184. package/dist/coding/session-delta-surfaces.d.ts +0 -23
  185. package/dist/coding/session-delta-surfaces.d.ts.map +1 -1
  186. package/dist/compounding/engine.js +20 -20
  187. package/dist/config.js +21 -21
  188. package/dist/connectors/codex-materialize-runner.js +19 -19
  189. package/dist/connectors/droid-mcp.d.ts +4 -3
  190. package/dist/connectors/droid-mcp.d.ts.map +1 -1
  191. package/dist/connectors/index.js +23 -23
  192. package/dist/convergence-refresh.js +21 -21
  193. package/dist/conversation-index/backend.js +2 -2
  194. package/dist/corpus-watermark.js +23 -23
  195. package/dist/deep-recall-config.js +2 -2
  196. package/dist/deep-recall-http-glue.js +4 -4
  197. package/dist/entity-recall-cancellation.js +2 -2
  198. package/dist/entity-recall-reads.js +3 -3
  199. package/dist/entity-retrieval.js +21 -21
  200. package/dist/explicit-capture.js +129 -128
  201. package/dist/external-wiki-access.js +4 -4
  202. package/dist/extraction-judge.js +1 -1
  203. package/dist/extraction.js +31 -30
  204. package/dist/harmonic-retrieval.js +19 -19
  205. package/dist/index.js +208 -206
  206. package/dist/local-llm.js +2 -2
  207. package/dist/location/index.js +21 -21
  208. package/dist/maintenance/memory-governance.js +19 -19
  209. package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +19 -19
  210. package/dist/maintenance/rebuild-memory-projection-runner.js +21 -21
  211. package/dist/maintenance/rebuild-memory-projection.js +20 -20
  212. package/dist/memory-browse-http-glue.js +2 -2
  213. package/dist/memory-browse-operations.js +4 -4
  214. package/dist/memory-browse.js +6 -6
  215. package/dist/memory-controller.d.ts +8 -0
  216. package/dist/memory-controller.d.ts.map +1 -1
  217. package/dist/memory-controller.js +1 -1
  218. package/dist/namespaces/migrate.js +20 -20
  219. package/dist/namespaces/search.js +8 -8
  220. package/dist/namespaces/storage.js +19 -19
  221. package/dist/offline-sync-impression-drain.js +8 -7
  222. package/dist/operator-doctor-corpus.js +26 -26
  223. package/dist/operator-doctor-replica.js +4 -4
  224. package/dist/operator-toolkit.js +35 -34
  225. package/dist/orchestration/backlog-scheduler.js +130 -129
  226. package/dist/orchestration/backlog-scheduler.js.map +1 -1
  227. package/dist/orchestration/buffer-drain-runner.js +130 -129
  228. package/dist/orchestration/episodic-context-section.d.ts +3 -2
  229. package/dist/orchestration/episodic-context-section.d.ts.map +1 -1
  230. package/dist/orchestration/maintenance.js +34 -33
  231. package/dist/orchestration/orchestrator-helpers.d.ts +10 -0
  232. package/dist/orchestration/orchestrator-helpers.d.ts.map +1 -1
  233. package/dist/orchestration/orchestrator-init.d.ts +12 -13
  234. package/dist/orchestration/orchestrator-init.d.ts.map +1 -1
  235. package/dist/orchestration/recall-entry.d.ts.map +1 -1
  236. package/dist/orchestration/recall-internal.d.ts.map +1 -1
  237. package/dist/orchestration/session-context.d.ts +5 -1
  238. package/dist/orchestration/session-context.d.ts.map +1 -1
  239. package/dist/orchestration/startup-search-sync.d.ts +73 -0
  240. package/dist/orchestration/startup-search-sync.d.ts.map +1 -0
  241. package/dist/orchestration/turn-ingestion.d.ts.map +1 -1
  242. package/dist/orchestrator.d.ts +4 -1
  243. package/dist/orchestrator.d.ts.map +1 -1
  244. package/dist/orchestrator.js +129 -128
  245. package/dist/qmd-daemon-session.js +2 -2
  246. package/dist/qmd.js +3 -3
  247. package/dist/recall-explain-renderer.js +3 -3
  248. package/dist/recall-navigate-access.js +2 -2
  249. package/dist/recall-navigate-disclosure.js +2 -2
  250. package/dist/recall-navigate.js +2 -2
  251. package/dist/recall-navigation-http-glue.js +2 -2
  252. package/dist/recall-navigation-operations.js +4 -4
  253. package/dist/recall-navigation.js +129 -128
  254. package/dist/recall-qos.d.ts +26 -0
  255. package/dist/recall-qos.d.ts.map +1 -1
  256. package/dist/recall-qos.js +9 -1
  257. package/dist/recall-state-view-admission.js +6 -6
  258. package/dist/recall-why-service.js +6 -6
  259. package/dist/recall-xray-cli.js +4 -4
  260. package/dist/recall-xray-renderer.js +3 -3
  261. package/dist/recall-xray.js +2 -2
  262. package/dist/relay/mission.d.ts +3 -3
  263. package/dist/replica-divergence.js +3 -3
  264. package/dist/resume-bundles.js +23 -23
  265. package/dist/search/factory.js +7 -7
  266. package/dist/search/index.js +9 -9
  267. package/dist/semantic-consolidation.js +20 -20
  268. package/dist/semantic-rule-promotion.js +19 -19
  269. package/dist/semantic-rule-verifier.js +19 -19
  270. package/dist/source-agent-qualifier.js +29 -28
  271. package/dist/standup/build.js +20 -20
  272. package/dist/storage/buffer-drain-claims.js +2 -2
  273. package/dist/storage/buffer-session-files.js +2 -2
  274. package/dist/storage.js +18 -18
  275. package/dist/summarizer.js +3 -3
  276. package/dist/support-passport/index.js +7 -7
  277. package/dist/tokens.js +3 -3
  278. package/dist/transfer/export-okf.js +19 -19
  279. package/dist/types.d.ts +1 -0
  280. package/dist/types.d.ts.map +1 -1
  281. package/dist/types.js +1 -1
  282. package/dist/verified-recall.js +19 -19
  283. package/dist/who-knows-cli.js +21 -21
  284. package/dist/who-knows.js +20 -20
  285. package/package.json +12 -2
  286. package/src/access-cli.ts +18 -9
  287. package/src/access-coding-context-resolution.ts +138 -0
  288. package/src/access-errors.ts +5 -0
  289. package/src/access-http-admission.test.ts +76 -0
  290. package/src/access-http.test.ts +2 -0
  291. package/src/access-http.ts +4 -0
  292. package/src/access-observe-write-surface.ts +2 -1
  293. package/src/access-operations-batch.ts +2 -2
  294. package/src/access-recall-concurrency.ts +179 -22
  295. package/src/access-recall-corpus-versions.ts +12 -7
  296. package/src/access-recall-response.ts +25 -2
  297. package/src/access-recall-surface.ts +6 -4
  298. package/src/access-schema.ts +9 -0
  299. package/src/access-service-raw-excerpt-read-gate.test.ts +7 -2
  300. package/src/access-service-recall-concurrency.test.ts +242 -0
  301. package/src/access-service-set-coding-context.test.ts +210 -0
  302. package/src/access-service.ts +43 -58
  303. package/src/buffer-turn-helpers.ts +3 -0
  304. package/src/capsule-import-gate.test.ts +106 -0
  305. package/src/coding/access-coding-context.test.ts +3 -0
  306. package/src/coding/architecture-surfaces.ts +2 -1
  307. package/src/coding/codegraph-surfaces.test.ts +34 -0
  308. package/src/coding/codegraph-surfaces.ts +3 -2
  309. package/src/coding/git-context.test.ts +29 -0
  310. package/src/coding/git-context.ts +63 -2
  311. package/src/coding/session-delta-surfaces.ts +2 -1
  312. package/src/connectors/droid-mcp.test.ts +46 -0
  313. package/src/connectors/droid-mcp.ts +5 -5
  314. package/src/harmonic-graph-version.test.ts +63 -0
  315. package/src/memory-controller.test.ts +38 -0
  316. package/src/memory-controller.ts +25 -2
  317. package/src/orchestration/episodic-context-section.ts +6 -7
  318. package/src/orchestration/orchestrator-helpers.ts +10 -0
  319. package/src/orchestration/orchestrator-init.ts +57 -303
  320. package/src/orchestration/recall-entry.ts +59 -4
  321. package/src/orchestration/recall-internal.ts +10 -10
  322. package/src/orchestration/session-context.ts +11 -1
  323. package/src/orchestration/startup-search-sync.ts +492 -0
  324. package/src/orchestration/task-exit.test.ts +45 -0
  325. package/src/orchestration/turn-ingestion-buffered.test.ts +224 -0
  326. package/src/orchestration/turn-ingestion.ts +28 -35
  327. package/src/orchestrator-flush.test.ts +7 -7
  328. package/src/orchestrator-init.test.ts +364 -12
  329. package/src/orchestrator-source-attribution.test.ts +100 -0
  330. package/src/orchestrator-startup-ready-path.test.ts +133 -10
  331. package/src/orchestrator.ts +16 -1
  332. package/src/recall-qos.test.ts +62 -0
  333. package/src/recall-qos.ts +75 -0
  334. package/src/recall-retrieval-failure.test.ts +282 -18
  335. package/src/recall-search-options.test.ts +13 -1
  336. package/src/storage/buffer-drain-handin-memo.test.ts +140 -0
  337. package/src/types.ts +1 -1
  338. package/dist/chunk-33VVVP57.js.map +0 -1
  339. package/dist/chunk-3QNFHI6T.js +0 -38
  340. package/dist/chunk-3QNFHI6T.js.map +0 -1
  341. package/dist/chunk-5HFCXTGY.js.map +0 -1
  342. package/dist/chunk-CJCTKL6Y.js.map +0 -1
  343. package/dist/chunk-IHOKB3L3.js.map +0 -1
  344. package/dist/chunk-PRE7R3RQ.js.map +0 -1
  345. package/dist/chunk-QASTQVGK.js.map +0 -1
  346. package/dist/chunk-RNFMFC37.js.map +0 -1
  347. package/dist/chunk-SOGOHLWN.js.map +0 -1
  348. package/dist/chunk-XBW7U7GM.js.map +0 -1
  349. package/dist/chunk-XKZBZOKV.js.map +0 -1
  350. package/dist/chunk-YVRQ5JRA.js.map +0 -1
  351. /package/dist/{chunk-5V3IBSVB.js.map → chunk-22V3CMIW.js.map} +0 -0
  352. /package/dist/{chunk-7IWRLYFJ.js.map → chunk-2TJSGIKT.js.map} +0 -0
  353. /package/dist/{chunk-V6M6N3EE.js.map → chunk-333SBFXB.js.map} +0 -0
  354. /package/dist/{chunk-XE4UYWW3.js.map → chunk-3YOX2BQD.js.map} +0 -0
  355. /package/dist/{chunk-XEBNSY7N.js.map → chunk-4D2EY4WM.js.map} +0 -0
  356. /package/dist/{chunk-LPV72KRQ.js.map → chunk-4IMOGAFF.js.map} +0 -0
  357. /package/dist/{chunk-QBREZ4QL.js.map → chunk-4L25GAYL.js.map} +0 -0
  358. /package/dist/{chunk-HADD45AR.js.map → chunk-4WCLZBM2.js.map} +0 -0
  359. /package/dist/{chunk-B3GKQ6DU.js.map → chunk-5MA6ZQ4Z.js.map} +0 -0
  360. /package/dist/{chunk-V4ASAWRP.js.map → chunk-5PUZV73Z.js.map} +0 -0
  361. /package/dist/{chunk-3QLAOYBL.js.map → chunk-5QDTZIGH.js.map} +0 -0
  362. /package/dist/{chunk-WXDTOE6F.js.map → chunk-5VMRM2X3.js.map} +0 -0
  363. /package/dist/{chunk-VE23DIBH.js.map → chunk-6QWFZ3X5.js.map} +0 -0
  364. /package/dist/{chunk-SDGD6MYV.js.map → chunk-7F7HRJI2.js.map} +0 -0
  365. /package/dist/{chunk-QFPNWSVH.js.map → chunk-7OCKK5M5.js.map} +0 -0
  366. /package/dist/{chunk-WAJL65KW.js.map → chunk-7VIJUZYW.js.map} +0 -0
  367. /package/dist/{chunk-EI2M2CFJ.js.map → chunk-A5UOREWD.js.map} +0 -0
  368. /package/dist/{chunk-32CA7B6L.js.map → chunk-AQZL7JBZ.js.map} +0 -0
  369. /package/dist/{chunk-EDA6CDBT.js.map → chunk-AVWOULJH.js.map} +0 -0
  370. /package/dist/{chunk-4HKK5HUI.js.map → chunk-B3M56D2A.js.map} +0 -0
  371. /package/dist/{chunk-SRN5M4LQ.js.map → chunk-BKTCVXMK.js.map} +0 -0
  372. /package/dist/{chunk-TXVTNDQT.js.map → chunk-BPCR5DZP.js.map} +0 -0
  373. /package/dist/{chunk-6S4DM53Y.js.map → chunk-C5QYWM6F.js.map} +0 -0
  374. /package/dist/{chunk-IEB6XYW6.js.map → chunk-CKZWLAHN.js.map} +0 -0
  375. /package/dist/{chunk-JVIWVJ2A.js.map → chunk-CUPILBIP.js.map} +0 -0
  376. /package/dist/{chunk-274UY54Z.js.map → chunk-DFZYZOLH.js.map} +0 -0
  377. /package/dist/{chunk-FSI45NUK.js.map → chunk-EZG54YDS.js.map} +0 -0
  378. /package/dist/{chunk-7ZFB4VZS.js.map → chunk-FFWFFAP3.js.map} +0 -0
  379. /package/dist/{chunk-22VXXA67.js.map → chunk-FGT7CUYZ.js.map} +0 -0
  380. /package/dist/{chunk-Z3SXC3MP.js.map → chunk-FOTFLHBN.js.map} +0 -0
  381. /package/dist/{chunk-RH6XWXMA.js.map → chunk-FRYCXXTB.js.map} +0 -0
  382. /package/dist/{chunk-B377OKUP.js.map → chunk-G64WYD2S.js.map} +0 -0
  383. /package/dist/{chunk-JJEQRSYU.js.map → chunk-GBSXTTLP.js.map} +0 -0
  384. /package/dist/{chunk-2YODOG2O.js.map → chunk-GIL2M2OI.js.map} +0 -0
  385. /package/dist/{chunk-ARJ3KCX4.js.map → chunk-HDLNSDLK.js.map} +0 -0
  386. /package/dist/{chunk-VXUO5JZC.js.map → chunk-HDWISXFH.js.map} +0 -0
  387. /package/dist/{chunk-EZ47HOJ6.js.map → chunk-IXI6S2VJ.js.map} +0 -0
  388. /package/dist/{chunk-VXMWTRQX.js.map → chunk-J74YOBB3.js.map} +0 -0
  389. /package/dist/{chunk-AMW3IDCO.js.map → chunk-JFMMEHVG.js.map} +0 -0
  390. /package/dist/{chunk-JTSSSR4L.js.map → chunk-KIUFT2WZ.js.map} +0 -0
  391. /package/dist/{chunk-L6BLTV4D.js.map → chunk-L7SEYUHS.js.map} +0 -0
  392. /package/dist/{chunk-WRAK5LLB.js.map → chunk-LPUEBFX2.js.map} +0 -0
  393. /package/dist/{chunk-DBVSU3HE.js.map → chunk-LVGTH6IQ.js.map} +0 -0
  394. /package/dist/{chunk-OGBQMY46.js.map → chunk-O544TUJO.js.map} +0 -0
  395. /package/dist/{chunk-TFNZXOXK.js.map → chunk-OAQRZ4SV.js.map} +0 -0
  396. /package/dist/{chunk-IEEV27BC.js.map → chunk-OO2HEUZ4.js.map} +0 -0
  397. /package/dist/{chunk-YMC4AYJK.js.map → chunk-OWM2VWNX.js.map} +0 -0
  398. /package/dist/{chunk-4LPTSB5V.js.map → chunk-PFLN6TTW.js.map} +0 -0
  399. /package/dist/{chunk-YOR5QBEU.js.map → chunk-QFTK6EDM.js.map} +0 -0
  400. /package/dist/{chunk-A2WFUMUN.js.map → chunk-QKDXO4FD.js.map} +0 -0
  401. /package/dist/{chunk-Y7HLGKKU.js.map → chunk-QLQUAVVP.js.map} +0 -0
  402. /package/dist/{chunk-MUMQWCE2.js.map → chunk-QPFM6DHY.js.map} +0 -0
  403. /package/dist/{chunk-YWPCDR3I.js.map → chunk-QVXEXGIM.js.map} +0 -0
  404. /package/dist/{chunk-UPE7TJWN.js.map → chunk-QWWHYBPT.js.map} +0 -0
  405. /package/dist/{chunk-NZHZQGLB.js.map → chunk-QXTKN25V.js.map} +0 -0
  406. /package/dist/{chunk-OAGTKS73.js.map → chunk-RFLC6PKQ.js.map} +0 -0
  407. /package/dist/{chunk-ZRLTQ2Y7.js.map → chunk-RO5EGRAI.js.map} +0 -0
  408. /package/dist/{chunk-5D4NBANY.js.map → chunk-SIONKXLU.js.map} +0 -0
  409. /package/dist/{chunk-6XTUZKCZ.js.map → chunk-SMDZTJ2D.js.map} +0 -0
  410. /package/dist/{chunk-OFSAKEZB.js.map → chunk-T4BT4FQN.js.map} +0 -0
  411. /package/dist/{chunk-IC35ZYLM.js.map → chunk-TAD6QMMD.js.map} +0 -0
  412. /package/dist/{chunk-EAHNSQ7H.js.map → chunk-TB6VFEHQ.js.map} +0 -0
  413. /package/dist/{chunk-6ARSFTLD.js.map → chunk-TNRGWJYT.js.map} +0 -0
  414. /package/dist/{chunk-6TPWIPE3.js.map → chunk-U3BCW7GX.js.map} +0 -0
  415. /package/dist/{chunk-CGOPDXLK.js.map → chunk-UMEUU66X.js.map} +0 -0
  416. /package/dist/{chunk-5LTXYM7D.js.map → chunk-UYIBNDQE.js.map} +0 -0
  417. /package/dist/{chunk-UGQEJWR3.js.map → chunk-VHXRLD6S.js.map} +0 -0
  418. /package/dist/{chunk-WJ6S54ES.js.map → chunk-VOLTQNAP.js.map} +0 -0
  419. /package/dist/{chunk-SBU5GDOT.js.map → chunk-VRHY7Y5A.js.map} +0 -0
  420. /package/dist/{chunk-E5RJPLNL.js.map → chunk-W7N7NWG5.js.map} +0 -0
  421. /package/dist/{chunk-UPWOMMVU.js.map → chunk-WECKZ3KT.js.map} +0 -0
  422. /package/dist/{chunk-PCUDFWX5.js.map → chunk-WEFFO2MJ.js.map} +0 -0
  423. /package/dist/{chunk-QCP75JGO.js.map → chunk-WQUGCOKF.js.map} +0 -0
  424. /package/dist/{chunk-FKBGK3NC.js.map → chunk-WWUQ6CP3.js.map} +0 -0
  425. /package/dist/{chunk-KR6PEAM4.js.map → chunk-X67XNZ64.js.map} +0 -0
  426. /package/dist/{chunk-UYHDMCY2.js.map → chunk-XUVCQ4YZ.js.map} +0 -0
  427. /package/dist/{chunk-7IJ2H43M.js.map → chunk-YY57TRKN.js.map} +0 -0
  428. /package/dist/{chunk-AU6AEUFD.js.map → chunk-YYXYZM2I.js.map} +0 -0
  429. /package/dist/{chunk-3FBAEPCU.js.map → chunk-ZDUE44CC.js.map} +0 -0
  430. /package/dist/{chunk-RDO6AMDL.js.map → chunk-ZWDDY4WF.js.map} +0 -0
@@ -13,13 +13,20 @@
13
13
  * module. `raceAbort` and `attachFlightAbort` need no host (they operate on the
14
14
  * caller signal / flight object alone).
15
15
  */
16
- import { abortError, raceAbort, throwIfAborted } from "./abort-error.js";
16
+ import { abortError, isAbortError, raceAbort, throwIfAborted } from "./abort-error.js";
17
17
  import { hashAccessIdempotencyPayload } from "./access-idempotency.js";
18
18
  import {
19
+ EngramAccessDeadlineExceededError,
19
20
  EngramAccessInputError,
20
21
  type EngramAccessRecallRequest,
21
22
  type EngramAccessRecallResponse,
22
23
  } from "./access-service.js";
24
+ import { clientDeadlineTimerMs, resolveClientDeadlineAtMs } from "./recall-qos.js";
25
+ import {
26
+ composeMissingMemoryContext,
27
+ composeRecallContext,
28
+ } from "./recall-context-composition.js";
29
+ import { DEFAULT_RECALL_DISCLOSURE, isRecallDisclosure } from "./types.js";
23
30
  import {
24
31
  type BudgetDecision,
25
32
  type BudgetReservation,
@@ -96,7 +103,12 @@ export interface RecallCoordinatorHost {
96
103
  readonly recallSemaphores: Map<string, PrincipalSemaphore>;
97
104
  readonly recallInFlight: Map<string, RecallFlight>;
98
105
  readonly budget: Pick<CrossNamespaceBudget, "record" | "release">;
99
- readonly orchestrator: { readonly config: { readonly recallMaxConcurrentPerPrincipal: number } };
106
+ readonly orchestrator: {
107
+ readonly config: {
108
+ readonly recallMaxConcurrentPerPrincipal: number;
109
+ readonly defaultNamespace: string;
110
+ };
111
+ };
100
112
  executeRecall(request: EngramAccessRecallRequest): Promise<RecallExecResult>;
101
113
  handleIdempotentRead<T>(options: {
102
114
  operation: string;
@@ -121,8 +133,17 @@ function acquireRecallSlot(
121
133
  key: string,
122
134
  limit: number,
123
135
  signal?: AbortSignal,
136
+ deadlineAtMs?: number | null,
124
137
  ): Promise<{ release: () => void; waitedMs: number }> {
125
138
  const cap = Number.isFinite(limit) && limit > 0 ? limit : Infinity;
139
+ // A deadline already past fails as a timeout, not a cancellation — checked
140
+ // before any semaphore state is inserted so an expired request cannot leave
141
+ // an idle entry behind (issue #3514 review).
142
+ if (deadlineAtMs != null && deadlineAtMs <= Date.now()) {
143
+ return Promise.reject(
144
+ new EngramAccessDeadlineExceededError("recall deadline exceeded while queued"),
145
+ );
146
+ }
126
147
  const sem = host.recallSemaphores.get(key) ?? { active: 0, waiters: [] };
127
148
  host.recallSemaphores.set(key, sem);
128
149
  const release = () => {
@@ -146,25 +167,43 @@ function acquireRecallSlot(
146
167
  // Contended — measure the real time spent blocked for a slot.
147
168
  const startedWaiting = Date.now();
148
169
  return new Promise<{ release: () => void; waitedMs: number }>((resolve, reject) => {
170
+ let deadlineHandle: NodeJS.Timeout | null = null;
171
+ const removeWaiter = () => {
172
+ const i = sem.waiters.indexOf(waiter);
173
+ if (i >= 0) sem.waiters.splice(i, 1);
174
+ if (deadlineHandle) clearTimeout(deadlineHandle);
175
+ if (sem.active === 0 && sem.waiters.length === 0) {
176
+ host.recallSemaphores.delete(key);
177
+ }
178
+ };
149
179
  const waiter = {
150
180
  take: () => {
181
+ if (deadlineHandle) clearTimeout(deadlineHandle);
151
182
  signal?.removeEventListener("abort", waiter.drop);
152
183
  resolve({ release, waitedMs: Date.now() - startedWaiting });
153
184
  },
154
185
  drop: () => {
155
- const i = sem.waiters.indexOf(waiter);
156
- if (i >= 0) sem.waiters.splice(i, 1);
157
- if (sem.active === 0 && sem.waiters.length === 0) {
158
- host.recallSemaphores.delete(key);
159
- }
186
+ removeWaiter();
160
187
  reject(abortError("operation aborted"));
161
188
  },
189
+ // A client deadline expiring mid-queue degrades as a timeout, not
190
+ // caller cancellation (#3514 review).
191
+ expire: () => {
192
+ removeWaiter();
193
+ signal?.removeEventListener("abort", waiter.drop);
194
+ reject(
195
+ new EngramAccessDeadlineExceededError("recall deadline exceeded while queued"),
196
+ );
197
+ },
162
198
  };
163
199
  if (signal?.aborted) {
164
200
  waiter.drop();
165
201
  return;
166
202
  }
167
203
  signal?.addEventListener("abort", waiter.drop, { once: true });
204
+ if (deadlineAtMs != null) {
205
+ deadlineHandle = setTimeout(waiter.expire, clientDeadlineTimerMs(deadlineAtMs, startedWaiting));
206
+ }
168
207
  sem.waiters.push(waiter);
169
208
  });
170
209
  }
@@ -182,11 +221,12 @@ export async function withRecallConcurrency<T>(
182
221
  principal: string,
183
222
  signal: AbortSignal | undefined,
184
223
  fn: (queueWaitMs: number) => Promise<T>,
224
+ deadlineAtMs?: number | null,
185
225
  ): Promise<T> {
186
226
  const key = principal || "__anonymous__";
187
227
  const limit = host.orchestrator.config.recallMaxConcurrentPerPrincipal;
188
228
  throwIfAborted(signal);
189
- const { release, waitedMs } = await acquireRecallSlot(host, key, limit, signal);
229
+ const { release, waitedMs } = await acquireRecallSlot(host, key, limit, signal, deadlineAtMs);
190
230
  try {
191
231
  // The signal may have fired while queued: `take()` already removed the
192
232
  // abort listener when granting this slot, so re-check before entering `fn`.
@@ -246,8 +286,15 @@ function attachFlightAbort(
246
286
  if (cancelOnAbort && signal) signal.removeEventListener("abort", onAbort);
247
287
  // Unregister only once the LAST consumer finishes, so a joiner arriving
248
288
  // while a consumer is still settling (slow put / hooked consume) still
249
- // coalesces onto the shared result (round 6 #1).
250
- if (flight.live === 0) flight.onIdle?.();
289
+ // coalesces onto the shared result (round 6 #1). The last consumer out
290
+ // cancels the flight for ANY leave reason — settle, abort, or a
291
+ // deadline-fired detach — with the same committed-keyed persistence guard
292
+ // as the abort path: a shared pipeline nobody still consumes must not keep
293
+ // a concurrency slot queued (#3514 review).
294
+ if (flight.live === 0) {
295
+ if (!flight.persisted || !flight.committed) flight.controller.abort();
296
+ flight.onIdle?.();
297
+ }
251
298
  };
252
299
  }
253
300
 
@@ -265,6 +312,54 @@ function attachFlightAbort(
265
312
  * entry. If the caller leaves before observing the result, the pipeline
266
313
  * reservation it owns is released once the flight resolves so a cancelled
267
314
  * recall never leaks quota (round 5 #2). */
315
+
316
+ /** Bound one consumer's flight wait by its OWN absolute deadline (#3514
317
+ * review). The shared pipeline belongs to every live consumer, so a firing
318
+ * deadline rejects ONLY this caller — detach drops the live refcount and the
319
+ * flight continues (or cancels at the last consumer via the flight
320
+ * controller, never because one consumer's deadline fired while others
321
+ * remain). A non-racing caller (committed keyed leader or keyed join) keeps
322
+ * awaiting once the flight is `committed`: its deadline abandons only a
323
+ * still-queued wait — the persistence contract outranks its own deadline
324
+ * mid-execution. */
325
+ function consumeWithinDeadline(
326
+ flight: RecallFlight,
327
+ request: EngramAccessRecallRequest,
328
+ race: boolean,
329
+ ): Promise<RecallExecResult> {
330
+ const deadlineAtMs = resolveClientDeadlineAtMs(request.deadlineMs, Date.now());
331
+ // Validate expiry BEFORE creating the abort race: a `settle` built then
332
+ // discarded by this early return keeps its abort listener armed, and a later
333
+ // caller abort would reject it unhandled (#3514 review).
334
+ if (deadlineAtMs !== null && deadlineAtMs <= Date.now()) {
335
+ return Promise.reject(
336
+ new EngramAccessDeadlineExceededError("recall deadline exceeded while queued"),
337
+ );
338
+ }
339
+ const settle = race
340
+ ? raceAbort(flight.promise, request.abortSignal)
341
+ : flight.promise;
342
+ if (deadlineAtMs === null) return settle;
343
+ return new Promise((resolve, reject) => {
344
+ const timer = setTimeout(() => {
345
+ if (!race && flight.committed) return;
346
+ reject(
347
+ new EngramAccessDeadlineExceededError("recall deadline exceeded while queued"),
348
+ );
349
+ }, clientDeadlineTimerMs(deadlineAtMs, Date.now()));
350
+ settle.then(
351
+ (result) => {
352
+ clearTimeout(timer);
353
+ resolve(result);
354
+ },
355
+ (err) => {
356
+ clearTimeout(timer);
357
+ reject(err);
358
+ },
359
+ );
360
+ });
361
+ }
362
+
268
363
  export async function consumeFlight(
269
364
  host: RecallCoordinatorHost,
270
365
  flight: RecallFlight,
@@ -277,9 +372,7 @@ export async function consumeFlight(
277
372
  try {
278
373
  let result: RecallExecResult;
279
374
  try {
280
- result = race
281
- ? await raceAbort(flight.promise, request.abortSignal)
282
- : await flight.promise;
375
+ result = await consumeWithinDeadline(flight, request, race);
283
376
  } catch (err) {
284
377
  // This caller left before observing the result. If it OWNS the
285
378
  // pipeline's reservation (recordBudget=false) and the flight still
@@ -502,6 +595,11 @@ export function createAndStartFlight(
502
595
  ...(persisted ? { persisted } : {}),
503
596
  };
504
597
  host.recallInFlight.set(flightKey, flight);
598
+ // The flight's own controller — not the leader's deadline — bounds the
599
+ // queued slot wait (#3514 review): each consumer's deadline detaches ONLY
600
+ // that consumer (consumeFlight), and the LAST consumer out aborts the
601
+ // controller, so queued shared work stays eligible while any live consumer
602
+ // still has budget instead of expiring on the leader's deadline alone.
505
603
  withRecallConcurrency(host, principalKey, controller.signal, async (queueWaitMs) => {
506
604
  // A slot was granted and the abort re-check in withRecallConcurrency passed
507
605
  // — the pipeline is now committing to execution. Past this point a keyed
@@ -570,7 +668,7 @@ export async function leadRecallFlight(
570
668
  // connected. Counting drops live to 0, and attachFlightAbort's
571
669
  // committed guard (!persisted || !committed) cancels the queued flight
572
670
  // while leaving a committed keyed flight to persist (round 15 #2).
573
- const consumed = await consumeFlight(host, existing, request, true, race, true);
671
+ const consumed = await consumeFlight(host, existing, normalizedRequest, true, race, true);
574
672
  capturedReservation = consumed.reservation;
575
673
  // A KEYED follower that coalesced onto the leader's flight must
576
674
  // inherit the leader's persistence outcome before reporting success.
@@ -635,7 +733,7 @@ export async function leadRecallFlight(
635
733
  // not-yet-committed pipeline (attachFlightAbort's committed guard keeps
636
734
  // a post-commit keyed flight persisting, and any additional live caller
637
735
  // keeps live > 0 so the shared flight survives) (round 14 #3).
638
- const consumed = await consumeFlight(host, flight, request, false, race, true);
736
+ const consumed = await consumeFlight(host, flight, normalizedRequest, false, race, true);
639
737
  capturedReservation = consumed.reservation;
640
738
  return consumed.response;
641
739
  },
@@ -651,7 +749,17 @@ export async function leadRecallFlight(
651
749
  // flight's `persisted` gate) that persistence failed so they behave
652
750
  // identically to this leader (release + reject) — no phantom success
653
751
  // (round 7 #1; keyed followers moved to the existing-join in round 12 #1).
654
- ownedFlight?.persisted?.reject(err);
752
+ // A CALLER-LOCAL wait failure (this leader's own deadline or abort) means
753
+ // the leader's put never ran — resolve the gate instead so a follower
754
+ // proceeds on its OWN persistence outcome instead of inheriting the
755
+ // leader's deadline while the shared flight still completes for it
756
+ // (#3514 review). The gate must still settle either way: `persisted`
757
+ // keeps the flight discoverable until it does (round 12 #2).
758
+ if (isAbortError(err) || err instanceof EngramAccessDeadlineExceededError) {
759
+ ownedFlight?.persisted?.resolve();
760
+ } else {
761
+ ownedFlight?.persisted?.reject(err);
762
+ }
655
763
  throw err;
656
764
  }
657
765
  // Leader persisted successfully — resolve the gate so keyed followers
@@ -672,6 +780,41 @@ export async function leadRecallFlight(
672
780
  return response;
673
781
  }
674
782
 
783
+ /** The degraded response for a recall whose deadline expired at admission,
784
+ * while queued for a slot, or while consuming a shared flight (#3514
785
+ * review): retrieval never started, so the result carries the missing-note
786
+ * composition and a machine-readable `retrievalFailure` — never an empty
787
+ * response indistinguishable from "no matches". */
788
+ function degradedDeadlineRecallResponse(
789
+ host: RecallCoordinatorHost,
790
+ request: EngramAccessRecallRequest,
791
+ ): EngramAccessRecallResponse {
792
+ if (
793
+ request.disclosure !== undefined &&
794
+ request.disclosure !== null &&
795
+ !isRecallDisclosure(request.disclosure)
796
+ ) {
797
+ throw new EngramAccessInputError(
798
+ `disclosure must be one of: chunk, section, raw (got: ${String(request.disclosure)})`,
799
+ );
800
+ }
801
+ const composition = composeMissingMemoryContext({ detail: "timeout" });
802
+ return {
803
+ query: request.query,
804
+ sessionKey: request.sessionKey,
805
+ namespace: request.namespace?.trim() || host.orchestrator.config.defaultNamespace,
806
+ context: composeRecallContext(composition),
807
+ contextComposition: composition,
808
+ retrievalFailure: { reason: "backend_unavailable", detail: "timeout" },
809
+ count: 0,
810
+ memoryIds: [],
811
+ results: [],
812
+ fallbackUsed: false,
813
+ sourcesUsed: [],
814
+ disclosure: request.disclosure ?? DEFAULT_RECALL_DISCLOSURE,
815
+ };
816
+ }
817
+
675
818
  /**
676
819
  * Top-level recall coordination (issue #1906): dispatch a validated recall to
677
820
  * either the non-coalesced per-request path (single-flight disabled) or the
@@ -679,22 +822,26 @@ export async function leadRecallFlight(
679
822
  * the caller through the shared access-setup capability projection so the
680
823
  * config flag is read only in capabilities.ts (#1523 scattered-gate ratchet).
681
824
  */
682
- export function coordinateRecall(
825
+ export async function coordinateRecall(
683
826
  host: RecallCoordinatorHost,
684
827
  request: EngramAccessRecallRequest,
685
828
  normalizedRequest: EngramAccessRecallRequest,
686
- requestFingerprint: Omit<EngramAccessRecallRequest, "abortSignal">,
829
+ requestFingerprint: Omit<EngramAccessRecallRequest, "abortSignal" | "deadlineMs">,
687
830
  principalKey: string,
688
831
  singleFlight: boolean,
689
832
  ): Promise<EngramAccessRecallResponse> {
833
+ try {
690
834
  if (!singleFlight) {
691
- // No coalescing: per-request execution under a concurrency slot.
692
- return withRecallConcurrency(
835
+ // No coalescing: per-request execution under a concurrency slot. The
836
+ // resolved absolute deadline also bounds the queue wait itself (#3514
837
+ // review) so a saturated semaphore cannot hold a recall past expiry.
838
+ return await withRecallConcurrency(
693
839
  host,
694
840
  principalKey,
695
841
  request.abortSignal,
696
842
  (queueWaitMs) =>
697
843
  runRecallDirect(host, request, normalizedRequest, requestFingerprint, queueWaitMs),
844
+ resolveClientDeadlineAtMs(normalizedRequest.deadlineMs, Date.now()),
698
845
  );
699
846
  }
700
847
 
@@ -734,11 +881,11 @@ export function coordinateRecall(
734
881
  // Reject at admission; the existing flight continues for its other live
735
882
  // consumers (round 10 #1).
736
883
  throwIfAborted(request.abortSignal);
737
- return followRecallFlight(host, existing, request);
884
+ return await followRecallFlight(host, existing, normalizedRequest);
738
885
  }
739
886
  // We are the leader: leadRecallFlight registers the flight synchronously in
740
887
  // this same turn, then acquires a slot to run the one shared pipeline.
741
- return leadRecallFlight(
888
+ return await leadRecallFlight(
742
889
  host,
743
890
  request,
744
891
  normalizedRequest,
@@ -746,4 +893,14 @@ export function coordinateRecall(
746
893
  flightKey,
747
894
  principalKey,
748
895
  );
896
+ } catch (err) {
897
+ // A deadline expiry at admission, in the queue, or on a shared-flight wait
898
+ // becomes the degraded recall response rather than a rejection (#3514
899
+ // review): caller cancellation stays an AbortError rejection, and every
900
+ // other failure propagates unchanged.
901
+ if (err instanceof EngramAccessDeadlineExceededError) {
902
+ return degradedDeadlineRecallResponse(host, normalizedRequest);
903
+ }
904
+ throw err;
905
+ }
749
906
  }
@@ -1,4 +1,5 @@
1
1
  import type { RecallInvocationOptions } from "./orchestration/orchestrator-helpers.js";
2
+ import { recallDeadlineSignal } from "./recall-qos.js";
2
3
 
3
4
  export type RecallCorpusVersion = { namespace: string; version: number | null };
4
5
 
@@ -20,10 +21,14 @@ export function createRecallCorpusVersionCapture(
20
21
  signal: AbortSignal | undefined,
21
22
  setVersions: (versions: RecallCorpusVersion[]) => void,
22
23
  includeNoRecall = false,
23
- timeoutMs = DEFAULT_CAPTURE_TIMEOUT_MS,
24
+ options: { timeoutMs?: number; deadlineMs?: number } = {},
24
25
  ): NonNullable<RecallInvocationOptions["onRecallPlanResolved"]> {
26
+ const timeoutMs = options.timeoutMs ?? DEFAULT_CAPTURE_TIMEOUT_MS;
27
+ // The client's own deadline bounds this capture too (issue #3499): the
28
+ // request signal alone would let a stalled lookup run the full timeout.
29
+ const captureSignal = recallDeadlineSignal(signal, options.deadlineMs);
25
30
  return async (mode, namespaces) => {
26
- if ((mode === "no_recall" && !includeNoRecall) || signal?.aborted) return;
31
+ if ((mode === "no_recall" && !includeNoRecall) || captureSignal?.aborted) return;
27
32
  const captured = await Promise.all(namespaces.map(async (namespace) => {
28
33
  let timer: ReturnType<typeof setTimeout> | undefined;
29
34
  let abortCapture: (() => void) | undefined;
@@ -31,13 +36,13 @@ export function createRecallCorpusVersionCapture(
31
36
  const timeout = new Promise<null>((resolve) => {
32
37
  timer = setTimeout(() => resolve(null), timeoutMs);
33
38
  });
34
- const aborted = signal
39
+ const aborted = captureSignal
35
40
  ? new Promise<null>((resolve) => {
36
- if (signal.aborted) {
41
+ if (captureSignal.aborted) {
37
42
  resolve(null);
38
43
  } else {
39
44
  abortCapture = () => resolve(null);
40
- signal.addEventListener("abort", abortCapture, { once: true });
45
+ captureSignal.addEventListener("abort", abortCapture, { once: true });
41
46
  }
42
47
  })
43
48
  : undefined;
@@ -51,9 +56,9 @@ export function createRecallCorpusVersionCapture(
51
56
  return { namespace, version: null };
52
57
  } finally {
53
58
  if (timer !== undefined) clearTimeout(timer);
54
- if (abortCapture) signal?.removeEventListener("abort", abortCapture);
59
+ if (abortCapture) captureSignal?.removeEventListener("abort", abortCapture);
55
60
  }
56
61
  }));
57
- if (!signal?.aborted) setVersions(captured);
62
+ if (!captureSignal?.aborted) setVersions(captured);
58
63
  };
59
64
  }
@@ -4,6 +4,7 @@
4
4
  * (#1520/#1995). Verbatim move of `AccessRecallSurface.assembleRecallResponse`
5
5
  * as a free function taking the surface's dependency bundle; behavior unchanged.
6
6
  */
7
+ import { createHash } from "node:crypto";
7
8
  import type { AccessAuditResult } from "./access-audit.js";
8
9
  import type { AccessRecallSurfaceDeps } from "./access-recall-surface.js";
9
10
  import {
@@ -14,6 +15,7 @@ import {
14
15
  import { type BudgetDecision, toBudgetWarning } from "./cross-namespace-budget.js";
15
16
  import { decideDisclosureEscalation } from "./recall-disclosure-escalation.js";
16
17
  import { type TagMatchMode, applyTagFilter, normalizeTags, parseTagMatch } from "./recall-tag-filter.js";
18
+ import { resolveRecallAuxiliaryCapabilities } from "./capabilities.js";
17
19
  import type { RecallDisclosure, RecallPlanMode } from "./types.js";
18
20
  import { displaySafeRecallSnapshot } from "./orchestration/recall-result-formatter.js";
19
21
  import {
@@ -69,9 +71,18 @@ export async function assembleRecallResponse(
69
71
  budgetDecision,
70
72
  budgetRecordPrincipal,
71
73
  } = params;
72
- const snapshot = request.sessionKey
74
+ // Only a snapshot recorded for THIS request may shape the response: a
75
+ // timed-out recall that never reached record() must not serve the
76
+ // previous query's results on the same session (issue #3499 review).
77
+ const storedSnapshot = request.sessionKey
73
78
  ? deps.orchestrator.lastRecall.get(request.sessionKey)
74
79
  : null;
80
+ const snapshot =
81
+ storedSnapshot &&
82
+ storedSnapshot.queryHash === createHash("sha256").update(query).digest("hex") &&
83
+ Date.parse(storedSnapshot.recordedAt) >= startedAt
84
+ ? storedSnapshot
85
+ : null;
75
86
  const effectiveNamespace = snapshot?.namespace
76
87
  ? deps.resolveNamespace(snapshot.namespace)
77
88
  : namespace;
@@ -222,7 +233,19 @@ export async function assembleRecallResponse(
222
233
  // than the orchestrator's native context, but a strict subset
223
234
  // safe to inject.
224
235
  const admittedIds = new Set(results.map((r) => r.id));
225
- const droppedAny = beforeIds.some((id) => !admittedIds.has(id));
236
+ // A rejected/absent snapshot serializes to zero results, so `beforeIds` is
237
+ // empty and nothing in `context` is tag-verified — a nonempty tag filter
238
+ // must still suppress that unverified memory text (#3514 review). The one
239
+ // exception is a locked secure store: its early-return context is a
240
+ // non-memory diagnostic (the unlock instructions), not recall text, so it
241
+ // survives the filter (#3514 review).
242
+ const secureStoreLocked =
243
+ snapshot === null &&
244
+ resolveRecallAuxiliaryCapabilities(deps.orchestrator.config).secureStore &&
245
+ !deps.orchestrator.storage.isSecureStoreUnlocked();
246
+ const droppedAny =
247
+ beforeIds.some((id) => !admittedIds.has(id)) ||
248
+ (snapshot === null && !secureStoreLocked && effectiveComposition.context.trim().length > 0);
226
249
  if (droppedAny) {
227
250
  const priorDegradation = effectiveComposition.degradation;
228
251
  const filteredContext = results
@@ -108,7 +108,7 @@ export interface AccessRecallSurfaceDeps {
108
108
  ): Promise<EngramAccessMemorySummary["rawExcerpts"] | null>;
109
109
  maybeAttachCodingContext(
110
110
  sessionKey: string | undefined,
111
- options: { cwd?: string; projectTag?: string },
111
+ options: { cwd?: string; projectTag?: string; authenticatedPrincipal?: string },
112
112
  ): Promise<void>;
113
113
  normalizeRecallMode(mode?: RecallPlanMode | "auto"): RecallPlanMode | undefined;
114
114
  readonly orchestrator: Orchestrator;
@@ -685,6 +685,7 @@ export class AccessRecallSurface {
685
685
  this.deps.setCodingContext({
686
686
  sessionKey: request.sessionKey,
687
687
  codingContext: request.codingContext,
688
+ authenticatedPrincipal: request.authenticatedPrincipal, remote: true,
688
689
  });
689
690
  }
690
691
  // Auto-resolve coding context from cwd/projectTag when no explicit
@@ -693,8 +694,8 @@ export class AccessRecallSurface {
693
694
  // transparently.
694
695
  if (request.codingContext === undefined && request.sessionKey) {
695
696
  await this.deps.maybeAttachCodingContext(request.sessionKey, {
696
- cwd: request.cwd,
697
- projectTag: request.projectTag,
697
+ cwd: request.cwd, projectTag: request.projectTag,
698
+ authenticatedPrincipal: request.authenticatedPrincipal,
698
699
  });
699
700
  }
700
701
  const authenticatedPrincipal = request.authenticatedPrincipal?.trim();
@@ -854,7 +855,7 @@ export class AccessRecallSurface {
854
855
  onContextComposition: (composition) => {
855
856
  contextComposition = composition;
856
857
  },
857
- onRecallPlanResolved: createRecallCorpusVersionCapture(this.deps.orchestrator, request.abortSignal, (versions) => { storageCorpusVersionsAtRecallStart = mergeRecallCorpusVersions(storageCorpusVersionsAtRecallStart, versions); }, true),
858
+ onRecallPlanResolved: createRecallCorpusVersionCapture(this.deps.orchestrator, request.abortSignal, (versions) => { storageCorpusVersionsAtRecallStart = mergeRecallCorpusVersions(storageCorpusVersionsAtRecallStart, versions); }, true, { deadlineMs: request.deadlineMs }),
858
859
  ...(authenticatedPrincipal ? { principalOverride: authenticatedPrincipal } : {}),
859
860
  ...(request.sourceConnector ? { sourceConnector: request.sourceConnector } : {}),
860
861
  ...(request.stateView !== undefined ? { stateView: request.stateView } : {}),
@@ -867,6 +868,7 @@ export class AccessRecallSurface {
867
868
  : {}),
868
869
  };
869
870
  if (request.searchOptions) recallOptions.searchOptions = request.searchOptions;
871
+ if (request.deadlineMs !== undefined) recallOptions.deadlineMs = request.deadlineMs;
870
872
  const startedAt = Date.now();
871
873
  // #1906 atomic budget admission: the peek loop above and this record are
872
874
  // one synchronous JS turn (no await between them), so record()'s own
@@ -179,6 +179,15 @@ export const recallRequestSchema = z.object({
179
179
  stateView: z.boolean().optional(),
180
180
  /** QMD search options for this recall only (`query` tool path). */
181
181
  searchOptions: recallQmdSearchOptionsSchema.optional(),
182
+ /**
183
+ * Client's own budget for this recall (issue #3499). Epoch-sized values
184
+ * are an absolute deadline; smaller values read as a relative budget —
185
+ * the force-flush convention (issue #3140). The daemon clamps its outer
186
+ * deadline to the tighter of this and `recallOuterTimeoutMs`, so a client
187
+ * whose hook dies sooner gets a degraded recall inside what remains
188
+ * instead of an answer it can no longer use.
189
+ */
190
+ deadlineMs: deadlineMsSchema,
182
191
  });
183
192
 
184
193
  export const recallExplainRequestSchema = z.object({
@@ -25,6 +25,7 @@
25
25
  * All fixtures are synthetic — no real user data.
26
26
  */
27
27
  import assert from "node:assert/strict";
28
+ import { createHash } from "node:crypto";
28
29
  import test from "node:test";
29
30
 
30
31
  import { EngramAccessService } from "./access-service.js";
@@ -86,8 +87,12 @@ function makeRawExcerptProbe(options: {
86
87
 
87
88
  const snapshot: LastRecallSnapshot = {
88
89
  sessionKey: options.sessionKey,
89
- recordedAt: new Date().toISOString(),
90
- queryHash: "hash",
90
+ // Reads as recorded inside this request (the response path gates on
91
+ // recordedAt >= request start + the request query's hash — #3499).
92
+ recordedAt: new Date(Date.now() + 60_000).toISOString(),
93
+ queryHash: createHash("sha256")
94
+ .update("what database are we using?")
95
+ .digest("hex"),
91
96
  queryLen: 5,
92
97
  memoryIds: [],
93
98
  namespace: options.snapshotNamespace,