@remnic/core 10.0.173 → 10.0.175

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 (347) hide show
  1. package/dist/access-admin-ops-surface.js +103 -101
  2. package/dist/access-audit.js +2 -2
  3. package/dist/access-cli.js +103 -101
  4. package/dist/access-cli.js.map +1 -1
  5. package/dist/access-coding-context-resolution.js +3 -3
  6. package/dist/access-extraction-force-flush-preempt.js +103 -101
  7. package/dist/access-extraction-force-flush.js +103 -101
  8. package/dist/access-http-briefing.js +103 -101
  9. package/dist/access-http-query.js +103 -101
  10. package/dist/access-http.js +103 -101
  11. package/dist/access-identity-continuity-surface.js +103 -101
  12. package/dist/access-lcm-surface.js +103 -101
  13. package/dist/access-mcp.js +103 -101
  14. package/dist/access-memory-search-fanout.js +3 -3
  15. package/dist/access-observe-objective-state.js +2 -2
  16. package/dist/access-observe-write-surface.js +103 -101
  17. package/dist/access-offline-manifest.js +6 -6
  18. package/dist/access-operations-batch.js +103 -101
  19. package/dist/access-operations.js +103 -101
  20. package/dist/access-recall-concurrency.js +103 -101
  21. package/dist/access-recall-diagnostics.js +4 -4
  22. package/dist/access-recall-response.js +103 -101
  23. package/dist/access-recall-surface.js +103 -101
  24. package/dist/access-service.js +103 -101
  25. package/dist/active-memory-bridge.js +3 -3
  26. package/dist/active-recall.js +18 -17
  27. package/dist/active-recall.js.map +1 -1
  28. package/dist/adapters/index.js +4 -4
  29. package/dist/adapters/registry.js +2 -2
  30. package/dist/{auto-sync-ACP5U5A3.js → auto-sync-IUKNPMNI.js} +5 -5
  31. package/dist/briefing.js +16 -15
  32. package/dist/buffer.js +12 -11
  33. package/dist/calibration.js +3 -3
  34. package/dist/capabilities.d.ts +5 -3
  35. package/dist/capabilities.d.ts.map +1 -1
  36. package/dist/capabilities.js +1 -1
  37. package/dist/causal-consolidation.js +17 -16
  38. package/dist/causal-consolidation.js.map +1 -1
  39. package/dist/{chunk-QKAFFVSO.js → chunk-2EKXMZ6E.js} +2 -2
  40. package/dist/{chunk-YVXM5QFL.js → chunk-2LWXBERZ.js} +2 -2
  41. package/dist/{chunk-BJOQQCYC.js → chunk-2LXROA34.js} +8 -8
  42. package/dist/{chunk-XJTRIHTH.js → chunk-2WITFW6F.js} +3 -3
  43. package/dist/{chunk-IUM3VSHI.js → chunk-2WREX7KD.js} +10 -1
  44. package/dist/chunk-2WREX7KD.js.map +1 -0
  45. package/dist/{chunk-WF2LYKOB.js → chunk-2ZWTTXMV.js} +3 -3
  46. package/dist/{chunk-YRD525ZO.js → chunk-3FEQNKMB.js} +3 -3
  47. package/dist/{chunk-ZJ3CEAJD.js → chunk-3FS6IVSU.js} +2 -2
  48. package/dist/{chunk-Y65XX5PC.js → chunk-3SP7EZWA.js} +5 -5
  49. package/dist/{chunk-PQIFYBUX.js → chunk-4GI2IGUK.js} +2 -2
  50. package/dist/{chunk-HHVK2JRE.js → chunk-4TPU36X4.js} +2 -2
  51. package/dist/{chunk-GUF2JKG5.js → chunk-4TZOOUMK.js} +2 -2
  52. package/dist/{chunk-5PHOU5QI.js → chunk-5OBYISRA.js} +2 -2
  53. package/dist/{chunk-W35ICLYZ.js → chunk-5RBHL5TF.js} +122 -42
  54. package/dist/chunk-5RBHL5TF.js.map +1 -0
  55. package/dist/{chunk-NDPS6OU2.js → chunk-63FIQIER.js} +2 -2
  56. package/dist/{chunk-HR3DKJCU.js → chunk-6SROXED4.js} +2 -2
  57. package/dist/{chunk-EBI6FI5U.js → chunk-76LDFLAG.js} +4 -4
  58. package/dist/{chunk-5RONA5FF.js → chunk-7DFJ4JX2.js} +4 -4
  59. package/dist/{chunk-Q7OKGBZY.js → chunk-7L73PLRG.js} +2 -2
  60. package/dist/{chunk-YSATDEBY.js → chunk-A6JDNYXE.js} +2 -2
  61. package/dist/{chunk-OGQL7QC7.js → chunk-AQ6V47Q7.js} +4 -4
  62. package/dist/{chunk-E53NLIAP.js → chunk-B4ZA2PZC.js} +3 -3
  63. package/dist/{chunk-DLR3SBOM.js → chunk-B7GZL7PR.js} +2 -2
  64. package/dist/{chunk-XYNUEXLC.js → chunk-BAMF6J4W.js} +4 -4
  65. package/dist/{chunk-ESG6ITGP.js → chunk-CA5MRHBP.js} +2 -2
  66. package/dist/{chunk-JFMMEHVG.js → chunk-CWOMCAUE.js} +2 -2
  67. package/dist/{chunk-JNBSTHVT.js → chunk-CXIBBZ6N.js} +4 -4
  68. package/dist/{chunk-KSIDZDW3.js → chunk-DIXXS4HS.js} +239 -154
  69. package/dist/chunk-DIXXS4HS.js.map +1 -0
  70. package/dist/{chunk-3DJ6R4CC.js → chunk-DLPS5YP3.js} +2 -2
  71. package/dist/{chunk-JVBAPAWZ.js → chunk-DPPIBEGC.js} +2 -2
  72. package/dist/{chunk-UFX24WNJ.js → chunk-DWQAMPLW.js} +10 -10
  73. package/dist/{chunk-7SNEJNA3.js → chunk-F2XXZR6A.js} +4 -4
  74. package/dist/{chunk-3MOL7YE7.js → chunk-FDAXNHEX.js} +6 -6
  75. package/dist/{chunk-CY2C5LM4.js → chunk-FDLPNFKE.js} +2 -2
  76. package/dist/{chunk-2OAFPBQB.js → chunk-FDXLO6CX.js} +3 -3
  77. package/dist/{chunk-YN2DQ2D6.js → chunk-FE43YKNJ.js} +2 -2
  78. package/dist/{chunk-KAGLV5KH.js → chunk-FTQF3G3B.js} +2 -2
  79. package/dist/{chunk-SA2YALFU.js → chunk-FTV2C3CA.js} +2 -2
  80. package/dist/{chunk-B7HYXVME.js → chunk-FZF7JX76.js} +1 -1
  81. package/dist/chunk-FZF7JX76.js.map +1 -0
  82. package/dist/{chunk-ZYP4YEEI.js → chunk-G6V32Q4F.js} +2 -2
  83. package/dist/{chunk-W2UV6VE3.js → chunk-G77MHQFZ.js} +2 -2
  84. package/dist/{chunk-LXSDEPEK.js → chunk-GFOLOYAR.js} +2 -2
  85. package/dist/{chunk-66DUCUOC.js → chunk-GGQ3CJVH.js} +2 -2
  86. package/dist/{chunk-C6S353AG.js → chunk-HAB7LLE7.js} +2 -2
  87. package/dist/{chunk-LAOJHOTG.js → chunk-HHKUWNHQ.js} +2 -2
  88. package/dist/{chunk-SAPC7N43.js → chunk-HOTAHSO3.js} +5 -5
  89. package/dist/{chunk-L5EE2CXU.js → chunk-IFXQGDMG.js} +2 -2
  90. package/dist/{chunk-EXYT52NR.js → chunk-IOBQMVVL.js} +2 -2
  91. package/dist/{chunk-7G5NTS7F.js → chunk-J66ZJW5U.js} +2 -2
  92. package/dist/{chunk-X5MFCZDL.js → chunk-JUROR7PB.js} +3 -3
  93. package/dist/{chunk-QKBFVLDH.js → chunk-JXYFXVPB.js} +2 -2
  94. package/dist/{chunk-4AKPTHOO.js → chunk-KNYUEYB6.js} +2 -2
  95. package/dist/{chunk-TNRCDMQT.js → chunk-KQ473UMU.js} +2 -2
  96. package/dist/{chunk-LMJVP5CM.js → chunk-KUCMDUEZ.js} +2 -2
  97. package/dist/{chunk-SOQOUZ2Y.js → chunk-KYPFQO43.js} +6 -6
  98. package/dist/{chunk-LH57QATU.js → chunk-KZBE4KBZ.js} +3 -3
  99. package/dist/{chunk-PXY2B7BG.js → chunk-MEB4NJO7.js} +2 -2
  100. package/dist/{chunk-6VFMEBXY.js → chunk-MFJM35R7.js} +7 -7
  101. package/dist/{chunk-QCFZDYYG.js → chunk-MLNDSATI.js} +2 -2
  102. package/dist/{chunk-5JD4DXQX.js → chunk-MNDIM6JB.js} +3 -1
  103. package/dist/chunk-MNDIM6JB.js.map +1 -0
  104. package/dist/{chunk-C5LWPYS3.js → chunk-MOWZCAKS.js} +3 -1
  105. package/dist/{chunk-C5LWPYS3.js.map → chunk-MOWZCAKS.js.map} +1 -1
  106. package/dist/{chunk-SX4BR26Y.js → chunk-NT7JD6D6.js} +2 -2
  107. package/dist/{chunk-RK7SE3BL.js → chunk-NWZEDYHT.js} +2 -2
  108. package/dist/{chunk-YY5UXARJ.js → chunk-OTE5E44O.js} +3 -3
  109. package/dist/{chunk-KW4XA7GM.js → chunk-P3SMXKFR.js} +2 -2
  110. package/dist/{chunk-A2XFG462.js → chunk-PCLTJUOY.js} +2 -2
  111. package/dist/{chunk-5JCYPBY5.js → chunk-PDMGJH4K.js} +2 -2
  112. package/dist/{chunk-H6TCS5XX.js → chunk-RASE4TEF.js} +2 -2
  113. package/dist/{chunk-JDH2BA2P.js → chunk-RXAWE76Y.js} +2 -2
  114. package/dist/{chunk-IXI6S2VJ.js → chunk-S45VECVD.js} +29 -2
  115. package/dist/chunk-S45VECVD.js.map +1 -0
  116. package/dist/{chunk-QXTKN25V.js → chunk-SVXUH3FP.js} +2 -2
  117. package/dist/{chunk-YE77U5HZ.js → chunk-T3NEDSLZ.js} +4 -4
  118. package/dist/{chunk-BFZFNXOC.js → chunk-TQXKUQFX.js} +2 -2
  119. package/dist/{chunk-BGSYM3SH.js → chunk-U4ECSKQE.js} +3 -3
  120. package/dist/{chunk-RHQL2RIM.js → chunk-V425GW5W.js} +2 -2
  121. package/dist/{chunk-4DLGKTM6.js → chunk-V5FCMJW4.js} +2 -2
  122. package/dist/{chunk-5MA6ZQ4Z.js → chunk-VBQ3FIS2.js} +2 -2
  123. package/dist/{chunk-BVRZSI7Q.js → chunk-VN3RYYMS.js} +2 -2
  124. package/dist/chunk-VOVSZYCP.js +581 -0
  125. package/dist/chunk-VOVSZYCP.js.map +1 -0
  126. package/dist/{chunk-4E2Z44CV.js → chunk-VR6NF6VX.js} +2 -2
  127. package/dist/{chunk-QRCE77YX.js → chunk-W3O3OEQ7.js} +4 -4
  128. package/dist/{chunk-UBG65KEY.js → chunk-WTYVXUKQ.js} +3 -3
  129. package/dist/chunk-XBJOO7G5.js +87 -0
  130. package/dist/chunk-XBJOO7G5.js.map +1 -0
  131. package/dist/{chunk-WECKZ3KT.js → chunk-Y6FJDJUK.js} +4 -4
  132. package/dist/{chunk-ETTV5F53.js → chunk-YMNPQMHA.js} +2 -2
  133. package/dist/{chunk-4LVQSHHN.js → chunk-ZBDTOWGX.js} +9 -9
  134. package/dist/{chunk-YCK26VSL.js → chunk-ZMEEOLQG.js} +2 -2
  135. package/dist/{chunk-R2AJAAHJ.js → chunk-ZNHLUYIT.js} +90 -16
  136. package/dist/chunk-ZNHLUYIT.js.map +1 -0
  137. package/dist/{chunk-DAOMWGO2.js → chunk-ZX5N5D6M.js} +4 -4
  138. package/dist/cli.js +103 -101
  139. package/dist/coding/export-okf-codegraph.js +18 -17
  140. package/dist/coding/export-okf-codegraph.js.map +1 -1
  141. package/dist/compounding/engine.js +18 -17
  142. package/dist/compounding/preference-consolidator.js +7 -571
  143. package/dist/compounding/preference-consolidator.js.map +1 -1
  144. package/dist/config.js +18 -17
  145. package/dist/connectors/codex-materialize-runner.js +16 -15
  146. package/dist/connectors/index.js +17 -16
  147. package/dist/contradiction/index.js +3 -3
  148. package/dist/{contradiction-scan-DTQFAW22.js → contradiction-scan-QSGW4CMA.js} +3 -3
  149. package/dist/convergence-refresh.js +18 -17
  150. package/dist/corpus-watermark.js +18 -17
  151. package/dist/day-summary.js +2 -2
  152. package/dist/embedding-fallback.js +2 -2
  153. package/dist/entity-recall-reads.js +2 -2
  154. package/dist/entity-retrieval.js +17 -16
  155. package/dist/explicit-capture.js +103 -101
  156. package/dist/extraction-judge.js +3 -3
  157. package/dist/extraction-normalization.js +3 -3
  158. package/dist/extraction-prompt.js +2 -2
  159. package/dist/extraction.js +27 -26
  160. package/dist/{first-start-migration-PPPP54X6.js → first-start-migration-TCPK2I7J.js} +5 -5
  161. package/dist/harmonic-retrieval.js +16 -15
  162. package/dist/index.js +135 -133
  163. package/dist/lcm/index.js +3 -3
  164. package/dist/local-llm.js +2 -2
  165. package/dist/location/index.js +17 -16
  166. package/dist/maintenance/memory-governance.js +16 -15
  167. package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +16 -15
  168. package/dist/maintenance/rebuild-memory-projection-runner.js +18 -17
  169. package/dist/maintenance/rebuild-memory-projection.js +17 -16
  170. package/dist/memory-browse.js +9 -8
  171. package/dist/namespaces/migrate.js +17 -16
  172. package/dist/namespaces/principal.js +2 -2
  173. package/dist/namespaces/search.d.ts +5 -1
  174. package/dist/namespaces/search.d.ts.map +1 -1
  175. package/dist/namespaces/search.js +14 -13
  176. package/dist/namespaces/storage.js +16 -15
  177. package/dist/offline-sync-impression-drain.js +5 -5
  178. package/dist/operator-doctor-corpus.js +19 -18
  179. package/dist/operator-toolkit.js +28 -27
  180. package/dist/orchestration/backlog-scheduler.js +104 -102
  181. package/dist/orchestration/backlog-scheduler.js.map +1 -1
  182. package/dist/orchestration/buffer-drain-runner.js +104 -102
  183. package/dist/orchestration/compounding-recall-sections.d.ts +17 -0
  184. package/dist/orchestration/compounding-recall-sections.d.ts.map +1 -0
  185. package/dist/orchestration/compression-guideline-coordinator.js +2 -2
  186. package/dist/orchestration/maintenance.js +29 -28
  187. package/dist/orchestration/recall-internal.d.ts.map +1 -1
  188. package/dist/orchestrator.d.ts.map +1 -1
  189. package/dist/orchestrator.js +103 -101
  190. package/dist/qmd-daemon-session.d.ts +8 -0
  191. package/dist/qmd-daemon-session.d.ts.map +1 -1
  192. package/dist/qmd-daemon-session.js +1 -1
  193. package/dist/qmd-health-metadata.d.ts +39 -0
  194. package/dist/qmd-health-metadata.d.ts.map +1 -0
  195. package/dist/qmd-health-metadata.js +12 -0
  196. package/dist/qmd-status.d.ts.map +1 -1
  197. package/dist/qmd-status.js +1 -1
  198. package/dist/qmd.d.ts +5 -1
  199. package/dist/qmd.d.ts.map +1 -1
  200. package/dist/qmd.js +8 -7
  201. package/dist/recall-attempt-timing.js +3 -3
  202. package/dist/recall-composition-decision.js +2 -2
  203. package/dist/recall-navigation.js +103 -101
  204. package/dist/recall-phase2-timing.d.ts +1 -1
  205. package/dist/recall-phase2-timing.d.ts.map +1 -1
  206. package/dist/recall-phase2-timing.js +1 -1
  207. package/dist/recall-state-view-admission.js +9 -8
  208. package/dist/recall-timings.js +2 -2
  209. package/dist/recall-why-service.js +13 -12
  210. package/dist/recall-why.js +3 -3
  211. package/dist/rerank-outcome.js +2 -2
  212. package/dist/{resolution-CV6QEYEZ.js → resolution-RWIGFH2W.js} +4 -4
  213. package/dist/resolution-RWIGFH2W.js.map +1 -0
  214. package/dist/resume-bundles.js +21 -20
  215. package/dist/search/embed-helper.js +2 -2
  216. package/dist/search/factory.js +13 -12
  217. package/dist/search/index.js +13 -12
  218. package/dist/search/lancedb-backend.js +2 -2
  219. package/dist/search/meilisearch-backend.js +2 -2
  220. package/dist/search/orama-backend.js +2 -2
  221. package/dist/search/port.d.ts +21 -0
  222. package/dist/search/port.d.ts.map +1 -1
  223. package/dist/search/port.js +1 -1
  224. package/dist/search/remote-backend.js +2 -2
  225. package/dist/semantic-consolidation.js +17 -16
  226. package/dist/semantic-rule-promotion.js +16 -15
  227. package/dist/semantic-rule-verifier.js +16 -15
  228. package/dist/shared-context/manager.js +2 -2
  229. package/dist/source-agent-qualifier.js +22 -21
  230. package/dist/standup/build.js +16 -15
  231. package/dist/storage.js +15 -14
  232. package/dist/summarizer.js +3 -3
  233. package/dist/support-passport/index.js +3 -3
  234. package/dist/{tier-stats-XWJSVEHC.js → tier-stats-DXIBRUZH.js} +2 -2
  235. package/dist/transcript.js +2 -2
  236. package/dist/transfer/export-okf.js +16 -15
  237. package/dist/verified-recall.js +16 -15
  238. package/dist/who-knows-cli.js +17 -16
  239. package/dist/who-knows.js +16 -15
  240. package/package.json +2 -2
  241. package/src/capabilities.test.ts +6 -4
  242. package/src/capabilities.ts +7 -7
  243. package/src/irc-preference-recall.test.ts +85 -0
  244. package/src/namespaces/search.test.ts +320 -4
  245. package/src/namespaces/search.ts +147 -51
  246. package/src/orchestration/compounding-recall-sections.ts +134 -0
  247. package/src/orchestration/recall-internal.ts +34 -48
  248. package/src/orchestrator.ts +0 -3
  249. package/src/qmd-client.test.ts +34 -3
  250. package/src/qmd-daemon-session.ts +34 -1
  251. package/src/qmd-health-metadata.test.ts +493 -0
  252. package/src/qmd-health-metadata.ts +95 -0
  253. package/src/qmd-status.ts +10 -1
  254. package/src/qmd.ts +83 -3
  255. package/src/recall-phase2-timing.ts +2 -0
  256. package/src/search/port.ts +23 -0
  257. package/dist/chunk-5JD4DXQX.js.map +0 -1
  258. package/dist/chunk-B7HYXVME.js.map +0 -1
  259. package/dist/chunk-IUM3VSHI.js.map +0 -1
  260. package/dist/chunk-IXI6S2VJ.js.map +0 -1
  261. package/dist/chunk-KSIDZDW3.js.map +0 -1
  262. package/dist/chunk-R2AJAAHJ.js.map +0 -1
  263. package/dist/chunk-W35ICLYZ.js.map +0 -1
  264. /package/dist/{auto-sync-ACP5U5A3.js.map → auto-sync-IUKNPMNI.js.map} +0 -0
  265. /package/dist/{chunk-QKAFFVSO.js.map → chunk-2EKXMZ6E.js.map} +0 -0
  266. /package/dist/{chunk-YVXM5QFL.js.map → chunk-2LWXBERZ.js.map} +0 -0
  267. /package/dist/{chunk-BJOQQCYC.js.map → chunk-2LXROA34.js.map} +0 -0
  268. /package/dist/{chunk-XJTRIHTH.js.map → chunk-2WITFW6F.js.map} +0 -0
  269. /package/dist/{chunk-WF2LYKOB.js.map → chunk-2ZWTTXMV.js.map} +0 -0
  270. /package/dist/{chunk-YRD525ZO.js.map → chunk-3FEQNKMB.js.map} +0 -0
  271. /package/dist/{chunk-ZJ3CEAJD.js.map → chunk-3FS6IVSU.js.map} +0 -0
  272. /package/dist/{chunk-Y65XX5PC.js.map → chunk-3SP7EZWA.js.map} +0 -0
  273. /package/dist/{chunk-PQIFYBUX.js.map → chunk-4GI2IGUK.js.map} +0 -0
  274. /package/dist/{chunk-HHVK2JRE.js.map → chunk-4TPU36X4.js.map} +0 -0
  275. /package/dist/{chunk-GUF2JKG5.js.map → chunk-4TZOOUMK.js.map} +0 -0
  276. /package/dist/{chunk-5PHOU5QI.js.map → chunk-5OBYISRA.js.map} +0 -0
  277. /package/dist/{chunk-NDPS6OU2.js.map → chunk-63FIQIER.js.map} +0 -0
  278. /package/dist/{chunk-HR3DKJCU.js.map → chunk-6SROXED4.js.map} +0 -0
  279. /package/dist/{chunk-EBI6FI5U.js.map → chunk-76LDFLAG.js.map} +0 -0
  280. /package/dist/{chunk-5RONA5FF.js.map → chunk-7DFJ4JX2.js.map} +0 -0
  281. /package/dist/{chunk-Q7OKGBZY.js.map → chunk-7L73PLRG.js.map} +0 -0
  282. /package/dist/{chunk-YSATDEBY.js.map → chunk-A6JDNYXE.js.map} +0 -0
  283. /package/dist/{chunk-OGQL7QC7.js.map → chunk-AQ6V47Q7.js.map} +0 -0
  284. /package/dist/{chunk-E53NLIAP.js.map → chunk-B4ZA2PZC.js.map} +0 -0
  285. /package/dist/{chunk-DLR3SBOM.js.map → chunk-B7GZL7PR.js.map} +0 -0
  286. /package/dist/{chunk-XYNUEXLC.js.map → chunk-BAMF6J4W.js.map} +0 -0
  287. /package/dist/{chunk-ESG6ITGP.js.map → chunk-CA5MRHBP.js.map} +0 -0
  288. /package/dist/{chunk-JFMMEHVG.js.map → chunk-CWOMCAUE.js.map} +0 -0
  289. /package/dist/{chunk-JNBSTHVT.js.map → chunk-CXIBBZ6N.js.map} +0 -0
  290. /package/dist/{chunk-3DJ6R4CC.js.map → chunk-DLPS5YP3.js.map} +0 -0
  291. /package/dist/{chunk-JVBAPAWZ.js.map → chunk-DPPIBEGC.js.map} +0 -0
  292. /package/dist/{chunk-UFX24WNJ.js.map → chunk-DWQAMPLW.js.map} +0 -0
  293. /package/dist/{chunk-7SNEJNA3.js.map → chunk-F2XXZR6A.js.map} +0 -0
  294. /package/dist/{chunk-3MOL7YE7.js.map → chunk-FDAXNHEX.js.map} +0 -0
  295. /package/dist/{chunk-CY2C5LM4.js.map → chunk-FDLPNFKE.js.map} +0 -0
  296. /package/dist/{chunk-2OAFPBQB.js.map → chunk-FDXLO6CX.js.map} +0 -0
  297. /package/dist/{chunk-YN2DQ2D6.js.map → chunk-FE43YKNJ.js.map} +0 -0
  298. /package/dist/{chunk-KAGLV5KH.js.map → chunk-FTQF3G3B.js.map} +0 -0
  299. /package/dist/{chunk-SA2YALFU.js.map → chunk-FTV2C3CA.js.map} +0 -0
  300. /package/dist/{chunk-ZYP4YEEI.js.map → chunk-G6V32Q4F.js.map} +0 -0
  301. /package/dist/{chunk-W2UV6VE3.js.map → chunk-G77MHQFZ.js.map} +0 -0
  302. /package/dist/{chunk-LXSDEPEK.js.map → chunk-GFOLOYAR.js.map} +0 -0
  303. /package/dist/{chunk-66DUCUOC.js.map → chunk-GGQ3CJVH.js.map} +0 -0
  304. /package/dist/{chunk-C6S353AG.js.map → chunk-HAB7LLE7.js.map} +0 -0
  305. /package/dist/{chunk-LAOJHOTG.js.map → chunk-HHKUWNHQ.js.map} +0 -0
  306. /package/dist/{chunk-SAPC7N43.js.map → chunk-HOTAHSO3.js.map} +0 -0
  307. /package/dist/{chunk-L5EE2CXU.js.map → chunk-IFXQGDMG.js.map} +0 -0
  308. /package/dist/{chunk-EXYT52NR.js.map → chunk-IOBQMVVL.js.map} +0 -0
  309. /package/dist/{chunk-7G5NTS7F.js.map → chunk-J66ZJW5U.js.map} +0 -0
  310. /package/dist/{chunk-X5MFCZDL.js.map → chunk-JUROR7PB.js.map} +0 -0
  311. /package/dist/{chunk-QKBFVLDH.js.map → chunk-JXYFXVPB.js.map} +0 -0
  312. /package/dist/{chunk-4AKPTHOO.js.map → chunk-KNYUEYB6.js.map} +0 -0
  313. /package/dist/{chunk-TNRCDMQT.js.map → chunk-KQ473UMU.js.map} +0 -0
  314. /package/dist/{chunk-LMJVP5CM.js.map → chunk-KUCMDUEZ.js.map} +0 -0
  315. /package/dist/{chunk-SOQOUZ2Y.js.map → chunk-KYPFQO43.js.map} +0 -0
  316. /package/dist/{chunk-LH57QATU.js.map → chunk-KZBE4KBZ.js.map} +0 -0
  317. /package/dist/{chunk-PXY2B7BG.js.map → chunk-MEB4NJO7.js.map} +0 -0
  318. /package/dist/{chunk-6VFMEBXY.js.map → chunk-MFJM35R7.js.map} +0 -0
  319. /package/dist/{chunk-QCFZDYYG.js.map → chunk-MLNDSATI.js.map} +0 -0
  320. /package/dist/{chunk-SX4BR26Y.js.map → chunk-NT7JD6D6.js.map} +0 -0
  321. /package/dist/{chunk-RK7SE3BL.js.map → chunk-NWZEDYHT.js.map} +0 -0
  322. /package/dist/{chunk-YY5UXARJ.js.map → chunk-OTE5E44O.js.map} +0 -0
  323. /package/dist/{chunk-KW4XA7GM.js.map → chunk-P3SMXKFR.js.map} +0 -0
  324. /package/dist/{chunk-A2XFG462.js.map → chunk-PCLTJUOY.js.map} +0 -0
  325. /package/dist/{chunk-5JCYPBY5.js.map → chunk-PDMGJH4K.js.map} +0 -0
  326. /package/dist/{chunk-H6TCS5XX.js.map → chunk-RASE4TEF.js.map} +0 -0
  327. /package/dist/{chunk-JDH2BA2P.js.map → chunk-RXAWE76Y.js.map} +0 -0
  328. /package/dist/{chunk-QXTKN25V.js.map → chunk-SVXUH3FP.js.map} +0 -0
  329. /package/dist/{chunk-YE77U5HZ.js.map → chunk-T3NEDSLZ.js.map} +0 -0
  330. /package/dist/{chunk-BFZFNXOC.js.map → chunk-TQXKUQFX.js.map} +0 -0
  331. /package/dist/{chunk-BGSYM3SH.js.map → chunk-U4ECSKQE.js.map} +0 -0
  332. /package/dist/{chunk-RHQL2RIM.js.map → chunk-V425GW5W.js.map} +0 -0
  333. /package/dist/{chunk-4DLGKTM6.js.map → chunk-V5FCMJW4.js.map} +0 -0
  334. /package/dist/{chunk-5MA6ZQ4Z.js.map → chunk-VBQ3FIS2.js.map} +0 -0
  335. /package/dist/{chunk-BVRZSI7Q.js.map → chunk-VN3RYYMS.js.map} +0 -0
  336. /package/dist/{chunk-4E2Z44CV.js.map → chunk-VR6NF6VX.js.map} +0 -0
  337. /package/dist/{chunk-QRCE77YX.js.map → chunk-W3O3OEQ7.js.map} +0 -0
  338. /package/dist/{chunk-UBG65KEY.js.map → chunk-WTYVXUKQ.js.map} +0 -0
  339. /package/dist/{chunk-WECKZ3KT.js.map → chunk-Y6FJDJUK.js.map} +0 -0
  340. /package/dist/{chunk-ETTV5F53.js.map → chunk-YMNPQMHA.js.map} +0 -0
  341. /package/dist/{chunk-4LVQSHHN.js.map → chunk-ZBDTOWGX.js.map} +0 -0
  342. /package/dist/{chunk-YCK26VSL.js.map → chunk-ZMEEOLQG.js.map} +0 -0
  343. /package/dist/{chunk-DAOMWGO2.js.map → chunk-ZX5N5D6M.js.map} +0 -0
  344. /package/dist/{contradiction-scan-DTQFAW22.js.map → contradiction-scan-QSGW4CMA.js.map} +0 -0
  345. /package/dist/{first-start-migration-PPPP54X6.js.map → first-start-migration-TCPK2I7J.js.map} +0 -0
  346. /package/dist/{resolution-CV6QEYEZ.js.map → qmd-health-metadata.js.map} +0 -0
  347. /package/dist/{tier-stats-XWJSVEHC.js.map → tier-stats-DXIBRUZH.js.map} +0 -0
