@remnic/core 10.0.144 → 10.0.146

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 (385) hide show
  1. package/dist/access-admin-ops-surface.js +189 -183
  2. package/dist/access-cli.js +189 -183
  3. package/dist/access-cli.js.map +1 -1
  4. package/dist/access-correlation.d.ts +4 -0
  5. package/dist/access-correlation.d.ts.map +1 -0
  6. package/dist/access-correlation.js +10 -0
  7. package/dist/access-extraction-force-flush-preempt.js +189 -183
  8. package/dist/access-extraction-force-flush.js +189 -183
  9. package/dist/access-http-briefing.js +189 -183
  10. package/dist/access-http-query.js +189 -183
  11. package/dist/access-http.d.ts.map +1 -1
  12. package/dist/access-http.js +189 -183
  13. package/dist/access-identity-continuity-surface.js +189 -183
  14. package/dist/access-lcm-surface.js +189 -183
  15. package/dist/access-mcp.js +189 -183
  16. package/dist/access-observe-write-category.js +13 -13
  17. package/dist/access-observe-write-surface.d.ts.map +1 -1
  18. package/dist/access-observe-write-surface.js +189 -183
  19. package/dist/access-offline-manifest.js +11 -11
  20. package/dist/access-operations-batch.js +189 -183
  21. package/dist/access-operations.js +189 -183
  22. package/dist/access-recall-concurrency.js +189 -183
  23. package/dist/access-recall-diagnostics.js +2 -2
  24. package/dist/access-recall-response.js +189 -183
  25. package/dist/access-recall-surface.js +189 -183
  26. package/dist/access-schema.js +9 -9
  27. package/dist/access-service.d.ts.map +1 -1
  28. package/dist/access-service.js +189 -183
  29. package/dist/active-recall.js +33 -33
  30. package/dist/adapters/index.js +4 -4
  31. package/dist/adapters/registry.js +2 -2
  32. package/dist/auto-sync-PSZJHHXB.js +2 -2
  33. package/dist/briefing.js +22 -22
  34. package/dist/buffer-add-turns-bounded.d.ts +27 -0
  35. package/dist/buffer-add-turns-bounded.d.ts.map +1 -0
  36. package/dist/buffer-add-turns-bounded.js +13 -0
  37. package/dist/buffer-admission-idempotency.d.ts +18 -0
  38. package/dist/buffer-admission-idempotency.d.ts.map +1 -0
  39. package/dist/buffer-admission-idempotency.js +18 -0
  40. package/dist/buffer-persistence.d.ts +4 -0
  41. package/dist/buffer-persistence.d.ts.map +1 -1
  42. package/dist/buffer-persistence.js +1 -1
  43. package/dist/buffer-turn-helpers.d.ts.map +1 -1
  44. package/dist/buffer-turn-helpers.js +1 -1
  45. package/dist/buffer-types.d.ts.map +1 -1
  46. package/dist/buffer.d.ts +11 -0
  47. package/dist/buffer.d.ts.map +1 -1
  48. package/dist/buffer.js +15 -10
  49. package/dist/calibration.js +4 -4
  50. package/dist/{capsule-crypto-YO5QJ6L3.js → capsule-crypto-7FJQINUR.js} +2 -2
  51. package/dist/capsule-crypto-7FJQINUR.js.map +1 -0
  52. package/dist/causal-behavior.js +2 -2
  53. package/dist/causal-chain.js +2 -2
  54. package/dist/causal-consolidation.js +25 -25
  55. package/dist/causal-retrieval.js +2 -2
  56. package/dist/causal-trajectory-graph.js +3 -3
  57. package/dist/causal-trajectory.js +1 -1
  58. package/dist/{chunk-AWKD2A73.js → chunk-2NGTY22Z.js} +12 -12
  59. package/dist/{chunk-BXLOS5AJ.js → chunk-2NLLXCJG.js} +2 -2
  60. package/dist/{chunk-EDGWAJLS.js → chunk-2WD2TRTJ.js} +2 -2
  61. package/dist/{chunk-AZFQXYIJ.js → chunk-33VVVP57.js} +9 -2
  62. package/dist/{chunk-AZFQXYIJ.js.map → chunk-33VVVP57.js.map} +1 -1
  63. package/dist/{chunk-AOZYOS4G.js → chunk-3MXQ5XJT.js} +2 -2
  64. package/dist/{chunk-XGDWR2L6.js → chunk-3NLBDM7V.js} +2 -2
  65. package/dist/{chunk-XVZA6VXC.js → chunk-3SL52JKD.js} +4 -4
  66. package/dist/chunk-4IJBNRMZ.js +45 -0
  67. package/dist/chunk-4IJBNRMZ.js.map +1 -0
  68. package/dist/{chunk-LE27GU4M.js → chunk-4N4BAO66.js} +2 -2
  69. package/dist/{chunk-UC3KG7KX.js → chunk-4WX32RLU.js} +3 -3
  70. package/dist/{chunk-WVV54HL2.js → chunk-4Y4LPKFV.js} +7 -7
  71. package/dist/{chunk-MFDEEOOZ.js → chunk-5BE3FLKL.js} +4 -4
  72. package/dist/chunk-5EP2V675.js +60 -0
  73. package/dist/chunk-5EP2V675.js.map +1 -0
  74. package/dist/chunk-5JD4DXQX.js +91 -0
  75. package/dist/chunk-5JD4DXQX.js.map +1 -0
  76. package/dist/{chunk-MPQQIHA7.js → chunk-5LL2X5SO.js} +2 -2
  77. package/dist/{chunk-CBJRI6VJ.js → chunk-64TIBZPZ.js} +2 -2
  78. package/dist/{chunk-LL7WIK2Z.js → chunk-6NPLVV6M.js} +2 -2
  79. package/dist/{chunk-DC55RIEZ.js → chunk-73TPOGS4.js} +9 -9
  80. package/dist/{chunk-XF2QQQXO.js → chunk-7P72BY4F.js} +2 -2
  81. package/dist/{chunk-XUKBX3GO.js → chunk-7YHU3NJD.js} +15 -15
  82. package/dist/chunk-7ZFB4VZS.js +73 -0
  83. package/dist/chunk-7ZFB4VZS.js.map +1 -0
  84. package/dist/{chunk-6CSWINXA.js → chunk-AIDFYS4Z.js} +14 -14
  85. package/dist/{chunk-E23BTVB2.js → chunk-AO5LKFGO.js} +4 -4
  86. package/dist/{chunk-G4NKURT4.js → chunk-C6S353AG.js} +30 -1
  87. package/dist/chunk-C6S353AG.js.map +1 -0
  88. package/dist/{chunk-JY3WATTF.js → chunk-C6Z3H23R.js} +2 -2
  89. package/dist/{chunk-FWDVW2BD.js → chunk-CAWVPY6E.js} +499 -480
  90. package/dist/chunk-CAWVPY6E.js.map +1 -0
  91. package/dist/{chunk-VAVCFMMQ.js → chunk-CJ2SYU4S.js} +2 -2
  92. package/dist/{chunk-WZ55LEUN.js → chunk-CLVILSBR.js} +22 -22
  93. package/dist/{chunk-B72X3KWL.js → chunk-COJBTRTQ.js} +2 -2
  94. package/dist/{chunk-NWS4I4K7.js → chunk-CVCKYMVX.js} +2 -2
  95. package/dist/{chunk-2LQUPEWF.js → chunk-EJ6EPEMP.js} +36 -33
  96. package/dist/chunk-EJ6EPEMP.js.map +1 -0
  97. package/dist/{chunk-6MEQHJTF.js → chunk-FMFCQRDM.js} +3 -3
  98. package/dist/{chunk-A3EWNU5V.js → chunk-G2TK5YYU.js} +2 -2
  99. package/dist/{chunk-WWQMZBDI.js → chunk-GCHM5BYL.js} +4 -4
  100. package/dist/{chunk-RHQSAXN3.js → chunk-GCQIXPWZ.js} +2 -2
  101. package/dist/{chunk-VEFGHRKV.js → chunk-GMO3BGOF.js} +1 -1
  102. package/dist/{chunk-I3UBDUHO.js → chunk-H6OTEBPK.js} +2 -2
  103. package/dist/{chunk-MIG4KRYU.js → chunk-HADCITEA.js} +8 -8
  104. package/dist/{chunk-M43GO34S.js → chunk-HASIFVWH.js} +2 -2
  105. package/dist/{chunk-RQBYC7EK.js → chunk-HLWXCDUQ.js} +2 -2
  106. package/dist/{chunk-JVSHXYOO.js → chunk-HOGSBSCH.js} +2 -2
  107. package/dist/{chunk-BFPF5N3H.js → chunk-HXFIILGF.js} +4 -4
  108. package/dist/{chunk-2JAT4S7N.js → chunk-IMULTENA.js} +2 -2
  109. package/dist/{chunk-B4I37XX6.js → chunk-IOMWNBMH.js} +15 -15
  110. package/dist/{chunk-74BX5NCU.js → chunk-IXR3SNHL.js} +2 -2
  111. package/dist/{chunk-2S4XW47C.js → chunk-J3EU5H7W.js} +2 -2
  112. package/dist/{chunk-EUL3S3LE.js → chunk-J5WI4QRP.js} +4 -4
  113. package/dist/{chunk-N7LYEA3K.js → chunk-JOQZRIL4.js} +2 -2
  114. package/dist/{chunk-DLX277NS.js → chunk-JXAHMR5L.js} +2 -2
  115. package/dist/{chunk-POXJ3KXJ.js → chunk-KG7RO5XU.js} +3 -3
  116. package/dist/{chunk-JVNGFQJN.js → chunk-KJ3Z7JHF.js} +1 -1
  117. package/dist/{chunk-JVNGFQJN.js.map → chunk-KJ3Z7JHF.js.map} +1 -1
  118. package/dist/{chunk-R45L4TV6.js → chunk-KQAFEZQX.js} +6 -6
  119. package/dist/{chunk-L6CMR5OI.js → chunk-L2DACC2T.js} +2 -2
  120. package/dist/{chunk-77SYM565.js → chunk-LD7I5AZW.js} +9 -9
  121. package/dist/{chunk-OYUTSLBU.js → chunk-LKXED2DT.js} +14 -14
  122. package/dist/{chunk-3KQPFIVV.js → chunk-LMFINE37.js} +2 -2
  123. package/dist/{chunk-OYHGCAGQ.js → chunk-LYM65HMS.js} +2 -2
  124. package/dist/{chunk-OV3XHQAB.js → chunk-LYSE5FNF.js} +43 -48
  125. package/dist/chunk-LYSE5FNF.js.map +1 -0
  126. package/dist/{chunk-MEALRZYB.js → chunk-MKJBZR7J.js} +2 -2
  127. package/dist/{chunk-AGJJTD3Q.js → chunk-MONIOXEG.js} +2 -2
  128. package/dist/{chunk-RVUD4WN3.js → chunk-ND7ZKKVK.js} +2 -2
  129. package/dist/{chunk-PKPW7MXT.js → chunk-O7CHKXSF.js} +4 -4
  130. package/dist/{chunk-UH3FPX3L.js → chunk-OM5ESBES.js} +2 -2
  131. package/dist/{chunk-Y6IRNAWT.js → chunk-OSM5MKAU.js} +2 -2
  132. package/dist/chunk-PXY2B7BG.js +51 -0
  133. package/dist/chunk-PXY2B7BG.js.map +1 -0
  134. package/dist/{chunk-5IGWEYNV.js → chunk-QDY4TSKK.js} +3 -3
  135. package/dist/{chunk-IJBOJJVS.js → chunk-QP6CBFYL.js} +2 -2
  136. package/dist/{chunk-MZCGHPIJ.js → chunk-RB7NXZ2E.js} +2 -2
  137. package/dist/{chunk-FJVWKIDV.js → chunk-RMPHPB6B.js} +2 -2
  138. package/dist/{chunk-QPOWOQYH.js → chunk-RXXXT5PA.js} +6 -6
  139. package/dist/{chunk-FYH62SF3.js → chunk-S627NPRV.js} +6 -6
  140. package/dist/{chunk-YCNSMVWG.js → chunk-SDGD6MYV.js} +64 -3
  141. package/dist/chunk-SDGD6MYV.js.map +1 -0
  142. package/dist/{chunk-6DHSEJIO.js → chunk-SXVU57SW.js} +2 -2
  143. package/dist/{chunk-YWXFO7G2.js → chunk-TAUBEJ37.js} +5 -5
  144. package/dist/{chunk-GOZXQNIM.js → chunk-TH6OYP6I.js} +3 -3
  145. package/dist/{chunk-QJJURIZV.js → chunk-TNACU47L.js} +3 -3
  146. package/dist/{chunk-4Y26S76X.js → chunk-TRFSTCQK.js} +14 -2
  147. package/dist/chunk-TRFSTCQK.js.map +1 -0
  148. package/dist/{chunk-YLTU2DC4.js → chunk-U2PSE7MB.js} +2 -2
  149. package/dist/{chunk-2VS3DAXE.js → chunk-V3D2OOVE.js} +2 -2
  150. package/dist/{chunk-PCMGMPQZ.js → chunk-X4EF7IG3.js} +4 -4
  151. package/dist/{chunk-DQEMWVMT.js → chunk-X7Y7WX73.js} +1 -1
  152. package/dist/{chunk-CBTERRF5.js → chunk-XCJDDXJX.js} +2 -2
  153. package/dist/{chunk-RSRHWNNM.js → chunk-XPDMJC5O.js} +3 -3
  154. package/dist/{chunk-NLSMLRH4.js → chunk-XTGQTSZZ.js} +2 -2
  155. package/dist/{chunk-EZ25VE3G.js → chunk-YNDLCWXS.js} +4 -4
  156. package/dist/chunk-YRHBSYQR.js +15 -0
  157. package/dist/chunk-YRHBSYQR.js.map +1 -0
  158. package/dist/{chunk-VEPT6DXJ.js → chunk-YVK7WZYC.js} +5 -5
  159. package/dist/{chunk-2IMKMMUS.js → chunk-ZDWZYKCL.js} +11 -11
  160. package/dist/{chunk-FAPJG3OG.js → chunk-ZDZJNXL6.js} +4 -4
  161. package/dist/{chunk-BNQJKWWZ.js → chunk-ZG4GNPRE.js} +8 -8
  162. package/dist/cli.js +189 -183
  163. package/dist/coding/export-okf-codegraph.js +21 -21
  164. package/dist/coding/pre-action-gate.js +2 -2
  165. package/dist/compounding/engine.js +23 -23
  166. package/dist/config.js +33 -33
  167. package/dist/connectors/codex-materialize-runner.js +22 -22
  168. package/dist/connectors/index.js +22 -22
  169. package/dist/contradiction/index.js +7 -7
  170. package/dist/convergence-refresh.js +24 -24
  171. package/dist/corpus-watermark.js +24 -24
  172. package/dist/dashboard-runtime.js +2 -2
  173. package/dist/deep-recall-http-glue.js +10 -10
  174. package/dist/deep-recall.js +2 -2
  175. package/dist/entity-retrieval.js +25 -25
  176. package/dist/event-order-recall.js +4 -4
  177. package/dist/explicit-capture.js +189 -183
  178. package/dist/extraction-span-materialize.js +2 -2
  179. package/dist/extraction.js +32 -32
  180. package/dist/{graph-edge-decay-EKWXRBWF.js → graph-edge-decay-BC3IO2J4.js} +6 -6
  181. package/dist/graph-edge-decay-BC3IO2J4.js.map +1 -0
  182. package/dist/graph-jsonl.js +4 -4
  183. package/dist/graph-snapshot.js +4 -4
  184. package/dist/graph.js +5 -5
  185. package/dist/harmonic-retrieval.js +22 -22
  186. package/dist/index.js +324 -318
  187. package/dist/lcm/engine.js +3 -3
  188. package/dist/lcm/index.js +9 -9
  189. package/dist/local-llm.js +3 -3
  190. package/dist/location/index.js +23 -23
  191. package/dist/maintenance/memory-governance.js +22 -22
  192. package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +22 -22
  193. package/dist/maintenance/rebuild-memory-projection-runner.js +24 -24
  194. package/dist/maintenance/rebuild-memory-projection.js +23 -23
  195. package/dist/memory-browse.js +7 -7
  196. package/dist/memory-subject.js +1 -1
  197. package/dist/namespaces/migrate.js +23 -23
  198. package/dist/namespaces/search.js +7 -7
  199. package/dist/namespaces/storage.js +22 -22
  200. package/dist/offline-sync-changeset-generations.js +3 -3
  201. package/dist/offline-sync-embedding-generation.js +2 -2
  202. package/dist/offline-sync-snapshot-stream.js +6 -6
  203. package/dist/offline-sync.js +7 -7
  204. package/dist/operator-doctor-corpus.js +25 -25
  205. package/dist/operator-toolkit.js +43 -43
  206. package/dist/orchestration/backlog-scheduler.js +190 -184
  207. package/dist/orchestration/backlog-scheduler.js.map +1 -1
  208. package/dist/orchestration/buffer-drain-runner.js +190 -184
  209. package/dist/orchestration/maintenance.js +34 -34
  210. package/dist/orchestration/recall-internal.d.ts.map +1 -1
  211. package/dist/orchestration/turn-ingestion-buffered.d.ts +13 -0
  212. package/dist/orchestration/turn-ingestion-buffered.d.ts.map +1 -0
  213. package/dist/orchestration/turn-ingestion.d.ts +2 -2
  214. package/dist/orchestration/turn-ingestion.d.ts.map +1 -1
  215. package/dist/orchestrator.js +189 -183
  216. package/dist/qmd.js +3 -3
  217. package/dist/recall-attempt-timing.d.ts +18 -0
  218. package/dist/recall-attempt-timing.d.ts.map +1 -0
  219. package/dist/recall-attempt-timing.js +14 -0
  220. package/dist/recall-attempt-timing.js.map +1 -0
  221. package/dist/recall-enrichment-promise.d.ts +22 -0
  222. package/dist/recall-enrichment-promise.d.ts.map +1 -0
  223. package/dist/recall-enrichment-promise.js +10 -0
  224. package/dist/recall-enrichment-promise.js.map +1 -0
  225. package/dist/recall-explain-renderer.js +3 -3
  226. package/dist/recall-navigate-access.js +2 -2
  227. package/dist/recall-navigate-disclosure.js +2 -2
  228. package/dist/recall-navigate.js +2 -2
  229. package/dist/recall-navigation.js +189 -183
  230. package/dist/recall-phase2-timing.d.ts +44 -0
  231. package/dist/recall-phase2-timing.d.ts.map +1 -0
  232. package/dist/recall-phase2-timing.js +22 -0
  233. package/dist/recall-phase2-timing.js.map +1 -0
  234. package/dist/recall-state-view-admission.js +6 -6
  235. package/dist/recall-timings.d.ts +35 -0
  236. package/dist/recall-timings.d.ts.map +1 -1
  237. package/dist/recall-timings.js +2 -1
  238. package/dist/recall-why-service.js +8 -8
  239. package/dist/recall-xray-cli.js +4 -4
  240. package/dist/recall-xray-renderer.js +3 -3
  241. package/dist/recall-xray.js +2 -2
  242. package/dist/reconcile/manifest.js +3 -3
  243. package/dist/{resolution-A3NAI3YE.js → resolution-TCO63RRC.js} +8 -8
  244. package/dist/resolution-TCO63RRC.js.map +1 -0
  245. package/dist/resume-bundles.js +34 -34
  246. package/dist/salvage-envelope.js +1 -1
  247. package/dist/search/factory.js +6 -6
  248. package/dist/search/index.js +10 -10
  249. package/dist/semantic-consolidation.js +23 -23
  250. package/dist/semantic-rule-promotion.js +22 -22
  251. package/dist/semantic-rule-verifier.js +22 -22
  252. package/dist/source-agent-qualifier.js +25 -25
  253. package/dist/standup/build.js +22 -22
  254. package/dist/storage/buffer-drain-claims.js +2 -2
  255. package/dist/storage/buffer-session-files.d.ts +4 -0
  256. package/dist/storage/buffer-session-files.d.ts.map +1 -1
  257. package/dist/storage/buffer-session-files.js +2 -2
  258. package/dist/storage.d.ts +1 -0
  259. package/dist/storage.d.ts.map +1 -1
  260. package/dist/storage.js +22 -22
  261. package/dist/subject-config.js +1 -1
  262. package/dist/summarizer.js +5 -5
  263. package/dist/support-passport/index.js +8 -8
  264. package/dist/transfer/autodetect.js +1 -1
  265. package/dist/transfer/backup.js +2 -2
  266. package/dist/transfer/capsule-export.js +3 -3
  267. package/dist/transfer/capsule-import.js +2 -2
  268. package/dist/transfer/export-okf.js +23 -23
  269. package/dist/types.d.ts +2 -0
  270. package/dist/types.d.ts.map +1 -1
  271. package/dist/types.js +1 -1
  272. package/dist/verified-recall.js +22 -22
  273. package/dist/who-knows-cli.js +23 -23
  274. package/dist/who-knows.js +22 -22
  275. package/dist/write-envelope.js +1 -1
  276. package/package.json +2 -2
  277. package/src/access-correlation.ts +17 -0
  278. package/src/access-http.ts +7 -8
  279. package/src/access-observe-write-surface.ts +10 -0
  280. package/src/access-service.ts +3 -1
  281. package/src/buffer-add-turns-bounded.ts +97 -0
  282. package/src/buffer-admission-idempotency.test.ts +297 -0
  283. package/src/buffer-admission-idempotency.ts +67 -0
  284. package/src/buffer-drain-handover.test.ts +1 -0
  285. package/src/buffer-persistence.ts +19 -1
  286. package/src/buffer-turn-helpers.ts +8 -1
  287. package/src/buffer-types.ts +1 -0
  288. package/src/buffer.ts +40 -43
  289. package/src/orchestration/recall-internal.ts +63 -75
  290. package/src/orchestration/turn-ingestion-buffered.ts +74 -0
  291. package/src/orchestration/turn-ingestion.ts +4 -78
  292. package/src/recall-attempt-timing.ts +78 -0
  293. package/src/recall-enrichment-promise.ts +62 -0
  294. package/src/recall-phase2-timing.ts +146 -0
  295. package/src/recall-timings-access.test.ts +140 -2
  296. package/src/recall-timings-request-contract.test.ts +488 -0
  297. package/src/recall-timings.ts +70 -0
  298. package/src/storage/buffer-session-files.ts +71 -0
  299. package/src/storage.ts +1 -0
  300. package/src/types.ts +2 -0
  301. package/dist/chunk-2LQUPEWF.js.map +0 -1
  302. package/dist/chunk-4Y26S76X.js.map +0 -1
  303. package/dist/chunk-FWDVW2BD.js.map +0 -1
  304. package/dist/chunk-G4NKURT4.js.map +0 -1
  305. package/dist/chunk-OV3XHQAB.js.map +0 -1
  306. package/dist/chunk-YCNSMVWG.js.map +0 -1
  307. /package/dist/{capsule-crypto-YO5QJ6L3.js.map → access-correlation.js.map} +0 -0
  308. /package/dist/{graph-edge-decay-EKWXRBWF.js.map → buffer-add-turns-bounded.js.map} +0 -0
  309. /package/dist/{resolution-A3NAI3YE.js.map → buffer-admission-idempotency.js.map} +0 -0
  310. /package/dist/{chunk-AWKD2A73.js.map → chunk-2NGTY22Z.js.map} +0 -0
  311. /package/dist/{chunk-BXLOS5AJ.js.map → chunk-2NLLXCJG.js.map} +0 -0
  312. /package/dist/{chunk-EDGWAJLS.js.map → chunk-2WD2TRTJ.js.map} +0 -0
  313. /package/dist/{chunk-AOZYOS4G.js.map → chunk-3MXQ5XJT.js.map} +0 -0
  314. /package/dist/{chunk-XGDWR2L6.js.map → chunk-3NLBDM7V.js.map} +0 -0
  315. /package/dist/{chunk-XVZA6VXC.js.map → chunk-3SL52JKD.js.map} +0 -0
  316. /package/dist/{chunk-LE27GU4M.js.map → chunk-4N4BAO66.js.map} +0 -0
  317. /package/dist/{chunk-UC3KG7KX.js.map → chunk-4WX32RLU.js.map} +0 -0
  318. /package/dist/{chunk-WVV54HL2.js.map → chunk-4Y4LPKFV.js.map} +0 -0
  319. /package/dist/{chunk-MFDEEOOZ.js.map → chunk-5BE3FLKL.js.map} +0 -0
  320. /package/dist/{chunk-MPQQIHA7.js.map → chunk-5LL2X5SO.js.map} +0 -0
  321. /package/dist/{chunk-CBJRI6VJ.js.map → chunk-64TIBZPZ.js.map} +0 -0
  322. /package/dist/{chunk-LL7WIK2Z.js.map → chunk-6NPLVV6M.js.map} +0 -0
  323. /package/dist/{chunk-DC55RIEZ.js.map → chunk-73TPOGS4.js.map} +0 -0
  324. /package/dist/{chunk-XF2QQQXO.js.map → chunk-7P72BY4F.js.map} +0 -0
  325. /package/dist/{chunk-XUKBX3GO.js.map → chunk-7YHU3NJD.js.map} +0 -0
  326. /package/dist/{chunk-6CSWINXA.js.map → chunk-AIDFYS4Z.js.map} +0 -0
  327. /package/dist/{chunk-E23BTVB2.js.map → chunk-AO5LKFGO.js.map} +0 -0
  328. /package/dist/{chunk-JY3WATTF.js.map → chunk-C6Z3H23R.js.map} +0 -0
  329. /package/dist/{chunk-VAVCFMMQ.js.map → chunk-CJ2SYU4S.js.map} +0 -0
  330. /package/dist/{chunk-WZ55LEUN.js.map → chunk-CLVILSBR.js.map} +0 -0
  331. /package/dist/{chunk-B72X3KWL.js.map → chunk-COJBTRTQ.js.map} +0 -0
  332. /package/dist/{chunk-NWS4I4K7.js.map → chunk-CVCKYMVX.js.map} +0 -0
  333. /package/dist/{chunk-6MEQHJTF.js.map → chunk-FMFCQRDM.js.map} +0 -0
  334. /package/dist/{chunk-A3EWNU5V.js.map → chunk-G2TK5YYU.js.map} +0 -0
  335. /package/dist/{chunk-WWQMZBDI.js.map → chunk-GCHM5BYL.js.map} +0 -0
  336. /package/dist/{chunk-RHQSAXN3.js.map → chunk-GCQIXPWZ.js.map} +0 -0
  337. /package/dist/{chunk-VEFGHRKV.js.map → chunk-GMO3BGOF.js.map} +0 -0
  338. /package/dist/{chunk-I3UBDUHO.js.map → chunk-H6OTEBPK.js.map} +0 -0
  339. /package/dist/{chunk-MIG4KRYU.js.map → chunk-HADCITEA.js.map} +0 -0
  340. /package/dist/{chunk-M43GO34S.js.map → chunk-HASIFVWH.js.map} +0 -0
  341. /package/dist/{chunk-RQBYC7EK.js.map → chunk-HLWXCDUQ.js.map} +0 -0
  342. /package/dist/{chunk-JVSHXYOO.js.map → chunk-HOGSBSCH.js.map} +0 -0
  343. /package/dist/{chunk-BFPF5N3H.js.map → chunk-HXFIILGF.js.map} +0 -0
  344. /package/dist/{chunk-2JAT4S7N.js.map → chunk-IMULTENA.js.map} +0 -0
  345. /package/dist/{chunk-B4I37XX6.js.map → chunk-IOMWNBMH.js.map} +0 -0
  346. /package/dist/{chunk-74BX5NCU.js.map → chunk-IXR3SNHL.js.map} +0 -0
  347. /package/dist/{chunk-2S4XW47C.js.map → chunk-J3EU5H7W.js.map} +0 -0
  348. /package/dist/{chunk-EUL3S3LE.js.map → chunk-J5WI4QRP.js.map} +0 -0
  349. /package/dist/{chunk-N7LYEA3K.js.map → chunk-JOQZRIL4.js.map} +0 -0
  350. /package/dist/{chunk-DLX277NS.js.map → chunk-JXAHMR5L.js.map} +0 -0
  351. /package/dist/{chunk-POXJ3KXJ.js.map → chunk-KG7RO5XU.js.map} +0 -0
  352. /package/dist/{chunk-R45L4TV6.js.map → chunk-KQAFEZQX.js.map} +0 -0
  353. /package/dist/{chunk-L6CMR5OI.js.map → chunk-L2DACC2T.js.map} +0 -0
  354. /package/dist/{chunk-77SYM565.js.map → chunk-LD7I5AZW.js.map} +0 -0
  355. /package/dist/{chunk-OYUTSLBU.js.map → chunk-LKXED2DT.js.map} +0 -0
  356. /package/dist/{chunk-3KQPFIVV.js.map → chunk-LMFINE37.js.map} +0 -0
  357. /package/dist/{chunk-OYHGCAGQ.js.map → chunk-LYM65HMS.js.map} +0 -0
  358. /package/dist/{chunk-MEALRZYB.js.map → chunk-MKJBZR7J.js.map} +0 -0
  359. /package/dist/{chunk-AGJJTD3Q.js.map → chunk-MONIOXEG.js.map} +0 -0
  360. /package/dist/{chunk-RVUD4WN3.js.map → chunk-ND7ZKKVK.js.map} +0 -0
  361. /package/dist/{chunk-PKPW7MXT.js.map → chunk-O7CHKXSF.js.map} +0 -0
  362. /package/dist/{chunk-UH3FPX3L.js.map → chunk-OM5ESBES.js.map} +0 -0
  363. /package/dist/{chunk-Y6IRNAWT.js.map → chunk-OSM5MKAU.js.map} +0 -0
  364. /package/dist/{chunk-5IGWEYNV.js.map → chunk-QDY4TSKK.js.map} +0 -0
  365. /package/dist/{chunk-IJBOJJVS.js.map → chunk-QP6CBFYL.js.map} +0 -0
  366. /package/dist/{chunk-MZCGHPIJ.js.map → chunk-RB7NXZ2E.js.map} +0 -0
  367. /package/dist/{chunk-FJVWKIDV.js.map → chunk-RMPHPB6B.js.map} +0 -0
  368. /package/dist/{chunk-QPOWOQYH.js.map → chunk-RXXXT5PA.js.map} +0 -0
  369. /package/dist/{chunk-FYH62SF3.js.map → chunk-S627NPRV.js.map} +0 -0
  370. /package/dist/{chunk-6DHSEJIO.js.map → chunk-SXVU57SW.js.map} +0 -0
  371. /package/dist/{chunk-YWXFO7G2.js.map → chunk-TAUBEJ37.js.map} +0 -0
  372. /package/dist/{chunk-GOZXQNIM.js.map → chunk-TH6OYP6I.js.map} +0 -0
  373. /package/dist/{chunk-QJJURIZV.js.map → chunk-TNACU47L.js.map} +0 -0
  374. /package/dist/{chunk-YLTU2DC4.js.map → chunk-U2PSE7MB.js.map} +0 -0
  375. /package/dist/{chunk-2VS3DAXE.js.map → chunk-V3D2OOVE.js.map} +0 -0
  376. /package/dist/{chunk-PCMGMPQZ.js.map → chunk-X4EF7IG3.js.map} +0 -0
  377. /package/dist/{chunk-DQEMWVMT.js.map → chunk-X7Y7WX73.js.map} +0 -0
  378. /package/dist/{chunk-CBTERRF5.js.map → chunk-XCJDDXJX.js.map} +0 -0
  379. /package/dist/{chunk-RSRHWNNM.js.map → chunk-XPDMJC5O.js.map} +0 -0
  380. /package/dist/{chunk-NLSMLRH4.js.map → chunk-XTGQTSZZ.js.map} +0 -0
  381. /package/dist/{chunk-EZ25VE3G.js.map → chunk-YNDLCWXS.js.map} +0 -0
  382. /package/dist/{chunk-VEPT6DXJ.js.map → chunk-YVK7WZYC.js.map} +0 -0
  383. /package/dist/{chunk-2IMKMMUS.js.map → chunk-ZDWZYKCL.js.map} +0 -0
  384. /package/dist/{chunk-FAPJG3OG.js.map → chunk-ZDZJNXL6.js.map} +0 -0
  385. /package/dist/{chunk-BNQJKWWZ.js.map → chunk-ZG4GNPRE.js.map} +0 -0
