@remnic/core 10.0.169 → 10.0.171

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 (360) hide show
  1. package/dist/access-admin-ops-surface.js +124 -123
  2. package/dist/access-cli.js +124 -123
  3. package/dist/access-cli.js.map +1 -1
  4. package/dist/access-coding-context-resolution.js +8 -8
  5. package/dist/access-extraction-force-flush-preempt.js +124 -123
  6. package/dist/access-extraction-force-flush.js +124 -123
  7. package/dist/access-http-briefing.js +124 -123
  8. package/dist/access-http-query.js +124 -123
  9. package/dist/access-http.js +124 -123
  10. package/dist/access-identity-continuity-surface.js +124 -123
  11. package/dist/access-lcm-surface.js +124 -123
  12. package/dist/access-mcp.js +124 -123
  13. package/dist/access-observe-write-category.js +8 -8
  14. package/dist/access-observe-write-surface.js +124 -123
  15. package/dist/access-offline-manifest.js +5 -5
  16. package/dist/access-operations-batch.js +124 -123
  17. package/dist/access-operations.js +124 -123
  18. package/dist/access-recall-concurrency.js +124 -123
  19. package/dist/access-recall-diagnostics.js +2 -2
  20. package/dist/access-recall-response.js +124 -123
  21. package/dist/access-recall-surface.d.ts.map +1 -1
  22. package/dist/access-recall-surface.js +124 -123
  23. package/dist/access-schema.js +7 -7
  24. package/dist/access-service.js +124 -123
  25. package/dist/active-recall.js +21 -20
  26. package/dist/active-recall.js.map +1 -1
  27. package/dist/adapters/index.js +4 -4
  28. package/dist/adapters/registry.js +2 -2
  29. package/dist/behavior-learner.js +1 -1
  30. package/dist/briefing.js +13 -13
  31. package/dist/buffer.js +6 -6
  32. package/dist/causal-behavior.js +2 -2
  33. package/dist/causal-chain.js +2 -2
  34. package/dist/causal-consolidation.js +16 -16
  35. package/dist/causal-retrieval.js +2 -2
  36. package/dist/causal-trajectory-graph.js +2 -2
  37. package/dist/causal-trajectory.js +1 -1
  38. package/dist/chat/chat-engine.d.ts +5 -3
  39. package/dist/chat/chat-engine.d.ts.map +1 -1
  40. package/dist/chat/chat-executor.d.ts +3 -4
  41. package/dist/chat/chat-executor.d.ts.map +1 -1
  42. package/dist/{chunk-FHWX2REL.js → chunk-2OAFPBQB.js} +2 -2
  43. package/dist/{chunk-5IZL4DCV.js → chunk-4DF5LMBJ.js} +2 -2
  44. package/dist/{chunk-FWTGO4NE.js → chunk-4DLGKTM6.js} +2 -2
  45. package/dist/{chunk-D6YCETHG.js → chunk-4E2Z44CV.js} +2 -2
  46. package/dist/{chunk-W4EJMMPP.js → chunk-4LVQSHHN.js} +11 -11
  47. package/dist/{chunk-W4Q65VJL.js → chunk-4X7HQKAG.js} +2 -2
  48. package/dist/{chunk-I74SUMNI.js → chunk-5ACIRCBO.js} +65 -3
  49. package/dist/chunk-5ACIRCBO.js.map +1 -0
  50. package/dist/{chunk-LPUEBFX2.js → chunk-5JCYPBY5.js} +2 -2
  51. package/dist/{chunk-ID65XTF3.js → chunk-5SOSQTVE.js} +2 -2
  52. package/dist/{chunk-SEIGLG62.js → chunk-6VFMEBXY.js} +4 -4
  53. package/dist/{chunk-333SBFXB.js → chunk-7AAMJQFW.js} +2 -2
  54. package/dist/{chunk-AHOYKJ5X.js → chunk-7SNEJNA3.js} +96 -23
  55. package/dist/chunk-7SNEJNA3.js.map +1 -0
  56. package/dist/{chunk-T3MCVSUC.js → chunk-A2XFG462.js} +2 -2
  57. package/dist/{chunk-HXFIILGF.js → chunk-BFPF5N3H.js} +4 -4
  58. package/dist/{chunk-GWY5ZFHP.js → chunk-BJOQQCYC.js} +5 -5
  59. package/dist/{chunk-7OYDFIL4.js → chunk-CY2C5LM4.js} +3 -3
  60. package/dist/{chunk-BFBS7OFQ.js → chunk-DC55RIEZ.js} +4 -4
  61. package/dist/{chunk-TGQW3AMK.js → chunk-DNXQVCIC.js} +3 -3
  62. package/dist/{chunk-TQ4CELUR.js → chunk-E53NLIAP.js} +3 -3
  63. package/dist/{chunk-2LA3H54D.js → chunk-E5IZTY4W.js} +2 -2
  64. package/dist/{chunk-PFR6ZKQI.js → chunk-EBI6FI5U.js} +6 -6
  65. package/dist/{chunk-JN7OSQJR.js → chunk-ETTV5F53.js} +2 -2
  66. package/dist/{chunk-FRYCXXTB.js → chunk-FSORYJRP.js} +3 -3
  67. package/dist/{chunk-K36RMINQ.js → chunk-GOZXQNIM.js} +3 -3
  68. package/dist/{chunk-H4IU24V5.js → chunk-GUF2JKG5.js} +2 -2
  69. package/dist/{chunk-XTRC6SSS.js → chunk-H6TCS5XX.js} +11 -8
  70. package/dist/chunk-H6TCS5XX.js.map +1 -0
  71. package/dist/{chunk-MTJFK42O.js → chunk-HHVK2JRE.js} +2 -2
  72. package/dist/{chunk-D5ZLTLHF.js → chunk-HR3DKJCU.js} +2 -2
  73. package/dist/{chunk-AUFPPBC3.js → chunk-IJKO5RVJ.js} +3 -3
  74. package/dist/{chunk-O3OEVYUR.js → chunk-IK7NPYYU.js} +2 -2
  75. package/dist/{chunk-ILNPU5W5.js → chunk-IMA4DJ7K.js} +5 -45
  76. package/dist/chunk-IMA4DJ7K.js.map +1 -0
  77. package/dist/{chunk-ACPFBVUD.js → chunk-JDH2BA2P.js} +2 -2
  78. package/dist/{chunk-VF6SC4OD.js → chunk-JNBSTHVT.js} +2 -2
  79. package/dist/chunk-JVVWCZ2P.js +18 -0
  80. package/dist/chunk-JVVWCZ2P.js.map +1 -0
  81. package/dist/{chunk-OBPOIZNR.js → chunk-KBHUGMUW.js} +2 -2
  82. package/dist/{chunk-M7CFCRWJ.js → chunk-KW4XA7GM.js} +3 -3
  83. package/dist/{chunk-B5KTTWC7.js → chunk-L5EE2CXU.js} +2 -2
  84. package/dist/{chunk-QNUNAXBE.js → chunk-L7LZDISF.js} +1 -9
  85. package/dist/{chunk-QNUNAXBE.js.map → chunk-L7LZDISF.js.map} +1 -1
  86. package/dist/{chunk-N3FRR6II.js → chunk-LAOJHOTG.js} +2 -2
  87. package/dist/{chunk-QPLI7LUU.js → chunk-LH57QATU.js} +2 -2
  88. package/dist/{chunk-JGGNUEVD.js → chunk-NDPS6OU2.js} +2 -2
  89. package/dist/{chunk-N7AIFTSH.js → chunk-NJG63FY2.js} +1 -1
  90. package/dist/{chunk-N7AIFTSH.js.map → chunk-NJG63FY2.js.map} +1 -1
  91. package/dist/{chunk-UPD5XDJX.js → chunk-NKAGGDSL.js} +4 -4
  92. package/dist/{chunk-G3RLCVJC.js → chunk-OGQL7QC7.js} +2 -2
  93. package/dist/{chunk-K3FH3LAQ.js → chunk-OJXK5C6Z.js} +4 -4
  94. package/dist/{chunk-HDLNSDLK.js → chunk-P3XO7HE3.js} +2 -2
  95. package/dist/{chunk-VMRPLHEU.js → chunk-PQIFYBUX.js} +2 -2
  96. package/dist/{chunk-WLT6LTQP.js → chunk-PRRWKTK6.js} +2 -2
  97. package/dist/{chunk-CX24SVLK.js → chunk-Q7OKGBZY.js} +2 -2
  98. package/dist/{chunk-BHRPZBAH.js → chunk-QJBULLKG.js} +3 -3
  99. package/dist/{chunk-WCJQ3OUP.js → chunk-QKAFFVSO.js} +2 -2
  100. package/dist/{chunk-VKXJQF5C.js → chunk-QKBFVLDH.js} +2 -2
  101. package/dist/{chunk-I7WPLMUX.js → chunk-QRCE77YX.js} +2 -2
  102. package/dist/{chunk-K2DTHNDY.js → chunk-R2AJAAHJ.js} +4 -4
  103. package/dist/{chunk-5KDDAQ6K.js → chunk-R3UQIS3F.js} +6 -6
  104. package/dist/{chunk-B3M56D2A.js → chunk-RDHEBINJ.js} +2 -2
  105. package/dist/{chunk-3I3NXB6X.js → chunk-RHQL2RIM.js} +2 -2
  106. package/dist/{chunk-FMIM36I4.js → chunk-SA2YALFU.js} +2 -2
  107. package/dist/{chunk-DPL5VO5V.js → chunk-SAPC7N43.js} +3 -3
  108. package/dist/{chunk-7FPI5MFB.js → chunk-SLWD7TB6.js} +5 -5
  109. package/dist/{chunk-ZA6CYFAK.js → chunk-SOQOUZ2Y.js} +2 -2
  110. package/dist/{chunk-VHXRLD6S.js → chunk-T2JZF45K.js} +2 -2
  111. package/dist/{chunk-32OTLNAU.js → chunk-T2KCROPA.js} +230 -216
  112. package/dist/chunk-T2KCROPA.js.map +1 -0
  113. package/dist/{chunk-63A2BU2B.js → chunk-T4MKFTJF.js} +2 -2
  114. package/dist/{chunk-E7ATID4Z.js → chunk-UFX24WNJ.js} +14 -14
  115. package/dist/{chunk-HQPFACXO.js → chunk-UH3FPX3L.js} +2 -2
  116. package/dist/{chunk-3LADDLAF.js → chunk-V5W67PQV.js} +4 -4
  117. package/dist/{chunk-PRC7SZYM.js → chunk-VAQIBC2L.js} +2 -2
  118. package/dist/{chunk-3Q3XD3NO.js → chunk-W2E2WFXL.js} +3 -3
  119. package/dist/{chunk-GF5NN3LE.js → chunk-W2UV6VE3.js} +2 -2
  120. package/dist/{chunk-SH3GOZWK.js → chunk-W35ICLYZ.js} +2 -2
  121. package/dist/{chunk-ALTLOHO7.js → chunk-WF2LYKOB.js} +2 -2
  122. package/dist/{chunk-FSXYBIEZ.js → chunk-X5MFCZDL.js} +72 -35
  123. package/dist/chunk-X5MFCZDL.js.map +1 -0
  124. package/dist/{chunk-FZVROZKC.js → chunk-XVZA6VXC.js} +4 -4
  125. package/dist/{chunk-IJVU4ILJ.js → chunk-XYNUEXLC.js} +4 -4
  126. package/dist/{chunk-RVAPK2S7.js → chunk-Y65XX5PC.js} +2 -2
  127. package/dist/{chunk-YWMCV5HL.js → chunk-YE77U5HZ.js} +3 -3
  128. package/dist/{chunk-VPEIWMUT.js → chunk-YLTU2DC4.js} +2 -2
  129. package/dist/{chunk-62YZOQFR.js → chunk-YRD525ZO.js} +2 -2
  130. package/dist/{chunk-TBBDFYXW.js → chunk-YVUNHNB6.js} +2 -3
  131. package/dist/chunk-YVUNHNB6.js.map +1 -0
  132. package/dist/{chunk-ITGAGNX5.js → chunk-YY5UXARJ.js} +24 -12
  133. package/dist/chunk-YY5UXARJ.js.map +1 -0
  134. package/dist/{chunk-U7KP6QFU.js → chunk-ZJ3CEAJD.js} +2 -2
  135. package/dist/{chunk-QC2MHZDD.js → chunk-ZOJUWVAU.js} +1 -1
  136. package/dist/{chunk-HH6PXQ2B.js → chunk-ZYP4YEEI.js} +2 -2
  137. package/dist/cli.js +124 -123
  138. package/dist/coding/export-okf-codegraph.js +21 -21
  139. package/dist/coding/pre-action-gate.js +2 -2
  140. package/dist/compounding/engine.js +14 -14
  141. package/dist/config-deprecations.d.ts +3 -0
  142. package/dist/config-deprecations.d.ts.map +1 -0
  143. package/dist/config-deprecations.js +9 -0
  144. package/dist/config.d.ts.map +1 -1
  145. package/dist/config.js +21 -20
  146. package/dist/connectors/codex-materialize-runner.js +13 -13
  147. package/dist/connectors/index.js +13 -13
  148. package/dist/convergence-refresh.js +16 -16
  149. package/dist/corpus-watermark.js +15 -15
  150. package/dist/correction/correction-access-wiring.d.ts +4 -1
  151. package/dist/correction/correction-access-wiring.d.ts.map +1 -1
  152. package/dist/deep-recall-http-glue.js +8 -8
  153. package/dist/deep-recall.js +2 -2
  154. package/dist/embedding-fallback.js +1 -1
  155. package/dist/entity-retrieval.js +14 -14
  156. package/dist/explicit-capture.js +124 -123
  157. package/dist/extraction-span-materialize.js +2 -2
  158. package/dist/extraction.js +22 -22
  159. package/dist/{first-start-migration-BPVJ4HJQ.js → first-start-migration-PPPP54X6.js} +5 -5
  160. package/dist/{graph-edge-decay-CXTNJ7IQ.js → graph-edge-decay-EKWXRBWF.js} +5 -5
  161. package/dist/graph-jsonl.js +3 -3
  162. package/dist/graph-snapshot.js +3 -3
  163. package/dist/graph.js +2 -2
  164. package/dist/harmonic-retrieval.js +13 -13
  165. package/dist/index.js +173 -171
  166. package/dist/lcm/engine.js +2 -2
  167. package/dist/lcm/index.js +4 -4
  168. package/dist/lifecycle.d.ts +0 -6
  169. package/dist/lifecycle.d.ts.map +1 -1
  170. package/dist/lifecycle.js +1 -1
  171. package/dist/location/index.js +25 -15
  172. package/dist/location/provider-setup.d.ts +26 -1
  173. package/dist/location/provider-setup.d.ts.map +1 -1
  174. package/dist/maintenance/memory-governance.js +14 -14
  175. package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +13 -13
  176. package/dist/maintenance/rebuild-memory-projection-runner.js +16 -16
  177. package/dist/maintenance/rebuild-memory-projection.js +15 -15
  178. package/dist/memory-browse.js +6 -6
  179. package/dist/{migrate-from-identity-anchor-MJYB6NNN.js → migrate-from-identity-anchor-TZSZXJ6L.js} +2 -2
  180. package/dist/migrate-from-identity-anchor-TZSZXJ6L.js.map +1 -0
  181. package/dist/model-registry.d.ts +0 -5
  182. package/dist/model-registry.d.ts.map +1 -1
  183. package/dist/model-registry.js +1 -1
  184. package/dist/namespaces/migrate.js +14 -14
  185. package/dist/namespaces/search.js +6 -6
  186. package/dist/namespaces/storage.js +13 -13
  187. package/dist/offline-sync-changeset-generations.js +3 -3
  188. package/dist/offline-sync-embedding-generation.js +2 -2
  189. package/dist/offline-sync-snapshot-stream.js +5 -5
  190. package/dist/offline-sync.js +4 -4
  191. package/dist/operator-doctor-corpus.js +16 -16
  192. package/dist/operator-toolkit.js +32 -31
  193. package/dist/orchestration/backlog-scheduler.js +125 -124
  194. package/dist/orchestration/backlog-scheduler.js.map +1 -1
  195. package/dist/orchestration/buffer-drain-runner.js +125 -124
  196. package/dist/orchestration/maintenance.js +22 -22
  197. package/dist/orchestration/semantic-consolidation-coordinator.d.ts.map +1 -1
  198. package/dist/orchestration/workspace-ops.d.ts.map +1 -1
  199. package/dist/orchestrator.js +124 -123
  200. package/dist/peers/index.d.ts +2 -1
  201. package/dist/peers/index.d.ts.map +1 -1
  202. package/dist/peers/index.js +3 -3
  203. package/dist/peers/interaction-log-append.d.ts +8 -0
  204. package/dist/peers/interaction-log-append.d.ts.map +1 -0
  205. package/dist/peers/storage.d.ts +22 -8
  206. package/dist/peers/storage.d.ts.map +1 -1
  207. package/dist/policy-runtime.js +2 -2
  208. package/dist/qmd.js +2 -2
  209. package/dist/recall-explain-renderer.js +3 -3
  210. package/dist/recall-navigate-access.js +2 -2
  211. package/dist/recall-navigate-disclosure.js +2 -2
  212. package/dist/recall-navigate.js +2 -2
  213. package/dist/recall-navigation.js +124 -123
  214. package/dist/recall-state-view-admission.js +6 -6
  215. package/dist/recall-why-service.js +6 -6
  216. package/dist/recall-xray-cli.js +4 -4
  217. package/dist/recall-xray-renderer.js +3 -3
  218. package/dist/recall-xray.js +2 -2
  219. package/dist/resume-bundles.js +22 -21
  220. package/dist/retrieval.js +2 -2
  221. package/dist/search/factory.js +5 -5
  222. package/dist/search/index.js +9 -9
  223. package/dist/semantic-consolidation.d.ts +10 -16
  224. package/dist/semantic-consolidation.d.ts.map +1 -1
  225. package/dist/semantic-consolidation.js +14 -14
  226. package/dist/semantic-rule-promotion.js +13 -13
  227. package/dist/semantic-rule-verifier.js +13 -13
  228. package/dist/source-agent-qualifier.js +17 -17
  229. package/dist/standup/build.js +13 -13
  230. package/dist/storage/links-frontmatter.d.ts +3 -0
  231. package/dist/storage/links-frontmatter.d.ts.map +1 -0
  232. package/dist/storage.d.ts.map +1 -1
  233. package/dist/storage.js +12 -12
  234. package/dist/summarizer.js +2 -2
  235. package/dist/tier-routing.js +2 -2
  236. package/dist/{tier-stats-FLFKN7Y6.js → tier-stats-XWJSVEHC.js} +5 -5
  237. package/dist/transfer/capsule-export.js +2 -2
  238. package/dist/transfer/capsule-import.js +2 -2
  239. package/dist/transfer/export-okf.js +13 -13
  240. package/dist/types.d.ts +1 -0
  241. package/dist/types.d.ts.map +1 -1
  242. package/dist/types.js +1 -1
  243. package/dist/utility-learner.js +2 -2
  244. package/dist/utility-runtime.js +3 -3
  245. package/dist/verified-recall.js +13 -13
  246. package/dist/who-knows-cli.js +14 -14
  247. package/dist/who-knows.js +13 -13
  248. package/package.json +2 -2
  249. package/src/access-recall-surface.ts +0 -2
  250. package/src/chat/chat-engine.ts +5 -3
  251. package/src/chat/chat-executor.test.ts +150 -0
  252. package/src/chat/chat-executor.ts +31 -20
  253. package/src/chat/chat-factory.ts +1 -1
  254. package/src/config-deprecations.ts +14 -0
  255. package/src/config.ts +2 -1
  256. package/src/correction/correction-access-wiring.ts +4 -1
  257. package/src/lifecycle.ts +0 -8
  258. package/src/location/provider-setup.test.ts +273 -2
  259. package/src/location/provider-setup.ts +138 -32
  260. package/src/model-registry.ts +0 -11
  261. package/src/orchestration/semantic-consolidation-coordinator.ts +40 -33
  262. package/src/orchestration/semantic-consolidation-split.test.ts +72 -0
  263. package/src/orchestration/workspace-ops.test.ts +23 -0
  264. package/src/orchestration/workspace-ops.ts +6 -5
  265. package/src/peers/index.ts +1 -1
  266. package/src/peers/interaction-log-append.ts +132 -0
  267. package/src/peers/peers.test.ts +30 -0
  268. package/src/peers/profile-reasoner.ts +1 -1
  269. package/src/peers/storage.ts +4 -105
  270. package/src/semantic-consolidation.ts +35 -27
  271. package/src/storage/links-frontmatter.ts +69 -0
  272. package/src/storage-links-parse.test.ts +153 -0
  273. package/src/storage.ts +4 -18
  274. package/src/testing/subjects/dependency-propagation.test.ts +5 -4
  275. package/src/types.ts +1 -0
  276. package/dist/chunk-32OTLNAU.js.map +0 -1
  277. package/dist/chunk-AHOYKJ5X.js.map +0 -1
  278. package/dist/chunk-FSXYBIEZ.js.map +0 -1
  279. package/dist/chunk-I74SUMNI.js.map +0 -1
  280. package/dist/chunk-ILNPU5W5.js.map +0 -1
  281. package/dist/chunk-ITGAGNX5.js.map +0 -1
  282. package/dist/chunk-TBBDFYXW.js.map +0 -1
  283. package/dist/chunk-XTRC6SSS.js.map +0 -1
  284. /package/dist/{chunk-FHWX2REL.js.map → chunk-2OAFPBQB.js.map} +0 -0
  285. /package/dist/{chunk-5IZL4DCV.js.map → chunk-4DF5LMBJ.js.map} +0 -0
  286. /package/dist/{chunk-FWTGO4NE.js.map → chunk-4DLGKTM6.js.map} +0 -0
  287. /package/dist/{chunk-D6YCETHG.js.map → chunk-4E2Z44CV.js.map} +0 -0
  288. /package/dist/{chunk-W4EJMMPP.js.map → chunk-4LVQSHHN.js.map} +0 -0
  289. /package/dist/{chunk-W4Q65VJL.js.map → chunk-4X7HQKAG.js.map} +0 -0
  290. /package/dist/{chunk-LPUEBFX2.js.map → chunk-5JCYPBY5.js.map} +0 -0
  291. /package/dist/{chunk-ID65XTF3.js.map → chunk-5SOSQTVE.js.map} +0 -0
  292. /package/dist/{chunk-SEIGLG62.js.map → chunk-6VFMEBXY.js.map} +0 -0
  293. /package/dist/{chunk-333SBFXB.js.map → chunk-7AAMJQFW.js.map} +0 -0
  294. /package/dist/{chunk-T3MCVSUC.js.map → chunk-A2XFG462.js.map} +0 -0
  295. /package/dist/{chunk-HXFIILGF.js.map → chunk-BFPF5N3H.js.map} +0 -0
  296. /package/dist/{chunk-GWY5ZFHP.js.map → chunk-BJOQQCYC.js.map} +0 -0
  297. /package/dist/{chunk-7OYDFIL4.js.map → chunk-CY2C5LM4.js.map} +0 -0
  298. /package/dist/{chunk-BFBS7OFQ.js.map → chunk-DC55RIEZ.js.map} +0 -0
  299. /package/dist/{chunk-TGQW3AMK.js.map → chunk-DNXQVCIC.js.map} +0 -0
  300. /package/dist/{chunk-TQ4CELUR.js.map → chunk-E53NLIAP.js.map} +0 -0
  301. /package/dist/{chunk-2LA3H54D.js.map → chunk-E5IZTY4W.js.map} +0 -0
  302. /package/dist/{chunk-PFR6ZKQI.js.map → chunk-EBI6FI5U.js.map} +0 -0
  303. /package/dist/{chunk-JN7OSQJR.js.map → chunk-ETTV5F53.js.map} +0 -0
  304. /package/dist/{chunk-FRYCXXTB.js.map → chunk-FSORYJRP.js.map} +0 -0
  305. /package/dist/{chunk-K36RMINQ.js.map → chunk-GOZXQNIM.js.map} +0 -0
  306. /package/dist/{chunk-H4IU24V5.js.map → chunk-GUF2JKG5.js.map} +0 -0
  307. /package/dist/{chunk-MTJFK42O.js.map → chunk-HHVK2JRE.js.map} +0 -0
  308. /package/dist/{chunk-D5ZLTLHF.js.map → chunk-HR3DKJCU.js.map} +0 -0
  309. /package/dist/{chunk-AUFPPBC3.js.map → chunk-IJKO5RVJ.js.map} +0 -0
  310. /package/dist/{chunk-O3OEVYUR.js.map → chunk-IK7NPYYU.js.map} +0 -0
  311. /package/dist/{chunk-ACPFBVUD.js.map → chunk-JDH2BA2P.js.map} +0 -0
  312. /package/dist/{chunk-VF6SC4OD.js.map → chunk-JNBSTHVT.js.map} +0 -0
  313. /package/dist/{chunk-OBPOIZNR.js.map → chunk-KBHUGMUW.js.map} +0 -0
  314. /package/dist/{chunk-M7CFCRWJ.js.map → chunk-KW4XA7GM.js.map} +0 -0
  315. /package/dist/{chunk-B5KTTWC7.js.map → chunk-L5EE2CXU.js.map} +0 -0
  316. /package/dist/{chunk-N3FRR6II.js.map → chunk-LAOJHOTG.js.map} +0 -0
  317. /package/dist/{chunk-QPLI7LUU.js.map → chunk-LH57QATU.js.map} +0 -0
  318. /package/dist/{chunk-JGGNUEVD.js.map → chunk-NDPS6OU2.js.map} +0 -0
  319. /package/dist/{chunk-UPD5XDJX.js.map → chunk-NKAGGDSL.js.map} +0 -0
  320. /package/dist/{chunk-G3RLCVJC.js.map → chunk-OGQL7QC7.js.map} +0 -0
  321. /package/dist/{chunk-K3FH3LAQ.js.map → chunk-OJXK5C6Z.js.map} +0 -0
  322. /package/dist/{chunk-HDLNSDLK.js.map → chunk-P3XO7HE3.js.map} +0 -0
  323. /package/dist/{chunk-VMRPLHEU.js.map → chunk-PQIFYBUX.js.map} +0 -0
  324. /package/dist/{chunk-WLT6LTQP.js.map → chunk-PRRWKTK6.js.map} +0 -0
  325. /package/dist/{chunk-CX24SVLK.js.map → chunk-Q7OKGBZY.js.map} +0 -0
  326. /package/dist/{chunk-BHRPZBAH.js.map → chunk-QJBULLKG.js.map} +0 -0
  327. /package/dist/{chunk-WCJQ3OUP.js.map → chunk-QKAFFVSO.js.map} +0 -0
  328. /package/dist/{chunk-VKXJQF5C.js.map → chunk-QKBFVLDH.js.map} +0 -0
  329. /package/dist/{chunk-I7WPLMUX.js.map → chunk-QRCE77YX.js.map} +0 -0
  330. /package/dist/{chunk-K2DTHNDY.js.map → chunk-R2AJAAHJ.js.map} +0 -0
  331. /package/dist/{chunk-5KDDAQ6K.js.map → chunk-R3UQIS3F.js.map} +0 -0
  332. /package/dist/{chunk-B3M56D2A.js.map → chunk-RDHEBINJ.js.map} +0 -0
  333. /package/dist/{chunk-3I3NXB6X.js.map → chunk-RHQL2RIM.js.map} +0 -0
  334. /package/dist/{chunk-FMIM36I4.js.map → chunk-SA2YALFU.js.map} +0 -0
  335. /package/dist/{chunk-DPL5VO5V.js.map → chunk-SAPC7N43.js.map} +0 -0
  336. /package/dist/{chunk-7FPI5MFB.js.map → chunk-SLWD7TB6.js.map} +0 -0
  337. /package/dist/{chunk-ZA6CYFAK.js.map → chunk-SOQOUZ2Y.js.map} +0 -0
  338. /package/dist/{chunk-VHXRLD6S.js.map → chunk-T2JZF45K.js.map} +0 -0
  339. /package/dist/{chunk-63A2BU2B.js.map → chunk-T4MKFTJF.js.map} +0 -0
  340. /package/dist/{chunk-E7ATID4Z.js.map → chunk-UFX24WNJ.js.map} +0 -0
  341. /package/dist/{chunk-HQPFACXO.js.map → chunk-UH3FPX3L.js.map} +0 -0
  342. /package/dist/{chunk-3LADDLAF.js.map → chunk-V5W67PQV.js.map} +0 -0
  343. /package/dist/{chunk-PRC7SZYM.js.map → chunk-VAQIBC2L.js.map} +0 -0
  344. /package/dist/{chunk-3Q3XD3NO.js.map → chunk-W2E2WFXL.js.map} +0 -0
  345. /package/dist/{chunk-GF5NN3LE.js.map → chunk-W2UV6VE3.js.map} +0 -0
  346. /package/dist/{chunk-SH3GOZWK.js.map → chunk-W35ICLYZ.js.map} +0 -0
  347. /package/dist/{chunk-ALTLOHO7.js.map → chunk-WF2LYKOB.js.map} +0 -0
  348. /package/dist/{chunk-FZVROZKC.js.map → chunk-XVZA6VXC.js.map} +0 -0
  349. /package/dist/{chunk-IJVU4ILJ.js.map → chunk-XYNUEXLC.js.map} +0 -0
  350. /package/dist/{chunk-RVAPK2S7.js.map → chunk-Y65XX5PC.js.map} +0 -0
  351. /package/dist/{chunk-YWMCV5HL.js.map → chunk-YE77U5HZ.js.map} +0 -0
  352. /package/dist/{chunk-VPEIWMUT.js.map → chunk-YLTU2DC4.js.map} +0 -0
  353. /package/dist/{chunk-62YZOQFR.js.map → chunk-YRD525ZO.js.map} +0 -0
  354. /package/dist/{chunk-U7KP6QFU.js.map → chunk-ZJ3CEAJD.js.map} +0 -0
  355. /package/dist/{chunk-QC2MHZDD.js.map → chunk-ZOJUWVAU.js.map} +0 -0
  356. /package/dist/{chunk-HH6PXQ2B.js.map → chunk-ZYP4YEEI.js.map} +0 -0
  357. /package/dist/{graph-edge-decay-CXTNJ7IQ.js.map → config-deprecations.js.map} +0 -0
  358. /package/dist/{first-start-migration-BPVJ4HJQ.js.map → first-start-migration-PPPP54X6.js.map} +0 -0
  359. /package/dist/{migrate-from-identity-anchor-MJYB6NNN.js.map → graph-edge-decay-EKWXRBWF.js.map} +0 -0
  360. /package/dist/{tier-stats-FLFKN7Y6.js.map → tier-stats-XWJSVEHC.js.map} +0 -0
