@remnic/core 9.45.3 → 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 (747) 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 +15 -11
  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.js +3 -3
  57. package/dist/{access-service-CiJRsgAB.d.ts → access-service-CsU-ljFD.d.ts} +25 -16
  58. package/dist/access-service-helpers.d.ts +14 -10
  59. package/dist/access-service.d.ts +14 -10
  60. package/dist/access-service.js +84 -76
  61. package/dist/access-surface-catalog.d.ts +14 -10
  62. package/dist/access-surface-catalog.js +4 -0
  63. package/dist/access-surface-catalog.js.map +1 -1
  64. package/dist/access-wearables-meetings-surface.d.ts +4 -3
  65. package/dist/action-confidence.d.ts +2 -1
  66. package/dist/active-memory-bridge.d.ts +2 -1
  67. package/dist/active-recall.d.ts +2 -1
  68. package/dist/active-recall.js +10 -8
  69. package/dist/active-recall.js.map +1 -1
  70. package/dist/adapters/index.js +7 -7
  71. package/dist/adapters/registry.js +3 -3
  72. package/dist/{auto-sync-5OE5QOZB.js → auto-sync-UPTUVE4X.js} +6 -6
  73. package/dist/behavior-learner.d.ts +2 -1
  74. package/dist/behavior-learner.js +1 -1
  75. package/dist/behavior-signals.d.ts +2 -1
  76. package/dist/bootstrap.d.ts +9 -8
  77. package/dist/briefing.d.ts +3 -2
  78. package/dist/briefing.js +23 -22
  79. package/dist/buffer-surprise-report.d.ts +2 -1
  80. package/dist/buffer-turn-helpers.d.ts +2 -1
  81. package/dist/buffer.d.ts +3 -2
  82. package/dist/buffer.js +12 -11
  83. package/dist/bulk-import/index.d.ts +4 -3
  84. package/dist/calibration.d.ts +2 -1
  85. package/dist/capabilities.d.ts +2 -1
  86. package/dist/{capsule-merge-IDWJPCWK.js → capsule-merge-Q6AR3XL7.js} +67 -54
  87. package/dist/capsule-merge-Q6AR3XL7.js.map +1 -0
  88. package/dist/{catalog-scBmy0sO.d.ts → catalog-bctMURhN.d.ts} +1 -1
  89. package/dist/causal-behavior.d.ts +2 -1
  90. package/dist/causal-behavior.js +2 -2
  91. package/dist/causal-chain.js +2 -2
  92. package/dist/causal-consolidation.d.ts +2 -1
  93. package/dist/causal-consolidation.js +27 -26
  94. package/dist/causal-consolidation.js.map +1 -1
  95. package/dist/causal-retrieval.js +2 -2
  96. package/dist/causal-trajectory-graph.d.ts +2 -1
  97. package/dist/causal-trajectory.js +1 -1
  98. package/dist/{chunk-VUPTKTDV.js → chunk-2MRHJNWL.js} +3 -3
  99. package/dist/{chunk-JBPKEARU.js → chunk-2QSZNTDO.js} +7 -7
  100. package/dist/{chunk-5IVLTFOV.js → chunk-44N6ESJ4.js} +2 -2
  101. package/dist/{chunk-WOCNN776.js → chunk-4POAMKV6.js} +100 -41
  102. package/dist/chunk-4POAMKV6.js.map +1 -0
  103. package/dist/{chunk-HO3QBJEY.js → chunk-5546W5SI.js} +2 -2
  104. package/dist/{chunk-U7GW7NE7.js → chunk-5CEECY6P.js} +10 -10
  105. package/dist/{chunk-4UH4BTGK.js → chunk-5SNZSWWR.js} +82 -82
  106. package/dist/{chunk-6CZPDBJS.js → chunk-5U7ID3EZ.js} +3 -3
  107. package/dist/{chunk-GF22HWS2.js → chunk-6NNNURLK.js} +7 -7
  108. package/dist/chunk-773TRRGT.js +36 -0
  109. package/dist/chunk-773TRRGT.js.map +1 -0
  110. package/dist/chunk-7CITSYSH.js +242 -0
  111. package/dist/chunk-7CITSYSH.js.map +1 -0
  112. package/dist/{chunk-227UFSEQ.js → chunk-7RZJWZ46.js} +5 -5
  113. package/dist/{chunk-E5UK4VPE.js → chunk-7SHJHPTY.js} +5 -5
  114. package/dist/{chunk-UVIKWC7M.js → chunk-7YERSTN7.js} +17 -17
  115. package/dist/{chunk-DLVPUX7U.js → chunk-7YKVM5H3.js} +8 -6
  116. package/dist/chunk-7YKVM5H3.js.map +1 -0
  117. package/dist/{chunk-3CE77VAP.js → chunk-A4JMGKCD.js} +87 -74
  118. package/dist/chunk-A4JMGKCD.js.map +1 -0
  119. package/dist/chunk-A5KNZSNA.js +26 -0
  120. package/dist/chunk-A5KNZSNA.js.map +1 -0
  121. package/dist/{chunk-S2NCTZGJ.js → chunk-AJQ57VV3.js} +15 -15
  122. package/dist/chunk-AJQ57VV3.js.map +1 -0
  123. package/dist/{chunk-CUM2BBPN.js → chunk-AUMWZSE7.js} +19 -10
  124. package/dist/chunk-AUMWZSE7.js.map +1 -0
  125. package/dist/{chunk-XYTOI63Z.js → chunk-BGHFOD5A.js} +19 -11
  126. package/dist/chunk-BGHFOD5A.js.map +1 -0
  127. package/dist/{chunk-BUE5E2HL.js → chunk-BGLY7EEM.js} +5 -314
  128. package/dist/chunk-BGLY7EEM.js.map +1 -0
  129. package/dist/chunk-BIPBQQFI.js +44 -0
  130. package/dist/chunk-BIPBQQFI.js.map +1 -0
  131. package/dist/{chunk-S5SLVSVY.js → chunk-BQIFZ2MP.js} +5 -5
  132. package/dist/chunk-BTTPKDIL.js +34 -0
  133. package/dist/{chunk-PVGDJXVK.js.map → chunk-BTTPKDIL.js.map} +1 -1
  134. package/dist/{chunk-E53DSZEN.js → chunk-C26TE27X.js} +3 -3
  135. package/dist/{chunk-LZ4LDKHZ.js → chunk-CLB32OHM.js} +6 -6
  136. package/dist/{chunk-Q6IP2ARR.js → chunk-CSOYVTRX.js} +2 -2
  137. package/dist/{chunk-XOQSEF7X.js → chunk-CVILPI77.js} +6 -6
  138. package/dist/chunk-D3I2MCN7.js +29 -0
  139. package/dist/chunk-D3I2MCN7.js.map +1 -0
  140. package/dist/{chunk-A5OJCXZL.js → chunk-DSUAAZZX.js} +15 -4
  141. package/dist/chunk-DSUAAZZX.js.map +1 -0
  142. package/dist/{chunk-HREE4JHI.js → chunk-DYVMXPCF.js} +486 -287
  143. package/dist/chunk-DYVMXPCF.js.map +1 -0
  144. package/dist/{chunk-J7VGGECD.js → chunk-DZPFMQZ7.js} +1 -1
  145. package/dist/chunk-DZPFMQZ7.js.map +1 -0
  146. package/dist/{chunk-PDLBLTOK.js → chunk-EITZHSX6.js} +9 -9
  147. package/dist/{chunk-D3J5SLQK.js → chunk-EJHEWCGQ.js} +81 -20
  148. package/dist/chunk-EJHEWCGQ.js.map +1 -0
  149. package/dist/{chunk-WUNIWKY4.js → chunk-ELIL2A37.js} +6 -6
  150. package/dist/{chunk-E6PNLPGJ.js → chunk-FZP32336.js} +806 -470
  151. package/dist/chunk-FZP32336.js.map +1 -0
  152. package/dist/{chunk-HZFHQ4AQ.js → chunk-G7A5HLUS.js} +23 -17
  153. package/dist/chunk-G7A5HLUS.js.map +1 -0
  154. package/dist/{chunk-CINZGPSJ.js → chunk-GUMZC2BO.js} +2 -2
  155. package/dist/{chunk-H24WNPA2.js → chunk-GWFSVJ4P.js} +3 -3
  156. package/dist/{chunk-7XC2HX75.js → chunk-GYPQL6XN.js} +157 -16
  157. package/dist/chunk-GYPQL6XN.js.map +1 -0
  158. package/dist/{chunk-TSH56VPU.js → chunk-HAYSYUAB.js} +2 -2
  159. package/dist/{chunk-TDHTVMPG.js → chunk-HFPASSFV.js} +7 -2
  160. package/dist/chunk-HFPASSFV.js.map +1 -0
  161. package/dist/chunk-J2WC5LF4.js +395 -0
  162. package/dist/chunk-J2WC5LF4.js.map +1 -0
  163. package/dist/{chunk-PKNLM44P.js → chunk-JH6BPLOP.js} +9 -9
  164. package/dist/{chunk-KXB4VXHY.js → chunk-JIYDRBVZ.js} +2 -2
  165. package/dist/chunk-JV3C2MNQ.js +74 -0
  166. package/dist/chunk-JV3C2MNQ.js.map +1 -0
  167. package/dist/{chunk-AV5ZEH4M.js → chunk-KVJRXN2E.js} +2 -2
  168. package/dist/{chunk-JVLCVFQ4.js → chunk-KXEFRMCF.js} +3 -3
  169. package/dist/{chunk-WFTIGIIS.js → chunk-L6CQ7WIW.js} +5 -5
  170. package/dist/{chunk-EJUEXZHX.js → chunk-LLJMAULE.js} +2 -2
  171. package/dist/{chunk-N5Z4EVOR.js → chunk-LNEWDF2A.js} +36 -11
  172. package/dist/chunk-LNEWDF2A.js.map +1 -0
  173. package/dist/{chunk-AS7YMSL6.js → chunk-M23RF3LJ.js} +4 -4
  174. package/dist/{chunk-UYLMNVY6.js → chunk-MDISBSYA.js} +16 -9
  175. package/dist/chunk-MDISBSYA.js.map +1 -0
  176. package/dist/{chunk-3F2LKUMU.js → chunk-NIS256NW.js} +2 -2
  177. package/dist/{chunk-YIAA2X3D.js → chunk-NK5RGJ65.js} +3 -3
  178. package/dist/chunk-NLDVVWCL.js +84 -0
  179. package/dist/chunk-NLDVVWCL.js.map +1 -0
  180. package/dist/{chunk-OQ5PRDDS.js → chunk-NTOIP2E6.js} +6 -6
  181. package/dist/{chunk-HLPD7B7P.js → chunk-NUEQKLNB.js} +2 -2
  182. package/dist/{chunk-4J7G5SY4.js → chunk-NZBZ7IS2.js} +72 -24
  183. package/dist/chunk-NZBZ7IS2.js.map +1 -0
  184. package/dist/{chunk-3TBLDMJA.js → chunk-O4KMGRXE.js} +5 -2
  185. package/dist/chunk-O4KMGRXE.js.map +1 -0
  186. package/dist/{chunk-33PLLLL7.js → chunk-P7NGM24P.js} +6 -6
  187. package/dist/{chunk-7TWUCYER.js → chunk-PNRA7FAD.js} +7 -7
  188. package/dist/{chunk-5I4M26Q7.js → chunk-QBSFOKY6.js} +4 -4
  189. package/dist/{chunk-QJAQNXWI.js → chunk-QCECHYZL.js} +76 -79
  190. package/dist/chunk-QCECHYZL.js.map +1 -0
  191. package/dist/{chunk-P4DRWEYC.js → chunk-QVSBTCVP.js} +2 -2
  192. package/dist/{chunk-AAIUERNB.js → chunk-R5RFK3CB.js} +6 -6
  193. package/dist/{chunk-WDISJRMG.js → chunk-RMMVQQA6.js} +2 -2
  194. package/dist/{chunk-KWMXR7XS.js → chunk-S2V7RUCL.js} +8 -1
  195. package/dist/{chunk-KWMXR7XS.js.map → chunk-S2V7RUCL.js.map} +1 -1
  196. package/dist/{chunk-5SM35XZR.js → chunk-S5NZBKKQ.js} +2 -2
  197. package/dist/{chunk-VNA7W7QF.js → chunk-SVH57F5Z.js} +12 -4
  198. package/dist/chunk-SVH57F5Z.js.map +1 -0
  199. package/dist/{chunk-WIPEXG6R.js → chunk-SXIMQLGV.js} +2 -2
  200. package/dist/{chunk-RVLJEII5.js → chunk-SYUBB3WM.js} +256 -187
  201. package/dist/chunk-SYUBB3WM.js.map +1 -0
  202. package/dist/{chunk-OAEQLRCY.js → chunk-TN76AKO3.js} +5 -5
  203. package/dist/{chunk-QN25OCUF.js → chunk-TQ4GD737.js} +5 -5
  204. package/dist/{chunk-VCD4PSK2.js → chunk-TQZ4DVBC.js} +7 -4
  205. package/dist/chunk-TQZ4DVBC.js.map +1 -0
  206. package/dist/{chunk-7K5Q6COX.js → chunk-TVVEYCNW.js} +4 -4
  207. package/dist/{chunk-DNWXFTLD.js → chunk-TYISDI6B.js} +2 -2
  208. package/dist/{chunk-4LMA77JH.js → chunk-U2VLVBBH.js} +3 -3
  209. package/dist/{chunk-5ZE7QHTK.js → chunk-ULVR5KG7.js} +5 -5
  210. package/dist/{chunk-NVRYW264.js → chunk-UQWIKLQK.js} +18 -15
  211. package/dist/chunk-UQWIKLQK.js.map +1 -0
  212. package/dist/{chunk-YV32N67O.js → chunk-URS5GSM7.js} +1 -1
  213. package/dist/chunk-URS5GSM7.js.map +1 -0
  214. package/dist/{chunk-4B77XSG5.js → chunk-UV72DEZD.js} +5 -5
  215. package/dist/{chunk-S2BBISHU.js → chunk-VANZKHTN.js} +3 -3
  216. package/dist/chunk-VHFXP27N.js +250 -0
  217. package/dist/chunk-VHFXP27N.js.map +1 -0
  218. package/dist/{chunk-3Y224NYC.js → chunk-VYISFWVX.js} +2 -2
  219. package/dist/{chunk-TIHMZFIV.js → chunk-W3IC7QOY.js} +3 -3
  220. package/dist/{chunk-NRV4Y3PM.js → chunk-W4FBGYGK.js} +1 -1
  221. package/dist/{chunk-P2BM76KT.js → chunk-WAS4HV46.js} +174 -43
  222. package/dist/chunk-WAS4HV46.js.map +1 -0
  223. package/dist/{chunk-57QKLRBV.js → chunk-WB7JSQCP.js} +2 -1
  224. package/dist/chunk-WB7JSQCP.js.map +1 -0
  225. package/dist/chunk-WGP57SR3.js +68 -0
  226. package/dist/chunk-WGP57SR3.js.map +1 -0
  227. package/dist/{chunk-ECK75GDJ.js → chunk-WQIHRA5F.js} +43 -24
  228. package/dist/chunk-WQIHRA5F.js.map +1 -0
  229. package/dist/{chunk-MU7ZHSZE.js → chunk-WZFAPHIK.js} +2 -2
  230. package/dist/{chunk-T2TTP3KU.js → chunk-X4IDNPOS.js} +2 -2
  231. package/dist/{chunk-BLAKS3CP.js → chunk-XL3TATMJ.js} +3 -3
  232. package/dist/{chunk-W4XJFLAL.js → chunk-XPRJSHNI.js} +2 -2
  233. package/dist/{chunk-5TFP4CUL.js → chunk-XQ3HXAQH.js} +14 -11
  234. package/dist/chunk-XQ3HXAQH.js.map +1 -0
  235. package/dist/{chunk-VWAXN2BN.js → chunk-XSFHWBQO.js} +93 -31
  236. package/dist/chunk-XSFHWBQO.js.map +1 -0
  237. package/dist/{chunk-DL7ZD3JH.js → chunk-XTAUXTDO.js} +14 -9
  238. package/dist/chunk-XTAUXTDO.js.map +1 -0
  239. package/dist/{chunk-JE7EK33X.js → chunk-Y7HRYCNW.js} +2 -2
  240. package/dist/{chunk-E6EE5B67.js → chunk-YK6BDDHP.js} +4 -4
  241. package/dist/{chunk-ES36HTSC.js → chunk-YLHM5BQQ.js} +3 -3
  242. package/dist/{chunk-RN7DY3FC.js → chunk-YMAQDHQM.js} +31 -12
  243. package/dist/chunk-YMAQDHQM.js.map +1 -0
  244. package/dist/{chunk-ULARSG5Z.js → chunk-YN6ASZUG.js} +10 -8
  245. package/dist/{chunk-ULARSG5Z.js.map → chunk-YN6ASZUG.js.map} +1 -1
  246. package/dist/{chunk-IKKWIPYN.js → chunk-YYQAKIDJ.js} +37 -1
  247. package/dist/chunk-YYQAKIDJ.js.map +1 -0
  248. package/dist/{chunk-BJKPPZ6Z.js → chunk-ZFGZ6PZ2.js} +2 -2
  249. package/dist/{chunk-CJ2ZR7UA.js → chunk-ZI32MKDW.js} +267 -214
  250. package/dist/chunk-ZI32MKDW.js.map +1 -0
  251. package/dist/{chunk-64UDOIMI.js → chunk-ZLQ37WJX.js} +2 -2
  252. package/dist/chunk-ZMAYKGPN.js +351 -0
  253. package/dist/chunk-ZMAYKGPN.js.map +1 -0
  254. package/dist/{cli-BUGN3d6_.d.ts → cli-BBHDtG36.d.ts} +5 -5
  255. package/dist/cli.d.ts +16 -12
  256. package/dist/cli.js +138 -124
  257. package/dist/compounding/engine.d.ts +3 -2
  258. package/dist/compounding/engine.js +24 -23
  259. package/dist/compounding/preference-consolidator.d.ts +2 -1
  260. package/dist/compression-optimizer.d.ts +2 -1
  261. package/dist/config.d.ts +2 -1
  262. package/dist/config.js +10 -8
  263. package/dist/connectors/codex-materialize-runner.d.ts +2 -1
  264. package/dist/connectors/codex-materialize-runner.js +23 -22
  265. package/dist/connectors/codex-materialize.d.ts +2 -1
  266. package/dist/connectors/index.d.ts +2 -1
  267. package/dist/connectors/index.js +26 -25
  268. package/dist/consolidation-provenance-check.d.ts +3 -2
  269. package/dist/consolidation-provenance-check.js +4 -4
  270. package/dist/consolidation-undo.d.ts +3 -2
  271. package/dist/consolidation-undo.js +10 -7
  272. package/dist/consolidation-undo.js.map +1 -1
  273. package/dist/contradiction/index.d.ts +3 -2
  274. package/dist/converge-config.d.ts +2 -1
  275. package/dist/convergence-refresh.d.ts +4 -3
  276. package/dist/convergence-refresh.js +27 -26
  277. package/dist/conversation-index/backend.d.ts +2 -1
  278. package/dist/conversation-index/backend.js +2 -2
  279. package/dist/conversation-index/chunker.d.ts +2 -1
  280. package/dist/conversation-index/faiss-adapter.d.ts +2 -1
  281. package/dist/conversation-index/indexer.d.ts +2 -1
  282. package/dist/conversation-index/search.d.ts +2 -1
  283. package/dist/corpus-watermark.d.ts +2 -1
  284. package/dist/corpus-watermark.js +42 -41
  285. package/dist/day-summary.d.ts +2 -1
  286. package/dist/delinearize.d.ts +2 -1
  287. package/dist/direct-answer-wiring.d.ts +2 -1
  288. package/dist/direct-answer-wiring.js +2 -2
  289. package/dist/direct-answer.d.ts +2 -1
  290. package/dist/embedding-fallback.d.ts +2 -1
  291. package/dist/embedding-fallback.js +2 -2
  292. package/dist/enrichment/index.d.ts +2 -1
  293. package/dist/entity-retrieval-boundaries.js +1 -1
  294. package/dist/entity-retrieval.d.ts +3 -2
  295. package/dist/entity-retrieval.js +24 -23
  296. package/dist/entity-schema.d.ts +2 -1
  297. package/dist/explicit-capture.d.ts +9 -8
  298. package/dist/explicit-capture.js +11 -9
  299. package/dist/external-wiki-access.d.ts +127 -0
  300. package/dist/external-wiki-access.js +186 -0
  301. package/dist/external-wiki-access.js.map +1 -0
  302. package/dist/external-wiki-cli.d.ts +13 -0
  303. package/dist/external-wiki-cli.js +96 -0
  304. package/dist/external-wiki-cli.js.map +1 -0
  305. package/dist/external-wiki-collection-registration.d.ts +39 -0
  306. package/dist/external-wiki-collection-registration.js +79 -0
  307. package/dist/external-wiki-collection-registration.js.map +1 -0
  308. package/dist/external-wiki-collection.d.ts +50 -0
  309. package/dist/external-wiki-collection.js +387 -0
  310. package/dist/external-wiki-collection.js.map +1 -0
  311. package/dist/external-wiki-config.d.ts +13 -0
  312. package/dist/external-wiki-config.js +13 -0
  313. package/dist/external-wiki-config.js.map +1 -0
  314. package/dist/external-wiki-guard.d.ts +11 -0
  315. package/dist/external-wiki-guard.js +18 -0
  316. package/dist/external-wiki-guard.js.map +1 -0
  317. package/dist/external-wiki-mcp-tools.d.ts +123 -0
  318. package/dist/external-wiki-mcp-tools.js +8 -0
  319. package/dist/external-wiki-mcp-tools.js.map +1 -0
  320. package/dist/external-wiki-search.d.ts +42 -0
  321. package/dist/external-wiki-search.js +11 -0
  322. package/dist/external-wiki-search.js.map +1 -0
  323. package/dist/external-wiki.d.ts +43 -0
  324. package/dist/external-wiki.js +16 -0
  325. package/dist/external-wiki.js.map +1 -0
  326. package/dist/extraction-error-classification.d.ts +2 -1
  327. package/dist/extraction-faithfulness.d.ts +2 -1
  328. package/dist/extraction-judge-telemetry.d.ts +2 -1
  329. package/dist/extraction-judge-training.d.ts +2 -1
  330. package/dist/extraction-judge.d.ts +2 -1
  331. package/dist/extraction-liveness.d.ts +2 -1
  332. package/dist/extraction-source-grounding-helpers.d.ts +5 -3
  333. package/dist/extraction-source-grounding-helpers.js +1 -1
  334. package/dist/extraction-source-grounding-rules.d.ts +2 -1
  335. package/dist/extraction-source-grounding-rules.js +2 -2
  336. package/dist/extraction-source-grounding.d.ts +2 -1
  337. package/dist/extraction-source-grounding.js +5 -5
  338. package/dist/extraction.d.ts +2 -1
  339. package/dist/extraction.js +45 -43
  340. package/dist/fallback-llm.d.ts +2 -1
  341. package/dist/graph-dashboard-diff.d.ts +2 -1
  342. package/dist/graph-dashboard-key.d.ts +2 -1
  343. package/dist/graph-dashboard-parser.d.ts +2 -1
  344. package/dist/graph-edge-reinforcement.d.ts +2 -1
  345. package/dist/graph-snapshot.d.ts +2 -1
  346. package/dist/graph.d.ts +2 -1
  347. package/dist/harmonic-retrieval.js +2 -2
  348. package/dist/importance.d.ts +2 -1
  349. package/dist/importers/index.d.ts +2 -1
  350. package/dist/in-flight-reads.d.ts +2 -1
  351. package/dist/index.d.ts +362 -350
  352. package/dist/index.js +291 -259
  353. package/dist/intent.d.ts +2 -1
  354. package/dist/lcm/engine.d.ts +2 -1
  355. package/dist/lcm/engine.js +3 -3
  356. package/dist/lcm/index.d.ts +2 -1
  357. package/dist/lcm/index.js +8 -8
  358. package/dist/lcm/tools.d.ts +2 -1
  359. package/dist/lifecycle.d.ts +2 -1
  360. package/dist/live-connectors-runner.d.ts +2 -1
  361. package/dist/local-llm.d.ts +2 -1
  362. package/dist/local-llm.js +2 -2
  363. package/dist/local-model-endpoint.d.ts +2 -1
  364. package/dist/maintenance/memory-governance.d.ts +2 -1
  365. package/dist/maintenance/memory-governance.js +24 -23
  366. package/dist/maintenance/rebuild-memory-lifecycle-ledger.d.ts +3 -2
  367. package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +24 -23
  368. package/dist/maintenance/rebuild-memory-projection.d.ts +3 -2
  369. package/dist/maintenance/rebuild-memory-projection.js +26 -25
  370. package/dist/{maintenance-LbuS2rUA.d.ts → maintenance-D2mveyCd.d.ts} +3 -3
  371. package/dist/mcp-memory-inspector-app.d.ts +14 -10
  372. package/dist/mcp-read-only-tools.js +1 -1
  373. package/dist/memory-action-policy.d.ts +2 -1
  374. package/dist/memory-cache.d.ts +2 -1
  375. package/dist/memory-lifecycle-ledger-utils.d.ts +2 -1
  376. package/dist/memory-projection-store.d.ts +2 -1
  377. package/dist/memory-provenance.d.ts +2 -1
  378. package/dist/memory-worth-outcomes.d.ts +3 -2
  379. package/dist/models-json.d.ts +2 -1
  380. package/dist/namespaces/migrate.d.ts +4 -3
  381. package/dist/namespaces/migrate.js +40 -39
  382. package/dist/namespaces/principal.d.ts +2 -1
  383. package/dist/namespaces/search.d.ts +2 -1
  384. package/dist/namespaces/search.js +18 -18
  385. package/dist/namespaces/storage.d.ts +4 -3
  386. package/dist/namespaces/storage.js +23 -22
  387. package/dist/native-knowledge.d.ts +2 -1
  388. package/dist/offline-sync-impression-drain.d.ts +2 -1
  389. package/dist/offline-sync-impression-drain.js +11 -9
  390. package/dist/offline-sync.d.ts +29 -3
  391. package/dist/offline-sync.js +6 -2
  392. package/dist/operator-doctor-corpus.d.ts +2 -1
  393. package/dist/operator-doctor-corpus.js +45 -44
  394. package/dist/operator-doctor-replica.d.ts +2 -1
  395. package/dist/operator-doctor-replica.js +3 -3
  396. package/dist/operator-toolkit.d.ts +4 -3
  397. package/dist/operator-toolkit.js +59 -55
  398. package/dist/orchestration/compression-guideline-coordinator.d.ts +3 -2
  399. package/dist/orchestration/maintenance.d.ts +5 -4
  400. package/dist/orchestration/maintenance.js +36 -33
  401. package/dist/{orchestrator-rHiWt32X.d.ts → orchestrator-DJYlwiUv.d.ts} +14 -7
  402. package/dist/orchestrator.d.ts +9 -8
  403. package/dist/orchestrator.js +201 -189
  404. package/dist/page-versioning.js +3 -3
  405. package/dist/patterns-cli.d.ts +2 -1
  406. package/dist/{pipeline-W_97O8BV.d.ts → pipeline-CNjY4wk3.d.ts} +1 -1
  407. package/dist/policy-runtime.d.ts +2 -1
  408. package/dist/policy-runtime.js +1 -1
  409. package/dist/proactive-contention.d.ts +2 -1
  410. package/dist/provenance.d.ts +2 -1
  411. package/dist/provenance.js +2 -2
  412. package/dist/{qmd-LWtMofAf.d.ts → qmd-C0UDZidt.d.ts} +9 -7
  413. package/dist/qmd-preflight.d.ts +5 -4
  414. package/dist/qmd-preflight.js +2 -2
  415. package/dist/qmd-recall-cache.d.ts +2 -1
  416. package/dist/qmd.d.ts +4 -3
  417. package/dist/qmd.js +5 -5
  418. package/dist/recall-concurrency-config.d.ts +2 -1
  419. package/dist/recall-disclosure-escalation.d.ts +2 -1
  420. package/dist/recall-explain-renderer.d.ts +2 -1
  421. package/dist/recall-explain-renderer.js +3 -3
  422. package/dist/recall-memory-map.d.ts +2 -1
  423. package/dist/recall-planner-llm.d.ts +2 -1
  424. package/dist/recall-state.d.ts +2 -1
  425. package/dist/recall-tag-filter.d.ts +2 -1
  426. package/dist/recall-timings.d.ts +2 -1
  427. package/dist/recall-xray-cli.d.ts +2 -1
  428. package/dist/recall-xray-cli.js +4 -4
  429. package/dist/recall-xray-renderer.d.ts +2 -1
  430. package/dist/recall-xray-renderer.js +3 -3
  431. package/dist/recall-xray.d.ts +8 -1
  432. package/dist/recall-xray.js +2 -2
  433. package/dist/reconcile/cursor.d.ts +12 -2
  434. package/dist/reconcile/cursor.js +46 -7
  435. package/dist/reconcile/cursor.js.map +1 -1
  436. package/dist/reconcile/manifest.d.ts +9 -2
  437. package/dist/reconcile/manifest.js +15 -268
  438. package/dist/reconcile/manifest.js.map +1 -1
  439. package/dist/reconcile/plan.d.ts +4 -1
  440. package/dist/reconcile/plan.js +4 -4
  441. package/dist/replay/normalizers/chatgpt.d.ts +2 -1
  442. package/dist/replay/normalizers/claude.d.ts +2 -1
  443. package/dist/replay/normalizers/openclaw.d.ts +2 -1
  444. package/dist/replay/normalizers/shared.d.ts +2 -1
  445. package/dist/replay/runner.d.ts +2 -1
  446. package/dist/replay/types.d.ts +2 -1
  447. package/dist/replica-divergence.d.ts +2 -1
  448. package/dist/replica-divergence.js +2 -2
  449. package/dist/replica-peers-config.d.ts +2 -1
  450. package/dist/resolve-auth-token.d.ts +2 -1
  451. package/dist/resume-bundles.js +12 -10
  452. package/dist/retrieval-agents.d.ts +4 -3
  453. package/dist/retrieval-agents.js +2 -2
  454. package/dist/retrieval-tiers.d.ts +2 -1
  455. package/dist/routing/engine.d.ts +2 -1
  456. package/dist/routing/store.d.ts +2 -1
  457. package/dist/salvage-envelope.d.ts +2 -1
  458. package/dist/schemas.d.ts +32 -32
  459. package/dist/{scope-profiles-BiQKOE-p.d.ts → scope-profiles-BJzp2F5A.d.ts} +1 -1
  460. package/dist/search/embed-helper.d.ts +2 -1
  461. package/dist/search/embed-helper.js +3 -3
  462. package/dist/search/factory.d.ts +4 -2
  463. package/dist/search/factory.js +20 -18
  464. package/dist/search/index.d.ts +2 -1
  465. package/dist/search/index.js +22 -22
  466. package/dist/search/lancedb-backend.d.ts +2 -1
  467. package/dist/search/lancedb-backend.js +4 -4
  468. package/dist/search/meilisearch-backend.d.ts +2 -1
  469. package/dist/search/meilisearch-backend.js +4 -4
  470. package/dist/search/noop-backend.d.ts +2 -1
  471. package/dist/search/orama-backend.d.ts +2 -1
  472. package/dist/search/orama-backend.js +4 -4
  473. package/dist/search/port.d.ts +18 -1
  474. package/dist/search/port.js +1 -1
  475. package/dist/search/remote-backend.d.ts +2 -1
  476. package/dist/search/remote-backend.js +2 -2
  477. package/dist/secure-store/index.js +2 -2
  478. package/dist/{semantic-consolidation-dHYCyqgh.d.ts → semantic-consolidation-D4KAZO2G.d.ts} +1 -1
  479. package/dist/semantic-consolidation.d.ts +3 -2
  480. package/dist/semantic-consolidation.js +25 -24
  481. package/dist/semantic-rule-promotion.js +23 -22
  482. package/dist/semantic-rule-verifier.d.ts +2 -1
  483. package/dist/semantic-rule-verifier.js +24 -23
  484. package/dist/{service-DJG3KCQ4.d.ts → service-BeDxSqE-.d.ts} +2 -2
  485. package/dist/session-observer-bands.d.ts +2 -1
  486. package/dist/session-observer-state.d.ts +2 -1
  487. package/dist/shared-context/manager.d.ts +2 -1
  488. package/dist/shared-context/manager.js +2 -2
  489. package/dist/signal.d.ts +2 -1
  490. package/dist/source-agent-qualifier.d.ts +2 -1
  491. package/dist/source-agent-qualifier.js +42 -40
  492. package/dist/{storage-F9FVh-w9.d.ts → storage-DfjxusTE.d.ts} +24 -12
  493. package/dist/storage.d.ts +3 -2
  494. package/dist/storage.js +25 -24
  495. package/dist/summarizer.d.ts +2 -1
  496. package/dist/summarizer.js +5 -5
  497. package/dist/summary-snapshot.d.ts +2 -1
  498. package/dist/temporal-supersession.d.ts +3 -2
  499. package/dist/temporal-timeline-recall.d.ts +2 -1
  500. package/dist/temporal-validity.d.ts +2 -1
  501. package/dist/threading.d.ts +2 -1
  502. package/dist/tier-migration.d.ts +3 -2
  503. package/dist/tier-routing.d.ts +2 -1
  504. package/dist/tool-scoped-memory.d.ts +5 -1
  505. package/dist/tool-scoped-memory.js +3 -1
  506. package/dist/topics.d.ts +2 -1
  507. package/dist/transcript.d.ts +2 -1
  508. package/dist/transfer/capsule-import.js +4 -4
  509. package/dist/transfer/types.d.ts +12 -12
  510. package/dist/trust-score-stage.d.ts +2 -1
  511. package/dist/trust-score.d.ts +2 -1
  512. package/dist/{types-rEwubvim.d.ts → types-yX_FwERf.d.ts} +8 -1
  513. package/dist/types.d.ts +2 -1
  514. package/dist/types.js +1 -1
  515. package/dist/utility-runtime.d.ts +2 -1
  516. package/dist/verified-recall.js +24 -23
  517. package/dist/write-envelope.d.ts +2 -1
  518. package/package.json +2 -2
  519. package/src/abort-error.ts +17 -0
  520. package/src/access-admin-ops-surface.ts +1 -0
  521. package/src/access-boundary.ts +1 -0
  522. package/src/access-coding-context-resolution.ts +42 -0
  523. package/src/access-extraction-force-flush.ts +38 -2
  524. package/src/access-http-lcm-compaction.ts +5 -2
  525. package/src/access-http-offline-stream.ts +79 -0
  526. package/src/access-http.test.ts +310 -3
  527. package/src/access-http.ts +85 -21
  528. package/src/access-mcp-output-schemas.ts +36 -0
  529. package/src/access-mcp.test.ts +95 -1
  530. package/src/access-mcp.ts +7 -9
  531. package/src/access-observe-helpers.ts +64 -22
  532. package/src/access-observe-write-surface.ts +8 -0
  533. package/src/access-offline-manifest.ts +54 -0
  534. package/src/access-operations-batch.ts +3 -3
  535. package/src/access-operations.ts +13 -7
  536. package/src/access-recall-concurrency.ts +3 -27
  537. package/src/access-recall-surface.ts +3 -0
  538. package/src/access-service-health.test.ts +32 -7
  539. package/src/access-service-namespace.test.ts +55 -0
  540. package/src/access-service-observe-idempotency.test.ts +34 -2
  541. package/src/access-service-observe-lcm-parity.test.ts +138 -3
  542. package/src/access-service-observe-scope.test.ts +160 -1
  543. package/src/access-service-offline-file-content.test.ts +345 -1
  544. package/src/access-service.ts +86 -59
  545. package/src/access-surface-catalog.ts +4 -0
  546. package/src/admin/admin-surfaces.ts +2 -0
  547. package/src/binary-lifecycle/pipeline.test.ts +106 -1
  548. package/src/binary-lifecycle/pipeline.ts +3 -0
  549. package/src/coding/git-context.test.ts +47 -0
  550. package/src/coding/git-context.ts +129 -27
  551. package/src/config.test.ts +24 -0
  552. package/src/config.ts +9 -12
  553. package/src/connector-provenance.test.ts +101 -0
  554. package/src/consolidation-undo.ts +3 -0
  555. package/src/convergence-refresh.ts +14 -2
  556. package/src/correction/correction-access-wiring.ts +9 -7
  557. package/src/correction/correction-executor.test.ts +206 -2
  558. package/src/correction/correction-executor.ts +29 -20
  559. package/src/correction/correction-planner.test.ts +36 -0
  560. package/src/correction/correction-planner.ts +9 -15
  561. package/src/correction/correction-service.ts +3 -1
  562. package/src/correction/correction-storage-integration.test.ts +77 -0
  563. package/src/correction/correction-surfaces.test.ts +41 -28
  564. package/src/correction/passive-capture.test.ts +59 -0
  565. package/src/correction/passive-capture.ts +4 -1
  566. package/src/entity-retrieval-boundaries.ts +17 -4
  567. package/src/entity-retrieval.ts +27 -6
  568. package/src/external-wiki-access.test.ts +65 -0
  569. package/src/external-wiki-access.ts +31 -0
  570. package/src/external-wiki-cli.ts +92 -0
  571. package/src/external-wiki-collection-registration.test.ts +163 -0
  572. package/src/external-wiki-collection-registration.ts +101 -0
  573. package/src/external-wiki-collection.test.ts +502 -0
  574. package/src/external-wiki-collection.ts +503 -0
  575. package/src/external-wiki-config.test.ts +135 -0
  576. package/src/external-wiki-config.ts +100 -0
  577. package/src/external-wiki-guard.ts +83 -0
  578. package/src/external-wiki-mcp-tools.ts +23 -0
  579. package/src/external-wiki-search.test.ts +301 -0
  580. package/src/external-wiki-search.ts +362 -0
  581. package/src/external-wiki.test.ts +240 -0
  582. package/src/external-wiki.ts +453 -0
  583. package/src/extraction-scope-source-agent.test.ts +21 -0
  584. package/src/extraction-source-grounding-helpers.ts +243 -53
  585. package/src/extraction-source-grounding-rules.ts +133 -39
  586. package/src/extraction-source-grounding.test.ts +363 -33
  587. package/src/extraction-timeout.test.ts +1 -0
  588. package/src/extraction-watermark.test.ts +150 -7
  589. package/src/extraction.ts +8 -1
  590. package/src/index.ts +8 -0
  591. package/src/mcp-read-only-tools.ts +1 -0
  592. package/src/offline-sync.test.ts +194 -0
  593. package/src/offline-sync.ts +217 -13
  594. package/src/orchestration/external-wiki-recall-guard.test.ts +94 -0
  595. package/src/orchestration/extraction-persist.ts +19 -2
  596. package/src/orchestration/extraction-run-helpers.ts +37 -19
  597. package/src/orchestration/extraction-run.test.ts +171 -2
  598. package/src/orchestration/extraction-run.ts +11 -13
  599. package/src/orchestration/extraction-watermark.ts +106 -17
  600. package/src/orchestration/generic-recall-paths.ts +14 -0
  601. package/src/orchestration/orchestrator-helpers.ts +2 -0
  602. package/src/orchestration/orchestrator-init.ts +9 -0
  603. package/src/orchestration/recall-internal-deps.ts +6 -0
  604. package/src/orchestration/recall-internal.ts +154 -33
  605. package/src/orchestration/recall-rerank-coordinator.ts +60 -25
  606. package/src/orchestration/recall-search-pipeline.test.ts +75 -1
  607. package/src/orchestration/recall-search-pipeline.ts +50 -10
  608. package/src/orchestrator-convergence-refresh.test.ts +36 -2
  609. package/src/orchestrator.ts +13 -3
  610. package/src/page-versioning.ts +5 -19
  611. package/src/procedural/procedure-recall.ts +5 -1
  612. package/src/provenance-surfaces.test.ts +3 -0
  613. package/src/qmd-client.test.ts +78 -17
  614. package/src/qmd.test.ts +24 -0
  615. package/src/qmd.ts +224 -315
  616. package/src/recall-explain-renderer.ts +3 -0
  617. package/src/recall-rerank-coordinator.test.ts +61 -0
  618. package/src/recall-xray-renderer.test.ts +6 -0
  619. package/src/recall-xray.test.ts +88 -1
  620. package/src/recall-xray.ts +15 -0
  621. package/src/reconcile/cursor.test.ts +48 -0
  622. package/src/reconcile/cursor.ts +58 -11
  623. package/src/reconcile/manifest.test.ts +4 -0
  624. package/src/reconcile/manifest.ts +41 -51
  625. package/src/reconcile/plan.test.ts +4 -0
  626. package/src/reconcile/plan.ts +28 -16
  627. package/src/search/factory.ts +6 -6
  628. package/src/search/port.ts +25 -9
  629. package/src/secure-store/secure-fs.ts +20 -12
  630. package/src/secure-store/secure-store.test.ts +41 -2
  631. package/src/spaces/index.test.ts +61 -2
  632. package/src/spaces/index.ts +44 -18
  633. package/src/storage/entity-alias-config.ts +97 -0
  634. package/src/storage/entity-canonical-id-lock.ts +53 -23
  635. package/src/storage/entity-canonical-id-migration.ts +53 -22
  636. package/src/storage/entity-canonical-id-references.ts +3 -0
  637. package/src/storage/entity-id-safety.ts +7 -0
  638. package/src/storage/entity-store.ts +6 -2
  639. package/src/storage/memory-frontmatter-metadata.ts +4 -9
  640. package/src/storage/memory-migration-serialization.ts +10 -15
  641. package/src/storage/tombstone-blocked-capture-mutation.ts +52 -64
  642. package/src/storage/tombstone-blocked-capture-sync.ts +244 -199
  643. package/src/storage-deletion-revisions.test.ts +91 -0
  644. package/src/storage-fact-hash-index-defer.test.ts +446 -163
  645. package/src/storage.ts +534 -245
  646. package/src/tool-scoped-memory.ts +10 -0
  647. package/src/transfer/capsule-import.ts +13 -0
  648. package/src/transfer/capsule-merge.ts +13 -0
  649. package/src/trust-score-recall-paths.test.ts +75 -1
  650. package/src/types.ts +7 -3
  651. package/dist/capsule-merge-IDWJPCWK.js.map +0 -1
  652. package/dist/chunk-3CE77VAP.js.map +0 -1
  653. package/dist/chunk-3TBLDMJA.js.map +0 -1
  654. package/dist/chunk-4J7G5SY4.js.map +0 -1
  655. package/dist/chunk-57QKLRBV.js.map +0 -1
  656. package/dist/chunk-5TFP4CUL.js.map +0 -1
  657. package/dist/chunk-7XC2HX75.js.map +0 -1
  658. package/dist/chunk-A5OJCXZL.js.map +0 -1
  659. package/dist/chunk-BUE5E2HL.js.map +0 -1
  660. package/dist/chunk-CJ2ZR7UA.js.map +0 -1
  661. package/dist/chunk-CUM2BBPN.js.map +0 -1
  662. package/dist/chunk-D3J5SLQK.js.map +0 -1
  663. package/dist/chunk-DL7ZD3JH.js.map +0 -1
  664. package/dist/chunk-DLVPUX7U.js.map +0 -1
  665. package/dist/chunk-E6PNLPGJ.js.map +0 -1
  666. package/dist/chunk-ECK75GDJ.js.map +0 -1
  667. package/dist/chunk-HREE4JHI.js.map +0 -1
  668. package/dist/chunk-HZFHQ4AQ.js.map +0 -1
  669. package/dist/chunk-IKKWIPYN.js.map +0 -1
  670. package/dist/chunk-J7VGGECD.js.map +0 -1
  671. package/dist/chunk-N5Z4EVOR.js.map +0 -1
  672. package/dist/chunk-NVRYW264.js.map +0 -1
  673. package/dist/chunk-P2BM76KT.js.map +0 -1
  674. package/dist/chunk-PVGDJXVK.js +0 -21
  675. package/dist/chunk-QJAQNXWI.js.map +0 -1
  676. package/dist/chunk-RN7DY3FC.js.map +0 -1
  677. package/dist/chunk-RVLJEII5.js.map +0 -1
  678. package/dist/chunk-S2NCTZGJ.js.map +0 -1
  679. package/dist/chunk-TDHTVMPG.js.map +0 -1
  680. package/dist/chunk-UYLMNVY6.js.map +0 -1
  681. package/dist/chunk-VCD4PSK2.js.map +0 -1
  682. package/dist/chunk-VNA7W7QF.js.map +0 -1
  683. package/dist/chunk-VWAXN2BN.js.map +0 -1
  684. package/dist/chunk-WOCNN776.js.map +0 -1
  685. package/dist/chunk-XYTOI63Z.js.map +0 -1
  686. package/dist/chunk-YV32N67O.js.map +0 -1
  687. /package/dist/{auto-sync-5OE5QOZB.js.map → auto-sync-UPTUVE4X.js.map} +0 -0
  688. /package/dist/{chunk-VUPTKTDV.js.map → chunk-2MRHJNWL.js.map} +0 -0
  689. /package/dist/{chunk-JBPKEARU.js.map → chunk-2QSZNTDO.js.map} +0 -0
  690. /package/dist/{chunk-5IVLTFOV.js.map → chunk-44N6ESJ4.js.map} +0 -0
  691. /package/dist/{chunk-HO3QBJEY.js.map → chunk-5546W5SI.js.map} +0 -0
  692. /package/dist/{chunk-U7GW7NE7.js.map → chunk-5CEECY6P.js.map} +0 -0
  693. /package/dist/{chunk-4UH4BTGK.js.map → chunk-5SNZSWWR.js.map} +0 -0
  694. /package/dist/{chunk-6CZPDBJS.js.map → chunk-5U7ID3EZ.js.map} +0 -0
  695. /package/dist/{chunk-GF22HWS2.js.map → chunk-6NNNURLK.js.map} +0 -0
  696. /package/dist/{chunk-227UFSEQ.js.map → chunk-7RZJWZ46.js.map} +0 -0
  697. /package/dist/{chunk-E5UK4VPE.js.map → chunk-7SHJHPTY.js.map} +0 -0
  698. /package/dist/{chunk-UVIKWC7M.js.map → chunk-7YERSTN7.js.map} +0 -0
  699. /package/dist/{chunk-S5SLVSVY.js.map → chunk-BQIFZ2MP.js.map} +0 -0
  700. /package/dist/{chunk-E53DSZEN.js.map → chunk-C26TE27X.js.map} +0 -0
  701. /package/dist/{chunk-LZ4LDKHZ.js.map → chunk-CLB32OHM.js.map} +0 -0
  702. /package/dist/{chunk-Q6IP2ARR.js.map → chunk-CSOYVTRX.js.map} +0 -0
  703. /package/dist/{chunk-XOQSEF7X.js.map → chunk-CVILPI77.js.map} +0 -0
  704. /package/dist/{chunk-PDLBLTOK.js.map → chunk-EITZHSX6.js.map} +0 -0
  705. /package/dist/{chunk-WUNIWKY4.js.map → chunk-ELIL2A37.js.map} +0 -0
  706. /package/dist/{chunk-CINZGPSJ.js.map → chunk-GUMZC2BO.js.map} +0 -0
  707. /package/dist/{chunk-H24WNPA2.js.map → chunk-GWFSVJ4P.js.map} +0 -0
  708. /package/dist/{chunk-TSH56VPU.js.map → chunk-HAYSYUAB.js.map} +0 -0
  709. /package/dist/{chunk-PKNLM44P.js.map → chunk-JH6BPLOP.js.map} +0 -0
  710. /package/dist/{chunk-KXB4VXHY.js.map → chunk-JIYDRBVZ.js.map} +0 -0
  711. /package/dist/{chunk-AV5ZEH4M.js.map → chunk-KVJRXN2E.js.map} +0 -0
  712. /package/dist/{chunk-JVLCVFQ4.js.map → chunk-KXEFRMCF.js.map} +0 -0
  713. /package/dist/{chunk-WFTIGIIS.js.map → chunk-L6CQ7WIW.js.map} +0 -0
  714. /package/dist/{chunk-EJUEXZHX.js.map → chunk-LLJMAULE.js.map} +0 -0
  715. /package/dist/{chunk-AS7YMSL6.js.map → chunk-M23RF3LJ.js.map} +0 -0
  716. /package/dist/{chunk-3F2LKUMU.js.map → chunk-NIS256NW.js.map} +0 -0
  717. /package/dist/{chunk-YIAA2X3D.js.map → chunk-NK5RGJ65.js.map} +0 -0
  718. /package/dist/{chunk-OQ5PRDDS.js.map → chunk-NTOIP2E6.js.map} +0 -0
  719. /package/dist/{chunk-HLPD7B7P.js.map → chunk-NUEQKLNB.js.map} +0 -0
  720. /package/dist/{chunk-33PLLLL7.js.map → chunk-P7NGM24P.js.map} +0 -0
  721. /package/dist/{chunk-7TWUCYER.js.map → chunk-PNRA7FAD.js.map} +0 -0
  722. /package/dist/{chunk-5I4M26Q7.js.map → chunk-QBSFOKY6.js.map} +0 -0
  723. /package/dist/{chunk-P4DRWEYC.js.map → chunk-QVSBTCVP.js.map} +0 -0
  724. /package/dist/{chunk-AAIUERNB.js.map → chunk-R5RFK3CB.js.map} +0 -0
  725. /package/dist/{chunk-WDISJRMG.js.map → chunk-RMMVQQA6.js.map} +0 -0
  726. /package/dist/{chunk-5SM35XZR.js.map → chunk-S5NZBKKQ.js.map} +0 -0
  727. /package/dist/{chunk-WIPEXG6R.js.map → chunk-SXIMQLGV.js.map} +0 -0
  728. /package/dist/{chunk-OAEQLRCY.js.map → chunk-TN76AKO3.js.map} +0 -0
  729. /package/dist/{chunk-QN25OCUF.js.map → chunk-TQ4GD737.js.map} +0 -0
  730. /package/dist/{chunk-7K5Q6COX.js.map → chunk-TVVEYCNW.js.map} +0 -0
  731. /package/dist/{chunk-DNWXFTLD.js.map → chunk-TYISDI6B.js.map} +0 -0
  732. /package/dist/{chunk-4LMA77JH.js.map → chunk-U2VLVBBH.js.map} +0 -0
  733. /package/dist/{chunk-5ZE7QHTK.js.map → chunk-ULVR5KG7.js.map} +0 -0
  734. /package/dist/{chunk-4B77XSG5.js.map → chunk-UV72DEZD.js.map} +0 -0
  735. /package/dist/{chunk-S2BBISHU.js.map → chunk-VANZKHTN.js.map} +0 -0
  736. /package/dist/{chunk-3Y224NYC.js.map → chunk-VYISFWVX.js.map} +0 -0
  737. /package/dist/{chunk-TIHMZFIV.js.map → chunk-W3IC7QOY.js.map} +0 -0
  738. /package/dist/{chunk-NRV4Y3PM.js.map → chunk-W4FBGYGK.js.map} +0 -0
  739. /package/dist/{chunk-MU7ZHSZE.js.map → chunk-WZFAPHIK.js.map} +0 -0
  740. /package/dist/{chunk-T2TTP3KU.js.map → chunk-X4IDNPOS.js.map} +0 -0
  741. /package/dist/{chunk-BLAKS3CP.js.map → chunk-XL3TATMJ.js.map} +0 -0
  742. /package/dist/{chunk-W4XJFLAL.js.map → chunk-XPRJSHNI.js.map} +0 -0
  743. /package/dist/{chunk-JE7EK33X.js.map → chunk-Y7HRYCNW.js.map} +0 -0
  744. /package/dist/{chunk-E6EE5B67.js.map → chunk-YK6BDDHP.js.map} +0 -0
  745. /package/dist/{chunk-ES36HTSC.js.map → chunk-YLHM5BQQ.js.map} +0 -0
  746. /package/dist/{chunk-BJKPPZ6Z.js.map → chunk-ZFGZ6PZ2.js.map} +0 -0
  747. /package/dist/{chunk-64UDOIMI.js.map → chunk-ZLQ37WJX.js.map} +0 -0