@@ -0,0 +1,488 @@
1
+ import assert from "node:assert/strict";
2
+ import { mkdtemp } from "node:fs/promises";
3
+ import os from "node:os";
4
+ import path from "node:path";
5
+ import test, { mock } from "node:test";
6
+ import { z } from "zod";
7
+
8
+ import { currentCorrelationId } from "./access-correlation.js";
9
+ import { recordAbstractionNode } from "./abstraction-nodes.js";
10
+ import { EngramAccessHttpServer } from "./access-http.js";
11
+ import { EngramAccessService } from "./access-service.js";
12
+ import { CompoundingEngine } from "./compounding/engine.js";
13
+ import { parseConfig } from "./config.js";
14
+ import { rebuildMemoryProjection } from "./maintenance/rebuild-memory-projection.js";
15
+ import { Orchestrator } from "./orchestrator.js";
16
+ import {
17
+ PHASE2_AWAIT_STATUSES,
18
+ type Phase2AwaitStatus,
19
+ } from "./recall-phase2-timing.js";
20
+ import { getRecallTimings } from "./recall-timings.js";
21
+ import { StorageManager } from "./storage.js";
22
+ import { cleanupDir, eventually } from "./testing/orchestrator-lite.js";
23
+ import type { MemoryFile, QmdSearchResult } from "./types.js";
24
+ import type { SearchBackend } from "./search/port.js";
25
+
26
+ test.afterEach(() => {
27
+ mock.restoreAll();
28
+ });
29
+
30
+ const UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
31
+
32
+ interface ConfigOverrides {
33
+ qmdEnabled?: boolean;
34
+ harmonicRetrievalEnabled?: boolean;
35
+ queryAwareIndexingEnabled?: boolean;
36
+ compoundingEnabled?: boolean;
37
+ recallEnrichmentDeadlineMs?: number;
38
+ recallOuterTimeoutMs?: number;
39
+ }
40
+
41
+ function makeConfig(memoryDir: string, overrides: ConfigOverrides = {}) {
42
+ return parseConfig({
43
+ openaiApiKey: "sk-test",
44
+ memoryDir,
45
+ workspaceDir: path.join(memoryDir, "workspace"),
46
+ qmdEnabled: false,
47
+ embeddingFallbackEnabled: false,
48
+ recallPlannerEnabled: false,
49
+ sharedContextEnabled: false,
50
+ initGateTimeoutMs: 1000,
51
+ ...overrides,
52
+ });
53
+ }
54
+
55
+ /** Complete typed SearchBackend stub (no casts): one settled QMD candidate. */
56
+ function settledQmdBackend(result: QmdSearchResult): SearchBackend {
57
+ return {
58
+ async probe() {
59
+ return true;
60
+ },
61
+ isAvailable() {
62
+ return true;
63
+ },
64
+ debugStatus() {
65
+ return "backend=settled-qmd-stub";
66
+ },
67
+ async search() {
68
+ return [result];
69
+ },
70
+ async searchGlobal() {
71
+ return [];
72
+ },
73
+ async bm25Search() {
74
+ return [];
75
+ },
76
+ async vectorSearch() {
77
+ return [];
78
+ },
79
+ async hybridSearch() {
80
+ return [];
81
+ },
82
+ async update() {},
83
+ async updateCollection() {},
84
+ async embed() {},
85
+ async embedCollection() {},
86
+ async ensureCollection() {
87
+ return "present";
88
+ },
89
+ };
90
+ }
91
+
92
+ interface StartedServer {
93
+ url: string;
94
+ stop: () => Promise<void>;
95
+ }
96
+
97
+ async function startTimingsServer(service: EngramAccessService): Promise<StartedServer> {
98
+ const server = new EngramAccessHttpServer({
99
+ service,
100
+ host: "127.0.0.1",
101
+ port: 0,
102
+ authToken: "secret-token",
103
+ principal: "operator",
104
+ trustPrincipalHeader: true,
105
+ maxBodyBytes: 1024,
106
+ });
107
+ const started = await server.start();
108
+ return { url: `http://${started.host}:${started.port}`, stop: () => server.stop() };
109
+ }
110
+
111
+ interface RecallBody {
112
+ query: string;
113
+ sessionKey: string;
114
+ asOf?: string;
115
+ }
116
+
117
+ function recallRequest(
118
+ server: StartedServer,
119
+ body: RecallBody,
120
+ extraHeaders: Record<string, string> = {},
121
+ signal?: AbortSignal,
122
+ ): Promise<Response> {
123
+ return fetch(`${server.url}/engram/v1/recall`, {
124
+ method: "POST",
125
+ headers: {
126
+ authorization: "Bearer secret-token",
127
+ "content-type": "application/json",
128
+ ...extraHeaders,
129
+ },
130
+ body: JSON.stringify(body),
131
+ signal,
132
+ });
133
+ }
134
+
135
+ function assertPhase2(
136
+ label: string,
137
+ ms: number | undefined,
138
+ status: Phase2AwaitStatus | undefined,
139
+ ): void {
140
+ assert.ok(
141
+ status !== undefined && PHASE2_AWAIT_STATUSES.includes(status),
142
+ `${label} status must be a bounded enum value`,
143
+ );
144
+ assert.ok(
145
+ ms !== undefined && Number.isFinite(ms) && ms >= 0,
146
+ `${label} ms must be a bounded non-negative number`,
147
+ );
148
+ }
149
+
150
+ interface HarmonicHarness {
151
+ qmdMemory: MemoryFile;
152
+ releaseHarmonicRead: () => void;
153
+ harmonicReadCalls: { count: number };
154
+ correlationIdsSeen: string[];
155
+ }
156
+
157
+ /** Park the harmonic source read behind a gate (the house ordering-harness pattern). */
158
+ async function makeHarmonicHarness(memoryDir: string): Promise<HarmonicHarness> {
159
+ const storage = new StorageManager(memoryDir);
160
+ await storage.ensureDirectories();
161
+ const { memory: qmdMemory } = await storage.writeMemory(
162
+ "fact",
163
+ "the atlas qmd sentinel confirms deployment cadence",
164
+ { source: "test" },
165
+ );
166
+ const { memory: harmonicSource } = await storage.writeMemory(
167
+ "fact",
168
+ "atlas harmonic source lookup body",
169
+ { source: "test" },
170
+ );
171
+ await recordAbstractionNode({
172
+ memoryDir,
173
+ node: {
174
+ schemaVersion: 1,
175
+ nodeId: "correlation-under-test",
176
+ recordedAt: new Date().toISOString(),
177
+ sessionKey: "agent:test",
178
+ kind: "topic",
179
+ abstractionLevel: "meso",
180
+ title: "atlas source lookup",
181
+ summary: "atlas source lookup",
182
+ sourceMemoryIds: [harmonicSource.frontmatter.id],
183
+ },
184
+ });
185
+ await rebuildMemoryProjection({ memoryDir, storage, dryRun: false });
186
+
187
+ const harmonicGate = Promise.withResolvers<void>();
188
+ const harmonicReadCalls = { count: 0 };
189
+ const correlationIdsSeen: string[] = [];
190
+ const originalRead = StorageManager.prototype.readMemoryByPath;
191
+ const harmonicSourcePath = path.resolve(harmonicSource.path);
192
+ mock.method(
193
+ StorageManager.prototype,
194
+ "readMemoryByPath",
195
+ function interceptHarmonicSourceRead(
196
+ this: StorageManager,
197
+ filePath: string,
198
+ ): Promise<MemoryFile | null> {
199
+ if (path.resolve(filePath) !== harmonicSourcePath) {
200
+ return originalRead.call(this, filePath);
201
+ }
202
+ harmonicReadCalls.count += 1;
203
+ const seen = currentCorrelationId();
204
+ if (seen !== undefined) correlationIdsSeen.push(seen);
205
+ return harmonicGate.promise.then(() => originalRead.call(this, filePath));
206
+ },
207
+ );
208
+ return {
209
+ qmdMemory,
210
+ releaseHarmonicRead: () => harmonicGate.resolve(),
211
+ harmonicReadCalls,
212
+ correlationIdsSeen,
213
+ };
214
+ }
215
+
216
+ function stubQmd(orchestrator: Orchestrator, harness: HarmonicHarness): void {
217
+ orchestrator.qmd = settledQmdBackend({
218
+ docid: harness.qmdMemory.frontmatter.id,
219
+ path: harness.qmdMemory.path,
220
+ score: 0.9,
221
+ snippet: harness.qmdMemory.content,
222
+ });
223
+ }
224
+
225
+ test("recall timing requestId equals the HTTP x-request-id response header", async () => {
226
+ const memoryDir = await mkdtemp(path.join(os.tmpdir(), "remnic-timing-corr-"));
227
+ const config = makeConfig(memoryDir);
228
+ const server = await startTimingsServer(new EngramAccessService(new Orchestrator(config)));
229
+ try {
230
+ const response = await recallRequest(server, { query: "correlation probe", sessionKey: "corr:probe" });
231
+ assert.equal(response.status, 200);
232
+ const requestIdHeader = response.headers.get("x-request-id");
233
+ assert.ok(requestIdHeader, "recall response must carry x-request-id");
234
+
235
+ const records = getRecallTimings(config);
236
+ // The record's requestId IS the server-generated HTTP correlation id
237
+ // surfaced as x-request-id — not a second, unrelated uuid.
238
+ assert.equal(records[0]?.requestId, requestIdHeader);
239
+ assert.equal(records[0]?.outcome, "ok");
240
+ } finally {
241
+ await server.stop();
242
+ await cleanupDir(memoryDir);
243
+ }
244
+ });
245
+
246
+ test("concurrent recalls never cross request ids", async () => {
247
+ const memoryDir = await mkdtemp(path.join(os.tmpdir(), "remnic-timing-corr-par-"));
248
+ const config = makeConfig(memoryDir);
249
+ const server = await startTimingsServer(new EngramAccessService(new Orchestrator(config)));
250
+ try {
251
+ const responses = await Promise.all(
252
+ ["parallel one", "parallel two", "parallel three"].map((query) =>
253
+ recallRequest(server, { query, sessionKey: "corr:parallel" }),
254
+ ),
255
+ );
256
+ const headerIds = responses.map((response) => response.headers.get("x-request-id"));
257
+ assert.equal(new Set(headerIds).size, headerIds.length, "each request gets its own correlation id");
258
+
259
+ const recordIds = getRecallTimings(config).map((record) => record.requestId);
260
+ for (const id of headerIds) {
261
+ assert.ok(id !== null && recordIds.includes(id), "each request's record carries that request's id");
262
+ }
263
+ } finally {
264
+ await server.stop();
265
+ await cleanupDir(memoryDir);
266
+ }
267
+ });
268
+
269
+ test("client-supplied x-request-id never becomes the record's request id", async () => {
270
+ const memoryDir = await mkdtemp(path.join(os.tmpdir(), "remnic-timing-corr-spoof-"));
271
+ const config = makeConfig(memoryDir);
272
+ const server = await startTimingsServer(new EngramAccessService(new Orchestrator(config)));
273
+ try {
274
+ const response = await recallRequest(
275
+ server,
276
+ { query: "spoof probe", sessionKey: "corr:spoof" },
277
+ { "x-request-id": "client-chosen-id" },
278
+ );
279
+ const serverHeader = response.headers.get("x-request-id");
280
+ assert.notEqual(serverHeader, "client-chosen-id");
281
+
282
+ const records = getRecallTimings(config);
283
+ assert.equal(records[0]?.requestId, serverHeader);
284
+ assert.match(records[0]?.requestId ?? "", UUID_PATTERN);
285
+ } finally {
286
+ await server.stop();
287
+ await cleanupDir(memoryDir);
288
+ }
289
+ });
290
+
291
+ test("HTTP recall rejected as bad input records outcome error under the x-request-id", async () => {
292
+ const memoryDir = await mkdtemp(path.join(os.tmpdir(), "remnic-timing-corr-error-"));
293
+ const config = makeConfig(memoryDir);
294
+ const server = await startTimingsServer(new EngramAccessService(new Orchestrator(config)));
295
+ try {
296
+ const response = await recallRequest(server, {
297
+ query: "bad asOf probe",
298
+ sessionKey: "corr:error",
299
+ asOf: "not-a-timestamp",
300
+ });
301
+ assert.equal(response.status, 400);
302
+ const requestIdHeader = response.headers.get("x-request-id");
303
+ assert.ok(requestIdHeader, "error responses carry x-request-id too");
304
+
305
+ const records = getRecallTimings(config);
306
+ assert.equal(records[0]?.requestId, requestIdHeader);
307
+ assert.equal(records[0]?.outcome, "error");
308
+ } finally {
309
+ await server.stop();
310
+ await cleanupDir(memoryDir);
311
+ }
312
+ });
313
+
314
+ test("aborted HTTP recall records outcome aborted under its own request id", async () => {
315
+ const memoryDir = await mkdtemp(path.join(os.tmpdir(), "remnic-timing-corr-abort-"));
316
+ const config = makeConfig(memoryDir, { qmdEnabled: true, harmonicRetrievalEnabled: true });
317
+ const orchestrator = new Orchestrator(config);
318
+ const harness = await makeHarmonicHarness(memoryDir);
319
+ stubQmd(orchestrator, harness);
320
+ const server = await startTimingsServer(new EngramAccessService(orchestrator));
321
+ try {
322
+ const client = new AbortController();
323
+ const pending = recallRequest(
324
+ server,
325
+ { query: "atlas source lookup", sessionKey: "corr:abort" },
326
+ {},
327
+ client.signal,
328
+ ).catch(() => undefined);
329
+ await eventually(
330
+ async () => (harness.harmonicReadCalls.count > 0 ? true : null),
331
+ "harmonic read reached the parked seam",
332
+ );
333
+ client.abort();
334
+ harness.releaseHarmonicRead();
335
+ await eventually(
336
+ async () => (getRecallTimings(config)[0]?.outcome === "aborted" ? true : null),
337
+ "the aborted attempt records outcome aborted",
338
+ );
339
+ await pending;
340
+
341
+ const records = getRecallTimings(config);
342
+ assert.equal(records.length, 1, "exactly one record for the attempt");
343
+ assert.equal(harness.correlationIdsSeen.length, 1);
344
+ // Same id: the one the HTTP layer minted for this request, observed from
345
+ // inside the request's own async context while the recall was in flight.
346
+ assert.equal(records[0]?.requestId, harness.correlationIdsSeen[0]);
347
+ assert.match(records[0]?.requestId ?? "", UUID_PATTERN);
348
+ } finally {
349
+ harness.releaseHarmonicRead();
350
+ await server.stop();
351
+ await cleanupDir(memoryDir);
352
+ }
353
+ });
354
+
355
+ test("phase-2 await fields are populated, bounded, and skipped for disabled sections", async () => {
356
+ const memoryDir = await mkdtemp(path.join(os.tmpdir(), "remnic-timing-phase2-"));
357
+ const config = makeConfig(memoryDir);
358
+ const service = new EngramAccessService(new Orchestrator(config));
359
+ await service.recall({ query: "phase two probe", sessionKey: "phase2:probe" });
360
+ const record = getRecallTimings(config)[0];
361
+ assert.ok(record);
362
+ assertPhase2("harmonic", record.phase2HarmonicMs, record.phase2HarmonicStatus);
363
+ assertPhase2("graph snapshot", record.phase2GraphSnapshotMs, record.phase2GraphSnapshotStatus);
364
+ assertPhase2("intent snapshot", record.phase2IntentSnapshotMs, record.phase2IntentSnapshotStatus);
365
+ assertPhase2("compression", record.phase2CompressionMs, record.phase2CompressionStatus);
366
+ assertPhase2("compounding", record.phase2CompoundingMs, record.phase2CompoundingStatus);
367
+ assertPhase2("questions", record.phase2QuestionsMs, record.phase2QuestionsStatus);
368
+ assertPhase2("prefilter", record.phase2PrefilterMs, record.phase2PrefilterStatus);
369
+ // Default config disables these sections: 0 ms, skipped, no invented time.
370
+ assert.equal(record.phase2HarmonicStatus, "skipped");
371
+ assert.equal(record.phase2HarmonicMs, 0);
372
+ assert.equal(record.phase2CompressionStatus, "skipped");
373
+ assert.equal(record.phase2CompressionMs, 0);
374
+ assert.equal(record.phase2QuestionsStatus, "skipped");
375
+ assert.equal(record.phase2QuestionsMs, 0);
376
+ assert.equal(record.phase2PrefilterStatus, "skipped");
377
+ assert.equal(record.phase2PrefilterMs, 0);
378
+ // The intent snapshot always runs.
379
+ assert.equal(record.phase2IntentSnapshotStatus, "ok");
380
+ await cleanupDir(memoryDir);
381
+ });
382
+
383
+ test("enrichment timeout records timeout status while recall still succeeds", async () => {
384
+ const memoryDir = await mkdtemp(path.join(os.tmpdir(), "remnic-timing-phase2-timeout-"));
385
+ const config = makeConfig(memoryDir, {
386
+ qmdEnabled: true,
387
+ harmonicRetrievalEnabled: true,
388
+ recallEnrichmentDeadlineMs: 1,
389
+ });
390
+ const orchestrator = new Orchestrator(config);
391
+ const harness = await makeHarmonicHarness(memoryDir);
392
+ stubQmd(orchestrator, harness);
393
+ const service = new EngramAccessService(orchestrator);
394
+ // The recall must still settle (fail-open unchanged) despite the parked read.
395
+ await service.recall({ query: "atlas source lookup", sessionKey: "phase2:timeout" });
396
+ const record = getRecallTimings(config)[0];
397
+ assert.ok(record);
398
+ assert.equal(record.phase2HarmonicStatus, "timeout");
399
+ assertPhase2("harmonic", record.phase2HarmonicMs, record.phase2HarmonicStatus);
400
+ assert.equal(record.outcome, "ok");
401
+ harness.releaseHarmonicRead();
402
+ await cleanupDir(memoryDir);
403
+ });
404
+
405
+ test("failed enrichment records error status while recall still succeeds", async () => {
406
+ const memoryDir = await mkdtemp(path.join(os.tmpdir(), "remnic-timing-phase2-error-"));
407
+ const config = makeConfig(memoryDir, { compoundingEnabled: true });
408
+ const orchestrator = new Orchestrator(config);
409
+ mock.method(CompoundingEngine.prototype, "buildRecallSection", () =>
410
+ Promise.reject(new Error("synthetic compounding failure")));
411
+ const service = new EngramAccessService(orchestrator);
412
+ // Fail-open is unchanged: the recall still resolves; only the status says why.
413
+ await service.recall({ query: "compounding failure probe", sessionKey: "phase2:error" });
414
+ const record = getRecallTimings(config)[0];
415
+ assert.ok(record);
416
+ assert.equal(record.phase2CompoundingStatus, "error");
417
+ assertPhase2("compounding", record.phase2CompoundingMs, record.phase2CompoundingStatus);
418
+ assert.equal(record.outcome, "ok");
419
+ await cleanupDir(memoryDir);
420
+ });
421
+
422
+ test("started-earlier awaits also record total time since their promise was created", async () => {
423
+ const memoryDir = await mkdtemp(path.join(os.tmpdir(), "remnic-timing-phase2-overlap-"));
424
+ const config = makeConfig(memoryDir, {
425
+ qmdEnabled: true,
426
+ harmonicRetrievalEnabled: true,
427
+ queryAwareIndexingEnabled: true,
428
+ });
429
+ const orchestrator = new Orchestrator(config);
430
+ const harness = await makeHarmonicHarness(memoryDir);
431
+ harness.releaseHarmonicRead();
432
+ stubQmd(orchestrator, harness);
433
+ const service = new EngramAccessService(orchestrator);
434
+ await service.recall({ query: "atlas source lookup", sessionKey: "phase2:overlap" });
435
+ const record = getRecallTimings(config)[0];
436
+ assert.ok(record);
437
+ assert.equal(record.phase2HarmonicStatus, "ok");
438
+ assert.ok(record.phase2HarmonicMs !== undefined && record.phase2HarmonicTotalMs !== undefined);
439
+ // Total time since the promise was created covers the await itself: the two
440
+ // overlap, they are not additive.
441
+ assert.ok(record.phase2HarmonicTotalMs >= record.phase2HarmonicMs);
442
+ assert.ok(record.phase2PrefilterMs !== undefined && record.phase2PrefilterTotalMs !== undefined);
443
+ assert.ok(record.phase2PrefilterTotalMs >= record.phase2PrefilterMs);
444
+ await cleanupDir(memoryDir);
445
+ });
446
+
447
+ test("recall response body carries no timing-contract fields", async () => {
448
+ const memoryDir = await mkdtemp(path.join(os.tmpdir(), "remnic-timing-corr-body-"));
449
+ const config = makeConfig(memoryDir);
450
+ const server = await startTimingsServer(new EngramAccessService(new Orchestrator(config)));
451
+ try {
452
+ const response = await recallRequest(server, { query: "body shape probe", sessionKey: "corr:body" });
453
+ assert.equal(response.status, 200);
454
+ const keys = Object.keys(z.object({}).passthrough().parse(await response.json()));
455
+ for (const expected of ["query", "namespace", "context", "count", "memoryIds", "results", "fallbackUsed", "sourcesUsed"]) {
456
+ assert.ok(keys.includes(expected), `recall body must still carry ${expected}`);
457
+ }
458
+ // Timing-contract fields live only in the operator-gated timing record.
459
+ for (const key of keys) {
460
+ assert.doesNotMatch(key, /requestId|outcome|httpTotal|phase2|timingsMs/, `timing field leaked into recall body: ${key}`);
461
+ }
462
+ } finally {
463
+ await server.stop();
464
+ await cleanupDir(memoryDir);
465
+ }
466
+ });
467
+
468
+ test("a recall the outer timeout cuts short records outcome error, not ok", async () => {
469
+ const memoryDir = await mkdtemp(path.join(os.tmpdir(), "remnic-timing-outer-timeout-"));
470
+ const config = makeConfig(memoryDir, {
471
+ qmdEnabled: true,
472
+ harmonicRetrievalEnabled: true,
473
+ recallOuterTimeoutMs: 50,
474
+ });
475
+ const orchestrator = new Orchestrator(config);
476
+ const harness = await makeHarmonicHarness(memoryDir);
477
+ stubQmd(orchestrator, harness);
478
+ const service = new EngramAccessService(orchestrator);
479
+ // The entry coordinator swallows the timeout and returns a degraded context,
480
+ // so the surface call resolves; the record must still say it did not complete.
481
+ await service.recall({ query: "atlas source lookup", sessionKey: "outer:timeout" });
482
+ harness.releaseHarmonicRead();
483
+ const records = getRecallTimings(config);
484
+ assert.equal(records.length, 1);
485
+ assert.equal(records[0]?.outcome, "error");
486
+ assert.equal(records[0]?.phase2HarmonicStatus, undefined, "no phase-2 data from a pipeline that never finished");
487
+ await cleanupDir(memoryDir);
488
+ });
@@ -1,10 +1,55 @@
1
1
  import type { PluginConfig } from "./types.js";
