@remnic/core 9.45.2 → 9.45.4

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 (749) hide show
  1. package/dist/abort-error.d.ts +2 -1
  2. package/dist/abort-error.js +3 -1
  3. package/dist/access-admin-ops-surface.d.ts +14 -10
  4. package/dist/access-admin-ops-surface.js +84 -76
  5. package/dist/access-audit.js +2 -2
  6. package/dist/access-authorization-probe.d.ts +14 -10
  7. package/dist/access-authorization-probe.js +85 -77
  8. package/dist/access-boundary.d.ts +15 -11
  9. package/dist/access-boundary.js +84 -76
  10. package/dist/access-citation-namespace.js +2 -2
  11. package/dist/access-cli.js +193 -181
  12. package/dist/access-cli.js.map +1 -1
  13. package/dist/access-coding-context-resolution.d.ts +16 -0
  14. package/dist/access-coding-context-resolution.js +13 -0
  15. package/dist/access-coding-context-resolution.js.map +1 -0
  16. package/dist/access-extraction-force-flush.d.ts +14 -10
  17. package/dist/access-extraction-force-flush.js +84 -76
  18. package/dist/access-health-types.d.ts +2 -1
  19. package/dist/access-http-lcm-compaction.d.ts +16 -12
  20. package/dist/access-http-lcm-compaction.js +3 -3
  21. package/dist/access-http-lifecycle-flush.d.ts +14 -10
  22. package/dist/access-http-lifecycle-flush.js +2 -2
  23. package/dist/access-http-offline-stream.d.ts +123 -0
  24. package/dist/access-http-offline-stream.js +10 -0
  25. package/dist/access-http-offline-stream.js.map +1 -0
  26. package/dist/access-http-query.js +84 -76
  27. package/dist/access-http.d.ts +15 -10
  28. package/dist/access-http.js +105 -92
  29. package/dist/access-identity-continuity-surface.d.ts +9 -8
  30. package/dist/access-identity-continuity-surface.js +84 -76
  31. package/dist/access-lcm-surface.d.ts +14 -10
  32. package/dist/access-lcm-surface.js +84 -76
  33. package/dist/access-mcp-output-schemas.js +1 -1
  34. package/dist/access-mcp.d.ts +14 -10
  35. package/dist/access-mcp.js +95 -83
  36. package/dist/access-memory-search-fanout.d.ts +3 -2
  37. package/dist/{access-namespace-preflight-5yZ4g6F8.d.ts → access-namespace-preflight-CWUDwB4M.d.ts} +1 -1
  38. package/dist/access-namespace-preflight.d.ts +4 -3
  39. package/dist/access-namespace-preflight.js +84 -76
  40. package/dist/access-observe-helpers.d.ts +1 -0
  41. package/dist/access-observe-helpers.js +1 -1
  42. package/dist/access-observe-write-surface.d.ts +16 -10
  43. package/dist/access-observe-write-surface.js +84 -76
  44. package/dist/access-offline-manifest.d.ts +104 -0
  45. package/dist/access-offline-manifest.js +45 -0
  46. package/dist/access-offline-manifest.js.map +1 -0
  47. package/dist/access-operations-batch.js +86 -78
  48. package/dist/access-operations.d.ts +18 -14
  49. package/dist/access-operations.js +91 -80
  50. package/dist/access-recall-concurrency.d.ts +16 -26
  51. package/dist/access-recall-concurrency.js +86 -77
  52. package/dist/access-recall-response.d.ts +18 -14
  53. package/dist/access-recall-response.js +84 -76
  54. package/dist/access-recall-surface.d.ts +29 -24
  55. package/dist/access-recall-surface.js +84 -76
  56. package/dist/access-schema.d.ts +84 -84
  57. package/dist/access-schema.js +3 -3
  58. package/dist/{access-service-CiJRsgAB.d.ts → access-service-CsU-ljFD.d.ts} +25 -16
  59. package/dist/access-service-helpers.d.ts +14 -10
  60. package/dist/access-service.d.ts +14 -10
  61. package/dist/access-service.js +84 -76
  62. package/dist/access-surface-catalog.d.ts +14 -10
  63. package/dist/access-surface-catalog.js +4 -0
  64. package/dist/access-surface-catalog.js.map +1 -1
  65. package/dist/access-wearables-meetings-surface.d.ts +4 -3
  66. package/dist/action-confidence.d.ts +2 -1
  67. package/dist/active-memory-bridge.d.ts +2 -1
  68. package/dist/active-recall.d.ts +2 -1
  69. package/dist/active-recall.js +10 -8
  70. package/dist/active-recall.js.map +1 -1
  71. package/dist/adapters/index.js +7 -7
  72. package/dist/adapters/registry.js +3 -3
  73. package/dist/{auto-sync-5OE5QOZB.js → auto-sync-UPTUVE4X.js} +6 -6
  74. package/dist/behavior-learner.d.ts +2 -1
  75. package/dist/behavior-learner.js +1 -1
  76. package/dist/behavior-signals.d.ts +2 -1
  77. package/dist/bootstrap.d.ts +9 -8
  78. package/dist/briefing.d.ts +3 -2
  79. package/dist/briefing.js +23 -22
  80. package/dist/buffer-surprise-report.d.ts +2 -1
  81. package/dist/buffer-turn-helpers.d.ts +2 -1
  82. package/dist/buffer.d.ts +3 -2
  83. package/dist/buffer.js +12 -11
  84. package/dist/bulk-import/index.d.ts +4 -3
  85. package/dist/calibration.d.ts +2 -1
  86. package/dist/capabilities.d.ts +2 -1
  87. package/dist/{capsule-merge-IDWJPCWK.js → capsule-merge-Q6AR3XL7.js} +67 -54
  88. package/dist/capsule-merge-Q6AR3XL7.js.map +1 -0
  89. package/dist/{catalog-scBmy0sO.d.ts → catalog-bctMURhN.d.ts} +1 -1
  90. package/dist/causal-behavior.d.ts +2 -1
  91. package/dist/causal-behavior.js +2 -2
  92. package/dist/causal-chain.js +2 -2
  93. package/dist/causal-consolidation.d.ts +2 -1
  94. package/dist/causal-consolidation.js +27 -26
  95. package/dist/causal-consolidation.js.map +1 -1
  96. package/dist/causal-retrieval.js +2 -2
  97. package/dist/causal-trajectory-graph.d.ts +2 -1
  98. package/dist/causal-trajectory.js +1 -1
  99. package/dist/{chunk-VUPTKTDV.js → chunk-2MRHJNWL.js} +3 -3
  100. package/dist/{chunk-JBPKEARU.js → chunk-2QSZNTDO.js} +7 -7
  101. package/dist/{chunk-5IVLTFOV.js → chunk-44N6ESJ4.js} +2 -2
  102. package/dist/{chunk-WOCNN776.js → chunk-4POAMKV6.js} +100 -41
  103. package/dist/chunk-4POAMKV6.js.map +1 -0
  104. package/dist/{chunk-HO3QBJEY.js → chunk-5546W5SI.js} +2 -2
  105. package/dist/{chunk-U7GW7NE7.js → chunk-5CEECY6P.js} +10 -10
  106. package/dist/{chunk-4UH4BTGK.js → chunk-5SNZSWWR.js} +82 -82
  107. package/dist/{chunk-6CZPDBJS.js → chunk-5U7ID3EZ.js} +3 -3
  108. package/dist/{chunk-GF22HWS2.js → chunk-6NNNURLK.js} +7 -7
  109. package/dist/chunk-773TRRGT.js +36 -0
  110. package/dist/chunk-773TRRGT.js.map +1 -0
  111. package/dist/chunk-7CITSYSH.js +242 -0
  112. package/dist/chunk-7CITSYSH.js.map +1 -0
  113. package/dist/{chunk-227UFSEQ.js → chunk-7RZJWZ46.js} +5 -5
  114. package/dist/{chunk-E5UK4VPE.js → chunk-7SHJHPTY.js} +5 -5
  115. package/dist/{chunk-UVIKWC7M.js → chunk-7YERSTN7.js} +17 -17
  116. package/dist/{chunk-DLVPUX7U.js → chunk-7YKVM5H3.js} +8 -6
  117. package/dist/chunk-7YKVM5H3.js.map +1 -0
  118. package/dist/{chunk-3CE77VAP.js → chunk-A4JMGKCD.js} +87 -74
  119. package/dist/chunk-A4JMGKCD.js.map +1 -0
  120. package/dist/chunk-A5KNZSNA.js +26 -0
  121. package/dist/chunk-A5KNZSNA.js.map +1 -0
  122. package/dist/{chunk-S2NCTZGJ.js → chunk-AJQ57VV3.js} +15 -15
  123. package/dist/chunk-AJQ57VV3.js.map +1 -0
  124. package/dist/{chunk-CUM2BBPN.js → chunk-AUMWZSE7.js} +19 -10
  125. package/dist/chunk-AUMWZSE7.js.map +1 -0
  126. package/dist/{chunk-XYTOI63Z.js → chunk-BGHFOD5A.js} +19 -11
  127. package/dist/chunk-BGHFOD5A.js.map +1 -0
  128. package/dist/{chunk-BUE5E2HL.js → chunk-BGLY7EEM.js} +5 -314
  129. package/dist/chunk-BGLY7EEM.js.map +1 -0
  130. package/dist/chunk-BIPBQQFI.js +44 -0
  131. package/dist/chunk-BIPBQQFI.js.map +1 -0
  132. package/dist/{chunk-S5SLVSVY.js → chunk-BQIFZ2MP.js} +5 -5
  133. package/dist/chunk-BTTPKDIL.js +34 -0
  134. package/dist/{chunk-PVGDJXVK.js.map → chunk-BTTPKDIL.js.map} +1 -1
  135. package/dist/{chunk-E53DSZEN.js → chunk-C26TE27X.js} +3 -3
  136. package/dist/{chunk-LZ4LDKHZ.js → chunk-CLB32OHM.js} +6 -6
  137. package/dist/{chunk-Q6IP2ARR.js → chunk-CSOYVTRX.js} +2 -2
  138. package/dist/{chunk-XOQSEF7X.js → chunk-CVILPI77.js} +6 -6
  139. package/dist/chunk-D3I2MCN7.js +29 -0
  140. package/dist/chunk-D3I2MCN7.js.map +1 -0
  141. package/dist/{chunk-A5OJCXZL.js → chunk-DSUAAZZX.js} +15 -4
  142. package/dist/chunk-DSUAAZZX.js.map +1 -0
  143. package/dist/{chunk-HREE4JHI.js → chunk-DYVMXPCF.js} +486 -287
  144. package/dist/chunk-DYVMXPCF.js.map +1 -0
  145. package/dist/{chunk-J7VGGECD.js → chunk-DZPFMQZ7.js} +1 -1
  146. package/dist/chunk-DZPFMQZ7.js.map +1 -0
  147. package/dist/{chunk-PDLBLTOK.js → chunk-EITZHSX6.js} +9 -9
  148. package/dist/{chunk-D3J5SLQK.js → chunk-EJHEWCGQ.js} +81 -20
  149. package/dist/chunk-EJHEWCGQ.js.map +1 -0
  150. package/dist/{chunk-WUNIWKY4.js → chunk-ELIL2A37.js} +6 -6
  151. package/dist/{chunk-E6PNLPGJ.js → chunk-FZP32336.js} +806 -470
  152. package/dist/chunk-FZP32336.js.map +1 -0
  153. package/dist/{chunk-4L6HUREQ.js → chunk-G7A5HLUS.js} +23 -17
  154. package/dist/chunk-G7A5HLUS.js.map +1 -0
  155. package/dist/{chunk-CINZGPSJ.js → chunk-GUMZC2BO.js} +2 -2
  156. package/dist/{chunk-H24WNPA2.js → chunk-GWFSVJ4P.js} +3 -3
  157. package/dist/{chunk-7XC2HX75.js → chunk-GYPQL6XN.js} +157 -16
  158. package/dist/chunk-GYPQL6XN.js.map +1 -0
  159. package/dist/{chunk-TSH56VPU.js → chunk-HAYSYUAB.js} +2 -2
  160. package/dist/{chunk-TDHTVMPG.js → chunk-HFPASSFV.js} +7 -2
  161. package/dist/chunk-HFPASSFV.js.map +1 -0
  162. package/dist/chunk-J2WC5LF4.js +395 -0
  163. package/dist/chunk-J2WC5LF4.js.map +1 -0
  164. package/dist/{chunk-PKNLM44P.js → chunk-JH6BPLOP.js} +9 -9
  165. package/dist/{chunk-KXB4VXHY.js → chunk-JIYDRBVZ.js} +2 -2
  166. package/dist/chunk-JV3C2MNQ.js +74 -0
  167. package/dist/chunk-JV3C2MNQ.js.map +1 -0
  168. package/dist/{chunk-AV5ZEH4M.js → chunk-KVJRXN2E.js} +2 -2
  169. package/dist/{chunk-JVLCVFQ4.js → chunk-KXEFRMCF.js} +3 -3
  170. package/dist/{chunk-WFTIGIIS.js → chunk-L6CQ7WIW.js} +5 -5
  171. package/dist/{chunk-EJUEXZHX.js → chunk-LLJMAULE.js} +2 -2
  172. package/dist/{chunk-N5Z4EVOR.js → chunk-LNEWDF2A.js} +36 -11
  173. package/dist/chunk-LNEWDF2A.js.map +1 -0
  174. package/dist/{chunk-AS7YMSL6.js → chunk-M23RF3LJ.js} +4 -4
  175. package/dist/{chunk-UYLMNVY6.js → chunk-MDISBSYA.js} +16 -9
  176. package/dist/chunk-MDISBSYA.js.map +1 -0
  177. package/dist/{chunk-3F2LKUMU.js → chunk-NIS256NW.js} +2 -2
  178. package/dist/{chunk-YIAA2X3D.js → chunk-NK5RGJ65.js} +3 -3
  179. package/dist/chunk-NLDVVWCL.js +84 -0
  180. package/dist/chunk-NLDVVWCL.js.map +1 -0
  181. package/dist/{chunk-OQ5PRDDS.js → chunk-NTOIP2E6.js} +6 -6
  182. package/dist/{chunk-HLPD7B7P.js → chunk-NUEQKLNB.js} +2 -2
  183. package/dist/{chunk-4J7G5SY4.js → chunk-NZBZ7IS2.js} +72 -24
  184. package/dist/chunk-NZBZ7IS2.js.map +1 -0
  185. package/dist/{chunk-3TBLDMJA.js → chunk-O4KMGRXE.js} +5 -2
  186. package/dist/chunk-O4KMGRXE.js.map +1 -0
  187. package/dist/{chunk-33PLLLL7.js → chunk-P7NGM24P.js} +6 -6
  188. package/dist/{chunk-7TWUCYER.js → chunk-PNRA7FAD.js} +7 -7
  189. package/dist/{chunk-5I4M26Q7.js → chunk-QBSFOKY6.js} +4 -4
  190. package/dist/{chunk-QJAQNXWI.js → chunk-QCECHYZL.js} +76 -79
  191. package/dist/chunk-QCECHYZL.js.map +1 -0
  192. package/dist/{chunk-P4DRWEYC.js → chunk-QVSBTCVP.js} +2 -2
  193. package/dist/{chunk-AAIUERNB.js → chunk-R5RFK3CB.js} +6 -6
  194. package/dist/{chunk-WDISJRMG.js → chunk-RMMVQQA6.js} +2 -2
  195. package/dist/{chunk-KWMXR7XS.js → chunk-S2V7RUCL.js} +8 -1
  196. package/dist/{chunk-KWMXR7XS.js.map → chunk-S2V7RUCL.js.map} +1 -1
  197. package/dist/{chunk-5SM35XZR.js → chunk-S5NZBKKQ.js} +2 -2
  198. package/dist/{chunk-VNA7W7QF.js → chunk-SVH57F5Z.js} +12 -4
  199. package/dist/chunk-SVH57F5Z.js.map +1 -0
  200. package/dist/{chunk-WIPEXG6R.js → chunk-SXIMQLGV.js} +2 -2
  201. package/dist/{chunk-RVLJEII5.js → chunk-SYUBB3WM.js} +256 -187
  202. package/dist/chunk-SYUBB3WM.js.map +1 -0
  203. package/dist/{chunk-OAEQLRCY.js → chunk-TN76AKO3.js} +5 -5
  204. package/dist/{chunk-QN25OCUF.js → chunk-TQ4GD737.js} +5 -5
  205. package/dist/{chunk-VCD4PSK2.js → chunk-TQZ4DVBC.js} +7 -4
  206. package/dist/chunk-TQZ4DVBC.js.map +1 -0
  207. package/dist/{chunk-7K5Q6COX.js → chunk-TVVEYCNW.js} +4 -4
  208. package/dist/{chunk-DNWXFTLD.js → chunk-TYISDI6B.js} +2 -2
  209. package/dist/{chunk-4LMA77JH.js → chunk-U2VLVBBH.js} +3 -3
  210. package/dist/{chunk-5ZE7QHTK.js → chunk-ULVR5KG7.js} +5 -5
  211. package/dist/{chunk-NVRYW264.js → chunk-UQWIKLQK.js} +18 -15
  212. package/dist/chunk-UQWIKLQK.js.map +1 -0
  213. package/dist/{chunk-YV32N67O.js → chunk-URS5GSM7.js} +1 -1
  214. package/dist/chunk-URS5GSM7.js.map +1 -0
  215. package/dist/{chunk-4B77XSG5.js → chunk-UV72DEZD.js} +5 -5
  216. package/dist/{chunk-S2BBISHU.js → chunk-VANZKHTN.js} +3 -3
  217. package/dist/chunk-VHFXP27N.js +250 -0
  218. package/dist/chunk-VHFXP27N.js.map +1 -0
  219. package/dist/{chunk-3Y224NYC.js → chunk-VYISFWVX.js} +2 -2
  220. package/dist/{chunk-TIHMZFIV.js → chunk-W3IC7QOY.js} +3 -3
  221. package/dist/{chunk-NRV4Y3PM.js → chunk-W4FBGYGK.js} +1 -1
  222. package/dist/{chunk-P2BM76KT.js → chunk-WAS4HV46.js} +174 -43
  223. package/dist/chunk-WAS4HV46.js.map +1 -0
  224. package/dist/{chunk-57QKLRBV.js → chunk-WB7JSQCP.js} +2 -1
  225. package/dist/chunk-WB7JSQCP.js.map +1 -0
  226. package/dist/chunk-WGP57SR3.js +68 -0
  227. package/dist/chunk-WGP57SR3.js.map +1 -0
  228. package/dist/{chunk-ECK75GDJ.js → chunk-WQIHRA5F.js} +43 -24
  229. package/dist/chunk-WQIHRA5F.js.map +1 -0
  230. package/dist/{chunk-MU7ZHSZE.js → chunk-WZFAPHIK.js} +2 -2
  231. package/dist/{chunk-T2TTP3KU.js → chunk-X4IDNPOS.js} +2 -2
  232. package/dist/{chunk-BLAKS3CP.js → chunk-XL3TATMJ.js} +3 -3
  233. package/dist/{chunk-W4XJFLAL.js → chunk-XPRJSHNI.js} +2 -2
  234. package/dist/{chunk-5TFP4CUL.js → chunk-XQ3HXAQH.js} +14 -11
  235. package/dist/chunk-XQ3HXAQH.js.map +1 -0
  236. package/dist/{chunk-VWAXN2BN.js → chunk-XSFHWBQO.js} +93 -31
  237. package/dist/chunk-XSFHWBQO.js.map +1 -0
  238. package/dist/{chunk-DL7ZD3JH.js → chunk-XTAUXTDO.js} +14 -9
  239. package/dist/chunk-XTAUXTDO.js.map +1 -0
  240. package/dist/{chunk-JE7EK33X.js → chunk-Y7HRYCNW.js} +2 -2
  241. package/dist/{chunk-E6EE5B67.js → chunk-YK6BDDHP.js} +4 -4
  242. package/dist/{chunk-ES36HTSC.js → chunk-YLHM5BQQ.js} +3 -3
  243. package/dist/{chunk-RN7DY3FC.js → chunk-YMAQDHQM.js} +31 -12
  244. package/dist/chunk-YMAQDHQM.js.map +1 -0
  245. package/dist/{chunk-ULARSG5Z.js → chunk-YN6ASZUG.js} +10 -8
  246. package/dist/{chunk-ULARSG5Z.js.map → chunk-YN6ASZUG.js.map} +1 -1
  247. package/dist/{chunk-IKKWIPYN.js → chunk-YYQAKIDJ.js} +37 -1
  248. package/dist/chunk-YYQAKIDJ.js.map +1 -0
  249. package/dist/{chunk-BJKPPZ6Z.js → chunk-ZFGZ6PZ2.js} +2 -2
  250. package/dist/{chunk-CJ2ZR7UA.js → chunk-ZI32MKDW.js} +267 -214
  251. package/dist/chunk-ZI32MKDW.js.map +1 -0
  252. package/dist/{chunk-64UDOIMI.js → chunk-ZLQ37WJX.js} +2 -2
  253. package/dist/chunk-ZMAYKGPN.js +351 -0
  254. package/dist/chunk-ZMAYKGPN.js.map +1 -0
  255. package/dist/{cli-BUGN3d6_.d.ts → cli-BBHDtG36.d.ts} +5 -5
  256. package/dist/cli.d.ts +16 -12
  257. package/dist/cli.js +138 -124
  258. package/dist/compounding/engine.d.ts +3 -2
  259. package/dist/compounding/engine.js +24 -23
  260. package/dist/compounding/preference-consolidator.d.ts +2 -1
  261. package/dist/compression-optimizer.d.ts +2 -1
  262. package/dist/config.d.ts +2 -1
  263. package/dist/config.js +10 -8
  264. package/dist/connectors/codex-materialize-runner.d.ts +2 -1
  265. package/dist/connectors/codex-materialize-runner.js +23 -22
  266. package/dist/connectors/codex-materialize.d.ts +2 -1
  267. package/dist/connectors/index.d.ts +2 -1
  268. package/dist/connectors/index.js +26 -25
  269. package/dist/consolidation-provenance-check.d.ts +3 -2
  270. package/dist/consolidation-provenance-check.js +4 -4
  271. package/dist/consolidation-undo.d.ts +3 -2
  272. package/dist/consolidation-undo.js +10 -7
  273. package/dist/consolidation-undo.js.map +1 -1
  274. package/dist/contradiction/index.d.ts +3 -2
  275. package/dist/converge-config.d.ts +2 -1
  276. package/dist/convergence-refresh.d.ts +4 -3
  277. package/dist/convergence-refresh.js +27 -26
  278. package/dist/conversation-index/backend.d.ts +2 -1
  279. package/dist/conversation-index/backend.js +2 -2
  280. package/dist/conversation-index/chunker.d.ts +2 -1
  281. package/dist/conversation-index/faiss-adapter.d.ts +2 -1
  282. package/dist/conversation-index/indexer.d.ts +2 -1
  283. package/dist/conversation-index/search.d.ts +2 -1
  284. package/dist/corpus-watermark.d.ts +2 -1
  285. package/dist/corpus-watermark.js +42 -41
  286. package/dist/day-summary.d.ts +2 -1
  287. package/dist/delinearize.d.ts +2 -1
  288. package/dist/direct-answer-wiring.d.ts +2 -1
  289. package/dist/direct-answer-wiring.js +2 -2
  290. package/dist/direct-answer.d.ts +2 -1
  291. package/dist/embedding-fallback.d.ts +2 -1
  292. package/dist/embedding-fallback.js +2 -2
  293. package/dist/enrichment/index.d.ts +2 -1
  294. package/dist/entity-retrieval-boundaries.js +1 -1
  295. package/dist/entity-retrieval.d.ts +3 -2
  296. package/dist/entity-retrieval.js +24 -23
  297. package/dist/entity-schema.d.ts +2 -1
  298. package/dist/explicit-capture.d.ts +9 -8
  299. package/dist/explicit-capture.js +11 -9
  300. package/dist/external-wiki-access.d.ts +127 -0
  301. package/dist/external-wiki-access.js +186 -0
  302. package/dist/external-wiki-access.js.map +1 -0
  303. package/dist/external-wiki-cli.d.ts +13 -0
  304. package/dist/external-wiki-cli.js +96 -0
  305. package/dist/external-wiki-cli.js.map +1 -0
  306. package/dist/external-wiki-collection-registration.d.ts +39 -0
  307. package/dist/external-wiki-collection-registration.js +79 -0
  308. package/dist/external-wiki-collection-registration.js.map +1 -0
  309. package/dist/external-wiki-collection.d.ts +50 -0
  310. package/dist/external-wiki-collection.js +387 -0
  311. package/dist/external-wiki-collection.js.map +1 -0
  312. package/dist/external-wiki-config.d.ts +13 -0
  313. package/dist/external-wiki-config.js +13 -0
  314. package/dist/external-wiki-config.js.map +1 -0
  315. package/dist/external-wiki-guard.d.ts +11 -0
  316. package/dist/external-wiki-guard.js +18 -0
  317. package/dist/external-wiki-guard.js.map +1 -0
  318. package/dist/external-wiki-mcp-tools.d.ts +123 -0
  319. package/dist/external-wiki-mcp-tools.js +8 -0
  320. package/dist/external-wiki-mcp-tools.js.map +1 -0
  321. package/dist/external-wiki-search.d.ts +42 -0
  322. package/dist/external-wiki-search.js +11 -0
  323. package/dist/external-wiki-search.js.map +1 -0
  324. package/dist/external-wiki.d.ts +43 -0
  325. package/dist/external-wiki.js +16 -0
  326. package/dist/external-wiki.js.map +1 -0
  327. package/dist/extraction-error-classification.d.ts +2 -1
  328. package/dist/extraction-faithfulness.d.ts +2 -1
  329. package/dist/extraction-judge-telemetry.d.ts +2 -1
  330. package/dist/extraction-judge-training.d.ts +2 -1
  331. package/dist/extraction-judge.d.ts +2 -1
  332. package/dist/extraction-liveness.d.ts +2 -1
  333. package/dist/extraction-source-grounding-helpers.d.ts +5 -3
  334. package/dist/extraction-source-grounding-helpers.js +1 -1
  335. package/dist/extraction-source-grounding-rules.d.ts +2 -1
  336. package/dist/extraction-source-grounding-rules.js +2 -2
  337. package/dist/extraction-source-grounding.d.ts +2 -1
  338. package/dist/extraction-source-grounding.js +5 -5
  339. package/dist/extraction.d.ts +2 -1
  340. package/dist/extraction.js +45 -43
  341. package/dist/fallback-llm.d.ts +2 -1
  342. package/dist/graph-dashboard-diff.d.ts +2 -1
  343. package/dist/graph-dashboard-key.d.ts +2 -1
  344. package/dist/graph-dashboard-parser.d.ts +2 -1
  345. package/dist/graph-edge-reinforcement.d.ts +2 -1
  346. package/dist/graph-snapshot.d.ts +2 -1
  347. package/dist/graph.d.ts +2 -1
  348. package/dist/harmonic-retrieval.js +2 -2
  349. package/dist/importance.d.ts +2 -1
  350. package/dist/importers/index.d.ts +2 -1
  351. package/dist/in-flight-reads.d.ts +2 -1
  352. package/dist/index.d.ts +732 -720
  353. package/dist/index.js +291 -259
  354. package/dist/intent.d.ts +2 -1
  355. package/dist/lcm/engine.d.ts +2 -1
  356. package/dist/lcm/engine.js +3 -3
  357. package/dist/lcm/index.d.ts +2 -1
  358. package/dist/lcm/index.js +8 -8
  359. package/dist/lcm/tools.d.ts +2 -1
  360. package/dist/lifecycle.d.ts +2 -1
  361. package/dist/live-connectors-runner.d.ts +2 -1
  362. package/dist/local-llm.d.ts +2 -1
  363. package/dist/local-llm.js +2 -2
  364. package/dist/local-model-endpoint.d.ts +2 -1
  365. package/dist/maintenance/memory-governance.d.ts +2 -1
  366. package/dist/maintenance/memory-governance.js +24 -23
  367. package/dist/maintenance/rebuild-memory-lifecycle-ledger.d.ts +3 -2
  368. package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +24 -23
  369. package/dist/maintenance/rebuild-memory-projection.d.ts +3 -2
  370. package/dist/maintenance/rebuild-memory-projection.js +26 -25
  371. package/dist/{maintenance-LbuS2rUA.d.ts → maintenance-D2mveyCd.d.ts} +3 -3
  372. package/dist/mcp-memory-inspector-app.d.ts +14 -10
  373. package/dist/mcp-read-only-tools.js +1 -1
  374. package/dist/memory-action-policy.d.ts +2 -1
  375. package/dist/memory-cache.d.ts +2 -1
  376. package/dist/memory-lifecycle-ledger-utils.d.ts +2 -1
  377. package/dist/memory-projection-store.d.ts +2 -1
  378. package/dist/memory-provenance.d.ts +2 -1
  379. package/dist/memory-worth-outcomes.d.ts +3 -2
  380. package/dist/models-json.d.ts +2 -1
  381. package/dist/namespaces/migrate.d.ts +4 -3
  382. package/dist/namespaces/migrate.js +40 -39
  383. package/dist/namespaces/principal.d.ts +2 -1
  384. package/dist/namespaces/search.d.ts +2 -1
  385. package/dist/namespaces/search.js +18 -18
  386. package/dist/namespaces/storage.d.ts +4 -3
  387. package/dist/namespaces/storage.js +23 -22
  388. package/dist/native-knowledge.d.ts +2 -1
  389. package/dist/offline-sync-impression-drain.d.ts +2 -1
  390. package/dist/offline-sync-impression-drain.js +11 -9
  391. package/dist/offline-sync.d.ts +29 -3
  392. package/dist/offline-sync.js +6 -2
  393. package/dist/operator-doctor-corpus.d.ts +2 -1
  394. package/dist/operator-doctor-corpus.js +45 -44
  395. package/dist/operator-doctor-replica.d.ts +2 -1
  396. package/dist/operator-doctor-replica.js +3 -3
  397. package/dist/operator-toolkit.d.ts +4 -3
  398. package/dist/operator-toolkit.js +59 -55
  399. package/dist/orchestration/compression-guideline-coordinator.d.ts +3 -2
  400. package/dist/orchestration/maintenance.d.ts +5 -4
  401. package/dist/orchestration/maintenance.js +36 -33
  402. package/dist/{orchestrator-rHiWt32X.d.ts → orchestrator-DJYlwiUv.d.ts} +14 -7
  403. package/dist/orchestrator.d.ts +9 -8
  404. package/dist/orchestrator.js +201 -189
  405. package/dist/page-versioning.js +3 -3
  406. package/dist/patterns-cli.d.ts +2 -1
  407. package/dist/{pipeline-W_97O8BV.d.ts → pipeline-CNjY4wk3.d.ts} +1 -1
  408. package/dist/policy-runtime.d.ts +2 -1
  409. package/dist/policy-runtime.js +1 -1
  410. package/dist/proactive-contention.d.ts +2 -1
  411. package/dist/provenance.d.ts +2 -1
  412. package/dist/provenance.js +2 -2
  413. package/dist/{qmd-LWtMofAf.d.ts → qmd-C0UDZidt.d.ts} +9 -7
  414. package/dist/qmd-preflight.d.ts +5 -4
  415. package/dist/qmd-preflight.js +2 -2
  416. package/dist/qmd-recall-cache.d.ts +2 -1
  417. package/dist/qmd.d.ts +4 -3
  418. package/dist/qmd.js +5 -5
  419. package/dist/recall-concurrency-config.d.ts +2 -1
  420. package/dist/recall-disclosure-escalation.d.ts +2 -1
  421. package/dist/recall-explain-renderer.d.ts +2 -1
  422. package/dist/recall-explain-renderer.js +3 -3
  423. package/dist/recall-memory-map.d.ts +2 -1
  424. package/dist/recall-planner-llm.d.ts +2 -1
  425. package/dist/recall-state.d.ts +2 -1
  426. package/dist/recall-tag-filter.d.ts +2 -1
  427. package/dist/recall-timings.d.ts +2 -1
  428. package/dist/recall-xray-cli.d.ts +2 -1
  429. package/dist/recall-xray-cli.js +4 -4
  430. package/dist/recall-xray-renderer.d.ts +2 -1
  431. package/dist/recall-xray-renderer.js +3 -3
  432. package/dist/recall-xray.d.ts +8 -1
  433. package/dist/recall-xray.js +2 -2
  434. package/dist/reconcile/cursor.d.ts +12 -2
  435. package/dist/reconcile/cursor.js +46 -7
  436. package/dist/reconcile/cursor.js.map +1 -1
  437. package/dist/reconcile/manifest.d.ts +9 -2
  438. package/dist/reconcile/manifest.js +15 -268
  439. package/dist/reconcile/manifest.js.map +1 -1
  440. package/dist/reconcile/plan.d.ts +6 -2
  441. package/dist/reconcile/plan.js +4 -4
  442. package/dist/replay/normalizers/chatgpt.d.ts +2 -1
  443. package/dist/replay/normalizers/claude.d.ts +2 -1
  444. package/dist/replay/normalizers/openclaw.d.ts +2 -1
  445. package/dist/replay/normalizers/shared.d.ts +2 -1
  446. package/dist/replay/runner.d.ts +2 -1
  447. package/dist/replay/types.d.ts +2 -1
  448. package/dist/replica-divergence.d.ts +2 -1
  449. package/dist/replica-divergence.js +2 -2
  450. package/dist/replica-peers-config.d.ts +2 -1
  451. package/dist/resolve-auth-token.d.ts +2 -1
  452. package/dist/resume-bundles.js +12 -10
  453. package/dist/retrieval-agents.d.ts +4 -3
  454. package/dist/retrieval-agents.js +2 -2
  455. package/dist/retrieval-tiers.d.ts +2 -1
  456. package/dist/routing/engine.d.ts +2 -1
  457. package/dist/routing/store.d.ts +2 -1
  458. package/dist/salvage-envelope.d.ts +2 -1
  459. package/dist/schemas.d.ts +76 -76
  460. package/dist/{scope-profiles-BiQKOE-p.d.ts → scope-profiles-BJzp2F5A.d.ts} +1 -1
  461. package/dist/search/embed-helper.d.ts +2 -1
  462. package/dist/search/embed-helper.js +3 -3
  463. package/dist/search/factory.d.ts +4 -2
  464. package/dist/search/factory.js +20 -18
  465. package/dist/search/index.d.ts +2 -1
  466. package/dist/search/index.js +22 -22
  467. package/dist/search/lancedb-backend.d.ts +2 -1
  468. package/dist/search/lancedb-backend.js +4 -4
  469. package/dist/search/meilisearch-backend.d.ts +2 -1
  470. package/dist/search/meilisearch-backend.js +4 -4
  471. package/dist/search/noop-backend.d.ts +2 -1
  472. package/dist/search/orama-backend.d.ts +2 -1
  473. package/dist/search/orama-backend.js +4 -4
  474. package/dist/search/port.d.ts +18 -1
  475. package/dist/search/port.js +1 -1
  476. package/dist/search/remote-backend.d.ts +2 -1
  477. package/dist/search/remote-backend.js +2 -2
  478. package/dist/secure-store/index.js +2 -2
  479. package/dist/{semantic-consolidation-dHYCyqgh.d.ts → semantic-consolidation-D4KAZO2G.d.ts} +1 -1
  480. package/dist/semantic-consolidation.d.ts +3 -2
  481. package/dist/semantic-consolidation.js +25 -24
  482. package/dist/semantic-rule-promotion.js +23 -22
  483. package/dist/semantic-rule-verifier.d.ts +2 -1
  484. package/dist/semantic-rule-verifier.js +24 -23
  485. package/dist/{service-DJG3KCQ4.d.ts → service-BeDxSqE-.d.ts} +2 -2
  486. package/dist/session-observer-bands.d.ts +2 -1
  487. package/dist/session-observer-state.d.ts +2 -1
  488. package/dist/shared-context/manager.d.ts +10 -9
  489. package/dist/shared-context/manager.js +2 -2
  490. package/dist/signal.d.ts +2 -1
  491. package/dist/source-agent-qualifier.d.ts +2 -1
  492. package/dist/source-agent-qualifier.js +42 -40
  493. package/dist/{storage-F9FVh-w9.d.ts → storage-DfjxusTE.d.ts} +24 -12
  494. package/dist/storage.d.ts +3 -2
  495. package/dist/storage.js +25 -24
  496. package/dist/summarizer.d.ts +2 -1
  497. package/dist/summarizer.js +5 -5
  498. package/dist/summary-snapshot.d.ts +2 -1
  499. package/dist/temporal-supersession.d.ts +3 -2
  500. package/dist/temporal-timeline-recall.d.ts +2 -1
  501. package/dist/temporal-validity.d.ts +2 -1
  502. package/dist/threading.d.ts +2 -1
  503. package/dist/tier-migration.d.ts +3 -2
  504. package/dist/tier-routing.d.ts +2 -1
  505. package/dist/tool-scoped-memory.d.ts +5 -1
  506. package/dist/tool-scoped-memory.js +3 -1
  507. package/dist/topics.d.ts +2 -1
  508. package/dist/transcript.d.ts +2 -1
  509. package/dist/transfer/capsule-import.js +4 -4
  510. package/dist/transfer/types.d.ts +66 -66
  511. package/dist/trust-score-stage.d.ts +2 -1
  512. package/dist/trust-score.d.ts +2 -1
  513. package/dist/{types-rEwubvim.d.ts → types-yX_FwERf.d.ts} +8 -1
  514. package/dist/types.d.ts +2 -1
  515. package/dist/types.js +1 -1
  516. package/dist/utility-runtime.d.ts +2 -1
  517. package/dist/verified-recall.js +24 -23
  518. package/dist/write-envelope.d.ts +2 -1
  519. package/package.json +2 -2
  520. package/src/abort-error.ts +17 -0
  521. package/src/access-admin-ops-surface.ts +1 -0
  522. package/src/access-boundary.ts +1 -0
  523. package/src/access-coding-context-resolution.ts +42 -0
  524. package/src/access-extraction-force-flush.ts +38 -2
  525. package/src/access-http-lcm-compaction.ts +5 -2
  526. package/src/access-http-offline-stream.ts +79 -0
  527. package/src/access-http.test.ts +310 -3
  528. package/src/access-http.ts +85 -21
  529. package/src/access-mcp-output-schemas.ts +36 -0
  530. package/src/access-mcp.test.ts +95 -1
  531. package/src/access-mcp.ts +7 -9
  532. package/src/access-observe-helpers.ts +64 -22
  533. package/src/access-observe-write-surface.ts +8 -0
  534. package/src/access-offline-manifest.ts +54 -0
  535. package/src/access-operations-batch.ts +3 -3
  536. package/src/access-operations.ts +13 -7
  537. package/src/access-recall-concurrency.ts +3 -27
  538. package/src/access-recall-surface.ts +3 -0
  539. package/src/access-service-health.test.ts +32 -7
  540. package/src/access-service-namespace.test.ts +55 -0
  541. package/src/access-service-observe-idempotency.test.ts +34 -2
  542. package/src/access-service-observe-lcm-parity.test.ts +138 -3
  543. package/src/access-service-observe-scope.test.ts +160 -1
  544. package/src/access-service-offline-file-content.test.ts +345 -1
  545. package/src/access-service.ts +86 -59
  546. package/src/access-surface-catalog.ts +4 -0
  547. package/src/admin/admin-surfaces.ts +2 -0
  548. package/src/binary-lifecycle/pipeline.test.ts +106 -1
  549. package/src/binary-lifecycle/pipeline.ts +3 -0
  550. package/src/coding/git-context.test.ts +47 -0
  551. package/src/coding/git-context.ts +129 -27
  552. package/src/config.test.ts +24 -0
  553. package/src/config.ts +9 -12
  554. package/src/connector-provenance.test.ts +101 -0
  555. package/src/consolidation-undo.ts +3 -0
  556. package/src/converge-conflict-policy-type.test.ts +15 -0
  557. package/src/convergence-refresh.ts +14 -2
  558. package/src/correction/correction-access-wiring.ts +9 -7
  559. package/src/correction/correction-executor.test.ts +206 -2
  560. package/src/correction/correction-executor.ts +29 -20
  561. package/src/correction/correction-planner.test.ts +36 -0
  562. package/src/correction/correction-planner.ts +9 -15
  563. package/src/correction/correction-service.ts +3 -1
  564. package/src/correction/correction-storage-integration.test.ts +77 -0
  565. package/src/correction/correction-surfaces.test.ts +41 -28
  566. package/src/correction/passive-capture.test.ts +59 -0
  567. package/src/correction/passive-capture.ts +4 -1
  568. package/src/entity-retrieval-boundaries.ts +17 -4
  569. package/src/entity-retrieval.ts +27 -6
  570. package/src/external-wiki-access.test.ts +65 -0
  571. package/src/external-wiki-access.ts +31 -0
  572. package/src/external-wiki-cli.ts +92 -0
  573. package/src/external-wiki-collection-registration.test.ts +163 -0
  574. package/src/external-wiki-collection-registration.ts +101 -0
  575. package/src/external-wiki-collection.test.ts +502 -0
  576. package/src/external-wiki-collection.ts +503 -0
  577. package/src/external-wiki-config.test.ts +135 -0
  578. package/src/external-wiki-config.ts +100 -0
  579. package/src/external-wiki-guard.ts +83 -0
  580. package/src/external-wiki-mcp-tools.ts +23 -0
  581. package/src/external-wiki-search.test.ts +301 -0
  582. package/src/external-wiki-search.ts +362 -0
  583. package/src/external-wiki.test.ts +240 -0
  584. package/src/external-wiki.ts +453 -0
  585. package/src/extraction-scope-source-agent.test.ts +21 -0
  586. package/src/extraction-source-grounding-helpers.ts +243 -53
  587. package/src/extraction-source-grounding-rules.ts +133 -39
  588. package/src/extraction-source-grounding.test.ts +363 -33
  589. package/src/extraction-timeout.test.ts +1 -0
  590. package/src/extraction-watermark.test.ts +150 -7
  591. package/src/extraction.ts +8 -1
  592. package/src/index.ts +8 -0
  593. package/src/mcp-read-only-tools.ts +1 -0
  594. package/src/offline-sync.test.ts +194 -0
  595. package/src/offline-sync.ts +217 -13
  596. package/src/orchestration/external-wiki-recall-guard.test.ts +94 -0
  597. package/src/orchestration/extraction-persist.ts +19 -2
  598. package/src/orchestration/extraction-run-helpers.ts +37 -19
  599. package/src/orchestration/extraction-run.test.ts +171 -2
  600. package/src/orchestration/extraction-run.ts +11 -13
  601. package/src/orchestration/extraction-watermark.ts +106 -17
  602. package/src/orchestration/generic-recall-paths.ts +14 -0
  603. package/src/orchestration/orchestrator-helpers.ts +2 -0
  604. package/src/orchestration/orchestrator-init.ts +9 -0
  605. package/src/orchestration/recall-internal-deps.ts +6 -0
  606. package/src/orchestration/recall-internal.ts +154 -33
  607. package/src/orchestration/recall-rerank-coordinator.ts +60 -25
  608. package/src/orchestration/recall-search-pipeline.test.ts +75 -1
  609. package/src/orchestration/recall-search-pipeline.ts +50 -10
  610. package/src/orchestrator-convergence-refresh.test.ts +36 -2
  611. package/src/orchestrator.ts +13 -3
  612. package/src/page-versioning.ts +5 -19
  613. package/src/procedural/procedure-recall.ts +5 -1
  614. package/src/provenance-surfaces.test.ts +3 -0
  615. package/src/qmd-client.test.ts +78 -17
  616. package/src/qmd.test.ts +24 -0
  617. package/src/qmd.ts +224 -315
  618. package/src/recall-explain-renderer.ts +3 -0
  619. package/src/recall-rerank-coordinator.test.ts +61 -0
  620. package/src/recall-xray-renderer.test.ts +6 -0
  621. package/src/recall-xray.test.ts +88 -1
  622. package/src/recall-xray.ts +15 -0
  623. package/src/reconcile/cursor.test.ts +48 -0
  624. package/src/reconcile/cursor.ts +58 -11
  625. package/src/reconcile/manifest.test.ts +4 -0
  626. package/src/reconcile/manifest.ts +41 -51
  627. package/src/reconcile/plan.test.ts +4 -0
  628. package/src/reconcile/plan.ts +29 -16
  629. package/src/search/factory.ts +6 -6
  630. package/src/search/port.ts +25 -9
  631. package/src/secure-store/secure-fs.ts +20 -12
  632. package/src/secure-store/secure-store.test.ts +41 -2
  633. package/src/spaces/index.test.ts +61 -2
  634. package/src/spaces/index.ts +44 -18
  635. package/src/storage/entity-alias-config.ts +97 -0
  636. package/src/storage/entity-canonical-id-lock.ts +53 -23
  637. package/src/storage/entity-canonical-id-migration.ts +53 -22
  638. package/src/storage/entity-canonical-id-references.ts +3 -0
  639. package/src/storage/entity-id-safety.ts +7 -0
  640. package/src/storage/entity-store.ts +6 -2
  641. package/src/storage/memory-frontmatter-metadata.ts +4 -9
  642. package/src/storage/memory-migration-serialization.ts +10 -15
  643. package/src/storage/tombstone-blocked-capture-mutation.ts +52 -64
  644. package/src/storage/tombstone-blocked-capture-sync.ts +244 -199
  645. package/src/storage-deletion-revisions.test.ts +91 -0
  646. package/src/storage-fact-hash-index-defer.test.ts +446 -163
  647. package/src/storage.ts +534 -245
  648. package/src/tool-scoped-memory.ts +10 -0
  649. package/src/transfer/capsule-import.ts +13 -0
  650. package/src/transfer/capsule-merge.ts +13 -0
  651. package/src/trust-score-recall-paths.test.ts +75 -1
  652. package/src/types.ts +7 -3
  653. package/dist/capsule-merge-IDWJPCWK.js.map +0 -1
  654. package/dist/chunk-3CE77VAP.js.map +0 -1
  655. package/dist/chunk-3TBLDMJA.js.map +0 -1
  656. package/dist/chunk-4J7G5SY4.js.map +0 -1
  657. package/dist/chunk-4L6HUREQ.js.map +0 -1
  658. package/dist/chunk-57QKLRBV.js.map +0 -1
  659. package/dist/chunk-5TFP4CUL.js.map +0 -1
  660. package/dist/chunk-7XC2HX75.js.map +0 -1
  661. package/dist/chunk-A5OJCXZL.js.map +0 -1
  662. package/dist/chunk-BUE5E2HL.js.map +0 -1
  663. package/dist/chunk-CJ2ZR7UA.js.map +0 -1
  664. package/dist/chunk-CUM2BBPN.js.map +0 -1
  665. package/dist/chunk-D3J5SLQK.js.map +0 -1
  666. package/dist/chunk-DL7ZD3JH.js.map +0 -1
  667. package/dist/chunk-DLVPUX7U.js.map +0 -1
  668. package/dist/chunk-E6PNLPGJ.js.map +0 -1
  669. package/dist/chunk-ECK75GDJ.js.map +0 -1
  670. package/dist/chunk-HREE4JHI.js.map +0 -1
  671. package/dist/chunk-IKKWIPYN.js.map +0 -1
  672. package/dist/chunk-J7VGGECD.js.map +0 -1
  673. package/dist/chunk-N5Z4EVOR.js.map +0 -1
  674. package/dist/chunk-NVRYW264.js.map +0 -1
  675. package/dist/chunk-P2BM76KT.js.map +0 -1
  676. package/dist/chunk-PVGDJXVK.js +0 -21
  677. package/dist/chunk-QJAQNXWI.js.map +0 -1
  678. package/dist/chunk-RN7DY3FC.js.map +0 -1
  679. package/dist/chunk-RVLJEII5.js.map +0 -1
  680. package/dist/chunk-S2NCTZGJ.js.map +0 -1
  681. package/dist/chunk-TDHTVMPG.js.map +0 -1
  682. package/dist/chunk-UYLMNVY6.js.map +0 -1
  683. package/dist/chunk-VCD4PSK2.js.map +0 -1
  684. package/dist/chunk-VNA7W7QF.js.map +0 -1
  685. package/dist/chunk-VWAXN2BN.js.map +0 -1
  686. package/dist/chunk-WOCNN776.js.map +0 -1
  687. package/dist/chunk-XYTOI63Z.js.map +0 -1
  688. package/dist/chunk-YV32N67O.js.map +0 -1
  689. /package/dist/{auto-sync-5OE5QOZB.js.map → auto-sync-UPTUVE4X.js.map} +0 -0
  690. /package/dist/{chunk-VUPTKTDV.js.map → chunk-2MRHJNWL.js.map} +0 -0
  691. /package/dist/{chunk-JBPKEARU.js.map → chunk-2QSZNTDO.js.map} +0 -0
  692. /package/dist/{chunk-5IVLTFOV.js.map → chunk-44N6ESJ4.js.map} +0 -0
  693. /package/dist/{chunk-HO3QBJEY.js.map → chunk-5546W5SI.js.map} +0 -0
  694. /package/dist/{chunk-U7GW7NE7.js.map → chunk-5CEECY6P.js.map} +0 -0
  695. /package/dist/{chunk-4UH4BTGK.js.map → chunk-5SNZSWWR.js.map} +0 -0
  696. /package/dist/{chunk-6CZPDBJS.js.map → chunk-5U7ID3EZ.js.map} +0 -0
  697. /package/dist/{chunk-GF22HWS2.js.map → chunk-6NNNURLK.js.map} +0 -0
  698. /package/dist/{chunk-227UFSEQ.js.map → chunk-7RZJWZ46.js.map} +0 -0
  699. /package/dist/{chunk-E5UK4VPE.js.map → chunk-7SHJHPTY.js.map} +0 -0
  700. /package/dist/{chunk-UVIKWC7M.js.map → chunk-7YERSTN7.js.map} +0 -0
  701. /package/dist/{chunk-S5SLVSVY.js.map → chunk-BQIFZ2MP.js.map} +0 -0
  702. /package/dist/{chunk-E53DSZEN.js.map → chunk-C26TE27X.js.map} +0 -0
  703. /package/dist/{chunk-LZ4LDKHZ.js.map → chunk-CLB32OHM.js.map} +0 -0
  704. /package/dist/{chunk-Q6IP2ARR.js.map → chunk-CSOYVTRX.js.map} +0 -0
  705. /package/dist/{chunk-XOQSEF7X.js.map → chunk-CVILPI77.js.map} +0 -0
  706. /package/dist/{chunk-PDLBLTOK.js.map → chunk-EITZHSX6.js.map} +0 -0
  707. /package/dist/{chunk-WUNIWKY4.js.map → chunk-ELIL2A37.js.map} +0 -0
  708. /package/dist/{chunk-CINZGPSJ.js.map → chunk-GUMZC2BO.js.map} +0 -0
  709. /package/dist/{chunk-H24WNPA2.js.map → chunk-GWFSVJ4P.js.map} +0 -0
  710. /package/dist/{chunk-TSH56VPU.js.map → chunk-HAYSYUAB.js.map} +0 -0
  711. /package/dist/{chunk-PKNLM44P.js.map → chunk-JH6BPLOP.js.map} +0 -0
  712. /package/dist/{chunk-KXB4VXHY.js.map → chunk-JIYDRBVZ.js.map} +0 -0
  713. /package/dist/{chunk-AV5ZEH4M.js.map → chunk-KVJRXN2E.js.map} +0 -0
  714. /package/dist/{chunk-JVLCVFQ4.js.map → chunk-KXEFRMCF.js.map} +0 -0
  715. /package/dist/{chunk-WFTIGIIS.js.map → chunk-L6CQ7WIW.js.map} +0 -0
  716. /package/dist/{chunk-EJUEXZHX.js.map → chunk-LLJMAULE.js.map} +0 -0
  717. /package/dist/{chunk-AS7YMSL6.js.map → chunk-M23RF3LJ.js.map} +0 -0
  718. /package/dist/{chunk-3F2LKUMU.js.map → chunk-NIS256NW.js.map} +0 -0
  719. /package/dist/{chunk-YIAA2X3D.js.map → chunk-NK5RGJ65.js.map} +0 -0
  720. /package/dist/{chunk-OQ5PRDDS.js.map → chunk-NTOIP2E6.js.map} +0 -0
  721. /package/dist/{chunk-HLPD7B7P.js.map → chunk-NUEQKLNB.js.map} +0 -0
  722. /package/dist/{chunk-33PLLLL7.js.map → chunk-P7NGM24P.js.map} +0 -0
  723. /package/dist/{chunk-7TWUCYER.js.map → chunk-PNRA7FAD.js.map} +0 -0
  724. /package/dist/{chunk-5I4M26Q7.js.map → chunk-QBSFOKY6.js.map} +0 -0
  725. /package/dist/{chunk-P4DRWEYC.js.map → chunk-QVSBTCVP.js.map} +0 -0
  726. /package/dist/{chunk-AAIUERNB.js.map → chunk-R5RFK3CB.js.map} +0 -0
  727. /package/dist/{chunk-WDISJRMG.js.map → chunk-RMMVQQA6.js.map} +0 -0
  728. /package/dist/{chunk-5SM35XZR.js.map → chunk-S5NZBKKQ.js.map} +0 -0
  729. /package/dist/{chunk-WIPEXG6R.js.map → chunk-SXIMQLGV.js.map} +0 -0
  730. /package/dist/{chunk-OAEQLRCY.js.map → chunk-TN76AKO3.js.map} +0 -0
  731. /package/dist/{chunk-QN25OCUF.js.map → chunk-TQ4GD737.js.map} +0 -0
  732. /package/dist/{chunk-7K5Q6COX.js.map → chunk-TVVEYCNW.js.map} +0 -0
  733. /package/dist/{chunk-DNWXFTLD.js.map → chunk-TYISDI6B.js.map} +0 -0
  734. /package/dist/{chunk-4LMA77JH.js.map → chunk-U2VLVBBH.js.map} +0 -0
  735. /package/dist/{chunk-5ZE7QHTK.js.map → chunk-ULVR5KG7.js.map} +0 -0
  736. /package/dist/{chunk-4B77XSG5.js.map → chunk-UV72DEZD.js.map} +0 -0
  737. /package/dist/{chunk-S2BBISHU.js.map → chunk-VANZKHTN.js.map} +0 -0
  738. /package/dist/{chunk-3Y224NYC.js.map → chunk-VYISFWVX.js.map} +0 -0
  739. /package/dist/{chunk-TIHMZFIV.js.map → chunk-W3IC7QOY.js.map} +0 -0
  740. /package/dist/{chunk-NRV4Y3PM.js.map → chunk-W4FBGYGK.js.map} +0 -0
  741. /package/dist/{chunk-MU7ZHSZE.js.map → chunk-WZFAPHIK.js.map} +0 -0
  742. /package/dist/{chunk-T2TTP3KU.js.map → chunk-X4IDNPOS.js.map} +0 -0
  743. /package/dist/{chunk-BLAKS3CP.js.map → chunk-XL3TATMJ.js.map} +0 -0
  744. /package/dist/{chunk-W4XJFLAL.js.map → chunk-XPRJSHNI.js.map} +0 -0
  745. /package/dist/{chunk-JE7EK33X.js.map → chunk-Y7HRYCNW.js.map} +0 -0
  746. /package/dist/{chunk-E6EE5B67.js.map → chunk-YK6BDDHP.js.map} +0 -0
  747. /package/dist/{chunk-ES36HTSC.js.map → chunk-YLHM5BQQ.js.map} +0 -0
  748. /package/dist/{chunk-BJKPPZ6Z.js.map → chunk-ZFGZ6PZ2.js.map} +0 -0
  749. /package/dist/{chunk-64UDOIMI.js.map → chunk-ZLQ37WJX.js.map} +0 -0
