@remnic/core 10.0.191 → 10.0.193

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 (272) hide show
  1. package/dist/abstraction-nodes.js +4 -4
  2. package/dist/access-admin-ops-surface.js +62 -62
  3. package/dist/access-cli.js +62 -62
  4. package/dist/access-extraction-force-flush-preempt.js +62 -62
  5. package/dist/access-extraction-force-flush.js +62 -62
  6. package/dist/access-http-briefing.js +62 -62
  7. package/dist/access-http-query.js +62 -62
  8. package/dist/access-http.js +62 -62
  9. package/dist/access-identity-continuity-surface.js +62 -62
  10. package/dist/access-lcm-surface.js +62 -62
  11. package/dist/access-mcp.js +62 -62
  12. package/dist/access-observe-write-surface.js +62 -62
  13. package/dist/access-operations-batch.js +62 -62
  14. package/dist/access-operations.js +62 -62
  15. package/dist/access-recall-concurrency.js +62 -62
  16. package/dist/access-recall-diagnostics.js +2 -2
  17. package/dist/access-recall-response.js +62 -62
  18. package/dist/access-recall-surface.js +62 -62
  19. package/dist/access-service.js +62 -62
  20. package/dist/active-recall.js +11 -11
  21. package/dist/briefing.js +11 -11
  22. package/dist/buffer-persistence.d.ts +7 -0
  23. package/dist/buffer-persistence.d.ts.map +1 -1
  24. package/dist/buffer-persistence.js +1 -1
  25. package/dist/buffer.d.ts +2 -0
  26. package/dist/buffer.d.ts.map +1 -1
  27. package/dist/buffer.js +6 -6
  28. package/dist/{capsule-merge-BADOICNP.js → capsule-merge-3FARYIHP.js} +5 -5
  29. package/dist/causal-consolidation.js +12 -12
  30. package/dist/{chunk-IMSLPQJB.js → chunk-2QW5HPKU.js} +2 -2
  31. package/dist/{chunk-KNYUEYB6.js → chunk-2YJ2ST23.js} +2 -2
  32. package/dist/{chunk-BZ5VO7KO.js → chunk-3BICT225.js} +2 -2
  33. package/dist/{chunk-UWKHLWUE.js → chunk-3RZ4GDOH.js} +2 -2
  34. package/dist/{chunk-ODIBCZLG.js → chunk-3YID7KZ6.js} +2 -2
  35. package/dist/{chunk-4SUNBSPD.js → chunk-4EAVEDLG.js} +9 -9
  36. package/dist/{chunk-TLRIRISJ.js → chunk-4LCA2GEX.js} +2 -2
  37. package/dist/{chunk-4N33L4HY.js → chunk-5GIYIYJI.js} +2 -2
  38. package/dist/{chunk-JQCEG54G.js → chunk-75K6DRPN.js} +12 -9
  39. package/dist/chunk-75K6DRPN.js.map +1 -0
  40. package/dist/{chunk-ZDLVHGIC.js → chunk-7EP4FURO.js} +2 -2
  41. package/dist/{chunk-CAUADFDM.js → chunk-7SOKOEAZ.js} +2 -2
  42. package/dist/{chunk-7Q74DD2W.js → chunk-7V6GNQC2.js} +2 -2
  43. package/dist/{chunk-C6YKKH73.js → chunk-AALJHIKH.js} +3 -3
  44. package/dist/{chunk-C2UN2CY7.js → chunk-AJ7JHHRY.js} +2 -2
  45. package/dist/{chunk-QSVWIKNY.js → chunk-BDFSVUUZ.js} +9 -7
  46. package/dist/chunk-BDFSVUUZ.js.map +1 -0
  47. package/dist/{chunk-3DADRUGW.js → chunk-BGA7S5EF.js} +3 -3
  48. package/dist/{chunk-7GMOB4FF.js → chunk-CJSTQNE5.js} +2 -2
  49. package/dist/{chunk-6YAQ3AJ5.js → chunk-DYUPSTCV.js} +3 -3
  50. package/dist/{chunk-E5QI6C6C.js → chunk-E3LGAZJC.js} +3 -3
  51. package/dist/{chunk-NL5KFA5N.js → chunk-EEA2RM4B.js} +2 -2
  52. package/dist/{chunk-BL7WULM5.js → chunk-FDO7ITP6.js} +2 -2
  53. package/dist/{chunk-7BIGO6ZL.js → chunk-FGFU6J26.js} +3 -3
  54. package/dist/{chunk-6TIQLG7I.js → chunk-FKHXXL42.js} +2 -2
  55. package/dist/{chunk-QPD7EYGI.js → chunk-G2MS56KM.js} +2 -2
  56. package/dist/{chunk-FFTGLWHI.js → chunk-GH7IKABD.js} +2 -2
  57. package/dist/{chunk-RC2TVYY2.js → chunk-GYCUX3N4.js} +2 -2
  58. package/dist/{chunk-CJYVVVOG.js → chunk-HEJFE3BC.js} +3 -3
  59. package/dist/{chunk-KM4QO4LN.js → chunk-HLQANATZ.js} +2 -2
  60. package/dist/{chunk-RQOUKIFS.js → chunk-J7RQ3RP7.js} +2 -2
  61. package/dist/{chunk-QTHFGP5F.js → chunk-JITK24KX.js} +7 -7
  62. package/dist/{chunk-EJYUAN5F.js → chunk-K6UXWVQ6.js} +2 -2
  63. package/dist/{chunk-3XJITLZQ.js → chunk-KJ65WZHB.js} +2 -2
  64. package/dist/{chunk-JOR4Y326.js → chunk-KOVQZJ27.js} +2 -2
  65. package/dist/{chunk-O6QSBI3U.js → chunk-KZ4BJRGQ.js} +2 -2
  66. package/dist/{chunk-FZPZML67.js → chunk-LR6LWX33.js} +4 -4
  67. package/dist/{chunk-NTS2RCQK.js → chunk-NAULI3EG.js} +2 -2
  68. package/dist/{chunk-V5W67PQV.js → chunk-NOKHMWMW.js} +4 -4
  69. package/dist/{chunk-JGVW6F3Q.js → chunk-ODI4K32P.js} +5 -5
  70. package/dist/{chunk-H7USCTPQ.js → chunk-OLD2GKQJ.js} +3 -3
  71. package/dist/{chunk-D7HOJFDS.js → chunk-ONSEODO2.js} +2 -2
  72. package/dist/{chunk-R3YMWUF3.js → chunk-P3IAZQPS.js} +2 -2
  73. package/dist/{chunk-LL6WEMTC.js → chunk-P3OONWJJ.js} +2 -2
  74. package/dist/chunk-P3OONWJJ.js.map +1 -0
  75. package/dist/{chunk-7KC6LT7U.js → chunk-PSQ347YP.js} +3 -3
  76. package/dist/{chunk-U6OQ7GWU.js → chunk-QFKNIKUF.js} +2 -2
  77. package/dist/{chunk-RFVX4WE7.js → chunk-QIPRDRGM.js} +1 -1
  78. package/dist/chunk-QIPRDRGM.js.map +1 -0
  79. package/dist/{chunk-2DFXIJPZ.js → chunk-QZMGZBTF.js} +2 -2
  80. package/dist/{chunk-NSFHMGOF.js → chunk-SKJM4PKE.js} +2 -2
  81. package/dist/{chunk-T7R42MWB.js → chunk-STSORBX5.js} +2 -2
  82. package/dist/{chunk-ICA5SCIT.js → chunk-T765HQ5U.js} +3 -3
  83. package/dist/{chunk-RFEQ7DQN.js → chunk-TDG5NZAZ.js} +2 -2
  84. package/dist/{chunk-2S6PPGIR.js → chunk-TWYYUMYO.js} +2 -2
  85. package/dist/{chunk-U6JZGQXC.js → chunk-TZ7ZA2LM.js} +2 -2
  86. package/dist/{chunk-AIS7RLTG.js → chunk-UAEJKURK.js} +58 -56
  87. package/dist/{chunk-AIS7RLTG.js.map → chunk-UAEJKURK.js.map} +1 -1
  88. package/dist/{chunk-JIB3UUYV.js → chunk-UH2VY2QQ.js} +3 -3
  89. package/dist/{chunk-X5XK6WWV.js → chunk-VHQNJW4Q.js} +2 -2
  90. package/dist/{chunk-CP6MUXNI.js → chunk-WEI6HEUX.js} +11 -6
  91. package/dist/chunk-WEI6HEUX.js.map +1 -0
  92. package/dist/{chunk-3IA2SUWM.js → chunk-WRVKI6ZO.js} +2 -2
  93. package/dist/{chunk-R5S57GRK.js → chunk-XSRZM6CQ.js} +38 -13
  94. package/dist/chunk-XSRZM6CQ.js.map +1 -0
  95. package/dist/{chunk-2CWCJYT3.js → chunk-XZLCAL5O.js} +2 -2
  96. package/dist/{chunk-7MAMRCZ7.js → chunk-XZMQLON4.js} +430 -292
  97. package/dist/chunk-XZMQLON4.js.map +1 -0
  98. package/dist/{chunk-HL53XYHC.js → chunk-YCJJODER.js} +5 -5
  99. package/dist/chunk-YCJJODER.js.map +1 -0
  100. package/dist/{chunk-W7FZ7ZZE.js → chunk-Z6EFSXU3.js} +2 -2
  101. package/dist/{chunk-GRX5BE73.js → chunk-ZNCCX7P6.js} +2 -2
  102. package/dist/cli.js +62 -62
  103. package/dist/coding/export-okf-codegraph.js +10 -10
  104. package/dist/compounding/engine.js +12 -12
  105. package/dist/config.d.ts.map +1 -1
  106. package/dist/config.js +11 -11
  107. package/dist/connectors/codex-materialize-runner.js +11 -11
  108. package/dist/connectors/index.js +11 -11
  109. package/dist/consolidation-provenance-check.js +5 -5
  110. package/dist/consolidation-undo.js +4 -4
  111. package/dist/contradiction/index.js +3 -3
  112. package/dist/convergence-refresh.js +13 -13
  113. package/dist/corpus-watermark.js +13 -13
  114. package/dist/cue-anchors.js +5 -5
  115. package/dist/{entity-canonical-id-migration-74IDJFPB.js → entity-canonical-id-migration-46EMEXTB.js} +4 -4
  116. package/dist/entity-retrieval.d.ts.map +1 -1
  117. package/dist/entity-retrieval.js +11 -11
  118. package/dist/explicit-capture.js +62 -62
  119. package/dist/extraction.js +15 -15
  120. package/dist/harmonic-construction.js +6 -6
  121. package/dist/harmonic-graph-version.js +3 -3
  122. package/dist/harmonic-retrieval.d.ts +15 -0
  123. package/dist/harmonic-retrieval.d.ts.map +1 -1
  124. package/dist/harmonic-retrieval.js +16 -14
  125. package/dist/index.js +62 -62
  126. package/dist/location/index.js +12 -12
  127. package/dist/maintenance/memory-governance.js +11 -11
  128. package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +11 -11
  129. package/dist/maintenance/rebuild-memory-projection-runner.js +13 -13
  130. package/dist/maintenance/rebuild-memory-projection.js +12 -12
  131. package/dist/memory-browse.js +5 -5
  132. package/dist/memory-cache.d.ts +44 -3
  133. package/dist/memory-cache.d.ts.map +1 -1
  134. package/dist/memory-cache.js +9 -1
  135. package/dist/memory-corpus-version.js +2 -2
  136. package/dist/namespaces/migrate.js +12 -12
  137. package/dist/namespaces/search.js +4 -4
  138. package/dist/namespaces/storage.js +11 -11
  139. package/dist/operator-doctor-corpus.js +14 -14
  140. package/dist/operator-toolkit.js +19 -19
  141. package/dist/orchestration/backlog-scheduler.js +63 -63
  142. package/dist/orchestration/buffer-drain-runner.js +63 -63
  143. package/dist/orchestration/maintenance.js +19 -19
  144. package/dist/orchestration/recall-internal.d.ts.map +1 -1
  145. package/dist/orchestration/turn-ingestion-buffered.d.ts.map +1 -1
  146. package/dist/orchestrator.js +62 -62
  147. package/dist/page-versioning.js +4 -4
  148. package/dist/qmd.js +2 -2
  149. package/dist/recall-explain-renderer.js +3 -3
  150. package/dist/recall-navigate-access.js +2 -2
  151. package/dist/recall-navigate-disclosure.js +2 -2
  152. package/dist/recall-navigate.js +2 -2
  153. package/dist/recall-navigation.js +62 -62
  154. package/dist/recall-state-view-admission.js +5 -5
  155. package/dist/recall-why-service.js +5 -5
  156. package/dist/recall-xray-cli.js +4 -4
  157. package/dist/recall-xray-renderer.js +3 -3
  158. package/dist/recall-xray.js +2 -2
  159. package/dist/{resolution-RWIGFH2W.js → resolution-4QPPLDEN.js} +4 -4
  160. package/dist/resume-bundles.js +12 -12
  161. package/dist/search/factory.js +3 -3
  162. package/dist/search/index.js +3 -3
  163. package/dist/semantic-consolidation.js +12 -12
  164. package/dist/semantic-rule-promotion.js +11 -11
  165. package/dist/semantic-rule-verifier.js +11 -11
  166. package/dist/source-agent-qualifier.js +14 -14
  167. package/dist/standup/build.js +11 -11
  168. package/dist/storage/entity-listing.d.ts +20 -0
  169. package/dist/storage/entity-listing.d.ts.map +1 -0
  170. package/dist/storage/entity-store.d.ts +5 -0
  171. package/dist/storage/entity-store.d.ts.map +1 -1
  172. package/dist/storage/hot-cache-validation.d.ts +60 -0
  173. package/dist/storage/hot-cache-validation.d.ts.map +1 -0
  174. package/dist/storage.d.ts +2 -0
  175. package/dist/storage.d.ts.map +1 -1
  176. package/dist/storage.js +10 -10
  177. package/dist/transfer/capsule-import.js +5 -5
  178. package/dist/transfer/export-okf.js +11 -11
  179. package/dist/types.d.ts +2 -0
  180. package/dist/types.d.ts.map +1 -1
  181. package/dist/types.js +1 -1
  182. package/dist/verified-recall.js +11 -11
  183. package/dist/who-knows-cli.js +12 -12
  184. package/dist/who-knows.js +11 -11
  185. package/package.json +2 -2
  186. package/src/buffer-large-session-defer.test.ts +81 -0
  187. package/src/buffer-persistence.ts +8 -1
  188. package/src/buffer.ts +9 -4
  189. package/src/config.test.ts +9 -0
  190. package/src/config.ts +3 -6
  191. package/src/entity-recall-hot-cache.test.ts +116 -0
  192. package/src/entity-retrieval.ts +22 -4
  193. package/src/harmonic-graph-cache.test.ts +28 -9
  194. package/src/harmonic-retrieval.ts +20 -4
  195. package/src/memory-cache-hot.test.ts +47 -0
  196. package/src/memory-cache.ts +96 -17
  197. package/src/observe-flush-force-keys.test.ts +130 -0
  198. package/src/orchestration/recall-internal.ts +1 -0
  199. package/src/orchestration/turn-ingestion-buffered.test.ts +6 -2
  200. package/src/orchestration/turn-ingestion-buffered.ts +5 -1
  201. package/src/storage/entity-listing.ts +73 -0
  202. package/src/storage/entity-store.ts +25 -26
  203. package/src/storage/hot-cache-validation.ts +149 -0
  204. package/src/storage-contract/cache-coherence.test.ts +42 -5
  205. package/src/storage-hot-cache-stat-validate.test.ts +112 -0
  206. package/src/storage.ts +58 -44
  207. package/src/types.ts +2 -0
  208. package/dist/chunk-7MAMRCZ7.js.map +0 -1
  209. package/dist/chunk-CP6MUXNI.js.map +0 -1
  210. package/dist/chunk-HL53XYHC.js.map +0 -1
  211. package/dist/chunk-JQCEG54G.js.map +0 -1
  212. package/dist/chunk-LL6WEMTC.js.map +0 -1
  213. package/dist/chunk-QSVWIKNY.js.map +0 -1
  214. package/dist/chunk-R5S57GRK.js.map +0 -1
  215. package/dist/chunk-RFVX4WE7.js.map +0 -1
  216. /package/dist/{capsule-merge-BADOICNP.js.map → capsule-merge-3FARYIHP.js.map} +0 -0
  217. /package/dist/{chunk-IMSLPQJB.js.map → chunk-2QW5HPKU.js.map} +0 -0
  218. /package/dist/{chunk-KNYUEYB6.js.map → chunk-2YJ2ST23.js.map} +0 -0
  219. /package/dist/{chunk-BZ5VO7KO.js.map → chunk-3BICT225.js.map} +0 -0
  220. /package/dist/{chunk-UWKHLWUE.js.map → chunk-3RZ4GDOH.js.map} +0 -0
  221. /package/dist/{chunk-ODIBCZLG.js.map → chunk-3YID7KZ6.js.map} +0 -0
  222. /package/dist/{chunk-4SUNBSPD.js.map → chunk-4EAVEDLG.js.map} +0 -0
  223. /package/dist/{chunk-TLRIRISJ.js.map → chunk-4LCA2GEX.js.map} +0 -0
  224. /package/dist/{chunk-4N33L4HY.js.map → chunk-5GIYIYJI.js.map} +0 -0
  225. /package/dist/{chunk-ZDLVHGIC.js.map → chunk-7EP4FURO.js.map} +0 -0
  226. /package/dist/{chunk-CAUADFDM.js.map → chunk-7SOKOEAZ.js.map} +0 -0
  227. /package/dist/{chunk-7Q74DD2W.js.map → chunk-7V6GNQC2.js.map} +0 -0
  228. /package/dist/{chunk-C6YKKH73.js.map → chunk-AALJHIKH.js.map} +0 -0
  229. /package/dist/{chunk-C2UN2CY7.js.map → chunk-AJ7JHHRY.js.map} +0 -0
  230. /package/dist/{chunk-3DADRUGW.js.map → chunk-BGA7S5EF.js.map} +0 -0
  231. /package/dist/{chunk-7GMOB4FF.js.map → chunk-CJSTQNE5.js.map} +0 -0
  232. /package/dist/{chunk-6YAQ3AJ5.js.map → chunk-DYUPSTCV.js.map} +0 -0
  233. /package/dist/{chunk-E5QI6C6C.js.map → chunk-E3LGAZJC.js.map} +0 -0
  234. /package/dist/{chunk-NL5KFA5N.js.map → chunk-EEA2RM4B.js.map} +0 -0
  235. /package/dist/{chunk-BL7WULM5.js.map → chunk-FDO7ITP6.js.map} +0 -0
  236. /package/dist/{chunk-7BIGO6ZL.js.map → chunk-FGFU6J26.js.map} +0 -0
  237. /package/dist/{chunk-6TIQLG7I.js.map → chunk-FKHXXL42.js.map} +0 -0
  238. /package/dist/{chunk-QPD7EYGI.js.map → chunk-G2MS56KM.js.map} +0 -0
  239. /package/dist/{chunk-FFTGLWHI.js.map → chunk-GH7IKABD.js.map} +0 -0
  240. /package/dist/{chunk-RC2TVYY2.js.map → chunk-GYCUX3N4.js.map} +0 -0
  241. /package/dist/{chunk-CJYVVVOG.js.map → chunk-HEJFE3BC.js.map} +0 -0
  242. /package/dist/{chunk-KM4QO4LN.js.map → chunk-HLQANATZ.js.map} +0 -0
  243. /package/dist/{chunk-RQOUKIFS.js.map → chunk-J7RQ3RP7.js.map} +0 -0
  244. /package/dist/{chunk-QTHFGP5F.js.map → chunk-JITK24KX.js.map} +0 -0
  245. /package/dist/{chunk-EJYUAN5F.js.map → chunk-K6UXWVQ6.js.map} +0 -0
  246. /package/dist/{chunk-3XJITLZQ.js.map → chunk-KJ65WZHB.js.map} +0 -0
  247. /package/dist/{chunk-JOR4Y326.js.map → chunk-KOVQZJ27.js.map} +0 -0
  248. /package/dist/{chunk-O6QSBI3U.js.map → chunk-KZ4BJRGQ.js.map} +0 -0
  249. /package/dist/{chunk-FZPZML67.js.map → chunk-LR6LWX33.js.map} +0 -0
  250. /package/dist/{chunk-NTS2RCQK.js.map → chunk-NAULI3EG.js.map} +0 -0
  251. /package/dist/{chunk-V5W67PQV.js.map → chunk-NOKHMWMW.js.map} +0 -0
  252. /package/dist/{chunk-JGVW6F3Q.js.map → chunk-ODI4K32P.js.map} +0 -0
  253. /package/dist/{chunk-H7USCTPQ.js.map → chunk-OLD2GKQJ.js.map} +0 -0
  254. /package/dist/{chunk-D7HOJFDS.js.map → chunk-ONSEODO2.js.map} +0 -0
  255. /package/dist/{chunk-R3YMWUF3.js.map → chunk-P3IAZQPS.js.map} +0 -0
  256. /package/dist/{chunk-7KC6LT7U.js.map → chunk-PSQ347YP.js.map} +0 -0
  257. /package/dist/{chunk-U6OQ7GWU.js.map → chunk-QFKNIKUF.js.map} +0 -0
  258. /package/dist/{chunk-2DFXIJPZ.js.map → chunk-QZMGZBTF.js.map} +0 -0
  259. /package/dist/{chunk-NSFHMGOF.js.map → chunk-SKJM4PKE.js.map} +0 -0
  260. /package/dist/{chunk-T7R42MWB.js.map → chunk-STSORBX5.js.map} +0 -0
  261. /package/dist/{chunk-ICA5SCIT.js.map → chunk-T765HQ5U.js.map} +0 -0
  262. /package/dist/{chunk-RFEQ7DQN.js.map → chunk-TDG5NZAZ.js.map} +0 -0
  263. /package/dist/{chunk-2S6PPGIR.js.map → chunk-TWYYUMYO.js.map} +0 -0
  264. /package/dist/{chunk-U6JZGQXC.js.map → chunk-TZ7ZA2LM.js.map} +0 -0
  265. /package/dist/{chunk-JIB3UUYV.js.map → chunk-UH2VY2QQ.js.map} +0 -0
  266. /package/dist/{chunk-X5XK6WWV.js.map → chunk-VHQNJW4Q.js.map} +0 -0
  267. /package/dist/{chunk-3IA2SUWM.js.map → chunk-WRVKI6ZO.js.map} +0 -0
  268. /package/dist/{chunk-2CWCJYT3.js.map → chunk-XZLCAL5O.js.map} +0 -0
  269. /package/dist/{chunk-W7FZ7ZZE.js.map → chunk-Z6EFSXU3.js.map} +0 -0
  270. /package/dist/{chunk-GRX5BE73.js.map → chunk-ZNCCX7P6.js.map} +0 -0
  271. /package/dist/{entity-canonical-id-migration-74IDJFPB.js.map → entity-canonical-id-migration-46EMEXTB.js.map} +0 -0
  272. /package/dist/{resolution-RWIGFH2W.js.map → resolution-4QPPLDEN.js.map} +0 -0