@@ -1,42 +1,33 @@
1
1
  import {
2
2
  runCodexMaterialize,
3
3
  runPostConsolidationMaterialize
4
- } from "../chunk-BJKPPZ6Z.js";
4
+ } from "../chunk-ZFGZ6PZ2.js";
5
5
  import "../chunk-KSXJOC4F.js";
6
- import "../chunk-E6PNLPGJ.js";
6
+ import "../chunk-FZP32336.js";
7
7
  import "../chunk-UHVXE24Y.js";
8
8
  import "../chunk-ENTCVTQR.js";
9
- import "../chunk-WIPEXG6R.js";
9
+ import "../chunk-SXIMQLGV.js";
10
+ import "../chunk-S2V7RUCL.js";
10
11
  import "../chunk-J6A3CX5N.js";
11
- import "../chunk-J7VGGECD.js";
12
- import "../chunk-WUNIWKY4.js";
13
- import "../chunk-EGGE52UU.js";
14
- import "../chunk-ZA53AZND.js";
12
+ import "../chunk-DZPFMQZ7.js";
15
13
  import "../chunk-SCU65EZI.js";
16
14
  import "../chunk-WRJVB3C2.js";
17
- import "../chunk-GCASGYIO.js";
18
- import "../chunk-7RJUVTVF.js";
19
15
  import "../chunk-DM2T26WE.js";