@@ -131,7 +131,7 @@ async function writeFileNoFollowIfAbsent(file: string, data: string): Promise<bo
131
131
 
132
132
  /** Append to a file, refusing to follow symlinks AND verifying parent
133
133
  * inode stability (codex P1 round 9). */
134
- async function appendFileNoFollow(file: string, data: string): Promise<void> {
134
+ export async function appendFileNoFollow(file: string, data: string): Promise<void> {
135
135
  await assertParentDirInodeStable(file);
136
136
  const fh = await openNoFollow(
137
137
  file,
@@ -274,7 +274,7 @@ async function assertPeersRootNotSymlink(memoryDir: string): Promise<void> {
274
274
  * target. The dir handle is held across the mkdir, then we lstat
275
275
  * the candidate and reject if it's a symlink.
276
276
  */
277
- async function mkdirPeerDirAtomic(memoryDir: string, peerId: string): Promise<void> {
277
+ export async function mkdirPeerDirAtomic(memoryDir: string, peerId: string): Promise<void> {
278
278
  const root = peersRoot(memoryDir);
279
279
  // Ensure the root exists as a real directory, not a symlink. Use
280
280
  // mkdir + lstat: if mkdir succeeds (or EEXIST), lstat must report
@@ -326,7 +326,7 @@ async function mkdirPeerDirAtomic(memoryDir: string, peerId: string): Promise<vo
326
326
  * can lstat it and realpath-check containment. For first-time writes,
327
327
  * call `mkdirPeerDirAtomic` BEFORE this; for reads, this alone.
328
328
  */
329
- async function assertPeerDirNotEscaped(memoryDir: string, peerId: string): Promise<void> {
329
+ export async function assertPeerDirNotEscaped(memoryDir: string, peerId: string): Promise<void> {
330
330
  const candidate = peerDir(memoryDir, peerId);
331
331
  const root = peersRoot(memoryDir);
332
332
  // 1. The peers root must not be a symlink (defensive — writers
@@ -361,7 +361,7 @@ function profilePath(memoryDir: string, peerId: string): string {
361
361
  return path.join(peerDir(memoryDir, peerId), "profile.md");
362
362
  }
363
363
 
364
- function interactionsPath(memoryDir: string, peerId: string): string {
364
+ export function interactionsPath(memoryDir: string, peerId: string): string {
365
365
  return path.join(peerDir(memoryDir, peerId), "interactions.log.md");
366
366
  }
367
367
 
@@ -898,20 +898,6 @@ export async function listPeers(memoryDir: string): Promise<Peer[]> {
898
898
  // Interaction log (append-only)
899
899
  // ──────────────────────────────────────────────────────────────────────
900
900
 
901
- function sanitizeLogField(value: string): string {
902
- // Cursor Medium: every interaction-log field — not just summary —
903
- // must collapse newlines so a malicious or buggy `timestamp` /
904
- // `kind` / `sessionId` value can't break the one-line-per-entry
905
- // invariant the append-only log relies on. Replace CR/LF/Tab with
906
- // a single space; trim leading/trailing whitespace.
907
- return value.replace(/[\r\n\t]+/g, " ").trim();
908
- }
909
-
910
- function isCanonicalIsoTimestamp(value: string): boolean {
911
- const ms = Date.parse(value);
912
- return Number.isFinite(ms) && new Date(ms).toISOString() === value;
913
- }
914
-
915
901
  function parseIsoTimestampMs(value: string): number | null {
916
902
  if (!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})$/.test(value)) {
917
903
  return null;
@@ -920,93 +906,6 @@ function parseIsoTimestampMs(value: string): number | null {
920
906
  return Number.isFinite(ms) ? ms : null;
921
907
  }
922
908
 
923
- function assertCanonicalIsoTimestamp(value: string, field: string): void {
924
- if (!isCanonicalIsoTimestamp(value)) {
925
- throw new Error(`${field} must be a canonical ISO-8601 timestamp`);
926
- }
927
- }
928
-
929
- function formatLogEntry(entry: PeerInteractionLogEntry): string {
930
- // One line per entry. We use a leading bullet so the file remains
931
- // readable as ordinary markdown. Order: timestamp, kind, optional
932
- // session id, summary. ALL fields are passed through `sanitizeLogField`
933
- // so a stray newline anywhere can't shatter the append-only invariant
934
- // (cursor Medium on PR #723).
935
- //
936
- // Cursor Low on PR #736: the previous bare `session=<id>` token was
937
- // ambiguous with summaries that literally start with `session=`
938
- // (e.g. summary `"session=foo bar"` round-tripped to
939
- // `{sessionId: "foo", summary: "bar"}`). New entries wrap the
940
- // session marker in square brackets — `[session=<id>]` — which a
941
- // sanitized summary can never start with (sanitizeLogField never
942
- // emits `[` as the first character of a summary that originally
943
- // started with `session=`, and bracketed metadata is unambiguously
944
- // distinct from `session=` text). Old entries written by previous
945
- // code remain parseable through the legacy fallback in
946
- // `parseLogLine`.
947
- const ts = sanitizeLogField(entry.timestamp);
948
- const kind = sanitizeLogField(entry.kind);
949
- const summary = sanitizeLogField(entry.summary);
950
- const session = entry.sessionId
951
- ? ` [session=${sanitizeLogField(entry.sessionId)}]`
952
- : "";
953
- return `- [${ts}] (${kind})${session} ${summary}`;
954
- }
955
-
956
- /**
957
- * Append one entry to a peer's interaction log.
958
- *
959
- * Creates `peers/{id}/` and `interactions.log.md` if needed. The file is
960
- * append-only by contract — this helper never rewrites prior entries.
961
- * Returns the absolute path of the log file (useful for tests).
962
- */
963
- export async function appendInteractionLog(
964
- memoryDir: string,
965
- peerId: string,
966
- entry: PeerInteractionLogEntry,
967
- ): Promise<string> {
968
- assertValidPeerId(peerId);
969
- // Codex P2 round 10: trim() before the empty check matches what
970
- // sanitizeLogField does at format time. A whitespace-only
971
- // `timestamp` or `kind` would previously pass validation and then
972
- // be normalized to "" later, producing an entry like `- [] ()`
973
- // that breaks downstream parsers.
974
- if (typeof entry.timestamp !== "string" || entry.timestamp.trim() === "") {
975
- throw new Error("interaction entry must have a non-whitespace timestamp");
976
- }
977
- assertCanonicalIsoTimestamp(entry.timestamp.trim(), "interaction entry timestamp");
978
- if (typeof entry.kind !== "string" || entry.kind.trim() === "") {
979
- throw new Error("interaction entry must have a non-whitespace kind");
980
- }
981
- if (typeof entry.summary !== "string") {
982
- throw new Error("interaction entry must have a string summary");
983
- }
984
- // Codex P2 round 6/8/9: optional sessionId must be a non-empty
985
- // string OR strictly `undefined` (omitted). null and empty string
986
- // are both rejected explicitly: the previous behavior silently
987
- // dropped them during formatting, which reinterprets invalid input
988
- // instead of failing fast like other validators in this module.
989
- // Codex P2 round 12: trim() before the empty check matches what
990
- // sanitizeLogField does at format time. Whitespace-only sessionId
991
- // would otherwise pass validation and produce a `session=` token
992
- // with an empty value that breaks downstream log parsers.
993
- if (entry.sessionId !== undefined) {
994
- if (typeof entry.sessionId !== "string" || entry.sessionId.trim() === "") {
995
- throw new Error("interaction entry sessionId must be a non-whitespace string when provided");
996
- }
997
- }
998
- await mkdirPeerDirAtomic(memoryDir, peerId);
999
- await assertPeerDirNotEscaped(memoryDir, peerId);
1000
- const file = interactionsPath(memoryDir, peerId);
1001
- const line = formatLogEntry(entry) + "\n";
1002
- // `appendFile` creates the file if it does not exist. POSIX guarantees
1003
- // writes < PIPE_BUF are atomic; entries on this path are well under
1004
- // that bound. Ordering across concurrent writers is the caller's
1005
- // responsibility for now — the reasoner runs serially in PR 2/5.
1006
- await appendFileNoFollow(file, line);
1007
- return file;
1008
- }
1009
-
1010
909
  // ──────────────────────────────────────────────────────────────────────
1011
910
  // Profile read/write (schema scaffold; reasoner ships in PR 2/5)
1012
911
  // ──────────────────────────────────────────────────────────────────────
@@ -6,6 +6,8 @@
6
6
  * Reduces memory store bloat while preserving all unique information.
7
7
  */
8
8
 
9
+ import { z } from "zod";
10
+
9
11
  import type { MemoryFile, PluginConfig } from "./types.js";
10
12
  import { normalizeRecallTokens, countRecallTokenOverlap } from "./recall-tokenization.js";
11
13
  import { runPostConsolidationMaterialize } from "./connectors/codex-materialize-runner.js";
@@ -179,15 +181,16 @@ export function parseConsolidationResponse(response: string): string {
179
181
  * Falls back to the heuristic default when the LLM omits or returns an
180
182
  * unknown value (the parser never surfaces an invalid operator; see
181
183
  * `parseOperatorAwareConsolidationResponse`).
182
- * - `output` — the canonical content (same format the legacy prompt
183
- * returns). Callers persist this as the body of the new memory.
184
+ * - `outputs` — the canonical memory bodies to persist, never empty.
185
+ * MERGE and UPDATE always carry exactly one; SPLIT carries one body per
186
+ * separated fact (#3566).
184
187
  */
185
188
  export interface OperatorAwareConsolidationResult {
186
189
  // Restricted to the LLM-allowed subset (Cursor Bugbot, PR #730):
187
190
  // `pattern-reinforcement` is reserved for the maintenance job and
188
191
  // must never reach this struct from a consolidation LLM response.
189
192
  operator: _SemanticConsolidationLlmOperator;
190
- output: string;
193
+ outputs: string[];
191
194
  }
192
195
 
193
196
  /**
@@ -203,11 +206,9 @@ export interface OperatorAwareConsolidationResult {
203
206
  * - A cluster of size 1 that still reaches consolidation (future path,
204
207
  * e.g. supersession of a single older memory by a newer value) is an
205
208
  * UPDATE.
206
- * - SPLIT is never selected by the heuristic because the current write
207
- * path emits exactly one canonical memory per cluster. The prompt
208
- * reserves SPLIT for future cluster shapes where the LLM decides one
209
- * logical source actually encodes several distinct facts — at which
210
- * point the orchestrator would need to write multiple outputs.
209
+ * - SPLIT is never selected by the heuristic: only the LLM can decide
210
+ * that one logical source encodes several distinct facts. When it
211
+ * does, the coordinator writes one canonical memory per output.
211
212
  */
212
213
  export function chooseConsolidationOperator(
213
214
  cluster: ConsolidationCluster,
@@ -217,14 +218,9 @@ export function chooseConsolidationOperator(
217
218
  }
218
219
 
219
220
  /**
220
- * Build the operator-aware LLM prompt. The LLM is asked to return a
221
- * JSON object `{ "operator": <split|merge|update>, "output": <content> }`.
222
- *
223
- * The prompt is additive: it still asks for a single canonical blob under
224
- * `output`, so the upstream write path does not change. Future expansions
225
- * (SPLIT emitting multiple outputs) are explicitly documented as
226
- * out-of-scope for the parser — `parseOperatorAwareConsolidationResponse`
227
- * collapses any SPLIT response into a single canonical output for now.
221
+ * Build the operator-aware LLM prompt. MERGE and UPDATE return
222
+ * `{ "operator", "output" }`; SPLIT returns `{ "operator": "split",
223
+ * "outputs": [...] }` with one canonical body per separated fact (#3566).
228
224
  */
229
225
  export function buildOperatorAwareConsolidationPrompt(
230
226
  cluster: ConsolidationCluster,
@@ -243,20 +239,26 @@ Pick exactly ONE consolidation operator for this cluster and return a JSON objec
243
239
  Operator vocabulary:
244
240
  - "merge" — multiple distinct source memories overlap and should be collapsed into one canonical memory (most common).
245
241
  - "update" — one source memory carries a stale value that a newer source supersedes within the same logical fact.
246
- - "split" — a single logical source really encodes multiple distinct facts that should be separated (rare; if you pick split, still emit ONE canonical body — the write path will chunk it later).
242
+ - "split" — a single logical source really encodes multiple distinct facts that should be separated (rare). For split, replace "output" with "outputs": an array holding one canonical memory text per separated fact.
247
243
 
248
244
  Output JSON ONLY, no prose before or after. The "operator" key MUST be set to exactly one of the three strings "merge", "update", or "split" — never a pipe-separated placeholder like "merge|update|split". Example shape:
249
245
  {
250
246
  "operator": "merge",
251
247
  "output": "<the canonical memory text>"
252
248
  }
249
+ Split shape:
250
+ {
251
+ "operator": "split",
252
+ "outputs": ["<first fact>", "<second fact>"]
253
+ }
253
254
 
254
- The "output" value must:
255
+ Each canonical memory text must:
255
256
  1. Preserve ALL unique information from every source memory
256
257
  2. Remove redundancy and repetition
257
258
  3. Use clear, concise language
258
259
  4. Match the "${cluster.category}" category and tone
259
260
  5. NOT add information that isn't in the sources
261
+ For split, the outputs together must hold all of the source information, and each output holds one fact.
260
262
 
261
263
  ${memoryTexts}
262
264
 
@@ -283,7 +285,7 @@ export function parseOperatorAwareConsolidationResponse(
283
285
  ): OperatorAwareConsolidationResult {
284
286
  const fallback: OperatorAwareConsolidationResult = {
285
287
  operator: chooseConsolidationOperator(cluster),
286
- output: response.trim(),
288
+ outputs: [response.trim()],
287
289
  };
288
290
 
289
291
  const trimmed = response.trim();
@@ -302,13 +304,10 @@ export function parseOperatorAwareConsolidationResponse(
302
304
  // `Example: {"note":"..."} ... {"operator":"merge",...}`). Walk the
303
305
  // payload tracking nesting + string/escape state and skip past
304
306
  // objects that don't look like our target shape.
305
- const parsed = findLastJsonObjectWithOperator(payload);
306
- if (parsed === undefined) return fallback;
307
- if (typeof parsed !== "object" || parsed === null) return fallback;
308
-
309
- const obj = parsed as Record<string, unknown>;
310
- const rawOperator = typeof obj.operator === "string" ? obj.operator.trim().toLowerCase() : "";
311
- const rawOutput = typeof obj.output === "string" ? obj.output : "";
307
+ const reply = CONSOLIDATION_LLM_REPLY.safeParse(findLastJsonObjectWithOperator(payload));
308
+ if (!reply.success) return fallback;
309
+ const rawOperator = reply.data.operator?.trim().toLowerCase() ?? "";
310
+ const rawOutput = reply.data.output ?? "";
312
311
 
313
312
  // Narrow gate (Cursor Bugbot review on PR #730 head `aa1c2a8`):
314
313
  // accept ONLY the legacy split/merge/update LLM vocabulary here.
@@ -320,10 +319,19 @@ export function parseOperatorAwareConsolidationResponse(
320
319
  ? rawOperator
321
320
  : chooseConsolidationOperator(cluster);
322
321
  const output = rawOutput.trim().length > 0 ? rawOutput.trim() : response.trim();
322
+ const splitOutputs = (reply.data.outputs ?? []).map((entry) => entry.trim()).filter((entry) => entry.length > 0);
323
+ if (operator === "split" && splitOutputs.length > 0) return { operator, outputs: splitOutputs };
323
324
 
324
- return { operator, output };
325
+ return { operator, outputs: [output] };
325
326
  }
326
327
 
328
+ // Fields read from the model's JSON object; a wrong-typed field reads as absent.
329
+ const CONSOLIDATION_LLM_REPLY = z.object({
330
+ operator: z.string().optional().catch(undefined),
331
+ output: z.string().optional().catch(undefined),
332
+ outputs: z.array(z.string()).optional().catch(undefined),
333
+ });
334
+
327
335
  /**
328
336
  * Walk `text`, find all balanced top-level `{ ... }` blocks whose
329
337
  * JSON.parse result is an object with an `operator` key, and return
@@ -0,0 +1,69 @@
1
+ import type { MemoryLink } from "../types.js";
2
+
3
+ // Parse links: block-sequence items of "key: value" fields under the
4
+ // links: key. Field order is free; an item missing targetId, a known
5
+ // linkType, or a 0-1 strength drops alone (issue #3568). Fields must sit
6
+ // at the item's own key column — deeper lines are nested scalar content
7
+ // (e.g. a "note: |" block), not link fields.
8
+ export function parseFrontmatterLinks(
9
+ fmBlock: string,
10
+ parseReason: (raw: string) => string,
11
+ ): MemoryLink[] | undefined {
12
+ const fmLines = fmBlock.split("\n");
13
+ const linksKeyIdx = fmLines.findIndex((l) => l.trimEnd() === "links:");
14
+ if (linksKeyIdx === -1) return undefined;
15
+
16
+ const linksIndent = fmLines[linksKeyIdx].search(/\S/);
17
+ const items: Record<string, string>[] = [];
18
+ let fieldIndent = -1;
19
+ let itemIndent = -1;
20
+ for (let k = linksKeyIdx + 1; k < fmLines.length; k++) {
21
+ const line = fmLines[k];
22
+ const t = line.trim();
23
+ if (!t || t.startsWith("#")) continue;
24
+ const indent = line.search(/\S/);
25
+ if (indent <= linksIndent) break;
26
+ if (t.startsWith("- ")) {
27
+ if (itemIndent === -1) itemIndent = indent;
28
+ if (indent !== itemIndent) continue;
29
+ items.push({});
30
+ const inline = t.slice(2);
31
+ const colon = inline.indexOf(":");
32
+ fieldIndent = colon > 0 ? indent + 2 : -1;
33
+ if (colon > 0) {
34
+ items[items.length - 1][inline.slice(0, colon).trim()] = inline.slice(colon + 1).trim();
35
+ }
36
+ continue;
37
+ }
38
+ if (items.length === 0) continue;
39
+ const colon = t.indexOf(":");
40
+ if (colon <= 0) continue;
41
+ if (fieldIndent === -1) fieldIndent = indent;
42
+ if (indent !== fieldIndent) continue;
43
+ items[items.length - 1][t.slice(0, colon).trim()] = t.slice(colon + 1).trim();
44
+ }
45
+
46
+ const links: MemoryLink[] = [];
47
+ for (const item of items) {
48
+ const strength = item.strength ? Number(item.strength) : NaN;
49
+ if (
50
+ !item.targetId ||
51
+ !["follows", "references", "contradicts", "supports", "related"].includes(item.linkType ?? "") ||
52
+ !Number.isFinite(strength) ||
53
+ strength < 0 ||
54
+ strength > 1
55
+ ) continue;
56
+ links.push({
57
+ targetId: item.targetId,
58
+ // SAFETY: linkType passed the closed literal list in the guard
59
+ // above, so the string narrows to MemoryLink["linkType"].
60
+ linkType: item.linkType as MemoryLink["linkType"],
61
+ strength,
62
+ reason:
63
+ item.reason?.startsWith('"') && item.reason.endsWith('"')
64
+ ? parseReason(item.reason.slice(1, -1))
65
+ : item.reason,
66
+ });
67
+ }
68
+ return links.length > 0 ? links : undefined;
69
+ }
@@ -0,0 +1,153 @@
1
+ import * as assert from "node:assert/strict";
2
+ import test from "node:test";
3
+
4
+ import { parseFrontmatter } from "./storage.js";
5
+
6
+ const BODY = "body text\n";
7
+
8
+ test("links: block items parse regardless of field order (issue #3568)", () => {
9
+ const raw = `---
10
+ links:
11
+ - strength: 0.8
12
+ targetId: mem-a
13
+ linkType: related
14
+ ---
15
+ ${BODY}`;
16
+ const links = parseFrontmatter(raw)?.frontmatter.links;
17
+ assert.deepEqual(links, [
18
+ { targetId: "mem-a", linkType: "related", strength: 0.8, reason: undefined },
19
+ ]);
20
+ });
21
+
22
+ test("links: items round-trip in the serializer's own order", () => {
23
+ const raw = `---
24
+ links:
25
+ - targetId: mem-a
26
+ linkType: related
27
+ strength: 0.8
28
+ reason: "because \\"quoted\\""
29
+ - targetId: mem-b
30
+ linkType: contradicts
31
+ strength: 0.2
32
+ ---
33
+ ${BODY}`;
34
+ const links = parseFrontmatter(raw)?.frontmatter.links;
35
+ assert.equal(links?.length, 2);
36
+ assert.equal(links?.[0]?.reason, 'because "quoted"');
37
+ assert.equal(links?.[1]?.targetId, "mem-b");
38
+ });
39
+
40
+ test("links: a corrupt item drops without losing its siblings", () => {
41
+ const raw = `---
42
+ links:
43
+ - targetId: mem-a
44
+ linkType: related
45
+ strength: 0.8
46
+ - targetId: mem-b
47
+ linkType: related
48
+ - targetId: mem-c
49
+ linkType: bogus-type
50
+ strength: 0.5
51
+ - targetId: mem-d
52
+ linkType: supports
53
+ strength: 1.5
54
+ ---
55
+ ${BODY}`;
56
+ const links = parseFrontmatter(raw)?.frontmatter.links;
57
+ assert.deepEqual(links, [
58
+ { targetId: "mem-a", linkType: "related", strength: 0.8, reason: undefined },
59
+ ]);
60
+ });
61
+
62
+ test("links: a link-shaped string inside another scalar makes no phantom link", () => {
63
+ const raw = `---
64
+ description: "note - targetId: mem-x linkType: related strength: 0.9 inside"
65
+ ---
66
+ ${BODY}`;
67
+ const links = parseFrontmatter(raw)?.frontmatter.links;
68
+ assert.equal(links, undefined);
69
+ });
70
+
71
+ test("links: a standalone comment between items does not truncate the list", () => {
72
+ const raw = `---
73
+ links:
74
+ - targetId: mem-a
75
+ linkType: related
76
+ strength: 0.8
77
+ # next link
78
+ - targetId: mem-b
79
+ linkType: supports
80
+ strength: 0.5
81
+ ---
82
+ ${BODY}`;
83
+ const links = parseFrontmatter(raw)?.frontmatter.links;
84
+ assert.equal(links?.length, 2);
85
+ assert.equal(links?.[1]?.targetId, "mem-b");
86
+ });
87
+
88
+ test("links: block-scalar content inside an item cannot overwrite link fields", () => {
89
+ const raw = `---
90
+ links:
91
+ - targetId: mem-a
92
+ linkType: related
93
+ strength: 0.8
94
+ note: |
95
+ targetId: mem-x
96
+ linkType: contradicts
97
+ strength: 0.9
98
+ ---
99
+ ${BODY}`;
100
+ const links = parseFrontmatter(raw)?.frontmatter.links;
101
+ assert.deepEqual(links, [
102
+ { targetId: "mem-a", linkType: "related", strength: 0.8, reason: undefined },
103
+ ]);
104
+ });
105
+
106
+ test("links: a dash line inside nested scalar content is not a new item", () => {
107
+ const raw = `---
108
+ links:
109
+ - targetId: mem-a
110
+ linkType: related
111
+ strength: 0.8
112
+ note: |
113
+ - targetId: mem-x
114
+ linkType: contradicts
115
+ strength: 0.9
116
+ ---
117
+ ${BODY}`;
118
+ const links = parseFrontmatter(raw)?.frontmatter.links;
119
+ assert.deepEqual(links, [
120
+ { targetId: "mem-a", linkType: "related", strength: 0.8, reason: undefined },
121
+ ]);
122
+ });
123
+
124
+ test("links: an empty strength drops the item, strength 0 stays valid", () => {
125
+ const raw = `---
126
+ links:
127
+ - targetId: mem-a
128
+ linkType: related
129
+ strength:
130
+ - targetId: mem-b
131
+ linkType: supports
132
+ strength: 0
133
+ ---
134
+ ${BODY}`;
135
+ const links = parseFrontmatter(raw)?.frontmatter.links;
136
+ assert.deepEqual(links, [
137
+ { targetId: "mem-b", linkType: "supports", strength: 0, reason: undefined },
138
+ ]);
139
+ });
140
+
141
+ test("links: unknown keys on an item do not drop the link", () => {
142
+ const raw = `---
143
+ links:
144
+ - targetId: mem-a
145
+ linkType: related
146
+ strength: 0.8
147
+ created: 2026-11-21
148
+ ---
149
+ ${BODY}`;
150
+ const links = parseFrontmatter(raw)?.frontmatter.links;
151
+ assert.equal(links?.length, 1);
152
+ assert.equal(links?.[0]?.targetId, "mem-a");
153
+ });
package/src/storage.ts CHANGED
@@ -29,6 +29,7 @@ import { MemoryReadStore, readWindowedMemories, type WindowedMemoryReadOptions,
29
29
  import { runCommittedInvalidation } from "./storage/committed-invalidation.js";
30
30
  import { renderProfileWithLastUpdated, stripOkfProfileFrontmatter, withOkfProfileFrontmatter } from "./storage/profile-header.js";
31
31
  import { appendToProfileSerialized, commitConsolidatedProfileSerialized, type ProfileMutationPorts } from "./storage/profile-mutation.js";
32
+ import { parseFrontmatterLinks } from "./storage/links-frontmatter.js";
32
33
  import { parseQuestionFile as parseQuestionFileText } from "./storage/questions-file.js";
33
34
  import { assertNotOkfReservedBasename, OKF_QUESTION_TYPE, okfTypeForEntityKind, okfTypeForMemory } from "./okf/type-mapping.js";
34
35
  import { appendContextTransformRecords, readContextTransformRecords } from "./storage/context-transform-ledger.js";
@@ -954,24 +955,9 @@ export function parseFrontmatter(raw: string): { frontmatter: MemoryFrontmatter;
954
955
  content,
955
956
  };
956
957
 
957
- // Parse links (YAML array format)
958
- // Note: Simple parsing - for full YAML we'd need a library.
959
- if (fmBlock.includes("links:")) {
960
- const links: MemoryLink[] = [];
961
- const linkMatches = fmBlock.matchAll(
962
- /- targetId: (\S+)\s+linkType: (\S+)\s+strength: ([\d.]+)(?:\s+reason: "((?:\\.|[^"\\])*)")?/g
963
- );
964
- for (const match of linkMatches) {
965
- links.push({
966
- targetId: match[1],
967
- linkType: match[2] as MemoryLink["linkType"],
968
- strength: parseFloat(match[3]),
969
- reason: match[4] ? parseLinkReasonValue(match[4]) : undefined,
970
- });
971
- }
972
- if (links.length > 0) {
973
- result.frontmatter.links = links;
974
- }
958
+ const links = parseFrontmatterLinks(fmBlock, parseLinkReasonValue);
959
+ if (links) {
960
+ result.frontmatter.links = links;
975
961
  }
976
962
 
977
963
  return result;
@@ -123,10 +123,11 @@ function namespaceMemories(namespace: NamespaceName): MemoryFile[] {
123
123
 
124
124
  function serializeFixture(memory: MemoryFile): string {
125
125
  const links = (memory.frontmatter.links ?? [])
126
- .map(
127
- (link) =>
128
- ` - targetId: ${link.targetId} linkType: ${link.linkType} strength: ${link.strength ?? 0.9}`,
129
- )
126
+ .flatMap((link) => [
127
+ ` - targetId: ${link.targetId}`,
128
+ ` linkType: ${link.linkType}`,
129
+ ` strength: ${link.strength ?? 0.9}`,
130
+ ])
130
131
  .join("\n");
131
132
  return [
132
133
  "---",
package/src/types.ts CHANGED
@@ -1884,6 +1884,7 @@ export interface PluginConfig
1884
1884
  cmcBehaviorMinFrequency: number;
1885
1885
  cmcBehaviorMinSessions: number;
1886
1886
  cmcBehaviorConfidenceThreshold: number;
1887
+ /** @deprecated No effect: lifecycle scoring has no causal impact signal (#3667). Parsed so existing configs load. */
1887
1888
  cmcLifecycleCausalImpactWeight: number;
1888
1889
 
1889
1890
  // PEDC (Prediction-Error-Driven Calibration) — model-user alignment