@remnic/core 9.69.87 → 9.69.89

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 (416) hide show
  1. package/dist/access-admin-ops-surface.js +56 -49
  2. package/dist/access-authorization-probe.js +57 -50
  3. package/dist/access-boundary.js +56 -49
  4. package/dist/access-citation-namespace.js +2 -2
  5. package/dist/access-cli.js +129 -122
  6. package/dist/access-cli.js.map +1 -1
  7. package/dist/access-extraction-force-flush.js +56 -49
  8. package/dist/access-http-briefing.js +57 -50
  9. package/dist/access-http-offline-stream.d.ts.map +1 -1
  10. package/dist/access-http-offline-stream.js +1 -1
  11. package/dist/access-http-query.js +58 -51
  12. package/dist/access-http.js +78 -71
  13. package/dist/access-identity-continuity-surface.js +56 -49
  14. package/dist/access-lcm-surface.js +56 -49
  15. package/dist/access-mcp-output-schemas.d.ts.map +1 -1
  16. package/dist/access-mcp-output-schemas.js +1 -1
  17. package/dist/access-mcp.js +69 -62
  18. package/dist/access-namespace-preflight.js +56 -49
  19. package/dist/access-observe-write-category.js +20 -13
  20. package/dist/access-observe-write-surface.js +56 -49
  21. package/dist/access-offline-manifest.js +16 -10
  22. package/dist/access-operations-batch.js +60 -53
  23. package/dist/access-operations.js +67 -60
  24. package/dist/access-recall-concurrency.js +56 -49
  25. package/dist/access-recall-response.js +56 -49
  26. package/dist/access-recall-surface.js +56 -49
  27. package/dist/access-schema.js +16 -7
  28. package/dist/access-service.d.ts.map +1 -1
  29. package/dist/access-service.js +56 -49
  30. package/dist/access-surface-catalog.js +58 -51
  31. package/dist/access-surface-catalog.js.map +1 -1
  32. package/dist/active-recall.js +24 -18
  33. package/dist/active-recall.js.map +1 -1
  34. package/dist/{auto-sync-6IPX2BAC.js → auto-sync-U5N3CB5Y.js} +7 -7
  35. package/dist/briefing.js +11 -11
  36. package/dist/buffer.js +7 -7
  37. package/dist/{capsule-crypto-7FJQINUR.js → capsule-crypto-GWVG7LGC.js} +2 -2
  38. package/dist/{capsule-merge-3MNURAQ3.js → capsule-merge-ZCXUPLNJ.js} +2 -2
  39. package/dist/causal-behavior.js +2 -2
  40. package/dist/causal-chain.js +2 -2
  41. package/dist/causal-consolidation.js +14 -14
  42. package/dist/causal-retrieval.js +2 -2
  43. package/dist/causal-trajectory-graph.js +2 -2
  44. package/dist/causal-trajectory.js +1 -1
  45. package/dist/{chunk-JE334SIA.js → chunk-22DYJLFN.js} +2 -2
  46. package/dist/{chunk-YTQGGO3K.js → chunk-22LMCQ5B.js} +85 -82
  47. package/dist/{chunk-YTQGGO3K.js.map → chunk-22LMCQ5B.js.map} +1 -1
  48. package/dist/{chunk-JGSQ6P4D.js → chunk-2FX374UI.js} +2 -2
  49. package/dist/{chunk-SY5KDWGU.js → chunk-2WLMWP2T.js} +2 -2
  50. package/dist/{chunk-6TT6HRE4.js → chunk-3AGHSQPM.js} +2 -2
  51. package/dist/{chunk-P6WFK4ZJ.js → chunk-3O5BB45T.js} +4 -4
  52. package/dist/{chunk-3C3J243X.js → chunk-3QKO4QN7.js} +3 -3
  53. package/dist/{chunk-KFCMMDHH.js → chunk-3YD44CH2.js} +2 -2
  54. package/dist/{chunk-FRCESVV6.js → chunk-4HUCP4R4.js} +18 -18
  55. package/dist/chunk-4HUCP4R4.js.map +1 -0
  56. package/dist/chunk-4NSLQ7EU.js +137 -0
  57. package/dist/chunk-4NSLQ7EU.js.map +1 -0
  58. package/dist/{chunk-7DE2NOON.js → chunk-4O4XCBOS.js} +3 -3
  59. package/dist/{chunk-GDYU6VF4.js → chunk-5AYUHSAU.js} +2 -2
  60. package/dist/{chunk-ICZQG4XE.js → chunk-5FAGCOZD.js} +4 -4
  61. package/dist/{chunk-VKQI47DJ.js → chunk-5FNZ3G6X.js} +4 -4
  62. package/dist/{chunk-CK5KOVHW.js → chunk-5R627MYY.js} +3 -2
  63. package/dist/{chunk-CK5KOVHW.js.map → chunk-5R627MYY.js.map} +1 -1
  64. package/dist/{chunk-VQNONC4E.js → chunk-5STPRPE7.js} +2 -2
  65. package/dist/{chunk-52II7PB6.js → chunk-645WOU5I.js} +4 -4
  66. package/dist/{chunk-SRZW7FNU.js → chunk-64ZUALXK.js} +2 -2
  67. package/dist/{chunk-4BZP2B4U.js → chunk-6MNKDTDI.js} +2 -2
  68. package/dist/{chunk-DUJYRVUD.js → chunk-6O2VUWV6.js} +3 -3
  69. package/dist/chunk-75PT4N7Q.js +75 -0
  70. package/dist/chunk-75PT4N7Q.js.map +1 -0
  71. package/dist/{chunk-HESDNYRB.js → chunk-76M5OK7V.js} +2 -2
  72. package/dist/{chunk-FAN73COB.js → chunk-7D7OUO5W.js} +2 -2
  73. package/dist/{chunk-DZ525SNQ.js → chunk-7QE46QXI.js} +1 -1
  74. package/dist/{chunk-VX6GCKBS.js → chunk-7WBSMXGC.js} +4 -4
  75. package/dist/{chunk-VVDWZRZG.js → chunk-A6RVIHHK.js} +3 -3
  76. package/dist/{chunk-M536WNTQ.js → chunk-AEJ3TE5H.js} +2 -2
  77. package/dist/{chunk-72JNNJJJ.js → chunk-AXC4WSF3.js} +3 -3
  78. package/dist/chunk-AXGJMDBS.js +684 -0
  79. package/dist/chunk-AXGJMDBS.js.map +1 -0
  80. package/dist/{chunk-UA5DX5C3.js → chunk-AZIOEOK4.js} +2 -2
  81. package/dist/{chunk-N4S4NUX5.js → chunk-B3O3IRZN.js} +1 -1
  82. package/dist/{chunk-XTYX6V52.js → chunk-BJVO4H5C.js} +2 -2
  83. package/dist/{chunk-7LCGFUMB.js → chunk-BUKK5SWA.js} +4 -4
  84. package/dist/{chunk-TM3RXL4G.js → chunk-BUQKSQXL.js} +2 -2
  85. package/dist/chunk-C6HPNPNK.js +64 -0
  86. package/dist/chunk-C6HPNPNK.js.map +1 -0
  87. package/dist/{chunk-RB776UH3.js → chunk-C7V3KPKJ.js} +235 -93
  88. package/dist/chunk-C7V3KPKJ.js.map +1 -0
  89. package/dist/{chunk-FOH7AMMI.js → chunk-CALBQ2NG.js} +71 -72
  90. package/dist/chunk-CALBQ2NG.js.map +1 -0
  91. package/dist/{chunk-37S3IMYB.js → chunk-DGS34QSY.js} +2 -2
  92. package/dist/{chunk-4IEOGIPB.js → chunk-DO4C4AXD.js} +2 -2
  93. package/dist/{chunk-SPSRGEDQ.js → chunk-EAQQ2FD3.js} +9 -9
  94. package/dist/{chunk-3BTFBQLO.js → chunk-EFHNFTWB.js} +49 -3
  95. package/dist/chunk-EFHNFTWB.js.map +1 -0
  96. package/dist/{chunk-C3QXITIP.js → chunk-EQUD7FP4.js} +2 -2
  97. package/dist/chunk-ETUZFFPU.js +218 -0
  98. package/dist/chunk-ETUZFFPU.js.map +1 -0
  99. package/dist/{chunk-YNDLCWXS.js → chunk-EZ25VE3G.js} +4 -4
  100. package/dist/{chunk-YITN5WXI.js → chunk-FC52YWAO.js} +2 -2
  101. package/dist/{chunk-ZI7QA4MK.js → chunk-FEIXG5FA.js} +2 -2
  102. package/dist/{chunk-CLXTDOKV.js → chunk-FUNBJQYR.js} +2 -2
  103. package/dist/{chunk-CLSYE5OZ.js → chunk-G2STTRYB.js} +2 -2
  104. package/dist/{chunk-TDYAIXHK.js → chunk-H36X4NRH.js} +5 -5
  105. package/dist/{chunk-3GQC3NMB.js → chunk-H56VY4BY.js} +5 -5
  106. package/dist/{chunk-PUKTBULQ.js → chunk-HWLIMQE2.js} +2 -2
  107. package/dist/{chunk-V2ES4WCZ.js → chunk-IIARQTZ2.js} +2 -2
  108. package/dist/{chunk-QEV26L2F.js → chunk-IKDRGVVJ.js} +2 -2
  109. package/dist/{chunk-WQZZDN5M.js → chunk-IVEHY2VT.js} +254 -377
  110. package/dist/chunk-IVEHY2VT.js.map +1 -0
  111. package/dist/{chunk-LS3XH3UE.js → chunk-IYIBGSHJ.js} +2 -2
  112. package/dist/{chunk-YSJTCOHR.js → chunk-J27JML5O.js} +2 -2
  113. package/dist/{chunk-AQK54Q7O.js → chunk-JB56XYHP.js} +2 -2
  114. package/dist/{chunk-NE6PHPLG.js → chunk-JBH26P62.js} +10 -10
  115. package/dist/{chunk-CWHV574S.js → chunk-JUT3OR2L.js} +6 -6
  116. package/dist/{chunk-6ET2VII7.js → chunk-JYG2334B.js} +2 -2
  117. package/dist/{chunk-LF5IGOOD.js → chunk-JYM4Y6SO.js} +16 -16
  118. package/dist/{chunk-FB64XE3R.js → chunk-JZ4TJHR2.js} +2 -2
  119. package/dist/{chunk-EHS5MJEF.js → chunk-KTKHO3UI.js} +3 -3
  120. package/dist/{chunk-WIKO4SCR.js → chunk-LHRQBMJN.js} +2 -2
  121. package/dist/{chunk-K4J4E7WV.js → chunk-LO4UKPKX.js} +2 -2
  122. package/dist/{chunk-JN72EPOE.js → chunk-MAAL6OZV.js} +7 -7
  123. package/dist/chunk-MAAL6OZV.js.map +1 -0
  124. package/dist/{chunk-MY2PLXSM.js → chunk-MCTM4YPL.js} +2 -1
  125. package/dist/{chunk-MY2PLXSM.js.map → chunk-MCTM4YPL.js.map} +1 -1
  126. package/dist/{chunk-6NQ4LSMS.js → chunk-MGZMC6WN.js} +47 -47
  127. package/dist/chunk-MSAI3Q7D.js +372 -0
  128. package/dist/chunk-MSAI3Q7D.js.map +1 -0
  129. package/dist/{chunk-BMYZTZ5D.js → chunk-MY7B3HYC.js} +2 -2
  130. package/dist/{chunk-NB3LRY4T.js → chunk-N4PYB235.js} +2 -2
  131. package/dist/{chunk-S3YM4SZQ.js → chunk-N7QV3CMX.js} +2 -2
  132. package/dist/{chunk-L6UZEAID.js → chunk-NJVR724O.js} +4 -4
  133. package/dist/{chunk-VLLD4TOB.js → chunk-NMZVDRVP.js} +2 -2
  134. package/dist/{chunk-P2WZHLUF.js → chunk-NOL7SEWN.js} +2 -2
  135. package/dist/{chunk-2NLLXCJG.js → chunk-OWHERGF2.js} +2 -2
  136. package/dist/{chunk-6L3PBSAR.js → chunk-PMNLL2TL.js} +2 -2
  137. package/dist/{chunk-VYCOJKSX.js → chunk-PO7NXNGC.js} +2 -2
  138. package/dist/{chunk-4IIMMZZK.js → chunk-PULDSMCJ.js} +10 -10
  139. package/dist/{chunk-G6SVZWPB.js → chunk-PZX3AQLF.js} +44 -1
  140. package/dist/chunk-PZX3AQLF.js.map +1 -0
  141. package/dist/{chunk-HBBHL4YF.js → chunk-QOXNTKXB.js} +2 -2
  142. package/dist/{chunk-CUCWX3MO.js → chunk-QZLCVO2V.js} +2 -2
  143. package/dist/{chunk-NE7I2RCT.js → chunk-R3X2T2LP.js} +2 -2
  144. package/dist/{chunk-S7GCT7NU.js → chunk-RBITPCMK.js} +8 -8
  145. package/dist/{chunk-EVBI7S4J.js → chunk-RMDGAAZF.js} +4 -4
  146. package/dist/{chunk-BJRAELDH.js → chunk-SCXURCVT.js} +3 -3
  147. package/dist/{chunk-EQ6YOIKO.js → chunk-ST2RQUXC.js} +3 -3
  148. package/dist/{chunk-CS52MFDV.js → chunk-SZG4WFAG.js} +2 -2
  149. package/dist/{chunk-BFO3IR56.js → chunk-TPEZ2SHV.js} +2 -2
  150. package/dist/chunk-TYT4TEQV.js +45 -0
  151. package/dist/chunk-TYT4TEQV.js.map +1 -0
  152. package/dist/{chunk-YRLHEEQT.js → chunk-U6VC6RP3.js} +2 -2
  153. package/dist/chunk-UCPGOUDZ.js +726 -0
  154. package/dist/chunk-UCPGOUDZ.js.map +1 -0
  155. package/dist/{chunk-MOQPEFLN.js → chunk-UP75KL3L.js} +2 -2
  156. package/dist/{chunk-W4AOR52H.js → chunk-UQDC3W77.js} +2 -2
  157. package/dist/{chunk-X7Y7WX73.js → chunk-UVYI6VIX.js} +1 -1
  158. package/dist/{chunk-D5F7TKMH.js → chunk-V4JZCTMK.js} +2 -2
  159. package/dist/{chunk-MQJL6CDZ.js → chunk-VA4O3U7U.js} +4 -4
  160. package/dist/{chunk-4CDYONWO.js → chunk-VDO32NLK.js} +3 -3
  161. package/dist/{chunk-SOZUJCME.js → chunk-VHDKPGMG.js} +6 -6
  162. package/dist/{chunk-QWW2JDDX.js → chunk-WNRTXEWW.js} +6 -6
  163. package/dist/{chunk-NR2ASHBL.js → chunk-XOV7NRY5.js} +2 -2
  164. package/dist/{chunk-KP7SANCF.js → chunk-YPI4RQWV.js} +2 -2
  165. package/dist/{chunk-JKMHZF3Q.js → chunk-YSWJXOOL.js} +2 -2
  166. package/dist/{chunk-LQG5O5EP.js → chunk-Z3O53WZR.js} +2 -2
  167. package/dist/{chunk-QVS22WTO.js → chunk-ZG5DWWKK.js} +2 -2
  168. package/dist/cli.js +99 -92
  169. package/dist/coding/export-okf-codegraph.js +12 -12
  170. package/dist/coding/pre-action-gate.js +2 -2
  171. package/dist/compounding/engine.js +12 -12
  172. package/dist/config.js +24 -18
  173. package/dist/connectors/codex-materialize-runner.js +11 -11
  174. package/dist/connectors/index.js +11 -11
  175. package/dist/console/state.d.ts +30 -0
  176. package/dist/console/state.d.ts.map +1 -1
  177. package/dist/contradiction/index.js +5 -5
  178. package/dist/convergence-refresh.js +13 -13
  179. package/dist/corpus-watermark.js +13 -13
  180. package/dist/dashboard-runtime.js +2 -2
  181. package/dist/deep-recall-http-glue.js +16 -8
  182. package/dist/embedding-fallback.d.ts +41 -31
  183. package/dist/embedding-fallback.d.ts.map +1 -1
  184. package/dist/embedding-fallback.js +9 -1
  185. package/dist/embedding-generation-lock.d.ts +49 -0
  186. package/dist/embedding-generation-lock.d.ts.map +1 -0
  187. package/dist/embedding-generation-lock.js +19 -0
  188. package/dist/embedding-index-storage.d.ts +276 -0
  189. package/dist/embedding-index-storage.d.ts.map +1 -0
  190. package/dist/embedding-index-storage.js +28 -0
  191. package/dist/entity-retrieval.js +12 -12
  192. package/dist/event-order-recall.js +3 -3
  193. package/dist/explicit-capture.js +6 -6
  194. package/dist/external-wiki-access.js +57 -50
  195. package/dist/extraction.js +17 -17
  196. package/dist/{first-start-migration-7OATHJKB.js → first-start-migration-GAT7G733.js} +4 -4
  197. package/dist/{graph-edge-decay-KQGS3L3B.js → graph-edge-decay-MKIRZ762.js} +5 -5
  198. package/dist/graph-jsonl.js +3 -3
  199. package/dist/graph-snapshot.js +3 -3
  200. package/dist/graph.js +2 -2
  201. package/dist/harmonic-retrieval.js +1 -1
  202. package/dist/index.d.ts +2 -0
  203. package/dist/index.d.ts.map +1 -1
  204. package/dist/index.js +195 -164
  205. package/dist/lcm/engine.js +2 -2
  206. package/dist/lcm/index.js +5 -5
  207. package/dist/local-llm.js +2 -2
  208. package/dist/location/index.js +14 -14
  209. package/dist/maintenance/memory-governance.js +11 -11
  210. package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +11 -11
  211. package/dist/maintenance/rebuild-memory-projection.js +12 -12
  212. package/dist/memory-browse-operations.js +57 -50
  213. package/dist/memory-subject.js +3 -3
  214. package/dist/namespaces/migrate.js +12 -12
  215. package/dist/namespaces/storage.js +11 -11
  216. package/dist/offline-sync-changeset-generations.d.ts +82 -0
  217. package/dist/offline-sync-changeset-generations.d.ts.map +1 -0
  218. package/dist/offline-sync-changeset-generations.js +21 -0
  219. package/dist/offline-sync-embedding-generation.d.ts +257 -0
  220. package/dist/offline-sync-embedding-generation.d.ts.map +1 -0
  221. package/dist/offline-sync-embedding-generation.js +44 -0
  222. package/dist/offline-sync-embedding-generation.js.map +1 -0
  223. package/dist/offline-sync-exclude-globs.d.ts +15 -0
  224. package/dist/offline-sync-exclude-globs.d.ts.map +1 -1
  225. package/dist/offline-sync-exclude-globs.js +11 -3
  226. package/dist/offline-sync-file-io.d.ts +7 -0
  227. package/dist/offline-sync-file-io.d.ts.map +1 -1
  228. package/dist/offline-sync-file-io.js +14 -2
  229. package/dist/offline-sync-impression-drain.js +3 -3
  230. package/dist/offline-sync-runtime-state.d.ts +5 -0
  231. package/dist/offline-sync-runtime-state.d.ts.map +1 -0
  232. package/dist/offline-sync-runtime-state.js +14 -0
  233. package/dist/offline-sync-runtime-state.js.map +1 -0
  234. package/dist/offline-sync-snapshot-stream.d.ts +26 -0
  235. package/dist/offline-sync-snapshot-stream.d.ts.map +1 -0
  236. package/dist/offline-sync-snapshot-stream.js +29 -0
  237. package/dist/offline-sync-snapshot-stream.js.map +1 -0
  238. package/dist/offline-sync-upload-staging.d.ts +34 -0
  239. package/dist/offline-sync-upload-staging.d.ts.map +1 -0
  240. package/dist/offline-sync-upload-staging.js +26 -0
  241. package/dist/offline-sync-upload-staging.js.map +1 -0
  242. package/dist/offline-sync.d.ts +58 -28
  243. package/dist/offline-sync.d.ts.map +1 -1
  244. package/dist/offline-sync.js +22 -8
  245. package/dist/operator-doctor-corpus.js +14 -14
  246. package/dist/operator-toolkit.js +35 -29
  247. package/dist/orchestration/maintenance.js +22 -22
  248. package/dist/orchestrator.d.ts.map +1 -1
  249. package/dist/orchestrator.js +129 -122
  250. package/dist/recall-navigation-operations.js +57 -50
  251. package/dist/recall-navigation.js +56 -49
  252. package/dist/reconcile/manifest.js +4 -4
  253. package/dist/{resolution-DNX7FO7A.js → resolution-K4A3VPKZ.js} +6 -6
  254. package/dist/resolution-K4A3VPKZ.js.map +1 -0
  255. package/dist/resume-bundles.js +25 -19
  256. package/dist/salvage-envelope.js +5 -5
  257. package/dist/secure-store/index.js +2 -2
  258. package/dist/secure-store/secure-fs.d.ts +14 -1
  259. package/dist/secure-store/secure-fs.d.ts.map +1 -1
  260. package/dist/semantic-consolidation.js +12 -12
  261. package/dist/semantic-rule-promotion.js +11 -11
  262. package/dist/semantic-rule-verifier.js +11 -11
  263. package/dist/source-agent-qualifier.js +14 -14
  264. package/dist/standup/build.js +11 -11
  265. package/dist/{state-ITXJKXRE.js → state-JB47KHYV.js} +2 -2
  266. package/dist/state-JB47KHYV.js.map +1 -0
  267. package/dist/storage.d.ts +9 -3
  268. package/dist/storage.d.ts.map +1 -1
  269. package/dist/storage.js +10 -10
  270. package/dist/subject-config.js +4 -4
  271. package/dist/summarizer.js +3 -3
  272. package/dist/support-passport/index.js +59 -52
  273. package/dist/support-passport/offline-sync-guard.d.ts +6 -2
  274. package/dist/support-passport/offline-sync-guard.d.ts.map +1 -1
  275. package/dist/{trace-ZFVRH4GO.js → trace-LXXCMZJA.js} +3 -3
  276. package/dist/transfer/backup.js +2 -2
  277. package/dist/transfer/capsule-export.js +2 -2
  278. package/dist/transfer/capsule-import.js +3 -3
  279. package/dist/transfer/export-okf.js +12 -12
  280. package/dist/{tui-55UJMJX7.js → tui-2Z5WOV7L.js} +3 -3
  281. package/dist/tui-2Z5WOV7L.js.map +1 -0
  282. package/dist/verified-recall.js +11 -11
  283. package/dist/who-knows-cli.js +12 -12
  284. package/dist/who-knows.js +11 -11
  285. package/dist/write-envelope.js +4 -4
  286. package/package.json +2 -2
  287. package/src/access-http-offline-stream.ts +3 -0
  288. package/src/access-mcp-output-schemas.ts +1 -0
  289. package/src/access-service.ts +7 -18
  290. package/src/console/state.test.ts +56 -0
  291. package/src/console/state.ts +83 -0
  292. package/src/embedding-fallback.ts +325 -141
  293. package/src/embedding-generation-lock.ts +141 -0
  294. package/src/embedding-index-storage.test.ts +245 -0
  295. package/src/embedding-index-storage.ts +1068 -0
  296. package/src/index.ts +3 -3
  297. package/src/offline-sync-changeset-generations.test.ts +962 -0
  298. package/src/offline-sync-changeset-generations.ts +549 -0
  299. package/src/offline-sync-embedding-generation.test.ts +2173 -0
  300. package/src/offline-sync-embedding-generation.ts +1153 -0
  301. package/src/offline-sync-exclude-globs.ts +112 -0
  302. package/src/offline-sync-file-io.ts +48 -0
  303. package/src/offline-sync-runtime-state.ts +48 -0
  304. package/src/offline-sync-snapshot-stream.ts +99 -0
  305. package/src/offline-sync-upload-staging.ts +291 -0
  306. package/src/offline-sync.test.ts +164 -1
  307. package/src/offline-sync.ts +372 -454
  308. package/src/orchestrator.ts +2 -1
  309. package/src/secure-store/secure-fs.ts +26 -6
  310. package/src/storage.ts +11 -6
  311. package/src/support-passport/offline-sync-guard.ts +16 -2
  312. package/dist/chunk-3BTFBQLO.js.map +0 -1
  313. package/dist/chunk-AREGMX2J.js +0 -50
  314. package/dist/chunk-AREGMX2J.js.map +0 -1
  315. package/dist/chunk-FOH7AMMI.js.map +0 -1
  316. package/dist/chunk-FRCESVV6.js.map +0 -1
  317. package/dist/chunk-G6SVZWPB.js.map +0 -1
  318. package/dist/chunk-JN72EPOE.js.map +0 -1
  319. package/dist/chunk-RB776UH3.js.map +0 -1
  320. package/dist/chunk-WQZZDN5M.js.map +0 -1
  321. /package/dist/{auto-sync-6IPX2BAC.js.map → auto-sync-U5N3CB5Y.js.map} +0 -0
  322. /package/dist/{capsule-crypto-7FJQINUR.js.map → capsule-crypto-GWVG7LGC.js.map} +0 -0
  323. /package/dist/{capsule-merge-3MNURAQ3.js.map → capsule-merge-ZCXUPLNJ.js.map} +0 -0
  324. /package/dist/{chunk-JE334SIA.js.map → chunk-22DYJLFN.js.map} +0 -0
  325. /package/dist/{chunk-JGSQ6P4D.js.map → chunk-2FX374UI.js.map} +0 -0
  326. /package/dist/{chunk-SY5KDWGU.js.map → chunk-2WLMWP2T.js.map} +0 -0
  327. /package/dist/{chunk-6TT6HRE4.js.map → chunk-3AGHSQPM.js.map} +0 -0
  328. /package/dist/{chunk-P6WFK4ZJ.js.map → chunk-3O5BB45T.js.map} +0 -0
  329. /package/dist/{chunk-3C3J243X.js.map → chunk-3QKO4QN7.js.map} +0 -0
  330. /package/dist/{chunk-KFCMMDHH.js.map → chunk-3YD44CH2.js.map} +0 -0
  331. /package/dist/{chunk-7DE2NOON.js.map → chunk-4O4XCBOS.js.map} +0 -0
  332. /package/dist/{chunk-GDYU6VF4.js.map → chunk-5AYUHSAU.js.map} +0 -0
  333. /package/dist/{chunk-ICZQG4XE.js.map → chunk-5FAGCOZD.js.map} +0 -0
  334. /package/dist/{chunk-VKQI47DJ.js.map → chunk-5FNZ3G6X.js.map} +0 -0
  335. /package/dist/{chunk-VQNONC4E.js.map → chunk-5STPRPE7.js.map} +0 -0
  336. /package/dist/{chunk-52II7PB6.js.map → chunk-645WOU5I.js.map} +0 -0
  337. /package/dist/{chunk-SRZW7FNU.js.map → chunk-64ZUALXK.js.map} +0 -0
  338. /package/dist/{chunk-4BZP2B4U.js.map → chunk-6MNKDTDI.js.map} +0 -0
  339. /package/dist/{chunk-DUJYRVUD.js.map → chunk-6O2VUWV6.js.map} +0 -0
  340. /package/dist/{chunk-HESDNYRB.js.map → chunk-76M5OK7V.js.map} +0 -0
  341. /package/dist/{chunk-FAN73COB.js.map → chunk-7D7OUO5W.js.map} +0 -0
  342. /package/dist/{chunk-DZ525SNQ.js.map → chunk-7QE46QXI.js.map} +0 -0
  343. /package/dist/{chunk-VX6GCKBS.js.map → chunk-7WBSMXGC.js.map} +0 -0
  344. /package/dist/{chunk-VVDWZRZG.js.map → chunk-A6RVIHHK.js.map} +0 -0
  345. /package/dist/{chunk-M536WNTQ.js.map → chunk-AEJ3TE5H.js.map} +0 -0
  346. /package/dist/{chunk-72JNNJJJ.js.map → chunk-AXC4WSF3.js.map} +0 -0
  347. /package/dist/{chunk-UA5DX5C3.js.map → chunk-AZIOEOK4.js.map} +0 -0
  348. /package/dist/{chunk-N4S4NUX5.js.map → chunk-B3O3IRZN.js.map} +0 -0
  349. /package/dist/{chunk-XTYX6V52.js.map → chunk-BJVO4H5C.js.map} +0 -0
  350. /package/dist/{chunk-7LCGFUMB.js.map → chunk-BUKK5SWA.js.map} +0 -0
  351. /package/dist/{chunk-TM3RXL4G.js.map → chunk-BUQKSQXL.js.map} +0 -0
  352. /package/dist/{chunk-37S3IMYB.js.map → chunk-DGS34QSY.js.map} +0 -0
  353. /package/dist/{chunk-4IEOGIPB.js.map → chunk-DO4C4AXD.js.map} +0 -0
  354. /package/dist/{chunk-SPSRGEDQ.js.map → chunk-EAQQ2FD3.js.map} +0 -0
  355. /package/dist/{chunk-C3QXITIP.js.map → chunk-EQUD7FP4.js.map} +0 -0
  356. /package/dist/{chunk-YNDLCWXS.js.map → chunk-EZ25VE3G.js.map} +0 -0
  357. /package/dist/{chunk-YITN5WXI.js.map → chunk-FC52YWAO.js.map} +0 -0
  358. /package/dist/{chunk-ZI7QA4MK.js.map → chunk-FEIXG5FA.js.map} +0 -0
  359. /package/dist/{chunk-CLXTDOKV.js.map → chunk-FUNBJQYR.js.map} +0 -0
  360. /package/dist/{chunk-CLSYE5OZ.js.map → chunk-G2STTRYB.js.map} +0 -0
  361. /package/dist/{chunk-TDYAIXHK.js.map → chunk-H36X4NRH.js.map} +0 -0
  362. /package/dist/{chunk-3GQC3NMB.js.map → chunk-H56VY4BY.js.map} +0 -0
  363. /package/dist/{chunk-PUKTBULQ.js.map → chunk-HWLIMQE2.js.map} +0 -0
  364. /package/dist/{chunk-V2ES4WCZ.js.map → chunk-IIARQTZ2.js.map} +0 -0
  365. /package/dist/{chunk-QEV26L2F.js.map → chunk-IKDRGVVJ.js.map} +0 -0
  366. /package/dist/{chunk-LS3XH3UE.js.map → chunk-IYIBGSHJ.js.map} +0 -0
  367. /package/dist/{chunk-YSJTCOHR.js.map → chunk-J27JML5O.js.map} +0 -0
  368. /package/dist/{chunk-AQK54Q7O.js.map → chunk-JB56XYHP.js.map} +0 -0
  369. /package/dist/{chunk-NE6PHPLG.js.map → chunk-JBH26P62.js.map} +0 -0
  370. /package/dist/{chunk-CWHV574S.js.map → chunk-JUT3OR2L.js.map} +0 -0
  371. /package/dist/{chunk-6ET2VII7.js.map → chunk-JYG2334B.js.map} +0 -0
  372. /package/dist/{chunk-LF5IGOOD.js.map → chunk-JYM4Y6SO.js.map} +0 -0
  373. /package/dist/{chunk-FB64XE3R.js.map → chunk-JZ4TJHR2.js.map} +0 -0
  374. /package/dist/{chunk-EHS5MJEF.js.map → chunk-KTKHO3UI.js.map} +0 -0
  375. /package/dist/{chunk-WIKO4SCR.js.map → chunk-LHRQBMJN.js.map} +0 -0
  376. /package/dist/{chunk-K4J4E7WV.js.map → chunk-LO4UKPKX.js.map} +0 -0
  377. /package/dist/{chunk-6NQ4LSMS.js.map → chunk-MGZMC6WN.js.map} +0 -0
  378. /package/dist/{chunk-BMYZTZ5D.js.map → chunk-MY7B3HYC.js.map} +0 -0
  379. /package/dist/{chunk-NB3LRY4T.js.map → chunk-N4PYB235.js.map} +0 -0
  380. /package/dist/{chunk-S3YM4SZQ.js.map → chunk-N7QV3CMX.js.map} +0 -0
  381. /package/dist/{chunk-L6UZEAID.js.map → chunk-NJVR724O.js.map} +0 -0
  382. /package/dist/{chunk-VLLD4TOB.js.map → chunk-NMZVDRVP.js.map} +0 -0
  383. /package/dist/{chunk-P2WZHLUF.js.map → chunk-NOL7SEWN.js.map} +0 -0
  384. /package/dist/{chunk-2NLLXCJG.js.map → chunk-OWHERGF2.js.map} +0 -0
  385. /package/dist/{chunk-6L3PBSAR.js.map → chunk-PMNLL2TL.js.map} +0 -0
  386. /package/dist/{chunk-VYCOJKSX.js.map → chunk-PO7NXNGC.js.map} +0 -0
  387. /package/dist/{chunk-4IIMMZZK.js.map → chunk-PULDSMCJ.js.map} +0 -0
  388. /package/dist/{chunk-HBBHL4YF.js.map → chunk-QOXNTKXB.js.map} +0 -0
  389. /package/dist/{chunk-CUCWX3MO.js.map → chunk-QZLCVO2V.js.map} +0 -0
  390. /package/dist/{chunk-NE7I2RCT.js.map → chunk-R3X2T2LP.js.map} +0 -0
  391. /package/dist/{chunk-S7GCT7NU.js.map → chunk-RBITPCMK.js.map} +0 -0
  392. /package/dist/{chunk-EVBI7S4J.js.map → chunk-RMDGAAZF.js.map} +0 -0
  393. /package/dist/{chunk-BJRAELDH.js.map → chunk-SCXURCVT.js.map} +0 -0
  394. /package/dist/{chunk-EQ6YOIKO.js.map → chunk-ST2RQUXC.js.map} +0 -0
  395. /package/dist/{chunk-CS52MFDV.js.map → chunk-SZG4WFAG.js.map} +0 -0
  396. /package/dist/{chunk-BFO3IR56.js.map → chunk-TPEZ2SHV.js.map} +0 -0
  397. /package/dist/{chunk-YRLHEEQT.js.map → chunk-U6VC6RP3.js.map} +0 -0
  398. /package/dist/{chunk-MOQPEFLN.js.map → chunk-UP75KL3L.js.map} +0 -0
  399. /package/dist/{chunk-W4AOR52H.js.map → chunk-UQDC3W77.js.map} +0 -0
  400. /package/dist/{chunk-X7Y7WX73.js.map → chunk-UVYI6VIX.js.map} +0 -0
  401. /package/dist/{chunk-D5F7TKMH.js.map → chunk-V4JZCTMK.js.map} +0 -0
  402. /package/dist/{chunk-MQJL6CDZ.js.map → chunk-VA4O3U7U.js.map} +0 -0
  403. /package/dist/{chunk-4CDYONWO.js.map → chunk-VDO32NLK.js.map} +0 -0
  404. /package/dist/{chunk-SOZUJCME.js.map → chunk-VHDKPGMG.js.map} +0 -0
  405. /package/dist/{chunk-QWW2JDDX.js.map → chunk-WNRTXEWW.js.map} +0 -0
  406. /package/dist/{chunk-NR2ASHBL.js.map → chunk-XOV7NRY5.js.map} +0 -0
  407. /package/dist/{chunk-KP7SANCF.js.map → chunk-YPI4RQWV.js.map} +0 -0
  408. /package/dist/{chunk-JKMHZF3Q.js.map → chunk-YSWJXOOL.js.map} +0 -0
  409. /package/dist/{chunk-LQG5O5EP.js.map → chunk-Z3O53WZR.js.map} +0 -0
  410. /package/dist/{chunk-QVS22WTO.js.map → chunk-ZG5DWWKK.js.map} +0 -0
  411. /package/dist/{graph-edge-decay-KQGS3L3B.js.map → embedding-generation-lock.js.map} +0 -0
  412. /package/dist/{resolution-DNX7FO7A.js.map → embedding-index-storage.js.map} +0 -0
  413. /package/dist/{first-start-migration-7OATHJKB.js.map → first-start-migration-GAT7G733.js.map} +0 -0
  414. /package/dist/{state-ITXJKXRE.js.map → graph-edge-decay-MKIRZ762.js.map} +0 -0
  415. /package/dist/{tui-55UJMJX7.js.map → offline-sync-changeset-generations.js.map} +0 -0
  416. /package/dist/{trace-ZFVRH4GO.js.map → trace-LXXCMZJA.js.map} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/offline-sync-changeset-generations.ts"],"sourcesContent":["// Changeset-side generation atomicity for offline sync (issue #3150).\n// Split from offline-sync-embedding-generation.ts to respect the 1200-line\n// new-file cap: the snapshot-side transaction machinery stays there, this\n// module owns the CHANGESET protocol — the `embeddingGenerations` manifest\n// (sender-side builder + receiver-side validation) and the routing that\n// applies manifested generations through the shared locked atomic swap.\nimport { createHash } from \"node:crypto\";\nimport { lstat, readdir } from \"node:fs/promises\";\nimport {\n EmbeddingIndexStorageError,\n} from \"./embedding-index-storage.js\";\nimport {\n EMBEDDING_SHARD_DIR_BASENAME,\n applyEmbeddingGenerationRemoval,\n applyEmbeddingGenerationTransaction,\n embeddingGenerationMembership,\n embeddingShardDirOf,\n isEmbeddingGenerationDirPath,\n type EmbeddingGenerationTransactionInput,\n type EmbeddingGenerationTransactionIo,\n type EmbeddingGenerationTransactionResult,\n} from \"./offline-sync-embedding-generation.js\";\nimport { EMBEDDING_SHARD_FILE_PATTERN } from \"./offline-sync-runtime-state.js\";\nimport type {\n OfflineSyncChange,\n OfflineSyncConflict,\n OfflineSyncFileDeleteTarget,\n OfflineSyncFileStagingReadTarget,\n OfflineSyncFileStagingWriteTarget,\n OfflineSyncFileState,\n} from \"./offline-sync.js\";\nimport { type SafeArchiveRoot, resolveSafeArchiveTarget } from \"./transfer/fs-utils.js\";\n\nconst EMBEDDING_MARKER_BASENAME = \"embeddings.json\";\n\nasync function pathExists(absPath: string): Promise<boolean> {\n try {\n await lstat(absPath);\n return true;\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code === \"ENOENT\") return false;\n throw err;\n }\n}\n\n// ---------------------------------------------------------------------------\n// Changeset-side generation atomicity (issue #3150)\n//\n// Inline changesets are DIFFS, not complete generations: a push that rewrites\n// two of five shards carries only those two records. To reuse the snapshot\n// path's single atomic swap without sweeping unchanged shards, the sender\n// attaches an `embeddingGenerations` manifest — the COMPLETE post-change\n// membership of every touched generation — and the receiver assembles the\n// full incoming set: changed members ride inline, unchanged members carry\n// over from local bytes hash-verified against the manifest, removed members\n// are swept by the swap. Everything below shares the generation lock and the\n// secure-staging rules with the snapshot path.\n// ---------------------------------------------------------------------------\n\nexport interface OfflineSyncChangesetGenerationMember {\n path: string;\n sha256: string;\n bytes: number;\n}\n\n/** Complete post-change membership of ONE sharded generation. */\nexport interface OfflineSyncChangesetGeneration {\n /** The generation dir, e.g. `state/embeddings`. */\n shardDir: string;\n members: OfflineSyncChangesetGenerationMember[];\n}\n\ntype OfflineSyncUpsertChange = Extract<OfflineSyncChange, { type: \"upsert\" }>;\n\nconst SHA256_PATTERN = /^[0-9a-f]{64}$/;\n\n/**\n * Validate the optional `embeddingGenerations` changeset field (receiver\n * boundary). Returns undefined when the field is absent (legacy sender);\n * throws on any incoherence — duplicate dirs or member paths, noncanonical\n * dirs, members outside their dir, or a manifested generation that does not\n * account for every upserted shard — so bad manifests fail closed BEFORE any\n * apply-time write.\n */\nexport function normalizeChangesetGenerations(\n raw: unknown,\n changes: readonly OfflineSyncChange[],\n): OfflineSyncChangesetGeneration[] | undefined {\n if (raw === undefined) return undefined;\n if (!Array.isArray(raw)) {\n throw new Error(\"offline sync changeset embeddingGenerations must be an array\");\n }\n const dirs = new Set<string>();\n const generations: OfflineSyncChangesetGeneration[] = [];\n for (const entry of raw) {\n if (!entry || typeof entry !== \"object\" || Array.isArray(entry)) {\n throw new Error(\"offline sync changeset embeddingGenerations entries must be objects\");\n }\n const record = entry as Record<string, unknown>;\n const shardDir = typeof record.shardDir === \"string\" ? record.shardDir : \"\";\n if (!isEmbeddingGenerationDirPath(shardDir)) {\n throw new Error(`offline sync changeset embeddingGenerations shardDir must be a canonical embeddings generation dir: ${shardDir}`);\n }\n if (dirs.has(shardDir)) {\n throw new Error(`offline sync changeset embeddingGenerations has a duplicate shardDir: ${shardDir}`);\n }\n if (!Array.isArray(record.members) || record.members.length === 0) {\n throw new Error(`offline sync changeset embeddingGenerations ${shardDir} must list its complete member set`);\n }\n const memberPaths = new Set<string>();\n const members: OfflineSyncChangesetGenerationMember[] = [];\n for (const rawMember of record.members) {\n if (!rawMember || typeof rawMember !== \"object\" || Array.isArray(rawMember)) {\n throw new Error(`offline sync changeset embeddingGenerations ${shardDir} members must be objects`);\n }\n const member = rawMember as Record<string, unknown>;\n const memberPath = typeof member.path === \"string\" ? member.path : \"\";\n if (embeddingShardDirOf(memberPath) !== shardDir) {\n throw new Error(`offline sync changeset embeddingGenerations member ${memberPath} does not belong to generation ${shardDir}`);\n }\n if (memberPaths.has(memberPath)) {\n throw new Error(`offline sync changeset embeddingGenerations ${shardDir} has a duplicate member: ${memberPath}`);\n }\n if (typeof member.sha256 !== \"string\" || !SHA256_PATTERN.test(member.sha256)) {\n throw new Error(`offline sync changeset embeddingGenerations member ${memberPath} sha256 must be a lowercase sha256 hex digest`);\n }\n if (typeof member.bytes !== \"number\" || !Number.isInteger(member.bytes) || member.bytes < 0) {\n throw new Error(`offline sync changeset embeddingGenerations member ${memberPath} bytes must be a non-negative integer`);\n }\n memberPaths.add(memberPath);\n members.push({ path: memberPath, sha256: member.sha256, bytes: member.bytes });\n }\n dirs.add(shardDir);\n generations.push({ shardDir, members });\n }\n\n // Coherence with the change list: a manifest-bearing sender must account\n // for EVERY upserted shard, and no delete may target a surviving member.\n const memberByPath = new Map<string, OfflineSyncChangesetGenerationMember>();\n for (const generation of generations) {\n for (const member of generation.members) memberByPath.set(member.path, member);\n }\n for (const change of changes) {\n const membership = embeddingGenerationMembership(change.path);\n if (!membership) continue;\n const manifested = memberByPath.get(change.path);\n if (change.type === \"upsert\") {\n if (membership.kind !== \"shard\") continue;\n if (!manifested) {\n throw new Error(`offline sync changeset upserts of embedding shards require a manifest entry: ${change.path}`);\n }\n if (manifested.sha256 !== change.file.sha256 || manifested.bytes !== change.file.bytes) {\n throw new Error(`offline sync changeset manifest member ${change.path} does not match the upserted record`);\n }\n continue;\n }\n if (manifested) {\n throw new Error(`offline sync changeset delete of ${change.path} contradicts its manifest membership`);\n }\n }\n return generations;\n}\n\n/** Change-list conflicts for a deferred generation: visible, never silent. */\nfunction deferGenerationConflicts(\n dirChanges: readonly OfflineSyncChange[],\n currentMap: ReadonlyMap<string, OfflineSyncFileState>,\n reason: OfflineSyncConflict[\"reason\"],\n): { conflicts: OfflineSyncConflict[]; conflictedPaths: Set<string> } {\n const conflicts: OfflineSyncConflict[] = [];\n const conflictedPaths = new Set<string>();\n for (const change of dirChanges) {\n conflictedPaths.add(change.path);\n conflicts.push({\n path: change.path,\n reason,\n ...(change.type === \"upsert\" ? { incomingSha256: change.file.sha256 } : {}),\n ...(change.baseSha256 !== undefined ? { baseSha256: change.baseSha256 } : {}),\n localSha256: currentMap.get(change.path)?.sha256,\n });\n }\n return { conflicts, conflictedPaths };\n}\n\nexport interface ChangesetGenerationApplication {\n /** Paths the per-file apply loop must skip (published, swept, or removed). */\n transactionHandled: Set<string>;\n /** Conflicts for deferred generations — surfaced so the push side never\n * checkpoints a deferred generation as applied. */\n conflicts: OfflineSyncConflict[];\n conflictedPaths: Set<string>;\n appliedUpserts: number;\n appliedDeletes: number;\n /** Result-map updates for published members. */\n writtenStates: Map<string, OfflineSyncFileState>;\n /** Result-map removals for swept/removed members. */\n removedPaths: Set<string>;\n}\n\nexport interface ChangesetGenerationApplyOptions {\n root: SafeArchiveRoot;\n /** NORMALIZED changeset (manifest validated by normalizeChangesetGenerations). */\n changeset: { changes: readonly OfflineSyncChange[]; embeddingGenerations?: readonly OfflineSyncChangesetGeneration[] };\n incomingBuffers: ReadonlyMap<string, Buffer>;\n currentMap: ReadonlyMap<string, OfflineSyncFileState>;\n io: EmbeddingGenerationTransactionIo;\n /** True when the caller supplied ANY custom storage IO — the staging-pair\n * fail-closed rule then applies (mirrors the snapshot apply). */\n customIoPresent: boolean;\n now: number;\n}\n\n/** Change-list maps scoped per generation dir. */\ntype OfflineSyncChangesByDir = Map<string, OfflineSyncChange[]>;\n\n/**\n * Route a changeset's embedding-generation changes through the shared locked\n * transaction: manifested dirs publish atomically (changed members inline,\n * unchanged members carried over, removed members swept), manifested\n * shrink-deletes ride the same swap, full-evidence tombstones remove the\n * whole generation through the removal transaction, and everything that\n * cannot be proven (legacy manifest-less shard upserts, under-lock\n * divergence, remote-only members) is DEFERRED as conflicts with the disk\n * untouched — a mixed generation is never published and the push side never\n * checkpoints a deferred generation as applied.\n */\nexport async function applyChangesetEmbeddingGenerations(\n options: ChangesetGenerationApplyOptions,\n): Promise<ChangesetGenerationApplication> {\n const result: ChangesetGenerationApplication = {\n transactionHandled: new Set(),\n conflicts: [],\n conflictedPaths: new Set(),\n appliedUpserts: 0,\n appliedDeletes: 0,\n writtenStates: new Map(),\n removedPaths: new Set(),\n };\n const manifest = new Map(\n (options.changeset.embeddingGenerations ?? []).map((generation) => [generation.shardDir, generation]),\n );\n const shardUpsertChanges: Map<string, OfflineSyncUpsertChange[]> = new Map();\n const markerUpsertChanges: Map<string, OfflineSyncUpsertChange[]> = new Map();\n const deleteChangesByDir = new Map<string, OfflineSyncChange[]>();\n const dirChanges = new Map<string, OfflineSyncChange[]>();\n for (const change of options.changeset.changes) {\n const membership = embeddingGenerationMembership(change.path);\n if (!membership) continue;\n const dir = membership.shardDir;\n if (!dirChanges.has(dir)) dirChanges.set(dir, []);\n dirChanges.get(dir)!.push(change);\n if (change.type === \"upsert\") {\n if (membership.kind === \"shard\") {\n if (!shardUpsertChanges.has(dir)) shardUpsertChanges.set(dir, []);\n shardUpsertChanges.get(dir)!.push(change);\n } else {\n if (!markerUpsertChanges.has(dir)) markerUpsertChanges.set(dir, []);\n markerUpsertChanges.get(dir)!.push(change);\n }\n } else {\n if (!deleteChangesByDir.has(dir)) deleteChangesByDir.set(dir, []);\n deleteChangesByDir.get(dir)!.push(change);\n }\n }\n\n // Fail closed BEFORE any publication: custom storage IO without the\n // staging pair would stage the incoming generation in plaintext (same rule\n // and message as the snapshot apply).\n if (\n (shardUpsertChanges.size > 0 || markerUpsertChanges.size > 0) &&\n options.customIoPresent &&\n !(options.io.writeStagingFile && options.io.readStagingFile)\n ) {\n throw new EmbeddingIndexStorageError(\n \"refusing to replace embedding generation: custom storage IO requires both writeStagingFile and readStagingFile hooks; unencrypted raw staging would plaintext-downgrade the index\",\n );\n }\n\n const runTransaction = async (\n shardDirRel: string,\n input: Omit<EmbeddingGenerationTransactionInput, \"root\" | \"io\" | \"now\">,\n ): Promise<EmbeddingGenerationTransactionResult> => {\n const transaction = await applyEmbeddingGenerationTransaction({\n ...input,\n root: options.root,\n io: options.io,\n now: options.now,\n });\n if (transaction.deferredLocalDivergence) {\n const deferred = deferGenerationConflicts(\n dirChanges.get(shardDirRel) ?? [],\n options.currentMap,\n \"embedding_generation_diverged\",\n );\n result.conflicts.push(...deferred.conflicts);\n for (const conflicted of deferred.conflictedPaths) result.conflictedPaths.add(conflicted);\n return transaction;\n }\n result.appliedUpserts += transaction.upserted;\n result.appliedDeletes += transaction.deleted;\n for (const [relPath, state] of transaction.writtenStates) {\n result.writtenStates.set(relPath, state);\n result.transactionHandled.add(relPath);\n }\n for (const relPath of transaction.removedPaths) {\n result.removedPaths.add(relPath);\n result.transactionHandled.add(relPath);\n }\n return transaction;\n };\n\n /** Incoming set + reconstructed shared base for ONE manifested generation. */\n const manifestedInput = (\n shardDirRel: string,\n generation: OfflineSyncChangesetGeneration,\n ): Omit<EmbeddingGenerationTransactionInput, \"root\" | \"io\" | \"now\"> => {\n const upsertByPath = new Map(\n (shardUpsertChanges.get(shardDirRel) ?? []).map((change: OfflineSyncUpsertChange) => [change.path, change]),\n );\n const memberByPath = new Map(generation.members.map((member) => [member.path, member]));\n const incomingShardPaths = generation.members.map((member) => member.path).sort();\n const tombstones = (deleteChangesByDir.get(shardDirRel) ?? [])\n .filter((change): change is Extract<OfflineSyncChange, { type: \"delete\" }> => change.type === \"delete\");\n const baseStates = new Map<string, { sha256: string }>();\n for (const member of generation.members) {\n const change = upsertByPath.get(member.path);\n if (change) {\n if (change.baseSha256 !== undefined) baseStates.set(member.path, { sha256: change.baseSha256 });\n continue;\n }\n // Unchanged member: the manifest digest IS its shared-base evidence.\n baseStates.set(member.path, { sha256: member.sha256 });\n }\n for (const change of tombstones) {\n baseStates.set(change.path, { sha256: change.baseSha256 });\n }\n return {\n shardDirRel,\n incomingShardPaths,\n incomingMarker: null,\n incomingMarkerPresent: markerUpsertChanges.has(shardDirRel),\n incomingShardStates: new Map(\n incomingShardPaths.map((relPath) => [relPath, {\n path: relPath,\n sha256: upsertByPath.get(relPath)?.file.sha256 ?? memberByPath.get(relPath)!.sha256,\n bytes: memberByPath.get(relPath)!.bytes,\n mtimeMs: options.now,\n } satisfies OfflineSyncFileState]),\n ),\n incomingBuffers: options.incomingBuffers,\n baseStates,\n // Manifested deletes are pre-authorized removals: the retry after a\n // response loss must re-apply idempotently instead of diverging\n // (#3150 review), and the swept members need their deletion revisions\n // recorded after the swap (the per-file loop never sees them). The\n // map is present whenever tombstones exist — even when none carries\n // mtimeMs — so the recording pass runs and defaults to `now`.\n justifiedRemovals: new Set(tombstones.map((change) => change.path)),\n deletionMtimeByPath: tombstones.length === 0\n ? undefined\n : new Map(\n tombstones\n .filter((change) => change.mtimeMs !== undefined)\n .map((change) => [change.path, change.mtimeMs as number]),\n ),\n // All-manifested members base-less = the sender claims a fresh\n // creation; an existing local generation must match exactly or defer.\n freshCreateClaim: baseStates.size === 0,\n };\n };\n\n const stateDirSuffix = `/${EMBEDDING_SHARD_DIR_BASENAME}`;\n const allDirs = new Set<string>([\n ...shardUpsertChanges.keys(),\n ...markerUpsertChanges.keys(),\n ...deleteChangesByDir.keys(),\n ]);\n for (const shardDirRel of [...allDirs].sort()) {\n const generation = manifest.get(shardDirRel);\n if (shardUpsertChanges.has(shardDirRel) || (generation && deleteChangesByDir.has(shardDirRel))) {\n if (!generation) {\n // Legacy sender: shard upserts without a manifest cannot prove\n // complete membership — defer instead of risking a mixed generation.\n const deferred = deferGenerationConflicts(\n dirChanges.get(shardDirRel) ?? [],\n options.currentMap,\n \"embedding_generation_manifest_required\",\n );\n result.conflicts.push(...deferred.conflicts);\n for (const conflicted of deferred.conflictedPaths) result.conflictedPaths.add(conflicted);\n continue;\n }\n await runTransaction(shardDirRel, manifestedInput(shardDirRel, generation));\n continue;\n }\n if (markerUpsertChanges.has(shardDirRel)) {\n // Cross-layout: an incoming legacy marker replaces the generation as a\n // whole. No manifest exists (post-change membership is the marker), so\n // base evidence comes from the marker change alone; a receiver-local\n // sharded generation the marker base cannot account for defers via the\n // transaction's under-lock census check rather than being swept.\n const markerChange = (markerUpsertChanges.get(shardDirRel) ?? [])[0] as OfflineSyncUpsertChange | undefined;\n if (!markerChange) continue;\n const stateDirRel = shardDirRel.slice(0, -stateDirSuffix.length);\n const markerRel = `${stateDirRel}/${EMBEDDING_MARKER_BASENAME}`;\n const transaction = await runTransaction(shardDirRel, {\n shardDirRel,\n incomingShardPaths: [],\n incomingMarker: {\n path: markerRel,\n sha256: markerChange.file.sha256,\n buffer: options.incomingBuffers.get(markerRel) ?? null,\n },\n incomingMarkerPresent: false,\n incomingShardStates: new Map(),\n incomingBuffers: options.incomingBuffers,\n baseStates: markerChange.baseSha256 === undefined\n ? undefined\n : new Map([[markerRel, { sha256: markerChange.baseSha256 }]]),\n });\n // The conversion consumes the marker change whole: on a published\n // transaction the per-file loop must not re-write the legacy marker\n // outside the atomic swap (#3150 review). On deferral the marker\n // change is already in conflictedPaths, so it stays uncheckpointed.\n if (!transaction.deferredLocalDivergence) result.transactionHandled.add(markerRel);\n continue;\n }\n // Delete-only without a manifest: whole-generation removal ONLY when the\n // changeset tombstones EVERY local member (complete evidence, mirrors the\n // snapshot rule). Incomplete manifest-less deletion evidence defers the\n // whole directory as `embedding_generation_manifest_required` conflicts;\n // the complete published generation survives and is never broken apart by\n // independent shard deletes. Only non-generation files keep per-file deletes.\n const deletes = deleteChangesByDir.get(shardDirRel) ?? [];\n const deletePaths = new Set(deletes.map((change) => change.path));\n const stateDirRel = shardDirRel.slice(0, -stateDirSuffix.length);\n const markerRel = `${stateDirRel}/${EMBEDDING_MARKER_BASENAME}`;\n const localMembers: string[] = [];\n if (await pathExists(await resolveSafeArchiveTarget(options.root, markerRel))) localMembers.push(markerRel);\n let localShardNames: string[] = [];\n try {\n localShardNames = (await readdir(await resolveSafeArchiveTarget(options.root, shardDirRel)))\n .filter((name) => EMBEDDING_SHARD_FILE_PATTERN.test(name));\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code !== \"ENOENT\") throw err;\n }\n for (const name of localShardNames) localMembers.push(`${shardDirRel}/${name}`);\n if (localMembers.length === 0) continue;\n if (!localMembers.every((relPath) => deletePaths.has(relPath))) {\n // Incomplete deletion evidence: applying the evidenced subset would\n // break the local generation apart. Defer the WHOLE dir as conflicts —\n // the complete published generation survives and the push side cannot\n // checkpoint the deletes as applied.\n const deferred = deferGenerationConflicts(deletes, options.currentMap, \"embedding_generation_manifest_required\");\n result.conflicts.push(...deferred.conflicts);\n for (const conflicted of deferred.conflictedPaths) result.conflictedPaths.add(conflicted);\n continue;\n }\n const tombstones = deletes.filter((change): change is Extract<OfflineSyncChange, { type: \"delete\" }> => change.type === \"delete\");\n const removal = await applyEmbeddingGenerationRemoval({\n root: options.root,\n shardDirRel,\n io: { deleteFile: options.io.deleteFile, readFile: options.io.readFile },\n deletionMtimeByPath: new Map(\n tombstones\n .filter((change) => change.mtimeMs !== undefined)\n .map((change) => [change.path, change.mtimeMs as number]),\n ),\n baseStates: new Map(tombstones.map((change) => [change.path, { sha256: change.baseSha256 }])),\n now: options.now,\n });\n if (removal.deferredLocalDivergence) {\n const deferred = deferGenerationConflicts(deletes, options.currentMap, \"embedding_generation_diverged\");\n result.conflicts.push(...deferred.conflicts);\n for (const conflicted of deferred.conflictedPaths) result.conflictedPaths.add(conflicted);\n continue;\n }\n result.appliedDeletes += removal.deleted;\n for (const relPath of removal.removedPaths) {\n result.removedPaths.add(relPath);\n result.transactionHandled.add(relPath);\n }\n }\n return result;\n}\n\nexport interface ChangesetGenerationManifestOptions {\n changes: readonly OfflineSyncChange[];\n /** The sender's complete current state (post-change generation members). */\n currentFiles: readonly OfflineSyncFileState[];\n baseFiles: readonly OfflineSyncFileState[];\n /** The exact exclusion predicate the change walk used — any member it\n * drops forces whole-generation omission (filter-to-omit, #3148). */\n isExcluded: (relPath: string) => boolean;\n}\n\n/**\n * Sender side: complete post-change membership for every generation touched\n * by the changeset. A touched generation with ANY excluded member is omitted\n * WHOLE — its changes are dropped by the caller contract below and no\n * manifest is emitted — so a filtered generation can never look like a\n * partial replacement on the receiver.\n */\nexport function buildChangesetGenerationManifest(\n options: ChangesetGenerationManifestOptions,\n): OfflineSyncChangesetGeneration[] {\n const currentByPath = new Map(options.currentFiles.map((state) => [state.path, state]));\n const baseByPath = new Map(options.baseFiles.map((state) => [state.path, state]));\n const touchedDirs = new Map<string, OfflineSyncChange[]>();\n for (const change of options.changes) {\n const membership = embeddingGenerationMembership(change.path);\n if (membership) {\n if (!touchedDirs.has(membership.shardDir)) touchedDirs.set(membership.shardDir, []);\n touchedDirs.get(membership.shardDir)!.push(change);\n }\n }\n const generations: OfflineSyncChangesetGeneration[] = [];\n for (const [shardDirRel, changes] of [...touchedDirs].sort(([left], [right]) => left.localeCompare(right))) {\n const memberPaths = new Set<string>();\n for (const relPath of currentByPath.keys()) {\n const membership = embeddingGenerationMembership(relPath);\n if (membership?.shardDir === shardDirRel) memberPaths.add(relPath);\n }\n for (const relPath of baseByPath.keys()) {\n const membership = embeddingGenerationMembership(relPath);\n if (membership?.shardDir === shardDirRel) memberPaths.add(relPath);\n }\n for (const change of changes) memberPaths.add(change.path);\n // Filter-to-omit: one excluded member omits the whole generation.\n let omitted = false;\n for (const relPath of memberPaths) {\n if (options.isExcluded(relPath)) {\n omitted = true;\n break;\n }\n }\n if (omitted) continue;\n const members = [...memberPaths]\n .filter((relPath) => currentByPath.has(relPath))\n .sort()\n .map((relPath) => {\n const state = currentByPath.get(relPath)!;\n return { path: state.path, sha256: state.sha256, bytes: state.bytes };\n });\n if (members.length === 0) continue;\n generations.push({ shardDir: shardDirRel, members });\n }\n return generations;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAOA,SAAS,OAAO,eAAe;AA0B/B,IAAM,4BAA4B;AAElC,eAAe,WAAW,SAAmC;AAC3D,MAAI;AACF,UAAM,MAAM,OAAO;AACnB,WAAO;AAAA,EACT,SAAS,KAAK;AACZ,QAAK,IAA8B,SAAS,SAAU,QAAO;AAC7D,UAAM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I,OAAO,CAAC,EAC9C,KAAK,EACL,IAAI,CAAC,YAAY;AAChB,YAAM,QAAQ,cAAc,IAAI,OAAO;AACvC,aAAO,EAAE,MAAM,MAAM,MAAM,QAAQ,MAAM,QAAQ,OAAO,MAAM,MAAM;AAAA,IACtE,CAAC;AACH,QAAI,QAAQ,WAAW,EAAG;AAC1B,gBAAY,KAAK,EAAE,UAAU,aAAa,QAAQ,CAAC;AAAA,EACrD;AACA,SAAO;AACT;","names":["stateDirRel","markerRel"]}