20
16
  import "../chunk-LDXUBPMO.js";
21
17
  import "../chunk-JYIJNNN3.js";
22
18
  import "../chunk-AAD2ZS6P.js";
23
- import "../chunk-RVLJEII5.js";
24
- import "../chunk-S5SLVSVY.js";
19
+ import "../chunk-SYUBB3WM.js";
25
20
  import "../chunk-CGASUJVP.js";
26
21
  import "../chunk-R3DJVOSM.js";
27
22
  import "../chunk-BT7NVCML.js";
28
- import "../chunk-3CSX3ETE.js";
29
- import "../chunk-RL6NEVXT.js";
30
23
  import "../chunk-YXZG5TVN.js";
31
- import "../chunk-W5H6ZRPT.js";
32
24
  import "../chunk-G7D6GZ5J.js";
33
- import "../chunk-DLVPUX7U.js";
25
+ import "../chunk-7YKVM5H3.js";
34
26
  import "../chunk-IJ7HK452.js";
35
27
  import "../chunk-PDJTHRAW.js";
36
- import "../chunk-4J7G5SY4.js";
28
+ import "../chunk-NZBZ7IS2.js";
37
29
  import "../chunk-DNHVPZOD.js";
38
30
  import "../chunk-6CIAGZ6X.js";