@@ -19,14 +19,14 @@ import {
19
19
  getFingerprint,
20
20
  migrateLegacyEntityCanonicalIds,
21
21
  validateRoots
22
- } from "./chunk-BL7WULM5.js";
22
+ } from "./chunk-FDO7ITP6.js";
23
23
  import {
24
24
  BufferSessionFiles
25
25
  } from "./chunk-QFZYIUMQ.js";
26
26
  import {
27
27
  normalizeQmdResultPath,
28
28
  resolveNamespaceResultPath
29
- } from "./chunk-2CWCJYT3.js";
29
+ } from "./chunk-XZLCAL5O.js";
30
30
  import {
31
31
  withholdToolScopedFromSharedNamespace
32
32
  } from "./chunk-S2V7RUCL.js";
@@ -95,7 +95,7 @@ import {
95
95
  } from "./chunk-3WU7XOFN.js";
96
96
  import {
97
97
  createVersion
98
- } from "./chunk-E5QI6C6C.js";
98
+ } from "./chunk-E3LGAZJC.js";
99
99
  import {
100
100
  ENTITY_CANONICAL_ID_MIGRATION_FILE,
101
101
  ENTITY_CANONICAL_ID_RECONCILE_CONSUMING_MARKER,
@@ -115,7 +115,7 @@ import {
115
115
  resolveHistoricalEntityCanonicalId,
116
116
  withEntityCanonicalMutationLock,
117
117
  withRawEntityPageMutation
118
- } from "./chunk-KM4QO4LN.js";
118
+ } from "./chunk-HLQANATZ.js";
119
119
  import {
120
120
  supersessionKeysForFact
121
121
  } from "./chunk-5WITETWU.js";