@@ -5,7 +5,7 @@ import {
5
5
  import {
6
6
  STRUCTURED_ATTRIBUTE_LIMITS,
7
7
  TAG_LIMITS
8
- } from "./chunk-GDYU6VF4.js";
8
+ } from "./chunk-5AYUHSAU.js";
9
9
  import {
10
10
  pathIsInside
11
11
  } from "./chunk-C7HJ3NEI.js";
@@ -889,4 +889,4 @@ export {
889
889
  applyBriefingLocationContext,
890
890
  daySummaryAutoOptions
891
891
  };
892
- //# sourceMappingURL=chunk-BMYZTZ5D.js.map
892
+ //# sourceMappingURL=chunk-MY7B3HYC.js.map
@@ -9,7 +9,7 @@ import {
9
9
  SecureStoreLockedError,
10
10
  readMaybeEncryptedFile,
11
11
  writeMaybeEncryptedFile
12
- } from "./chunk-JN72EPOE.js";
12
+ } from "./chunk-MAAL6OZV.js";
13
13
  import {
14
14
  isErrnoCode
15
15
  } from "./chunk-KNA3BXXL.js";
@@ -577,4 +577,4 @@ export {
577
577
  FactHashIndexNotAuthoritativeError,
578
578
  ContentHashIndex
579
579
  };