2
+ import {
3
+ PHASE2_AWAIT_NAMES,
4
+ PHASE2_AWAIT_STATUSES,
5
+ PHASE2_AWAIT_TOTAL_NAMES,
6
+ phase2MsField,
7
+ phase2StatusField,
8
+ phase2TotalField,
9
+ type Phase2AwaitStatus,
10
+ } from "./recall-phase2-timing.js";
11
+
12
+ export type RecallTimingOutcome = "ok" | "error" | "aborted";
13
+
14
+ /**
15
+ * Flat per-phase timing payload the recall pipeline emits (recall-timings
16
+ * attempt contract). `timestamp`/`namespace` are required; every other key is
17
+ * a phase or dimension the recall-timings sanitizer already knows how to
18
+ * parse (string durations like "12ms", plus `recallPlan`/`queryPolicy`).
19
+ */
20
+ export type RecallTimingEmission = {
21
+ timestamp: string;
22
+ namespace: string;
23
+ } & Record<string, string>;
2
24
 
3
25
  export interface RecallTimingRecord {
4
26
  readonly timestamp: string;
5
27
  readonly namespace: string;
6
28
  readonly recallPlan: string;
7
29
  readonly queryPolicy: string;
30
+ /** Server-generated id for the recall attempt; never caller-supplied input. */
31
+ readonly requestId: string;
32
+ readonly outcome: RecallTimingOutcome;
33
+ /** Monotonic (performance.now) total for the whole recall attempt, in ms. */
34
+ readonly httpTotalMs: number;
35
+ /** Phase-2 await timings: overlapping, not additive (see recall-phase2-timing.ts). */
36
+ readonly phase2HarmonicMs?: number;
37
+ readonly phase2HarmonicStatus?: Phase2AwaitStatus;
38
+ readonly phase2HarmonicTotalMs?: number;
39
+ readonly phase2GraphSnapshotMs?: number;
40
+ readonly phase2GraphSnapshotStatus?: Phase2AwaitStatus;
41
+ readonly phase2IntentSnapshotMs?: number;
42
+ readonly phase2IntentSnapshotStatus?: Phase2AwaitStatus;
43
+ readonly phase2CompressionMs?: number;
44
+ readonly phase2CompressionStatus?: Phase2AwaitStatus;
45
+ readonly phase2CompoundingMs?: number;
46
+ readonly phase2CompoundingStatus?: Phase2AwaitStatus;
47
+ readonly phase2CompoundingTotalMs?: number;
48
+ readonly phase2QuestionsMs?: number;
49
+ readonly phase2QuestionsStatus?: Phase2AwaitStatus;
50
+ readonly phase2PrefilterMs?: number;
51
+ readonly phase2PrefilterStatus?: Phase2AwaitStatus;
52
+ readonly phase2PrefilterTotalMs?: number;
8
53
  readonly timingsMs: Readonly<Record<string, number>>;
9
54
  }