@@ -154,7 +154,7 @@ import {
154
154
  import {
155
155
  SPECULATIVE_TTL_DAYS,
156
156
  confidenceTier
157
- } from "./chunk-RFVX4WE7.js";
157
+ } from "./chunk-QIPRDRGM.js";
158
158
  import {
159
159
  composeMemoryEnvelope,
160
160
  isSealedMemoryEnvelope,
@@ -248,17 +248,21 @@ import {
248
248
  } from "./chunk-7CT3AI52.js";
249
249
  import {
250
250
  clearMemoryCache,
251
+ entityCacheStats,
251
252
  getCachedEntities,
252
253
  getCachedMemories,
254
+ getHotCacheEntry,
255
+ hotCacheReadStats,
253
256
  invalidateAllForDir,
254
257
  invalidateDerivedAndGlobalForDir,
255
258
  invalidateForScope,
256
259
  invalidateForScopeExceptHot,
260
+ promoteHotCacheVersion,
257
261
  setCachedEntities,
258
262
  setCachedMemories,
259
263
  updateCacheOnDelete,
260
264
  updateCacheOnWrite
261
- } from "./chunk-R5S57GRK.js";
265
+ } from "./chunk-XSRZM6CQ.js";
262
266
  import {
263
267
  isMacOsReplicationJunkBasename,
264
268
  warnIgnoredMacOsReplicationJunk,
@@ -303,7 +307,7 @@ import {
303
307
  readdir as readdir7,
304
308
  readFile as readFile4,
305
309
  realpath as realpath2,
306
- stat as stat4,
310
+ stat as stat6,
307
311
  writeFile as writeFile3,
308
312
  mkdir as mkdir5,
309
313
  unlink as unlink8,
@@ -335,7 +339,7 @@ function parseDriftProvenance(fm) {
335
339
  }
336
340
 
337
341
  // src/storage.ts
338
- import path20 from "path";
342
+ import path21 from "path";
339
343
 
340
344
  // src/storage/tombstone-migration-sources.ts
341
345
  import { statSync } from "fs";
@@ -1845,7 +1849,11 @@ function selfDeps(self) {
1845
1849
  }
1846
1850
 
1847
1851
  // src/storage/entity-store.ts
1848
- import { lstat as lstat3, readdir as readdir2, unlink } from "fs/promises";
1852
+ import { lstat as lstat3, unlink } from "fs/promises";
1853
+ import path8 from "path";
1854
+
1855
+ // src/storage/entity-listing.ts
1856
+ import { readdir as readdir2, stat as stat3 } from "fs/promises";
1849
1857
  import path7 from "path";
1850
1858
 
1851
1859
  // src/storage/entity-migration-completion-cache.ts
@@ -1948,6 +1956,51 @@ async function readEntityFileResolvingRename(deps, firstPath, entityId) {
1948
1956
  return null;
1949
1957
  }
1950
1958
 
1959
+ // src/storage/entity-listing.ts
1960
+ async function scanEntitiesDir(deps, warn, options) {
1961
+ if (!await isTrustedEntitiesRoot(deps.baseDir, deps.entitiesDir)) return null;
1962
+ let listed;
1963
+ try {
1964
+ listed = await readdir2(deps.entitiesDir);
1965
+ } catch {
1966
+ return null;
1967
+ }
1968
+ const { kept: names, ignored } = withoutMacOsReplicationJunk(listed, (name) => name);
1969
+ if (warn) {
1970
+ warnIgnoredMacOsReplicationJunk(deps.entitiesDir, ignored, (message) => {
1971
+ log.warn(`entity load ${message}`);
1972
+ });
1973
+ }
1974
+ const listing = /* @__PURE__ */ new Map();
1975
+ const BATCH = 200;
1976
+ for (let i = 0; i < names.length; i += BATCH) {
1977
+ checkCorpusReadAbort(options);
1978
+ await Promise.all(names.slice(i, i + BATCH).map(async (name) => {
1979
+ try {
1980
+ const st = await stat3(path7.join(deps.entitiesDir, name));
1981
+ listing.set(name, `${st.mtimeMs}:${st.size}`);
1982
+ } catch {
1983
+ listing.set(name, "missing");
1984
+ }
1985
+ }));
1986
+ }
1987
+ return { names, listing };
1988
+ }
1989
+ async function entitiesListingUnchanged(deps, listing, options) {
1990
+ const scanned = await scanEntitiesDir(
1991
+ deps,
1992
+ /* warn */
1993
+ false,
1994
+ options
1995
+ );
1996
+ if (!scanned || scanned.listing.size !== listing.size) return false;
1997
+ checkCorpusReadAbort(options);
1998
+ for (const [name, token] of listing) {
1999
+ if (scanned.listing.get(name) !== token) return false;
2000
+ }
2001
+ return true;
2002
+ }
2003
+
1951
2004
  // src/storage/entity-store.ts
1952
2005
  var EntityStore = class {
1953
2006
  constructor(deps) {
@@ -1972,7 +2025,7 @@ var EntityStore = class {
1972
2025
  assertSafeEntityId(name);
1973
2026
  const canonical = resolveHistoricalEntityCanonicalId(name, historicalIds);
1974
2027
  for (const candidate of canonical === name ? [name] : [canonical, name]) {
1975
- const filePath = path7.join(this.deps.entitiesDir, `${candidate}.md`);
2028
+ const filePath = path8.join(this.deps.entitiesDir, `${candidate}.md`);
1976
2029
  try {
1977
2030
  const entity = parseEntityFile(await this.deps.readStorageSecureFile(filePath), this.deps.entitySchemas);
1978
2031
  return { filePath, entity };
@@ -1998,7 +2051,7 @@ var EntityStore = class {
1998
2051
  */
1999
2052
  async mutateEntityFile(name, method, mutate) {
2000
2053
  await this.deps.ensureDirectories();
2001
- const stateDir = path7.join(this.deps.baseDir, "state");
2054
+ const stateDir = path8.join(this.deps.baseDir, "state");
2002
2055
  return withEntityCanonicalMutationLock(stateDir, async () => {
2003
2056
  for (let attempt = 0; attempt < 3; attempt += 1) {
2004
2057
  const idsAtResolve = this.deps.currentHistoricalIds();
@@ -2053,7 +2106,7 @@ var EntityStore = class {
2053
2106
  async writeEntity(name, type, facts, options = {}) {
2054
2107
  await this.deps.ensureDirectories();
2055
2108
  return withEntityCanonicalMutationLock(
2056
- path7.join(this.deps.baseDir, "state"),
2109
+ path8.join(this.deps.baseDir, "state"),
2057
2110
  () => this.writeEntityUnlocked(name, type, facts, options)
2058
2111
  );
2059
2112
  }
@@ -2074,7 +2127,7 @@ var EntityStore = class {
2074
2127
  log.debug(`fuzzy match: "${normalized}" \u2192 existing "${match}"`);
2075
2128
  normalized = match;
2076
2129
  }
2077
- const filePath = path7.join(this.deps.entitiesDir, `${normalized}.md`);
2130
+ const filePath = path8.join(this.deps.entitiesDir, `${normalized}.md`);
2078
2131
  let entity = {
2079
2132
  name,
2080
2133
  type,
@@ -2192,7 +2245,7 @@ var EntityStore = class {
2192
2245
  if (!file.endsWith(".md") || !await this.isContainedRegularEntityFile(file)) continue;
2193
2246
  let content;
2194
2247
  try {
2195
- content = await this.deps.readStorageSecureFile(path7.join(this.deps.entitiesDir, file));
2248
+ content = await this.deps.readStorageSecureFile(path8.join(this.deps.entitiesDir, file));
2196
2249
  } catch (err) {
2197
2250
  if (err instanceof SecureStoreLockedError) throw err;
2198
2251
  if (isErrnoCode(err, "ENOENT") || isErrnoCode(err, "ELOOP")) continue;
@@ -2213,13 +2266,12 @@ var EntityStore = class {
2213
2266
  * A symlinked entities root yields an empty list and is not read.
2214
2267
  */
2215
2268
  async readEntityDirectoryNames() {
2216
- if (!await isTrustedEntitiesRoot(this.deps.baseDir, this.deps.entitiesDir)) return [];
2217
- const entries = await readdir2(this.deps.entitiesDir);
2218
- const { kept, ignored } = withoutMacOsReplicationJunk(entries, (name) => name);
2219
- warnIgnoredMacOsReplicationJunk(this.deps.entitiesDir, ignored, (message) => {
2220
- log.warn(`entity load ${message}`);
2221
- });
2222
- return kept;
2269
+ const scanned = await scanEntitiesDir(
2270
+ this.deps,
2271
+ /* warn */
2272
+ true
2273
+ );
2274
+ return scanned?.names ?? [];
2223
2275
  }
2224
2276
  /**
2225
2277
  * A directory entry is readable only when it is a regular file.
@@ -2228,7 +2280,7 @@ var EntityStore = class {
2228
2280
  */
2229
2281
  async isMissingEntry(file) {
2230
2282
  try {
2231
- await lstat3(path7.join(this.deps.entitiesDir, file));
2283
+ await lstat3(path8.join(this.deps.entitiesDir, file));
2232
2284
  return false;
2233
2285
  } catch (err) {
2234
2286
  if (isErrnoCode(err, "ENOENT")) return true;
@@ -2236,7 +2288,7 @@ var EntityStore = class {
2236
2288
  }
2237
2289
  }
2238
2290
  async isContainedRegularEntityFile(file) {
2239
- const filePath = path7.join(this.deps.entitiesDir, file);
2291
+ const filePath = path8.join(this.deps.entitiesDir, file);
2240
2292
  let entryStat;
2241
2293
  try {
2242
2294
  entryStat = await lstat3(filePath);
@@ -2253,7 +2305,7 @@ var EntityStore = class {
2253
2305
  * reread the whole directory on every extraction write.
2254
2306
  */
2255
2307
  async isIndexableEntityMarkdown(file) {
2256
- const filePath = path7.join(this.deps.entitiesDir, file);
2308
+ const filePath = path8.join(this.deps.entitiesDir, file);
2257
2309
  let entryStat;
2258
2310
  try {
2259
2311
  entryStat = await lstat3(filePath);
@@ -2329,7 +2381,7 @@ var EntityStore = class {
2329
2381
  async migrateEntityFilesToCompiledTruthTimeline() {
2330
2382
  await this.deps.ensureDirectories();
2331
2383
  const entityNames = await this.listEntityNames();
2332
- const stateDir = path7.join(this.deps.baseDir, "state");
2384
+ const stateDir = path8.join(this.deps.baseDir, "state");
2333
2385
  let migrated = 0;
2334
2386
  for (const entityName of entityNames) {
2335
2387
  const wrote = await withEntityCanonicalMutationLock(stateDir, async () => {
@@ -2365,7 +2417,7 @@ var EntityStore = class {
2365
2417
  async updateEntitySynthesis(name, synthesis, options = {}) {
2366
2418
  await this.deps.ensureDirectories();
2367
2419
  return withEntityCanonicalMutationLock(
2368
- path7.join(this.deps.baseDir, "state"),
2420
+ path8.join(this.deps.baseDir, "state"),
2369
2421
  () => this.updateEntitySynthesisUnlocked(name, synthesis, options)
2370
2422
  );
2371
2423
  }
@@ -2397,26 +2449,39 @@ var EntityStore = class {
2397
2449
  /**
2398
2450
  * Read all entity files and return lightweight EntityFile objects.
2399
2451
  * Parsing is fast (~50-100ms for ~1,800 files) since entity files are small.
2452
+ *
2453
+ * COS-825: the parsed cache is validated by an entities-dir listing snapshot
2454
+ * (name, mtime, size) plus the entity-mutation version — NOT the memory-status
2455
+ * version, which churns with unrelated memory lifecycle writes and used to
2456
+ * force a full re-read on every recall under observe traffic.
2400
2457
  */
2401
2458
  async readAllEntityFiles(options) {
2402
2459
  checkCorpusReadAbort(options);
2403
- const currentVersion = this.deps.getMemoryStatusVersion();
2404
2460
  const cacheKey = [
2405
2461
  this.deps.getEntityCacheSecureStoreKey(),
2406
2462
  buildEntitySchemaCacheKey(this.deps.entitySchemas),
2407
2463
  this.deps.getEntityMutationVersion()
2408
2464
  ].join("\0");
2409
- const cached = getCachedEntities(this.deps.baseDir, currentVersion, cacheKey);
2410
- if (cached) return cached;
2465
+ const cached = getCachedEntities(this.deps.baseDir, cacheKey);
2466
+ if (cached && await entitiesListingUnchanged(this.deps, cached.listing, options)) {
2467
+ entityCacheStats.hits++;
2468
+ return cached.entities;
2469
+ }
2470
+ entityCacheStats.rebuilds++;
2411
2471
  try {
2412
- if (!await isTrustedEntitiesRoot(this.deps.baseDir, this.deps.entitiesDir)) return [];
2413
- const listed = await readdir2(this.deps.entitiesDir);
2414
- const { kept: entries, ignored } = withoutMacOsReplicationJunk(listed, (name) => name);
2415
- warnIgnoredMacOsReplicationJunk(this.deps.entitiesDir, ignored, (message) => {
2416
- log.warn(`entity load ${message}`);
2417
- });
2418
- const mdFiles = entries.filter((e) => e.endsWith(".md"));
2419
- if (mdFiles.length === 0) return [];
2472
+ const scanned = await scanEntitiesDir(
2473
+ this.deps,
2474
+ /* warn */
2475
+ true,
2476
+ options
2477
+ );
2478
+ checkCorpusReadAbort(options);
2479
+ if (!scanned) return [];
2480
+ const mdFiles = scanned.names.filter((e) => e.endsWith(".md"));
2481
+ if (mdFiles.length === 0) {
2482
+ setCachedEntities(this.deps.baseDir, [], cacheKey, scanned.listing);
2483
+ return [];
2484
+ }
2420
2485
  const historicalIds = this.deps.currentHistoricalIds();
2421
2486
  const seen = /* @__PURE__ */ new Map();
2422
2487
  const BATCH_SIZE = 100;
@@ -2427,7 +2492,7 @@ var EntityStore = class {
2427
2492
  const results = await Promise.all(
2428
2493
  batch.map(async (entry) => {
2429
2494
  const entityId = entry.slice(0, -".md".length);
2430
- const entryPath = path7.join(this.deps.entitiesDir, entry);
2495
+ const entryPath = path8.join(this.deps.entitiesDir, entry);
2431
2496
  try {
2432
2497
  if (!await this.isContainedRegularEntityFile(entry)) {
2433
2498
  if (await this.isMissingEntry(entry)) {
@@ -2459,7 +2524,7 @@ var EntityStore = class {
2459
2524
  }
2460
2525
  }
2461
2526
  checkCorpusReadAbort(options);
2462
- setCachedEntities(this.deps.baseDir, entities, currentVersion, cacheKey);
2527
+ setCachedEntities(this.deps.baseDir, entities, cacheKey, scanned.listing);
2463
2528
  return entities;
2464
2529
  } catch (err) {
2465
2530
  if (err instanceof SecureStoreLockedError || !isErrnoCode(err, "ENOENT")) throw err;
@@ -2522,7 +2587,7 @@ ${rows.join("\n")}
2522
2587
  async mergeFragmentedEntities() {
2523
2588
  await this.deps.ensureDirectories();
2524
2589
  return withEntityCanonicalMutationLock(
2525
- path7.join(this.deps.baseDir, "state"),
2590
+ path8.join(this.deps.baseDir, "state"),
2526
2591
  () => this.mergeFragmentedEntitiesUnlocked()
2527
2592
  );
2528
2593
  }
@@ -2550,7 +2615,7 @@ ${rows.join("\n")}
2550
2615
  const canonicalDestinationOccupied = async (canonicalName, members) => {
2551
2616
  if (members.includes(canonicalName)) return false;
2552
2617
  try {
2553
- await lstat3(path7.join(this.deps.entitiesDir, canonicalName));
2618
+ await lstat3(path8.join(this.deps.entitiesDir, canonicalName));
2554
2619
  return true;
2555
2620
  } catch (err) {
2556
2621
  if (isErrnoCode(err, "ENOENT")) return false;
@@ -2587,7 +2652,7 @@ ${rows.join("\n")}
2587
2652
  extraSections: []
2588
2653
  };
2589
2654
  for (const file of files) {
2590
- const filePath = path7.join(this.deps.entitiesDir, file);
2655
+ const filePath = path8.join(this.deps.entitiesDir, file);
2591
2656
  try {
2592
2657
  const content = await this.deps.readStorageSecureFile(filePath);
2593
2658
  const parsed = parseEntityFile(content, this.deps.entitySchemas);
@@ -2740,7 +2805,7 @@ ${rows.join("\n")}
2740
2805
  }
2741
2806
  mergedEntity.created = mergedEntity.created || mergedEntity.updated || (/* @__PURE__ */ new Date()).toISOString();
2742
2807
  mergedEntity.updated = mergedEntity.updated || (/* @__PURE__ */ new Date()).toISOString();
2743
- const canonicalPath = path7.join(this.deps.entitiesDir, canonicalName);
2808
+ const canonicalPath = path8.join(this.deps.entitiesDir, canonicalName);
2744
2809
  if (await canonicalDestinationOccupied(canonicalName, files)) {
2745
2810
  log.warn(`skipped entity merge into occupied ${canonicalName}`);
2746
2811
  continue;
@@ -2748,7 +2813,7 @@ ${rows.join("\n")}
2748
2813
  await this.deps.writeStorageSecureFile(canonicalPath, serializeEntityFile(mergedEntity, this.deps.entitySchemas, this.deps.okfConformanceEnabled()));
2749
2814
  this.deps.bumpEntityMutationVersion();
2750
2815
  for (const file of files) {
2751
- const filePath = path7.join(this.deps.entitiesDir, file);
2816
+ const filePath = path8.join(this.deps.entitiesDir, file);
2752
2817
  if (filePath !== canonicalPath) {
2753
2818
  try {
2754
2819
  await unlink(filePath);
@@ -2769,7 +2834,7 @@ ${rows.join("\n")}
2769
2834
  // src/storage/deletion-revision-store.ts
2770
2835
  import { createHash, randomUUID } from "crypto";
2771
2836
  import { lstat as lstat4, mkdir, open, readFile, rename, unlink as unlink2 } from "fs/promises";
2772
- import path8 from "path";
2837
+ import path9 from "path";
2773
2838
  var DELETION_REVISION_MAX_MTIME_MS = 864e13;
2774
2839
  var DELETION_REVISION_LOCK_STALE_MS = 6e4;
2775
2840
  var DELETION_REVISION_LOCK_MAX_WAIT_MS = 12e4;
@@ -2835,7 +2900,7 @@ function isValidMemoryId(value) {
2835
2900
  return typeof value === "string" && value.length > 0 && !value.includes("\0");
2836
2901
  }
2837
2902
  function isValidManagedStoragePath(value) {
2838
- return typeof value === "string" && value.length > 0 && !value.includes("\\") && !value.includes("\0") && !path8.posix.isAbsolute(value) && path8.posix.normalize(value) === value && value !== "." && value !== ".." && !value.startsWith("../");
2903
+ return typeof value === "string" && value.length > 0 && !value.includes("\\") && !value.includes("\0") && !path9.posix.isAbsolute(value) && path9.posix.normalize(value) === value && value !== "." && value !== ".." && !value.startsWith("../");
2839
2904
  }
2840
2905
  function deletionRevisionPathIdentity(value) {
2841
2906
  return value.normalize("NFC").toUpperCase().toLowerCase();
@@ -2866,14 +2931,14 @@ var DeletionRevisionStore = class {
2866
2931
  this.invalidationProofQuarantine.add(memoryId);
2867
2932
  }
2868
2933
  async resolveConfiguredStoragePath(targetPath) {
2869
- const baseDir = path8.resolve(this.options.baseDir);
2870
- const relativePath = path8.relative(baseDir, path8.resolve(targetPath));
2934
+ const baseDir = path9.resolve(this.options.baseDir);
2935
+ const relativePath = path9.relative(baseDir, path9.resolve(targetPath));
2871
2936
  return resolveSafeStoragePath(baseDir, relativePath);
2872
2937
  }
2873
2938
  async resolveManagedStoragePath(filePath, method) {
2874
2939
  const assertedPath = this.options.assertManagedStoragePath(filePath, method);
2875
2940
  const target = await this.resolveConfiguredStoragePath(assertedPath);
2876
- const relativePath = path8.relative(path8.resolve(this.options.baseDir), target).split(path8.sep).join("/");
2941
+ const relativePath = path9.relative(path9.resolve(this.options.baseDir), target).split(path9.sep).join("/");
2877
2942
  return { target, relativePath };
2878
2943
  }
2879
2944
  parseDeletionRevisionMetadata(raw) {
@@ -3028,7 +3093,7 @@ var DeletionRevisionStore = class {
3028
3093
  const temporaryPath = await this.resolveConfiguredStoragePath(
3029
3094
  `${metadataPath}.${process.pid}.${randomUUID()}.tmp`
3030
3095
  );
3031
- const metadataDir = await this.resolveConfiguredStoragePath(path8.dirname(metadataPath));
3096
+ const metadataDir = await this.resolveConfiguredStoragePath(path9.dirname(metadataPath));
3032
3097
  let handle = null;
3033
3098
  let renamed = false;
3034
3099
  try {
@@ -3211,7 +3276,7 @@ var DeletionRevisionStore = class {
3211
3276
  // src/storage/cas-revision-store.ts
3212
3277
  import { createHash as createHash2, randomUUID as randomUUID2 } from "crypto";
3213
3278
  import { mkdir as mkdir2, open as open2, readFile as readFile2, rename as rename2, unlink as unlink3 } from "fs/promises";
3214
- import path9 from "path";
3279
+ import path10 from "path";
3215
3280
  var ACCESS_TELEMETRY_FRONTMATTER_KEY = /^(?:accessCount|lastAccessed):/;
3216
3281
  function canonicalSemanticFileText(raw) {
3217
3282
  const lines = raw.split("\n");
@@ -3238,7 +3303,7 @@ var CasRevisionStore = class {
3238
3303
  legacyMetadataPath;
3239
3304
  constructor(baseDir) {
3240
3305
  this.baseDir = baseDir;
3241
- this.legacyMetadataPath = path9.join(baseDir, ".offline-sync", "cas-revisions.v1.json");
3306
+ this.legacyMetadataPath = path10.join(baseDir, ".offline-sync", "cas-revisions.v1.json");
3242
3307
  }
3243
3308
  parseCasRevisionMetadata(raw) {
3244
3309
  let parsed;
@@ -3268,8 +3333,8 @@ var CasRevisionStore = class {
3268
3333
  return revisions;
3269
3334
  }
3270
3335
  async readLegacyMetadata() {
3271
- const baseDir = path9.resolve(this.baseDir);
3272
- const legacyPath = await resolveSafeStoragePath(baseDir, path9.relative(baseDir, this.legacyMetadataPath));
3336
+ const baseDir = path10.resolve(this.baseDir);
3337
+ const legacyPath = await resolveSafeStoragePath(baseDir, path10.relative(baseDir, this.legacyMetadataPath));
3273
3338
  let raw;
3274
3339
  try {
3275
3340
  raw = await readFile2(legacyPath, "utf8");
@@ -3285,7 +3350,7 @@ var CasRevisionStore = class {
3285
3350
  * shard file makes this throw, so no sidecar traffic can follow a link
3286
3351
  * out of the root. */
3287
3352
  async getSafeShardInfo(relativePath) {
3288
- const baseDir = path9.resolve(this.baseDir);
3353
+ const baseDir = path10.resolve(this.baseDir);
3289
3354
  const hash = createHash2("sha256").update(relativePath).digest("hex");
3290
3355
  const shardPath = await resolveSafeStoragePath(baseDir, ".offline-sync", "cas-revisions", `${hash}.json`);
3291
3356
  const lockPath = await resolveSafeStoragePath(baseDir, ".offline-sync", "cas-revisions", `${hash}.json.lock`);
@@ -3400,14 +3465,14 @@ var CasRevisionStore = class {
3400
3465
  if (evidence.writeLanded !== void 0) payload.writeLanded = evidence.writeLanded;
3401
3466
  }
3402
3467
  }
3403
- const baseDir = path9.resolve(this.baseDir);
3468
+ const baseDir = path10.resolve(this.baseDir);
3404
3469
  const temporaryPath = await resolveSafeStoragePath(
3405
3470
  baseDir,
3406
- path9.relative(baseDir, `${shardPath}.${process.pid}.${randomUUID2()}.tmp`)
3471
+ path10.relative(baseDir, `${shardPath}.${process.pid}.${randomUUID2()}.tmp`)
3407
3472
  );
3408
3473
  let handle = null;
3409
3474
  try {
3410
- await mkdir2(path9.dirname(shardPath), { recursive: true });
3475
+ await mkdir2(path10.dirname(shardPath), { recursive: true });
3411
3476
  handle = await open2(temporaryPath, "wx", 384);
3412
3477
  await handle.writeFile(`${JSON.stringify(payload)}
3413
3478
  `, "utf8");
@@ -3432,9 +3497,9 @@ var CasRevisionStore = class {
3432
3497
  }
3433
3498
  }
3434
3499
  async resolveRelativePath(filePath) {
3435
- const baseDir = path9.resolve(this.baseDir);
3436
- const target = await resolveSafeStoragePath(baseDir, path9.relative(baseDir, path9.resolve(baseDir, filePath)));
3437
- return path9.relative(baseDir, target).split(path9.sep).join("/");
3500
+ const baseDir = path10.resolve(this.baseDir);
3501
+ const target = await resolveSafeStoragePath(baseDir, path10.relative(baseDir, path10.resolve(baseDir, filePath)));
3502
+ return path10.relative(baseDir, target).split(path10.sep).join("/");
3438
3503
  }
3439
3504
  async withShardLock(relativePath, task) {
3440
3505
  const { lockPath } = await this.getSafeShardInfo(relativePath);
@@ -3530,7 +3595,7 @@ var CasRevisionStore = class {
3530
3595
  }
3531
3596
  async readDurableBytes(filePath) {
3532
3597
  const relativePath = await this.resolveRelativePath(filePath);
3533
- const baseDir = path9.resolve(this.baseDir);
3598
+ const baseDir = path10.resolve(this.baseDir);
3534
3599
  const target = await resolveSafeStoragePath(baseDir, relativePath);
3535
3600
  try {
3536
3601
  return await readFile2(target);
@@ -3785,7 +3850,7 @@ var CasRevisionHost = class extends CasRevisionStore {
3785
3850
 
3786
3851
  // src/storage/identity-continuity-store.ts
3787
3852
  import { readdir as readdir3 } from "fs/promises";
3788
- import path10 from "path";
3853
+ import path11 from "path";
3789
3854
  var IdentityContinuityStore = class {
3790
3855
  constructor(deps) {
3791
3856
  this.deps = deps;
@@ -3810,7 +3875,7 @@ var IdentityContinuityStore = class {
3810
3875
  const date = nowIso.slice(0, 10);
3811
3876
  const id = this.deps.generateId("incident");
3812
3877
  const incident = createContinuityIncidentRecord(id, input, nowIso);
3813
- const filePath = path10.join(this.deps.identityIncidentsDir, `${date}-${id}.md`);
3878
+ const filePath = path11.join(this.deps.identityIncidentsDir, `${date}-${id}.md`);
3814
3879
  await this.deps.writeStorageSecureFile(filePath, serializeContinuityIncident(incident));
3815
3880
  return { ...incident, filePath };
3816
3881
  }
@@ -3823,7 +3888,7 @@ var IdentityContinuityStore = class {
3823
3888
  const incidents = [];
3824
3889
  for (const file of candidates) {
3825
3890
  if (incidents.length >= cappedLimit) break;
3826
- const filePath = path10.join(this.deps.identityIncidentsDir, file);
3891
+ const filePath = path11.join(this.deps.identityIncidentsDir, file);
3827
3892
  try {
3828
3893
  const raw = await this.deps.readStorageSecureFile(filePath);
3829
3894
  const parsed = parseContinuityIncident(raw);
@@ -3854,7 +3919,7 @@ var IdentityContinuityStore = class {
3854
3919
  await this.deps.ensureDirectories();
3855
3920
  const safeKey = this.sanitizeIdentityAuditKey(key);
3856
3921
  const dir = period === "weekly" ? this.deps.identityAuditsWeeklyDir : this.deps.identityAuditsMonthlyDir;
3857
- const filePath = path10.join(dir, `${safeKey}.md`);
3922
+ const filePath = path11.join(dir, `${safeKey}.md`);
3858
3923
  await this.deps.writeStorageSecureFile(filePath, content);
3859
3924
  return filePath;
3860
3925
  }
@@ -3862,7 +3927,7 @@ var IdentityContinuityStore = class {
3862
3927
  try {
3863
3928
  const safeKey = this.sanitizeIdentityAuditKey(key);
3864
3929
  const dir = period === "weekly" ? this.deps.identityAuditsWeeklyDir : this.deps.identityAuditsMonthlyDir;
3865
- return await this.deps.readStorageSecureFile(path10.join(dir, `${safeKey}.md`));
3930
+ return await this.deps.readStorageSecureFile(path11.join(dir, `${safeKey}.md`));
3866
3931
  } catch (err) {
3867
3932
  if (err instanceof Error && err.message === "Invalid identity audit key") return null;
3868
3933
  if (!isErrnoCode(err, "ENOENT")) throw err;
@@ -3918,12 +3983,12 @@ var IdentityContinuityStore = class {
3918
3983
  const fileNames = await this.readContinuityIncidentFileNames();
3919
3984
  const directMatch = fileNames.find((name) => name.endsWith(`-${id}.md`));
3920
3985
  if (directMatch) {
3921
- const directPath = path10.join(this.deps.identityIncidentsDir, directMatch);
3986
+ const directPath = path11.join(this.deps.identityIncidentsDir, directMatch);
3922
3987
  const parsed = await this.readContinuityIncidentFile(directPath);
3923
3988
  if (parsed?.id === id) return directPath;
3924
3989
  }
3925
3990
  for (const fileName of fileNames) {
3926
- const filePath = path10.join(this.deps.identityIncidentsDir, fileName);
3991
+ const filePath = path11.join(this.deps.identityIncidentsDir, fileName);
3927
3992
  const parsed = await this.readContinuityIncidentFile(filePath);
3928
3993
  if (parsed?.id === id) return filePath;
3929
3994
  }
@@ -4045,11 +4110,11 @@ ${before.content}
4045
4110
  // src/storage/entity-migration-maintenance-pending.ts
4046
4111
  import { randomUUID as randomUUID3 } from "crypto";
4047
4112
  import { readdir as readdir4, rename as rename3, unlink as unlink5, writeFile } from "fs/promises";
4048
- import path11 from "path";
4113
+ import path12 from "path";
4049
4114
  var ENTITY_MIGRATION_MAINTENANCE_PENDING_PREFIX = "entity-canonical-id-maintenance.pending";
4050
4115
  async function writeMaintenancePending(stateDir) {
4051
4116
  const name = `${ENTITY_MIGRATION_MAINTENANCE_PENDING_PREFIX}.${process.pid}-${randomUUID3()}`;
4052
- const destination = path11.join(stateDir, name);
4117
+ const destination = path12.join(stateDir, name);
4053
4118
  const temporary = `${destination}.tmp`;
4054
4119
  try {
4055
4120
  await writeFile(temporary, `${(/* @__PURE__ */ new Date()).toISOString()}
@@ -4073,7 +4138,7 @@ async function listMaintenancePending(stateDir) {
4073
4138
  async function clearMaintenancePending(stateDir, names) {
4074
4139
  for (const name of names) {
4075
4140
  try {
4076
- await unlink5(path11.join(stateDir, name));
4141
+ await unlink5(path12.join(stateDir, name));
4077
4142
  } catch (error) {
4078
4143
  if (!isErrnoCode(error, "ENOENT")) throw error;
4079
4144
  }
@@ -4178,7 +4243,7 @@ var EntityCanonicalIdMigrationRunner = class {
4178
4243
  await this.ensure();
4179
4244
  return;
4180
4245
  }
4181
- const { readSafeEntityEntries } = await import("./entity-canonical-id-migration-74IDJFPB.js");
4246
+ const { readSafeEntityEntries } = await import("./entity-canonical-id-migration-46EMEXTB.js");
4182
4247
  await readSafeEntityEntries(entitiesDir);
4183
4248
  }
4184
4249
  /**
@@ -4278,7 +4343,7 @@ import {
4278
4343
  readFileSync,
4279
4344
  realpathSync
4280
4345
  } from "fs";
4281
- import path12 from "path";
4346
+ import path13 from "path";
4282
4347
  function resolveSafeAliasRoots(baseDir, configDir) {
4283
4348
  let baseStat;
4284
4349
  try {
@@ -4305,8 +4370,8 @@ function resolveSafeAliasRoots(baseDir, configDir) {
4305
4370
  return memoryRoot;
4306
4371
  }
4307
4372
  function readEntityAliasConfigSync(baseDir) {
4308
- const configDir = path12.join(baseDir, "config");
4309
- const aliasPath = path12.join(configDir, "aliases.json");
4373
+ const configDir = path13.join(baseDir, "config");
4374
+ const aliasPath = path13.join(configDir, "aliases.json");
4310
4375
  let memoryRoot = resolveSafeAliasRoots(baseDir, configDir);
4311
4376
  if (memoryRoot === void 0) return void 0;
4312
4377
  let aliasPreflight;
@@ -4368,7 +4433,7 @@ function decodeYamlScalar(value) {
4368
4433
 
4369
4434
  // src/orchestration/qmd-result-resolver.ts
4370
4435
  import { existsSync } from "fs";
4371
- import path13 from "path";
4436
+ import path14 from "path";
4372
4437
  var INTERNAL_QMD_ROOTS = /* @__PURE__ */ new Set([
4373
4438
  ...ALL_CATEGORY_DIRS,
4374
4439
  "activity",
@@ -4390,7 +4455,7 @@ var INTERNAL_QMD_ROOTS = /* @__PURE__ */ new Set([
4390
4455
  ]);
4391
4456
  var PRIVATE_RESULT_RESOLUTION_CONCURRENCY = 16;
4392
4457
  function qmdCollectionPathParts(resultPath) {
4393
- if (!resultPath || path13.isAbsolute(resultPath)) return null;
4458
+ if (!resultPath || path14.isAbsolute(resultPath)) return null;
4394
4459
  if (resultPath.trim().startsWith("qmd://")) {
4395
4460
  try {
4396
4461
  const parsed = new URL(resultPath.trim());
@@ -4415,9 +4480,9 @@ function qmdCollectionPathParts(resultPath) {
4415
4480
  }
4416
4481
  function qmdResultPathCandidates(storageDir, resultPath) {
4417
4482
  const candidates = /* @__PURE__ */ new Set();
4418
- const storageRoot = path13.resolve(storageDir);
4483
+ const storageRoot = path14.resolve(storageDir);
4419
4484
  const addCandidate = (candidate) => {
4420
- const resolved = path13.resolve(candidate);
4485
+ const resolved = path14.resolve(candidate);
4421
4486
  if (isPathInsideStorageRoot(storageRoot, resolved)) {
4422
4487
  candidates.add(resolved);
4423
4488
  }
@@ -4425,18 +4490,18 @@ function qmdResultPathCandidates(storageDir, resultPath) {
4425
4490
  const addRelativeCandidates = (relativePath) => {
4426
4491
  const normalized = relativePath.replace(/\\/g, "/").replace(/^\/+/, "");
4427
4492
  if (!normalized) return;
4428
- addCandidate(path13.join(storageRoot, normalized));
4493
+ addCandidate(path14.join(storageRoot, normalized));
4429
4494
  if (/^\d{4}-\d{2}-\d{2}\//.test(normalized)) {
4430
- addCandidate(path13.join(storageRoot, "facts", normalized));
4495
+ addCandidate(path14.join(storageRoot, "facts", normalized));
4431
4496
  }
4432
4497
  };
4433
- if (path13.isAbsolute(resultPath)) {
4498
+ if (path14.isAbsolute(resultPath)) {
4434
4499
  addCandidate(resultPath);
4435
- const relative2 = path13.relative(storageRoot, path13.resolve(resultPath));
4436
- if (relative2 && !relative2.startsWith("..") && !path13.isAbsolute(relative2)) {
4437
- const normalized = relative2.split(path13.sep).join("/");
4500
+ const relative2 = path14.relative(storageRoot, path14.resolve(resultPath));
4501
+ if (relative2 && !relative2.startsWith("..") && !path14.isAbsolute(relative2)) {
4502
+ const normalized = relative2.split(path14.sep).join("/");
4438
4503
  if (/^\d{4}-\d{2}-\d{2}\//.test(normalized)) {
4439
- addCandidate(path13.join(storageRoot, "facts", normalized));
4504
+ addCandidate(path14.join(storageRoot, "facts", normalized));
4440
4505
  }
4441
4506
  }
4442
4507
  } else {
@@ -4452,9 +4517,9 @@ function normalizeFlatQmdResults(results, config, collection = config.qmdCollect
4452
4517
  }));
4453
4518
  }
4454
4519
  function withHotFactsPath(memoryDir, resolved) {
4455
- const relative2 = path13.relative(path13.resolve(memoryDir), resolved).split(path13.sep).join("/");
4520
+ const relative2 = path14.relative(path14.resolve(memoryDir), resolved).split(path14.sep).join("/");
4456
4521
  if (!/^\d{4}-\d{2}-\d{2}\//.test(relative2) || existsSync(resolved)) return resolved;
4457
- const hot = path13.join(path13.resolve(memoryDir), "facts", relative2);
4522
+ const hot = path14.join(path14.resolve(memoryDir), "facts", relative2);
4458
4523
  return existsSync(hot) ? hot : resolved;
4459
4524
  }
4460
4525
  function storageDirOrNull(storage) {
@@ -4485,7 +4550,7 @@ var QmdResultResolver = class {
4485
4550
  const seenStorageDirs = /* @__PURE__ */ new Set();
4486
4551
  const addStorage = (storage) => {
4487
4552
  const storageDir = storageDirOrNull(storage);
4488
- const storageKey = storageDir ? path13.resolve(storageDir) : `storage-without-dir-${storages.length}`;
4553
+ const storageKey = storageDir ? path14.resolve(storageDir) : `storage-without-dir-${storages.length}`;
4489
4554
  if (seenStorageDirs.has(storageKey)) return;
4490
4555
  seenStorageDirs.add(storageKey);
4491
4556
  storages.push(storage);
@@ -4515,7 +4580,7 @@ var QmdResultResolver = class {
4515
4580
  continue;
4516
4581
  }
4517
4582
  try {
4518
- const coldRoot = path13.join(storageDir, "cold");
4583
+ const coldRoot = path14.join(storageDir, "cold");
4519
4584
  for (const candidate of qmdResultPathCandidates(coldRoot, parts.relativePath)) {
4520
4585
  const memory = await storage.readMemoryByPath(candidate);
4521
4586
  if (memory) return memory;
@@ -4565,9 +4630,9 @@ var QmdResultResolver = class {
4565
4630
  error: err.message
4566
4631
  });
4567
4632
  }
4568
- if (!path13.isAbsolute(fallbackResultPath)) return null;
4633
+ if (!path14.isAbsolute(fallbackResultPath)) return null;
4569
4634
  }
4570
- if (path13.isAbsolute(fallbackResultPath)) {
4635
+ if (path14.isAbsolute(fallbackResultPath)) {
4571
4636
  if (!fallbackStorageDir) {
4572
4637
  return await fallbackStorage.readMemoryByPath(fallbackResultPath);
4573
4638
  }
@@ -4624,17 +4689,17 @@ var QmdResultResolver = class {
4624
4689
  if (!memory && parts && !collectionIsKnownInternal && !collectionIsConfigured) {
4625
4690
  memory = await this.readQmdResultMemory(parts.relativePath, fallbackStorage, namespaces, result.namespace);
4626
4691
  }
4627
- const absoluteInsideMemoryRoot = path13.isAbsolute(result.path) && isPathInsideStorageRoot(path13.resolve(config.memoryDir), path13.resolve(result.path));
4692
+ const absoluteInsideMemoryRoot = path14.isAbsolute(result.path) && isPathInsideStorageRoot(path14.resolve(config.memoryDir), path14.resolve(result.path));
4628
4693
  const hasExplicitQmdCollection = result.path.trim().startsWith("qmd://");
4629
4694
  const unresolvedInternalPath = !memory && (absoluteInsideMemoryRoot || collectionIsKnownInternal && (!preserveUnresolved || hasExplicitQmdCollection) || hasExplicitQmdCollection && collectionIsConfigured);
4630
- const unresolvedExternalCollection = !memory && (parts !== null && !collectionIsKnownInternal && !collectionIsConfigured || path13.isAbsolute(result.path) && !isPathInsideStorageRoot(path13.resolve(config.memoryDir), path13.resolve(result.path)));
4695
+ const unresolvedExternalCollection = !memory && (parts !== null && !collectionIsKnownInternal && !collectionIsConfigured || path14.isAbsolute(result.path) && !isPathInsideStorageRoot(path14.resolve(config.memoryDir), path14.resolve(result.path)));
4631
4696
  return memory !== null && !isSupportPassportPrivateMemory(memory) || !memory && !unresolvedInternalPath && (preserveUnresolved || unresolvedExternalCollection);
4632
4697
  }
4633
4698
  async resolveColdQmdResultForRecall(result, fallbackStorage, recallNamespaces = []) {
4634
4699
  const memory = await this.readQmdResultMemory(result.path, fallbackStorage, recallNamespaces, result.namespace);
4635
4700
  if (!memory) return null;
4636
4701
  let ownerNamespace = null;
4637
- if (path13.isAbsolute(memory.path)) {
4702
+ if (path14.isAbsolute(memory.path)) {
4638
4703
  const ownerStorage = await this.storageForAbsoluteQmdResultPath(memory.path, fallbackStorage, recallNamespaces);
4639
4704
  ownerNamespace = ownerStorage?.namespace ?? null;
4640
4705
  if (!ownerNamespace && resolveNamespaceCapabilities(this.getConfig()).namespaces) return null;
@@ -4655,17 +4720,17 @@ var QmdResultResolver = class {
4655
4720
  };
4656
4721
  }
4657
4722
  async storageForAbsoluteQmdResultPath(resultPath, fallbackStorage, recallNamespaces = []) {
4658
- const resolvedPath = path13.resolve(resultPath);
4723
+ const resolvedPath = path14.resolve(resultPath);
4659
4724
  const config = this.getConfig();
4660
- const memoryRoot = path13.resolve(config.memoryDir);
4661
- const namespacesRoot = path13.join(memoryRoot, "namespaces");
4725
+ const memoryRoot = path14.resolve(config.memoryDir);
4726
+ const namespacesRoot = path14.join(memoryRoot, "namespaces");
4662
4727
  const fallbackStorageDir = storageDirOrNull(fallbackStorage);
4663
4728
  const matches = [];
4664
4729
  const seenDirs = /* @__PURE__ */ new Set();
4665
4730
  const maybeAddStorage = (storage, namespace) => {
4666
4731
  const storageDir = storageDirOrNull(storage);
4667
4732
  if (!storageDir) return;
4668
- const candidateRoot = path13.resolve(storageDir);
4733
+ const candidateRoot = path14.resolve(storageDir);
4669
4734
  if (seenDirs.has(candidateRoot)) return;
4670
4735
  if (!isPathInsideStorageRoot(candidateRoot, resolvedPath)) return;
4671
4736
  if (candidateRoot === memoryRoot && isPathInsideStorageRoot(namespacesRoot, resolvedPath)) {
@@ -4683,7 +4748,7 @@ var QmdResultResolver = class {
4683
4748
  candidateNamespaces.add(ns);
4684
4749
  }
4685
4750
  if (isPathInsideStorageRoot(namespacesRoot, resolvedPath)) {
4686
- const relativeToNamespaces = path13.relative(namespacesRoot, resolvedPath);
4751
+ const relativeToNamespaces = path14.relative(namespacesRoot, resolvedPath);
4687
4752
  const [namespaceSegment] = relativeToNamespaces.split(/[\\/]/);
4688
4753
  if (namespaceSegment) {
4689
4754
  candidateNamespaces.add(namespaceIdentityFromToken(namespaceSegment) ?? namespaceSegment);
@@ -4704,6 +4769,69 @@ var QmdResultResolver = class {
4704
4769
  }
4705
4770
  };
4706
4771
 
4772
+ // src/storage/hot-cache-validation.ts
4773
+ import { stat as stat4 } from "fs/promises";
4774
+ async function publishCorpusAfterScan(host, memories, version, keyId, snapshot) {
4775
+ hotCacheReadStats.fullScans++;
4776
+ if (!host.isHotCacheEnabled() || host.getMemoryCorpusVersion() !== version || host.hotCacheKeyId() !== keyId) {
4777
+ return;
4778
+ }
4779
+ setCachedMemories(host.dir, memories, version, keyId, host.hotCacheTtlMs(), snapshot);
4780
+ }
4781
+ async function readWithStableStat(fullPath, snapshot, read) {
4782
+ if (!snapshot) return { raw: await read(), stat: { mtimeMs: 0, size: 0 } };
4783
+ for (let attempt = 0; attempt < 2; attempt++) {
4784
+ let before;
4785
+ try {
4786
+ const st = await stat4(fullPath);
4787
+ before = { mtimeMs: st.mtimeMs, size: st.size };
4788
+ } catch {
4789
+ return null;
4790
+ }
4791
+ const raw = await read();
4792
+ try {
4793
+ const st = await stat4(fullPath);
4794
+ if (st.mtimeMs === before.mtimeMs && st.size === before.size) {
4795
+ return { raw, stat: before };
4796
+ }
4797
+ } catch {
4798
+ return null;
4799
+ }
4800
+ }
4801
+ return null;
4802
+ }
4803
+ async function serveHotMemoriesValidated(host, abortSignal) {
4804
+ if (!host.isHotCacheEnabled()) return null;
4805
+ const keyId = host.hotCacheKeyId();
4806
+ const cached = getCachedMemories(host.dir, host.getMemoryCorpusVersion(), keyId, host.hotCacheTtlMs());
4807
+ if (cached !== null) return cached;
4808
+ const entry = getHotCacheEntry(host.dir, keyId);
4809
+ if (!entry) return null;
4810
+ const ttlMs = host.hotCacheTtlMs();
4811
+ if (ttlMs > 0 && Date.now() - entry.loadedAt > ttlMs) return null;
4812
+ const versionAtStart = host.getMemoryCorpusVersion();
4813
+ let paths;
4814
+ try {
4815
+ paths = await host.collectActiveMemoryPaths({ abortSignal });
4816
+ } catch {
4817
+ return null;
4818
+ }
4819
+ if (paths.length !== entry.memories.size) return null;
4820
+ const pathSet = new Set(paths);
4821
+ for (const cachedPath of pathSet) {
4822
+ const snap = entry.stats.get(cachedPath);
4823
+ if (!snap) return null;
4824
+ try {
4825
+ const st = await stat4(cachedPath);
4826
+ if (st.mtimeMs !== snap.mtimeMs || st.size !== snap.size) return null;
4827
+ } catch {
4828
+ return null;
4829
+ }
4830
+ }
4831
+ if (host.getMemoryCorpusVersion() !== versionAtStart) return null;
4832
+ return promoteHotCacheVersion(host.dir, versionAtStart, keyId);
4833
+ }
4834
+
4707
4835
  // src/storage/entity-mention-frontmatter-hold.ts
4708
4836
  async function holdMentionNeutralFrontmatter(storage, memory, updated, write) {
4709
4837
  const identities = [
@@ -5345,7 +5473,7 @@ function fuseDay(date, inputs, options = {}) {
5345
5473
 
5346
5474
  // src/wearables/fusion/store.ts
5347
5475
  import { createHash as createHash4 } from "crypto";
5348
- import * as path14 from "path";
5476
+ import * as path15 from "path";
5349
5477
  var FUSION_KIND = "wearable-fusion";
5350
5478
  function hashFusionBody(conversations) {
5351
5479
  return createHash4("sha256").update(JSON.stringify(conversations), "utf-8").digest("hex");
@@ -5532,7 +5660,7 @@ var FusionArtifactStore = class {
5532
5660
  `invalid wearable fusion date '${String(date)}' \u2014 expected YYYY-MM-DD`
5533
5661
  );
5534
5662
  }
5535
- return path14.join(this.wearablesDir, FUSION_DIR_NAME, `${date}.md`);
5663
+ return path15.join(this.wearablesDir, FUSION_DIR_NAME, `${date}.md`);
5536
5664
  }
5537
5665
  async writeFusedDay(date, serialized) {
5538
5666
  const filePath = this.fusedDayPath(date);
@@ -5569,7 +5697,7 @@ var FusionArtifactStore = class {
5569
5697
  }
5570
5698
  /** List dates with stored fused artifacts, newest first. */
5571
5699
  async listFusedDays() {
5572
- const fusionDir = path14.join(this.wearablesDir, FUSION_DIR_NAME);
5700
+ const fusionDir = path15.join(this.wearablesDir, FUSION_DIR_NAME);
5573
5701
  await this.assertPathContained(fusionDir);
5574
5702
  let entries;
5575
5703
  try {
@@ -5613,10 +5741,10 @@ var FusionArtifactStore = class {
5613
5741
  try {
5614
5742
  rootReal = await this.io.realpath(this.memoryDir);
5615
5743
  } catch {
5616
- rootReal = path14.resolve(this.memoryDir);
5744
+ rootReal = path15.resolve(this.memoryDir);
5617
5745
  }
5618
5746
  await this.assertNoEscape(rootReal, this.wearablesDir);
5619
- await this.assertNoEscape(rootReal, path14.dirname(targetPath));
5747
+ await this.assertNoEscape(rootReal, path15.dirname(targetPath));
5620
5748
  await this.assertNoEscape(rootReal, targetPath);
5621
5749
  await this.assertFusionDirNotSymlinked();
5622
5750
  }
@@ -5630,15 +5758,15 @@ var FusionArtifactStore = class {
5630
5758
  * (a fresh write creates a real directory lexically under the root).
5631
5759
  */
5632
5760
  async assertFusionDirNotSymlinked() {
5633
- const fusionDir = path14.join(this.wearablesDir, FUSION_DIR_NAME);
5634
- let stat5;
5761
+ const fusionDir = path15.join(this.wearablesDir, FUSION_DIR_NAME);
5762
+ let stat7;
5635
5763
  try {
5636
- stat5 = await this.io.lstat(fusionDir);
5764
+ stat7 = await this.io.lstat(fusionDir);
5637
5765
  } catch (err) {
5638
5766
  if (err.code === "ENOENT") return;
5639
5767
  throw err;
5640
5768
  }
5641
- if (stat5.isSymbolicLink) {
5769
+ if (stat7.isSymbolicLink) {
5642
5770
  throw new Error(
5643
5771
  "wearable fusion dir '_fusion' is a symbolic link \u2014 refusing to follow it even when it resolves inside the memory dir (AGENTS.md pattern #3)"
5644
5772
  );
@@ -5766,7 +5894,7 @@ function reconstructFusionInputs(date, dayTranscripts) {
5766
5894
 
5767
5895
  // src/meetings/store.ts
5768
5896
  import { createHash as createHash5 } from "crypto";
5769
- import * as path15 from "path";
5897
+ import * as path16 from "path";
5770
5898
  var MEETINGS_DIR_NAME = "meetings";
5771
5899
  var MEETING_KIND = "meeting";
5772
5900
  var MEETING_FORMAT_VERSION = 1;
@@ -5935,7 +6063,7 @@ var MeetingRecordStore = class {
5935
6063
  constructor(memoryDir, io) {
5936
6064
  this.memoryDir = memoryDir;
5937
6065
  this.io = io;
5938
- this.meetingsDir = path15.join(memoryDir, MEETINGS_DIR_NAME);
6066
+ this.meetingsDir = path16.join(memoryDir, MEETINGS_DIR_NAME);
5939
6067
  }
5940
6068
  memoryDir;
5941
6069
  io;
@@ -5951,7 +6079,7 @@ var MeetingRecordStore = class {
5951
6079
  if (idDate !== date) {
5952
6080
  throw new Error(`meeting id '${id}' does not belong to date '${date}'`);
5953
6081
  }
5954
- return path15.join(this.meetingsDir, date, `${id}.md`);
6082
+ return path16.join(this.meetingsDir, date, `${id}.md`);
5955
6083
  }
5956
6084
  /** Idempotently persist a record: skip the write when contentHash is unchanged. */
5957
6085
  async saveMeetingRecord(record) {
@@ -5982,7 +6110,7 @@ var MeetingRecordStore = class {
5982
6110
  if (!isValidTranscriptDate(date)) {
5983
6111
  throw new Error(`invalid meeting date '${String(date)}' \u2014 expected YYYY-MM-DD`);
5984
6112
  }
5985
- const dayDir = path15.join(this.meetingsDir, date);
6113
+ const dayDir = path16.join(this.meetingsDir, date);
5986
6114
  await this.assertPathContained(dayDir);
5987
6115
  let entries;
5988
6116
  try {
@@ -6050,10 +6178,10 @@ var MeetingRecordStore = class {
6050
6178
  try {
6051
6179
  rootReal = await this.io.realpath(this.memoryDir);
6052
6180
  } catch {
6053
- rootReal = path15.resolve(this.memoryDir);
6181
+ rootReal = path16.resolve(this.memoryDir);
6054
6182
  }
6055
6183
  await this.assertNoEscape(rootReal, this.meetingsDir);
6056
- await this.assertNoEscape(rootReal, path15.dirname(targetPath));
6184
+ await this.assertNoEscape(rootReal, path16.dirname(targetPath));
6057
6185
  await this.assertNoEscape(rootReal, targetPath);
6058
6186
  await this.assertNotSymlink(this.meetingsDir, "directory");
6059
6187
  const dayDir = this.dayDirWithin(targetPath);
@@ -6063,22 +6191,22 @@ var MeetingRecordStore = class {
6063
6191
  /** The `<meetings>/<date>` directory on the path to `targetPath`, or null when
6064
6192
  * `targetPath` is the meetings root itself. */
6065
6193
  dayDirWithin(targetPath) {
6066
- const rel = path15.relative(this.meetingsDir, targetPath);
6067
- if (rel === "" || rel.startsWith("..") || path15.isAbsolute(rel)) return null;
6068
- const first = rel.split(path15.sep)[0];
6194
+ const rel = path16.relative(this.meetingsDir, targetPath);
6195
+ if (rel === "" || rel.startsWith("..") || path16.isAbsolute(rel)) return null;
6196
+ const first = rel.split(path16.sep)[0];
6069
6197
  if (first === void 0 || first.length === 0) return null;
6070
- return path15.join(this.meetingsDir, first);
6198
+ return path16.join(this.meetingsDir, first);
6071
6199
  }
6072
6200
  async assertNotSymlink(target, kind) {
6073
- let stat5;
6201
+ let stat7;
6074
6202
  try {
6075
- stat5 = await this.io.lstat(target);
6203
+ stat7 = await this.io.lstat(target);
6076
6204
  } catch (err) {
6077
6205
  if (err.code === "ENOENT") return;
6078
6206
  throw err;
6079
6207
  }
6080
- if (stat5.isSymbolicLink) {
6081
- const label = path15.relative(this.memoryDir, target) || MEETINGS_DIR_NAME;
6208
+ if (stat7.isSymbolicLink) {
6209
+ const label = path16.relative(this.memoryDir, target) || MEETINGS_DIR_NAME;
6082
6210
  throw new Error(
6083
6211
  `meetings ${kind} '${label}' is a symbolic link \u2014 refusing to follow it even when it resolves inside the memory dir (AGENTS.md pattern #3)`
6084
6212
  );
@@ -6102,7 +6230,7 @@ var SORT_STR = (a, b) => a < b ? -1 : a > b ? 1 : 0;
6102
6230
 
6103
6231
  // src/storage/supersession-audit.ts
6104
6232
  import { readdir as readdir5 } from "fs/promises";
6105
- import path16 from "path";
6233
+ import path17 from "path";
6106
6234
  async function hasSupersessionAudit(lookup, oldMemoryId, newMemoryId, auditBody, structuredAttributes) {
6107
6235
  let entries;
6108
6236
  try {
@@ -6114,7 +6242,7 @@ async function hasSupersessionAudit(lookup, oldMemoryId, newMemoryId, auditBody,
6114
6242
  for (const entry of entries) {
6115
6243
  if (isMacOsReplicationJunkBasename(entry.name)) continue;
6116
6244
  if (!entry.isFile() || !entry.name.endsWith(".md")) continue;
6117
- const memory = await lookup.readMemoryByPath(path16.join(lookup.correctionsDir, entry.name));
6245
+ const memory = await lookup.readMemoryByPath(path17.join(lookup.correctionsDir, entry.name));
6118
6246
  if (memory?.frontmatter.category === "correction" && (memory.frontmatter.sourceMemoryId === oldMemoryId || memory.frontmatter.sourceMemoryId === void 0 && memory.frontmatter.lineage?.includes(oldMemoryId)) && memory.frontmatter.lineage?.includes(newMemoryId) && stripAttributesSuffix(memory.content) === auditBody && (structuredAttributes === void 0 || Object.entries(structuredAttributes).every(
6119
6247
  ([key, value]) => memory.frontmatter.structuredAttributes?.[key] === value
6120
6248
  ))) {
@@ -6206,12 +6334,12 @@ Reason: ${reason}`;
6206
6334
  // src/storage/dropped-extraction-chunk.ts
6207
6335
  import { randomUUID as randomUUID4 } from "crypto";
6208
6336
  import { mkdir as mkdir3 } from "fs/promises";
6209
- import path17 from "path";
6337
+ import path18 from "path";
6210
6338
  async function saveDroppedExtractionChunk(stateDir, writeSecureFile, bufferKey, reason, turns) {
6211
- const droppedDir = path17.join(stateDir, "dropped");
6339
+ const droppedDir = path18.join(stateDir, "dropped");
6212
6340
  await mkdir3(droppedDir, { recursive: true });
6213
6341
  const safeKey = bufferKey.replace(/[^a-zA-Z0-9._-]/g, "-").slice(0, 80) || "default";
6214
- const filePath = path17.join(droppedDir, `${Date.now()}-${randomUUID4().slice(0, 8)}-${safeKey}.json`);
6342
+ const filePath = path18.join(droppedDir, `${Date.now()}-${randomUUID4().slice(0, 8)}-${safeKey}.json`);
6215
6343
  const payload = { bufferKey, reason, droppedAt: (/* @__PURE__ */ new Date()).toISOString(), turns };
6216
6344
  await writeSecureFile(filePath, JSON.stringify(payload, null, 2));
6217
6345
  return filePath;
@@ -6684,14 +6812,14 @@ function isEntitySynthesisStale(entity) {
6684
6812
  // src/storage/tombstone-blocked-capture-index.ts
6685
6813
  import { execFile } from "child_process";
6686
6814
  import { randomUUID as randomUUID6 } from "crypto";
6687
- import { mkdir as mkdir4, readFile as readFile3, readdir as readdir6, rename as rename4, stat as stat3, unlink as unlink7, writeFile as writeFile2 } from "fs/promises";
6688
- import path19 from "path";
6815
+ import { mkdir as mkdir4, readFile as readFile3, readdir as readdir6, rename as rename4, stat as stat5, unlink as unlink7, writeFile as writeFile2 } from "fs/promises";
6816
+ import path20 from "path";
6689
6817
  import { promisify } from "util";
6690
6818
 
6691
6819
  // src/storage/tombstone-blocked-capture-sync.ts
6692
6820
  import { createHash as createHash7, randomUUID as randomUUID5 } from "crypto";
6693
6821
  import { unlink as unlink6 } from "fs/promises";
6694
- import path18 from "path";
6822
+ import path19 from "path";
6695
6823
  import { isDeepStrictEqual } from "util";
6696
6824
  var OFFLINE_SYNC_BUFFER_LIMIT_BYTES = 1048576;
6697
6825
  var OFFLINE_SYNC_STAGE_READ_BYTES = 64 * 1024;
@@ -7048,7 +7176,7 @@ var TombstoneBlockedCaptureIndexHost = class {
7048
7176
  this.invalidateAllMemoriesCache();
7049
7177
  this.invalidateKnowledgeIndexCache();
7050
7178
  this.markFactHashIndexNotAuthoritative();
7051
- if (filePath.includes(`${path18.sep}cold${path18.sep}`)) {
7179
+ if (filePath.includes(`${path19.sep}cold${path19.sep}`)) {
7052
7180
  this.invalidateColdMemoriesCache();
7053
7181
  }
7054
7182
  if (blockedKeySetMayHaveChanged) {
@@ -7061,7 +7189,7 @@ var TombstoneBlockedCaptureIndexHost = class {
7061
7189
  log.warn(`storage.offlineSyncFile committed write succeeded; marker cleanup failed: ${err}`);
7062
7190
  }
7063
7191
  }
7064
- if (filePath.includes(`${path18.sep}artifacts${path18.sep}`)) {
7192
+ if (filePath.includes(`${path19.sep}artifacts${path19.sep}`)) {
7065
7193
  this.bumpArtifactWriteVersion();
7066
7194
  }
7067
7195
  const memoryDir = this.tombstoneBlockedCaptureIndexOptions().memoryDir;
@@ -7156,7 +7284,7 @@ var TombstoneBlockedCaptureIndexHost = class {
7156
7284
  bumpArchiveMutationForPath(memoryDir, true, current.path);
7157
7285
  markProjectedMemoryPathInvalid(memoryDir, current.frontmatter.id);
7158
7286
  this.invalidateAllMemoriesCache();
7159
- if (current.path.includes(`${path18.sep}cold${path18.sep}`)) {
7287
+ if (current.path.includes(`${path19.sep}cold${path19.sep}`)) {
7160
7288
  this.invalidateColdMemoriesCache();
7161
7289
  }
7162
7290
  await this.rebuildTombstoneBlockedCaptureAfterInvalidation(rebuildMarker);
@@ -7239,7 +7367,7 @@ var TombstoneBlockedCaptureIndexHost = class {
7239
7367
  async writeTombstoneBlockedOfflineSyncFile(target, content) {
7240
7368
  const options = this.tombstoneBlockedCaptureIndexOptions();
7241
7369
  const after = options.parseMemory?.(target, content) ?? null;
7242
- await withRawEntityPageMutation(path18.dirname(options.stateDir), target, async () => {
7370
+ await withRawEntityPageMutation(path19.dirname(options.stateDir), target, async () => {
7243
7371
  await this.runTombstoneBlockedOfflineSyncMutation(
7244
7372
  target,
7245
7373
  after,
@@ -7278,7 +7406,7 @@ var TombstoneBlockedCaptureIndexHost = class {
7278
7406
  return { after, chunks: replay };
7279
7407
  }
7280
7408
  const options = this.tombstoneBlockedCaptureIndexOptions();
7281
- const stagePath = path18.join(
7409
+ const stagePath = path19.join(
7282
7410
  options.stateDir,
7283
7411
  "tombstone-blocked-capture",
7284
7412
  "offline-sync-staging",
@@ -7403,7 +7531,7 @@ var TombstoneBlockedCaptureIndexHost = class {
7403
7531
  const coordinate = this.getTombstoneBlockedCaptureIndex().shouldRebuildAfterInvalidationForPath(target);
7404
7532
  const prepared = coordinate ? await this.prepareTombstoneBlockedOfflineSyncChunks(target, chunks) : { after: null, chunks };
7405
7533
  const streamedIdentity = prepared.streamedIdentity;
7406
- const baseDir = path18.dirname(this.tombstoneBlockedCaptureIndexOptions().stateDir);
7534
+ const baseDir = path19.dirname(this.tombstoneBlockedCaptureIndexOptions().stateDir);
7407
7535
  try {
7408
7536
  await withRawEntityPageMutation(baseDir, target, async () => {
7409
7537
  await this.runTombstoneBlockedOfflineSyncMutation(
@@ -7435,7 +7563,7 @@ var TombstoneBlockedCaptureIndexHost = class {
7435
7563
  */
7436
7564
  async requestSyncReconcileIfMigrationPath(target) {
7437
7565
  const stateDir = this.tombstoneBlockedCaptureIndexOptions().stateDir;
7438
- if (!pathMayCarryEntityRefs(path18.dirname(stateDir), target)) return;
7566
+ if (!pathMayCarryEntityRefs(path19.dirname(stateDir), target)) return;
7439
7567
  await requestEntityCanonicalIdReconcile(stateDir);
7440
7568
  }
7441
7569
  async deleteOfflineSyncFile(filePath, deletionMtimeMs) {
@@ -7445,7 +7573,7 @@ var TombstoneBlockedCaptureIndexHost = class {
7445
7573
  }
7446
7574
  async deleteTombstoneBlockedOfflineSyncFile(target, deletionMtimeMs) {
7447
7575
  const stateDir = this.tombstoneBlockedCaptureIndexOptions().stateDir;
7448
- await withRawEntityPageMutation(path18.dirname(stateDir), target, async () => {
7576
+ await withRawEntityPageMutation(path19.dirname(stateDir), target, async () => {
7449
7577
  await this.runTombstoneBlockedOfflineSyncMutation(target, null, async () => {
7450
7578
  return await this.deleteManagedStorageFile(target, deletionMtimeMs);
7451
7579
  });
@@ -7496,7 +7624,7 @@ var TombstoneBlockedCaptureIndex = class {
7496
7624
  }
7497
7625
  createIndex() {
7498
7626
  return new ContentHashIndex(
7499
- path19.join(this.options.stateDir, "tombstone-blocked-capture"),
7627
+ path20.join(this.options.stateDir, "tombstone-blocked-capture"),
7500
7628
  this.options.secureStoreKeyProvider,
7501
7629
  this.options.secureStoreWriteKeyProvider,
7502
7630
  this.options.memoryDir,
@@ -7504,17 +7632,17 @@ var TombstoneBlockedCaptureIndex = class {
7504
7632
  );
7505
7633
  }
7506
7634
  indexPath() {
7507
- return path19.join(this.options.stateDir, "tombstone-blocked-capture", "fact-hashes.txt");
7635
+ return path20.join(this.options.stateDir, "tombstone-blocked-capture", "fact-hashes.txt");
7508
7636
  }
7509
7637
  rebuildMarkerPath() {
7510
- return path19.join(this.options.stateDir, "tombstone-blocked-capture", "rebuild-required");
7638
+ return path20.join(this.options.stateDir, "tombstone-blocked-capture", "rebuild-required");
7511
7639
  }
7512
7640
  async readRebuildMarkers() {
7513
7641
  try {
7514
7642
  const entries = (await readdir6(this.rebuildMarkerPath())).filter((entry) => !entry.startsWith("."));
7515
7643
  return (await Promise.all(
7516
7644
  entries.map(async (entry) => {
7517
- const markerPath = path19.join(this.rebuildMarkerPath(), entry);
7645
+ const markerPath = path20.join(this.rebuildMarkerPath(), entry);
7518
7646
  try {
7519
7647
  const raw = (await readFile3(markerPath, "utf8")).trim();
7520
7648
  if (raw === "committed") return { path: markerPath, committed: true };
@@ -7534,10 +7662,10 @@ var TombstoneBlockedCaptureIndex = class {
7534
7662
  }
7535
7663
  const state = value.state;
7536
7664
  if (state !== "pending" && state !== "committed") malformed = true;
7537
- const markerStat = await stat3(markerPath).catch(() => null);
7665
+ const markerStat = await stat5(markerPath).catch(() => null);
7538
7666
  const createdAt = typeof value.createdAt === "number" && Number.isFinite(value.createdAt) ? value.createdAt : markerStat?.mtimeMs;
7539
7667
  if (typeof value.pid !== "number" || !Number.isInteger(value.pid)) malformed = true;
7540
- const ownerId = typeof value.ownerId === "string" && value.ownerId.length > 0 ? value.ownerId : path19.basename(markerPath);
7668
+ const ownerId = typeof value.ownerId === "string" && value.ownerId.length > 0 ? value.ownerId : path20.basename(markerPath);
7541
7669
  if (typeof value.ownerId !== "string" || value.ownerId.length === 0) malformed = true;
7542
7670
  const processStartedAtMs = typeof value.processStartedAtMs === "number" && Number.isFinite(value.processStartedAtMs) && value.processStartedAtMs > 0 ? value.processStartedAtMs : void 0;
7543
7671
  return {
@@ -7631,7 +7759,7 @@ var TombstoneBlockedCaptureIndex = class {
7631
7759
  const markerDir = this.rebuildMarkerPath();
7632
7760
  await mkdir4(markerDir, { recursive: true });
7633
7761
  const ownerId = randomUUID6();
7634
- const markerPath = path19.join(markerDir, ownerId);
7762
+ const markerPath = path20.join(markerDir, ownerId);
7635
7763
  await this.writeMarkerAtomically(
7636
7764
  markerPath,
7637
7765
  `${JSON.stringify({
@@ -7651,7 +7779,7 @@ var TombstoneBlockedCaptureIndex = class {
7651
7779
  `${JSON.stringify({
7652
7780
  state: "committed",
7653
7781
  pid: process.pid,
7654
- ownerId: path19.basename(markerPath),
7782
+ ownerId: path20.basename(markerPath),
7655
7783
  createdAt: Date.now(),
7656
7784
  processStartedAtMs: MARKER_PROCESS_STARTED_AT_MS
7657
7785
  })}
@@ -7693,7 +7821,7 @@ var TombstoneBlockedCaptureIndex = class {
7693
7821
  }
7694
7822
  async hasPersistedIndexOrMarkers() {
7695
7823
  try {
7696
- await stat3(this.indexPath());
7824
+ await stat5(this.indexPath());
7697
7825
  return true;
7698
7826
  } catch (err) {
7699
7827
  if (!isErrnoCode(err, "ENOENT")) throw err;
@@ -7710,7 +7838,7 @@ var TombstoneBlockedCaptureIndex = class {
7710
7838
  const clearableRebuildMarkers = await this.getClearableRebuildMarkerPaths(rebuildMarkers);
7711
7839
  let persisted = !index.requiresFormatMigration;
7712
7840
  try {
7713
- await stat3(this.indexPath());
7841
+ await stat5(this.indexPath());
7714
7842
  if (rebuildMarkers.length > 0) persisted = false;
7715
7843
  } catch (err) {
7716
7844
  if (isErrnoCode(err, "ENOENT")) persisted = false;
@@ -7903,8 +8031,8 @@ var TombstoneBlockedCaptureIndex = class {
7903
8031
  await this.failOpen("writeMemoryFrontmatter", () => this.sync(before, { ...before, frontmatter }, rebuildMarker));
7904
8032
  }
7905
8033
  shouldRebuildAfterInvalidationForPath(filePath) {
7906
- const relative2 = path19.relative(path19.resolve(this.options.memoryDir), path19.resolve(filePath));
7907
- const category = relative2.split(path19.sep)[0];
8034
+ const relative2 = path20.relative(path20.resolve(this.options.memoryDir), path20.resolve(filePath));
8035
+ const category = relative2.split(path20.sep)[0];
7908
8036
  return category === "cold" || RECALL_FALLBACK_DIRS.includes(category);
7909
8037
  }
7910
8038
  };
@@ -8432,17 +8560,17 @@ function inferEntityTypeFromContent(content) {
8432
8560
  }
8433
8561
  var KNOWN_ENTITY_FILENAME_PREFIXES = /* @__PURE__ */ new Set(["company", "other", "person", "place", "project", "tool", "topic"]);
8434
8562
  function inferEntityTypeFromFilename(pathRel) {
8435
- const basename = path20.basename(pathRel, ".md").toLowerCase();
8563
+ const basename = path21.basename(pathRel, ".md").toLowerCase();
8436
8564
  const separator = basename.indexOf("-");
8437
8565
  if (separator <= 0) return void 0;
8438
8566
  const candidate = basename.slice(0, separator);
8439
8567
  return KNOWN_ENTITY_FILENAME_PREFIXES.has(candidate) ? candidate : void 0;
8440
8568
  }
8441
8569
  function normalizeFrontmatterForPath(frontmatter, pathRel, content = "") {
8442
- const normalizedPath = pathRel.split(path20.sep).join("/");
8570
+ const normalizedPath = pathRel.split(path21.sep).join("/");
8443
8571
  let normalizedFrontmatter = frontmatter;
8444
8572
  if (normalizedPath === "entities" || normalizedPath.startsWith("entities/") || normalizedPath.includes("/entities/")) {
8445
- const basename = path20.basename(pathRel, ".md");
8573
+ const basename = path21.basename(pathRel, ".md");
8446
8574
  const inferredType = inferEntityTypeFromContent(content) || inferEntityTypeFromFilename(pathRel) || "entity";
8447
8575
  const existingTags = Array.isArray(frontmatter.tags) ? frontmatter.tags : [];
8448
8576
  normalizedFrontmatter = {
@@ -8915,9 +9043,9 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
8915
9043
  this.entitySchemas = entitySchemas;
8916
9044
  this.deletionRevisionStore = new DeletionRevisionStore({
8917
9045
  baseDir,
8918
- deletionRevisionMetadataPath: path20.join(baseDir, ".offline-sync", "deletion-revisions.v1.json"),
8919
- invalidationCommitMetadataPath: path20.join(baseDir, ".offline-sync", "invalidation-commits.v1.json"),
8920
- deletionRevisionLockPath: path20.join(baseDir, ".offline-sync", "deletion-revisions.v1.json.lock"),
9046
+ deletionRevisionMetadataPath: path21.join(baseDir, ".offline-sync", "deletion-revisions.v1.json"),
9047
+ invalidationCommitMetadataPath: path21.join(baseDir, ".offline-sync", "invalidation-commits.v1.json"),
9048
+ deletionRevisionLockPath: path21.join(baseDir, ".offline-sync", "deletion-revisions.v1.json.lock"),
8921
9049
  assertManagedStoragePath: (filePath, method) => this.assertManagedStoragePath(filePath, method)
8922
9050
  });
8923
9051
  this.casRevisions = new CasRevisionHost(baseDir);
@@ -9106,8 +9234,8 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
9106
9234
  }
9107
9235
  /** Whether `filePath` resolves to `stateDir` itself or a path contained in it. */
9108
9236
  isStateFilePath(filePath) {
9109
- const rel = path20.relative(this.stateDir, path20.resolve(filePath));
9110
- return rel === "" || !rel.startsWith("..") && !path20.isAbsolute(rel);
9237
+ const rel = path21.relative(this.stateDir, path21.resolve(filePath));
9238
+ return rel === "" || !rel.startsWith("..") && !path21.isAbsolute(rel);
9111
9239
  }
9112
9240
  // ── Tombstone store (issue #1579) ───────────────────────────────────────
9113
9241
  // Instance-scoped (rule 11) + namespace-scoped (rule 42) tombstone index.
@@ -9222,8 +9350,8 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
9222
9350
  * /srv/cold/remnic), skipping the patch and stranding a stale hot entry.
9223
9351
  */
9224
9352
  isColdOrArchiveTierPath(p) {
9225
- const rel = path20.relative(this.baseDir, p);
9226
- return rel === "cold" || rel === "archive" || rel.startsWith(`cold${path20.sep}`) || rel.startsWith(`archive${path20.sep}`);
9353
+ const rel = path21.relative(this.baseDir, p);
9354
+ return rel === "cold" || rel === "archive" || rel.startsWith(`cold${path21.sep}`) || rel.startsWith(`archive${path21.sep}`);
9227
9355
  }
9228
9356
  /**
9229
9357
  * Mark the secure-store as required for this storage instance.
@@ -9310,7 +9438,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
9310
9438
  void 0,
9311
9439
  this.baseDir
9312
9440
  );
9313
- const rel = path20.relative(this.baseDir, filePath).split(path20.sep).join("/");
9441
+ const rel = path21.relative(this.baseDir, filePath).split(path21.sep).join("/");
9314
9442
  return `${rel}:${version.versionId}`;
9315
9443
  } catch (err) {
9316
9444
  log.warn(
@@ -9355,10 +9483,10 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
9355
9483
  _StorageManager.okfConformanceByDir.set(memoryDir, enabled !== false);
9356
9484
  }
9357
9485
  okfConformanceEnabled() {
9358
- for (let dir = this.baseDir; ; dir = path20.dirname(dir)) {
9486
+ for (let dir = this.baseDir; ; dir = path21.dirname(dir)) {
9359
9487
  const registered = _StorageManager.okfConformanceByDir.get(dir);
9360
9488
  if (registered !== void 0) return registered;
9361
- if (dir === path20.dirname(dir)) return true;
9489
+ if (dir === path21.dirname(dir)) return true;
9362
9490
  }
9363
9491
  }
9364
9492
  /**
@@ -9402,12 +9530,12 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
9402
9530
  }
9403
9531
  identityFilePath(workspaceDir, namespace) {
9404
9532
  const rawNamespace = typeof namespace === "string" ? namespace.trim() : "";
9405
- if (!rawNamespace) return path20.join(workspaceDir, "IDENTITY.md");
9533
+ if (!rawNamespace) return path21.join(workspaceDir, "IDENTITY.md");
9406
9534
  const safeNamespace = rawNamespace.replace(/[^a-zA-Z0-9._-]/g, "-");
9407
- return path20.join(workspaceDir, `IDENTITY.${safeNamespace}.md`);
9535
+ return path21.join(workspaceDir, `IDENTITY.${safeNamespace}.md`);
9408
9536
  }
9409
9537
  versionFilePath(kind) {
9410
- return path20.join(this.stateDir, `.${kind}-version.log`);
9538
+ return path21.join(this.stateDir, `.${kind}-version.log`);
9411
9539
  }
9412
9540
  bumpSharedVersion(kind, fallbackMap) {
9413
9541
  const filePath = this.versionFilePath(kind);
@@ -9514,7 +9642,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
9514
9642
  // memories.
9515
9643
  // -------------------------------------------------------------------------
9516
9644
  get wearablesDir() {
9517
- return path20.join(this.baseDir, WEARABLES_DIR_NAME);
9645
+ return path21.join(this.baseDir, WEARABLES_DIR_NAME);
9518
9646
  }
9519
9647
  /**
9520
9648
  * Resolve the on-disk path for a source/day transcript. Throws on
@@ -9530,7 +9658,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
9530
9658
  if (!isValidTranscriptDate(date)) {
9531
9659
  throw new Error(`invalid wearable transcript date '${String(date)}' \u2014 expected YYYY-MM-DD`);
9532
9660
  }
9533
- return path20.join(this.wearablesDir, sourceId, `${date}.md`);
9661
+ return path21.join(this.wearablesDir, sourceId, `${date}.md`);
9534
9662
  }
9535
9663
  async writeWearableDayTranscript(sourceId, date, serialized) {
9536
9664
  const targetPath = this.wearableTranscriptPath(sourceId, date);
@@ -9644,25 +9772,25 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
9644
9772
  });
9645
9773
  }
9646
9774
  get factsDir() {
9647
- return path20.join(this.baseDir, "facts");
9775
+ return path21.join(this.baseDir, "facts");
9648
9776
  }
9649
9777
  get correctionsDir() {
9650
- return path20.join(this.baseDir, "corrections");
9778
+ return path21.join(this.baseDir, "corrections");
9651
9779
  }
9652
9780
  get proceduresDir() {
9653
- return path20.join(this.baseDir, "procedures");
9781
+ return path21.join(this.baseDir, "procedures");
9654
9782
  }
9655
9783
  get reasoningTracesDir() {
9656
- return path20.join(this.baseDir, "reasoning-traces");
9784
+ return path21.join(this.baseDir, "reasoning-traces");
9657
9785
  }
9658
9786
  get entitiesDir() {
9659
- return path20.join(this.baseDir, "entities");
9787
+ return path21.join(this.baseDir, "entities");
9660
9788
  }
9661
9789
  resolveEntityFilePath(name) {
9662
9790
  if (typeof name !== "string") return null;
9663
- const filePath = path20.resolve(this.entitiesDir, `${name}.md`);
9664
- const relative2 = path20.relative(this.entitiesDir, filePath);
9665
- if (relative2 === "" || relative2.startsWith("..") || path20.isAbsolute(relative2)) {
9791
+ const filePath = path21.resolve(this.entitiesDir, `${name}.md`);
9792
+ const relative2 = path21.relative(this.entitiesDir, filePath);
9793
+ if (relative2 === "" || relative2.startsWith("..") || path21.isAbsolute(relative2)) {
9666
9794
  return null;
9667
9795
  }
9668
9796
  return filePath;
@@ -9673,7 +9801,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
9673
9801
  async readDependencyPropagationQueueFile(filePath) {
9674
9802
  const target = await resolveSafeStoragePath(
9675
9803
  this.baseDir,
9676
- path20.relative(
9804
+ path21.relative(
9677
9805
  this.baseDir,
9678
9806
  this.assertManagedStoragePath(filePath, "storage.readDependencyPropagationQueueFile")
9679
9807
  )
@@ -9683,7 +9811,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
9683
9811
  async writeDependencyPropagationQueueFile(filePath, content) {
9684
9812
  const target = await resolveSafeStoragePath(
9685
9813
  this.baseDir,
9686
- path20.relative(
9814
+ path21.relative(
9687
9815
  this.baseDir,
9688
9816
  this.assertManagedStoragePath(filePath, "storage.writeDependencyPropagationQueueFile")
9689
9817
  )
@@ -9698,10 +9826,10 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
9698
9826
  });
9699
9827
  }
9700
9828
  assertManagedStoragePath(filePath, method) {
9701
- const resolved = path20.resolve(filePath);
9702
- const base = path20.resolve(this.baseDir);
9703
- const rel = path20.relative(base, resolved);
9704
- if (rel === "" || rel === ".." || rel.startsWith(`..${path20.sep}`) || path20.isAbsolute(rel)) {
9829
+ const resolved = path21.resolve(filePath);
9830
+ const base = path21.resolve(this.baseDir);
9831
+ const rel = path21.relative(base, resolved);
9832
+ if (rel === "" || rel === ".." || rel.startsWith(`..${path21.sep}`) || path21.isAbsolute(rel)) {
9705
9833
  throw new Error(`${method}: file path escapes memory dir`);
9706
9834
  }
9707
9835
  return resolved;
@@ -9737,8 +9865,8 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
9737
9865
  }
9738
9866
  async digestOfflineSyncFile(filePath) {
9739
9867
  const target = this.assertManagedStoragePath(filePath, "storage.digestOfflineSyncFile");
9740
- const st = await stat4(target);
9741
- const relPath = path20.relative(this.baseDir, target).split(path20.sep).join("/");
9868
+ const st = await stat6(target);
9869
+ const relPath = path21.relative(this.baseDir, target).split(path21.sep).join("/");
9742
9870
  const cache = await this.loadOfflineSyncDigestCache();
9743
9871
  const cached = cache.get(relPath);
9744
9872
  if (cached && cached.statBytes === st.size && cached.mtimeMs === st.mtimeMs && cached.ctimeMs === st.ctimeMs && !cached.encrypted) {
@@ -9823,7 +9951,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
9823
9951
  const cache = this.offlineSyncDigestCache;
9824
9952
  if (!cache) return;
9825
9953
  const entries = [...cache.entries()].sort(([a], [b]) => a.localeCompare(b)).map(([entryPath, entry]) => ({ path: entryPath, ...entry }));
9826
- await mkdir5(path20.dirname(this.offlineSyncDigestCachePath), { recursive: true });
9954
+ await mkdir5(path21.dirname(this.offlineSyncDigestCachePath), { recursive: true });
9827
9955
  await writeFile3(this.offlineSyncDigestCachePath, `${JSON.stringify({ version: 1, entries })}
9828
9956
  `, "utf-8");
9829
9957
  }).catch((err) => {
@@ -9893,7 +10021,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
9893
10021
  async isEncryptedFileHeader(filePath) {
9894
10022
  let st;
9895
10023
  try {
9896
- st = await stat4(filePath);
10024
+ st = await stat6(filePath);
9897
10025
  } catch (err) {
9898
10026
  if (isErrnoCode(err, "ENOENT")) return false;
9899
10027
  throw err;
@@ -9924,7 +10052,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
9924
10052
  }
9925
10053
  async appendStorageSecureFileUnlocked(filePath, content) {
9926
10054
  const writeKey = this.resolveWriteKey();
9927
- await mkdir5(path20.dirname(filePath), { recursive: true });
10055
+ await mkdir5(path21.dirname(filePath), { recursive: true });
9928
10056
  if (writeKey === null) {
9929
10057
  try {
9930
10058
  if (await this.isEncryptedFileHeader(filePath)) {
@@ -9950,13 +10078,13 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
9950
10078
  this.notifyCatalogWriteForPath(filePath);
9951
10079
  }
9952
10080
  get stateDir() {
9953
- return path20.join(this.baseDir, "state");
10081
+ return path21.join(this.baseDir, "state");
9954
10082
  }
9955
10083
  get offlineSyncDigestCachePath() {
9956
- return path20.join(this.baseDir, ".offline-sync", "digest-cache.v1.json");
10084
+ return path21.join(this.baseDir, ".offline-sync", "digest-cache.v1.json");
9957
10085
  }
9958
10086
  get entitySynthesisQueuePath() {
9959
- return path20.join(this.stateDir, "entity-synthesis-queue.json");
10087
+ return path21.join(this.stateDir, "entity-synthesis-queue.json");
9960
10088
  }
9961
10089
  // ── Tombstone store access (issue #1579) ─────────────────────────────────
9962
10090
  /**
@@ -9966,7 +10094,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
9966
10094
  * helpers are injected into the store).
9967
10095
  */
9968
10096
  get tombstonesPath() {
9969
- return path20.join(this.stateDir, "tombstones.jsonl");
10097
+ return path21.join(this.stateDir, "tombstones.jsonl");
9970
10098
  }
9971
10099
  /**
9972
10100
  * Configure the tombstone invariant for this storage instance. Installed
@@ -10279,55 +10407,55 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
10279
10407
  return legacyMatches.length > 0 ? [...new Set(legacyMatches.map((content) => ContentHashIndex.computeHash(content)))] : [persistedHash];
10280
10408
  }
10281
10409
  get questionsDir() {
10282
- return path20.join(this.baseDir, "questions");
10410
+ return path21.join(this.baseDir, "questions");
10283
10411
  }
10284
10412
  get artifactsDir() {
10285
- return path20.join(this.baseDir, "artifacts");
10413
+ return path21.join(this.baseDir, "artifacts");
10286
10414
  }
10287
10415
  get identityDir() {
10288
- return path20.join(this.baseDir, "identity");
10416
+ return path21.join(this.baseDir, "identity");
10289
10417
  }
10290
10418
  get identityAnchorPath() {
10291
- return path20.join(this.identityDir, "identity-anchor.md");
10419
+ return path21.join(this.identityDir, "identity-anchor.md");
10292
10420
  }
10293
10421
  get identityIncidentsDir() {
10294
- return path20.join(this.identityDir, "incidents");
10422
+ return path21.join(this.identityDir, "incidents");
10295
10423
  }
10296
10424
  get identityAuditsWeeklyDir() {
10297
- return path20.join(this.identityDir, "audits", "weekly");
10425
+ return path21.join(this.identityDir, "audits", "weekly");
10298
10426
  }
10299
10427
  get identityAuditsMonthlyDir() {
10300
- return path20.join(this.identityDir, "audits", "monthly");
10428
+ return path21.join(this.identityDir, "audits", "monthly");
10301
10429
  }
10302
10430
  get identityImprovementLoopsPath() {
10303
- return path20.join(this.identityDir, "improvement-loops.md");
10431
+ return path21.join(this.identityDir, "improvement-loops.md");
10304
10432
  }
10305
10433
  get identityReflectionsPath() {
10306
- return path20.join(this.identityDir, "reflections.md");
10434
+ return path21.join(this.identityDir, "reflections.md");
10307
10435
  }
10308
10436
  get profilePath() {
10309
- return path20.join(this.baseDir, "profile.md");
10437
+ return path21.join(this.baseDir, "profile.md");
10310
10438
  }
10311
10439
  get memoryActionsPath() {
10312
- return path20.join(this.stateDir, "memory-actions.jsonl");
10440
+ return path21.join(this.stateDir, "memory-actions.jsonl");
10313
10441
  }
10314
10442
  get memoryLifecycleLedgerPath() {
10315
- return path20.join(this.stateDir, "memory-lifecycle-ledger.jsonl");
10443
+ return path21.join(this.stateDir, "memory-lifecycle-ledger.jsonl");
10316
10444
  }
10317
10445
  get compressionGuidelinesPath() {
10318
- return path20.join(this.stateDir, "compression-guidelines.md");
10446
+ return path21.join(this.stateDir, "compression-guidelines.md");
10319
10447
  }
10320
10448
  get compressionGuidelineDraftPath() {
10321
- return path20.join(this.stateDir, "compression-guidelines.draft.md");
10449
+ return path21.join(this.stateDir, "compression-guidelines.draft.md");
10322
10450
  }
10323
10451
  get compressionGuidelineStatePath() {
10324
- return path20.join(this.stateDir, "compression-guideline-state.json");
10452
+ return path21.join(this.stateDir, "compression-guideline-state.json");
10325
10453
  }
10326
10454
  get compressionGuidelineDraftStatePath() {
10327
- return path20.join(this.stateDir, "compression-guideline-draft-state.json");
10455
+ return path21.join(this.stateDir, "compression-guideline-draft-state.json");
10328
10456
  }
10329
10457
  get behaviorSignalsPath() {
10330
- return path20.join(this.stateDir, "behavior-signals.jsonl");
10458
+ return path21.join(this.stateDir, "behavior-signals.jsonl");
10331
10459
  }
10332
10460
  /**
10333
10461
  * In-memory dedup key set for behavior-signals appends (issue #1909),
@@ -10359,7 +10487,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
10359
10487
  * governance sweeps can treat it uniformly.
10360
10488
  */
10361
10489
  get bufferSurpriseLedgerPath() {
10362
- return path20.join(this.stateDir, "buffer-surprise-ledger.jsonl");
10490
+ return path21.join(this.stateDir, "buffer-surprise-ledger.jsonl");
10363
10491
  }
10364
10492
  /**
10365
10493
  * Entity alias table loaded from THIS store's config/aliases.json.
@@ -10422,7 +10550,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
10422
10550
  this.loadAliasesSync();
10423
10551
  }
10424
10552
  loadAliasesSync() {
10425
- const aliasPath = path20.join(this.baseDir, "config", "aliases.json");
10553
+ const aliasPath = path21.join(this.baseDir, "config", "aliases.json");
10426
10554
  this.userAliases = {};
10427
10555
  const raw = readEntityAliasConfigSync(this.baseDir);
10428
10556
  if (raw === void 0) return;
@@ -10460,9 +10588,9 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
10460
10588
  await mkdir5(this.baseDir, { recursive: true });
10461
10589
  await validateRoots(this.baseDir, this.entitiesDir, this.stateDir, this.archiveDir);
10462
10590
  const today = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
10463
- await mkdir5(path20.join(this.factsDir, today), { recursive: true });
10464
- await mkdir5(path20.join(this.proceduresDir, today), { recursive: true });
10465
- await mkdir5(path20.join(this.reasoningTracesDir, today), { recursive: true });
10591
+ await mkdir5(path21.join(this.factsDir, today), { recursive: true });
10592
+ await mkdir5(path21.join(this.proceduresDir, today), { recursive: true });
10593
+ await mkdir5(path21.join(this.reasoningTracesDir, today), { recursive: true });
10466
10594
  await mkdir5(this.correctionsDir, { recursive: true });
10467
10595
  await mkdir5(this.entitiesDir, { recursive: true });
10468
10596
  await mkdir5(this.stateDir, { recursive: true });
@@ -10472,7 +10600,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
10472
10600
  await mkdir5(this.identityIncidentsDir, { recursive: true });
10473
10601
  await mkdir5(this.identityAuditsWeeklyDir, { recursive: true });
10474
10602
  await mkdir5(this.identityAuditsMonthlyDir, { recursive: true });
10475
- await mkdir5(path20.join(this.baseDir, "config"), { recursive: true });
10603
+ await mkdir5(path21.join(this.baseDir, "config"), { recursive: true });
10476
10604
  await this.entityCanonicalIdMigration.begin(options.waitForEntityMigration !== false, this.entitiesDir);
10477
10605
  if (this.hotMemoriesCacheEnabled && this.getMemoryCorpusVersion() === 0) {
10478
10606
  this.bumpMemoryCorpusVersion();
@@ -10495,11 +10623,11 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
10495
10623
  async resolveCategoryWritePath(category, id, today) {
10496
10624
  if (category === "correction") {
10497
10625
  await mkdir5(this.correctionsDir, { recursive: true });
10498
- return path20.join(this.correctionsDir, `${id}.md`);
10626
+ return path21.join(this.correctionsDir, `${id}.md`);
10499
10627
  }
10500
- const datedDir = path20.join(getCategoryDir(this.baseDir, category), today);
10628
+ const datedDir = path21.join(getCategoryDir(this.baseDir, category), today);
10501
10629
  await mkdir5(datedDir, { recursive: true });
10502
- return path20.join(datedDir, `${id}.md`);
10630
+ return path21.join(datedDir, `${id}.md`);
10503
10631
  }
10504
10632
  async findExistingTombstoneBlockedMemory(content, category, sourceConnector) {
10505
10633
  const identity = buildExplicitCaptureDedupKey(content, category, sourceConnector);
@@ -10891,7 +11019,7 @@ ${sanitized.text}
10891
11019
  await this.ensureDirectories();
10892
11020
  const now = /* @__PURE__ */ new Date();
10893
11021
  const day = now.toISOString().slice(0, 10);
10894
- const dir = path20.join(this.artifactsDir, day);
11022
+ const dir = path21.join(this.artifactsDir, day);
10895
11023
  await mkdir5(dir, { recursive: true });
10896
11024
  const id = `artifact-${Date.now()}-${randomUUID7()}`;
10897
11025
  const fm = {
@@ -10918,7 +11046,7 @@ ${sanitized.text}
10918
11046
  log.warn(`artifact content rejected for ${id}; violations=${sanitized.violations.join(", ")}`);
10919
11047
  return "";
10920
11048
  }
10921
- const filePath = path20.join(dir, `${id}.md`);
11049
+ const filePath = path21.join(dir, `${id}.md`);
10922
11050
  await this.writeStorageSecureFile(filePath, `${serializeFrontmatter(this.withOkfType(fm))}
10923
11051
 
10924
11052
  ${sanitized.text}
@@ -11019,33 +11147,21 @@ ${sanitized.text}
11019
11147
  async readAllMemories(options) {
11020
11148
  checkCorpusReadAbort(options);
11021
11149
  if (options?.retainRaw === false) return this._readAllMemoriesFromDisk(options);
11022
- if (this.hotMemoriesCacheEnabled) {
11023
- const cached = getCachedMemories(
11024
- this.baseDir,
11025
- this.getMemoryCorpusVersion(),
11026
- this.hotCacheKeyId(),
11027
- this.hotCacheTtlMs()
11028
- );
11029
- if (cached !== null) return this.rememberMemorySnapshots(cached);
11030
- }
11150
+ const cached = this.hotMemoriesCacheEnabled ? getCachedMemories(this.baseDir, this.getMemoryCorpusVersion(), this.hotCacheKeyId(), this.hotCacheTtlMs()) : null;
11151
+ if (cached !== null) return this.rememberMemorySnapshots(cached);
11031
11152
  const keyId = this.hotCacheKeyId();
11032
- const inFlight = attachInFlightReader(this.baseDir, keyId, options?.abortSignal);
11033
- if (inFlight) {
11034
- try {
11035
- return this.rememberMemorySnapshots(
11036
- await raceAbort(inFlight.read, options?.abortSignal, "corpus read aborted")
11037
- );
11038
- } finally {
11039
- inFlight.waiter.leave();
11040
- }
11041
- }
11153
+ const joined = await this.tryJoinInFlight(keyId, options);
11154
+ if (joined !== null) return joined;
11155
+ const served = await serveHotMemoriesValidated(this, options?.abortSignal);
11156
+ if (served !== null) return this.rememberMemorySnapshots(served);
11157
+ const rejoined = await this.tryJoinInFlight(keyId, options);
11158
+ if (rejoined !== null) return rejoined;
11042
11159
  const scan = beginCoalescedScan(this.baseDir, keyId, options?.abortSignal);
11043
11160
  const readPromise = (async () => {
11044
11161
  const version = this.getMemoryCorpusVersion();
11045
- const memories = await this._readAllMemoriesFromDisk({ abortSignal: scan.scanSignal });
11046
- if (this.hotMemoriesCacheEnabled && this.getMemoryCorpusVersion() === version && this.hotCacheKeyId() === keyId) {
11047
- setCachedMemories(this.baseDir, memories, version, keyId, this.hotCacheTtlMs());
11048
- }
11162
+ const snapshot = this.isHotCacheEnabled() ? /* @__PURE__ */ new Map() : void 0;
11163
+ const memories = await this._readAllMemoriesFromDisk({ abortSignal: scan.scanSignal }, snapshot);
11164
+ await publishCorpusAfterScan(this, memories, version, keyId, snapshot);
11049
11165
  return memories;
11050
11166
  })();
11051
11167
  scan.arm(readPromise);
@@ -11058,6 +11174,16 @@ ${sanitized.text}
11058
11174
  deleteInFlightRead(this.baseDir, keyId, readPromise);
11059
11175
  }
11060
11176
  }
11177
+ /** Join an in-flight corpus scan if one exists (null = caller starts the scan); joins precede COS-825 validation. */
11178
+ async tryJoinInFlight(keyId, options) {
11179
+ const inFlight = attachInFlightReader(this.baseDir, keyId, options?.abortSignal);
11180
+ if (!inFlight) return null;
11181
+ try {
11182
+ return this.rememberMemorySnapshots(await raceAbort(inFlight.read, options?.abortSignal, "corpus read aborted"));
11183
+ } finally {
11184
+ inFlight.waiter.leave();
11185
+ }
11186
+ }
11061
11187
  /** Invalidate the readAllMemories() cache after writes that add/remove memories. */
11062
11188
  /** Public cache invalidation for callers that need authoritative disk reads
11063
11189
  * (e.g. projection verify/rebuild). */
@@ -11172,7 +11298,10 @@ ${sanitized.text}
11172
11298
  }
11173
11299
  if (patchedOk && exclusive && produced === prevVersion + 1 && this.getMemoryCorpusVersion() === produced && this.hotCacheKeyId() === keyId) {
11174
11300
  const patched = getCachedMemories(this.baseDir, prevVersion, keyId);
11175
- if (patched) setCachedMemories(this.baseDir, patched, produced, keyId, this.hotCacheTtlMs());
11301
+ if (patched) {
11302
+ const stats = getHotCacheEntry(this.baseDir, keyId)?.stats;
11303
+ setCachedMemories(this.baseDir, patched, produced, keyId, this.hotCacheTtlMs(), stats);
11304
+ }
11176
11305
  }
11177
11306
  if (scope === "memory-create" && (_StorageManager.scopedCacheInvalidationByDir.get(this.baseDir) ?? true)) {
11178
11307
  invalidateForScopeExceptHot(this.baseDir, "memory-create");
@@ -11198,7 +11327,7 @@ ${sanitized.text}
11198
11327
  * per-process in-memory cache safe across process boundaries.
11199
11328
  */
11200
11329
  invalidateColdMemoriesCache() {
11201
- const coldRoot = path20.join(this.baseDir, "cold");
11330
+ const coldRoot = path21.join(this.baseDir, "cold");
11202
11331
  _StorageManager.coldMemoriesCache.delete(coldRoot);
11203
11332
  this.bumpColdWriteVersion();
11204
11333
  invalidateAllForDir(this.baseDir);
@@ -11246,7 +11375,7 @@ ${sanitized.text}
11246
11375
  getCorpusScanVersion() {
11247
11376
  return `${this.getMemoryCorpusVersion()}:${this.readColdWriteVersion()}`;
11248
11377
  }
11249
- async readParsedMemoriesFromPaths(filePaths, batchSize, options) {
11378
+ async readParsedMemoriesFromPaths(filePaths, batchSize, options, snapshot) {
11250
11379
  if (filePaths.length === 0) return [];
11251
11380
  const normalizedBatchSize = this.normalizeMemoryReadBatchSize(batchSize);
11252
11381
  const memories = [];
@@ -11256,8 +11385,10 @@ ${sanitized.text}
11256
11385
  const results = await Promise.all(
11257
11386
  batch.map(async (fullPath) => {
11258
11387
  try {
11259
- const raw = await readMaybeEncryptedFile(fullPath, this._secureStoreKey, this.baseDir);
11260
- const parsed = parseFrontmatter(raw);
11388
+ const read = await readWithStableStat(fullPath, snapshot, () => readMaybeEncryptedFile(fullPath, this._secureStoreKey, this.baseDir));
11389
+ if (read === null) return null;
11390
+ const parsed = parseFrontmatter(read.raw);
11391
+ if (parsed && snapshot) snapshot.set(fullPath, read.stat);
11261
11392
  if (!parsed) return null;
11262
11393
  const memory = {
11263
11394
  path: fullPath,
@@ -11268,7 +11399,7 @@ ${sanitized.text}
11268
11399
  ),
11269
11400
  content: parsed.content
11270
11401
  };
11271
- return options?.retainRaw === false ? memory : rememberRawFrontmatter(memory, raw);
11402
+ return options?.retainRaw === false ? memory : rememberRawFrontmatter(memory, read.raw);
11272
11403
  } catch (err) {
11273
11404
  if (err instanceof SecureStoreLockedError) throw err;
11274
11405
  return null;
@@ -11303,7 +11434,7 @@ ${sanitized.text}
11303
11434
  return updatedMs >= updatedAfterMs ? filePath : null;
11304
11435
  }
11305
11436
  try {
11306
- const fileStat = await stat4(filePath);
11437
+ const fileStat = await stat6(filePath);
11307
11438
  return fileStat.mtimeMs >= updatedAfterMs ? filePath : null;
11308
11439
  } catch {
11309
11440
  return filePath;
@@ -11316,7 +11447,7 @@ ${sanitized.text}
11316
11447
  const correctionPaths = [];
11317
11448
  const factPaths = [];
11318
11449
  for (const filePath of filePaths) {
11319
- if (filePath === this.correctionsDir || filePath.startsWith(`${this.correctionsDir}${path20.sep}`)) {
11450
+ if (filePath === this.correctionsDir || filePath.startsWith(`${this.correctionsDir}${path21.sep}`)) {
11320
11451
  correctionPaths.push(filePath);
11321
11452
  } else {
11322
11453
  factPaths.push(filePath);
@@ -11362,9 +11493,9 @@ ${sanitized.text}
11362
11493
  async readMemoriesWindow(options = {}) {
11363
11494
  return readWindowedMemories(this.memoryReadStore, options, { enabled: this.hotMemoriesCacheEnabled, baseDir: this.baseDir, corpusVersion: this.getMemoryCorpusVersion(), cacheKeyId: this.hotCacheKeyId(), ttlMs: this.hotCacheTtlMs() }, (memories) => this.rememberMemorySnapshots(memories));
11364
11495
  }
11365
- async _readAllMemoriesFromDisk(options) {
11496
+ async _readAllMemoriesFromDisk(options, snapshot) {
11366
11497
  const filePaths = await this.collectActiveMemoryPaths(options);
11367
- return this.readParsedMemoriesFromPaths(filePaths, 50, options);
11498
+ return this.readParsedMemoriesFromPaths(filePaths, 50, options, snapshot);
11368
11499
  }
11369
11500
  async readAllColdMemories(options) {
11370
11501
  const memories = await this.memoryReadStore.readAllColdMemories(options);
@@ -11383,7 +11514,7 @@ ${sanitized.text}
11383
11514
  const entries = (await readdir7(dir, { withFileTypes: true })).filter((e) => !isMacOsReplicationJunkBasename(e.name));
11384
11515
  for (const entry of entries) {
11385
11516
  checkCorpusReadAbort(options);
11386
- const fullPath = path20.join(dir, entry.name);
11517
+ const fullPath = path21.join(dir, entry.name);
11387
11518
  if (entry.isDirectory()) {
11388
11519
  await readDir(fullPath);
11389
11520
  } else if (entry.name.endsWith(".md")) {
@@ -11423,7 +11554,7 @@ ${sanitized.text}
11423
11554
  return this.rememberMemorySnapshot(await this.memoryReadStore.readMemoryByPath(filePath));
11424
11555
  }
11425
11556
  resolveTierRootDir(tier) {
11426
- return tier === "cold" ? path20.join(this.baseDir, "cold") : this.baseDir;
11557
+ return tier === "cold" ? path21.join(this.baseDir, "cold") : this.baseDir;
11427
11558
  }
11428
11559
  resolveMemoryDateDir(memory) {
11429
11560
  const preferred = memory.frontmatter.created || memory.frontmatter.updated;
@@ -11438,13 +11569,13 @@ ${sanitized.text}
11438
11569
  buildTierMemoryPath(memory, tier) {
11439
11570
  const root = this.resolveTierRootDir(tier);
11440
11571
  if (this.isArtifactMemory(memory)) {
11441
- return path20.join(root, "artifacts", this.resolveMemoryDateDir(memory), `${memory.frontmatter.id}.md`);
11572
+ return path21.join(root, "artifacts", this.resolveMemoryDateDir(memory), `${memory.frontmatter.id}.md`);
11442
11573
  }
11443
11574
  if (memory.frontmatter.category === "correction") {
11444
- return path20.join(root, "corrections", `${memory.frontmatter.id}.md`);
11575
+ return path21.join(root, "corrections", `${memory.frontmatter.id}.md`);
11445
11576
  }
11446
11577
  const dir = categoryDirName(memory.frontmatter.category);
11447
- return path20.join(root, dir, this.resolveMemoryDateDir(memory), `${memory.frontmatter.id}.md`);
11578
+ return path21.join(root, dir, this.resolveMemoryDateDir(memory), `${memory.frontmatter.id}.md`);
11448
11579
  }
11449
11580
  async writeMemoryFileAtomic(targetPath, memory) {
11450
11581
  assertNotOkfReservedBasename(targetPath);
@@ -11523,8 +11654,8 @@ ${memory.content}
11523
11654
  memory.frontmatter.entityRef = current.frontmatter.entityRef;
11524
11655
  }
11525
11656
  durable = true;
11526
- const sourcePath = path20.resolve(current.path);
11527
- const destPath = path20.resolve(targetPath);
11657
+ const sourcePath = path21.resolve(current.path);
11658
+ const destPath = path21.resolve(targetPath);
11528
11659
  if (sourcePath !== destPath) {
11529
11660
  await recordArchiveDelete2(this.baseDir, current.path, () => this.deleteManagedStorageFile(current.path));
11530
11661
  this.invalidateAllMemoriesCache();
@@ -11548,8 +11679,8 @@ ${memory.content}
11548
11679
  }
11549
11680
  async migrateMemoryToTier(memory, targetTier) {
11550
11681
  const targetPath = this.buildTierMemoryPath(memory, targetTier);
11551
- const sourcePath = path20.resolve(memory.path);
11552
- const destPath = path20.resolve(targetPath);
11682
+ const sourcePath = path21.resolve(memory.path);
11683
+ const destPath = path21.resolve(targetPath);
11553
11684
  if (sourcePath === destPath) {
11554
11685
  return { changed: false, targetPath };
11555
11686
  }
@@ -11559,7 +11690,7 @@ ${memory.content}
11559
11690
  return { changed, targetPath };
11560
11691
  }
11561
11692
  get archiveDir() {
11562
- return path20.join(this.baseDir, "archive");
11693
+ return path21.join(this.baseDir, "archive");
11563
11694
  }
11564
11695
  /**
11565
11696
  * Archive a memory by moving it from facts/ to archive/YYYY-MM-DD/.
@@ -11572,7 +11703,7 @@ ${memory.content}
11572
11703
  try {
11573
11704
  const now = lifecycle?.at ?? /* @__PURE__ */ new Date();
11574
11705
  const today = now.toISOString().slice(0, 10);
11575
- const destDir = path20.join(this.archiveDir, today);
11706
+ const destDir = path21.join(this.archiveDir, today);
11576
11707
  await mkdir5(destDir, { recursive: true });
11577
11708
  const refIdsAtWrite = this.currentHistoricalIds();
11578
11709
  const updatedFm = canonicalizeEntityRefOption(
@@ -11588,7 +11719,7 @@ ${memory.content}
11588
11719
 
11589
11720
  ${current.content}
11590
11721
  `;
11591
- const destPath = path20.join(destDir, path20.basename(current.path));
11722
+ const destPath = path21.join(destDir, path21.basename(current.path));
11592
11723
  const priorDest = await this.readStorageSecureFile(destPath).catch(() => null);
11593
11724
  await recordArchiveWrite(this.baseDir, destPath, () => this.writeStorageSecureFile(destPath, fileContent));
11594
11725
  if (typeof current.frontmatter.entityRef === "string") {
@@ -11812,7 +11943,7 @@ ${memory.content}
11812
11943
  `;
11813
11944
  await this.writeTombstoneBlockedFrontmatter(memory, fileContent, updated, async () => {
11814
11945
  this.invalidateAllMemoriesCache();
11815
- if (memory.path.includes(`${path20.sep}cold${path20.sep}`)) {
11946
+ if (memory.path.includes(`${path21.sep}cold${path21.sep}`)) {
11816
11947
  this.invalidateColdMemoriesCache();
11817
11948
  }
11818
11949
  });
@@ -11824,7 +11955,7 @@ ${memory.content}
11824
11955
  }
11825
11956
  if (mentionReentry && !entityMentionEpoch.neutral(memory.frontmatter, updated)) entityMentionEpoch.bump(this.baseDir);
11826
11957
  await this.patchHotMemoriesCache({ addedPath: memory.path });
11827
- if (memory.path.includes(`${path20.sep}cold${path20.sep}`)) {
11958
+ if (memory.path.includes(`${path21.sep}cold${path21.sep}`)) {
11828
11959
  this.invalidateColdMemoriesCache();
11829
11960
  }
11830
11961
  try {
@@ -11941,7 +12072,7 @@ ${memory.content}
11941
12072
  return saveDroppedExtractionChunk(this.stateDir, (file, content) => this.writeStorageSecureFile(file, content), bufferKey, reason, turns);
11942
12073
  }
11943
12074
  async loadMeta() {
11944
- const metaPath = path20.join(this.stateDir, "meta.json");
12075
+ const metaPath = path21.join(this.stateDir, "meta.json");
11945
12076
  try {
11946
12077
  const raw = await this.readStorageSecureFile(metaPath);
11947
12078
  const parsed = JSON.parse(raw);
@@ -11974,7 +12105,7 @@ ${memory.content}
11974
12105
  }
11975
12106
  async saveMeta(state) {
11976
12107
  await this.ensureDirectories();
11977
- await this.writeStorageSecureFile(path20.join(this.stateDir, "meta.json"), JSON.stringify(state, null, 2));
12108
+ await this.writeStorageSecureFile(path21.join(this.stateDir, "meta.json"), JSON.stringify(state, null, 2));
11978
12109
  }
11979
12110
  async updateMeta(mutate) {
11980
12111
  await updateMetaSerialized(this.stateDir, () => this.loadMeta(), (meta) => this.saveMeta(meta), mutate);
@@ -12046,7 +12177,7 @@ ${memory.content}
12046
12177
  },
12047
12178
  (payload) => this.appendStorageSecureFile(target, payload),
12048
12179
  async () => {
12049
- await mkdir5(path20.dirname(target), { recursive: true });
12180
+ await mkdir5(path21.dirname(target), { recursive: true });
12050
12181
  }
12051
12182
  );
12052
12183
  }
@@ -12078,7 +12209,7 @@ ${memory.content}
12078
12209
  let existingKeys;
12079
12210
  let identity = null;
12080
12211
  try {
12081
- const st = await stat4(this.behaviorSignalsPath);
12212
+ const st = await stat6(this.behaviorSignalsPath);
12082
12213
  identity = { size: st.size, mtimeMs: st.mtimeMs };
12083
12214
  if (this.behaviorSignalsKeyCache && this.behaviorSignalsKeyCache.identity.size === identity.size && this.behaviorSignalsKeyCache.identity.mtimeMs === identity.mtimeMs) {
12084
12215
  existingKeys = this.behaviorSignalsKeyCache.keys;
@@ -12126,7 +12257,7 @@ ${memory.content}
12126
12257
  await this.appendStorageSecureFile(this.behaviorSignalsPath, payload);
12127
12258
  for (const key of pending) existingKeys.add(key);
12128
12259
  try {
12129
- const st = await stat4(this.behaviorSignalsPath);
12260
+ const st = await stat6(this.behaviorSignalsPath);
12130
12261
  const expectedSize = (identity?.size ?? 0) + Buffer.byteLength(payload, "utf-8");
12131
12262
  if (st.size === expectedSize) {
12132
12263
  this.behaviorSignalsKeyCache = {
@@ -12144,7 +12275,7 @@ ${memory.content}
12144
12275
  async appendReextractJobs(events) {
12145
12276
  if (events.length === 0) return 0;
12146
12277
  await this.ensureDirectories();
12147
- const filePath = path20.join(this.stateDir, "reextract-jobs.jsonl");
12278
+ const filePath = path21.join(this.stateDir, "reextract-jobs.jsonl");
12148
12279
  const lines = events.map((event) => JSON.stringify(event)).join("\n") + "\n";
12149
12280
  try {
12150
12281
  await this.appendStorageSecureFile(filePath, lines);
@@ -12157,7 +12288,7 @@ ${memory.content}
12157
12288
  }
12158
12289
  async readReextractJobs(limit = 200) {
12159
12290
  const safeLimit = Number.isFinite(limit) ? Math.max(1, Math.min(1e3, Math.floor(limit))) : 200;
12160
- const filePath = path20.join(this.stateDir, "reextract-jobs.jsonl");
12291
+ const filePath = path21.join(this.stateDir, "reextract-jobs.jsonl");
12161
12292
  try {
12162
12293
  const raw = await this.readStorageSecureFile(filePath);
12163
12294
  const lines = raw.split("\n").filter((line) => line.trim().length > 0);
@@ -12392,7 +12523,7 @@ ${question}
12392
12523
 
12393
12524
  **Context:** ${context}
12394
12525
  `;
12395
- const filePath = path20.join(this.questionsDir, `${id}.md`);
12526
+ const filePath = path21.join(this.questionsDir, `${id}.md`);
12396
12527
  await this.writeStorageSecureFile(filePath, content);
12397
12528
  log.debug(`wrote question ${id} to ${filePath}`);
12398
12529
  this.invalidateQuestionsCache();
@@ -12451,11 +12582,11 @@ ${question}
12451
12582
  } catch {
12452
12583
  }
12453
12584
  const hygiene = opts?.hygiene;
12454
- const rotateEnabled = hygiene?.enabled === true && hygiene.rotateEnabled === true && Array.isArray(hygiene.rotatePaths) && hygiene.rotatePaths.includes(path20.basename(identityPath));
12585
+ const rotateEnabled = hygiene?.enabled === true && hygiene.rotateEnabled === true && Array.isArray(hygiene.rotatePaths) && hygiene.rotatePaths.includes(path21.basename(identityPath));
12455
12586
  if (rotateEnabled) {
12456
12587
  const maxBytes = hygiene.rotateMaxBytes;
12457
12588
  if (existing.length > maxBytes) {
12458
- const archiveDir = path20.join(workspaceDir, hygiene.archiveDir);
12589
+ const archiveDir = path21.join(workspaceDir, hygiene.archiveDir);
12459
12590
  const { newContent } = await rotateMarkdownFileToArchive({
12460
12591
  filePath: identityPath,
12461
12592
  archiveDir,
@@ -12715,7 +12846,7 @@ ${reflection}
12715
12846
  if (entries.length === 0) return 0;
12716
12847
  const memories = await this.readAllMemories();
12717
12848
  const memoryMap = new Map(memories.map((m) => [m.frontmatter.id, m]));
12718
- const memoryPathMap = new Map(memories.map((m) => [path20.resolve(m.path), m]));
12849
+ const memoryPathMap = new Map(memories.map((m) => [path21.resolve(m.path), m]));
12719
12850
  let updated = 0;
12720
12851
  const prevVersion = this.getMemoryCorpusVersion();
12721
12852
  let entityRefMoved = false;
@@ -12723,7 +12854,7 @@ ${reflection}
12723
12854
  const warm = this.hotMemoriesCacheEnabled && getCachedMemories(this.baseDir, prevVersion, keyId, this.hotCacheTtlMs()) !== null;
12724
12855
  const appliedPatches = /* @__PURE__ */ new Map();
12725
12856
  for (const entry of entries) {
12726
- const memory = entry.memoryPath ? memoryPathMap.get(path20.resolve(entry.memoryPath)) : memoryMap.get(entry.memoryId);
12857
+ const memory = entry.memoryPath ? memoryPathMap.get(path21.resolve(entry.memoryPath)) : memoryMap.get(entry.memoryId);
12727
12858
  if (!memory) continue;
12728
12859
  try {
12729
12860
  const applied = await this.withTombstoneBlockedMemoryPathLock(memory.path, async (current) => {
@@ -12755,7 +12886,7 @@ ${current.content}
12755
12886
  if (warm) {
12756
12887
  updateCacheOnWrite(this.baseDir, { ...applied.current, frontmatter: applied.newFm }, keyId);
12757
12888
  }
12758
- appliedPatches.set(path20.resolve(memory.path), {
12889
+ appliedPatches.set(path21.resolve(memory.path), {
12759
12890
  accessCount: entry.newCount,
12760
12891
  lastAccessed: entry.lastAccessed
12761
12892
  });
@@ -12773,13 +12904,20 @@ ${current.content}
12773
12904
  const cur = getCachedMemories(this.baseDir, prevVersion, keyId);
12774
12905
  if (cur) {
12775
12906
  const reapplied = cur.map((m) => {
12776
- const patch = appliedPatches.get(path20.resolve(m.path));
12907
+ const patch = appliedPatches.get(path21.resolve(m.path));
12777
12908
  return patch ? {
12778
12909
  ...m,
12779
12910
  frontmatter: { ...m.frontmatter, accessCount: patch.accessCount, lastAccessed: patch.lastAccessed }
12780
12911
  } : m;
12781
12912
  });
12782
- setCachedMemories(this.baseDir, reapplied, produced, keyId, this.hotCacheTtlMs());
12913
+ setCachedMemories(
12914
+ this.baseDir,
12915
+ reapplied,
12916
+ produced,
12917
+ keyId,
12918
+ this.hotCacheTtlMs(),
12919
+ getHotCacheEntry(this.baseDir, keyId)?.stats
12920
+ );
12783
12921
  }
12784
12922
  }
12785
12923
  invalidateDerivedAndGlobalForDir(this.baseDir);
@@ -12803,7 +12941,7 @@ ${current.content}
12803
12941
  const pathsById = /* @__PURE__ */ new Map();
12804
12942
  const filePathsById = /* @__PURE__ */ new Map();
12805
12943
  for (const filePath of filePaths) {
12806
- const memoryId = path20.basename(filePath, ".md");
12944
+ const memoryId = path21.basename(filePath, ".md");
12807
12945
  if (!wantedIds.has(memoryId)) continue;
12808
12946
  const paths = filePathsById.get(memoryId) ?? [];
12809
12947
  paths.push(filePath);
@@ -12815,7 +12953,7 @@ ${current.content}
12815
12953
  const preferredMatches = [];
12816
12954
  for (const preferredPath of preferred) {
12817
12955
  const directCandidates = new Set(qmdResultPathCandidates(this.baseDir, preferredPath));
12818
- const directMatch = existingPaths.find((filePath) => directCandidates.has(path20.resolve(filePath)));
12956
+ const directMatch = existingPaths.find((filePath) => directCandidates.has(path21.resolve(filePath)));
12819
12957
  if (directMatch) {
12820
12958
  preferredMatches.push(directMatch);
12821
12959
  continue;
@@ -12827,7 +12965,7 @@ ${current.content}
12827
12965
  candidates.add(candidate);
12828
12966
  }
12829
12967
  }
12830
- const match = existingPaths.find((filePath) => candidates.has(path20.resolve(filePath)));
12968
+ const match = existingPaths.find((filePath) => candidates.has(path21.resolve(filePath)));
12831
12969
  if (match) preferredMatches.push(match);
12832
12970
  }
12833
12971
  if (preferredMatches.length > 0) {
@@ -13149,11 +13287,11 @@ ${current.content}
13149
13287
  }
13150
13288
  }
13151
13289
  get summariesDir() {
13152
- return path20.join(this.baseDir, "summaries");
13290
+ return path21.join(this.baseDir, "summaries");
13153
13291
  }
13154
13292
  async writeSummary(summary) {
13155
13293
  await mkdir5(this.summariesDir, { recursive: true });
13156
- const filePath = path20.join(this.summariesDir, `${summary.id}.json`);
13294
+ const filePath = path21.join(this.summariesDir, `${summary.id}.json`);
13157
13295
  await this.writeStorageSecureFile(filePath, JSON.stringify(summary, null, 2));
13158
13296
  log.debug(`wrote summary ${summary.id}`);
13159
13297
  }
@@ -13163,7 +13301,7 @@ ${current.content}
13163
13301
  const summaries = [];
13164
13302
  for (const file of files) {
13165
13303
  if (isMacOsReplicationJunkBasename(file) || !file.endsWith(".json")) continue;
13166
- const filePath = path20.join(this.summariesDir, file);
13304
+ const filePath = path21.join(this.summariesDir, file);
13167
13305
  const raw = await this.readStorageSecureFile(filePath);
13168
13306
  summaries.push(JSON.parse(raw));
13169
13307
  }
@@ -13233,13 +13371,13 @@ ${current.content}
13233
13371
  return archived;
13234
13372
  }
13235
13373
  async saveTopics(topics) {
13236
- const metaPath = path20.join(this.stateDir, "topics.json");
13374
+ const metaPath = path21.join(this.stateDir, "topics.json");
13237
13375
  await mkdir5(this.stateDir, { recursive: true });
13238
13376
  await this.writeStorageSecureFile(metaPath, JSON.stringify({ topics, updatedAt: (/* @__PURE__ */ new Date()).toISOString() }, null, 2));
13239
13377
  log.debug(`saved ${topics.length} topic scores`);
13240
13378
  }
13241
13379
  async loadTopics() {
13242
- const metaPath = path20.join(this.stateDir, "topics.json");
13380
+ const metaPath = path21.join(this.stateDir, "topics.json");
13243
13381
  try {
13244
13382
  const raw = await this.readStorageSecureFile(metaPath);
13245
13383
  return JSON.parse(raw);
@@ -13361,4 +13499,4 @@ export {
13361
13499
  isValidBufferSurpriseEvent,
13362
13500
  StorageManager3 as StorageManager
13363
13501
  };
13364
- //# sourceMappingURL=chunk-7MAMRCZ7.js.map
13502
+ //# sourceMappingURL=chunk-XZMQLON4.js.map