580
- //# sourceMappingURL=chunk-NB3LRY4T.js.map
580
+ //# sourceMappingURL=chunk-N4PYB235.js.map
@@ -12,7 +12,7 @@ import {
12
12
  } from "./chunk-7RJUVTVF.js";
13
13
  import {
14
14
  ContentHashIndex
15
- } from "./chunk-NB3LRY4T.js";
15
+ } from "./chunk-N4PYB235.js";
16
16
  import {
17
17
  computeLegacyContentHash,
18
18
  normalizeLegacyContent
@@ -348,4 +348,4 @@ export {
348
348
  buildReconcileManifest,
349
349
  collapseActiveFactDuplicates
350
350
  };
351
- //# sourceMappingURL=chunk-S3YM4SZQ.js.map
351
+ //# sourceMappingURL=chunk-N7QV3CMX.js.map
@@ -3,10 +3,10 @@ import {
3
3
  } from "./chunk-KJTKLXTH.js";
4
4
  import {
5
5
  StorageManager
6
- } from "./chunk-FRCESVV6.js";
6
+ } from "./chunk-4HUCP4R4.js";
7
7
  import {
8
8
  assertInjectedStorageRooted
9
- } from "./chunk-JE334SIA.js";
9
+ } from "./chunk-22DYJLFN.js";
10
10
  import {
11
11
  MEMORY_LIFECYCLE_LEDGER_LOCK_STALE_MS,
12
12
  buildLifecycleEventsForMemory,
@@ -28,7 +28,7 @@ import {
28
28
  } from "./chunk-FFAZ2XFU.js";
29
29
  import {
30
30
  probeEncryptedRegularFileHeader
31
- } from "./chunk-JN72EPOE.js";
31
+ } from "./chunk-MAAL6OZV.js";
32
32
  import {
33
33
  isErrnoCode
34
34
  } from "./chunk-KNA3BXXL.js";