@@ -4,17 +4,19 @@ import os from "node:os";
4
4
  import path from "node:path";
5
5
  import { mkdtemp, rm } from "node:fs/promises";
6
6
  import { setImmediate } from "node:timers/promises";
7
- import { NamespaceSearchRouter, NAMESPACE_SEARCH_LEG_TIMEOUT_MS, normalizeQmdResultPath } from "./search.js";
7
+ import { NamespaceSearchRouter, NAMESPACE_SEARCH_LEG_TIMEOUT_MS, normalizeQmdResultPath, isSearchHealthDegraded } from "./search.js";
8
8
  import { MaintenanceScheduler } from "../orchestration/maintenance.js";
9
9
  import type { NamespaceCatalog } from "./catalog.js";
10
10
  import type {
11
11
  SearchBackend,
12
12
  SearchBackendStatus,
13
+ OperationalSearchHealth,
13
14
  SearchDegradation,
14
15
  SearchExecutionOptions,
15
16
  SearchQueryOptions,
16
17
  } from "../search/port.js";
17
18
  import type { QmdCapabilities, QmdVersionStatus } from "../qmd.js";
19
+ import { parseQmdStatusOutput } from "../qmd-status.js";
18
20
  import type { PluginConfig, QmdSearchResult } from "../types.js";