@@ -116,6 +116,11 @@ function qmdOptions(config: PluginConfig): QmdClientOptions {
116
116
  };
117
117
  }
118
118
 
119
+ export function isSearchBackendEnabled(config: PluginConfig): boolean {
120
+ const backend = config.searchBackend ?? "qmd";
121
+ return backend !== "noop" && (backend !== "qmd" || resolveQmdCapabilities(config).qmd);
122
+ }
123
+
119
124
  /**
120
125
  * Create a SearchBackend from plugin config.
121
126
  *
@@ -124,14 +129,9 @@ function qmdOptions(config: PluginConfig): QmdClientOptions {
124
129
  * - "qmd" (default) → QmdClient if qmdEnabled, else NoopSearchBackend
125
130
  */
126
131
  export function createSearchBackend(config: PluginConfig): SearchBackend {
132
+ if (!isSearchBackendEnabled(config)) return new NoopSearchBackend();
127
133
  const nonQmd = resolveNonQmdBackend(config);
128
134
  if (nonQmd) return nonQmd;
129
-
130
- // Default: QMD — fall back to noop if qmdEnabled is false
131
- if (!resolveQmdCapabilities(config).qmd) {
132
- return new NoopSearchBackend();
133
- }
134
-
135
135
  return new QmdClient(config.qmdCollection, config.qmdMaxResults, qmdOptions(config));
136
136
  }