@@ -260,4 +260,4 @@ export {
260
260
  backupExistingLedger,
261
261
  rebuildMemoryLifecycleLedger
262
262
  };
263
- //# sourceMappingURL=chunk-L6UZEAID.js.map
263
+ //# sourceMappingURL=chunk-NJVR724O.js.map
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-TBBDFYXW.js";
4
4
  import {
5
5
  StorageManager
6
- } from "./chunk-FRCESVV6.js";
6
+ } from "./chunk-4HUCP4R4.js";
7
7
  import {
8
8
  bumpMemoryCorpusVersionForDir
9
9
  } from "./chunk-XCB6QDL6.js";
@@ -765,4 +765,4 @@ export {
765
765
  listMemoryGovernanceRuns,
766
766
  readMemoryGovernanceRunArtifact
767
767
  };
768
- //# sourceMappingURL=chunk-VLLD4TOB.js.map
768
+ //# sourceMappingURL=chunk-NMZVDRVP.js.map
@@ -6,7 +6,7 @@ import {
6
6
  } from "./chunk-6JMQR72P.js";
7
7
  import {
8
8
  StorageManager
9
- } from "./chunk-FRCESVV6.js";
9
+ } from "./chunk-4HUCP4R4.js";
10
10
  import {
11
11
  normalizeEntityName
12
12
  } from "./chunk-YXZG5TVN.js";