10
55
 
@@ -78,11 +123,36 @@ function sanitizeRecallTiming(
78
123
  // Phases that did not run are omitted; 0 means "ran, measured zero".
79
124
  if (value !== undefined) timingsMs[field] = value;
80
125
  }
126
+ // Attempt-contract id decode: String(x) === x holds exactly for string
127
+ // primitives; every other value coalesces to "" (no runtime typeof here).
128
+ const requestId = String(input.requestId);
129
+ // Phase-2 await fields ride the same boundary decode: durations parse like
130
+ // every other ms string, statuses must be enum literals, and anything else
131
+ // is omitted so legacy emitters carry no phase-2 noise.
132
+ const phase2Fields: Record<string, number | Phase2AwaitStatus> = {};
133
+ for (const name of PHASE2_AWAIT_NAMES) {
134
+ const ms = numericMilliseconds(input[phase2MsField(name)]);
135
+ if (ms !== undefined) phase2Fields[phase2MsField(name)] = ms;
136
+ const status = PHASE2_AWAIT_STATUSES.find((candidate) => candidate === input[phase2StatusField(name)]);
137
+ if (status !== undefined) phase2Fields[phase2StatusField(name)] = status;
138
+ }
139
+ for (const name of PHASE2_AWAIT_TOTAL_NAMES) {
140
+ const totalMs = numericMilliseconds(input[phase2TotalField(name)]);
141
+ if (totalMs !== undefined) phase2Fields[phase2TotalField(name)] = totalMs;
142
+ }
81
143
  return {
82
144
  timestamp: typeof input.timestamp === "string" ? input.timestamp : "",
83
145
  namespace: typeof input.namespace === "string" ? input.namespace : "",
84
146
  recallPlan: typeof input.recallPlan === "string" ? input.recallPlan : "",
85
147
  queryPolicy: typeof input.queryPolicy === "string" ? input.queryPolicy : "",
148
+ // Attempt contract, copied field-by-field like the dimension strings:
149
+ // non-string requestIds drop, anything but the literal error/abort marks
150
+ // is "ok", and the monotonic total rides the same numeric-ms parsing as
151
+ // the phases (absent or negative floors to 0 for legacy emitters).
152
+ requestId: requestId === input.requestId ? requestId : "",
153
+ outcome: input.outcome === "error" || input.outcome === "aborted" ? input.outcome : "ok",
154
+ httpTotalMs: numericMilliseconds(input.httpTotalMs) ?? 0,
155
+ ...phase2Fields,
86
156
  timingsMs,
87
157
  };
