@remnic/core 9.27.0 → 9.29.0

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 (515) hide show
  1. package/dist/access-admin-ops-surface.d.ts +13 -10
  2. package/dist/access-admin-ops-surface.js +46 -41
  3. package/dist/access-audit.js +2 -2
  4. package/dist/access-authorization-probe.d.ts +13 -10
  5. package/dist/access-authorization-probe.js +47 -42
  6. package/dist/access-boundary.d.ts +13 -10
  7. package/dist/access-boundary.js +46 -41
  8. package/dist/access-cli.js +105 -96
  9. package/dist/access-cli.js.map +1 -1
  10. package/dist/access-health-types.d.ts +10 -1
  11. package/dist/access-http-lcm-compaction.d.ts +13 -10
  12. package/dist/access-http.d.ts +13 -10
  13. package/dist/access-http.js +56 -51
  14. package/dist/access-identity-continuity-surface.d.ts +9 -8
  15. package/dist/access-identity-continuity-surface.js +46 -41
  16. package/dist/access-lcm-surface.d.ts +13 -10
  17. package/dist/access-lcm-surface.js +46 -41
  18. package/dist/access-mcp.d.ts +13 -10
  19. package/dist/access-mcp.js +51 -46
  20. package/dist/access-memory-search-fanout.d.ts +2 -2
  21. package/dist/access-memory-search-fanout.js +3 -3
  22. package/dist/{access-namespace-preflight-wRSZEO5V.d.ts → access-namespace-preflight-DCXBkDp0.d.ts} +1 -1
  23. package/dist/access-namespace-preflight.d.ts +3 -3
  24. package/dist/access-namespace-preflight.js +46 -41
  25. package/dist/access-observe-write-surface.d.ts +13 -10
  26. package/dist/access-observe-write-surface.js +46 -41
  27. package/dist/access-operations-batch.js +48 -43
  28. package/dist/access-operations.d.ts +16 -13
  29. package/dist/access-operations.js +50 -45
  30. package/dist/access-recall-concurrency.d.ts +13 -10
  31. package/dist/access-recall-concurrency.js +46 -41
  32. package/dist/access-recall-response.d.ts +13 -10
  33. package/dist/access-recall-response.js +46 -41
  34. package/dist/access-recall-surface.d.ts +13 -10
  35. package/dist/access-recall-surface.js +46 -41
  36. package/dist/access-schema.d.ts +80 -80
  37. package/dist/access-schema.js +3 -3
  38. package/dist/{access-service-B4-Fu9x2.d.ts → access-service-DvPW_M5j.d.ts} +12 -8
  39. package/dist/access-service.d.ts +13 -10
  40. package/dist/access-service.js +46 -41
  41. package/dist/access-surface-catalog.d.ts +13 -10
  42. package/dist/access-wearables-meetings-surface.d.ts +4 -3
  43. package/dist/action-confidence.d.ts +1 -1
  44. package/dist/active-memory-bridge.d.ts +1 -1
  45. package/dist/active-memory-bridge.js +3 -3
  46. package/dist/active-recall.d.ts +1 -1
  47. package/dist/active-recall.js +4 -2
  48. package/dist/active-recall.js.map +1 -1
  49. package/dist/adapters/index.js +4 -4
  50. package/dist/adapters/registry.js +2 -2
  51. package/dist/behavior-learner.d.ts +1 -1
  52. package/dist/behavior-signals.d.ts +1 -1
  53. package/dist/bootstrap.d.ts +9 -8
  54. package/dist/briefing.d.ts +3 -2
  55. package/dist/briefing.js +14 -12
  56. package/dist/buffer-surprise-report.d.ts +1 -1
  57. package/dist/buffer.d.ts +3 -2
  58. package/dist/buffer.js +2 -2
  59. package/dist/bulk-import/index.d.ts +3 -3
  60. package/dist/calibration.d.ts +1 -1
  61. package/dist/capabilities.d.ts +3 -2
  62. package/dist/capabilities.js +1 -1
  63. package/dist/{capsule-crypto-YO5QJ6L3.js → capsule-crypto-GWVG7LGC.js} +2 -2
  64. package/dist/{catalog-BLLxZ5L5.d.ts → catalog-BIVgftWu.d.ts} +1 -1
  65. package/dist/causal-behavior.d.ts +1 -1
  66. package/dist/causal-consolidation.d.ts +1 -1
  67. package/dist/causal-consolidation.js +15 -13
  68. package/dist/causal-consolidation.js.map +1 -1
  69. package/dist/causal-trajectory-graph.d.ts +1 -1
  70. package/dist/{chunk-CI26JDZA.js → chunk-2HNUMF5V.js} +6 -4
  71. package/dist/{chunk-CI26JDZA.js.map → chunk-2HNUMF5V.js.map} +1 -1
  72. package/dist/{chunk-NUWMZIYZ.js → chunk-2XC73SHY.js} +61 -43
  73. package/dist/chunk-2XC73SHY.js.map +1 -0
  74. package/dist/{chunk-RDQGLJRR.js → chunk-2XRE6FLM.js} +2 -1
  75. package/dist/{chunk-RDQGLJRR.js.map → chunk-2XRE6FLM.js.map} +1 -1
  76. package/dist/{chunk-2H7OEVPO.js → chunk-3GD2HFR6.js} +2 -2
  77. package/dist/{chunk-4TFIRMTE.js → chunk-4A6YGWQN.js} +2 -2
  78. package/dist/{chunk-JDOJZTFF.js → chunk-4PBVXX7L.js} +2 -2
  79. package/dist/{chunk-IKMAO55B.js → chunk-55MDBZLC.js} +2 -2
  80. package/dist/{chunk-VDX2J7OX.js → chunk-5W7CTZ2E.js} +4 -4
  81. package/dist/{chunk-B7GROTXD.js → chunk-6LKEUCEM.js} +2 -2
  82. package/dist/{chunk-2AJ72VVS.js → chunk-7BZOBA5J.js} +3 -3
  83. package/dist/{chunk-44DUJETW.js → chunk-7HXCF4RE.js} +2 -2
  84. package/dist/{chunk-X3SQYAPP.js → chunk-ACXPX4AG.js} +2 -2
  85. package/dist/{chunk-AJ7QCSIS.js → chunk-ALSGMEJR.js} +5 -5
  86. package/dist/{chunk-JGUXPJUQ.js → chunk-AS7YMSL6.js} +2 -2
  87. package/dist/{chunk-77CNV7DY.js → chunk-BLAKS3CP.js} +4 -4
  88. package/dist/{chunk-5BRT4Z2I.js → chunk-CMRQ34J5.js} +2 -2
  89. package/dist/{chunk-HEXSNYJD.js → chunk-CSMCNOPH.js} +8 -8
  90. package/dist/chunk-CVILPI77.js +432 -0
  91. package/dist/chunk-CVILPI77.js.map +1 -0
  92. package/dist/{chunk-SK3EYPKC.js → chunk-D2ANTDGO.js} +3 -3
  93. package/dist/{chunk-JCVQV6QX.js → chunk-D3LMYTBV.js} +7 -7
  94. package/dist/{chunk-GJJBPI6I.js → chunk-DRBXHRXE.js} +7 -3
  95. package/dist/chunk-DRBXHRXE.js.map +1 -0
  96. package/dist/{chunk-XY7QPJDA.js → chunk-E6EE5B67.js} +2 -2
  97. package/dist/{chunk-LLISELSY.js → chunk-EP5BVCRI.js} +2 -2
  98. package/dist/{chunk-PTN6UAUA.js → chunk-ES36HTSC.js} +4 -4
  99. package/dist/{chunk-WEAO45M4.js → chunk-ESBQWC3U.js} +4 -4
  100. package/dist/{chunk-EUSLKI4X.js → chunk-EVX44I7C.js} +5 -5
  101. package/dist/{chunk-CIQXI47W.js → chunk-FCDWWCLX.js} +1195 -271
  102. package/dist/chunk-FCDWWCLX.js.map +1 -0
  103. package/dist/{chunk-X6ROIHFE.js → chunk-G5R3D5UP.js} +2 -2
  104. package/dist/{chunk-MG6MNSP4.js → chunk-G6LBWZRF.js} +7 -7
  105. package/dist/{chunk-TKBDJTXG.js → chunk-GBJ4RDFR.js} +94 -20
  106. package/dist/chunk-GBJ4RDFR.js.map +1 -0
  107. package/dist/{chunk-FRVTCCGD.js → chunk-GGUBDXRR.js} +2 -2
  108. package/dist/{chunk-QH6CS6XJ.js → chunk-H24WNPA2.js} +2 -2
  109. package/dist/{chunk-V25OWXAC.js → chunk-HUHX2OCX.js} +1 -1
  110. package/dist/chunk-HUHX2OCX.js.map +1 -0
  111. package/dist/{chunk-TGQ2NTWH.js → chunk-IJ6WHMFB.js} +16 -2
  112. package/dist/{chunk-TGQ2NTWH.js.map → chunk-IJ6WHMFB.js.map} +1 -1
  113. package/dist/{chunk-EOLC6EXV.js → chunk-IMA2EWLV.js} +24 -3
  114. package/dist/chunk-IMA2EWLV.js.map +1 -0
  115. package/dist/{chunk-MQVINOJQ.js → chunk-IYZ5K7MU.js} +3 -3
  116. package/dist/{chunk-RPA2RX5P.js → chunk-JDZRYH2N.js} +2 -2
  117. package/dist/{chunk-M5EPMNS4.js → chunk-K5GB36ME.js} +2 -2
  118. package/dist/{chunk-UT3OQPFA.js → chunk-KUJQHXPH.js} +2 -2
  119. package/dist/{chunk-7RZJWZ46.js → chunk-LEPOP46W.js} +5 -5
  120. package/dist/{chunk-EYJSW2RV.js → chunk-NBDCZWP4.js} +4 -4
  121. package/dist/{chunk-XKGPIWGI.js → chunk-OFHFH655.js} +6 -6
  122. package/dist/{chunk-FGBJBYWP.js → chunk-OVRQLAYR.js} +3 -3
  123. package/dist/{chunk-BXLOS5AJ.js → chunk-OWHERGF2.js} +2 -2
  124. package/dist/chunk-P2BM76KT.js +528 -0
  125. package/dist/chunk-P2BM76KT.js.map +1 -0
  126. package/dist/{chunk-U3TH5Q2Q.js → chunk-P3MH72CI.js} +2 -2
  127. package/dist/{chunk-P2OZKKYP.js → chunk-PHWUFPCO.js} +2 -2
  128. package/dist/{chunk-KGTD2KZJ.js → chunk-PKRIQL3V.js} +2 -2
  129. package/dist/{chunk-BNGPHGVZ.js → chunk-Q6VFVAKZ.js} +13 -6
  130. package/dist/{chunk-BNGPHGVZ.js.map → chunk-Q6VFVAKZ.js.map} +1 -1
  131. package/dist/{chunk-4MJZTF42.js → chunk-QAOGGNE3.js} +3 -3
  132. package/dist/{chunk-RGJBM7Z3.js → chunk-QMBNMPQM.js} +84 -84
  133. package/dist/{chunk-RGJBM7Z3.js.map → chunk-QMBNMPQM.js.map} +1 -1
  134. package/dist/{chunk-2QSZNTDO.js → chunk-RKNJBZ55.js} +4 -4
  135. package/dist/chunk-RMMVQQA6.js +70 -0
  136. package/dist/chunk-RMMVQQA6.js.map +1 -0
  137. package/dist/{chunk-FCCMFVS6.js → chunk-RPSYDM6C.js} +2 -2
  138. package/dist/chunk-RPW2NOU6.js +33 -0
  139. package/dist/chunk-RPW2NOU6.js.map +1 -0
  140. package/dist/{chunk-RYHWZ52A.js → chunk-S2BBISHU.js} +4 -4
  141. package/dist/{chunk-RSYJV25N.js → chunk-SG265CVF.js} +10 -10
  142. package/dist/{chunk-UGH6VPPO.js → chunk-SH6YO3LT.js} +3 -3
  143. package/dist/{chunk-2RAC4JIG.js → chunk-T3GCXULH.js} +16 -16
  144. package/dist/chunk-T3GCXULH.js.map +1 -0
  145. package/dist/{chunk-FMLKOL2Z.js → chunk-TC3VNKGX.js} +4 -4
  146. package/dist/{chunk-7K5Q6COX.js → chunk-TVVEYCNW.js} +4 -4
  147. package/dist/{chunk-BJJAX3IZ.js → chunk-UTRO5UJU.js} +2 -2
  148. package/dist/{chunk-DQEMWVMT.js → chunk-UVYI6VIX.js} +1 -1
  149. package/dist/chunk-VNA7W7QF.js +134 -0
  150. package/dist/chunk-VNA7W7QF.js.map +1 -0
  151. package/dist/{chunk-BHLN7L7M.js → chunk-VVIW3PTA.js} +17 -17
  152. package/dist/chunk-WNIUPHWV.js +152 -0
  153. package/dist/chunk-WNIUPHWV.js.map +1 -0
  154. package/dist/chunk-WOCNN776.js +742 -0
  155. package/dist/chunk-WOCNN776.js.map +1 -0
  156. package/dist/{chunk-XQ4EH6DI.js → chunk-WONS4RZ2.js} +3 -3
  157. package/dist/chunk-WRJVB3C2.js +118 -0
  158. package/dist/chunk-WRJVB3C2.js.map +1 -0
  159. package/dist/{chunk-HORJVJ6K.js → chunk-WZ7UB7XQ.js} +42 -37
  160. package/dist/chunk-WZ7UB7XQ.js.map +1 -0
  161. package/dist/{chunk-MEBQFQ26.js → chunk-XEQ7OT7U.js} +8 -6
  162. package/dist/chunk-XEQ7OT7U.js.map +1 -0
  163. package/dist/{chunk-CSXHRAJJ.js → chunk-XOZ4ALGB.js} +3 -3
  164. package/dist/{chunk-XKO7BM2C.js → chunk-YGHMSDLK.js} +187 -26
  165. package/dist/chunk-YGHMSDLK.js.map +1 -0
  166. package/dist/chunk-YXZG5TVN.js +40 -0
  167. package/dist/chunk-YXZG5TVN.js.map +1 -0
  168. package/dist/{chunk-6NNNURLK.js → chunk-Z54EM5YZ.js} +4 -4
  169. package/dist/{chunk-YSGBD3QN.js → chunk-ZGOQTOYA.js} +3 -3
  170. package/dist/{chunk-4DJQYKMN.js → chunk-ZIKENA2C.js} +2 -2
  171. package/dist/chunk-ZIKENA2C.js.map +1 -0
  172. package/dist/{chunk-RNY3BO35.js → chunk-ZXAGJFHJ.js} +4 -4
  173. package/dist/{cli-Bz7X7dGx.d.ts → cli-CxoSOiG0.d.ts} +5 -5
  174. package/dist/cli.d.ts +14 -12
  175. package/dist/cli.js +73 -68
  176. package/dist/compounding/engine.d.ts +3 -2
  177. package/dist/compounding/engine.js +15 -13
  178. package/dist/compounding/preference-consolidator.d.ts +1 -1
  179. package/dist/compression-optimizer.d.ts +1 -1
  180. package/dist/config.d.ts +1 -1
  181. package/dist/config.js +4 -2
  182. package/dist/connectors/codex-materialize-runner.d.ts +1 -1
  183. package/dist/connectors/codex-materialize-runner.js +14 -12
  184. package/dist/connectors/codex-materialize.d.ts +1 -1
  185. package/dist/connectors/index.d.ts +1 -1
  186. package/dist/connectors/index.js +15 -13
  187. package/dist/consolidation-provenance-check.d.ts +3 -2
  188. package/dist/consolidation-undo.d.ts +3 -2
  189. package/dist/contradiction/index.d.ts +3 -2
  190. package/dist/contradiction/index.js +6 -6
  191. package/dist/{contradiction-scan-HMF7CNKD.js → contradiction-scan-HYLIRMJ2.js} +3 -3
  192. package/dist/conversation-index/backend.d.ts +1 -1
  193. package/dist/conversation-index/backend.js +2 -2
  194. package/dist/conversation-index/chunker.d.ts +1 -1
  195. package/dist/conversation-index/faiss-adapter.d.ts +1 -1
  196. package/dist/conversation-index/indexer.d.ts +1 -1
  197. package/dist/conversation-index/search.d.ts +1 -1
  198. package/dist/corpus-watermark.d.ts +15 -2
  199. package/dist/corpus-watermark.js +27 -23
  200. package/dist/day-summary.d.ts +1 -1
  201. package/dist/day-summary.js +2 -2
  202. package/dist/delinearize.d.ts +1 -1
  203. package/dist/direct-answer-wiring.d.ts +1 -1
  204. package/dist/direct-answer.d.ts +1 -1
  205. package/dist/embedding-fallback.d.ts +1 -1
  206. package/dist/embedding-fallback.js +2 -2
  207. package/dist/enrichment/index.d.ts +1 -1
  208. package/dist/entity-id-normalization.d.ts +4 -0
  209. package/dist/entity-id-normalization.js +10 -0
  210. package/dist/entity-id-normalization.js.map +1 -0
  211. package/dist/entity-retrieval-boundaries.d.ts +3 -0
  212. package/dist/entity-retrieval-boundaries.js +8 -0
  213. package/dist/entity-retrieval-boundaries.js.map +1 -0
  214. package/dist/entity-retrieval.d.ts +3 -2
  215. package/dist/entity-retrieval.js +15 -12
  216. package/dist/entity-schema.d.ts +1 -1
  217. package/dist/entity-schema.js +1 -1
  218. package/dist/explicit-capture.d.ts +9 -8
  219. package/dist/explicit-capture.js +2 -2
  220. package/dist/extraction-error-classification.d.ts +1 -1
  221. package/dist/extraction-faithfulness.d.ts +1 -1
  222. package/dist/extraction-judge-telemetry.d.ts +1 -1
  223. package/dist/extraction-judge-training.d.ts +1 -1
  224. package/dist/extraction-judge.d.ts +1 -1
  225. package/dist/extraction-liveness.d.ts +1 -1
  226. package/dist/extraction-source-grounding-helpers.d.ts +34 -0
  227. package/dist/extraction-source-grounding-helpers.js +62 -0
  228. package/dist/extraction-source-grounding-helpers.js.map +1 -0
  229. package/dist/extraction-source-grounding-rules.d.ts +18 -0
  230. package/dist/extraction-source-grounding-rules.js +12 -0
  231. package/dist/extraction-source-grounding-rules.js.map +1 -0
  232. package/dist/extraction-source-grounding.d.ts +11 -0
  233. package/dist/extraction-source-grounding.js +13 -0
  234. package/dist/extraction-source-grounding.js.map +1 -0
  235. package/dist/extraction.d.ts +3 -1
  236. package/dist/extraction.js +7 -4
  237. package/dist/fallback-llm.d.ts +1 -1
  238. package/dist/{first-start-migration-LEXL3XYL.js → first-start-migration-F2QJD66E.js} +2 -2
  239. package/dist/graph-dashboard-diff.d.ts +1 -1
  240. package/dist/graph-dashboard-key.d.ts +1 -1
  241. package/dist/graph-dashboard-parser.d.ts +1 -1
  242. package/dist/graph-edge-reinforcement.d.ts +1 -1
  243. package/dist/graph-snapshot.d.ts +1 -1
  244. package/dist/graph.d.ts +1 -1
  245. package/dist/importance.d.ts +1 -1
  246. package/dist/importers/index.d.ts +1 -1
  247. package/dist/in-flight-reads.d.ts +1 -1
  248. package/dist/index.d.ts +407 -405
  249. package/dist/index.js +154 -145
  250. package/dist/intent.d.ts +1 -1
  251. package/dist/lcm/engine.d.ts +1 -1
  252. package/dist/lcm/engine.js +2 -2
  253. package/dist/lcm/index.d.ts +1 -1
  254. package/dist/lcm/index.js +2 -2
  255. package/dist/lcm/tools.d.ts +1 -1
  256. package/dist/lifecycle.d.ts +1 -1
  257. package/dist/live-connectors-runner.d.ts +1 -1
  258. package/dist/local-llm.d.ts +1 -1
  259. package/dist/local-llm.js +2 -2
  260. package/dist/local-model-endpoint.d.ts +1 -1
  261. package/dist/maintenance/memory-governance.d.ts +1 -1
  262. package/dist/maintenance/memory-governance.js +14 -12
  263. package/dist/maintenance/rebuild-memory-lifecycle-ledger.d.ts +3 -2
  264. package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +14 -12
  265. package/dist/maintenance/rebuild-memory-projection.d.ts +3 -2
  266. package/dist/maintenance/rebuild-memory-projection.js +15 -13
  267. package/dist/{maintenance-DgnD2z8S.d.ts → maintenance-Cb-PjxQd.d.ts} +3 -3
  268. package/dist/mcp-memory-inspector-app.d.ts +13 -10
  269. package/dist/memory-action-policy.d.ts +1 -1
  270. package/dist/memory-cache.d.ts +1 -1
  271. package/dist/memory-lifecycle-ledger-utils.d.ts +1 -1
  272. package/dist/memory-projection-mutations.d.ts +4 -0
  273. package/dist/memory-projection-mutations.js +15 -0
  274. package/dist/memory-projection-mutations.js.map +1 -0
  275. package/dist/memory-projection-store.d.ts +1 -1
  276. package/dist/memory-provenance.d.ts +1 -1
  277. package/dist/memory-worth-outcomes.d.ts +3 -2
  278. package/dist/models-json.d.ts +1 -1
  279. package/dist/namespaces/migrate.d.ts +4 -3
  280. package/dist/namespaces/migrate.js +24 -22
  281. package/dist/namespaces/principal.d.ts +1 -1
  282. package/dist/namespaces/principal.js +2 -2
  283. package/dist/namespaces/search.d.ts +1 -1
  284. package/dist/namespaces/search.js +10 -10
  285. package/dist/namespaces/storage.d.ts +4 -3
  286. package/dist/namespaces/storage.js +14 -12
  287. package/dist/native-knowledge.d.ts +1 -1
  288. package/dist/offline-sync-impression-drain.d.ts +1 -1
  289. package/dist/offline-sync-impression-drain.js +7 -7
  290. package/dist/operator-doctor-corpus.d.ts +22 -3
  291. package/dist/operator-doctor-corpus.js +34 -24
  292. package/dist/operator-doctor-replica.d.ts +52 -0
  293. package/dist/operator-doctor-replica.js +15 -0
  294. package/dist/operator-doctor-replica.js.map +1 -0
  295. package/dist/operator-toolkit.d.ts +7 -3
  296. package/dist/operator-toolkit.js +37 -31
  297. package/dist/orchestration/compression-guideline-coordinator.d.ts +3 -2
  298. package/dist/orchestration/compression-guideline-coordinator.js +2 -2
  299. package/dist/orchestration/maintenance.d.ts +5 -4
  300. package/dist/orchestration/maintenance.js +21 -19
  301. package/dist/{orchestrator-rIHmHpv1.d.ts → orchestrator-5GKqb_HL.d.ts} +7 -7
  302. package/dist/orchestrator.d.ts +9 -8
  303. package/dist/orchestrator.js +105 -96
  304. package/dist/patterns-cli.d.ts +1 -1
  305. package/dist/{pipeline-Bq5zU6Bp.d.ts → pipeline-3Qi1TpRo.d.ts} +1 -1
  306. package/dist/policy-runtime.d.ts +1 -1
  307. package/dist/proactive-contention.d.ts +1 -1
  308. package/dist/provenance.d.ts +1 -1
  309. package/dist/{qmd-3ILJkC70.d.ts → qmd-D9JqzzRX.d.ts} +1 -1
  310. package/dist/qmd-preflight.d.ts +2 -2
  311. package/dist/qmd-recall-cache.d.ts +1 -1
  312. package/dist/qmd.d.ts +2 -2
  313. package/dist/recall-concurrency-config.d.ts +1 -1
  314. package/dist/recall-disclosure-escalation.d.ts +1 -1
  315. package/dist/recall-explain-renderer.d.ts +1 -1
  316. package/dist/recall-explain-renderer.js +3 -3
  317. package/dist/recall-memory-map.d.ts +1 -1
  318. package/dist/recall-planner-llm.d.ts +1 -1
  319. package/dist/recall-state.d.ts +1 -1
  320. package/dist/recall-state.js +2 -2
  321. package/dist/recall-tag-filter.d.ts +1 -1
  322. package/dist/recall-timings.d.ts +1 -1
  323. package/dist/recall-xray-cli.d.ts +1 -1
  324. package/dist/recall-xray-cli.js +4 -4
  325. package/dist/recall-xray-renderer.d.ts +1 -1
  326. package/dist/recall-xray-renderer.js +3 -3
  327. package/dist/recall-xray.d.ts +1 -1
  328. package/dist/recall-xray.js +2 -2
  329. package/dist/replay/normalizers/chatgpt.d.ts +1 -1
  330. package/dist/replay/normalizers/claude.d.ts +1 -1
  331. package/dist/replay/normalizers/openclaw.d.ts +1 -1
  332. package/dist/replay/normalizers/shared.d.ts +1 -1
  333. package/dist/replay/runner.d.ts +1 -1
  334. package/dist/replay/types.d.ts +1 -1
  335. package/dist/replica-divergence.d.ts +279 -0
  336. package/dist/replica-divergence.js +28 -0
  337. package/dist/replica-divergence.js.map +1 -0
  338. package/dist/replica-peers-config.d.ts +5 -0
  339. package/dist/replica-peers-config.js +13 -0
  340. package/dist/replica-peers-config.js.map +1 -0
  341. package/dist/resolve-auth-token.d.ts +21 -2
  342. package/dist/resolve-auth-token.js +5 -1
  343. package/dist/resume-bundles.js +5 -3
  344. package/dist/retrieval-agents.d.ts +2 -2
  345. package/dist/retrieval-tiers.d.ts +1 -1
  346. package/dist/routing/engine.d.ts +1 -1
  347. package/dist/routing/store.d.ts +1 -1
  348. package/dist/salvage-envelope.d.ts +1 -1
  349. package/dist/schemas.d.ts +54 -54
  350. package/dist/{scope-profiles-D0-ff4xT.d.ts → scope-profiles-C4g6_UdP.d.ts} +1 -1
  351. package/dist/search/embed-helper.d.ts +1 -1
  352. package/dist/search/embed-helper.js +2 -2
  353. package/dist/search/factory.d.ts +1 -1
  354. package/dist/search/factory.js +9 -9
  355. package/dist/search/index.d.ts +1 -1
  356. package/dist/search/index.js +9 -9
  357. package/dist/search/lancedb-backend.d.ts +1 -1
  358. package/dist/search/lancedb-backend.js +2 -2
  359. package/dist/search/meilisearch-backend.d.ts +1 -1
  360. package/dist/search/meilisearch-backend.js +2 -2
  361. package/dist/search/noop-backend.d.ts +1 -1
  362. package/dist/search/orama-backend.d.ts +1 -1
  363. package/dist/search/orama-backend.js +2 -2
  364. package/dist/search/port.d.ts +1 -1
  365. package/dist/search/remote-backend.d.ts +1 -1
  366. package/dist/{semantic-consolidation-4Tfh7c1g.d.ts → semantic-consolidation-BrxqnzTW.d.ts} +1 -1
  367. package/dist/semantic-consolidation.d.ts +2 -2
  368. package/dist/semantic-consolidation.js +15 -13
  369. package/dist/semantic-rule-promotion.js +14 -12
  370. package/dist/semantic-rule-verifier.d.ts +1 -1
  371. package/dist/semantic-rule-verifier.js +14 -12
  372. package/dist/{service-cTvil7D_.d.ts → service-Bi1JgxdP.d.ts} +2 -2
  373. package/dist/session-observer-bands.d.ts +1 -1
  374. package/dist/session-observer-state.d.ts +1 -1
  375. package/dist/shared-context/manager.d.ts +9 -9
  376. package/dist/shared-context/manager.js +2 -2
  377. package/dist/signal.d.ts +1 -1
  378. package/dist/{storage-C9ibpTme.d.ts → storage-CcH6yPk2.d.ts} +13 -19
  379. package/dist/storage.d.ts +3 -2
  380. package/dist/storage.js +15 -12
  381. package/dist/summarizer.d.ts +1 -1
  382. package/dist/summarizer.js +3 -3
  383. package/dist/summary-snapshot.d.ts +1 -1
  384. package/dist/temporal-supersession.d.ts +3 -2
  385. package/dist/temporal-timeline-recall.d.ts +1 -1
  386. package/dist/temporal-validity.d.ts +1 -1
  387. package/dist/threading.d.ts +1 -1
  388. package/dist/tier-migration.d.ts +3 -2
  389. package/dist/tier-routing.d.ts +1 -1
  390. package/dist/{tier-stats-XKD7SXYY.js → tier-stats-OPTSBNRH.js} +2 -2
  391. package/dist/topics.d.ts +1 -1
  392. package/dist/transcript.d.ts +1 -1
  393. package/dist/transfer/backup.js +2 -2
  394. package/dist/transfer/capsule-export.js +2 -2
  395. package/dist/transfer/capsule-import.js +2 -2
  396. package/dist/transfer/types.d.ts +66 -66
  397. package/dist/trust-score-stage.d.ts +1 -1
  398. package/dist/trust-score.d.ts +1 -1
  399. package/dist/{types-DHBxIF0s.d.ts → types-Dg0w9ADr.d.ts} +54 -4
  400. package/dist/types.d.ts +1 -1
  401. package/dist/types.js +1 -1
  402. package/dist/utility-runtime.d.ts +1 -1
  403. package/dist/verified-recall.js +14 -12
  404. package/dist/write-envelope.d.ts +1 -1
  405. package/package.json +2 -2
  406. package/src/access-health-types.ts +8 -0
  407. package/src/access-http.test.ts +4 -0
  408. package/src/access-service-health.test.ts +23 -0
  409. package/src/access-service.ts +27 -4
  410. package/src/capabilities.test.ts +1 -0
  411. package/src/capabilities.ts +7 -7
  412. package/src/cli.ts +9 -7
  413. package/src/config.test.ts +5 -0
  414. package/src/config.ts +3 -2
  415. package/src/corpus-watermark.test.ts +21 -0
  416. package/src/corpus-watermark.ts +25 -3
  417. package/src/entity-id-normalization.ts +55 -0
  418. package/src/entity-retrieval-boundaries.ts +134 -0
  419. package/src/entity-retrieval.ts +253 -27
  420. package/src/entity-schema.ts +2 -1
  421. package/src/extraction-source-grounding-helpers.ts +603 -0
  422. package/src/extraction-source-grounding-rules.ts +1031 -0
  423. package/src/extraction-source-grounding.test.ts +2337 -0
  424. package/src/extraction-source-grounding.ts +50 -0
  425. package/src/extraction.ts +120 -15
  426. package/src/memory-projection-mutations.ts +132 -0
  427. package/src/namespaces/storage.ts +5 -3
  428. package/src/operator-doctor-corpus.ts +41 -0
  429. package/src/operator-doctor-replica.test.ts +261 -0
  430. package/src/operator-doctor-replica.ts +129 -0
  431. package/src/operator-toolkit.ts +5 -4
  432. package/src/orchestration/orchestrator-init.ts +2 -2
  433. package/src/replica-divergence.test.ts +1475 -0
  434. package/src/replica-divergence.ts +910 -0
  435. package/src/replica-peers-config.ts +250 -0
  436. package/src/resolve-auth-token.ts +38 -0
  437. package/src/storage/entity-canonical-id-migration-adapter.ts +72 -0
  438. package/src/storage/entity-canonical-id-migration-runner.ts +68 -0
  439. package/src/storage/entity-canonical-id-migration.ts +904 -0
  440. package/src/storage/entity-store.ts +44 -0
  441. package/src/storage/memory-frontmatter-metadata.ts +17 -0
  442. package/src/storage/memory-migration-serialization.ts +37 -0
  443. package/src/storage/memory-read-store.ts +3 -2
  444. package/src/storage/profile-header.ts +8 -7
  445. package/src/storage-profile-timestamp.test.ts +68 -0
  446. package/src/storage.ts +68 -69
  447. package/src/types.ts +5 -5
  448. package/dist/chunk-2RAC4JIG.js.map +0 -1
  449. package/dist/chunk-4DJQYKMN.js.map +0 -1
  450. package/dist/chunk-CIQXI47W.js.map +0 -1
  451. package/dist/chunk-EOLC6EXV.js.map +0 -1
  452. package/dist/chunk-GJJBPI6I.js.map +0 -1
  453. package/dist/chunk-HORJVJ6K.js.map +0 -1
  454. package/dist/chunk-MEBQFQ26.js.map +0 -1
  455. package/dist/chunk-NUWMZIYZ.js.map +0 -1
  456. package/dist/chunk-TKBDJTXG.js.map +0 -1
  457. package/dist/chunk-V25OWXAC.js.map +0 -1
  458. package/dist/chunk-XKO7BM2C.js.map +0 -1
  459. /package/dist/{capsule-crypto-YO5QJ6L3.js.map → capsule-crypto-GWVG7LGC.js.map} +0 -0
  460. /package/dist/{chunk-2H7OEVPO.js.map → chunk-3GD2HFR6.js.map} +0 -0
  461. /package/dist/{chunk-4TFIRMTE.js.map → chunk-4A6YGWQN.js.map} +0 -0
  462. /package/dist/{chunk-JDOJZTFF.js.map → chunk-4PBVXX7L.js.map} +0 -0
  463. /package/dist/{chunk-IKMAO55B.js.map → chunk-55MDBZLC.js.map} +0 -0
  464. /package/dist/{chunk-VDX2J7OX.js.map → chunk-5W7CTZ2E.js.map} +0 -0
  465. /package/dist/{chunk-B7GROTXD.js.map → chunk-6LKEUCEM.js.map} +0 -0
  466. /package/dist/{chunk-2AJ72VVS.js.map → chunk-7BZOBA5J.js.map} +0 -0
  467. /package/dist/{chunk-44DUJETW.js.map → chunk-7HXCF4RE.js.map} +0 -0
  468. /package/dist/{chunk-X3SQYAPP.js.map → chunk-ACXPX4AG.js.map} +0 -0
  469. /package/dist/{chunk-AJ7QCSIS.js.map → chunk-ALSGMEJR.js.map} +0 -0
  470. /package/dist/{chunk-JGUXPJUQ.js.map → chunk-AS7YMSL6.js.map} +0 -0
  471. /package/dist/{chunk-77CNV7DY.js.map → chunk-BLAKS3CP.js.map} +0 -0
  472. /package/dist/{chunk-5BRT4Z2I.js.map → chunk-CMRQ34J5.js.map} +0 -0
  473. /package/dist/{chunk-HEXSNYJD.js.map → chunk-CSMCNOPH.js.map} +0 -0
  474. /package/dist/{chunk-SK3EYPKC.js.map → chunk-D2ANTDGO.js.map} +0 -0
  475. /package/dist/{chunk-JCVQV6QX.js.map → chunk-D3LMYTBV.js.map} +0 -0
  476. /package/dist/{chunk-XY7QPJDA.js.map → chunk-E6EE5B67.js.map} +0 -0
  477. /package/dist/{chunk-LLISELSY.js.map → chunk-EP5BVCRI.js.map} +0 -0
  478. /package/dist/{chunk-PTN6UAUA.js.map → chunk-ES36HTSC.js.map} +0 -0
  479. /package/dist/{chunk-WEAO45M4.js.map → chunk-ESBQWC3U.js.map} +0 -0
  480. /package/dist/{chunk-EUSLKI4X.js.map → chunk-EVX44I7C.js.map} +0 -0
  481. /package/dist/{chunk-X6ROIHFE.js.map → chunk-G5R3D5UP.js.map} +0 -0
  482. /package/dist/{chunk-MG6MNSP4.js.map → chunk-G6LBWZRF.js.map} +0 -0
  483. /package/dist/{chunk-FRVTCCGD.js.map → chunk-GGUBDXRR.js.map} +0 -0
  484. /package/dist/{chunk-QH6CS6XJ.js.map → chunk-H24WNPA2.js.map} +0 -0
  485. /package/dist/{chunk-MQVINOJQ.js.map → chunk-IYZ5K7MU.js.map} +0 -0
  486. /package/dist/{chunk-RPA2RX5P.js.map → chunk-JDZRYH2N.js.map} +0 -0
  487. /package/dist/{chunk-M5EPMNS4.js.map → chunk-K5GB36ME.js.map} +0 -0
  488. /package/dist/{chunk-UT3OQPFA.js.map → chunk-KUJQHXPH.js.map} +0 -0
  489. /package/dist/{chunk-7RZJWZ46.js.map → chunk-LEPOP46W.js.map} +0 -0
  490. /package/dist/{chunk-EYJSW2RV.js.map → chunk-NBDCZWP4.js.map} +0 -0
  491. /package/dist/{chunk-XKGPIWGI.js.map → chunk-OFHFH655.js.map} +0 -0
  492. /package/dist/{chunk-FGBJBYWP.js.map → chunk-OVRQLAYR.js.map} +0 -0
  493. /package/dist/{chunk-BXLOS5AJ.js.map → chunk-OWHERGF2.js.map} +0 -0
  494. /package/dist/{chunk-U3TH5Q2Q.js.map → chunk-P3MH72CI.js.map} +0 -0
  495. /package/dist/{chunk-P2OZKKYP.js.map → chunk-PHWUFPCO.js.map} +0 -0
  496. /package/dist/{chunk-KGTD2KZJ.js.map → chunk-PKRIQL3V.js.map} +0 -0
  497. /package/dist/{chunk-4MJZTF42.js.map → chunk-QAOGGNE3.js.map} +0 -0
  498. /package/dist/{chunk-2QSZNTDO.js.map → chunk-RKNJBZ55.js.map} +0 -0
  499. /package/dist/{chunk-FCCMFVS6.js.map → chunk-RPSYDM6C.js.map} +0 -0
  500. /package/dist/{chunk-RYHWZ52A.js.map → chunk-S2BBISHU.js.map} +0 -0
  501. /package/dist/{chunk-RSYJV25N.js.map → chunk-SG265CVF.js.map} +0 -0
  502. /package/dist/{chunk-UGH6VPPO.js.map → chunk-SH6YO3LT.js.map} +0 -0
  503. /package/dist/{chunk-FMLKOL2Z.js.map → chunk-TC3VNKGX.js.map} +0 -0
  504. /package/dist/{chunk-7K5Q6COX.js.map → chunk-TVVEYCNW.js.map} +0 -0
  505. /package/dist/{chunk-BJJAX3IZ.js.map → chunk-UTRO5UJU.js.map} +0 -0
  506. /package/dist/{chunk-DQEMWVMT.js.map → chunk-UVYI6VIX.js.map} +0 -0
  507. /package/dist/{chunk-BHLN7L7M.js.map → chunk-VVIW3PTA.js.map} +0 -0
  508. /package/dist/{chunk-XQ4EH6DI.js.map → chunk-WONS4RZ2.js.map} +0 -0
  509. /package/dist/{chunk-CSXHRAJJ.js.map → chunk-XOZ4ALGB.js.map} +0 -0
  510. /package/dist/{chunk-6NNNURLK.js.map → chunk-Z54EM5YZ.js.map} +0 -0
  511. /package/dist/{chunk-YSGBD3QN.js.map → chunk-ZGOQTOYA.js.map} +0 -0
  512. /package/dist/{chunk-RNY3BO35.js.map → chunk-ZXAGJFHJ.js.map} +0 -0
  513. /package/dist/{contradiction-scan-HMF7CNKD.js.map → contradiction-scan-HYLIRMJ2.js.map} +0 -0
  514. /package/dist/{first-start-migration-LEXL3XYL.js.map → first-start-migration-F2QJD66E.js.map} +0 -0
  515. /package/dist/{tier-stats-XKD7SXYY.js.map → tier-stats-OPTSBNRH.js.map} +0 -0