@@ -962,4 +962,4 @@ export {
962
962
  resolveBriefingSaveDir,
963
963
  briefingFilename
964
964
  };
965
- //# sourceMappingURL=chunk-P2WZHLUF.js.map
965
+ //# sourceMappingURL=chunk-NOL7SEWN.js.map
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-765K3SAT.js";
4
4
  import {
5
5
  encryptCapsuleFile
6
- } from "./chunk-X7Y7WX73.js";
6
+ } from "./chunk-UVYI6VIX.js";
7
7
  import {
8
8
  computeTransferOutputRel,
9
9
  isTransferPathExcluded
@@ -109,4 +109,4 @@ async function enforceRetention(outDirAbs, retentionDays) {
109
109
  export {
110
110
  backupMemoryDir
111
111
  };
112
- //# sourceMappingURL=chunk-2NLLXCJG.js.map
112
+ //# sourceMappingURL=chunk-OWHERGF2.js.map
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-A7AISUJI.js";
4
4
  import {
5
5
  deepRecallRequestSchema
6
- } from "./chunk-3C3J243X.js";
6
+ } from "./chunk-3QKO4QN7.js";
7
7
  import {
8
8
  EngramAccessInputError
9
9
  } from "./chunk-3MUKQQ7A.js";
@@ -40,4 +40,4 @@ async function respondDeepRecall(req, res, respondJson, readJsonBody, service, s
40
40
  export {
41
41
  respondDeepRecall
42
42
  };
43
- //# sourceMappingURL=chunk-6L3PBSAR.js.map
43
+ //# sourceMappingURL=chunk-PMNLL2TL.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  ContentHashIndex
3
- } from "./chunk-NB3LRY4T.js";
3
+ } from "./chunk-N4PYB235.js";
4
4
  import {
5
5
  sanitizeMemoryContent
6
6
  } from "./chunk-5GKPFL3S.js";