39
- import "../chunk-FFAZ2XFU.js";
40
31
  import "../chunk-XMMESCPD.js";
41
32
  import "../chunk-42JKGUFJ.js";
42
33
  import "../chunk-C23BYTJV.js";
@@ -45,22 +36,32 @@ import "../chunk-L2EXJQJP.js";
45
36
  import "../chunk-45GF7Y3V.js";
46
37
  import "../chunk-RGMVMVMF.js";
47
38
  import "../chunk-N7RWREIQ.js";
48
- import "../chunk-5I4M26Q7.js";
49
- import "../chunk-ZIKENA2C.js";
39
+ import "../chunk-QBSFOKY6.js";
50
40
  import "../chunk-5GKPFL3S.js";
41
+ import "../chunk-ZIKENA2C.js";
51
42
  import "../chunk-PQVCH2AE.js";
52
- import "../chunk-EYIEWJNI.js";
53
- import "../chunk-JUC24CTX.js";
54
43
  import "../chunk-6MKAMLQL.js";
55
44
  import "../chunk-JAKIDQB2.js";
56
45
  import "../chunk-BJMBJZ2Y.js";
57
46
  import "../chunk-UKJAGEXH.js";
58
47
  import "../chunk-FP2373TW.js";
48
+ import "../chunk-ELIL2A37.js";
49
+ import "../chunk-EGGE52UU.js";
50
+ import "../chunk-ZA53AZND.js";
51
+ import "../chunk-7RJUVTVF.js";
52
+ import "../chunk-GCASGYIO.js";
53
+ import "../chunk-BQIFZ2MP.js";
54
+ import "../chunk-3CSX3ETE.js";
55
+ import "../chunk-RL6NEVXT.js";
56
+ import "../chunk-FFAZ2XFU.js";
57
+ import "../chunk-W5H6ZRPT.js";
59
58
  import "../chunk-P7FMDTKL.js";
60
59
  import "../chunk-U3PN77QT.js";
61
60
  import "../chunk-2XRE6FLM.js";
61
+ import "../chunk-EYIEWJNI.js";
62
+ import "../chunk-JUC24CTX.js";
62
63
  import "../chunk-FF4KLI5W.js";
63
- import "../chunk-5TFP4CUL.js";
64
+ import "../chunk-XQ3HXAQH.js";
64
65
  import "../chunk-A6XUJE5D.js";
65
66
  import "../chunk-5UZXUTVO.js";
66
67
  import "../chunk-VS2IYZRU.js";
@@ -1,7 +1,8 @@
1
- import { M as MemoryFile } from '../types-rEwubvim.js';
1
+ import { M as MemoryFile } from '../types-yX_FwERf.js';
2
2
  import '../message-parts/index.js';
3
3
  import '../bounded-jsonl-state.js';
4
4
  import '../operator-doctor-types.js';
5
+ import '../external-wiki-config.js';
5
6
  import '../types-continuity.js';
6
7
 