88
158
  }
@@ -66,6 +66,13 @@ interface SessionFileBody {
66
66
  extractionCount?: number;
67
67
  }
68
68
 
69
+ const ADMISSION_IDEMPOTENCY_FILE = "_admission-idempotency.json";
70
+
71
+ interface AdmissionIdempotencyFileBody {
72
+ keys?: Record<string, number>;
73
+ order?: string[];
74
+ }
75
+
69
76
  function entryFromBody(body: SessionFileBody): { key: string; entry: BufferEntryState } | null {
70
77
  if (!body || !Array.isArray(body.turns) || (body.key?.length ?? 0) === 0) return null;
71
78
  const entry: BufferEntryState = {
@@ -116,6 +123,68 @@ export class BufferSessionFiles {
116
123
  return path.join(this.dir, bufferSessionFileName(key));
117
124
  }
118
125
 
126
+ private admissionMetaPath(): string {
127
+ return path.join(this.dir, ADMISSION_IDEMPOTENCY_FILE);
128
+ }
129
+
130
+ private async readAdmissionIdempotency(): Promise<Pick<BufferState, "admissionIdempotency" | "admissionIdempotencyOrder">> {
131
+ let raw: string;
132
+ try {
133
+ raw = await this.io.read(this.admissionMetaPath());
134
+ } catch (err) {
135
+ if (err instanceof Error && isMissing(asFsError(err))) return {};
136
+ throw err;
137
+ }
138
+ try {
139
+ const body: AdmissionIdempotencyFileBody = JSON.parse(raw);
140
+ const rawKeys = body.keys;
141
+ if (rawKeys == null || Array.isArray(rawKeys)) return {};
142
+ // SAFETY: admission file contract — keys is a plain record of finite turn counts.
143
+ const map = Object.create(null) as Record<string, number>;
144
+ for (const [key, value] of Object.entries(rawKeys)) {
145
+ const count = Number(value);
146
+ if (Number.isFinite(count)) map[key] = count;
147
+ }
148
+ const loaded: Pick<BufferState, "admissionIdempotency" | "admissionIdempotencyOrder"> = {
149
+ admissionIdempotency: map,
150
+ };
151
+ if (Array.isArray(body.order) && body.order.length > 0) {
152
+ const order: string[] = [];
153
+ for (const entry of body.order) {
154
+ const slot = String(entry);
155
+ if (Object.hasOwn(map, slot)) order.push(slot);
156
+ }
157
+ if (order.length > 0) loaded.admissionIdempotencyOrder = order;
158
+ }
159
+ return loaded;
160
+ } catch (err) {
161
+ log.warn(
162
+ `buffer: unreadable admission idempotency file; starting empty (${err instanceof Error ? err.message : String(err)})`,
163
+ );
164
+ return {};
165
+ }
166
+ }
167
+
168
+ /** Persist observe-buffer idempotency metadata (production storage path). */
169
+ async saveAdmissionIdempotency(state: BufferState): Promise<void> {
170
+ const keys = state.admissionIdempotency;
171
+ if (!keys || Object.keys(keys).length === 0) {
172
+ await this.assertDirSafe();
173
+ try {
174
+ await unlink(this.admissionMetaPath());
175
+ } catch (err) {
176
+ if (!(err instanceof Error) || !isMissing(asFsError(err))) throw err;
177
+ }
178
+ return;
179
+ }
180
+ await this.assertDirSafe();
181
+ const order = state.admissionIdempotencyOrder ?? Object.keys(keys);
182
+ await this.io.write(
183
+ this.admissionMetaPath(),
184
+ JSON.stringify({ keys, order }),
185
+ );
186
+ }
187
+
119
188
  /**
120
189
  * Refuse a symlinked buffer directory: following it would send buffered
121
190
  * conversation data (and deletions) outside the memory root. One lstat of
@@ -269,11 +338,13 @@ export class BufferSessionFiles {
269
338
  const out: NonNullable<BufferState["entries"]> = Object.create(null);
270
339
  for (const [key, entry] of entries) out[key] = entry;
271
340
  const def = entries.get("default");
341
+ const admission = await this.readAdmissionIdempotency();
272
342
  return {
273
343
  turns: def?.turns ?? [],
274
344
  lastExtractionAt: def?.lastExtractionAt ?? null,
275
345
  extractionCount: def?.extractionCount ?? 0,
276
346
  entries: out,
347
+ ...admission,
277
348
  };
278
349
  }
279
350
 
package/src/storage.ts CHANGED
@@ -5518,6 +5518,7 @@ export class StorageManager extends TombstoneBlockedCaptureIndexHost {
5518
5518
  async loadBuffer(): Promise<BufferState> { return this.bufferSessionFiles().load(); }
5519
5519
  async saveBuffer(state: BufferState): Promise<void> { await this.bufferSessionFiles().reconcile(state); }
5520
5520
  async saveBufferSession(key: string, entry: BufferEntryState): Promise<BufferSessionSaveOutcome> { return await this.bufferSessionFiles().save(key, entry); }
5521
+ async saveBufferAdmissionIdempotency(state: BufferState): Promise<void> { await this.bufferSessionFiles().saveAdmissionIdempotency(state); }
5521
5522
  async deleteBufferSession(key: string): Promise<void> { await this.bufferSessionFiles().remove(key); }
5522
5523
  /** Sync gate check for the extraction queue: is this session claimed by a buffer drain? */
5523
5524
  isBufferSessionClaimed(key: string): boolean { return this.bufferSessionFiles().isClaimed(key); }
package/src/types.ts CHANGED
@@ -2700,6 +2700,8 @@ export interface BufferState {
2700
2700
  lastExtractionAt: string | null;
2701
2701
  extractionCount: number;
2702
2702
  entries?: Record<string, BufferEntryState>;
2703
+ admissionIdempotency?: Record<string, number>;
2704
+ admissionIdempotencyOrder?: string[];
2703
2705
  }
2704
2706
 
2705
2707
  export interface BehaviorLoopAdjustment {