@@ -164,4 +164,4 @@ export {
164
164
  PROMOTION_CANDIDATES_MCP_TOOLS,
165
165
  backfillMemorySubjects
166
166
  };
167
- //# sourceMappingURL=chunk-VYCOJKSX.js.map
167
+ //# sourceMappingURL=chunk-PO7NXNGC.js.map
@@ -3,7 +3,7 @@ import {
3
3
  readNamespaceMaintenanceLastRanStatuses,
4
4
  readNamespaceMaintenanceStatuses,
5
5
  runNamespaceMaintenancePlan
6
- } from "./chunk-4CDYONWO.js";
6
+ } from "./chunk-VDO32NLK.js";
7
7
  import {
8
8
  analyzeSessionIntegrity,
9
9
  applySessionRepair,
@@ -14,7 +14,7 @@ import {
14
14
  } from "./chunk-CMTINOFS.js";
15
15
  import {
16
16
  summarizeCorpusAndReplica
17
- } from "./chunk-QEV26L2F.js";
17
+ } from "./chunk-IKDRGVVJ.js";
18
18
  import {
19
19
  readJudgeVerdictStats
20
20
  } from "./chunk-OZKOPQCM.js";
@@ -38,26 +38,26 @@ import {
38
38
  } from "./chunk-YBPYIAA5.js";
39
39
  import {
40
40
  parseConfig
41
- } from "./chunk-3GQC3NMB.js";
41
+ } from "./chunk-H56VY4BY.js";
42
42
  import {
43
43
  readAggregateExtractionWatermark
44
- } from "./chunk-UA5DX5C3.js";
44
+ } from "./chunk-AZIOEOK4.js";
45
45
  import {
46
46
  listMemoryGovernanceRuns,
47
47
  readMemoryGovernanceRunArtifact
48
- } from "./chunk-VLLD4TOB.js";
48
+ } from "./chunk-NMZVDRVP.js";
49
49
  import {
50
50
  listNamespaces
51
- } from "./chunk-JGSQ6P4D.js";
51
+ } from "./chunk-2FX374UI.js";
52
52
  import {
53
53
  analyzeGraphHealth
54
- } from "./chunk-ICZQG4XE.js";
54
+ } from "./chunk-5FAGCOZD.js";
55
55
  import {
56
56
  summarizeExtractionLiveness
57
57
  } from "./chunk-AWD36R4D.js";
58
58
  import {
59
59
  StorageManager
60
- } from "./chunk-FRCESVV6.js";
60
+ } from "./chunk-4HUCP4R4.js";
61
61
  import {
62
62
  lintWorkspaceFiles
63
63
  } from "./chunk-DM2T26WE.js";
@@ -1069,7 +1069,7 @@ async function summarizeBufferSurpriseDistribution(storage, config) {
1069
1069
  }
1070
1070
  }