7
8
  /**
@@ -1,9 +1,10 @@
1
1
  export { MATERIALIZE_VERSION, MaterializeOptions, MaterializeResult, MemoryMdValidation, RolloutSummaryInput, SENTINEL_FILE, TMP_DIR, approximateTokenCount, describeMemoriesDir, ensureSentinel, materializeForNamespace, renderMemoryMd, renderMemorySummary, renderRawMemories, renderRolloutSummary, truncateToTokenBudget, validateMemoryMd } from './codex-materialize.js';
2
2
  export { RunMaterializeOptions, runCodexMaterialize } from './codex-materialize-runner.js';
3
- import { P as PluginConfig } from '../types-rEwubvim.js';
3
+ import { P as PluginConfig } from '../types-yX_FwERf.js';
4
4
  import '../message-parts/index.js';
5
5
  import '../bounded-jsonl-state.js';
6
6
  import '../operator-doctor-types.js';
7
+ import '../external-wiki-config.js';
7
8
  import '../types-continuity.js';
8
9
 
9
10
  /**
@@ -25,12 +25,11 @@ import {
25
25
  upsertHermesConfig,
26
26
  validateMarketplaceManifest,
27
27
  writeMarketplaceManifest
28
- } from "../chunk-7TWUCYER.js";
28
+ } from "../chunk-PNRA7FAD.js";
29
29
  import "../chunk-EMDLM3LW.js";
30
- import "../chunk-O75CRYGF.js";
31
30
  import {
32
31
  runCodexMaterialize
33
- } from "../chunk-BJKPPZ6Z.js";
32
+ } from "../chunk-ZFGZ6PZ2.js";
34
33
  import {
35
34
  MATERIALIZE_VERSION,
36
35
  SENTINEL_FILE,
@@ -46,40 +45,31 @@ import {
46
45
  truncateToTokenBudget,
47
46
  validateMemoryMd
48
47
  } from "../chunk-KSXJOC4F.js";
49
- import "../chunk-E6PNLPGJ.js";
48
+ import "../chunk-FZP32336.js";
50
49
  import "../chunk-UHVXE24Y.js";
51
50
  import "../chunk-ENTCVTQR.js";
52
- import "../chunk-WIPEXG6R.js";
51
+ import "../chunk-SXIMQLGV.js";
52
+ import "../chunk-S2V7RUCL.js";
53
53
  import "../chunk-J6A3CX5N.js";
54
- import "../chunk-J7VGGECD.js";
55
- import "../chunk-WUNIWKY4.js";
56
- import "../chunk-EGGE52UU.js";
57
- import "../chunk-ZA53AZND.js";
54
+ import "../chunk-DZPFMQZ7.js";
58
55
  import "../chunk-SCU65EZI.js";
59
56
  import "../chunk-WRJVB3C2.js";
60
- import "../chunk-GCASGYIO.js";
61
- import "../chunk-7RJUVTVF.js";
62
57
  import "../chunk-DM2T26WE.js";
63
58
  import "../chunk-LDXUBPMO.js";
64
59
  import "../chunk-JYIJNNN3.js";
65
60
  import "../chunk-AAD2ZS6P.js";
66
- import "../chunk-RVLJEII5.js";
67
- import "../chunk-S5SLVSVY.js";
61
+ import "../chunk-SYUBB3WM.js";
68
62
  import "../chunk-CGASUJVP.js";
69
63
  import "../chunk-R3DJVOSM.js";
70
64
  import "../chunk-BT7NVCML.js";
71
- import "../chunk-3CSX3ETE.js";
72
- import "../chunk-RL6NEVXT.js";
73
65
  import "../chunk-YXZG5TVN.js";
74
- import "../chunk-W5H6ZRPT.js";
75
66
  import "../chunk-G7D6GZ5J.js";
76
- import "../chunk-DLVPUX7U.js";
67
+ import "../chunk-7YKVM5H3.js";
77
68
  import "../chunk-IJ7HK452.js";
78
69
  import "../chunk-PDJTHRAW.js";
79
- import "../chunk-4J7G5SY4.js";
70
+ import "../chunk-NZBZ7IS2.js";
80
71
  import "../chunk-DNHVPZOD.js";
81
72
  import "../chunk-6CIAGZ6X.js";
82
- import "../chunk-FFAZ2XFU.js";
83
73
  import "../chunk-XMMESCPD.js";
84
74
  import "../chunk-42JKGUFJ.js";
85
75
  import "../chunk-C23BYTJV.js";
@@ -88,30 +78,41 @@ import "../chunk-L2EXJQJP.js";
88
78
  import "../chunk-45GF7Y3V.js";
89
79
  import "../chunk-RGMVMVMF.js";
90
80
  import "../chunk-N7RWREIQ.js";
91
- import "../chunk-MZWSOLMT.js";
92
81
  import {
93
82
  getConnectorsDir,
94
83
  getRegistryPath
95
84
  } from "../chunk-K6MV3TRQ.js";
96
- import "../chunk-5I4M26Q7.js";
97
- import "../chunk-ZIKENA2C.js";
85
+ import "../chunk-QBSFOKY6.js";
98
86
  import "../chunk-5GKPFL3S.js";
87
+ import "../chunk-ZIKENA2C.js";
99
88
  import {
100
89
  coerceInstallExtension
101
90
  } from "../chunk-PQVCH2AE.js";
102
- import "../chunk-EYIEWJNI.js";
103
- import "../chunk-JUC24CTX.js";
104
91
  import "../chunk-6MKAMLQL.js";
105
92
  import "../chunk-JAKIDQB2.js";
106
93
  import "../chunk-BJMBJZ2Y.js";
107
94
  import "../chunk-UKJAGEXH.js";
108
95
  import "../chunk-FP2373TW.js";
96
+ import "../chunk-ELIL2A37.js";
97
+ import "../chunk-EGGE52UU.js";
98
+ import "../chunk-ZA53AZND.js";
99
+ import "../chunk-7RJUVTVF.js";
100
+ import "../chunk-GCASGYIO.js";
101
+ import "../chunk-BQIFZ2MP.js";
102
+ import "../chunk-3CSX3ETE.js";
103
+ import "../chunk-RL6NEVXT.js";
104
+ import "../chunk-FFAZ2XFU.js";
105
+ import "../chunk-W5H6ZRPT.js";
109
106
  import "../chunk-P7FMDTKL.js";
107
+ import "../chunk-MZWSOLMT.js";
110
108
  import "../chunk-U3PN77QT.js";
111
109
  import "../chunk-2XRE6FLM.js";
110
+ import "../chunk-O75CRYGF.js";
111
+ import "../chunk-EYIEWJNI.js";
112
+ import "../chunk-JUC24CTX.js";
112
113
  import "../chunk-2Z24E5W2.js";
113
114
  import "../chunk-FF4KLI5W.js";
114
- import "../chunk-5TFP4CUL.js";
115
+ import "../chunk-XQ3HXAQH.js";
115
116
  import "../chunk-A6XUJE5D.js";
116
117
  import "../chunk-5UZXUTVO.js";
117
118
  import "../chunk-VS2IYZRU.js";
@@ -1,8 +1,9 @@
1
- import { S as StorageManager } from './storage-F9FVh-w9.js';
2
- import './types-rEwubvim.js';
1
+ import { S as StorageManager } from './storage-DfjxusTE.js';
2
+ import './types-yX_FwERf.js';
3
3
  import './message-parts/index.js';
4
4
  import './bounded-jsonl-state.js';
5
5
  import './operator-doctor-types.js';
6
+ import './external-wiki-config.js';
6
7
  import './types-continuity.js';
7
8
  import './entity-id-normalization.js';
8
9
  import './page-versioning.js';
@@ -1,16 +1,16 @@
1
1
  import {
2
2
  runConsolidationProvenanceCheck
3
- } from "./chunk-TSH56VPU.js";
3
+ } from "./chunk-HAYSYUAB.js";
4
4
  import "./chunk-G7D6GZ5J.js";
5
- import "./chunk-DLVPUX7U.js";
5
+ import "./chunk-7YKVM5H3.js";
6
6
  import "./chunk-IJ7HK452.js";
7
7
  import "./chunk-PDJTHRAW.js";
8
- import "./chunk-4J7G5SY4.js";
8
+ import "./chunk-NZBZ7IS2.js";
9
9
  import "./chunk-DNHVPZOD.js";
10
10
  import "./chunk-6CIAGZ6X.js";
11
- import "./chunk-FFAZ2XFU.js";
12
11
  import "./chunk-XMMESCPD.js";
13
12
  import "./chunk-42JKGUFJ.js";
13
+ import "./chunk-FFAZ2XFU.js";
14
14
  import "./chunk-5UZXUTVO.js";
15
15
  import "./chunk-VS2IYZRU.js";
16
16
  import "./chunk-3WCASNQZ.js";
@@ -1,9 +1,10 @@
1
- import { S as StorageManager } from './storage-F9FVh-w9.js';
1
+ import { S as StorageManager } from './storage-DfjxusTE.js';
2
2
  import { VersioningConfig } from './page-versioning.js';
3
- import './types-rEwubvim.js';
3
+ import './types-yX_FwERf.js';
4
4
  import './message-parts/index.js';
5
5
  import './bounded-jsonl-state.js';
6
6
  import './operator-doctor-types.js';
7
+ import './external-wiki-config.js';
7
8
  import './types-continuity.js';
8
9
  import './entity-id-normalization.js';
9
10
  import './consolidation-operator.js';
@@ -1,18 +1,19 @@
1
1
  import {
2
2
  getVersion
3
- } from "./chunk-DLVPUX7U.js";
3
+ } from "./chunk-7YKVM5H3.js";
4
4
  import {
5
5
  bumpMemoryCorpusVersionForDir
6
6
  } from "./chunk-IJ7HK452.js";
7
7
  import "./chunk-PDJTHRAW.js";
8
8
  import {
9
- requestEntityCanonicalIdReconcile
10
- } from "./chunk-4J7G5SY4.js";
9
+ requestEntityCanonicalIdReconcile,
10
+ withRawEntityPageMutation
11
+ } from "./chunk-NZBZ7IS2.js";
11
12
  import "./chunk-DNHVPZOD.js";
12
13
  import "./chunk-6CIAGZ6X.js";
13
- import "./chunk-FFAZ2XFU.js";
14
14
  import "./chunk-XMMESCPD.js";
15
15
  import "./chunk-42JKGUFJ.js";
16
+ import "./chunk-FFAZ2XFU.js";
16
17
  import "./chunk-5UZXUTVO.js";
17
18
  import "./chunk-VS2IYZRU.js";
18
19
  import "./chunk-3WCASNQZ.js";
@@ -386,9 +387,11 @@ async function runConsolidationUndo(options) {
386
387
  }
387
388
  try {
388
389
  await mkdir(path.dirname(p.sourcePath), { recursive: true });
389
- await writeFile(p.sourcePath, p.content, { encoding: "utf-8", flag: "wx" });
390
- bumpMemoryCorpusVersionForDir(memoryDir);
391
- await requestEntityCanonicalIdReconcile(path.join(memoryDir, "state"));
390
+ await withRawEntityPageMutation(memoryDir, p.sourcePath, async () => {
391
+ await writeFile(p.sourcePath, p.content, { encoding: "utf-8", flag: "wx" });
392
+ bumpMemoryCorpusVersionForDir(memoryDir);
393
+ await requestEntityCanonicalIdReconcile(path.join(memoryDir, "state"));
394
+ });
392
395
  result.restores.push({
393
396
  entry: p.entry,
394
397
  sourcePath: p.sourcePath,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/consolidation-undo.ts"],"sourcesContent":["/**\n * Consolidation undo (issue #561 PR 5).\n *\n * Reverts a consolidated memory by restoring each source memory from its\n * `derived_from` snapshot and archiving the target.\n *\n * Contract:\n * - Load the target memory markdown file via its absolute path.\n * - For every `\"<rel>:<version>\"` entry in `derived_from`, fetch the\n * snapshot content via `page-versioning.getVersion` and restore it\n * to the original relative path. If the restore target file\n * already exists, we skip overwriting it (the source was never\n * archived, or was re-created since) and record the skip.\n * - Archive the target with reason code `\"consolidation-undo\"` so the\n * lifecycle ledger records the undo.\n * - Dry-run mode produces the same plan without touching disk.\n *\n * The helper is kept pure over `StorageManager` so the CLI can reuse it\n * without additional wiring, and tests can exercise the plan logic\n * directly.\n */\n\nimport path from \"node:path\";\nimport { mkdir, writeFile, access, realpath, lstat } from \"node:fs/promises\";\nimport { constants as fsConstants } from \"node:fs\";\nimport type { StorageManager } from \"./storage.js\";\nimport type { VersioningConfig } from \"./page-versioning.js\";\nimport { bumpMemoryCorpusVersionForDir } from \"./memory-corpus-version.js\";\nimport { requestEntityCanonicalIdReconcile } from \"./storage/entity-canonical-id-references.js\";\nimport { getVersion } from \"./page-versioning.js\";\n\n/**\n * Outcome of restoring a single `derived_from` source.\n */\nexport interface ConsolidationUndoRestore {\n /** The raw `\"<relpath>:<version>\"` entry from `derived_from`. */\n entry: string;\n /** Absolute path where the source would be / was restored. */\n sourcePath: string;\n /** What actually happened. */\n outcome:\n | \"restored\"\n | \"skipped_file_exists\"\n | \"skipped_non_regular_file\"\n | \"skipped_snapshot_missing\"\n | \"skipped_malformed_entry\"\n | \"skipped_outside_memory_dir\"\n | \"skipped_non_active_path\"\n | \"skipped_self_referential\"\n | \"skipped_write_failed\"\n | \"skipped_blocked_by_other_failures\"\n | \"skipped_dry_run\";\n /** Human-readable detail. */\n detail?: string;\n}\n\n/**\n * Plan + result of a `remnic consolidate undo` invocation.\n */\nexport interface ConsolidationUndoResult {\n /** Absolute path to the target memory. */\n targetPath: string;\n /** True when the target was archived successfully. */\n targetArchived: boolean;\n /** Per-source restore outcomes. */\n restores: ConsolidationUndoRestore[];\n /** Whether the run was a dry-run plan only. */\n dryRun: boolean;\n /** Fatal error, if any — the run bails early. */\n error?: string;\n}\n\nconst DERIVED_FROM_ENTRY_RE = /^(.+):(\\d+)$/;\n\nfunction parseEntry(entry: unknown): { pagePath: string; versionId: string } | null {\n // Non-string entries (PR #637 round-3 review, cursor Low) can arrive\n // from hostile on-disk frontmatter — guard against a .match() crash.\n if (typeof entry !== \"string\") return null;\n const match = entry.match(DERIVED_FROM_ENTRY_RE);\n if (!match) return null;\n return { pagePath: match[1], versionId: match[2] };\n}\n\n/**\n * Verify that `candidate` resolves inside `root` (defense against\n * path-traversal in `derived_from` entries and user-facing target\n * paths). Path-string normalization only; for symlink-aware checks\n * use `isInsideDirectoryRealpath`. Both paths are resolved to\n * absolute form before comparison so `..` segments, symlinks-as-\n * strings, and relative prefixes are normalized.\n */\nexport function isInsideDirectory(candidate: string, root: string): boolean {\n const normRoot = path.resolve(root);\n const normCandidate = path.resolve(candidate);\n const rel = path.relative(normRoot, normCandidate);\n if (rel.length === 0) return true;\n if (rel.startsWith(\"..\")) return false;\n if (path.isAbsolute(rel)) return false;\n return true;\n}\n\n/**\n * Symlink-aware containment check (PR #637 round-2 review, codex P1).\n *\n * `isInsideDirectory` only normalizes path strings — if a `derived_from`\n * entry resolves through a symlink inside `memoryDir` that points\n * outside, the string check passes but the subsequent `writeFile` would\n * land outside the memory tree. Use this guard for any path that is\n * about to be written.\n *\n * Walks every parent directory between `candidate` and `root`,\n * `realpath`-ing each segment that exists and rejecting when any\n * segment escapes `root`. Non-existent parents are resolved as the\n * canonicalized deepest-existing ancestor plus the trailing segments,\n * so a not-yet-created target file still gets the symlink check on its\n * existing parent directories.\n */\nexport async function isInsideDirectoryRealpath(\n candidate: string,\n root: string,\n): Promise<boolean> {\n if (!isInsideDirectory(candidate, root)) return false;\n // Reject raw `..` segments before canonicalization so that symlinks\n // cannot be hidden behind intermediate dot-dot components (PR #637\n // round-14 review, codex P1).\n const rawSegments = candidate.replace(/\\\\/g, \"/\").split(\"/\");\n if (rawSegments.some((s) => s === \"..\")) return false;\n let resolvedRoot: string;\n try {\n resolvedRoot = await realpath(path.resolve(root));\n } catch {\n return false;\n }\n const normCandidate = path.resolve(candidate);\n\n // Reject dangling symlinks (PR #637 round-3 review, codex P1).\n // If the candidate itself is a symlink (even if its target doesn't\n // exist), Node will follow it when we later call `writeFile`.\n // `lstat` inspects the link itself without dereferencing; if it\n // succeeds and reports a symlink, we treat the candidate as\n // unsafe. We must check every non-root ancestor too — a symlink\n // anywhere along the path lets an attacker redirect writes.\n const normRoot = path.resolve(root);\n const relFromRoot = path.relative(normRoot, normCandidate);\n const segments = relFromRoot.length > 0 ? relFromRoot.split(path.sep) : [];\n for (let i = 0; i <= segments.length; i++) {\n const probe = i === 0 ? normRoot : path.join(normRoot, ...segments.slice(0, i));\n try {\n const st = await lstat(probe);\n if (st.isSymbolicLink() && probe !== normRoot) {\n // A symlink on the path — resolve THIS segment and bail out\n // if the resolved target escapes `resolvedRoot`.\n let target: string;\n try {\n target = await realpath(probe);\n } catch {\n // Dangling symlink inside memoryDir — always unsafe.\n return false;\n }\n const rel = path.relative(resolvedRoot, target);\n if (rel.length === 0) continue;\n if (rel.startsWith(\"..\") || path.isAbsolute(rel)) return false;\n }\n } catch {\n // Segment doesn't exist yet — that's fine, fall through to the\n // textual containment verification below.\n }\n }\n\n // Walk up from the candidate until we hit a path that exists, then\n // realpath THAT and re-apply the trailing segments textually.\n const parts = normCandidate.split(path.sep);\n for (let i = parts.length; i > 0; i--) {\n const probe = parts.slice(0, i).join(path.sep) || path.sep;\n try {\n const resolved = await realpath(probe);\n // Re-join any trailing segments that didn't exist yet.\n const trailing = parts.slice(i).join(path.sep);\n const final = trailing.length > 0 ? path.join(resolved, trailing) : resolved;\n // Now apply the textual containment check against the canonical\n // `resolvedRoot`.\n const rel = path.relative(resolvedRoot, final);\n if (rel.length === 0) return true;\n if (rel.startsWith(\"..\")) return false;\n if (path.isAbsolute(rel)) return false;\n return true;\n } catch {\n continue;\n }\n }\n // Nothing along the path resolvable — treat as outside by default.\n return false;\n}\n\n/**\n * Directories under memoryDir that are NOT active memory locations.\n * A `derived_from` entry pointing into one of these should not be\n * counted as \"recovered_existing\" (PR #637 round-7 review, codex P2).\n * The versioning sidecar directory is included dynamically via the\n * `sidecarDir` parameter (PR #637 round-8 review, codex P2).\n */\nconst NON_ACTIVE_PREFIXES = [\"archive/\", \"state/\"];\n\n/**\n * Normalize a relative path by collapsing `.` and `..` segments so\n * that crafted entries like `\"facts/../archive/x.md\"` are reduced to\n * `\"archive/x.md\"` before the non-active-prefix check.\n */\nfunction normalizeRelativePath(p: string): string {\n // Normalize separators, split into segments, then resolve.\n const parts = p.replace(/\\\\/g, \"/\").split(\"/\");\n const resolved: string[] = [];\n for (const seg of parts) {\n if (seg === \"\" || seg === \".\") continue;\n if (seg === \"..\") {\n if (resolved.length > 0) resolved.pop();\n // If \"..\" pops past the root, we let the caller's containment\n // check catch it — don't silently drop.\n } else {\n resolved.push(seg);\n }\n }\n return resolved.join(\"/\");\n}\n\n/**\n * Check that a relative path (relative to memoryDir) points to an\n * active memory location rather than an internal/archive directory.\n * Returns `true` when the normalised `pagePath` does NOT start with\n * a known non-active prefix.\n *\n * @param pagePath Relative path from `derived_from` entry.\n * @param sidecarDir Optional versioning sidecar directory name\n * (e.g. `\".versions\"`). When provided, paths\n * under this directory are also rejected as\n * non-active.\n */\nexport function isActiveMemoryRelativePath(\n pagePath: string,\n sidecarDir?: string,\n): boolean {\n const normalized = normalizeRelativePath(pagePath);\n const prefixes = [...NON_ACTIVE_PREFIXES];\n if (sidecarDir) {\n const normSidecar = normalizeRelativePath(sidecarDir);\n prefixes.push(normSidecar + \"/\");\n }\n for (const prefix of prefixes) {\n if (normalized === prefix.slice(0, -1) || normalized.startsWith(prefix)) {\n return false;\n }\n }\n return true;\n}\n\nasync function isRegularFile(p: string): Promise<boolean> {\n try {\n const st = await lstat(p);\n return st.isFile();\n } catch {\n return false;\n }\n}\n\nasync function fileExists(p: string): Promise<boolean> {\n try {\n await access(p, fsConstants.F_OK);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Perform a consolidation-undo operation.\n *\n * @param options.storage Storage manager for the memory directory.\n * @param options.memoryDir Absolute memory directory root.\n * @param options.targetPath Absolute path to the consolidated memory.\n * @param options.versioning Page-versioning config (sidecarDir must\n * match the sidecar layout used when the\n * snapshots were created).\n * @param options.dryRun When true, compute the plan but do not\n * write or archive.\n */\nexport async function runConsolidationUndo(options: {\n storage: StorageManager;\n memoryDir: string;\n targetPath: string;\n versioning: VersioningConfig;\n dryRun?: boolean;\n}): Promise<ConsolidationUndoResult> {\n const { storage, memoryDir, targetPath, versioning } = options;\n const dryRun = options.dryRun === true;\n\n const result: ConsolidationUndoResult = {\n targetPath,\n targetArchived: false,\n restores: [],\n dryRun,\n };\n\n // Defense against path-traversal (PR #637 review, codex P1): refuse\n // to operate on a target outside the configured memory directory.\n // Archive moves and eventual unlink would otherwise let an operator\n // accidentally destroy an unrelated file with memory-like\n // frontmatter. Uses the realpath-aware check so a symlinked\n // directory inside `memoryDir` can't tunnel a target past the guard.\n if (!(await isInsideDirectoryRealpath(targetPath, memoryDir))) {\n result.error = `target path ${targetPath} is outside memory directory ${memoryDir}`;\n return result;\n }\n\n // Reject targets in non-active directories (archive/, state/,\n // versioning sidecar). A target inside `.versions/...` would be\n // a sidecar snapshot, not a real consolidated memory; archiving\n // it would silently delete version history (PR #637 round-8\n // review, codex P2).\n const targetRel = path.relative(memoryDir, targetPath);\n if (!isActiveMemoryRelativePath(targetRel, versioning.sidecarDir)) {\n result.error = `target path \"${targetRel}\" is inside a non-active directory — refusing to operate`;\n return result;\n }\n\n // Load the target memory. readMemoryByPath returns null when the file\n // is absent or unparseable — surface that as a fatal error because the\n // caller cannot continue without a derived_from list.\n const target = await storage.readMemoryByPath(targetPath);\n if (!target) {\n result.error = `could not load target memory at ${targetPath}`;\n return result;\n }\n\n const derivedFrom = target.frontmatter.derived_from;\n if (!Array.isArray(derivedFrom) || derivedFrom.length === 0) {\n result.error = \"target memory has no derived_from entries — nothing to undo\";\n return result;\n }\n\n // Two-pass plan + execute (PR #637 round-4 review, cursor Medium):\n // the undo is \"all-or-nothing\" both for the archive decision AND\n // for the per-source writes. First pass validates + loads every\n // snapshot into memory; second pass writes only if every source\n // would succeed. This prevents the previous eager-write behaviour\n // where a later-failing source would leave earlier sources already\n // written to disk alongside an unarchived consolidated target.\n type RestorePlan =\n | { kind: \"skip\"; restore: ConsolidationUndoRestore }\n | { kind: \"write\"; entry: string; sourcePath: string; content: string }\n | { kind: \"recovered_existing\"; entry: string; sourcePath: string };\n\n const plans: RestorePlan[] = [];\n for (const rawEntry of derivedFrom) {\n const entry = typeof rawEntry === \"string\" ? rawEntry : String(rawEntry);\n const parsed = parseEntry(rawEntry);\n if (!parsed) {\n plans.push({\n kind: \"skip\",\n restore: {\n entry,\n sourcePath: \"\",\n outcome: \"skipped_malformed_entry\",\n detail: `expected \"<path>:<version>\" shape`,\n },\n });\n continue;\n }\n\n // Reject absolute paths in derived_from entries (PR #637 round-10\n // review, codex P1). An absolute pagePath would cause path.join to\n // ignore memoryDir, bypassing the active-directory guard downstream.\n if (path.isAbsolute(parsed.pagePath)) {\n plans.push({\n kind: \"skip\",\n restore: {\n entry,\n sourcePath: parsed.pagePath,\n outcome: \"skipped_malformed_entry\",\n detail: `derived_from path must be relative, got absolute: \"${parsed.pagePath}\"`,\n },\n });\n continue;\n }\n\n const sourcePath = path.join(memoryDir, parsed.pagePath);\n\n if (!(await isInsideDirectoryRealpath(sourcePath, memoryDir))) {\n plans.push({\n kind: \"skip\",\n restore: {\n entry,\n sourcePath,\n outcome: \"skipped_outside_memory_dir\",\n detail: `resolved path escapes memory directory ${memoryDir}`,\n },\n });\n continue;\n }\n\n // Reject source paths inside non-active directories (archive/,\n // state/, versioning sidecar). A crafted or corrupted derived_from\n // entry like \"archive/2024-01-01/x.md:1\" would otherwise be counted\n // as \"recovered_existing\" even though no active memory was restored.\n // Also resolve symlinks before checking — a derived_from entry like\n // \"facts/link/stale.md:1\" where `facts/link` points to `archive/…`\n // must be caught (PR #637 round-8 review, cursor+codex).\n let resolvedRelative = parsed.pagePath;\n try {\n const realBase = await realpath(memoryDir);\n try {\n const realSource = await realpath(sourcePath);\n const rel = path.relative(realBase, realSource);\n if (!rel.startsWith(\"..\") && !path.isAbsolute(rel)) {\n resolvedRelative = rel.replace(/\\\\/g, \"/\");\n }\n } catch {\n // realpath on the leaf failed (file doesn't exist yet). Try\n // resolving the parent directory instead — if the parent is a\n // symlink into archive/state, the leaf would be written there\n // too (PR #637 round-12 review, codex P1).\n const parentDir = path.dirname(sourcePath);\n try {\n const realParent = await realpath(parentDir);\n const parentRel = path.relative(realBase, realParent);\n if (!parentRel.startsWith(\"..\") && !path.isAbsolute(parentRel)) {\n const leafName = path.basename(sourcePath);\n resolvedRelative = path.join(parentRel, leafName).replace(/\\\\/g, \"/\");\n }\n } catch {\n // Parent also doesn't exist — fall through to text path check\n }\n }\n } catch {\n // memoryDir realpath failed — use the text path\n }\n if (!isActiveMemoryRelativePath(parsed.pagePath, versioning.sidecarDir) ||\n !isActiveMemoryRelativePath(resolvedRelative, versioning.sidecarDir)) {\n plans.push({\n kind: \"skip\",\n restore: {\n entry,\n sourcePath,\n outcome: \"skipped_non_active_path\",\n detail: `source path \"${parsed.pagePath}\" is inside a non-active directory (archive/state/versions)`,\n },\n });\n continue;\n }\n\n // Reject self-referential derived_from entries (PR #637 round-9 review,\n // codex P1). If the source resolves to the same file as the target,\n // counting it as \"recovered\" would let undo archive the target without\n // restoring any independent source — leaving no active copy. This\n // guards against corrupted or manually-edited derived_from lists.\n if (path.resolve(sourcePath) === path.resolve(targetPath)) {\n plans.push({\n kind: \"skip\",\n restore: {\n entry,\n sourcePath,\n outcome: \"skipped_self_referential\",\n detail: `derived_from entry \"${entry}\" resolves to the same file as the target — refusing to count as recovered`,\n },\n });\n continue;\n }\n\n if (await isRegularFile(sourcePath)) {\n // Source is still active (regular file present) — nothing to\n // restore but this counts as \"recovered\" for the archive\n // decision. We require a regular file specifically (PR #637\n // round-5 review, codex P2): a directory, device node, or\n // symlink at the source path should not count as \"recovered\"\n // because a later read won't find the expected memory content.\n plans.push({ kind: \"recovered_existing\", entry, sourcePath });\n continue;\n }\n if (await fileExists(sourcePath)) {\n // Something other than a regular file is at the source path\n // (directory, device node, symlink). Refuse to overwrite AND\n // refuse to count as recovered (PR #637 round-5 review, codex\n // P2) — the operator needs to clean up manually. This is a\n // blocking skip: no source writes happen, target stays active.\n plans.push({\n kind: \"skip\",\n restore: {\n entry,\n sourcePath,\n outcome: \"skipped_non_regular_file\",\n detail: \"source path is occupied by a non-regular-file; refusing to proceed\",\n },\n });\n continue;\n }\n\n let snapshotContent: string;\n try {\n snapshotContent = await getVersion(\n sourcePath,\n parsed.versionId,\n versioning,\n memoryDir,\n );\n } catch {\n plans.push({\n kind: \"skip\",\n restore: {\n entry,\n sourcePath,\n outcome: \"skipped_snapshot_missing\",\n detail: `no snapshot for version ${parsed.versionId}`,\n },\n });\n continue;\n }\n\n plans.push({ kind: \"write\", entry, sourcePath, content: snapshotContent });\n }\n\n // If any plan is a skip (anything other than \"write\" or\n // \"recovered_existing\"), the undo is over before it starts — no\n // writes happen. Reveal every per-source skip reason in the\n // result so operators can diagnose what went wrong.\n const skipped = plans.filter((p) => p.kind === \"skip\");\n if (skipped.length > 0) {\n for (const p of plans) {\n if (p.kind === \"skip\") {\n result.restores.push(p.restore);\n } else if (p.kind === \"write\") {\n // Announced-but-not-executed write — still record it so the\n // operator sees what would have been restored if the failed\n // sources had been recoverable.\n result.restores.push({\n entry: p.entry,\n sourcePath: p.sourcePath,\n outcome: dryRun ? \"skipped_dry_run\" : \"skipped_blocked_by_other_failures\",\n detail: dryRun\n ? \"would restore from snapshot (blocked by other failures)\"\n : \"snapshot available but undo aborted due to other failures\",\n });\n } else {\n result.restores.push({\n entry: p.entry,\n sourcePath: p.sourcePath,\n outcome: \"skipped_file_exists\",\n detail: \"source file already exists; no restore needed\",\n });\n }\n }\n const recovered = result.restores.filter(\n (r) => r.outcome === \"restored\" || r.outcome === \"skipped_file_exists\",\n ).length;\n if (recovered === 0) {\n result.error =\n \"no sources could be recovered (all snapshots missing or paths unsafe); target not archived to preserve data\";\n } else {\n result.error = `${skipped.length} of ${plans.length} sources could not be recovered; target not archived (undo is all-or-nothing)`;\n }\n return result;\n }\n\n // Deduplicate plans by sourcePath: duplicate derived_from entries for\n // the same source would cause the second wx-flagged write to fail with\n // EEXIST after the first succeeds. The first plan for each source wins;\n // subsequent duplicates are recorded as skipped. Applied before dry-run\n // so the preview accurately reflects what execution would do.\n const seenSourcePaths = new Set<string>();\n const dedupedPlans: RestorePlan[] = [];\n for (const p of plans) {\n if (p.kind === \"write\" || p.kind === \"recovered_existing\") {\n if (seenSourcePaths.has(p.sourcePath)) {\n dedupedPlans.push({\n kind: \"skip\",\n restore: {\n entry: p.kind === \"write\" ? p.entry : p.entry,\n sourcePath: p.sourcePath,\n outcome: \"skipped_file_exists\",\n detail: \"duplicate derived_from entry — source already processed\",\n },\n });\n continue;\n }\n seenSourcePaths.add(p.sourcePath);\n }\n dedupedPlans.push(p);\n }\n\n // Dry-run: report what each plan would do.\n if (dryRun) {\n for (const p of dedupedPlans) {\n if (p.kind === \"write\") {\n result.restores.push({\n entry: p.entry,\n sourcePath: p.sourcePath,\n outcome: \"skipped_dry_run\",\n detail: \"would restore from snapshot\",\n });\n } else if (p.kind === \"recovered_existing\") {\n result.restores.push({\n entry: p.entry,\n sourcePath: p.sourcePath,\n outcome: \"skipped_file_exists\",\n detail: \"source file already exists; no restore needed\",\n });\n } else if (p.kind === \"skip\" && p.restore) {\n result.restores.push(p.restore);\n }\n }\n return result;\n }\n\n // All validations passed — execute writes. A write failure here\n // is a filesystem problem rather than a provenance problem, but\n // any failure still aborts the archive.\n\n let writeFailed = false;\n for (const p of dedupedPlans) {\n if (p.kind === \"skip\") {\n // Dedup-generated skip entries and other pre-write skips.\n if (p.restore) result.restores.push(p.restore);\n continue;\n }\n if (p.kind === \"recovered_existing\") {\n result.restores.push({\n entry: p.entry,\n sourcePath: p.sourcePath,\n outcome: \"skipped_file_exists\",\n detail: \"source file already exists; no restore needed\",\n });\n continue;\n }\n if (p.kind === \"write\") {\n if (writeFailed) {\n // All-or-nothing: once a write fails, skip all remaining writes\n // so the target is not archived with partial source coverage.\n result.restores.push({\n entry: p.entry,\n sourcePath: p.sourcePath,\n outcome: \"skipped_blocked_by_other_failures\",\n detail: \"a prior source write failed; skipping remaining writes to honor all-or-nothing contract\",\n });\n continue;\n }\n try {\n await mkdir(path.dirname(p.sourcePath), { recursive: true });\n // Use exclusive create (wx / O_EXCL) so that if another process\n // recreates the source file between planning and execution, this\n // write fails with EEXIST instead of silently overwriting the new\n // file (PR #637 round-11 review, codex P1).\n await writeFile(p.sourcePath, p.content, { encoding: \"utf-8\", flag: \"wx\" });\n // Restore writes an active memory file back out-of-band (direct wx write,\n // not a StorageManager mutation). Bump the corpus sentinel per successful\n // restore so a warm hot-memories cache rescans — a later restore failure\n // returns before archiveMemory() runs, so without this the already-written\n // restores would stay invisible to recall until an unrelated mutation or\n // restart (esp. with hotMemoriesCacheTtlMs: 0). Issue #1902, Codex Medium.\n bumpMemoryCorpusVersionForDir(memoryDir);\n // Restored bytes predate the current migration journal and can carry\n // legacy entity references (issue #2213) — request one reconcile pass.\n await requestEntityCanonicalIdReconcile(path.join(memoryDir, \"state\"));\n result.restores.push({\n entry: p.entry,\n sourcePath: p.sourcePath,\n outcome: \"restored\",\n });\n } catch (err) {\n writeFailed = true;\n result.restores.push({\n entry: p.entry,\n sourcePath: p.sourcePath,\n outcome: \"skipped_write_failed\",\n detail: `write failed: ${err instanceof Error ? err.message : String(err)}`,\n });\n }\n }\n }\n\n if (writeFailed) {\n result.error =\n \"one or more source writes failed mid-restore; target not archived to preserve data\";\n return result;\n }\n\n // Archive the target memory. archiveMemory returns null on\n // failure — surface that as a fatal error (PR #637 round-5 review,\n // codex P2) so automation doesn't mistake a half-undo for a clean\n // run. The already-completed restores still roll forward; the\n // result.restores list records what was written.\n const archivedAt = await storage.archiveMemory(target, {\n actor: \"consolidate-undo\",\n reasonCode: \"consolidation-undo\",\n });\n result.targetArchived = archivedAt !== null;\n if (!result.targetArchived) {\n result.error =\n \"sources restored successfully but archiving the consolidated target failed; inspect storage for manual cleanup\";\n }\n return result;\n}\n\n/**\n * Render a consolidation-undo result as a human-readable multi-line\n * string for the CLI. Extracted so tests can snapshot the formatting\n * without parsing stdout.\n */\nexport function formatConsolidationUndoResult(result: ConsolidationUndoResult): string {\n const lines: string[] = [];\n lines.push(`consolidate undo ${result.dryRun ? \"(dry run) \" : \"\"}→ ${result.targetPath}`);\n // Emit per-restore details BEFORE the error (PR #637 review, cursor\n // Medium): the \"no sources could be recovered\" error is set after\n // the restore loop ran, so operators need the per-source skip\n // reasons to diagnose which snapshots were missing / outside\n // memoryDir / malformed. Early-bail errors (unloadable target,\n // target outside memoryDir, no derived_from) run before the loop,\n // so `result.restores` is empty in those cases and this block is a\n // no-op.\n for (const r of result.restores) {\n lines.push(` - ${r.entry} → ${r.outcome}${r.detail ? ` (${r.detail})` : \"\"}`);\n }\n if (result.error) {\n lines.push(` ERROR: ${result.error}`);\n return lines.join(\"\\n\");\n }\n lines.push(\n result.dryRun\n ? \" (dry run — no files were modified, target not archived)\"\n : ` target archived: ${result.targetArchived ? \"yes\" : \"no\"}`,\n );\n return lines.join(\"\\n\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAsBA,OAAO,UAAU;AACjB,SAAS,OAAO,WAAW,QAAQ,UAAU,aAAa;AAC1D,SAAS,aAAa,mBAAmB;AAgDzC,IAAM,wBAAwB;AAE9B,SAAS,WAAW,OAAgE;AAGlF,MAAI,OAAO,UAAU,SAAU,QAAO;AACtC,QAAM,QAAQ,MAAM,MAAM,qBAAqB;AAC/C,MAAI,CAAC,MAAO,QAAO;AACnB,SAAO,EAAE,UAAU,MAAM,CAAC,GAAG,WAAW,MAAM,CAAC,EAAE;AACnD;AAUO,SAAS,kBAAkB,WAAmB,MAAuB;AAC1E,QAAM,WAAW,KAAK,QAAQ,IAAI;AAClC,QAAM,gBAAgB,KAAK,QAAQ,SAAS;AAC5C,QAAM,MAAM,KAAK,SAAS,UAAU,aAAa;AACjD,MAAI,IAAI,WAAW,EAAG,QAAO;AAC7B,MAAI,IAAI,WAAW,IAAI,EAAG,QAAO;AACjC,MAAI,KAAK,WAAW,GAAG,EAAG,QAAO;AACjC,SAAO;AACT;AAkBA,eAAsB,0BACpB,WACA,MACkB;AAClB,MAAI,CAAC,kBAAkB,WAAW,IAAI,EAAG,QAAO;AAIhD,QAAM,cAAc,UAAU,QAAQ,OAAO,GAAG,EAAE,MAAM,GAAG;AAC3D,MAAI,YAAY,KAAK,CAAC,MAAM,MAAM,IAAI,EAAG,QAAO;AAChD,MAAI;AACJ,MAAI;AACF,mBAAe,MAAM,SAAS,KAAK,QAAQ,IAAI,CAAC;AAAA,EAClD,QAAQ;AACN,WAAO;AAAA,EACT;AACA,QAAM,gBAAgB,KAAK,QAAQ,SAAS;AAS5C,QAAM,WAAW,KAAK,QAAQ,IAAI;AAClC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SAAO,iBAAiB,eAAe;AACvC,MAAI,CAAC,OAAO,gBAAgB;AAC1B,WAAO,QACL;AAAA,EACJ;AACA,SAAO;AACT;AAOO,SAAS,8BAA8B,QAAyC;AACrF,QAAM,QAAkB,CAAC;AACzB,QAAM,KAAK,oBAAoB,OAAO,SAAS,eAAe,EAAE,UAAK,OAAO,UAAU,EAAE;AASxF,aAAW,KAAK,OAAO,UAAU;AAC/B,UAAM,KAAK,OAAO,EAAE,KAAK,WAAM,EAAE,OAAO,GAAG,EAAE,SAAS,KAAK,EAAE,MAAM,MAAM,EAAE,EAAE;AAAA,EAC/E;AACA,MAAI,OAAO,OAAO;AAChB,UAAM,KAAK,YAAY,OAAO,KAAK,EAAE;AACrC,WAAO,MAAM,KAAK,IAAI;AAAA,EACxB;AACA,QAAM;AAAA,IACJ,OAAO,SACH,mEACA,sBAAsB,OAAO,iBAAiB,QAAQ,IAAI;AAAA,EAChE;AACA,SAAO,MAAM,KAAK,IAAI;AACxB;","names":[]}