@@ -13,6 +13,7 @@
13
13
  import { readdir, unlink } from "node:fs/promises";
14
14
  import path from "node:path";
15
15
  import { normalizeEntityStructuredSection, sortStructuredSectionsBySchema } from "../entity-schema.js";
16
+ import { withEntityCanonicalMutationLock } from "./entity-canonical-id-migration.js";
16
17
  import { log } from "../logger.js";
17
18
  import { getCachedEntities, setCachedEntities } from "../memory-cache.js";
18
19
  import type { VersionTrigger } from "../page-versioning.js";
@@ -78,6 +79,24 @@ export class EntityStore {
78
79
  } = {},
79
80
  ): Promise<string> {
80
81
  await this.deps.ensureDirectories();
82
+ return withEntityCanonicalMutationLock(
83
+ path.join(this.deps.baseDir, "state"),
84
+ () => this.writeEntityUnlocked(name, type, facts, options),
85
+ );
86
+ }
87
+
88
+ private async writeEntityUnlocked(
89
+ name: string,
90
+ type: string,
91
+ facts: string[],
92
+ options: {
93
+ timestamp?: string;
94
+ source?: string;
95
+ sessionKey?: string;
96
+ principal?: string;
97
+ structuredSections?: EntityStructuredSection[];
98
+ } = {},
99
+ ): Promise<string> {
81
100
  if (typeof name !== "string" || !name.trim() || typeof type !== "string" || !type.trim()) {
82
101
  log.warn("writeEntity: invalid entity payload, skipping", {
83
102
  nameType: typeof name,
@@ -238,6 +257,24 @@ export class EntityStore {
238
257
  updatedAt?: string;
239
258
  incrementVersion?: boolean;
240
259
  } = {},
260
+ ): Promise<void> {
261
+ return withEntityCanonicalMutationLock(
262
+ path.join(this.deps.baseDir, "state"),
263
+ () => this.updateEntitySynthesisUnlocked(name, synthesis, options),
264
+ );
265
+ }
266
+
267
+ private async updateEntitySynthesisUnlocked(
268
+ name: string,
269
+ synthesis: string,
270
+ options: {
271
+ entityUpdatedAt?: string;
272
+ synthesisStructuredFactCount?: number;
273
+ synthesisStructuredFactDigest?: string;
274
+ synthesisTimelineCount?: number;
275
+ updatedAt?: string;
276
+ incrementVersion?: boolean;
277
+ } = {},
241
278
  ): Promise<void> {
242
279
  const filePath = path.join(this.deps.entitiesDir, `${name}.md`);
243
280
  let entity: EntityFile;
@@ -407,6 +444,13 @@ export class EntityStore {
407
444
  * Returns count of files merged.
408
445
  */
409
446
  async mergeFragmentedEntities(): Promise<number> {
447
+ return withEntityCanonicalMutationLock(
448
+ path.join(this.deps.baseDir, "state"),
449
+ () => this.mergeFragmentedEntitiesUnlocked(),
450
+ );
451
+ }
452
+
453
+ private async mergeFragmentedEntitiesUnlocked(): Promise<number> {
410
454
  let merged = 0;
411
455
  try {
412
456
  const entries = await readdir(this.deps.entitiesDir);
@@ -0,0 +1,17 @@
1
+ export type RawFrontmatterOwner = object;
2
+
3
+ const rawFrontmatterByMemory = new WeakMap<RawFrontmatterOwner, string>();
4
+
5
+ export function extractRawFrontmatter(raw: string): string | null {
6
+ return raw.match(/^---\n([\s\S]*?)\n---\n?/)?.[1] ?? null;
7
+ }
8
+
9
+ export function rememberRawFrontmatter<T extends RawFrontmatterOwner>(owner: T, raw: string): T {
10
+ const frontmatter = extractRawFrontmatter(raw);
11
+ if (frontmatter !== null) rawFrontmatterByMemory.set(owner, frontmatter);
12
+ return owner;
13
+ }
14
+
15
+ export function readRawFrontmatter(owner: RawFrontmatterOwner): string | undefined {
16
+ return rawFrontmatterByMemory.get(owner);
17
+ }
@@ -0,0 +1,37 @@
1
+ import type { MemoryFile, MemoryFrontmatter } from "../types.js";
2
+ import { readRawFrontmatter } from "./memory-frontmatter-metadata.js";
3
+
4
+ export type MemoryEntityRefSerializer = (memory: MemoryFile, entityRef: string) => string;
5
+
6
+ export function serializeMemoryWithEntityRef(
7
+ memory: MemoryFile,
8
+ entityRef: string,
9
+ fallback: MemoryEntityRefSerializer,
10
+ ): string {
11
+ const rawFrontmatter = readRawFrontmatter(memory);
12
+ if (rawFrontmatter === undefined) return fallback(memory, entityRef);
13
+ const lines = rawFrontmatter.split("\n");
14
+ let entityRefLine = -1;
15
+ for (let index = 0; index < lines.length; index += 1) {
16
+ if (/^\s*entityRef\s*:/.test(lines[index] ?? "")) entityRefLine = index;
17
+ }
18
+ if (entityRefLine >= 0) {
19
+ const indent = lines[entityRefLine]!.match(/^\s*/)?.[0] ?? "";
20
+ lines[entityRefLine] = `${indent}entityRef: ${entityRef}`;
21
+ } else {
22
+ lines.push(`entityRef: ${entityRef}`);
23
+ }
24
+ return `---\n${lines.join("\n")}\n---\n\n${memory.content}\n`;
25
+ }
26
+
27
+ export function createMemoryEntityRefSerializer(
28
+ serializeFrontmatter: (frontmatter: MemoryFrontmatter) => string,
29
+ ): MemoryEntityRefSerializer {
30
+ return (memory, entityRef) =>
31
+ serializeMemoryWithEntityRef(
32
+ memory,
33
+ entityRef,
34
+ (fallbackMemory, fallbackEntityRef) =>
35
+ `${serializeFrontmatter({ ...fallbackMemory.frontmatter, entityRef: fallbackEntityRef })}\n\n${fallbackMemory.content}\n`,
36
+ );
37
+ }
@@ -26,6 +26,7 @@ import {
26
26
  parseFrontmatter,
27
27
  StorageManager,
28
28
  } from "../storage.js";
29
+ import { rememberRawFrontmatter } from "./memory-frontmatter-metadata.js";
29
30
 
30
31
  export interface MemoryReadStoreDeps {
31
32
  /** Live class object of the host instance — shared static caches (see storage.ts storageManagerClass). */
@@ -495,7 +496,7 @@ export class MemoryReadStore {
495
496
  // but SecureStoreLockedError must propagate — see re-throw below.
496
497
  const parsed = parseFrontmatter(raw);
497
498
  if (parsed) {
498
- return {
499
+ return rememberRawFrontmatter({
499
500
  path: filePath,
500
501
  frontmatter: normalizeFrontmatterForPath(
501
502
  parsed.frontmatter,
@@ -503,7 +504,7 @@ export class MemoryReadStore {
503
504
  parsed.content,
504
505
  ),
505
506
  content: parsed.content,
506
- };
507
+ }, raw);
507
508
  }
508
509
 
509
510
  // Entity files use a `# Name` + `**Type:** ...` markdown format rather than
@@ -7,12 +7,12 @@ const MARKDOWN_THEMATIC_BREAK = /^(?:(?:\*[ \t]*){3,}|(?:-[ \t]*){3,}|(?:_[ \t]*
7
7
  const MARKDOWN_SETEXT_UNDERLINE = /^(?:=+|-+)$/;
8
8
  const MARKDOWN_BLOCK_QUOTE = /^>/;
9
9
  const MARKDOWN_LINK_REFERENCE =
10
- /^\[(?:\\.|[^\\\[\]])+\]:\s*(?:<[^>\n]*>|([^\s]+))(?:\s+(?:"[^"\n]*"|'[^'\n]*'|\([^)\n]*\)))?$/;
11
- const MARKDOWN_LINK_REFERENCE_LABEL = /^\[(?:\\.|[^\\\[\]])+\]:\s*$/;
10
+ /^\[(?:\\.|[^\\\[\]])+\]:[ \t]*(?:<[^>\n]*>|([^\s]+))(?:[ \t]+(?:"[^"\n]*"|'[^'\n]*'|\([^)\n]*\)))?$/;
11
+ const MARKDOWN_LINK_REFERENCE_LABEL = /^\[(?:\\.|[^\\\[\]])+\]:[ \t]*$/;
12
12
  const MARKDOWN_LINK_REFERENCE_CONTINUATION =
13
13
  /^ {1,3}(?:"[^"\n]*"|'[^'\n]*'|\([^)\n]*\))$/;
14
14
  const MARKDOWN_LINK_REFERENCE_DESTINATION_CONTINUATION =
15
- /^ {1,3}(?:<[^>\n]*>|(?!["'(])[^\s]+(?:\s+(?:"[^"\n]*"|'[^'\n]*'|\([^)\n]*\)))?)$/;
15
+ /^ {1,3}(?:<[^>\n]*>|(?!["'(])[^\s]+(?:[ \t]+(?:"[^"\n]*"|'[^'\n]*'|\([^)\n]*\)))?)$/;
16
16
  const UTF8_BOM = "\uFEFF";
17
17
 
18
18
  type FenceMarker = {
@@ -440,10 +440,11 @@ function canStartGenericHtmlBlock(
440
440
  const previousLine = lines[index - 1]?.content.trim() ?? "";
441
441
  if (previousLine === "") return true;
442
442
  return (
443
- isMetadataBoundary(previousLine, previousHtmlTerminator) &&
444
- !isLastUpdatedHeader(previousLine) &&
445
- !MARKDOWN_LIST_ITEM.test(previousLine) &&
446
- !MARKDOWN_BLOCK_QUOTE.test(previousLine)
443
+ isCompletedIndentedCodeBlock(lines, index) ||
444
+ (isMetadataBoundary(previousLine, previousHtmlTerminator) &&
445
+ !isLastUpdatedHeader(previousLine) &&
446
+ !MARKDOWN_LIST_ITEM.test(previousLine) &&
447
+ !MARKDOWN_BLOCK_QUOTE.test(previousLine))
447
448
  );
448
449
  }
449
450
 
@@ -819,6 +819,38 @@ test("writeProfile recognizes a completed indented code block before metadata",
819
819
  t.mock.timers.reset();
820
820
  }
821
821
  });
822
+ test("writeProfile treats generic HTML after completed indented code as opaque", async (t) => {
823
+ t.mock.timers.enable({ apis: ["Date"], now: Date.parse(WRITE_TIME) });
824
+ try {
825
+ await withMemoryDir(async (dir) => {
826
+ const storage = new StorageManager(dir);
827
+ const profile = [
828
+ "# Behavioral Profile",
829
+ "",
830
+ " code example",
831
+ "<custom>",
832
+ "# Embedded heading",
833
+ "",
834
+ "*Last updated: literal inside HTML*",
835
+ "</custom>",
836
+ "",
837
+ STALE_HEADER,
838
+ "",
839
+ "- Keeps metadata after generic HTML.",
840
+ "",
841
+ ].join("\n");
842
+
843
+ await storage.writeProfile(profile);
844
+
845
+ assert.equal(
846
+ await storage.readProfile(),
847
+ profile.replace(STALE_HEADER, FRESH_HEADER),
848
+ );
849
+ });
850
+ } finally {
851
+ t.mock.timers.reset();
852
+ }
853
+ });
822
854
  test("writeProfile recognizes standalone headers with Markdown indentation", async (t) => {
823
855
  t.mock.timers.enable({ apis: ["Date"], now: Date.parse(WRITE_TIME) });
824
856
  try {
@@ -1264,6 +1296,42 @@ test("writeProfile recognizes link reference definitions as metadata boundaries"
1264
1296
  t.mock.timers.reset();
1265
1297
  }
1266
1298
  });
1299
+ test("writeProfile ignores non-breaking spaces as link-reference separators", async (t) => {
1300
+ t.mock.timers.enable({ apis: ["Date"], now: Date.parse(WRITE_TIME) });
1301
+ try {
1302
+ await withMemoryDir(async (dir) => {
1303
+ const storage = new StorageManager(dir);
1304
+ const profile = [
1305
+ "# Behavioral Profile",
1306
+ "",
1307
+ "[docs]:\u00a0/url",
1308
+ STALE_HEADER,
1309
+ "",
1310
+ "- Keeps ordinary paragraph content.",
1311
+ "",
1312
+ ].join("\n");
1313
+
1314
+ await storage.writeProfile(profile);
1315
+
1316
+ assert.equal(
1317
+ await storage.readProfile(),
1318
+ [
1319
+ "# Behavioral Profile",
1320
+ "",
1321
+ FRESH_HEADER,
1322
+ "",
1323
+ "[docs]:\u00a0/url",
1324
+ STALE_HEADER,
1325
+ "",
1326
+ "- Keeps ordinary paragraph content.",
1327
+ "",
1328
+ ].join("\n"),
1329
+ );
1330
+ });
1331
+ } finally {
1332
+ t.mock.timers.reset();
1333
+ }
1334
+ });
1267
1335
 
1268
1336
  test("writeProfile stops nested-list context at an intervening document paragraph", async (t) => {
1269
1337
  t.mock.timers.enable({ apis: ["Date"], now: Date.parse(WRITE_TIME) });
package/src/storage.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { readProjectionRebuiltAt } from "./maintenance/projection-support.js";
2
2
  import {
3
- access,
4
3
  lstat,
5
4
  readdir,
6
5
  readFile,
@@ -9,7 +8,6 @@ import {
9
8
  writeFile,
10
9
  mkdir,
11
10
  unlink,
12
- rename,
13
11
  appendFile,
14
12
  open,
15
13
  } from "node:fs/promises";
@@ -35,10 +33,17 @@ import {
35
33
  import { selfDeps } from "./orchestration/self-deps.js";
36
34
  import { EntityStore } from "./storage/entity-store.js";
37
35
  import { IdentityContinuityStore } from "./storage/identity-continuity-store.js";
36
+ import * as entityMigration from "./storage/entity-canonical-id-migration.js";
37
+ import {
38
+ runLegacyEntityCanonicalIdMigration,
39
+ type EntityCanonicalIdMigrationHost,
40
+ } from "./storage/entity-canonical-id-migration-adapter.js";
41
+ import { EntityCanonicalIdMigrationRunner } from "./storage/entity-canonical-id-migration-runner.js";
42
+ import { rememberRawFrontmatter } from "./storage/memory-frontmatter-metadata.js";
43
+ import { createMemoryEntityRefSerializer } from "./storage/memory-migration-serialization.js";
44
+ export { normalizeEntityName } from "./entity-id-normalization.js";
38
45
  import { isErrnoCode } from "./utils/errno.js";
39
- import { withHeldFileLock } from "./utils/serialize-mutations.js";
40
- import { RECALL_FALLBACK_DIRS, getCategoryDir, categoryDirName } from "./utils/category-dir.js";
41
- import { assertPathInsideRoot } from "./utils/path-containment.js";
46
+ import { getCategoryDir, categoryDirName } from "./utils/category-dir.js";
42
47
  import { decodeYamlScalar } from "./utils/yaml-scalar.js";
43
48
  import {
44
49
  qmdCollectionPathParts,
@@ -1095,52 +1100,6 @@ function inferCurrentStateStatus(
1095
1100
  return inferMemoryStatus(frontmatter, pathRel, fallbackStatus);
1096
1101
  }
1097
1102
 
1098
- /** Built-in aliases for common structural normalizations (no personal data) */
1099
- const BUILTIN_ALIASES: Record<string, string> = {
1100
- openclaw: "openclaw",
1101
- "open-claw": "openclaw",
1102
- };
1103
-
1104
- /**
1105
- * Normalize an entity name to a canonical form.
1106
- * Strips non-alphanumeric chars, collapses hyphens, removes type prefix duplication.
1107
- * e.g. "My Project" → "my-project"
1108
- *
1109
- * Checks caller-provided user aliases first, then built-in aliases. Alias
1110
- * tables are instance state on StorageManager (issue #1534) — use
1111
- * `storageManager.normalizeEntityName(raw, type)` when normalizing within a
1112
- * store, or pass `storageManager.entityAliases` explicitly. Without an
1113
- * aliases argument only the built-in structural aliases apply.
1114
- */
1115
- export function normalizeEntityName(raw: string, type: string, aliases?: Readonly<Record<string, string>>): string {
1116
- // Strip type prefix if present (e.g. name="person-jane-doe", type="person")
1117
- const rawStr = typeof raw === "string" ? raw : "";
1118
- const typeStr = typeof type === "string" && type.trim().length > 0 ? type : "entity";
1119
-
1120
- let name = rawStr.toLowerCase().trim();
1121
- const typePrefix = `${typeStr.toLowerCase()}-`;
1122
- if (name.startsWith(typePrefix)) {
1123
- name = name.slice(typePrefix.length);
1124
- }
1125
-
1126
- // Replace non-alphanumeric with hyphens, collapse multiples, trim edges
1127
- let normalized = name
1128
- .replace(/[^a-z0-9]+/g, "-")
1129
- .replace(/-+/g, "-")
1130
- .replace(/^-|-$/g, "");
1131
-
1132
- // Check caller-provided user aliases first, then built-in. Own-property and
1133
- // string guards keep inherited object keys (e.g. an entity literally named
1134
- // "constructor") and malformed alias values from corrupting canonical ids.
1135
- const userAlias = aliases !== undefined && Object.hasOwn(aliases, normalized) ? aliases[normalized] : undefined;
1136
- if (typeof userAlias === "string" && userAlias.length > 0) {
1137
- normalized = userAlias;
1138
- } else if (Object.hasOwn(BUILTIN_ALIASES, normalized)) {
1139
- normalized = BUILTIN_ALIASES[normalized];
1140
- }
1141
-
1142
- return `${typeStr.toLowerCase()}-${normalized}`;
1143
- }
1144
1103
 
1145
1104
  /**
1146
1105
  * Simple Levenshtein distance between two strings.
@@ -2135,24 +2094,39 @@ export class StorageManager {
2135
2094
  * Set or clear the at-rest encryption key.
2136
2095
  *
2137
2096
  * Pass a 32-byte Buffer to enable encryption; pass null to clear
2138
- * (lock) the store. The caller is responsible for key lifecycle —
2097
+ * (lock) the store. The caller is responsible for key lifecycle —
2139
2098
  * this method does not zero the buffer on replacement; the keyring
2140
- * module (`keyring.ts`) owns zeroization.
2099
+ * module (`keyring.ts`) owns zeroization. The setter remains synchronous
2100
+ * for existing consumers; call `setSecureStoreKeyAndWait` when unlock must
2101
+ * await migration.
2141
2102
  */
2142
2103
  setSecureStoreKey(key: Buffer | null, encryptOnWrite = true): void {
2104
+ if (!this.applySecureStoreKey(key, encryptOnWrite) || key === null) return;
2105
+ void this.entityCanonicalIdMigration.triggerAfterUnlock().catch((error: unknown) => {
2106
+ log.warn(
2107
+ `secure-store unlock migration failed: ${error instanceof Error ? error.message : String(error)}`,
2108
+ );
2109
+ });
2110
+ }
2111
+
2112
+ public async setSecureStoreKeyAndWait(key: Buffer | null, encryptOnWrite = true): Promise<void> {
2113
+ if (!this.applySecureStoreKey(key, encryptOnWrite) || key === null) return;
2114
+ await this.entityCanonicalIdMigration.triggerAfterUnlock();
2115
+ }
2116
+
2117
+ private applySecureStoreKey(key: Buffer | null, encryptOnWrite: boolean): boolean {
2118
+ const sameKey =
2119
+ this._secureStoreKey === key ||
2120
+ (this._secureStoreKey !== null && key !== null && this._secureStoreKey.equals(key));
2121
+ if (sameKey && this._secureStoreEncryptOnWrite === encryptOnWrite) return false;
2122
+
2143
2123
  this._secureStoreKey = key;
2144
2124
  this._secureStoreEncryptOnWrite = encryptOnWrite;
2145
- // Route through the invalidation chokepoint (issue #1535): a key change
2146
- // (or store lock) must evict every cache layer that may hold content
2147
- // decrypted under the previous key, not just the entity layer.
2148
2125
  invalidateAllForDir(this.baseDir);
2149
2126
  this.invalidateKnowledgeIndexCache();
2150
- // A key change flips resolveWriteKey(), so a file's plain/encrypted class on
2151
- // the next full rewrite may differ from what was cached (issue #1909).
2152
2127
  this.secureFileEncryptionSniffCache.clear();
2153
- // Same rationale for the behavior-signals dedup key cache (issue #1909):
2154
- // drop it on a key change so a re-encrypted/re-decrypted ledger is reloaded.
2155
2128
  this.behaviorSignalsKeyCache = null;
2129
+ return true;
2156
2130
  }
2157
2131
 
2158
2132
  private getEntityCacheSecureStoreKey(): string {
@@ -2340,6 +2314,7 @@ export class StorageManager {
2340
2314
  // loadAliases() explicitly — every creation path must still get the
2341
2315
  // store's own aliases, never an empty or foreign table.
2342
2316
  this.loadAliasesSync();
2317
+ this.loadHistoricalEntityCanonicalIdsSync();
2343
2318
  }
2344
2319
 
2345
2320
  /** Set the process-wide hot-memories cache default (issue #1902). The
@@ -3597,9 +3572,17 @@ export class StorageManager {
3597
3572
  * store loaded last rewrite every other store's canonical entity ids.
3598
3573
  */
3599
3574
  private userAliases: Record<string, string> = {};
3600
-
3575
+ private historicalEntityCanonicalIds: Readonly<Record<string, string>> = {};
3576
+ private readonly entityCanonicalIdMigration = new EntityCanonicalIdMigrationRunner(
3577
+ () => !(this._secureStoreRequired && !this.isSecureStoreUnlocked()),
3578
+ () => this.runLegacyEntityCanonicalIdMigration(),
3579
+ () => entityMigration.getFingerprint(this.baseDir, this.entitiesDir, () => this.getCorpusScanVersion()),
3580
+ );
3601
3581
  normalizeEntityName(raw: string, type: string): string {
3602
- return this.entityStore.normalizeEntityName(raw, type);
3582
+ return entityMigration.resolveHistoricalEntityCanonicalId(
3583
+ this.entityStore.normalizeEntityName(raw, type),
3584
+ this.historicalEntityCanonicalIds,
3585
+ );
3603
3586
  }
3604
3587
 
3605
3588
  /**
@@ -3646,8 +3629,24 @@ export class StorageManager {
3646
3629
  log.debug("no config/aliases.json found — using built-in aliases only");
3647
3630
  }
3648
3631
  }
3632
+ private loadHistoricalEntityCanonicalIdsSync(): void {
3633
+ this.historicalEntityCanonicalIds = entityMigration.loadHistoricalEntityCanonicalIds(this.stateDir);
3634
+ }
3635
+
3636
+ private async runLegacyEntityCanonicalIdMigration(): Promise<string> {
3637
+ const completionFingerprint = await runLegacyEntityCanonicalIdMigration(
3638
+ this as unknown as EntityCanonicalIdMigrationHost,
3639
+ (content) => parseEntityFile(content, this.entitySchemas),
3640
+ (entity) => serializeEntityFile(entity, this.entitySchemas),
3641
+ createMemoryEntityRefSerializer(serializeFrontmatter),
3642
+ );
3643
+ this.loadHistoricalEntityCanonicalIdsSync();
3644
+ return completionFingerprint;
3645
+ }
3649
3646
 
3650
3647
  async ensureDirectories(): Promise<void> {
3648
+ await mkdir(this.baseDir, { recursive: true });
3649
+ await entityMigration.validateRoots(this.baseDir, this.entitiesDir, this.stateDir, this.archiveDir);
3651
3650
  const today = new Date().toISOString().slice(0, 10);
3652
3651
  await mkdir(path.join(this.factsDir, today), { recursive: true });
3653
3652
  await mkdir(path.join(this.proceduresDir, today), { recursive: true });
@@ -3662,6 +3661,7 @@ export class StorageManager {
3662
3661
  await mkdir(this.identityAuditsWeeklyDir, { recursive: true });
3663
3662
  await mkdir(this.identityAuditsMonthlyDir, { recursive: true });
3664
3663
  await mkdir(path.join(this.baseDir, "config"), { recursive: true });
3664
+ await this.entityCanonicalIdMigration.ensure();
3665
3665
  // Activate the corpus sentinel at setup (issue #1902, Cursor Medium): an
3666
3666
  // existing corpus predating this feature has a size-0/absent sentinel, which
3667
3667
  // getCachedMemories treats as a miss — so a read-heavy workload would never
@@ -3675,6 +3675,7 @@ export class StorageManager {
3675
3675
  if (this.hotMemoriesCacheEnabled && this.getMemoryCorpusVersion() === 0) {
3676
3676
  this.bumpMemoryCorpusVersion();
3677
3677
  }
3678
+ await this.entityCanonicalIdMigration.markDirectoriesInitialized();
3678
3679
  }
3679
3680
 
3680
3681
  /**
@@ -4682,7 +4683,7 @@ export class StorageManager {
4682
4683
  const raw = await readMaybeEncryptedFile(fullPath, this._secureStoreKey, this.baseDir);
4683
4684
  const parsed = parseFrontmatter(raw);
4684
4685
  if (!parsed) return null;
4685
- return {
4686
+ return rememberRawFrontmatter({
4686
4687
  path: fullPath,
4687
4688
  frontmatter: normalizeFrontmatterForPath(
4688
4689
  parsed.frontmatter,
@@ -4690,7 +4691,7 @@ export class StorageManager {
4690
4691
  parsed.content
4691
4692
  ),
4692
4693
  content: parsed.content,
4693
- } satisfies MemoryFile;
4694
+ } satisfies MemoryFile, raw);
4694
4695
  } catch (err) {
4695
4696
  // Re-throw store-locked errors so a locked encrypted store fails
4696
4697
  // loudly rather than appearing as an empty memory corpus (Cursor
@@ -4841,7 +4842,7 @@ export class StorageManager {
4841
4842
  const raw = await readMaybeEncryptedFile(fullPath, this._secureStoreKey, this.baseDir);
4842
4843
  const parsed = parseFrontmatter(raw);
4843
4844
  if (parsed) {
4844
- memories.push({
4845
+ memories.push(rememberRawFrontmatter({
4845
4846
  path: fullPath,
4846
4847
  frontmatter: normalizeFrontmatterForPath(
4847
4848
  parsed.frontmatter,
@@ -4849,7 +4850,7 @@ export class StorageManager {
4849
4850
  parsed.content
4850
4851
  ),
4851
4852
  content: parsed.content,
4852
- });
4853
+ }, raw));
4853
4854
  }
4854
4855
  } catch (err) {
4855
4856
  // Re-throw store-locked errors — a locked encrypted store
@@ -6133,9 +6134,6 @@ export class StorageManager {
6133
6134
  this.invalidateKnowledgeIndexCache();
6134
6135
  }
6135
6136
 
6136
- /**
6137
- * Add an alias to an entity file. Deduplicates.
6138
- */
6139
6137
  async addEntityAlias(name: string, alias: string): Promise<void> {
6140
6138
  const filePath = path.join(this.entitiesDir, `${name}.md`);
6141
6139
  let entity: EntityFile;
@@ -6154,6 +6152,7 @@ export class StorageManager {
6154
6152
  entity.updated = new Date().toISOString();
6155
6153
  await this.writeStorageSecureFile(filePath, serializeEntityFile(entity, this.entitySchemas));
6156
6154
  this.invalidateKnowledgeIndexCache();
6155
+ this.bumpMemoryStatusVersion();
6157
6156
  }
6158
6157
 
6159
6158
  async updateEntitySynthesis(
package/src/types.ts CHANGED
@@ -3,6 +3,7 @@ import type { MeetingsConfig } from "./meetings/types.js";
3
3
  import type { ActivityConfig } from "./activity/types.js";
4
4
  import type { WearablesConfig } from "./wearables/types.js";
5
5
  import type { ExtractionLivenessConfig } from "./extraction-liveness.js";
6
+ import type { ReplicaPeersConfig } from "./replica-peers-config.js";
6
7
 
7
8
  export type ReasoningEffort = "none" | "low" | "medium" | "high";
8
9
  export type TriggerMode = "smart" | "every_n" | "time_based";
@@ -1208,9 +1209,8 @@ export interface PluginConfig extends BoundedJsonlStateConfig {
1208
1209
  dreamsPhases: DreamsPhasesConfig;
1209
1210
  procedural: ProceduralConfig;
1210
1211
  extractionLiveness: ExtractionLivenessConfig;
1211
- /** Claim-level provenance spans (#1575); see `ProvenanceConfig` for defaults.
1212
- * PR 1 parses + persists only; extraction wiring lands in PR 2.
1213
- */
1212
+ replicaPeers: ReplicaPeersConfig;
1213
+ /** Claim-level provenance spans (#1575); see `ProvenanceConfig` for defaults. */
1214
1214
  provenance: ProvenanceConfig;
1215
1215
  /**
1216
1216
  * Wearable transcript ingestion (Limitless / Bee / Omi connectors).
@@ -1556,8 +1556,8 @@ export interface PluginConfig extends BoundedJsonlStateConfig {
1556
1556
  profilingStorageDir: string;
1557
1557
  /** Maximum number of trace files to keep (rolling window). */
1558
1558
  profilingMaxTraces: number;
1559
- // Extraction stability guards (P0/P1)
1560
- extractionDedupeEnabled: boolean;
1559
+ // Extraction stability guards (P0/P1).
1560
+ extractionDedupeEnabled: boolean; extractionSourceGroundingEnabled: boolean;
1561
1561
  extractionDedupeWindowMs: number;
1562
1562
  extractionMinChars: number;
1563
1563
  extractionMinUserTurns: number;