19
21
 
20
22
  type CollectionState = "present" | "missing" | "unknown" | "skipped";
@@ -704,16 +706,16 @@ test("clearCache releases evicted namespace backend handles before recreation",
704
706
  assert.equal(createCalls, 2);
705
707
  });
706
708
 
707
- test("legacy default namespace root auto-creates its base collection (broad root, #1929)", async () => {
709
+ test("a spelling alias of the legacy default namespace auto-creates its base collection (#1929)", async () => {
708
710
  const backend = new FakeBackend(false);
709
711
  const router = new NamespaceSearchRouter(
710
- config(),
712
+ { ...config(), defaultNamespace: "cafe\u0301" },
711
713
  { storageFor: async () => ({ dir: "/tmp/remnic" }) },
712
714
  () => backend,
713
715
  );
714
716
  const controller = new AbortController();
715
717
 
716
- const state = await router.ensureNamespaceCollection("main", {
718
+ const state = await router.ensureNamespaceCollection("caf\u00e9", {
717
719
  signal: controller.signal,
718
720
  });
719
721
 
@@ -1261,6 +1263,8 @@ test("healthForNamespace does not cache an answer whose backend status failed",
1261
1263
 
1262
1264
  const first = await router.healthForNamespace("shared");
1263
1265
  assert.equal(first.pendingEmbeddings, null);
1266
+ assert.equal(first.collectionState, "unknown");
1267
+ assert.equal(isSearchHealthDegraded(first, first.embeddingBacklogThreshold), true);
1264
1268
 
1265
1269
  const second = await router.healthForNamespace("shared");
1266
1270
  assert.equal(second.pendingEmbeddings, 10, "backlog data must be visible on the next probe");
@@ -1612,3 +1616,315 @@ test("namespace-mode maintenance is served only when a non-QMD backend's refresh
1612
1616
  }
1613
1617
  }
1614
1618
  });
1619
+
1620
+ const operationalSnapshot: OperationalSearchHealth = {
1621
+ collectionState: "present", pendingEmbeddings: 0, oldestPendingAgeMs: null,
1622
+ totalFiles: 0, embeddedFiles: null,
1623
+ };
1624
+
1625
+ test("native removal invalidates CLI readiness across equivalent namespace spellings", async t => {
1626
+ let snapshot: OperationalSearchHealth | undefined;
1627
+ let created = 0;
1628
+ const composed = "caf\u00e9";
1629
+ const decomposed = "cafe\u0301";
1630
+ const live = new FakeBackend(false, [], { ensure: "present" }, true);
1631
+ live.statusResult = { ...operationalSnapshot };
1632
+ Object.assign(live, { readOperationalHealth: async () => snapshot });
1633
+ const missing = new FakeBackend(false, [], { check: "missing" });
1634
+ const present = new FakeBackend(false, [], { check: "present" });
1635
+ present.statusResult = operationalSnapshot;
1636
+ const router = new NamespaceSearchRouter(config(),
1637
+ { storageFor: async () => ({ dir: "/fixture/notes" }) },
1638
+ () => ++created === 1 ? live : created === 2 ? present : missing);
1639
+ t.after(() => router.dispose());
1640
+ await router.ensureNamespaceCollection(decomposed);
1641
+ assert.equal((await router.healthForNamespace(composed)).collectionState, "present");
1642
+ assert.equal(created, 2);
1643
+ assert.equal((await router.healthForNamespace(composed)).collectionState, "present");
1644
+ assert.equal(created, 2, "absent older capability must retain the guarded diagnostic TTL");
1645
+ snapshot = { ...operationalSnapshot, collectionState: "missing", pendingEmbeddings: null };
1646
+ assert.equal((await router.healthForNamespace(decomposed)).collectionState, "missing");
1647
+ assert.equal(created, 2);
1648
+ assert.equal(live.disposed, 0);
1649
+ snapshot = undefined; // Operational metadata became unavailable after the removal.
1650
+ assert.equal((await router.healthForNamespace(composed)).collectionState, "missing");
1651
+ assert.equal(created, 3, "the native removal must have invalidated the old CLI result");
1652
+ });
1653
+
1654
+ test("an older CLI diagnostic cannot publish readiness after native removal", async t => {
1655
+ let snapshot: OperationalSearchHealth | undefined;
1656
+ let created = 0;
1657
+ const { promise: entered, resolve: statusEntered } = Promise.withResolvers<void>();
1658
+ const { promise: status, resolve: releaseStatus } = Promise.withResolvers<SearchBackendStatus>();
1659
+ t.after(() => releaseStatus(operationalSnapshot));
1660
+ const live = new FakeBackend(false, [], { ensure: "present" }, true);
1661
+ t.mock.method(live, "status", () => {
1662
+ statusEntered();
1663
+ return status;
1664
+ });
1665
+ Object.assign(live, { readOperationalHealth: async () => snapshot });
1666
+ const router = new NamespaceSearchRouter(config(),
1667
+ { storageFor: async () => ({ dir: "/fixture/notes" }) }, () => {
1668
+ created++;
1669
+ return created === 1 ? live
1670
+ : new FakeBackend(false, [], { check: created === 2 ? "present" : "missing" });
1671
+ });
1672
+ t.after(() => router.dispose());
1673
+ await router.ensureNamespaceCollection("shared");
1674
+ const older = router.healthForNamespace("shared");
1675
+ await entered;
1676
+ snapshot = { ...operationalSnapshot, collectionState: "missing", pendingEmbeddings: null };
1677
+ assert.equal((await router.healthForNamespace("shared")).collectionState, "missing");
1678
+ snapshot = undefined;
1679
+ releaseStatus(operationalSnapshot);
1680
+ const stale = await older;
1681
+ assert.equal((await router.healthForNamespace("shared")).collectionState, "missing");
1682
+ assert.equal(created, 3);
1683
+ assert.equal(stale.collectionState, "unknown");
1684
+ assert.equal(stale.pendingEmbeddings, null);
1685
+ });
1686
+
1687
+ test("a cancelled poll does not invalidate another poll's CLI readiness", async t => {
1688
+ const { promise: entered, resolve: statusEntered } = Promise.withResolvers<void>();
1689
+ const { promise: status, resolve: releaseStatus } = Promise.withResolvers<SearchBackendStatus>();
1690
+ const { promise: storage, resolve: releaseStorage } = Promise.withResolvers<{ dir: string }>();
1691
+ const { promise: paused, resolve: storageEntered } = Promise.withResolvers<void>();
1692
+ const dir = "/fixture/notes";
1693
+ t.after(() => { releaseStatus(operationalSnapshot); releaseStorage({ dir }); });
1694
+ let pauseStorage = false;
1695
+ let created = 0;
1696
+ const live = new FakeBackend(false, [], { ensure: "present" }, true);
1697
+ t.mock.method(live, "status", () => { statusEntered(); return status; });
1698
+ Object.assign(live, { readOperationalHealth: async () => undefined });
1699
+ const router = new NamespaceSearchRouter(config(), {
1700
+ storageFor: async () => {
1701
+ if (pauseStorage) { storageEntered(); return storage; }
1702
+ return { dir };
1703
+ },
1704
+ }, () => ++created === 1 ? live : new FakeBackend(false, [], { check: "present" }));
1705
+ t.after(() => router.dispose());
1706
+ await router.ensureNamespaceCollection("shared");
1707
+ const older = router.healthForNamespace("shared");
1708
+ await entered;
1709
+ pauseStorage = true;
1710
+ const controller = new AbortController();
1711
+ const cancelled = router.healthForNamespace("shared", { signal: controller.signal });
1712
+ await paused;
1713
+ controller.abort();
1714
+ assert.equal((await cancelled).collectionState, "unknown");
1715
+ pauseStorage = false;
1716
+ releaseStorage({ dir });
1717
+ releaseStatus(operationalSnapshot);
1718
+ assert.equal((await older).collectionState, "present");
1719
+ assert.equal((await router.healthForNamespace("shared")).collectionState, "present");
1720
+ assert.equal(created, 2, "the successful diagnostic still uses the TTL");
1721
+ });
1722
+
1723
+ test("health re-probes after a cached operational backend failed startup", async t => {
1724
+ let created = 0;
1725
+ const cold = new FakeBackend(false);
1726
+ cold.available = false;
1727
+ const router = new NamespaceSearchRouter(config(),
1728
+ { storageFor: async () => ({ dir: "/fixture/notes" }) }, () => {
1729
+ if (++created === 1) return cold;
1730
+ const diagnostic = new FakeBackend(false, [], { check: "present" });
1731
+ diagnostic.statusResult = operationalSnapshot;
1732
+ return diagnostic;
1733
+ });
1734
+ t.after(() => router.dispose());
1735
+ assert.equal(await router.ensureNamespaceCollection("shared"), "unknown");
1736
+ const recovered = await router.healthForNamespace("shared");
1737
+ assert.equal(recovered.available, true);
1738
+ assert.equal(recovered.collectionState, "present");
1739
+ assert.equal(recovered.pendingEmbeddings, 0);
1740
+ assert.equal(isSearchHealthDegraded(recovered, recovered.embeddingBacklogThreshold), false);
1741
+ assert.equal((await router.healthForNamespace("shared")).collectionState, "present");
1742
+ assert.equal(created, 2);
1743
+ });
1744
+
1745
+ test("CLI-only health caches a recognized QMD report with no pending embeddings", async t => {
1746
+ let created = 0;
1747
+ const router = new NamespaceSearchRouter(config(),
1748
+ { storageFor: async () => ({ dir: "/fixture/notes" }) }, () => {
1749
+ created++;
1750
+ const backend = new FakeBackend(false, [], { check: "present" });
1751
+ backend.statusResult = parseQmdStatusOutput(
1752
+ "QMD Status\n\nIndex: /fixture/index.sqlite\nSize: 1 KB\n\nDocuments\n Total: 1 files indexed\n Vectors: 1 embedded\n",
1753
+ );
1754
+ return backend;
1755
+ });
1756
+ t.after(() => router.dispose());
1757
+ const health = await router.healthForNamespace("shared");
1758
+ assert.equal(health.collectionState, "present");
1759
+ assert.equal(health.pendingEmbeddings, 0);
1760
+ assert.equal(isSearchHealthDegraded(health, health.embeddingBacklogThreshold), false);
1761
+ assert.equal((await router.healthForNamespace("shared")).pendingEmbeddings, 0);
1762
+ assert.equal(created, 1);
1763
+ });
1764
+
1765
+ test("operational snapshot is revalidated at the public return boundary", async t => {
1766
+ let valid = true;
1767
+ const live = new FakeBackend(false, [], { ensure: "present" }, true);
1768
+ Object.assign(live, {
1769
+ readOperationalHealth: async () => ({
1770
+ ...operationalSnapshot,
1771
+ isCurrent: () => {
1772
+ queueMicrotask(() => { valid = false; });
1773
+ return valid;
1774
+ },
1775
+ }),
1776
+ });
1777
+ const router = new NamespaceSearchRouter(config(),
1778
+ { storageFor: async () => ({ dir: "/fixture/notes" }) }, () => live);
1779
+ t.after(() => router.dispose());
1780
+ await router.ensureNamespaceCollection("shared");
1781
+ assert.equal((await router.healthForNamespace("shared")).collectionState, "unknown");
1782
+ });
1783
+
1784
+ test("operational health preserves backlog and fresh removal instead of returning old readiness", async t => {
1785
+ let snapshot: OperationalSearchHealth = { ...operationalSnapshot, pendingEmbeddings: 50_000 };
1786
+ const live = new FakeBackend(false, [], { ensure: "present" }, true);
1787
+ Object.assign(live, { readOperationalHealth: async () => snapshot });
1788
+ const router = new NamespaceSearchRouter(config(),
1789
+ { storageFor: async () => ({ dir: "/fixture/notes" }) },
1790
+ () => live);
1791
+ t.after(() => router.dispose());
1792
+ await router.ensureNamespaceCollection("shared");
1793
+ const backlog = await router.healthForNamespace("shared");
1794
+ assert.equal(backlog.pendingEmbeddings, 50_000);
1795
+ assert.equal(isSearchHealthDegraded(backlog, backlog.embeddingBacklogThreshold), true);
1796
+ snapshot = { ...operationalSnapshot, collectionState: "missing" };
1797
+ assert.equal((await router.healthForNamespace("shared")).collectionState, "missing");
1798
+ });
1799
+
1800
+ test("operational health does not heal a cached missing collection using a positive snapshot", async t => {
1801
+ let created = 0;
1802
+ let metadataReads = 0;
1803
+ const live = new FakeBackend(false, [], { ensure: "missing" }, true);
1804
+ Object.assign(live, { readOperationalHealth: async () => { metadataReads++; return operationalSnapshot; } });
1805
+ const router = new NamespaceSearchRouter(config(),
1806
+ { storageFor: async () => ({ dir: "/fixture/notes" }) },
1807
+ () => ++created === 1 ? live : new FakeBackend(false, [], { check: "present" }));
1808
+ t.after(() => router.dispose());
1809
+ await router.ensureNamespaceCollection("shared");
1810
+ assert.equal((await router.healthForNamespace("shared")).collectionState, "missing");
1811
+ assert.equal(metadataReads, 0);
1812
+ });
1813
+
1814
+ test("operational health refuses a failed RPC without creating a disposable CLI diagnostic", async t => {
1815
+ let created = 0;
1816
+ const live = new FakeBackend(false, [], { ensure: "present" }, true);
1817
+ Object.assign(live, { readOperationalHealth: async () => { throw new Error("Synthetic RPC failure"); } });
1818
+ const router = new NamespaceSearchRouter(config(),
1819
+ { storageFor: async () => ({ dir: "/fixture/notes" }) },
1820
+ () => {
1821
+ assert.equal(++created, 1, "No second diagnostic backend after an advertised capability fails");
1822
+ return live;
1823
+ });
1824
+ t.after(() => router.dispose());
1825
+ await router.ensureNamespaceCollection("shared");
1826
+ assert.equal((await router.healthForNamespace("shared")).collectionState, "unknown");
1827
+ });
1828
+
1829
+ test("operational health refuses a result after abort, namespace path drift, or record replacement", async t => {
1830
+ let directory = "/fixture/notes";
1831
+ let afterRead = () => {};
1832
+ const live = new FakeBackend(false, [], { ensure: "present" }, true);
1833
+ Object.assign(live, { readOperationalHealth: async () => { afterRead(); return operationalSnapshot; } });
1834
+ const router = new NamespaceSearchRouter(config(),
1835
+ { storageFor: async () => ({ dir: directory }) }, () => live);
1836
+ t.after(() => router.dispose());
1837
+ await router.ensureNamespaceCollection("shared");
1838
+ const controller = new AbortController();
1839
+ afterRead = () => controller.abort();
1840
+ assert.equal((await router.healthForNamespace("shared", { signal: controller.signal })).collectionState, "unknown");
1841
+ afterRead = () => { directory = "/fixture/changed"; };
1842
+ assert.equal((await router.healthForNamespace("shared")).collectionState, "unknown");
1843
+ directory = "/fixture/notes";
1844
+ afterRead = () => router.clearCache();
1845
+ assert.equal((await router.healthForNamespace("shared")).collectionState, "unknown");
1846
+ });
1847
+
1848
+ test("operational record creation during a cached-health read cannot return old green", async t => {
1849
+ let created = 0;
1850
+ const cold = new FakeBackend(false, [], { check: "present" });
1851
+ cold.statusResult = { ...operationalSnapshot };
1852
+ const live = new FakeBackend(false, [], { ensure: "present" }, true);
1853
+ Object.assign(live, {
1854
+ readOperationalHealth: async () => ({
1855
+ ...operationalSnapshot, collectionState: "unknown", pendingEmbeddings: null,
1856
+ }),
1857
+ });
1858
+ const router = new NamespaceSearchRouter(config(),
1859
+ { storageFor: async () => ({ dir: "/fixture/notes" }) },
1860
+ () => ++created === 1 ? cold : live);
1861
+ t.after(() => router.dispose());
1862
+ assert.equal((await router.healthForNamespace("shared")).collectionState, "present");
1863
+ const preparing = router.ensureNamespaceCollection("shared");
1864
+ const reading = router.healthForNamespace("shared");
1865
+ await preparing;
1866
+ const health = await reading;
1867
+ assert.equal(health.collectionState, "unknown");
1868
+ assert.equal(isSearchHealthDegraded(health, health.embeddingBacklogThreshold), true);
1869
+ });
1870
+
1871
+ test("cold health refuses status errors, unknown backlog and unsupported versions without caching green", async () => {
1872
+ const failures: Array<[string, (backend: FakeBackend) => void]> = [
1873
+ ["null status", backend => {
1874
+ Object.defineProperty(backend, "status", { value: async () => null });
1875
+ }],
1876
+ ["status error", backend => {
1877
+ backend.statusResult = Object.assign({
1878
+ pendingEmbeddings: null, oldestPendingAgeMs: null, totalFiles: null, embeddedFiles: null,
1879
+ }, { error: "synthetic status failure" });
1880
+ }],
1881
+ ["unknown backlog", backend => {
1882
+ backend.statusResult = {
1883
+ pendingEmbeddings: null, oldestPendingAgeMs: null, totalFiles: 1, embeddedFiles: null,
1884
+ };
1885
+ }],
1886
+ ["unsupported version", backend => {
1887
+ Object.defineProperty(backend, "getVersionStatus", { value: () => ({
1888
+ installedVersion: "1.0.0", supportedVersion: "2.8.3", supported: false,
1889
+ newerThanSupported: false, upgradeAvailable: true, capabilities: qmdCapabilities(false),
1890
+ }) });
1891
+ }],
1892
+ ];
1893
+ for (const [name, fail] of failures) {
1894
+ const created: FakeBackend[] = [];
1895
+ const router = routerWithDegradedFirstProbe(created, "present", fail);
1896
+ try {
1897
+ const first = await router.healthForNamespace("shared");
1898
+ assert.equal(first.collectionState, "unknown", name);
1899
+ assert.equal(isSearchHealthDegraded(first, first.embeddingBacklogThreshold), true, name);
1900
+ const recovered = await router.healthForNamespace("shared");
1901
+ assert.equal(recovered.collectionState, "present", name);
1902
+ assert.equal(recovered.pendingEmbeddings, 10, name);
1903
+ assert.equal(created.length, 2, `${name} must not cache green`);
1904
+ } finally {
1905
+ await router.dispose();
1906
+ }
1907
+ }
1908
+ });
1909
+
1910
+ test("a backend without a status capability retains legitimate readiness and its diagnostic TTL", async () => {
1911
+ let created = 0;
1912
+ const router = new NamespaceSearchRouter(config(),
1913
+ { storageFor: async () => ({ dir: "/fixture/notes" }) },
1914
+ () => {
1915
+ created++;
1916
+ const backend = new FakeBackend(false, [], { check: "present" });
1917
+ Object.defineProperty(backend, "status", { value: undefined });
1918
+ return backend;
1919
+ });
1920
+ try {
1921
+ const health = await router.healthForNamespace("shared");
1922
+ assert.equal(health.collectionState, "present");
1923
+ assert.equal(health.pendingEmbeddings, null);
1924
+ assert.equal(isSearchHealthDegraded(health, health.embeddingBacklogThreshold), false);
1925
+ assert.equal((await router.healthForNamespace("shared")).collectionState, "present");
1926
+ assert.equal(created, 1);
1927
+ } finally {
1928
+ await router.dispose();
1929
+ }
1930
+ });
@@ -1,4 +1,4 @@
1
- import { resolveNamespaceCapabilities } from "../capabilities.js";
1
+ import { resolveNamespaceCapabilities, resolveQmdCapabilities } from "../capabilities.js";
2
2
  import path from "node:path";
3
3
  import { realpathSync } from "node:fs";
4
4
  import type { PluginConfig, QmdSearchResult } from "../types.js";
@@ -6,6 +6,8 @@ import type {
6
6
  SearchBackend,
7
7
  SearchExecutionOptions,
8
8
  SearchQueryOptions,
9
+ SearchBackendStatus,
10
+ OperationalSearchHealth,
9
11
  } from "../search/port.js";
10
12
  import { reportSearchDegradation } from "../search/port.js";
11
13
  import { createSearchBackend } from "../search/factory.js";
@@ -90,13 +92,15 @@ export function embeddingBacklogExceeds(pending: number | null, threshold: numbe
90
92
  * reports it, and `healthForNamespace` refuses to cache it.
91
93
  */
92
94
  export function isSearchHealthDegraded(
93
- health: Pick<NamespaceSearchHealth, "available" | "collectionState" | "pendingEmbeddings">,
95
+ health: Pick<NamespaceSearchHealth, "available" | "collectionState" | "pendingEmbeddings"> &
96
+ Partial<Pick<NamespaceSearchHealth, "supported">>,
94
97
  backlogThreshold: number,
95
98
  ): boolean {
96
99
  const active = health.available && health.collectionState !== "missing";
97
100
  return (
98
101
  !active ||
99
102
  health.collectionState === "unknown" ||
103
+ health.supported === false ||
100
104
  embeddingBacklogExceeds(health.pendingEmbeddings, backlogThreshold)
101
105
  );
102
106
  }
@@ -113,6 +117,8 @@ type BackendRecordOptions = {
113
117
 
114
118
  export class NamespaceSearchRouter {
115
119
  private readonly cache = new Map<string, Promise<NamespaceBackendRecord>>();
120
+ // Scoped to the backend record's lifetime; a native result supersedes older CLI probes.
121
+ private readonly nativeHealthRevision = new WeakMap<Promise<NamespaceBackendRecord>, number>();
116
122
  private readonly healthResultCache = new Map<
117
123
  string,
118
124
  { expiresAt: number; value: NamespaceSearchHealth }
@@ -156,7 +162,7 @@ export class NamespaceSearchRouter {
156
162
  if (maxResults === 0) return [];
157
163
 
158
164
  const method = options.mode ?? "search";
159
- const namespaces = Array.from(new Set(options.namespaces.map((value) => value.trim()).filter(Boolean)));
165
+ const namespaces = Array.from(new Set(options.namespaces.map(normalizeNamespaceIdentity).filter(Boolean)));
160
166
  if (namespaces.length === 0) return [];
161
167
 
162
168
  const resultsByNamespace = await Promise.all(
@@ -286,7 +292,7 @@ export class NamespaceSearchRouter {
286
292
  execution?: SearchExecutionOptions,
287
293
  options?: { strict?: boolean; force?: boolean },
288
294
  ): Promise<NamespaceUpdateResult> {
289
- const unique = Array.from(new Set(namespaces.map((value) => value.trim()).filter(Boolean)));
295
+ const unique = Array.from(new Set(namespaces.map(normalizeNamespaceIdentity).filter(Boolean)));
290
296
  const eligible = (await Promise.all(
291
297
  unique.map(async (namespace) => {
292
298
  const record = await this.backendRecordFor(namespace);
@@ -315,7 +321,7 @@ export class NamespaceSearchRouter {
315
321
  }
316
322
 
317
323
  async embedNamespaces(namespaces: string[], options?: { strict?: boolean }): Promise<void> {
318
- const unique = Array.from(new Set(namespaces.map((value) => value.trim()).filter(Boolean)));
324
+ const unique = Array.from(new Set(namespaces.map(normalizeNamespaceIdentity).filter(Boolean)));
319
325
  await Promise.all(
320
326
  unique.map(async (namespace) => {
321
327
  const record = await this.backendRecordFor(namespace);
@@ -337,12 +343,22 @@ export class NamespaceSearchRouter {
337
343
  namespace: string,
338
344
  execution?: SearchExecutionOptions,
339
345
  ): Promise<NamespaceSearchHealth> {
340
- const key = namespace.trim() || this.config.defaultNamespace;
346
+ const key = this.namespaceKey(namespace);
347
+ let pending = this.cache.get(key);
348
+ let operational = await this.operationalHealthForNamespace(key, execution);
349
+ if (!operational && this.cache.get(key) !== pending) {
350
+ pending = this.cache.get(key);
351
+ operational = await this.operationalHealthForNamespace(key, execution);
352
+ }
353
+ if (operational) return operational();
341
354
  const cached = this.healthResultCache.get(key);
342
- if (cached && cached.expiresAt > Date.now()) {
355
+ if (operational === undefined && this.cache.get(key) === pending &&
356
+ cached && cached.expiresAt > Date.now() &&
357
+ !execution?.signal?.aborted && resolveQmdCapabilities(this.config).qmd !== false) {
343
358
  return { ...cached.value };
344
359
  }
345
360
 
361
+ const nativeRevision = pending && this.nativeHealthRevision.get(pending);
346
362
  const record = await this.createBackendRecordFor(
347
363
  key,
348
364
  execution,
@@ -352,18 +368,12 @@ export class NamespaceSearchRouter {
352
368
  failOpenMissingGuardedCollection: false,
353
369
  },
354
370
  );
371
+ let health: NamespaceSearchHealth;
355
372
  try {
356
373
  const liveRecord = await this.liveCachedRecordForHealth(key, record, execution);
357
374
  const diagnosticBackend = liveRecord?.backend ?? record.backend;
358
- const versionStatus =
359
- "getVersionStatus" in diagnosticBackend &&
360
- typeof diagnosticBackend.getVersionStatus === "function"
361
- ? diagnosticBackend.getVersionStatus()
362
- : null;
363
- const daemonMode = daemonModeForBackend(diagnosticBackend);
364
375
  const backendStatus =
365
- "status" in diagnosticBackend &&
366
- typeof diagnosticBackend.status === "function"
376
+ diagnosticBackend.status
367
377
  ? await Promise.race([
368
378
  diagnosticBackend.status().catch(() => null),
369
379
  new Promise<null>((resolve) => setTimeout(() => resolve(null), 5_000).unref?.()),
@@ -374,42 +384,124 @@ export class NamespaceSearchRouter {
374
384
  ? "missing"
375
385
  : record.collectionState;
376
386
 
377
- const health: NamespaceSearchHealth = {
378
- collection: record.collection,
379
- memoryDir: record.memoryDir,
380
- available: liveRecord?.available ?? record.available,
381
- collectionState,
382
- debugStatus: diagnosticBackend.debugStatus(),
383
- installedVersion: versionStatus?.installedVersion ?? null,
384
- supportedVersion: versionStatus?.supportedVersion ?? null,
385
- supported: versionStatus?.supported ?? null,
386
- upgradeAvailable: versionStatus?.upgradeAvailable ?? null,
387
- doctorAvailable: versionStatus?.capabilities?.doctor ?? null,
388
- daemonMode,
389
- pendingEmbeddings: backendStatus?.pendingEmbeddings ?? null,
390
- oldestPendingAgeMs: backendStatus?.oldestPendingAgeMs ?? null,
391
- embeddingBacklogThreshold: this.config.qmdEmbeddingBacklogThreshold,
392
- };
393
-
394
- // Cache only a healthy answer that carries backlog data when the backend
395
- // reports status. A degraded or incomplete answer must re-probe so a
396
- // readiness poll sees recovery on the next call, not one TTL late.
397
- const statusMissing = backendStatus === null && "status" in diagnosticBackend;
398
- if (
399
- execution?.signal?.aborted !== true &&
400
- !statusMissing &&
401
- !isSearchHealthDegraded(health, health.embeddingBacklogThreshold)
402
- ) {
403
- this.healthResultCache.set(key, {
404
- expiresAt: Date.now() + HEALTH_RESULT_CACHE_TTL_MS,
405
- value: { ...health },
406
- });
407
- }
408
- return { ...health };
387
+ health = this.describeHealth(
388
+ record, diagnosticBackend,
389
+ execution?.signal?.aborted ? "unknown" : collectionState,
390
+ execution?.signal?.aborted ? null : backendStatus,
391
+ liveRecord?.available ?? record.available,
392
+ );
409
393
  } finally {
410
394
  const dispose = (record.backend as { dispose?: () => void | Promise<void> }).dispose;
411
395
  await dispose?.call(record.backend);
412
396
  }
397
+
398
+ if (execution?.signal?.aborted || this.cache.get(key) !== pending ||
399
+ (pending && this.nativeHealthRevision.get(pending) !== nativeRevision)) {
400
+ return { ...health, collectionState: "unknown", pendingEmbeddings: null, oldestPendingAgeMs: null };
401
+ }
402
+ // Cache only a healthy, unsuperseded diagnostic.
403
+ if (
404
+ operational === undefined &&
405
+ !isSearchHealthDegraded(health, health.embeddingBacklogThreshold)
406
+ ) {
407
+ this.healthResultCache.set(key, {
408
+ expiresAt: Date.now() + HEALTH_RESULT_CACHE_TTL_MS,
409
+ value: { ...health },
410
+ });
411
+ }
412
+ return health;
413
+ }
414
+
415
+ private describeHealth(
416
+ record: NamespaceBackendRecord,
417
+ diagnosticBackend: SearchBackend,
418
+ collectionState: CollectionState,
419
+ backendStatus: SearchBackendStatus | null,
420
+ available = record.available,
421
+ ): NamespaceSearchHealth {
422
+ const versionStatus = diagnosticBackend.getVersionStatus?.();
423
+ const statusFailed = diagnosticBackend.status &&
424
+ (backendStatus === null || "error" in backendStatus ||
425
+ !Number.isSafeInteger(backendStatus.pendingEmbeddings) ||
426
+ backendStatus.pendingEmbeddings === null || backendStatus.pendingEmbeddings < 0);
427
+ return {
428
+ collection: record.collection,
429
+ memoryDir: record.memoryDir,
430
+ available,
431
+ collectionState: collectionState !== "missing" && (statusFailed || versionStatus?.supported === false)
432
+ ? "unknown" : collectionState,
433
+ debugStatus: diagnosticBackend.debugStatus(),
434
+ installedVersion: versionStatus?.installedVersion ?? null,
435
+ supportedVersion: versionStatus?.supportedVersion ?? null,
436
+ supported: versionStatus?.supported ?? null,
437
+ upgradeAvailable: versionStatus?.upgradeAvailable ?? null,
438
+ doctorAvailable: versionStatus?.capabilities?.doctor ?? null,
439
+ daemonMode: daemonModeForBackend(diagnosticBackend),
440
+ pendingEmbeddings: backendStatus?.pendingEmbeddings ?? null,
441
+ oldestPendingAgeMs: backendStatus?.oldestPendingAgeMs ?? null,
442
+ embeddingBacklogThreshold: this.config.qmdEmbeddingBacklogThreshold,
443
+ };
444
+ }
445
+
446
+ private async operationalHealthForNamespace(
447
+ key: string,
448
+ execution?: SearchExecutionOptions,
449
+ ): Promise<(() => NamespaceSearchHealth) | null | undefined> {
450
+ const pending = this.cache.get(key);
451
+ if (!pending) return undefined;
452
+ if (execution?.signal?.aborted || resolveQmdCapabilities(this.config).qmd === false) return null;
453
+ const record = await awaitWithAbort(pending, execution?.signal).catch(() => null);
454
+ if (!record) return null;
455
+ const backend = record.backend;
456
+ const daemonMode = daemonModeForBackend(backend);
457
+ const operationalIdentity = backend.operationalHealthIdentity?.();
458
+ const ownsRecord = () => !execution?.signal?.aborted && this.cache.get(key) === pending &&
459
+ !record.disposed && resolveQmdCapabilities(this.config).qmd !== false && record.backend === backend;
460
+ const current = () => ownsRecord() && record.available && backend.isAvailable() &&
461
+ daemonModeForBackend(backend) === daemonMode &&
462
+ backend.operationalHealthIdentity?.() === operationalIdentity;
463
+ const refused = () => this.describeHealth(
464
+ record, backend, record.collectionState === "missing" ? "missing" : "unknown", null,
465
+ record.available && !record.disposed,
466
+ );
467
+ // A failed initial probe never established an operational connection.
468
+ if (!record.available && record.collectionState === "unknown" && ownsRecord()) return undefined;
469
+ if (!current()) return refused;
470
+ if (!backend.readOperationalHealth) return undefined;
471
+ if (record.collectionState === "missing") return refused;
472
+ const storage = await awaitWithAbort(this.storageRouter.storageFor(key), execution?.signal).catch(() => null);
473
+ if (!current() || !storage) return refused;
474
+ const expectedCollection = () => namespaceCollectionName(this.config.qmdCollection, key, {
475
+ defaultNamespace: this.config.defaultNamespace,
476
+ useLegacyDefaultCollection: key === this.namespaceKey("") && storage.dir === this.config.memoryDir,
477
+ });
478
+ if (record.memoryDir !== storage.dir || record.collection !== expectedCollection()) return refused;
479
+
480
+ let snapshot: OperationalSearchHealth | null | undefined;
481
+ try {
482
+ snapshot = await awaitWithAbort(
483
+ backend.readOperationalHealth(storage.dir, execution), execution?.signal,
484
+ );
485
+ } catch {
486
+ return refused;
487
+ }
488
+ if (snapshot === null) return refused;
489
+ const currentStorage = await awaitWithAbort(
490
+ this.storageRouter.storageFor(key), execution?.signal,
491
+ ).catch(() => null);
492
+ const canPublish = () => current() && currentStorage?.dir === storage.dir &&
493
+ record.memoryDir === storage.dir && record.collection === expectedCollection() &&
494
+ snapshot?.isCurrent?.() !== false;
495
+ if (!canPublish()) return refused;
496
+ if (snapshot === undefined) return undefined;
497
+ // The public caller resumes after this helper; invalidation can run in between.
498
+ return () => {
499
+ if (!canPublish()) return refused();
500
+ const health = this.describeHealth(record, backend, snapshot.collectionState, snapshot);
501
+ this.healthResultCache.delete(key);
502
+ this.nativeHealthRevision.set(pending, (this.nativeHealthRevision.get(pending) ?? 0) + 1);
503
+ return health;
504
+ };
413
505
  }
414
506
 
415
507
  private async liveCachedRecordForHealth(
@@ -421,6 +513,7 @@ export class NamespaceSearchRouter {
421
513
  if (!pending) return null;
422
514
  const cachedRecord = await awaitWithAbort(pending, execution?.signal).catch(() => null);
423
515
  if (!cachedRecord) return null;
516
+ if (!cachedRecord.available && cachedRecord.collectionState === "unknown" && !cachedRecord.disposed) return null;
424
517
  if (cachedRecord.collection !== disposableRecord.collection) return null;
425
518
  if (cachedRecord.memoryDir !== disposableRecord.memoryDir) return null;
426
519
  return cachedRecord;
@@ -489,12 +582,16 @@ export class NamespaceSearchRouter {
489
582
  );
490
583
  }
491
584
 
585
+ private namespaceKey(namespace: string): string {
586
+ return normalizeNamespaceIdentity(namespace) || normalizeNamespaceIdentity(this.config.defaultNamespace);
587
+ }
588
+
492
589
  private async backendRecordFor(
493
590
  namespace: string,
494
591
  execution?: SearchExecutionOptions,
495
592
  ): Promise<NamespaceBackendRecord> {
496
593
  await this.drainPendingDisposals();
497
- const key = namespace.trim() || this.config.defaultNamespace;
594
+ const key = this.namespaceKey(namespace);
498
595
  const existing = this.cache.get(key);
499
596
  if (existing) return await existing;
500
597
 
@@ -512,14 +609,13 @@ export class NamespaceSearchRouter {
512
609
  }
513
610
 
514
611
  private async createBackendRecordFor(
515
- namespace: string,
612
+ key: string,
516
613
  execution: SearchExecutionOptions | undefined,
517
614
  options: BackendRecordOptions,
518
615
  ): Promise<NamespaceBackendRecord> {
519
- const key = namespace.trim() || this.config.defaultNamespace;
520
616
  const storage = await this.storageRouter.storageFor(key);
521
617
  const useLegacyDefaultCollection =
522
- key === this.config.defaultNamespace && storage.dir === this.config.memoryDir;
618
+ key === this.namespaceKey("") && storage.dir === this.config.memoryDir;
523
619
  const filtersNestedNamespaces =
524
620
  resolveNamespaceCapabilities(this.config).namespaces === true && useLegacyDefaultCollection;
525
621
  const rootHostEmbeddingScope =