1
+ {"version":3,"sources":["../src/consolidation-undo.ts"],"sourcesContent":["/**\n * Consolidation undo (issue #561 PR 5).\n *\n * Reverts a consolidated memory by restoring each source memory from its\n * `derived_from` snapshot and archiving the target.\n *\n * Contract:\n * - Load the target memory markdown file via its absolute path.\n * - For every `\"<rel>:<version>\"` entry in `derived_from`, fetch the\n * snapshot content via `page-versioning.getVersion` and restore it\n * to the original relative path. If the restore target file\n * already exists, we skip overwriting it (the source was never\n * archived, or was re-created since) and record the skip.\n * - Archive the target with reason code `\"consolidation-undo\"` so the\n * lifecycle ledger records the undo.\n * - Dry-run mode produces the same plan without touching disk.\n *\n * The helper is kept pure over `StorageManager` so the CLI can reuse it\n * without additional wiring, and tests can exercise the plan logic\n * directly.\n */\n\nimport path from \"node:path\";\nimport { mkdir, writeFile, access, realpath, lstat } from \"node:fs/promises\";\nimport { constants as fsConstants } from \"node:fs\";\nimport type { StorageManager } from \"./storage.js\";\nimport type { VersioningConfig } from \"./page-versioning.js\";\nimport { bumpMemoryCorpusVersionForDir } from \"./memory-corpus-version.js\";\nimport { requestEntityCanonicalIdReconcile } from \"./storage/entity-canonical-id-references.js\";\nimport { withRawEntityPageMutation } from \"./storage/entity-canonical-id-lock.js\";\nimport { getVersion } from \"./page-versioning.js\";\n\n/**\n * Outcome of restoring a single `derived_from` source.\n */\nexport interface ConsolidationUndoRestore {\n /** The raw `\"<relpath>:<version>\"` entry from `derived_from`. */\n entry: string;\n /** Absolute path where the source would be / was restored. */\n sourcePath: string;\n /** What actually happened. */\n outcome:\n | \"restored\"\n | \"skipped_file_exists\"\n | \"skipped_non_regular_file\"\n | \"skipped_snapshot_missing\"\n | \"skipped_malformed_entry\"\n | \"skipped_outside_memory_dir\"\n | \"skipped_non_active_path\"\n | \"skipped_self_referential\"\n | \"skipped_write_failed\"\n | \"skipped_blocked_by_other_failures\"\n | \"skipped_dry_run\";\n /** Human-readable detail. */\n detail?: string;\n}\n\n/**\n * Plan + result of a `remnic consolidate undo` invocation.\n */\nexport interface ConsolidationUndoResult {\n /** Absolute path to the target memory. */\n targetPath: string;\n /** True when the target was archived successfully. */\n targetArchived: boolean;\n /** Per-source restore outcomes. */\n restores: ConsolidationUndoRestore[];\n /** Whether the run was a dry-run plan only. */\n dryRun: boolean;\n /** Fatal error, if any — the run bails early. */\n error?: string;\n}\n\nconst DERIVED_FROM_ENTRY_RE = /^(.+):(\\d+)$/;\n\nfunction parseEntry(entry: unknown): { pagePath: string; versionId: string } | null {\n // Non-string entries (PR #637 round-3 review, cursor Low) can arrive\n // from hostile on-disk frontmatter — guard against a .match() crash.\n if (typeof entry !== \"string\") return null;\n const match = entry.match(DERIVED_FROM_ENTRY_RE);\n if (!match) return null;\n return { pagePath: match[1], versionId: match[2] };\n}\n\n/**\n * Verify that `candidate` resolves inside `root` (defense against\n * path-traversal in `derived_from` entries and user-facing target\n * paths). Path-string normalization only; for symlink-aware checks\n * use `isInsideDirectoryRealpath`. Both paths are resolved to\n * absolute form before comparison so `..` segments, symlinks-as-\n * strings, and relative prefixes are normalized.\n */\nexport function isInsideDirectory(candidate: string, root: string): boolean {\n const normRoot = path.resolve(root);\n const normCandidate = path.resolve(candidate);\n const rel = path.relative(normRoot, normCandidate);\n if (rel.length === 0) return true;\n if (rel.startsWith(\"..\")) return false;\n if (path.isAbsolute(rel)) return false;\n return true;\n}\n\n/**\n * Symlink-aware containment check (PR #637 round-2 review, codex P1).\n *\n * `isInsideDirectory` only normalizes path strings — if a `derived_from`\n * entry resolves through a symlink inside `memoryDir` that points\n * outside, the string check passes but the subsequent `writeFile` would\n * land outside the memory tree. Use this guard for any path that is\n * about to be written.\n *\n * Walks every parent directory between `candidate` and `root`,\n * `realpath`-ing each segment that exists and rejecting when any\n * segment escapes `root`. Non-existent parents are resolved as the\n * canonicalized deepest-existing ancestor plus the trailing segments,\n * so a not-yet-created target file still gets the symlink check on its\n * existing parent directories.\n */\nexport async function isInsideDirectoryRealpath(\n candidate: string,\n root: string,\n): Promise<boolean> {\n if (!isInsideDirectory(candidate, root)) return false;\n // Reject raw `..` segments before canonicalization so that symlinks\n // cannot be hidden behind intermediate dot-dot components (PR #637\n // round-14 review, codex P1).\n const rawSegments = candidate.replace(/\\\\/g, \"/\").split(\"/\");\n if (rawSegments.some((s) => s === \"..\")) return false;\n let resolvedRoot: string;\n try {\n resolvedRoot = await realpath(path.resolve(root));\n } catch {\n return false;\n }\n const normCandidate = path.resolve(candidate);\n\n // Reject dangling symlinks (PR #637 round-3 review, codex P1).\n // If the candidate itself is a symlink (even if its target doesn't\n // exist), Node will follow it when we later call `writeFile`.\n // `lstat` inspects the link itself without dereferencing; if it\n // succeeds and reports a symlink, we treat the candidate as\n // unsafe. We must check every non-root ancestor too — a symlink\n // anywhere along the path lets an attacker redirect writes.\n const normRoot = path.resolve(root);\n const relFromRoot = path.relative(normRoot, normCandidate);\n const segments = relFromRoot.length > 0 ? relFromRoot.split(path.sep) : [];\n for (let i = 0; i <= segments.length; i++) {\n const probe = i === 0 ? normRoot : path.join(normRoot, ...segments.slice(0, i));\n try {\n const st = await lstat(probe);\n if (st.isSymbolicLink() && probe !== normRoot) {\n // A symlink on the path — resolve THIS segment and bail out\n // if the resolved target escapes `resolvedRoot`.\n let target: string;\n try {\n target = await realpath(probe);\n } catch {\n // Dangling symlink inside memoryDir — always unsafe.\n return false;\n }\n const rel = path.relative(resolvedRoot, target);\n if (rel.length === 0) continue;\n if (rel.startsWith(\"..\") || path.isAbsolute(rel)) return false;\n }\n } catch {\n // Segment doesn't exist yet — that's fine, fall through to the\n // textual containment verification below.\n }\n }\n\n // Walk up from the candidate until we hit a path that exists, then\n // realpath THAT and re-apply the trailing segments textually.\n const parts = normCandidate.split(path.sep);\n for (let i = parts.length; i > 0; i--) {\n const probe = parts.slice(0, i).join(path.sep) || path.sep;\n try {\n const resolved = await realpath(probe);\n // Re-join any trailing segments that didn't exist yet.\n const trailing = parts.slice(i).join(path.sep);\n const final = trailing.length > 0 ? path.join(resolved, trailing) : resolved;\n // Now apply the textual containment check against the canonical\n // `resolvedRoot`.\n const rel = path.relative(resolvedRoot, final);\n if (rel.length === 0) return true;\n if (rel.startsWith(\"..\")) return false;\n if (path.isAbsolute(rel)) return false;\n return true;\n } catch {\n continue;\n }\n }\n // Nothing along the path resolvable — treat as outside by default.\n return false;\n}\n\n/**\n * Directories under memoryDir that are NOT active memory locations.\n * A `derived_from` entry pointing into one of these should not be\n * counted as \"recovered_existing\" (PR #637 round-7 review, codex P2).\n * The versioning sidecar directory is included dynamically via the\n * `sidecarDir` parameter (PR #637 round-8 review, codex P2).\n */\nconst NON_ACTIVE_PREFIXES = [\"archive/\", \"state/\"];\n\n/**\n * Normalize a relative path by collapsing `.` and `..` segments so\n * that crafted entries like `\"facts/../archive/x.md\"` are reduced to\n * `\"archive/x.md\"` before the non-active-prefix check.\n */\nfunction normalizeRelativePath(p: string): string {\n // Normalize separators, split into segments, then resolve.\n const parts = p.replace(/\\\\/g, \"/\").split(\"/\");\n const resolved: string[] = [];\n for (const seg of parts) {\n if (seg === \"\" || seg === \".\") continue;\n if (seg === \"..\") {\n if (resolved.length > 0) resolved.pop();\n // If \"..\" pops past the root, we let the caller's containment\n // check catch it — don't silently drop.\n } else {\n resolved.push(seg);\n }\n }\n return resolved.join(\"/\");\n}\n\n/**\n * Check that a relative path (relative to memoryDir) points to an\n * active memory location rather than an internal/archive directory.\n * Returns `true` when the normalised `pagePath` does NOT start with\n * a known non-active prefix.\n *\n * @param pagePath Relative path from `derived_from` entry.\n * @param sidecarDir Optional versioning sidecar directory name\n * (e.g. `\".versions\"`). When provided, paths\n * under this directory are also rejected as\n * non-active.\n */\nexport function isActiveMemoryRelativePath(\n pagePath: string,\n sidecarDir?: string,\n): boolean {\n const normalized = normalizeRelativePath(pagePath);\n const prefixes = [...NON_ACTIVE_PREFIXES];\n if (sidecarDir) {\n const normSidecar = normalizeRelativePath(sidecarDir);\n prefixes.push(normSidecar + \"/\");\n }\n for (const prefix of prefixes) {\n if (normalized === prefix.slice(0, -1) || normalized.startsWith(prefix)) {\n return false;\n }\n }\n return true;\n}\n\nasync function isRegularFile(p: string): Promise<boolean> {\n try {\n const st = await lstat(p);\n return st.isFile();\n } catch {\n return false;\n }\n}\n\nasync function fileExists(p: string): Promise<boolean> {\n try {\n await access(p, fsConstants.F_OK);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Perform a consolidation-undo operation.\n *\n * @param options.storage Storage manager for the memory directory.\n * @param options.memoryDir Absolute memory directory root.\n * @param options.targetPath Absolute path to the consolidated memory.\n * @param options.versioning Page-versioning config (sidecarDir must\n * match the sidecar layout used when the\n * snapshots were created).\n * @param options.dryRun When true, compute the plan but do not\n * write or archive.\n */\nexport async function runConsolidationUndo(options: {\n storage: StorageManager;\n memoryDir: string;\n targetPath: string;\n versioning: VersioningConfig;\n dryRun?: boolean;\n}): Promise<ConsolidationUndoResult> {\n const { storage, memoryDir, targetPath, versioning } = options;\n const dryRun = options.dryRun === true;\n\n const result: ConsolidationUndoResult = {\n targetPath,\n targetArchived: false,\n restores: [],\n dryRun,\n };\n\n // Defense against path-traversal (PR #637 review, codex P1): refuse\n // to operate on a target outside the configured memory directory.\n // Archive moves and eventual unlink would otherwise let an operator\n // accidentally destroy an unrelated file with memory-like\n // frontmatter. Uses the realpath-aware check so a symlinked\n // directory inside `memoryDir` can't tunnel a target past the guard.\n if (!(await isInsideDirectoryRealpath(targetPath, memoryDir))) {\n result.error = `target path ${targetPath} is outside memory directory ${memoryDir}`;\n return result;\n }\n\n // Reject targets in non-active directories (archive/, state/,\n // versioning sidecar). A target inside `.versions/...` would be\n // a sidecar snapshot, not a real consolidated memory; archiving\n // it would silently delete version history (PR #637 round-8\n // review, codex P2).\n const targetRel = path.relative(memoryDir, targetPath);\n if (!isActiveMemoryRelativePath(targetRel, versioning.sidecarDir)) {\n result.error = `target path \"${targetRel}\" is inside a non-active directory — refusing to operate`;\n return result;\n }\n\n // Load the target memory. readMemoryByPath returns null when the file\n // is absent or unparseable — surface that as a fatal error because the\n // caller cannot continue without a derived_from list.\n const target = await storage.readMemoryByPath(targetPath);\n if (!target) {\n result.error = `could not load target memory at ${targetPath}`;\n return result;\n }\n\n const derivedFrom = target.frontmatter.derived_from;\n if (!Array.isArray(derivedFrom) || derivedFrom.length === 0) {\n result.error = \"target memory has no derived_from entries — nothing to undo\";\n return result;\n }\n\n // Two-pass plan + execute (PR #637 round-4 review, cursor Medium):\n // the undo is \"all-or-nothing\" both for the archive decision AND\n // for the per-source writes. First pass validates + loads every\n // snapshot into memory; second pass writes only if every source\n // would succeed. This prevents the previous eager-write behaviour\n // where a later-failing source would leave earlier sources already\n // written to disk alongside an unarchived consolidated target.\n type RestorePlan =\n | { kind: \"skip\"; restore: ConsolidationUndoRestore }\n | { kind: \"write\"; entry: string; sourcePath: string; content: string }\n | { kind: \"recovered_existing\"; entry: string; sourcePath: string };\n\n const plans: RestorePlan[] = [];\n for (const rawEntry of derivedFrom) {\n const entry = typeof rawEntry === \"string\" ? rawEntry : String(rawEntry);\n const parsed = parseEntry(rawEntry);\n if (!parsed) {\n plans.push({\n kind: \"skip\",\n restore: {\n entry,\n sourcePath: \"\",\n outcome: \"skipped_malformed_entry\",\n detail: `expected \"<path>:<version>\" shape`,\n },\n });\n continue;\n }\n\n // Reject absolute paths in derived_from entries (PR #637 round-10\n // review, codex P1). An absolute pagePath would cause path.join to\n // ignore memoryDir, bypassing the active-directory guard downstream.\n if (path.isAbsolute(parsed.pagePath)) {\n plans.push({\n kind: \"skip\",\n restore: {\n entry,\n sourcePath: parsed.pagePath,\n outcome: \"skipped_malformed_entry\",\n detail: `derived_from path must be relative, got absolute: \"${parsed.pagePath}\"`,\n },\n });\n continue;\n }\n\n const sourcePath = path.join(memoryDir, parsed.pagePath);\n\n if (!(await isInsideDirectoryRealpath(sourcePath, memoryDir))) {\n plans.push({\n kind: \"skip\",\n restore: {\n entry,\n sourcePath,\n outcome: \"skipped_outside_memory_dir\",\n detail: `resolved path escapes memory directory ${memoryDir}`,\n },\n });\n continue;\n }\n\n // Reject source paths inside non-active directories (archive/,\n // state/, versioning sidecar). A crafted or corrupted derived_from\n // entry like \"archive/2024-01-01/x.md:1\" would otherwise be counted\n // as \"recovered_existing\" even though no active memory was restored.\n // Also resolve symlinks before checking — a derived_from entry like\n // \"facts/link/stale.md:1\" where `facts/link` points to `archive/…`\n // must be caught (PR #637 round-8 review, cursor+codex).\n let resolvedRelative = parsed.pagePath;\n try {\n const realBase = await realpath(memoryDir);\n try {\n const realSource = await realpath(sourcePath);\n const rel = path.relative(realBase, realSource);\n if (!rel.startsWith(\"..\") && !path.isAbsolute(rel)) {\n resolvedRelative = rel.replace(/\\\\/g, \"/\");\n }\n } catch {\n // realpath on the leaf failed (file doesn't exist yet). Try\n // resolving the parent directory instead — if the parent is a\n // symlink into archive/state, the leaf would be written there\n // too (PR #637 round-12 review, codex P1).\n const parentDir = path.dirname(sourcePath);\n try {\n const realParent = await realpath(parentDir);\n const parentRel = path.relative(realBase, realParent);\n if (!parentRel.startsWith(\"..\") && !path.isAbsolute(parentRel)) {\n const leafName = path.basename(sourcePath);\n resolvedRelative = path.join(parentRel, leafName).replace(/\\\\/g, \"/\");\n }\n } catch {\n // Parent also doesn't exist — fall through to text path check\n }\n }\n } catch {\n // memoryDir realpath failed — use the text path\n }\n if (!isActiveMemoryRelativePath(parsed.pagePath, versioning.sidecarDir) ||\n !isActiveMemoryRelativePath(resolvedRelative, versioning.sidecarDir)) {\n plans.push({\n kind: \"skip\",\n restore: {\n entry,\n sourcePath,\n outcome: \"skipped_non_active_path\",\n detail: `source path \"${parsed.pagePath}\" is inside a non-active directory (archive/state/versions)`,\n },\n });\n continue;\n }\n\n // Reject self-referential derived_from entries (PR #637 round-9 review,\n // codex P1). If the source resolves to the same file as the target,\n // counting it as \"recovered\" would let undo archive the target without\n // restoring any independent source — leaving no active copy. This\n // guards against corrupted or manually-edited derived_from lists.\n if (path.resolve(sourcePath) === path.resolve(targetPath)) {\n plans.push({\n kind: \"skip\",\n restore: {\n entry,\n sourcePath,\n outcome: \"skipped_self_referential\",\n detail: `derived_from entry \"${entry}\" resolves to the same file as the target — refusing to count as recovered`,\n },\n });\n continue;\n }\n\n if (await isRegularFile(sourcePath)) {\n // Source is still active (regular file present) — nothing to\n // restore but this counts as \"recovered\" for the archive\n // decision. We require a regular file specifically (PR #637\n // round-5 review, codex P2): a directory, device node, or\n // symlink at the source path should not count as \"recovered\"\n // because a later read won't find the expected memory content.\n plans.push({ kind: \"recovered_existing\", entry, sourcePath });\n continue;\n }\n if (await fileExists(sourcePath)) {\n // Something other than a regular file is at the source path\n // (directory, device node, symlink). Refuse to overwrite AND\n // refuse to count as recovered (PR #637 round-5 review, codex\n // P2) — the operator needs to clean up manually. This is a\n // blocking skip: no source writes happen, target stays active.\n plans.push({\n kind: \"skip\",\n restore: {\n entry,\n sourcePath,\n outcome: \"skipped_non_regular_file\",\n detail: \"source path is occupied by a non-regular-file; refusing to proceed\",\n },\n });\n continue;\n }\n\n let snapshotContent: string;\n try {\n snapshotContent = await getVersion(\n sourcePath,\n parsed.versionId,\n versioning,\n memoryDir,\n );\n } catch {\n plans.push({\n kind: \"skip\",\n restore: {\n entry,\n sourcePath,\n outcome: \"skipped_snapshot_missing\",\n detail: `no snapshot for version ${parsed.versionId}`,\n },\n });\n continue;\n }\n\n plans.push({ kind: \"write\", entry, sourcePath, content: snapshotContent });\n }\n\n // If any plan is a skip (anything other than \"write\" or\n // \"recovered_existing\"), the undo is over before it starts — no\n // writes happen. Reveal every per-source skip reason in the\n // result so operators can diagnose what went wrong.\n const skipped = plans.filter((p) => p.kind === \"skip\");\n if (skipped.length > 0) {\n for (const p of plans) {\n if (p.kind === \"skip\") {\n result.restores.push(p.restore);\n } else if (p.kind === \"write\") {\n // Announced-but-not-executed write — still record it so the\n // operator sees what would have been restored if the failed\n // sources had been recoverable.\n result.restores.push({\n entry: p.entry,\n sourcePath: p.sourcePath,\n outcome: dryRun ? \"skipped_dry_run\" : \"skipped_blocked_by_other_failures\",\n detail: dryRun\n ? \"would restore from snapshot (blocked by other failures)\"\n : \"snapshot available but undo aborted due to other failures\",\n });\n } else {\n result.restores.push({\n entry: p.entry,\n sourcePath: p.sourcePath,\n outcome: \"skipped_file_exists\",\n detail: \"source file already exists; no restore needed\",\n });\n }\n }\n const recovered = result.restores.filter(\n (r) => r.outcome === \"restored\" || r.outcome === \"skipped_file_exists\",\n ).length;\n if (recovered === 0) {\n result.error =\n \"no sources could be recovered (all snapshots missing or paths unsafe); target not archived to preserve data\";\n } else {\n result.error = `${skipped.length} of ${plans.length} sources could not be recovered; target not archived (undo is all-or-nothing)`;\n }\n return result;\n }\n\n // Deduplicate plans by sourcePath: duplicate derived_from entries for\n // the same source would cause the second wx-flagged write to fail with\n // EEXIST after the first succeeds. The first plan for each source wins;\n // subsequent duplicates are recorded as skipped. Applied before dry-run\n // so the preview accurately reflects what execution would do.\n const seenSourcePaths = new Set<string>();\n const dedupedPlans: RestorePlan[] = [];\n for (const p of plans) {\n if (p.kind === \"write\" || p.kind === \"recovered_existing\") {\n if (seenSourcePaths.has(p.sourcePath)) {\n dedupedPlans.push({\n kind: \"skip\",\n restore: {\n entry: p.kind === \"write\" ? p.entry : p.entry,\n sourcePath: p.sourcePath,\n outcome: \"skipped_file_exists\",\n detail: \"duplicate derived_from entry — source already processed\",\n },\n });\n continue;\n }\n seenSourcePaths.add(p.sourcePath);\n }\n dedupedPlans.push(p);\n }\n\n // Dry-run: report what each plan would do.\n if (dryRun) {\n for (const p of dedupedPlans) {\n if (p.kind === \"write\") {\n result.restores.push({\n entry: p.entry,\n sourcePath: p.sourcePath,\n outcome: \"skipped_dry_run\",\n detail: \"would restore from snapshot\",\n });\n } else if (p.kind === \"recovered_existing\") {\n result.restores.push({\n entry: p.entry,\n sourcePath: p.sourcePath,\n outcome: \"skipped_file_exists\",\n detail: \"source file already exists; no restore needed\",\n });\n } else if (p.kind === \"skip\" && p.restore) {\n result.restores.push(p.restore);\n }\n }\n return result;\n }\n\n // All validations passed — execute writes. A write failure here\n // is a filesystem problem rather than a provenance problem, but\n // any failure still aborts the archive.\n\n let writeFailed = false;\n for (const p of dedupedPlans) {\n if (p.kind === \"skip\") {\n // Dedup-generated skip entries and other pre-write skips.\n if (p.restore) result.restores.push(p.restore);\n continue;\n }\n if (p.kind === \"recovered_existing\") {\n result.restores.push({\n entry: p.entry,\n sourcePath: p.sourcePath,\n outcome: \"skipped_file_exists\",\n detail: \"source file already exists; no restore needed\",\n });\n continue;\n }\n if (p.kind === \"write\") {\n if (writeFailed) {\n // All-or-nothing: once a write fails, skip all remaining writes\n // so the target is not archived with partial source coverage.\n result.restores.push({\n entry: p.entry,\n sourcePath: p.sourcePath,\n outcome: \"skipped_blocked_by_other_failures\",\n detail: \"a prior source write failed; skipping remaining writes to honor all-or-nothing contract\",\n });\n continue;\n }\n try {\n await mkdir(path.dirname(p.sourcePath), { recursive: true });\n await withRawEntityPageMutation(memoryDir, p.sourcePath, async () => {\n // Use exclusive create (wx / O_EXCL) so that if another process\n // recreates the source file between planning and execution, this\n // write fails with EEXIST instead of silently overwriting the new\n // file (PR #637 round-11 review, codex P1).\n await writeFile(p.sourcePath, p.content, { encoding: \"utf-8\", flag: \"wx\" });\n // Restore writes an active memory file back out-of-band (direct wx write,\n // not a StorageManager mutation). Bump the corpus sentinel per successful\n // restore so a warm hot-memories cache rescans — a later restore failure\n // returns before archiveMemory() runs, so without this the already-written\n // restores would stay invisible to recall until an unrelated mutation or\n // restart (esp. with hotMemoriesCacheTtlMs: 0). Issue #1902, Codex Medium.\n bumpMemoryCorpusVersionForDir(memoryDir);\n // Restored bytes predate the current migration journal and can carry\n // legacy entity references (issue #2213) — request one reconcile pass.\n await requestEntityCanonicalIdReconcile(path.join(memoryDir, \"state\"));\n });\n result.restores.push({\n entry: p.entry,\n sourcePath: p.sourcePath,\n outcome: \"restored\",\n });\n } catch (err) {\n writeFailed = true;\n result.restores.push({\n entry: p.entry,\n sourcePath: p.sourcePath,\n outcome: \"skipped_write_failed\",\n detail: `write failed: ${err instanceof Error ? err.message : String(err)}`,\n });\n }\n }\n }\n\n if (writeFailed) {\n result.error =\n \"one or more source writes failed mid-restore; target not archived to preserve data\";\n return result;\n }\n\n // Archive the target memory. archiveMemory returns null on\n // failure — surface that as a fatal error (PR #637 round-5 review,\n // codex P2) so automation doesn't mistake a half-undo for a clean\n // run. The already-completed restores still roll forward; the\n // result.restores list records what was written.\n const archivedAt = await storage.archiveMemory(target, {\n actor: \"consolidate-undo\",\n reasonCode: \"consolidation-undo\",\n });\n result.targetArchived = archivedAt !== null;\n if (!result.targetArchived) {\n result.error =\n \"sources restored successfully but archiving the consolidated target failed; inspect storage for manual cleanup\";\n }\n return result;\n}\n\n/**\n * Render a consolidation-undo result as a human-readable multi-line\n * string for the CLI. Extracted so tests can snapshot the formatting\n * without parsing stdout.\n */\nexport function formatConsolidationUndoResult(result: ConsolidationUndoResult): string {\n const lines: string[] = [];\n lines.push(`consolidate undo ${result.dryRun ? \"(dry run) \" : \"\"}→ ${result.targetPath}`);\n // Emit per-restore details BEFORE the error (PR #637 review, cursor\n // Medium): the \"no sources could be recovered\" error is set after\n // the restore loop ran, so operators need the per-source skip\n // reasons to diagnose which snapshots were missing / outside\n // memoryDir / malformed. Early-bail errors (unloadable target,\n // target outside memoryDir, no derived_from) run before the loop,\n // so `result.restores` is empty in those cases and this block is a\n // no-op.\n for (const r of result.restores) {\n lines.push(` - ${r.entry} → ${r.outcome}${r.detail ? ` (${r.detail})` : \"\"}`);\n }\n if (result.error) {\n lines.push(` ERROR: ${result.error}`);\n return lines.join(\"\\n\");\n }\n lines.push(\n result.dryRun\n ? \" (dry run — no files were modified, target not archived)\"\n : ` target archived: ${result.targetArchived ? \"yes\" : \"no\"}`,\n );\n return lines.join(\"\\n\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAsBA,OAAO,UAAU;AACjB,SAAS,OAAO,WAAW,QAAQ,UAAU,aAAa;AAC1D,SAAS,aAAa,mBAAmB;AAiDzC,IAAM,wBAAwB;AAE9B,SAAS,WAAW,OAAgE;AAGlF,MAAI,OAAO,UAAU,SAAU,QAAO;AACtC,QAAM,QAAQ,MAAM,MAAM,qBAAqB;AAC/C,MAAI,CAAC,MAAO,QAAO;AACnB,SAAO,EAAE,UAAU,MAAM,CAAC,GAAG,WAAW,MAAM,CAAC,EAAE;AACnD;AAUO,SAAS,kBAAkB,WAAmB,MAAuB;AAC1E,QAAM,WAAW,KAAK,QAAQ,IAAI;AAClC,QAAM,gBAAgB,KAAK,QAAQ,SAAS;AAC5C,QAAM,MAAM,KAAK,SAAS,UAAU,aAAa;AACjD,MAAI,IAAI,WAAW,EAAG,QAAO;AAC7B,MAAI,IAAI,WAAW,IAAI,EAAG,QAAO;AACjC,MAAI,KAAK,WAAW,GAAG,EAAG,QAAO;AACjC,SAAO;AACT;AAkBA,eAAsB,0BACpB,WACA,MACkB;AAClB,MAAI,CAAC,kBAAkB,WAAW,IAAI,EAAG,QAAO;AAIhD,QAAM,cAAc,UAAU,QAAQ,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AAS,KAAK;AAAA,UACnB,OAAO,EAAE;AAAA,UACT,YAAY,EAAE;AAAA,UACd,SAAS;AAAA,UACT,QAAQ,iBAAiB,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG,CAAC;AAAA,QAC3E,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AAEA,MAAI,aAAa;AACf,WAAO,QACL;AACF,WAAO;AAAA,EACT;AAOA,QAAM,aAAa,MAAM,QAAQ,cAAc,QAAQ;AAAA,IACrD,OAAO;AAAA,IACP,YAAY;AAAA,EACd,CAAC;AACD,SAAO,iBAAiB,eAAe;AACvC,MAAI,CAAC,OAAO,gBAAgB;AAC1B,WAAO,QACL;AAAA,EACJ;AACA,SAAO;AACT;AAOO,SAAS,8BAA8B,QAAyC;AACrF,QAAM,QAAkB,CAAC;AACzB,QAAM,KAAK,oBAAoB,OAAO,SAAS,eAAe,EAAE,UAAK,OAAO,UAAU,EAAE;AASxF,aAAW,KAAK,OAAO,UAAU;AAC/B,UAAM,KAAK,OAAO,EAAE,KAAK,WAAM,EAAE,OAAO,GAAG,EAAE,SAAS,KAAK,EAAE,MAAM,MAAM,EAAE,EAAE;AAAA,EAC/E;AACA,MAAI,OAAO,OAAO;AAChB,UAAM,KAAK,YAAY,OAAO,KAAK,EAAE;AACrC,WAAO,MAAM,KAAK,IAAI;AAAA,EACxB;AACA,QAAM;AAAA,IACJ,OAAO,SACH,mEACA,sBAAsB,OAAO,iBAAiB,QAAQ,IAAI;AAAA,EAChE;AACA,SAAO,MAAM,KAAK,IAAI;AACxB;","names":[]}
@@ -1,5 +1,5 @@
1
- import { S as StorageManager } from '../storage-F9FVh-w9.js';
2
- import { x as MemoryStatus, P as PluginConfig, v as MemoryCategory } from '../types-rEwubvim.js';
1
+ import { S as StorageManager } from '../storage-DfjxusTE.js';
2
+ import { y as MemoryStatus, P as PluginConfig, w as MemoryCategory } from '../types-yX_FwERf.js';
3
3
  import { S as SemanticDedupLookup } from '../semantic-TddhF0y7.js';
4
4
  import { LocalLlmClient } from '../local-llm.js';
5
5
  import { FallbackLlmClient } from '../fallback-llm.js';
@@ -12,6 +12,7 @@ import '../maintenance/memory-governance.js';
12
12
  import '../message-parts/index.js';
13
13
  import '../bounded-jsonl-state.js';
14
14
  import '../operator-doctor-types.js';
15
+ import '../external-wiki-config.js';
15
16
  import '../types-continuity.js';
16
17
  import '../runtime/better-sqlite.js';
17
18
  import 'better-sqlite3';
@@ -1,7 +1,8 @@
1
- import { ai as ConvergeConflictPolicy, aj as ConvergeConfig } from './types-rEwubvim.js';
1
+ import { a2 as ConvergeConflictPolicy, ak as ConvergeConfig } from './types-yX_FwERf.js';
2
2
  import './message-parts/index.js';
3
3
  import './bounded-jsonl-state.js';
4
4
  import './operator-doctor-types.js';
5
+ import './external-wiki-config.js';
5
6
  import './types-continuity.js';
6
7
 
7
8
  declare const CONVERGE_CONFLICT_POLICIES: readonly ["newest-wins", "manual"];
@@ -1,10 +1,11 @@
1
1
  import { RebuildMemoryProjectionOptions } from './maintenance/rebuild-memory-projection.js';
2
2
  import { NamespaceSearchRouter } from './namespaces/search.js';
3
- import './storage-F9FVh-w9.js';
4
- import './types-rEwubvim.js';
3
+ import './storage-DfjxusTE.js';
4
+ import './types-yX_FwERf.js';
5
5
  import './message-parts/index.js';
6
6
  import './bounded-jsonl-state.js';
7
7
  import './operator-doctor-types.js';
8
+ import './external-wiki-config.js';
8
9
  import './types-continuity.js';
9
10
  import './entity-id-normalization.js';
10
11
  import './page-versioning.js';
@@ -19,6 +20,6 @@ import './structured-attributes.js';
19
20
  import './search/port.js';
20
21
 
21
22
  type ConvergenceStorage = NonNullable<RebuildMemoryProjectionOptions["storage"]>;
22
- declare function refreshConvergedNamespaces(namespaces: readonly string[], namespaceSearchRouter: Pick<NamespaceSearchRouter, "updateNamespacesDetailed">, getStorage: (namespace: string) => Promise<ConvergenceStorage>): Promise<void>;
23
+ declare function refreshConvergedNamespaces(namespaces: readonly string[], namespaceSearchRouter: Pick<NamespaceSearchRouter, "updateNamespacesDetailed">, getStorage: (namespace: string) => Promise<ConvergenceStorage>, searchEnabled: boolean): Promise<void>;
23
24
 
24
25
  export { refreshConvergedNamespaces };