1071
1071
  async function summarizeGraphEdgeDecayStatus(config) {
1072
- const { readGraphEdgeDecayStatus } = await import("./graph-edge-decay-KQGS3L3B.js");
1072
+ const { readGraphEdgeDecayStatus } = await import("./graph-edge-decay-MKIRZ762.js");
1073
1073
  const { graphEdgeDecayEnabled } = config;
1074
1074
  const enabled = graphEdgeDecayEnabled === true;
1075
1075
  if (!enabled) {
@@ -1683,4 +1683,4 @@ export {
1683
1683
  runBenchmarkRecall,
1684
1684
  runOperatorRepair
1685
1685
  };
1686
- //# sourceMappingURL=chunk-4IIMMZZK.js.map
1686
+ //# sourceMappingURL=chunk-PULDSMCJ.js.map
@@ -17,6 +17,7 @@ async function gatherConsoleState(orchestrator) {
17
17
  );
18
18
  const qmdProbe = readQmdProbe(orchestrator, errors);
19
19
  const daemon = readDaemonInfo(orchestrator, errors);
20
+ const embeddingIndex = await readEmbeddingIndexState(orchestrator, errors);
20
21
  let faithfulness;
21
22
  try {
22
23
  if (typeof orchestrator.getConsoleFaithfulnessDistribution === "function") {
@@ -34,9 +35,51 @@ async function gatherConsoleState(orchestrator) {
34
35
  qmdProbe,
35
36
  daemon,
36
37
  ...faithfulness ? { faithfulness } : {},
38
+ ...embeddingIndex ? { embeddingIndex } : {},
37
39
  errors
38
40
  };
39
41
  }
42
+ var EMBEDDING_SHARD_PATTERN = /^shard-\d{4}\.json$/;
43
+ async function readEmbeddingIndexState(orchestrator, errors) {
44
+ try {
45
+ const memoryDir = orchestrator.config?.memoryDir;
46
+ if (!memoryDir) return void 0;
47
+ const stateDir = path.join(memoryDir, "state");
48
+ let legacyFileBytes = null;
49
+ try {
50
+ legacyFileBytes = (await fs.stat(path.join(stateDir, "embeddings.json"))).size;
51
+ } catch (err) {
52
+ if (err.code !== "ENOENT") throw err;
53
+ }
54
+ let shardCount = 0;
55
+ let shardBytes = 0;
56
+ let shardNames = [];
57
+ try {
58
+ shardNames = await fs.readdir(path.join(stateDir, "embeddings"));
59
+ } catch (err) {
60
+ if (err.code !== "ENOENT") throw err;
61
+ }
62
+ for (const name of shardNames) {
63
+ if (!EMBEDDING_SHARD_PATTERN.test(name)) continue;
64
+ shardCount += 1;
65
+ shardBytes += (await fs.stat(path.join(stateDir, "embeddings", name))).size;
66
+ }
67
+ let status = null;
68
+ try {
69
+ const parsed = JSON.parse(
70
+ await fs.readFile(path.join(stateDir, "embedding-fallback-status.json"), "utf-8")
71
+ );
72
+ if (parsed && typeof parsed === "object") status = parsed;
73
+ } catch (err) {
74
+ if (err.code !== "ENOENT") throw err;
75
+ }
76
+ if (legacyFileBytes === null && shardCount === 0 && status === null) return void 0;
77
+ return { legacyFileBytes, shardCount, shardBytes, status };
78
+ } catch (err) {
79
+ errors.push(`embeddingIndex: ${describeError(err)}`);
80
+ return void 0;
81
+ }
82
+ }
40
83
  function readBufferState(orchestrator, errors) {
41
84
  try {
42
85
  const getTurns = orchestrator.buffer?.getTurns;
@@ -257,4 +300,4 @@ function describeError(err) {
257
300
  export {
258
301
  gatherConsoleState
259
302
  };
260
- //# sourceMappingURL=chunk-G6SVZWPB.js.map
303
+ //# sourceMappingURL=chunk-PZX3AQLF.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/console/state.ts"],"sourcesContent":["/**\n * Structured engine-state aggregator for the operator console (issue #688).\n *\n * This module is the data layer for the upcoming console TUI / HTTP /\n * MCP surfaces. It collects a point-in-time snapshot of the engine's\n * runtime state — buffer contents, extraction queue depth, recent\n * dedup decisions, the tail of the maintenance/observation ledger,\n * QMD probe status, and daemon metadata — into a single\n * JSON-serializable shape.\n *\n * Design contract:\n * - Each subsystem read is wrapped in try/catch so one failure\n * never crashes the whole snapshot. Failed reads return null /\n * empty values and append a string to `errors`.\n * - The output MUST be JSON-serializable so the CLI / HTTP / MCP\n * surfaces can pipe it directly through `JSON.stringify`.\n * - Read-only: this module never mutates orchestrator state.\n *\n * PR 1/3 of issue #688 wires only the data layer + a CLI flag. The\n * TUI (PR 2/3), HTTP `/console/state`, MCP `engram.console_state`,\n * SSE live updates, and trace replay (PR 3/3) land separately.\n */\n\nimport { promises as fs, createReadStream } from \"node:fs\";\nimport { createInterface } from \"node:readline\";\nimport path from \"node:path\";\n\n/**\n * Public state read off the orchestrator. We intentionally type this\n * as a permissive duck-typed shape rather than importing the concrete\n * `Orchestrator` class — the aggregator must tolerate missing fields\n * (e.g. tests that pass a stub) without throwing. Each accessor is\n * defensively read at call time.\n */\nexport interface ConsoleStateOrchestratorLike {\n config?: {\n memoryDir?: string;\n };\n buffer?: {\n getTurns?: (bufferKey?: string) => Array<{ content?: string }>;\n };\n qmd?: {\n debugStatus?: () => string;\n isAvailable?: () => boolean;\n isDaemonMode?: () => boolean;\n };\n /**\n * Optional console-specific read surface added by future slices.\n * The aggregator falls back to placeholders when these are absent\n * so PR 1/3 ships without coupling to private orchestrator state.\n */\n getConsoleExtractionQueueDepth?: () => number;\n getConsoleExtractionRecentVerdicts?: () => ReadonlyArray<ConsoleExtractionVerdict>;\n getConsoleDedupRecentDecisions?: () => ReadonlyArray<ConsoleDedupDecision>;\n /**\n * Process / daemon metadata. Hosts that run remnic as a long-lived\n * daemon (gateway, MCP server) can override these; otherwise the\n * aggregator falls back to `process.uptime()` and the package\n * version read from disk.\n */\n getConsoleDaemonInfo?: () => ConsoleDaemonInfo;\n /**\n * Optional faithfulness gate distribution (issue #1576). Returns the\n * per-orchestrator running counters when the gate is active, or undefined\n * when the gate is off (so the snapshot omits the block).\n */\n getConsoleFaithfulnessDistribution?: () => ConsoleFaithfulnessDistribution | undefined;\n}\n\nexport interface ConsoleBufferState {\n /** Number of turns currently held in the default buffer slot. */\n turnsCount: number;\n /** Approximate byte size of buffered content (UTF-8). */\n byteCount: number;\n}\n\nexport interface ConsoleExtractionVerdict {\n /** ISO-8601 timestamp the verdict was recorded. */\n ts: string;\n /** Verdict kind — typically \"accept\" | \"reject\" | \"defer\". */\n kind: string;\n /** Optional short reason from the judge or fallback. */\n reason?: string;\n}\n\nexport interface ConsoleExtractionQueueState {\n /** Number of pending extraction tasks queued in the orchestrator. */\n depth: number;\n /** Most recent judge verdicts, newest last. Capped at 25 entries. */\n recentVerdicts: ConsoleExtractionVerdict[];\n}\n\nexport interface ConsoleDedupDecision {\n /** ISO-8601 timestamp the decision was recorded. */\n ts: string;\n /** Outcome of the dedup check — \"duplicate\" | \"novel\" | etc. */\n decision: string;\n /** Optional content fingerprint (first 16 chars of a hash). */\n fingerprint?: string;\n /** Optional similarity score that drove the decision. */\n similarity?: number;\n}\n\nexport interface ConsoleMaintenanceLedgerEvent {\n /** ISO-8601 timestamp from the ledger row. */\n ts: string;\n /** Event category (e.g. \"EXTRACTION_JUDGE_VERDICT\"). */\n category: string;\n /** Compact one-line summary. */\n summary: string;\n}\n\nexport interface ConsoleQmdProbeState {\n /** Whether QMD is reachable via CLI or daemon. */\n available: boolean;\n /** Whether the daemon transport is in use. */\n daemonMode: boolean;\n /** Raw debug-status string from `qmd.debugStatus()`. */\n debug: string;\n}\n\nexport interface ConsoleDaemonInfo {\n /** Process uptime in milliseconds. */\n uptimeMs: number;\n /** Package / daemon version (best-effort). */\n version: string;\n}\n\n/**\n * Faithfulness gate verdict distribution (issue #1576). Surfaced via\n * console_state so `remnic doctor` can render how the gate is performing.\n */\nexport interface ConsoleFaithfulnessDistribution {\n entailed: number;\n contradicted: number;\n unsupported: number;\n unchecked: number;\n skippedNoSpan: number;\n}\n\nexport interface ConsoleStateSnapshot {\n /** ISO-8601 capture timestamp. */\n capturedAt: string;\n bufferState: ConsoleBufferState;\n extractionQueue: ConsoleExtractionQueueState;\n dedupRecent: ConsoleDedupDecision[];\n maintenanceLedgerTail: ConsoleMaintenanceLedgerEvent[];\n qmdProbe: ConsoleQmdProbeState;\n daemon: ConsoleDaemonInfo;\n /** Faithfulness gate distribution (issue #1576). Absent when the gate is off. */\n faithfulness?: ConsoleFaithfulnessDistribution;\n /**\n * Embedding-fallback index layout + durable diagnostics (issue #3146).\n * Absent when the memory dir carries no embedding index state at all.\n */\n embeddingIndex?: ConsoleEmbeddingIndexState;\n /**\n * Subsystem read errors. One entry per failed reader keyed by\n * subsystem name (e.g. `\"bufferState: ...\"`). An empty array means\n * every section was read cleanly.\n */\n errors: string[];\n}\n\n/** Loose view of `state/embedding-fallback-status.json` (written by EmbeddingFallback). */\nexport interface ConsoleEmbeddingIndexStatus {\n failureCount?: number;\n lastWriteFailure?: { ts: string; kind: string; message: string; memoryId?: string };\n lastReadRecovery?: { ts: string; message: string };\n lastSuccessAt?: string;\n}\n\n/** Embedding-fallback index layout + durable failure diagnostics (issue #3146). */\nexport interface ConsoleEmbeddingIndexState {\n /** Size in bytes of the legacy single-file index, when present. */\n legacyFileBytes: number | null;\n /** Shard files under `state/embeddings/` (indexes past the single-file budget). */\n shardCount: number;\n shardBytes: number;\n /** Durable diagnostics written by EmbeddingFallback, when present. */\n status: ConsoleEmbeddingIndexStatus | null;\n}\n\nconst MAX_LEDGER_TAIL = 50;\nconst MAX_VERDICT_TAIL = 25;\nconst MAX_DEDUP_TAIL = 10;\n\n/**\n * Gather a `ConsoleStateSnapshot` from the orchestrator. Each\n * subsystem read is independent; a thrown error in one reader is\n * captured in `errors` and the corresponding section is filled with\n * empty / placeholder values.\n */\nexport async function gatherConsoleState(\n orchestrator: ConsoleStateOrchestratorLike,\n): Promise<ConsoleStateSnapshot> {\n const errors: string[] = [];\n const capturedAt = new Date().toISOString();\n\n const bufferState = readBufferState(orchestrator, errors);\n const extractionQueue = readExtractionQueue(orchestrator, errors);\n const dedupRecent = readDedupRecent(orchestrator, errors);\n const maintenanceLedgerTail = await readMaintenanceLedgerTail(\n orchestrator,\n errors,\n );\n const qmdProbe = readQmdProbe(orchestrator, errors);\n const daemon = readDaemonInfo(orchestrator, errors);\n const embeddingIndex = await readEmbeddingIndexState(orchestrator, errors);\n\n // Faithfulness gate distribution (issue #1576). Optional — absent when\n // the gate is off or the orchestrator does not expose the accessor.\n let faithfulness: ConsoleFaithfulnessDistribution | undefined;\n try {\n if (typeof orchestrator.getConsoleFaithfulnessDistribution === \"function\") {\n faithfulness = orchestrator.getConsoleFaithfulnessDistribution();\n }\n } catch (err) {\n errors.push(`faithfulness: ${describeError(err)}`);\n }\n\n return {\n capturedAt,\n bufferState,\n extractionQueue,\n dedupRecent,\n maintenanceLedgerTail,\n qmdProbe,\n daemon,\n ...(faithfulness ? { faithfulness } : {}),\n ...(embeddingIndex ? { embeddingIndex } : {}),\n errors,\n };\n}\n\nconst EMBEDDING_SHARD_PATTERN = /^shard-\\d{4}\\.json$/;\n\n/**\n * Read the embedding-fallback index layout and its durable failure\n * diagnostics straight off disk (issue #3146): legacy file size, shard\n * count/bytes under `state/embeddings/`, and the status file\n * EmbeddingFallback writes on write failures and corrupt-file recovery.\n * Returns undefined when the memory dir carries no index state at all.\n */\nasync function readEmbeddingIndexState(\n orchestrator: ConsoleStateOrchestratorLike,\n errors: string[],\n): Promise<ConsoleEmbeddingIndexState | undefined> {\n try {\n const memoryDir = orchestrator.config?.memoryDir;\n if (!memoryDir) return undefined;\n const stateDir = path.join(memoryDir, \"state\");\n\n let legacyFileBytes: number | null = null;\n try {\n legacyFileBytes = (await fs.stat(path.join(stateDir, \"embeddings.json\"))).size;\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code !== \"ENOENT\") throw err;\n }\n\n let shardCount = 0;\n let shardBytes = 0;\n let shardNames: string[] = [];\n try {\n shardNames = await fs.readdir(path.join(stateDir, \"embeddings\"));\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code !== \"ENOENT\") throw err;\n }\n for (const name of shardNames) {\n if (!EMBEDDING_SHARD_PATTERN.test(name)) continue;\n shardCount += 1;\n shardBytes += (await fs.stat(path.join(stateDir, \"embeddings\", name))).size;\n }\n\n let status: ConsoleEmbeddingIndexStatus | null = null;\n try {\n const parsed: unknown = JSON.parse(\n await fs.readFile(path.join(stateDir, \"embedding-fallback-status.json\"), \"utf-8\"),\n );\n if (parsed && typeof parsed === \"object\") status = parsed as ConsoleEmbeddingIndexStatus;\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code !== \"ENOENT\") throw err;\n }\n\n if (legacyFileBytes === null && shardCount === 0 && status === null) return undefined;\n return { legacyFileBytes, shardCount, shardBytes, status };\n } catch (err) {\n errors.push(`embeddingIndex: ${describeError(err)}`);\n return undefined;\n }\n}\n\nfunction readBufferState(\n orchestrator: ConsoleStateOrchestratorLike,\n errors: string[],\n): ConsoleBufferState {\n try {\n const getTurns = orchestrator.buffer?.getTurns;\n if (typeof getTurns !== \"function\") {\n return { turnsCount: 0, byteCount: 0 };\n }\n const turns = getTurns.call(orchestrator.buffer) ?? [];\n let byteCount = 0;\n for (const turn of turns) {\n const content = typeof turn?.content === \"string\" ? turn.content : \"\";\n byteCount += Buffer.byteLength(content, \"utf8\");\n }\n return { turnsCount: turns.length, byteCount };\n } catch (err) {\n errors.push(`bufferState: ${describeError(err)}`);\n return { turnsCount: 0, byteCount: 0 };\n }\n}\n\nfunction readExtractionQueue(\n orchestrator: ConsoleStateOrchestratorLike,\n errors: string[],\n): ConsoleExtractionQueueState {\n try {\n const depth =\n typeof orchestrator.getConsoleExtractionQueueDepth === \"function\"\n ? orchestrator.getConsoleExtractionQueueDepth()\n : 0;\n const verdicts =\n typeof orchestrator.getConsoleExtractionRecentVerdicts === \"function\"\n ? orchestrator.getConsoleExtractionRecentVerdicts()\n : [];\n const recentVerdicts = (verdicts ?? [])\n .slice(-MAX_VERDICT_TAIL)\n .map((v) => ({\n ts: typeof v?.ts === \"string\" ? v.ts : \"\",\n kind: typeof v?.kind === \"string\" ? v.kind : \"unknown\",\n ...(typeof v?.reason === \"string\" ? { reason: v.reason } : {}),\n }));\n return { depth: Number.isFinite(depth) ? depth : 0, recentVerdicts };\n } catch (err) {\n errors.push(`extractionQueue: ${describeError(err)}`);\n return { depth: 0, recentVerdicts: [] };\n }\n}\n\nfunction readDedupRecent(\n orchestrator: ConsoleStateOrchestratorLike,\n errors: string[],\n): ConsoleDedupDecision[] {\n try {\n // Cursor Medium: call directly on `orchestrator` to preserve the\n // `this` binding. Extracting the method into a local and invoking\n // it bare loses `this`, so a non-arrow implementation that\n // references `this` would fail at runtime. Mirrors how\n // `readExtractionQueue` and `readMaintenanceLedgerTail` invoke\n // their orchestrator methods.\n if (typeof orchestrator.getConsoleDedupRecentDecisions !== \"function\") return [];\n const raw = orchestrator.getConsoleDedupRecentDecisions() ?? [];\n return raw.slice(-MAX_DEDUP_TAIL).map((d) => ({\n ts: typeof d?.ts === \"string\" ? d.ts : \"\",\n decision: typeof d?.decision === \"string\" ? d.decision : \"unknown\",\n ...(typeof d?.fingerprint === \"string\"\n ? { fingerprint: d.fingerprint }\n : {}),\n ...(typeof d?.similarity === \"number\" && Number.isFinite(d.similarity)\n ? { similarity: d.similarity }\n : {}),\n }));\n } catch (err) {\n errors.push(`dedupRecent: ${describeError(err)}`);\n return [];\n }\n}\n\n/**\n * Stream a JSONL file line-by-line, parse each row, project it into a\n * console event, and keep only the `topN` most-recent items by `ts`\n * (descending). Memory is bounded at O(2 * topN) regardless of file\n * size — we sort-and-truncate whenever the working buffer grows past\n * `2 * topN`. This satisfies BOTH:\n *\n * 1. \"Don't load the whole file into memory\" — streaming + bounded\n * buffer means a multi-GB ledger never blows up RAM.\n * 2. \"Don't miss recent rows just because the file isn't sorted by\n * recency\" — `rebuilt-observations.jsonl` is written sorted by\n * `(sessionKey, hour)`, NOT by global ts, so a byte-tail-only\n * read silently dropped recent-but-lexicographically-earlier\n * sessions. Streaming top-N visits every row and keeps the\n * globally-most-recent ones.\n *\n * Returns an array sorted oldest-first within the top-N window. Rows\n * with no parseable `ts` are dropped (they would otherwise compare\n * undefined under any sort).\n */\nasync function streamLedgerTopN<T extends { ts: string }>(\n ledgerPath: string,\n topN: number,\n project: (parsed: Record<string, unknown>) => T | null,\n): Promise<T[]> {\n let stream: ReturnType<typeof createReadStream>;\n try {\n // `fs.access`-style probe so we can quietly return `[]` for\n // ENOENT without hitting the readline error path.\n await fs.stat(ledgerPath);\n } catch (err) {\n const code = (err as NodeJS.ErrnoException).code;\n if (code === \"ENOENT\") return [];\n throw err;\n }\n try {\n stream = createReadStream(ledgerPath, { encoding: \"utf-8\" });\n } catch (err) {\n const code = (err as NodeJS.ErrnoException).code;\n if (code === \"ENOENT\") return [];\n throw err;\n }\n const rl = createInterface({ input: stream, crlfDelay: Infinity });\n const cap = Math.max(1, topN) * 2;\n const buf: T[] = [];\n const truncate = () => {\n // Sort descending by ts, keep top-N, drop the rest.\n buf.sort((a, b) => {\n const aMs = Date.parse(a.ts);\n const bMs = Date.parse(b.ts);\n if (Number.isFinite(aMs) && Number.isFinite(bMs)) return bMs - aMs;\n if (Number.isFinite(aMs)) return -1;\n if (Number.isFinite(bMs)) return 1;\n return 0;\n });\n if (buf.length > topN) buf.length = topN;\n };\n try {\n for await (const line of rl) {\n const trimmed = line.trim();\n if (!trimmed) continue;\n let parsed: unknown;\n try {\n parsed = JSON.parse(trimmed);\n } catch {\n continue;\n }\n if (typeof parsed !== \"object\" || parsed === null || Array.isArray(parsed)) {\n continue;\n }\n const event = project(parsed as Record<string, unknown>);\n if (event === null) continue;\n // Drop rows we couldn't even date-stamp — they can't be sorted\n // meaningfully against the rest of the corpus.\n if (!event.ts || !Number.isFinite(Date.parse(event.ts))) continue;\n buf.push(event);\n if (buf.length >= cap) truncate();\n }\n } finally {\n rl.close();\n stream.close();\n }\n truncate();\n return buf.reverse(); // oldest-first within the top-N window\n}\n\nfunction projectLedgerRow(p: Record<string, unknown>): ConsoleMaintenanceLedgerEvent | null {\n // The two canonical writers produce different row shapes:\n // - extraction-judge-telemetry: `{ts, verdictKind, reason, candidateCategory, ...}`\n // - rebuild-observations / migrate-observations:\n // `{sessionKey, hour, turnCount, userTurns, assistantTurns, rebuiltAt}`\n // Map both into the canonical {ts, category, summary} shape.\n const ts =\n typeof p.ts === \"string\" && p.ts.length > 0\n ? p.ts\n : typeof p.hour === \"string\" && p.hour.length > 0\n ? p.hour\n : typeof p.rebuiltAt === \"string\" && p.rebuiltAt.length > 0\n ? p.rebuiltAt\n : \"\";\n const category =\n typeof p.category === \"string\" && p.category.length > 0\n ? p.category\n : typeof p.verdictKind === \"string\"\n ? \"judge-verdict\"\n : typeof p.turnCount === \"number\"\n ? \"observation\"\n : \"unknown\";\n const summary = summarizeLedgerEvent(p);\n return { ts, category, summary };\n}\n\nasync function readMaintenanceLedgerTail(\n orchestrator: ConsoleStateOrchestratorLike,\n errors: string[],\n): Promise<ConsoleMaintenanceLedgerEvent[]> {\n try {\n const memoryDir = orchestrator.config?.memoryDir;\n if (!memoryDir || typeof memoryDir !== \"string\") return [];\n const ledgerDir = path.join(memoryDir, \"state\", \"observation-ledger\");\n // Codex review converged on two competing constraints:\n // 1. Don't load the whole file into memory (multi-GB ledgers\n // would OOM the console surface).\n // 2. Don't miss recent rows just because the file isn't sorted\n // by recency (`rebuilt-observations.jsonl` is sorted by\n // sessionKey/hour, so byte-tail reads silently drop recent\n // lexicographically-earlier sessions).\n // The right answer is a streaming bounded top-N: visit every row,\n // but keep only the MAX_LEDGER_TAIL most-recent in memory at any\n // time. Memory stays O(MAX_LEDGER_TAIL); recency ordering is\n // globally correct.\n const verdictsTopN = await streamLedgerTopN(\n path.join(ledgerDir, \"extraction-judge-verdicts.jsonl\"),\n MAX_LEDGER_TAIL,\n projectLedgerRow,\n );\n const rebuiltTopN = await streamLedgerTopN(\n path.join(ledgerDir, \"rebuilt-observations.jsonl\"),\n MAX_LEDGER_TAIL,\n projectLedgerRow,\n );\n // Merge the two source top-N windows and select the global\n // top-N. Both inputs already arrive oldest-first within their\n // respective windows; sort the merged set descending by ts and\n // take the most-recent MAX_LEDGER_TAIL.\n const events: ConsoleMaintenanceLedgerEvent[] = [...verdictsTopN, ...rebuiltTopN];\n if (events.length === 0) return [];\n events.sort((a, b) => {\n const aMs = Date.parse(a.ts);\n const bMs = Date.parse(b.ts);\n if (Number.isFinite(aMs) && Number.isFinite(bMs)) return bMs - aMs;\n if (Number.isFinite(aMs)) return -1;\n if (Number.isFinite(bMs)) return 1;\n return 0;\n });\n const tail = events.slice(0, MAX_LEDGER_TAIL);\n // Reverse so the caller sees oldest-first within the tail window.\n return tail.reverse();\n } catch (err) {\n errors.push(`maintenanceLedgerTail: ${describeError(err)}`);\n return [];\n }\n}\n\nfunction summarizeLedgerEvent(p: Record<string, unknown>): string {\n const parts: string[] = [];\n // Judge-verdict rows.\n if (typeof p.verdictKind === \"string\") parts.push(`verdict=${p.verdictKind}`);\n if (typeof p.reason === \"string\" && p.reason.length > 0) {\n const trimmed = p.reason.length > 80 ? `${p.reason.slice(0, 80)}…` : p.reason;\n parts.push(`reason=${trimmed}`);\n }\n if (typeof p.candidateCategory === \"string\") {\n parts.push(`cat=${p.candidateCategory}`);\n }\n // Canonical rebuilt-observations rows (codex P2).\n if (typeof p.sessionKey === \"string\" && p.sessionKey.length > 0) {\n parts.push(`session=${p.sessionKey}`);\n }\n if (typeof p.turnCount === \"number\" && Number.isFinite(p.turnCount)) {\n parts.push(`turns=${p.turnCount}`);\n }\n if (typeof p.userTurns === \"number\" && Number.isFinite(p.userTurns)) {\n parts.push(`u=${p.userTurns}`);\n }\n if (typeof p.assistantTurns === \"number\" && Number.isFinite(p.assistantTurns)) {\n parts.push(`a=${p.assistantTurns}`);\n }\n if (parts.length === 0) {\n return typeof p.category === \"string\" ? p.category : \"event\";\n }\n return parts.join(\" \");\n}\n\nfunction readQmdProbe(\n orchestrator: ConsoleStateOrchestratorLike,\n errors: string[],\n): ConsoleQmdProbeState {\n try {\n const qmd = orchestrator.qmd;\n if (!qmd) {\n return { available: false, daemonMode: false, debug: \"qmd unavailable\" };\n }\n const available =\n typeof qmd.isAvailable === \"function\" ? qmd.isAvailable() : false;\n const daemonMode =\n typeof qmd.isDaemonMode === \"function\" ? qmd.isDaemonMode() : false;\n const debug =\n typeof qmd.debugStatus === \"function\" ? qmd.debugStatus() : \"\";\n return { available, daemonMode, debug };\n } catch (err) {\n errors.push(`qmdProbe: ${describeError(err)}`);\n return { available: false, daemonMode: false, debug: \"\" };\n }\n}\n\nfunction readDaemonInfo(\n orchestrator: ConsoleStateOrchestratorLike,\n errors: string[],\n): ConsoleDaemonInfo {\n try {\n if (typeof orchestrator.getConsoleDaemonInfo === \"function\") {\n const info = orchestrator.getConsoleDaemonInfo();\n return {\n uptimeMs: Number.isFinite(info?.uptimeMs) ? info.uptimeMs : 0,\n version: typeof info?.version === \"string\" ? info.version : \"unknown\",\n };\n }\n // Fallback: process uptime + best-effort package version. This is\n // only meaningful when the orchestrator runs in the same process\n // as the CLI (which is the case for `remnic console --state-only`).\n const uptimeMs = Math.round((process.uptime?.() ?? 0) * 1000);\n return { uptimeMs, version: resolvePackageVersion() };\n } catch (err) {\n errors.push(`daemon: ${describeError(err)}`);\n return { uptimeMs: 0, version: \"unknown\" };\n }\n}\n\nfunction resolvePackageVersion(): string {\n // Best-effort, sync, never throws. We avoid importing package.json\n // statically because tsup bundles into a single file at runtime.\n try {\n const env = process.env?.REMNIC_VERSION;\n if (typeof env === \"string\" && env.length > 0) return env;\n } catch {\n // ignore\n }\n return \"unknown\";\n}\n\nfunction describeError(err: unknown): string {\n if (err instanceof Error) return err.message;\n try {\n return String(err);\n } catch {\n return \"unknown error\";\n }\n}\n"],"mappings":";AAuBA,SAAS,YAAY,IAAI,wBAAwB;AACjD,SAAS,uBAAuB;AAChC,OAAO,UAAU;AA8JjB,IAAM,kBAAkB;AACxB,IAAM,mBAAmB;AACzB,IAAM,iBAAiB;AAQvB,eAAsB,mBACpB,cAC+B;AAC/B,QAAM,SAAmB,CAAC;AAC1B,QAAM,cAAa,oBAAI,KAAK,GAAE,YAAY;AAE1C,QAAM,cAAc,gBAAgB,cAAc,MAAM;AACxD,QAAM,kBAAkB,oBAAoB,cAAc,MAAM;AAChE,QAAM,cAAc,gBAAgB,cAAc,MAAM;AACxD,QAAM,wBAAwB,MAAM;AAAA,IAClC;AAAA,IACA;AAAA,EACF;AACA,QAAM,WAAW,aAAa,cAAc,MAAM;AAClD,QAAM,SAAS,eAAe,cAAc,MAAM;AAClD,QAAM,iBAAiB,MAAM,wBAAwB,cAAc,MAAM;A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,WAAO;AAAA,EACT;AACF;","names":[]}
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  SupportPassportCreateGrantRequestSchema,
3
3
  defineOperation
4
- } from "./chunk-FOH7AMMI.js";
4
+ } from "./chunk-CALBQ2NG.js";
5
5
  import {
6
6
  SupportPassportCardCategorySchema,
7
7
  SupportPassportMemoryIdSchema,
@@ -220,4 +220,4 @@ var supportPassportGrantAskOperation = defineOperation({
220
220
  result: await ctx.service.supportPassportAskGrant(grantId, secret, question, ctx.abortSignal)
221
221
  })
222
222
  });
223
- //# sourceMappingURL=chunk-HBBHL4YF.js.map
223
+ //# sourceMappingURL=chunk-QOXNTKXB.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  parseFrontmatter
3
- } from "./chunk-FRCESVV6.js";
3
+ } from "./chunk-4HUCP4R4.js";
4
4
  import {
5
5
  activityDigestPath,
6
6
  isValidActivityDate
@@ -199,4 +199,4 @@ export {
199
199
  buildStandup,
200
200
  standupHelp
201
201
  };
202
- //# sourceMappingURL=chunk-CUCWX3MO.js.map
202
+ //# sourceMappingURL=chunk-QZLCVO2V.js.map
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-XCB6QDL6.js";
4
4
  import {
5
5
  composeMemoryEnvelope
6
- } from "./chunk-GDYU6VF4.js";
6
+ } from "./chunk-5AYUHSAU.js";
7
7
  import {
8
8
  judgeContradictionPairs,
9
9
  resolveScanStorage
@@ -876,4 +876,4 @@ export {
876
876
  isValidResolutionVerb,
877
877
  executeResolution
878
878
  };
879
- //# sourceMappingURL=chunk-NE7I2RCT.js.map
879
+ //# sourceMappingURL=chunk-R3X2T2LP.js.map
@@ -1,3 +1,10 @@
1
+ import {
2
+ isObjectRecord,
3
+ orderedLocalServers
4
+ } from "./chunk-U4LUIE6Y.js";
5
+ import {
6
+ ChatTransport
7
+ } from "./chunk-JUXOTY6J.js";
1
8
  import {
2
9
  SingleFlightProbe,
3
10
  extractNonRecoverableBackendReason,
@@ -8,13 +15,6 @@ import {
8
15
  resolveUnavailableVerdict,
9
16
  waitForRetryBackoff
10
17
  } from "./chunk-QM2SPLKQ.js";
11
- import {
12
- isObjectRecord,
13
- orderedLocalServers
14
- } from "./chunk-U4LUIE6Y.js";
15
- import {
16
- ChatTransport
17
- } from "./chunk-JUXOTY6J.js";
18
18
  import {
19
19
  estimateTokenCount
20
20
  } from "./chunk-TOTT6S2V.js";
@@ -1050,4 +1050,4 @@ var LocalLlmClient = class _LocalLlmClient {
1050
1050
  export {
1051
1051
  LocalLlmClient
1052
1052
  };
1053
- //# sourceMappingURL=chunk-S7GCT7NU.js.map
1053
+ //# sourceMappingURL=chunk-RBITPCMK.js.map
@@ -5,13 +5,13 @@ import {
5
5
  citationTemplateFingerprint,
6
6
  isCachedIdentityReusable,
7
7
  isReconcileMemoryIdentity
8
- } from "./chunk-S3YM4SZQ.js";
8
+ } from "./chunk-N7QV3CMX.js";
9
9
  import {
10
10
  offlineSyncStorageForSnapshot
11
- } from "./chunk-MOQPEFLN.js";
11
+ } from "./chunk-UP75KL3L.js";
12
12
  import {
13
13
  iterateOfflineSyncSnapshotFileRecords
14
- } from "./chunk-WQZZDN5M.js";
14
+ } from "./chunk-IVEHY2VT.js";
15
15
  import {
16
16
  createPersistedSupportPassportPrivateFileExclusion
17
17
  } from "./chunk-PWPIERBM.js";
@@ -250,4 +250,4 @@ export {
250
250
  retainExcludedClassifications,
251
251
  createOfflineSyncManifestStream
252
252
  };
253
- //# sourceMappingURL=chunk-EVBI7S4J.js.map
253
+ //# sourceMappingURL=chunk-RMDGAAZF.js.map
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  writeGraphJsonlAtomic
3
- } from "./chunk-37S3IMYB.js";
3
+ } from "./chunk-DGS34QSY.js";
4
4
  import {
5
5
  graphFilePath,
6
6
  graphsDir,
7
7
  readEdgesStrict
8
- } from "./chunk-ICZQG4XE.js";
8
+ } from "./chunk-5FAGCOZD.js";
9
9
  import {
10
10
  assertGraphLockHeld,
11
11
  withGraphWriteLock,
@@ -215,4 +215,4 @@ export {
215
215
  discoverGraphNamespaceRoots,
216
216
  runGraphEdgeDecayMaintenanceAcrossNamespaces
217
217
  };
218
- //# sourceMappingURL=chunk-BJRAELDH.js.map
218
+ //# sourceMappingURL=chunk-SCXURCVT.js.map
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  StorageManager
3
- } from "./chunk-FRCESVV6.js";
3
+ } from "./chunk-4HUCP4R4.js";
4
4
  import {
5
5
  composeMemoryEnvelope
6
- } from "./chunk-GDYU6VF4.js";
6
+ } from "./chunk-5AYUHSAU.js";
7
7
  import {
8
8
  isErrnoCode
9
9
  } from "./chunk-KNA3BXXL.js";