137
137
 
@@ -45,7 +45,7 @@ export interface SearchExecutionOptions {
45
45
 
46
46
  export function reportSearchDegradation(
47
47
  execution: SearchExecutionOptions | undefined,
48
- degradation: SearchDegradation,
48
+ degradation: SearchDegradation
49
49
  ): void {
50
50
  try {
51
51
  execution?.onDegradation?.(degradation);
@@ -56,7 +56,7 @@ export function reportSearchDegradation(
56
56
 
57
57
  export function resolveEnsureCollectionArgs(
58
58
  collectionOrExecution?: string | SearchExecutionOptions,
59
- execution?: SearchExecutionOptions,
59
+ execution?: SearchExecutionOptions
60
60
  ): { collection?: string; execution?: SearchExecutionOptions } {
61
61
  if (typeof collectionOrExecution === "string") {
62
62
  return { collection: collectionOrExecution, execution };
@@ -108,26 +108,26 @@ export interface SearchBackend {
108
108
  collection?: string,
109
109
  maxResults?: number,
110
110
  options?: SearchQueryOptions,
111
- execution?: SearchExecutionOptions,
111
+ execution?: SearchExecutionOptions
112
112
  ): Promise<SearchResult[]>;
113
113
  searchGlobal(query: string, maxResults?: number, execution?: SearchExecutionOptions): Promise<SearchResult[]>;
114
114
  bm25Search(
115
115
  query: string,
116
116
  collection?: string,
117
117
  maxResults?: number,
118
- execution?: SearchExecutionOptions,
118
+ execution?: SearchExecutionOptions
119
119
  ): Promise<SearchResult[]>;
120
120
  vectorSearch(
121
121
  query: string,
122
122
  collection?: string,
123
123
  maxResults?: number,
124
- execution?: SearchExecutionOptions,
124
+ execution?: SearchExecutionOptions
125
125
  ): Promise<SearchResult[]>;
126
126
  hybridSearch(
127
127
  query: string,
128
128
  collection?: string,
129
129
  maxResults?: number,
130
- execution?: SearchExecutionOptions,
130
+ execution?: SearchExecutionOptions
131
131
  ): Promise<SearchResult[]>;
132
132
 
133
133
  // ── Maintenance ──
@@ -177,6 +177,22 @@ export interface SearchBackend {
177
177
  embedCollectionStrict?(collection: string): Promise<void>;
178
178
 
179
179
  // ── Collection management ──
180
+ /**
181
+ * True only when the backend can bind, isolate, search, and delete collections
182
+ * outside Remnic's primary memory roots.
183
+ */
184
+ supportsAdditionalCollections?(): boolean;
185
+ /**
186
+ * Prevent a collection from participating in unscoped/global searches.
187
+ * Dedicated corpora must call this immediately after collection creation.
188
+ */
189
+ excludeCollectionFromGlobalSearch?(collection: string, execution?: SearchExecutionOptions): Promise<void>;
190
+ /** Remove a non-primary collection and its backend-owned index state. */
191
+ deleteCollection?(collection: string, execution?: SearchExecutionOptions): Promise<boolean>;
192
+ /** Canonical source root currently bound to a named collection. */
193
+ collectionRoot?(collection: string, execution?: SearchExecutionOptions): Promise<string | null>;
194
+ /** Collection-scoped status for observability surfaces. */
195
+ collectionStatus?(collection: string): Promise<Pick<SearchBackendStatus, "totalFiles">>;
180
196
  /**
181
197
  * Optional non-mutating collection probe. Backends that can distinguish a
182
198
  * missing collection from a transient probe failure should implement this so
@@ -184,15 +200,15 @@ export interface SearchBackend {
184
200
  */
185
201
  checkCollection?(
186
202
  collectionOrExecution?: string | SearchExecutionOptions,
187
- execution?: SearchExecutionOptions,
203
+ execution?: SearchExecutionOptions
188
204
  ): Promise<"present" | "missing" | "unknown" | "skipped">;
189
205
  ensureCollection(
190
206
  memoryDir: string,
191
- execution?: SearchExecutionOptions,
207
+ execution?: SearchExecutionOptions
192
208
  ): Promise<"present" | "missing" | "unknown" | "skipped">;
193
209
  ensureCollection(
194
210
  memoryDir: string,
195
211
  collection?: string,
196
- execution?: SearchExecutionOptions,
212
+ execution?: SearchExecutionOptions
197
213
  ): Promise<"present" | "missing" | "unknown" | "skipped">;
198
214
  }
@@ -132,6 +132,20 @@ export function isEncryptedFile(buf: Uint8Array): boolean {
132
132
  return b.subarray(0, MAGIC_BYTES.length).equals(MAGIC_BYTES);
133
133
  }
134
134
 
135
+ type PositionedFileReader = {
136
+ read: (buffer: Buffer, offset: number, length: number, position: number) => Promise<{ bytesRead: number }>;
137
+ };
138
+
139
+ async function readPositionedPrefix(handle: PositionedFileReader, buffer: Buffer): Promise<number> {
140
+ let bytesRead = 0;
141
+ while (bytesRead < buffer.length) {
142
+ const result = await handle.read(buffer, bytesRead, buffer.length - bytesRead, bytesRead);
143
+ if (result.bytesRead === 0) break;
144
+ bytesRead += result.bytesRead;
145
+ }
146
+ return bytesRead;
147
+ }
148
+
135
149
  /**
136
150
  * True when the REGULAR file at `probePath` is encrypted at rest (its first
137
151
  * bytes are the REMNIC-ENC magic header). ENOENT resolves to false — an absent
@@ -153,14 +167,14 @@ export async function probeEncryptedRegularFileHeader(probePath: string): Promis
153
167
  }
154
168
  if (!entryStat.isFile()) {
155
169
  throw new Error(
156
- `refusing to probe non-regular state path ${probePath} `
157
- + `(symlink/FIFO/device); opening it could block or escape containment (#2033)`,
170
+ `refusing to probe non-regular state path ${probePath} ` +
171
+ `(symlink/FIFO/device); opening it could block or escape containment (#2033)`
158
172
  );
159
173
  }
160
174
  const handle = await openFile(probePath, "r");
161
175
  try {
162
176
  const header = Buffer.alloc(MAGIC_HEADER_SIZE);
163
- const { bytesRead } = await handle.read(header, 0, header.length, 0);
177
+ const bytesRead = await readPositionedPrefix(handle, header);
164
178
  return isEncryptedFile(header.subarray(0, bytesRead));
165
179
  } finally {
166
180
  await handle.close();
@@ -431,7 +445,7 @@ export async function* readMaybeEncryptedFileFromChunks(
431
445
  const headerSize = MAGIC_HEADER_SIZE + ENVELOPE_HEADER_SIZE;
432
446
  try {
433
447
  const prefix = Buffer.alloc(headerSize);
434
- const { bytesRead: prefixBytes } = await handle.read(prefix, 0, prefix.length, 0);
448
+ const prefixBytes = await readPositionedPrefix(handle, prefix);
435
449
  const prefixView = prefix.subarray(0, prefixBytes);
436
450
  if (!isEncryptedFile(prefixView)) {
437
451
  if (prefixBytes > 0) yield Buffer.from(prefixView);
@@ -459,15 +473,9 @@ export async function* readMaybeEncryptedFileFromChunks(
459
473
  if (version !== ENVELOPE_VERSION) {
460
474
  throw new Error(`secure-store: unsupported envelope version ${version}`);
461
475
  }
462
- const salt = envelope.subarray(
463
- ENVELOPE_LAYOUT.salt,
464
- ENVELOPE_LAYOUT.salt + ENVELOPE_SALT_LENGTH
465
- );
476
+ const salt = envelope.subarray(ENVELOPE_LAYOUT.salt, ENVELOPE_LAYOUT.salt + ENVELOPE_SALT_LENGTH);
466
477
  const iv = envelope.subarray(ENVELOPE_LAYOUT.iv, ENVELOPE_LAYOUT.iv + IV_LENGTH);
467
- const authTag = envelope.subarray(
468
- ENVELOPE_LAYOUT.authTag,
469
- ENVELOPE_LAYOUT.authTag + AUTH_TAG_LENGTH
470
- );
478
+ const authTag = envelope.subarray(ENVELOPE_LAYOUT.authTag, ENVELOPE_LAYOUT.authTag + AUTH_TAG_LENGTH);
471
479
  const decipher = createDecipheriv("aes-256-gcm", key, iv, { authTagLength: AUTH_TAG_LENGTH });
472
480
  decipher.setAAD(Buffer.concat([buildHeaderAad(salt), filePathAad(filePath, memoryDir)]));
473
481
  decipher.setAuthTag(authTag);
@@ -15,7 +15,7 @@
15
15
  */
16
16
 
17
17
  import assert from "node:assert/strict";
18
- import { mkdir, mkdtemp, readFile, rm, symlink, writeFile } from "node:fs/promises";
18
+ import { mkdir, mkdtemp, open as openFile, readFile, rm, symlink, writeFile } from "node:fs/promises";
19
19
  import { tmpdir } from "node:os";
20
20
  import path from "node:path";
21
21
  import { PassThrough } from "node:stream";
@@ -77,6 +77,7 @@ import {
77
77
  migrateMemoryDirToEncrypted,
78
78
  probeEncryptedRegularFileHeader,
79
79
  readMaybeEncryptedFile,
80
+ readMaybeEncryptedFileFromChunks,
80
81
  } from "./secure-fs.js";
81
82
 
82
83
  /** Cheap scrypt params for tests — still hex-correct but ~milliseconds. */
@@ -965,6 +966,44 @@ test("secure-store migration encrypts memory category dirs but leaves the questi
965
966
  }
966
967
  });
967
968
 
969
+ test("chunked encrypted reads fill the header across positioned short reads", async () => {
970
+ const dir = await mkdtemp(path.join(tmpdir(), "remnic-chunked-header-"));
971
+ const filePath = path.join(dir, "encrypted.md");
972
+ const key = Buffer.alloc(32, 9);
973
+ const plaintext = Buffer.from("streamed encrypted content survives short header reads");
974
+ await writeFile(filePath, encryptFileBody(plaintext, key, filePathAad(filePath, dir)));
975
+
976
+ const probeHandle = await openFile(filePath, "r");
977
+ type PositionedRead = (
978
+ buffer: Buffer,
979
+ offset: number,
980
+ length: number,
981
+ position: number | null
982
+ ) => Promise<{ bytesRead: number; buffer: Buffer }>;
983
+ const handlePrototype = Object.getPrototypeOf(probeHandle) as { read: PositionedRead };
984
+ const originalRead = handlePrototype.read;
985
+ await probeHandle.close();
986
+ let shortReadsRemaining = 3;
987
+ handlePrototype.read = async function (buffer, offset, length, position) {
988
+ const boundedLength = shortReadsRemaining > 0 ? Math.min(length, 4) : length;
989
+ shortReadsRemaining -= 1;
990
+ return await originalRead.call(this, buffer, offset, boundedLength, position);
991
+ };
992
+
993
+ try {
994
+ assert.equal(await probeEncryptedRegularFileHeader(filePath), true);
995
+ shortReadsRemaining = 3;
996
+ const chunks: Buffer[] = [];
997
+ for await (const chunk of readMaybeEncryptedFileFromChunks(filePath, key, dir, 11)) {
998
+ chunks.push(chunk);
999
+ }
1000
+ assert.deepEqual(Buffer.concat(chunks), plaintext);
1001
+ } finally {
1002
+ handlePrototype.read = originalRead;
1003
+ await rm(dir, { recursive: true, force: true });
1004
+ }
1005
+ });
1006
+
968
1007
  test("probeEncryptedRegularFileHeader detects encryption, treats absent as false, and refuses non-regular paths (#2033)", async () => {
969
1008
  const dir = await mkdtemp(path.join(tmpdir(), "remnic-probe-header-"));
970
1009
  try {
@@ -994,7 +1033,7 @@ test("probeEncryptedRegularFileHeader detects encryption, treats absent as false
994
1033
  assert.match(message, /symlink\/FIFO\/device/);
995
1034
  assert.ok(message.includes(linkPath));
996
1035
  return true;
997
- },
1036
+ }
998
1037
  );
999
1038
 
1000
1039
  // A directory is likewise non-regular and refused.
@@ -1,14 +1,15 @@
1
1
  import assert from "node:assert/strict";
2
2
  import { spawn } from "node:child_process";
3
3
  import fs, { existsSync } from "node:fs";
4
- import { mkdir, mkdtemp, rm, utimes, writeFile } from "node:fs/promises";
4
+ import { mkdir, mkdtemp, readFile, rm, utimes, writeFile } from "node:fs/promises";
5
5
  import os from "node:os";
6
6
  import path from "node:path";
7
7
  import test from "node:test";
8
8
  import { setTimeout as sleep } from "node:timers/promises";
9
9
  import { fileURLToPath } from "node:url";
10
10
 
11
- import { createSpace, loadManifest } from "./index.js";
11
+ import { withEntityCanonicalMutationLock } from "../storage/entity-canonical-id-lock.js";
12
+ import { createSpace, loadManifest, pushToSpace, type SpacePushResult } from "./index.js";
12
13
 
13
14
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
14
15
  const repoRoot = path.resolve(__dirname, "../../../..");
@@ -238,6 +239,64 @@ test("loadManifest persists bootstrap when manifest disappears between existence
238
239
  }
239
240
  });
240
241
 
242
+ test("pushToSpace serializes entity-page batches with the target canonical mutation lock", async () => {
243
+ const baseDir = await mkdtemp(path.join(os.tmpdir(), "remnic-spaces-entity-lock-"));
244
+ const sourceDir = path.join(baseDir, "source");
245
+ const targetDir = path.join(baseDir, "target");
246
+ const entityRelativePath = path.join("entities", "serialized-project.md");
247
+ const sourceEntityPath = path.join(sourceDir, entityRelativePath);
248
+ const targetEntityPath = path.join(targetDir, entityRelativePath);
249
+ const entityBytes = Buffer.from(
250
+ "---\nid: serialized-project\n---\n\n# Serialized Project\n\n**Type:** project\n\nPush bytes.\n",
251
+ "utf8",
252
+ );
253
+ const lockHeld = Promise.withResolvers<void>();
254
+ const releaseLock = Promise.withResolvers<void>();
255
+ let lockPromise: Promise<void> | undefined;
256
+ let pushPromise: Promise<SpacePushResult> | undefined;
257
+
258
+ try {
259
+ const source = createSpace({ baseDir, name: "Source", kind: "project", memoryDir: sourceDir });
260
+ const target = createSpace({ baseDir, name: "Target", kind: "project", memoryDir: targetDir });
261
+ await mkdir(path.dirname(sourceEntityPath), { recursive: true });
262
+ await mkdir(path.join(targetDir, "state"), { recursive: true });
263
+ await writeFile(sourceEntityPath, entityBytes);
264
+
265
+ lockPromise = withEntityCanonicalMutationLock(path.join(targetDir, "state"), async () => {
266
+ lockHeld.resolve();
267
+ await releaseLock.promise;
268
+ });
269
+ await lockHeld.promise;
270
+
271
+ let pushFinished = false;
272
+ pushPromise = pushToSpace(source.id, target.id, { baseDir });
273
+ void pushPromise.then(
274
+ () => {
275
+ pushFinished = true;
276
+ },
277
+ () => {
278
+ pushFinished = true;
279
+ },
280
+ );
281
+ await new Promise<void>((resolve) => setImmediate(resolve));
282
+
283
+ assert.equal(pushFinished, false, "the push must not finish while the target entity lock is held");
284
+ assert.equal(existsSync(targetEntityPath), false, "the entity page must not land before lock release");
285
+
286
+ releaseLock.resolve();
287
+ await lockPromise;
288
+ const result = await pushPromise;
289
+
290
+ assert.equal(result.memoriesPushed, 1);
291
+ assert.deepEqual(await readFile(targetEntityPath), entityBytes);
292
+ } finally {
293
+ releaseLock.resolve();
294
+ await lockPromise?.catch(() => undefined);
295
+ await pushPromise?.catch(() => undefined);
296
+ await rm(baseDir, { recursive: true, force: true });
297
+ }
298
+ });
299
+
241
300
  async function runSpaceChild(
242
301
  baseDir: string,
243
302
  name: string,
@@ -22,6 +22,7 @@ import {
22
22
  repairContentAfterJournalMoveSync,
23
23
  requestEntityCanonicalIdReconcileSync,
24
24
  } from "../storage/entity-canonical-id-references.js";
25
+ import { withRawEntityPageMutation } from "../storage/entity-canonical-id-lock.js";
25
26
 
26
27
  // Write-boundary journal cache for promoted copies (issue #2213).
27
28
  const historicalIdCache = new HistoricalEntityCanonicalIdCache();
@@ -637,11 +638,11 @@ export function switchSpace(spaceId: string, baseDir?: string): SpaceSwitchResul
637
638
 
638
639
  // ── Push / Pull ─────────────────────────────────────────────────────────────
639
640
 
640
- export function pushToSpace(
641
+ export async function pushToSpace(
641
642
  sourceSpaceId: string,
642
643
  targetSpaceId: string,
643
644
  options?: { memoryIds?: string[]; force?: boolean; baseDir?: string }
644
- ): SpacePushResult {
645
+ ): Promise<SpacePushResult> {
645
646
  const startTime = Date.now();
646
647
  const manifest = loadManifest(options?.baseDir);
647
648
 
@@ -651,7 +652,7 @@ export function pushToSpace(
651
652
  if (!source) throw new Error(`Source space "${sourceSpaceId}" not found`);
652
653
  if (!target) throw new Error(`Target space "${targetSpaceId}" not found`);
653
654
 
654
- const result = copyMemories(source.memoryDir, target.memoryDir, {
655
+ const result = await copyMemories(source.memoryDir, target.memoryDir, {
655
656
  filterIds: options?.memoryIds,
656
657
  force: options?.force,
657
658
  });
@@ -675,11 +676,11 @@ export function pushToSpace(
675
676
  };
676
677
  }
677
678
 
678
- export function pullFromSpace(
679
+ export async function pullFromSpace(
679
680
  sourceSpaceId: string,
680
681
  targetSpaceId: string,
681
682
  options?: { memoryIds?: string[]; force?: boolean; baseDir?: string }
682
- ): SpacePullResult {
683
+ ): Promise<SpacePullResult> {
683
684
  const startTime = Date.now();
684
685
  const manifest = loadManifest(options?.baseDir);
685
686
 
@@ -689,7 +690,7 @@ export function pullFromSpace(
689
690
  if (!source) throw new Error(`Source space "${sourceSpaceId}" not found`);
690
691
  if (!target) throw new Error(`Target space "${targetSpaceId}" not found`);
691
692
 
692
- const result = copyMemories(source.memoryDir, target.memoryDir, {
693
+ const result = await copyMemories(source.memoryDir, target.memoryDir, {
693
694
  filterIds: options?.memoryIds,
694
695
  force: options?.force,
695
696
  });
@@ -744,11 +745,11 @@ export function shareSpace(spaceId: string, members: string[], baseDir?: string)
744
745
 
745
746
  // ── Promote ──────────────────────────────────────────────────────────────────
746
747
 
747
- export function promoteSpace(
748
+ export async function promoteSpace(
748
749
  sourceSpaceId: string,
749
750
  targetSpaceId: string,
750
751
  options?: { memoryIds?: string[]; force?: boolean; forceOverwrite?: boolean; baseDir?: string }
751
- ): SpacePromoteResult {
752
+ ): Promise<SpacePromoteResult> {
752
753
  const startTime = Date.now();
753
754
  const manifest = loadManifest(options?.baseDir);
754
755
 
@@ -765,7 +766,7 @@ export function promoteSpace(
765
766
  }
766
767
  }
767
768
 
768
- const result = copyMemories(source.memoryDir, target.memoryDir, {
769
+ const result = await copyMemories(source.memoryDir, target.memoryDir, {
769
770
  filterIds: options?.memoryIds,
770
771
  force: options?.forceOverwrite !== undefined ? options.forceOverwrite : (options?.force ?? false),
771
772
  });
@@ -791,11 +792,11 @@ export function promoteSpace(
791
792
 
792
793
  // ── Merge ────────────────────────────────────────────────────────────────────
793
794
 
794
- export function mergeSpaces(
795
+ export async function mergeSpaces(
795
796
  sourceSpaceId: string,
796
797
  targetSpaceId: string,
797
798
  options?: { force?: boolean; baseDir?: string }
798
- ): MergeResult {
799
+ ): Promise<MergeResult> {
799
800
  const startTime = Date.now();
800
801
  const manifest = loadManifest(options?.baseDir);
801
802
 
@@ -805,7 +806,7 @@ export function mergeSpaces(
805
806
  if (!source) throw new Error(`Source space "${sourceSpaceId}" not found`);
806
807
  if (!target) throw new Error(`Target space "${targetSpaceId}" not found`);
807
808
 
808
- const result = copyMemories(source.memoryDir, target.memoryDir, {
809
+ const result = await copyMemories(source.memoryDir, target.memoryDir, {
809
810
  force: options?.force,
810
811
  });
811
812
 
@@ -855,15 +856,13 @@ interface CopyOptions {
855
856
  force?: boolean;
856
857
  }
857
858
 
858
- function copyMemories(
859
+ type CopyResult = { merged: number; conflicts: ConflictEntry[]; skipped: number };
860
+
861
+ async function copyMemories(
859
862
  sourceDir: string,
860
863
  targetDir: string,
861
864
  options?: CopyOptions
862
- ): { merged: number; conflicts: ConflictEntry[]; skipped: number } {
863
- let merged = 0;
864
- const conflicts: ConflictEntry[] = [];
865
- let skipped = 0;
866
-
865
+ ): Promise<CopyResult> {
867
866
  if (!fs.existsSync(sourceDir)) {
868
867
  return { merged: 0, conflicts: [], skipped: 0 };
869
868
  }
@@ -891,6 +890,33 @@ function copyMemories(
891
890
  })
892
891
  .map((p) => path.basename(p, ".md")),
893
892
  );
893
+ const firstEntityId = sourceEntityIds.values().next().value;
894
+ if (firstEntityId === undefined) {
895
+ return copyPreparedMemories(sourceFiles, sourceRoot, targetRoot, sourceEntityIds, options);
896
+ }
897
+ return withRawEntityPageMutation(
898
+ targetRoot,
899
+ path.join(targetRoot, "entities", `${firstEntityId}.md`),
900
+ async () => copyPreparedMemories(
901
+ sourceFiles,
902
+ sourceRoot,
903
+ targetRoot,
904
+ sourceEntityIds,
905
+ options,
906
+ ),
907
+ );
908
+ }
909
+
910
+ function copyPreparedMemories(
911
+ sourceFiles: string[],
912
+ sourceRoot: string,
913
+ targetRoot: string,
914
+ sourceEntityIds: ReadonlySet<string>,
915
+ options?: CopyOptions,
916
+ ): CopyResult {
917
+ let merged = 0;
918
+ const conflicts: ConflictEntry[] = [];
919
+ let skipped = 0;
894
920
  // The reconcile marker is published ONCE, after every record landed
895
921
  // (Codex P1, round 21): a per-record marker could be consumed by a peer
896
922
  // between a legacy-preserving memory write and its colliding entity page,
@@ -0,0 +1,97 @@
1
+ import {
2
+ closeSync,
3
+ constants,
4
+ fstatSync,
5
+ lstatSync,
6
+ openSync,
7
+ readFileSync,
8
+ realpathSync,
9
+ } from "node:fs";
10
+ import path from "node:path";
11
+
12
+ import { isErrnoCode } from "../utils/errno.js";
13
+ import { assertPathInsideRoot } from "../utils/path-containment.js";
14
+
15
+ function resolveSafeAliasRoots(baseDir: string, configDir: string): string | undefined {
16
+ let baseStat;
17
+ try {
18
+ baseStat = lstatSync(baseDir);
19
+ } catch (error) {
20
+ if (isErrnoCode(error, "ENOENT")) return undefined;
21
+ throw error;
22
+ }
23
+ if (baseStat.isSymbolicLink() || !baseStat.isDirectory()) {
24
+ throw new Error(`Refusing unsafe entity alias memory root: ${baseDir}.`);
25
+ }
26
+
27
+ let configStat;
28
+ try {
29
+ configStat = lstatSync(configDir);
30
+ } catch (error) {
31
+ if (isErrnoCode(error, "ENOENT")) return undefined;
32
+ throw error;
33
+ }
34
+ if (configStat.isSymbolicLink() || !configStat.isDirectory()) {
35
+ throw new Error(`Refusing unsafe entity alias config root: ${configDir}.`);
36
+ }
37
+
38
+ const memoryRoot = realpathSync(baseDir);
39
+ assertPathInsideRoot(memoryRoot, realpathSync(configDir), configDir);
40
+ return memoryRoot;
41
+ }
42
+
43
+ export function readEntityAliasConfigSync(baseDir: string): string | undefined {
44
+ const configDir = path.join(baseDir, "config");
45
+ const aliasPath = path.join(configDir, "aliases.json");
46
+ let memoryRoot = resolveSafeAliasRoots(baseDir, configDir);
47
+ if (memoryRoot === undefined) return undefined;
48
+
49
+ let aliasPreflight;
50
+ try {
51
+ aliasPreflight = lstatSync(aliasPath);
52
+ } catch (error) {
53
+ if (isErrnoCode(error, "ENOENT")) return undefined;
54
+ throw error;
55
+ }
56
+ if (aliasPreflight.isSymbolicLink() || !aliasPreflight.isFile()) {
57
+ throw new Error(`Refusing unsafe entity alias config file: ${aliasPath}.`);
58
+ }
59
+
60
+ let fd: number;
61
+ try {
62
+ fd = openSync(
63
+ aliasPath,
64
+ constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0) | (constants.O_NONBLOCK ?? 0),
65
+ );
66
+ } catch (error) {
67
+ if (isErrnoCode(error, "ENOENT")) {
68
+ resolveSafeAliasRoots(baseDir, configDir);
69
+ return undefined;
70
+ }
71
+ if (isErrnoCode(error, "ELOOP")) {
72
+ throw new Error(`Refusing unsafe entity alias config file: ${aliasPath}.`);
73
+ }
74
+ throw error;
75
+ }
76
+ try {
77
+ const opened = fstatSync(fd);
78
+ memoryRoot = resolveSafeAliasRoots(baseDir, configDir);
79
+ if (memoryRoot === undefined) {
80
+ throw new Error(`Refusing unsafe entity alias config root: ${configDir}.`);
81
+ }
82
+ const aliasStat = lstatSync(aliasPath);
83
+ if (
84
+ !opened.isFile() ||
85
+ aliasStat.isSymbolicLink() ||
86
+ !aliasStat.isFile() ||
87
+ aliasStat.dev !== opened.dev ||
88
+ aliasStat.ino !== opened.ino
89
+ ) {
90
+ throw new Error(`Refusing unsafe entity alias config file: ${aliasPath}.`);
91
+ }
92
+ assertPathInsideRoot(memoryRoot, realpathSync(aliasPath), aliasPath);
93
+ return readFileSync(fd, "utf-8");
94
+ } finally {
95
+ closeSync(fd);
96
+ }
97
+ }
@@ -1,33 +1,63 @@
1
- /**
2
- * Entity canonical-id MUTATION lock (issue #2213).
3
- *
4
- * Serializes every writer whose correctness depends on the canonical-id
5
- * journal not moving mid-write: entity file mutations (entity-store),
6
- * per-pair file migration and journal pruning (entity-canonical-id-migration),
7
- * and the final settle attempt of the post-persist repair helpers
8
- * (entity-canonical-id-references). Lives in its own module so the reference
9
- * helpers can take the lock without importing the migration module, which
10
- * itself imports the reference helpers.
11
- */
1
+ import { appendFileSync, mkdirSync, realpathSync } from "node:fs";
12
2
  import path from "node:path";
13
- import { withHeldFileLock } from "../utils/serialize-mutations.js";
3
+ import { invalidateForScope } from "../memory-cache.js";
4
+ import { serializeMutations, withHeldFileLock } from "../utils/serialize-mutations.js";
14
5
 
15
6
  const ENTITY_CANONICAL_ID_MUTATION_LOCK_STALE_MS = 60_000;
16
7
  const ENTITY_CANONICAL_ID_MUTATION_LOCK_MAX_WAIT_MS = 300_000;
17
8
 
18
- export async function withEntityCanonicalMutationLock<T>(
9
+ export function isEntityPagePath(baseDir: string, filePath: string): boolean {
10
+ if (path.extname(filePath) !== ".md") return false;
11
+ const parentDir = path.dirname(path.resolve(filePath));
12
+ const entitiesDir = path.resolve(baseDir, "entities");
13
+ if (parentDir === entitiesDir) return true;
14
+ try {
15
+ return realpathSync(parentDir) === path.join(realpathSync(baseDir), "entities");
16
+ } catch {
17
+ return false;
18
+ }
19
+ }
20
+
21
+ function recordRawEntityMutation(baseDir: string, stateDir: string): void {
22
+ invalidateForScope(baseDir, "entity-write");
23
+ mkdirSync(stateDir, { recursive: true });
24
+ appendFileSync(path.join(stateDir, ".entity-mutation-version.log"), "x");
25
+ }
26
+
27
+ export function withEntityCanonicalMutationLock<T>(
19
28
  stateDir: string,
20
29
  task: (refreshLock: () => Promise<boolean>) => Promise<T>,
21
30
  ): Promise<T> {
22
- return withHeldFileLock(
23
- path.join(stateDir, "entity-canonical-id-mutation.lock"),
24
- {
25
- staleMs: ENTITY_CANONICAL_ID_MUTATION_LOCK_STALE_MS,
26
- maxWaitMs: ENTITY_CANONICAL_ID_MUTATION_LOCK_MAX_WAIT_MS,
27
- },
28
- async (acquired, lock) => {
29
- if (!acquired) throw new Error("Timed out waiting for entity mutation lock.");
30
- return task(() => lock.refresh());
31
- },
31
+ const lockPath = path.join(stateDir, "entity-canonical-id-mutation.lock");
32
+ return serializeMutations(lockPath, () =>
33
+ withHeldFileLock(
34
+ lockPath,
35
+ {
36
+ staleMs: ENTITY_CANONICAL_ID_MUTATION_LOCK_STALE_MS,
37
+ maxWaitMs: ENTITY_CANONICAL_ID_MUTATION_LOCK_MAX_WAIT_MS,
38
+ },
39
+ async (acquired, lock) => {
40
+ if (!acquired) throw new Error("Timed out waiting for entity mutation lock.");
41
+ return task(() => lock.refresh());
42
+ },
43
+ ),
32
44
  );
33
45
  }
46
+
47
+ export async function withRawEntityPageMutation<T>(
48
+ baseDir: string,
49
+ filePath: string,
50
+ task: (refreshLock: () => Promise<boolean>) => Promise<T>,
51
+ ): Promise<T> {
52
+ if (!isEntityPagePath(baseDir, filePath)) {
53
+ return task(async () => true);
54
+ }
55
+ const stateDir = path.join(baseDir, "state");
56
+ return withEntityCanonicalMutationLock(stateDir, async (refreshLock) => {
57
+ try {
58
+ return await task(refreshLock);
59
+ } finally {
60
+ recordRawEntityMutation(baseDir, stateDir);
61
+ }
62
+ });
63
+ }