@@ -546,4 +546,4 @@ export {
546
546
  setSemanticRulePromotionTestHooks,
547
547
  promoteSemanticRuleFromMemory
548
548
  };
549
- //# sourceMappingURL=chunk-EQ6YOIKO.js.map
549
+ //# sourceMappingURL=chunk-ST2RQUXC.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  parseEntityFile
3
- } from "./chunk-FRCESVV6.js";
3
+ } from "./chunk-4HUCP4R4.js";
4
4
  import {
5
5
  inferMemoryStatus
6
6
  } from "./chunk-7RJUVTVF.js";
@@ -253,4 +253,4 @@ export {
253
253
  WHO_KNOWS_MCP_TOOLS,
254
254
  handleWhoKnowsHttpQuery
255
255
  };
256
- //# sourceMappingURL=chunk-CS52MFDV.js.map
256
+ //# sourceMappingURL=chunk-SZG4WFAG.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  StorageManager
3
- } from "./chunk-FRCESVV6.js";
3
+ } from "./chunk-4HUCP4R4.js";
4
4
  import {
5
5
  keyring_exports,
6
6
  secureStoreDir
@@ -412,4 +412,4 @@ export {
412
412
  resolveNamespaceStorageRoot,
413
413
  NamespaceStorageRouter
414
414
  };
415
- //# sourceMappingURL=chunk-BFO3IR56.js.map
415
+ //# sourceMappingURL=chunk-TPEZ2SHV.js.map