@remnic/core 10.0.168 → 10.0.170

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 (492) hide show
  1. package/dist/access-admin-ops-surface.js +181 -179
  2. package/dist/access-cli.js +181 -179
  3. package/dist/access-cli.js.map +1 -1
  4. package/dist/access-coding-context-resolution.js +11 -11
  5. package/dist/access-extraction-force-flush-preempt.js +181 -179
  6. package/dist/access-extraction-force-flush.js +181 -179
  7. package/dist/access-http-briefing.js +181 -179
  8. package/dist/access-http-query.js +181 -179
  9. package/dist/access-http.js +181 -179
  10. package/dist/access-identity-continuity-surface.js +181 -179
  11. package/dist/access-lcm-surface.js +181 -179
  12. package/dist/access-mcp.js +181 -179
  13. package/dist/access-observe-write-category.js +11 -11
  14. package/dist/access-observe-write-surface.js +181 -179
  15. package/dist/access-offline-manifest.js +9 -9
  16. package/dist/access-operations-batch.js +181 -179
  17. package/dist/access-operations.js +181 -179
  18. package/dist/access-recall-concurrency.js +181 -179
  19. package/dist/access-recall-diagnostics.js +2 -2
  20. package/dist/access-recall-excerpt-attribution.d.ts +19 -0
  21. package/dist/access-recall-excerpt-attribution.d.ts.map +1 -0
  22. package/dist/access-recall-excerpt-attribution.js +8 -0
  23. package/dist/access-recall-response.js +181 -179
  24. package/dist/access-recall-surface.d.ts.map +1 -1
  25. package/dist/access-recall-surface.js +181 -179
  26. package/dist/access-schema.js +10 -10
  27. package/dist/access-service.js +181 -179
  28. package/dist/active-recall.js +30 -29
  29. package/dist/active-recall.js.map +1 -1
  30. package/dist/adapters/index.js +7 -7
  31. package/dist/adapters/registry.js +3 -3
  32. package/dist/{auto-sync-L3M4RKJD.js → auto-sync-ACP5U5A3.js} +3 -3
  33. package/dist/behavior-learner.js +1 -1
  34. package/dist/binary-lifecycle/scanner.d.ts +2 -4
  35. package/dist/binary-lifecycle/scanner.d.ts.map +1 -1
  36. package/dist/briefing.js +19 -19
  37. package/dist/buffer-add-turns-bounded.d.ts +11 -1
  38. package/dist/buffer-add-turns-bounded.d.ts.map +1 -1
  39. package/dist/buffer-add-turns-bounded.js +3 -3
  40. package/dist/buffer-session-cap.d.ts +2 -2
  41. package/dist/buffer-session-cap.d.ts.map +1 -1
  42. package/dist/buffer-session-cap.js +1 -1
  43. package/dist/buffer.d.ts +3 -2
  44. package/dist/buffer.d.ts.map +1 -1
  45. package/dist/buffer.js +13 -13
  46. package/dist/calibration.d.ts +19 -2
  47. package/dist/calibration.d.ts.map +1 -1
  48. package/dist/calibration.js +28 -5
  49. package/dist/calibration.js.map +1 -1
  50. package/dist/{capsule-crypto-GWVG7LGC.js → capsule-crypto-7FJQINUR.js} +2 -2
  51. package/dist/{capsule-merge-VHBRF65A.js → capsule-merge-BADOICNP.js} +2 -2
  52. package/dist/causal-behavior.js +2 -2
  53. package/dist/causal-chain.js +2 -2
  54. package/dist/causal-consolidation.js +23 -23
  55. package/dist/causal-retrieval.js +2 -2
  56. package/dist/causal-trajectory-graph.js +3 -3
  57. package/dist/causal-trajectory.js +1 -1
  58. package/dist/{chunk-OWHERGF2.js → chunk-2NLLXCJG.js} +2 -2
  59. package/dist/{chunk-CKELO7Q6.js → chunk-2OAFPBQB.js} +2 -2
  60. package/dist/{chunk-2DL3OFLD.js → chunk-45GEJRIG.js} +2 -2
  61. package/dist/{chunk-5IZL4DCV.js → chunk-4DF5LMBJ.js} +2 -2
  62. package/dist/{chunk-A5UOREWD.js → chunk-4DLGKTM6.js} +2 -2
  63. package/dist/{chunk-WEFFO2MJ.js → chunk-4E2Z44CV.js} +2 -2
  64. package/dist/{chunk-X67XNZ64.js → chunk-4LVQSHHN.js} +14 -14
  65. package/dist/{chunk-RB7NXZ2E.js → chunk-4X7HQKAG.js} +2 -2
  66. package/dist/{chunk-I74SUMNI.js → chunk-5ACIRCBO.js} +65 -3
  67. package/dist/chunk-5ACIRCBO.js.map +1 -0
  68. package/dist/{chunk-LPUEBFX2.js → chunk-5JCYPBY5.js} +2 -2
  69. package/dist/{chunk-IMULTENA.js → chunk-5SOSQTVE.js} +2 -2
  70. package/dist/{chunk-D6BOOYNJ.js → chunk-5YIOUS5T.js} +384 -345
  71. package/dist/chunk-5YIOUS5T.js.map +1 -0
  72. package/dist/{chunk-5PUZV73Z.js → chunk-6VFMEBXY.js} +12 -12
  73. package/dist/{chunk-333SBFXB.js → chunk-7AAMJQFW.js} +2 -2
  74. package/dist/{chunk-BKTCVXMK.js → chunk-7SNEJNA3.js} +96 -23
  75. package/dist/chunk-7SNEJNA3.js.map +1 -0
  76. package/dist/{chunk-PFLN6TTW.js → chunk-A2XFG462.js} +2 -2
  77. package/dist/{chunk-WEHSQBFR.js → chunk-AIF6V2OX.js} +9 -4
  78. package/dist/chunk-AIF6V2OX.js.map +1 -0
  79. package/dist/{chunk-HXFIILGF.js → chunk-BFPF5N3H.js} +4 -4
  80. package/dist/{chunk-QFTK6EDM.js → chunk-BFZFNXOC.js} +13 -13
  81. package/dist/{chunk-7OCKK5M5.js → chunk-BJOQQCYC.js} +9 -9
  82. package/dist/{chunk-ZX546Y3Y.js → chunk-CY2C5LM4.js} +3 -3
  83. package/dist/{chunk-73TPOGS4.js → chunk-DC55RIEZ.js} +9 -9
  84. package/dist/{chunk-ZDZJNXL6.js → chunk-DK2VBJ6Q.js} +4 -4
  85. package/dist/{chunk-CLVILSBR.js → chunk-DNXQVCIC.js} +22 -22
  86. package/dist/{chunk-7VIJUZYW.js → chunk-E53NLIAP.js} +3 -3
  87. package/dist/{chunk-2LA3H54D.js → chunk-E5IZTY4W.js} +2 -2
  88. package/dist/{chunk-J74YOBB3.js → chunk-EBI6FI5U.js} +12 -12
  89. package/dist/{chunk-YYXYZM2I.js → chunk-ETTV5F53.js} +2 -2
  90. package/dist/{chunk-FRYCXXTB.js → chunk-FSORYJRP.js} +3 -3
  91. package/dist/{chunk-TH6OYP6I.js → chunk-GOZXQNIM.js} +3 -3
  92. package/dist/{chunk-TNRGWJYT.js → chunk-GUF2JKG5.js} +2 -2
  93. package/dist/{chunk-AL3TCNSJ.js → chunk-H3MLOQ7F.js} +24 -53
  94. package/dist/chunk-H3MLOQ7F.js.map +1 -0
  95. package/dist/{chunk-SIONKXLU.js → chunk-H6TCS5XX.js} +18 -15
  96. package/dist/chunk-H6TCS5XX.js.map +1 -0
  97. package/dist/{chunk-FEUWI5QH.js → chunk-HHPY5SSE.js} +2 -2
  98. package/dist/{chunk-QPFM6DHY.js → chunk-HHVK2JRE.js} +2 -2
  99. package/dist/{chunk-YY57TRKN.js → chunk-HR3DKJCU.js} +2 -2
  100. package/dist/{chunk-FMFCQRDM.js → chunk-IJKO5RVJ.js} +3 -3
  101. package/dist/{chunk-UMEUU66X.js → chunk-IK7NPYYU.js} +2 -2
  102. package/dist/{chunk-ILNPU5W5.js → chunk-IMA4DJ7K.js} +5 -45
  103. package/dist/chunk-IMA4DJ7K.js.map +1 -0
  104. package/dist/chunk-IUGOGDCP.js +39 -0
  105. package/dist/chunk-IUGOGDCP.js.map +1 -0
  106. package/dist/{chunk-CKZWLAHN.js → chunk-JDH2BA2P.js} +2 -2
  107. package/dist/{chunk-QVXEXGIM.js → chunk-JNBSTHVT.js} +2 -2
  108. package/dist/chunk-JVVWCZ2P.js +18 -0
  109. package/dist/chunk-JVVWCZ2P.js.map +1 -0
  110. package/dist/{chunk-OBPOIZNR.js → chunk-KBHUGMUW.js} +2 -2
  111. package/dist/{chunk-OZKVVUJB.js → chunk-KIM5VNZN.js} +2 -2
  112. package/dist/{chunk-ZWDDY4WF.js → chunk-KW4XA7GM.js} +3 -3
  113. package/dist/{chunk-OAQRZ4SV.js → chunk-L5EE2CXU.js} +2 -2
  114. package/dist/{chunk-QNUNAXBE.js → chunk-L7LZDISF.js} +1 -9
  115. package/dist/{chunk-QNUNAXBE.js.map → chunk-L7LZDISF.js.map} +1 -1
  116. package/dist/{chunk-RO5EGRAI.js → chunk-LAOJHOTG.js} +2 -2
  117. package/dist/{chunk-FOTFLHBN.js → chunk-LH57QATU.js} +3 -2
  118. package/dist/chunk-LH57QATU.js.map +1 -0
  119. package/dist/{chunk-BFPQJNFZ.js → chunk-LXSDEPEK.js} +60 -11
  120. package/dist/{chunk-BFPQJNFZ.js.map → chunk-LXSDEPEK.js.map} +1 -1
  121. package/dist/{chunk-3PNJZTDV.js → chunk-NDPS6OU2.js} +2 -2
  122. package/dist/{chunk-N7AIFTSH.js → chunk-NJG63FY2.js} +1 -1
  123. package/dist/{chunk-N7AIFTSH.js.map → chunk-NJG63FY2.js.map} +1 -1
  124. package/dist/{chunk-BUKK5SWA.js → chunk-NKAGGDSL.js} +3 -3
  125. package/dist/{chunk-BUKK5SWA.js.map → chunk-NKAGGDSL.js.map} +1 -1
  126. package/dist/{chunk-U3BCW7GX.js → chunk-OGQL7QC7.js} +3 -3
  127. package/dist/{chunk-K3FH3LAQ.js → chunk-OJXK5C6Z.js} +4 -4
  128. package/dist/{chunk-HDLNSDLK.js → chunk-P3XO7HE3.js} +2 -2
  129. package/dist/{chunk-RFLC6PKQ.js → chunk-PQIFYBUX.js} +2 -2
  130. package/dist/{chunk-WLT6LTQP.js → chunk-PRRWKTK6.js} +2 -2
  131. package/dist/{chunk-LWZNSQN3.js → chunk-PUQQPLVV.js} +3 -3
  132. package/dist/{chunk-LWZNSQN3.js.map → chunk-PUQQPLVV.js.map} +1 -1
  133. package/dist/{chunk-4L25GAYL.js → chunk-Q7OKGBZY.js} +2 -2
  134. package/dist/{chunk-ZQUOUPP3.js → chunk-QJBULLKG.js} +4 -4
  135. package/dist/{chunk-W7N7NWG5.js → chunk-QKAFFVSO.js} +2 -2
  136. package/dist/{chunk-EZG54YDS.js → chunk-QKBFVLDH.js} +2 -2
  137. package/dist/{chunk-MOUSHJAR.js → chunk-QMFHKWHN.js} +5 -5
  138. package/dist/{chunk-QLQUAVVP.js → chunk-QRCE77YX.js} +16 -16
  139. package/dist/chunk-QRCE77YX.js.map +1 -0
  140. package/dist/{chunk-4D2EY4WM.js → chunk-R2AJAAHJ.js} +6 -6
  141. package/dist/{chunk-5BE3FLKL.js → chunk-R3UQIS3F.js} +8 -8
  142. package/dist/{chunk-B3M56D2A.js → chunk-RDHEBINJ.js} +2 -2
  143. package/dist/{chunk-L7SEYUHS.js → chunk-RHQL2RIM.js} +3 -3
  144. package/dist/{chunk-2MWKUVHT.js → chunk-RK7SE3BL.js} +5 -5
  145. package/dist/{chunk-CUPILBIP.js → chunk-SA2YALFU.js} +2 -2
  146. package/dist/{chunk-VRHY7Y5A.js → chunk-SAPC7N43.js} +3 -3
  147. package/dist/{chunk-6QWFZ3X5.js → chunk-SOQOUZ2Y.js} +2 -2
  148. package/dist/{chunk-VHXRLD6S.js → chunk-T2JZF45K.js} +2 -2
  149. package/dist/{chunk-HLWXCDUQ.js → chunk-T4MKFTJF.js} +5 -5
  150. package/dist/{chunk-WQUGCOKF.js → chunk-TFA6HPOA.js} +4 -4
  151. package/dist/{chunk-YZYAYUJQ.js → chunk-TLRIRISJ.js} +4 -4
  152. package/dist/{chunk-LVGTH6IQ.js → chunk-UFX24WNJ.js} +14 -14
  153. package/dist/{chunk-OM5ESBES.js → chunk-UH3FPX3L.js} +2 -2
  154. package/dist/{chunk-4NBUHYUV.js → chunk-V5W67PQV.js} +3 -3
  155. package/dist/{chunk-TAD6QMMD.js → chunk-VAQIBC2L.js} +2 -2
  156. package/dist/{chunk-3Q3XD3NO.js → chunk-W2E2WFXL.js} +3 -3
  157. package/dist/{chunk-UYIBNDQE.js → chunk-W2UV6VE3.js} +2 -2
  158. package/dist/{chunk-AVWOULJH.js → chunk-W35ICLYZ.js} +2 -2
  159. package/dist/{chunk-HDDRVXX4.js → chunk-W5LJ3SJ7.js} +2 -2
  160. package/dist/{chunk-FGT7CUYZ.js → chunk-WF2LYKOB.js} +2 -2
  161. package/dist/{chunk-JIF22AXI.js → chunk-WGKIXNLY.js} +5 -2
  162. package/dist/{chunk-JIF22AXI.js.map → chunk-WGKIXNLY.js.map} +1 -1
  163. package/dist/{chunk-FFWFFAP3.js → chunk-WI2WTIMY.js} +14 -8
  164. package/dist/chunk-WI2WTIMY.js.map +1 -0
  165. package/dist/{chunk-OWM2VWNX.js → chunk-X5MFCZDL.js} +82 -44
  166. package/dist/chunk-X5MFCZDL.js.map +1 -0
  167. package/dist/{chunk-UVYI6VIX.js → chunk-X7Y7WX73.js} +1 -1
  168. package/dist/{chunk-22V3CMIW.js → chunk-XJTRIHTH.js} +8 -8
  169. package/dist/{chunk-3SL52JKD.js → chunk-XVZA6VXC.js} +4 -4
  170. package/dist/{chunk-WWQMZBDI.js → chunk-XYNUEXLC.js} +7 -7
  171. package/dist/{chunk-HDWISXFH.js → chunk-Y65XX5PC.js} +2 -2
  172. package/dist/{chunk-3YOX2BQD.js → chunk-YE77U5HZ.js} +3 -3
  173. package/dist/{chunk-U2PSE7MB.js → chunk-YLTU2DC4.js} +2 -2
  174. package/dist/{chunk-BPCR5DZP.js → chunk-YRD525ZO.js} +6 -6
  175. package/dist/chunk-YRD525ZO.js.map +1 -0
  176. package/dist/{chunk-SBRUTD5O.js → chunk-YSATDEBY.js} +5 -5
  177. package/dist/{chunk-TBBDFYXW.js → chunk-YVUNHNB6.js} +2 -3
  178. package/dist/chunk-YVUNHNB6.js.map +1 -0
  179. package/dist/{chunk-GBSXTTLP.js → chunk-YY5UXARJ.js} +24 -12
  180. package/dist/chunk-YY5UXARJ.js.map +1 -0
  181. package/dist/{chunk-L272A5QW.js → chunk-YYDUBGUF.js} +30 -22
  182. package/dist/chunk-YYDUBGUF.js.map +1 -0
  183. package/dist/{chunk-5QDTZIGH.js → chunk-ZJ3CEAJD.js} +2 -2
  184. package/dist/{chunk-GMO3BGOF.js → chunk-ZOJUWVAU.js} +1 -1
  185. package/dist/{chunk-T4BT4FQN.js → chunk-ZYP4YEEI.js} +3 -3
  186. package/dist/cli.js +181 -179
  187. package/dist/coding/export-okf-codegraph.js +30 -30
  188. package/dist/coding/pre-action-gate.js +2 -2
  189. package/dist/compounding/engine.js +20 -20
  190. package/dist/config-deprecations.d.ts +3 -0
  191. package/dist/config-deprecations.d.ts.map +1 -0
  192. package/dist/config-deprecations.js +9 -0
  193. package/dist/config.d.ts.map +1 -1
  194. package/dist/config.js +30 -29
  195. package/dist/connectors/codex-marketplace.d.ts.map +1 -1
  196. package/dist/connectors/codex-materialize-runner.js +20 -20
  197. package/dist/connectors/codex-materialize.d.ts.map +1 -1
  198. package/dist/connectors/codex-materialize.js +1 -1
  199. package/dist/connectors/index.js +21 -21
  200. package/dist/consolidation-provenance-check.js +2 -2
  201. package/dist/convergence-refresh.js +22 -22
  202. package/dist/conversation-index/backend.js +2 -2
  203. package/dist/corpus-watermark.js +21 -21
  204. package/dist/deep-recall-http-glue.js +11 -11
  205. package/dist/deep-recall.js +2 -2
  206. package/dist/embedding-fallback.js +2 -2
  207. package/dist/entity-retrieval.js +21 -21
  208. package/dist/event-order-recall.js +3 -3
  209. package/dist/explicit-capture.js +181 -179
  210. package/dist/extraction-judge.js +1 -1
  211. package/dist/extraction-normalization.js +1 -1
  212. package/dist/extraction-span-materialize.js +2 -2
  213. package/dist/extraction.js +35 -35
  214. package/dist/{first-start-migration-BPVJ4HJQ.js → first-start-migration-PPPP54X6.js} +5 -5
  215. package/dist/{graph-edge-decay-BC3IO2J4.js → graph-edge-decay-EKWXRBWF.js} +6 -6
  216. package/dist/graph-edge-decay-EKWXRBWF.js.map +1 -0
  217. package/dist/graph-jsonl.js +4 -4
  218. package/dist/graph-snapshot.js +4 -4
  219. package/dist/graph.js +5 -5
  220. package/dist/harmonic-retrieval.js +19 -19
  221. package/dist/index.js +272 -269
  222. package/dist/lcm/engine.js +2 -2
  223. package/dist/lcm/index.js +7 -7
  224. package/dist/lifecycle.d.ts +0 -6
  225. package/dist/lifecycle.d.ts.map +1 -1
  226. package/dist/lifecycle.js +1 -1
  227. package/dist/local-llm.js +2 -2
  228. package/dist/location/index.js +31 -21
  229. package/dist/location/provider-setup.d.ts +26 -1
  230. package/dist/location/provider-setup.d.ts.map +1 -1
  231. package/dist/maintenance/memory-governance.js +20 -20
  232. package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +19 -19
  233. package/dist/maintenance/rebuild-memory-projection-runner.js +22 -22
  234. package/dist/maintenance/rebuild-memory-projection.js +21 -21
  235. package/dist/memory-browse.js +6 -6
  236. package/dist/memory-controller.d.ts.map +1 -1
  237. package/dist/memory-controller.js +1 -1
  238. package/dist/{migrate-from-identity-anchor-MJYB6NNN.js → migrate-from-identity-anchor-TZSZXJ6L.js} +2 -2
  239. package/dist/migrate-from-identity-anchor-TZSZXJ6L.js.map +1 -0
  240. package/dist/model-registry.d.ts +0 -5
  241. package/dist/model-registry.d.ts.map +1 -1
  242. package/dist/model-registry.js +1 -1
  243. package/dist/namespaces/migrate.js +20 -20
  244. package/dist/namespaces/search.js +9 -9
  245. package/dist/namespaces/storage.d.ts.map +1 -1
  246. package/dist/namespaces/storage.js +19 -19
  247. package/dist/offline-sync-changeset-generations.js +4 -4
  248. package/dist/offline-sync-embedding-generation.js +3 -3
  249. package/dist/offline-sync-snapshot-stream.js +7 -7
  250. package/dist/offline-sync.js +6 -6
  251. package/dist/operator-doctor-corpus.js +22 -22
  252. package/dist/operator-toolkit.js +42 -41
  253. package/dist/orchestration/backlog-scheduler.d.ts +4 -0
  254. package/dist/orchestration/backlog-scheduler.d.ts.map +1 -1
  255. package/dist/orchestration/backlog-scheduler.js +192 -184
  256. package/dist/orchestration/backlog-scheduler.js.map +1 -1
  257. package/dist/orchestration/buffer-drain-runner.js +182 -180
  258. package/dist/orchestration/extraction-persist-citation.d.ts +2 -2
  259. package/dist/orchestration/extraction-persist-citation.d.ts.map +1 -1
  260. package/dist/orchestration/extraction-persist.d.ts.map +1 -1
  261. package/dist/orchestration/maintenance.js +30 -30
  262. package/dist/orchestration/recall-internal.d.ts.map +1 -1
  263. package/dist/orchestration/semantic-consolidation-coordinator.d.ts.map +1 -1
  264. package/dist/orchestration/turn-ingestion-buffered.d.ts.map +1 -1
  265. package/dist/orchestration/workspace-ops.d.ts.map +1 -1
  266. package/dist/orchestrator.d.ts.map +1 -1
  267. package/dist/orchestrator.js +183 -181
  268. package/dist/peers/index.d.ts +2 -1
  269. package/dist/peers/index.d.ts.map +1 -1
  270. package/dist/peers/index.js +3 -3
  271. package/dist/peers/interaction-log-append.d.ts +8 -0
  272. package/dist/peers/interaction-log-append.d.ts.map +1 -0
  273. package/dist/peers/storage.d.ts +22 -8
  274. package/dist/peers/storage.d.ts.map +1 -1
  275. package/dist/policy-runtime.js +2 -2
  276. package/dist/qmd.js +4 -4
  277. package/dist/recall-explain-renderer.js +3 -3
  278. package/dist/recall-navigate-access.js +2 -2
  279. package/dist/recall-navigate-disclosure.js +2 -2
  280. package/dist/recall-navigate.js +2 -2
  281. package/dist/recall-navigation.js +181 -179
  282. package/dist/recall-state-view-admission.js +6 -6
  283. package/dist/recall-state-view-packet.d.ts.map +1 -1
  284. package/dist/recall-state-view-packet.js +30 -8
  285. package/dist/recall-state-view-packet.js.map +1 -1
  286. package/dist/recall-why-service.js +6 -6
  287. package/dist/recall-xray-cli.js +4 -4
  288. package/dist/recall-xray-renderer.js +3 -3
  289. package/dist/recall-xray.js +2 -2
  290. package/dist/reconcile/manifest.js +2 -2
  291. package/dist/resume-bundles.js +31 -30
  292. package/dist/retrieval.js +2 -2
  293. package/dist/search/factory.js +8 -8
  294. package/dist/search/index.js +14 -14
  295. package/dist/semantic-consolidation.d.ts +10 -16
  296. package/dist/semantic-consolidation.d.ts.map +1 -1
  297. package/dist/semantic-consolidation.js +24 -24
  298. package/dist/semantic-rule-promotion.js +19 -19
  299. package/dist/semantic-rule-verifier.js +19 -19
  300. package/dist/source-agent-qualifier.js +25 -25
  301. package/dist/source-attribution.d.ts +3 -3
  302. package/dist/source-attribution.d.ts.map +1 -1
  303. package/dist/source-attribution.js +1 -1
  304. package/dist/standup/build.js +19 -19
  305. package/dist/storage/links-frontmatter.d.ts +3 -0
  306. package/dist/storage/links-frontmatter.d.ts.map +1 -0
  307. package/dist/storage.d.ts +1 -0
  308. package/dist/storage.d.ts.map +1 -1
  309. package/dist/storage.js +18 -18
  310. package/dist/summarizer.d.ts +7 -1
  311. package/dist/summarizer.d.ts.map +1 -1
  312. package/dist/summarizer.js +4 -4
  313. package/dist/support-passport/index.js +16 -16
  314. package/dist/tier-routing.js +2 -2
  315. package/dist/{tier-stats-FLFKN7Y6.js → tier-stats-XWJSVEHC.js} +5 -5
  316. package/dist/transfer/autodetect.js +3 -3
  317. package/dist/transfer/backup.js +2 -2
  318. package/dist/transfer/capsule-export.js +3 -3
  319. package/dist/transfer/capsule-import.js +3 -3
  320. package/dist/transfer/export-okf.js +19 -19
  321. package/dist/transfer/import-json.js +2 -2
  322. package/dist/transfer/import-md.js +2 -2
  323. package/dist/transfer/types.d.ts +15 -3
  324. package/dist/transfer/types.d.ts.map +1 -1
  325. package/dist/transfer/types.js +3 -1
  326. package/dist/types.d.ts +1 -0
  327. package/dist/types.d.ts.map +1 -1
  328. package/dist/types.js +1 -1
  329. package/dist/utility-learner.js +2 -2
  330. package/dist/utility-runtime.js +3 -3
  331. package/dist/verified-recall.js +19 -19
  332. package/dist/who-knows-cli.js +20 -20
  333. package/dist/who-knows.js +19 -19
  334. package/package.json +2 -2
  335. package/src/access-cli.test.ts +9 -9
  336. package/src/access-recall-excerpt-attribution.ts +69 -0
  337. package/src/access-recall-surface.ts +23 -23
  338. package/src/access-service-raw-excerpt-read-gate.test.ts +192 -11
  339. package/src/backlog-scheduler.test.ts +31 -0
  340. package/src/binary-lifecycle/scanner.ts +35 -14
  341. package/src/buffer-add-turns-bounded.ts +16 -2
  342. package/src/buffer-session-cap.ts +4 -4
  343. package/src/buffer.ts +5 -5
  344. package/src/calibration.ts +56 -4
  345. package/src/config-deprecations.ts +14 -0
  346. package/src/config.ts +2 -1
  347. package/src/connectors/codex-marketplace-git.test.ts +267 -0
  348. package/src/connectors/codex-marketplace.ts +76 -13
  349. package/src/connectors/codex-materialize.ts +29 -55
  350. package/src/lifecycle.ts +0 -8
  351. package/src/location/provider-setup.test.ts +273 -2
  352. package/src/location/provider-setup.ts +138 -32
  353. package/src/memory-controller.test.ts +11 -0
  354. package/src/memory-controller.ts +5 -1
  355. package/src/model-registry.ts +0 -11
  356. package/src/namespaces/storage.ts +1 -0
  357. package/src/orchestration/backlog-scheduler.ts +12 -3
  358. package/src/orchestration/extraction-persist-citation.ts +5 -3
  359. package/src/orchestration/extraction-persist.ts +15 -14
  360. package/src/orchestration/recall-internal.ts +2 -3
  361. package/src/orchestration/semantic-consolidation-coordinator.ts +40 -33
  362. package/src/orchestration/semantic-consolidation-split.test.ts +72 -0
  363. package/src/orchestration/turn-ingestion-buffered.test.ts +52 -1
  364. package/src/orchestration/turn-ingestion-buffered.ts +26 -8
  365. package/src/orchestration/workspace-ops.test.ts +23 -0
  366. package/src/orchestration/workspace-ops.ts +6 -5
  367. package/src/orchestrator.ts +1 -0
  368. package/src/peers/index.ts +1 -1
  369. package/src/peers/interaction-log-append.ts +132 -0
  370. package/src/peers/peers.test.ts +30 -0
  371. package/src/peers/profile-reasoner.ts +1 -1
  372. package/src/peers/storage.ts +4 -105
  373. package/src/recall-state-view-packet.test.ts +40 -0
  374. package/src/recall-state-view-packet.ts +46 -9
  375. package/src/semantic-consolidation.ts +35 -27
  376. package/src/source-attribution.test.ts +57 -0
  377. package/src/source-attribution.ts +46 -43
  378. package/src/storage/links-frontmatter.ts +69 -0
  379. package/src/storage-links-parse.test.ts +153 -0
  380. package/src/storage.ts +8 -21
  381. package/src/summarizer-shutdown.test.ts +49 -16
  382. package/src/summarizer.ts +13 -5
  383. package/src/testing/subjects/dependency-propagation.test.ts +5 -4
  384. package/src/testing/subjects/memory-maintenance.test.ts +293 -0
  385. package/src/transfer/capsule-export.ts +2 -1
  386. package/src/transfer/capsule-taxonomy-version.test.ts +70 -0
  387. package/src/transfer/types.ts +13 -3
  388. package/src/types.ts +1 -0
  389. package/dist/chunk-AL3TCNSJ.js.map +0 -1
  390. package/dist/chunk-BKTCVXMK.js.map +0 -1
  391. package/dist/chunk-BPCR5DZP.js.map +0 -1
  392. package/dist/chunk-D6BOOYNJ.js.map +0 -1
  393. package/dist/chunk-FFWFFAP3.js.map +0 -1
  394. package/dist/chunk-FOTFLHBN.js.map +0 -1
  395. package/dist/chunk-GBSXTTLP.js.map +0 -1
  396. package/dist/chunk-I74SUMNI.js.map +0 -1
  397. package/dist/chunk-ILNPU5W5.js.map +0 -1
  398. package/dist/chunk-L272A5QW.js.map +0 -1
  399. package/dist/chunk-OWM2VWNX.js.map +0 -1
  400. package/dist/chunk-QLQUAVVP.js.map +0 -1
  401. package/dist/chunk-SIONKXLU.js.map +0 -1
  402. package/dist/chunk-TBBDFYXW.js.map +0 -1
  403. package/dist/chunk-WEHSQBFR.js.map +0 -1
  404. /package/dist/{capsule-crypto-GWVG7LGC.js.map → access-recall-excerpt-attribution.js.map} +0 -0
  405. /package/dist/{auto-sync-L3M4RKJD.js.map → auto-sync-ACP5U5A3.js.map} +0 -0
  406. /package/dist/{graph-edge-decay-BC3IO2J4.js.map → capsule-crypto-7FJQINUR.js.map} +0 -0
  407. /package/dist/{capsule-merge-VHBRF65A.js.map → capsule-merge-BADOICNP.js.map} +0 -0
  408. /package/dist/{chunk-OWHERGF2.js.map → chunk-2NLLXCJG.js.map} +0 -0
  409. /package/dist/{chunk-CKELO7Q6.js.map → chunk-2OAFPBQB.js.map} +0 -0
  410. /package/dist/{chunk-2DL3OFLD.js.map → chunk-45GEJRIG.js.map} +0 -0
  411. /package/dist/{chunk-5IZL4DCV.js.map → chunk-4DF5LMBJ.js.map} +0 -0
  412. /package/dist/{chunk-A5UOREWD.js.map → chunk-4DLGKTM6.js.map} +0 -0
  413. /package/dist/{chunk-WEFFO2MJ.js.map → chunk-4E2Z44CV.js.map} +0 -0
  414. /package/dist/{chunk-X67XNZ64.js.map → chunk-4LVQSHHN.js.map} +0 -0
  415. /package/dist/{chunk-RB7NXZ2E.js.map → chunk-4X7HQKAG.js.map} +0 -0
  416. /package/dist/{chunk-LPUEBFX2.js.map → chunk-5JCYPBY5.js.map} +0 -0
  417. /package/dist/{chunk-IMULTENA.js.map → chunk-5SOSQTVE.js.map} +0 -0
  418. /package/dist/{chunk-5PUZV73Z.js.map → chunk-6VFMEBXY.js.map} +0 -0
  419. /package/dist/{chunk-333SBFXB.js.map → chunk-7AAMJQFW.js.map} +0 -0
  420. /package/dist/{chunk-PFLN6TTW.js.map → chunk-A2XFG462.js.map} +0 -0
  421. /package/dist/{chunk-HXFIILGF.js.map → chunk-BFPF5N3H.js.map} +0 -0
  422. /package/dist/{chunk-QFTK6EDM.js.map → chunk-BFZFNXOC.js.map} +0 -0
  423. /package/dist/{chunk-7OCKK5M5.js.map → chunk-BJOQQCYC.js.map} +0 -0
  424. /package/dist/{chunk-ZX546Y3Y.js.map → chunk-CY2C5LM4.js.map} +0 -0
  425. /package/dist/{chunk-73TPOGS4.js.map → chunk-DC55RIEZ.js.map} +0 -0
  426. /package/dist/{chunk-ZDZJNXL6.js.map → chunk-DK2VBJ6Q.js.map} +0 -0
  427. /package/dist/{chunk-CLVILSBR.js.map → chunk-DNXQVCIC.js.map} +0 -0
  428. /package/dist/{chunk-7VIJUZYW.js.map → chunk-E53NLIAP.js.map} +0 -0
  429. /package/dist/{chunk-2LA3H54D.js.map → chunk-E5IZTY4W.js.map} +0 -0
  430. /package/dist/{chunk-J74YOBB3.js.map → chunk-EBI6FI5U.js.map} +0 -0
  431. /package/dist/{chunk-YYXYZM2I.js.map → chunk-ETTV5F53.js.map} +0 -0
  432. /package/dist/{chunk-FRYCXXTB.js.map → chunk-FSORYJRP.js.map} +0 -0
  433. /package/dist/{chunk-TH6OYP6I.js.map → chunk-GOZXQNIM.js.map} +0 -0
  434. /package/dist/{chunk-TNRGWJYT.js.map → chunk-GUF2JKG5.js.map} +0 -0
  435. /package/dist/{chunk-FEUWI5QH.js.map → chunk-HHPY5SSE.js.map} +0 -0
  436. /package/dist/{chunk-QPFM6DHY.js.map → chunk-HHVK2JRE.js.map} +0 -0
  437. /package/dist/{chunk-YY57TRKN.js.map → chunk-HR3DKJCU.js.map} +0 -0
  438. /package/dist/{chunk-FMFCQRDM.js.map → chunk-IJKO5RVJ.js.map} +0 -0
  439. /package/dist/{chunk-UMEUU66X.js.map → chunk-IK7NPYYU.js.map} +0 -0
  440. /package/dist/{chunk-CKZWLAHN.js.map → chunk-JDH2BA2P.js.map} +0 -0
  441. /package/dist/{chunk-QVXEXGIM.js.map → chunk-JNBSTHVT.js.map} +0 -0
  442. /package/dist/{chunk-OBPOIZNR.js.map → chunk-KBHUGMUW.js.map} +0 -0
  443. /package/dist/{chunk-OZKVVUJB.js.map → chunk-KIM5VNZN.js.map} +0 -0
  444. /package/dist/{chunk-ZWDDY4WF.js.map → chunk-KW4XA7GM.js.map} +0 -0
  445. /package/dist/{chunk-OAQRZ4SV.js.map → chunk-L5EE2CXU.js.map} +0 -0
  446. /package/dist/{chunk-RO5EGRAI.js.map → chunk-LAOJHOTG.js.map} +0 -0
  447. /package/dist/{chunk-3PNJZTDV.js.map → chunk-NDPS6OU2.js.map} +0 -0
  448. /package/dist/{chunk-U3BCW7GX.js.map → chunk-OGQL7QC7.js.map} +0 -0
  449. /package/dist/{chunk-K3FH3LAQ.js.map → chunk-OJXK5C6Z.js.map} +0 -0
  450. /package/dist/{chunk-HDLNSDLK.js.map → chunk-P3XO7HE3.js.map} +0 -0
  451. /package/dist/{chunk-RFLC6PKQ.js.map → chunk-PQIFYBUX.js.map} +0 -0
  452. /package/dist/{chunk-WLT6LTQP.js.map → chunk-PRRWKTK6.js.map} +0 -0
  453. /package/dist/{chunk-4L25GAYL.js.map → chunk-Q7OKGBZY.js.map} +0 -0
  454. /package/dist/{chunk-ZQUOUPP3.js.map → chunk-QJBULLKG.js.map} +0 -0
  455. /package/dist/{chunk-W7N7NWG5.js.map → chunk-QKAFFVSO.js.map} +0 -0
  456. /package/dist/{chunk-EZG54YDS.js.map → chunk-QKBFVLDH.js.map} +0 -0
  457. /package/dist/{chunk-MOUSHJAR.js.map → chunk-QMFHKWHN.js.map} +0 -0
  458. /package/dist/{chunk-4D2EY4WM.js.map → chunk-R2AJAAHJ.js.map} +0 -0
  459. /package/dist/{chunk-5BE3FLKL.js.map → chunk-R3UQIS3F.js.map} +0 -0
  460. /package/dist/{chunk-B3M56D2A.js.map → chunk-RDHEBINJ.js.map} +0 -0
  461. /package/dist/{chunk-L7SEYUHS.js.map → chunk-RHQL2RIM.js.map} +0 -0
  462. /package/dist/{chunk-2MWKUVHT.js.map → chunk-RK7SE3BL.js.map} +0 -0
  463. /package/dist/{chunk-CUPILBIP.js.map → chunk-SA2YALFU.js.map} +0 -0
  464. /package/dist/{chunk-VRHY7Y5A.js.map → chunk-SAPC7N43.js.map} +0 -0
  465. /package/dist/{chunk-6QWFZ3X5.js.map → chunk-SOQOUZ2Y.js.map} +0 -0
  466. /package/dist/{chunk-VHXRLD6S.js.map → chunk-T2JZF45K.js.map} +0 -0
  467. /package/dist/{chunk-HLWXCDUQ.js.map → chunk-T4MKFTJF.js.map} +0 -0
  468. /package/dist/{chunk-WQUGCOKF.js.map → chunk-TFA6HPOA.js.map} +0 -0
  469. /package/dist/{chunk-YZYAYUJQ.js.map → chunk-TLRIRISJ.js.map} +0 -0
  470. /package/dist/{chunk-LVGTH6IQ.js.map → chunk-UFX24WNJ.js.map} +0 -0
  471. /package/dist/{chunk-OM5ESBES.js.map → chunk-UH3FPX3L.js.map} +0 -0
  472. /package/dist/{chunk-4NBUHYUV.js.map → chunk-V5W67PQV.js.map} +0 -0
  473. /package/dist/{chunk-TAD6QMMD.js.map → chunk-VAQIBC2L.js.map} +0 -0
  474. /package/dist/{chunk-3Q3XD3NO.js.map → chunk-W2E2WFXL.js.map} +0 -0
  475. /package/dist/{chunk-UYIBNDQE.js.map → chunk-W2UV6VE3.js.map} +0 -0
  476. /package/dist/{chunk-AVWOULJH.js.map → chunk-W35ICLYZ.js.map} +0 -0
  477. /package/dist/{chunk-HDDRVXX4.js.map → chunk-W5LJ3SJ7.js.map} +0 -0
  478. /package/dist/{chunk-FGT7CUYZ.js.map → chunk-WF2LYKOB.js.map} +0 -0
  479. /package/dist/{chunk-UVYI6VIX.js.map → chunk-X7Y7WX73.js.map} +0 -0
  480. /package/dist/{chunk-22V3CMIW.js.map → chunk-XJTRIHTH.js.map} +0 -0
  481. /package/dist/{chunk-3SL52JKD.js.map → chunk-XVZA6VXC.js.map} +0 -0
  482. /package/dist/{chunk-WWQMZBDI.js.map → chunk-XYNUEXLC.js.map} +0 -0
  483. /package/dist/{chunk-HDWISXFH.js.map → chunk-Y65XX5PC.js.map} +0 -0
  484. /package/dist/{chunk-3YOX2BQD.js.map → chunk-YE77U5HZ.js.map} +0 -0
  485. /package/dist/{chunk-U2PSE7MB.js.map → chunk-YLTU2DC4.js.map} +0 -0
  486. /package/dist/{chunk-SBRUTD5O.js.map → chunk-YSATDEBY.js.map} +0 -0
  487. /package/dist/{chunk-5QDTZIGH.js.map → chunk-ZJ3CEAJD.js.map} +0 -0
  488. /package/dist/{chunk-GMO3BGOF.js.map → chunk-ZOJUWVAU.js.map} +0 -0
  489. /package/dist/{chunk-T4BT4FQN.js.map → chunk-ZYP4YEEI.js.map} +0 -0
  490. /package/dist/{migrate-from-identity-anchor-MJYB6NNN.js.map → config-deprecations.js.map} +0 -0
  491. /package/dist/{first-start-migration-BPVJ4HJQ.js.map → first-start-migration-PPPP54X6.js.map} +0 -0
  492. /package/dist/{tier-stats-FLFKN7Y6.js.map → tier-stats-XWJSVEHC.js.map} +0 -0
@@ -0,0 +1,132 @@
1
+ /**
2
+ * peers/interaction-log-append.ts — append path for the peer
3
+ * interaction log, extracted from storage.ts (#1995 ratchet: the file
4
+ * exceeded its grandfathered ceiling). Read/parse stays in storage.ts.
5
+ */
6
+
7
+ import { z } from "zod";
8
+
9
+ import type { PeerInteractionLogEntry } from "./types.js";
10
+ import {
11
+ appendFileNoFollow,
12
+ assertPeerDirNotEscaped,
13
+ assertValidPeerId,
14
+ interactionsPath,
15
+ mkdirPeerDirAtomic,
16
+ } from "./storage.js";
17
+
18
+ // Boundary decode for the untrusted entry argument. The checks below
19
+ // carry the Codex P2 review history: trim() before the empty check
20
+ // matches what sanitizeLogField does at format time (round 10/12); a
21
+ // whitespace-only timestamp or kind would previously pass validation
22
+ // and then be normalized to "" later, producing an entry like
23
+ // `- [] ()` that breaks downstream parsers; optional sessionId must be
24
+ // a non-empty string OR strictly `undefined` — null and "" are both
25
+ // rejected explicitly (rounds 6/8/9) because silently dropping them
26
+ // reinterprets invalid input instead of failing fast.
27
+ const NON_WHITESPACE_TIMESTAMP = "interaction entry must have a non-whitespace timestamp";
28
+ const NON_WHITESPACE_KIND = "interaction entry must have a non-whitespace kind";
29
+ const STRING_SUMMARY = "interaction entry must have a string summary";
30
+ const NON_WHITESPACE_SESSION = "interaction entry sessionId must be a non-whitespace string when provided";
31
+ const interactionEntrySchema = z.object({
32
+ timestamp: z.string({ error: NON_WHITESPACE_TIMESTAMP }).trim().min(1, NON_WHITESPACE_TIMESTAMP),
33
+ kind: z.string({ error: NON_WHITESPACE_KIND }).trim().min(1, NON_WHITESPACE_KIND),
34
+ summary: z.string({ error: STRING_SUMMARY }),
35
+ sessionId: z.string({ error: NON_WHITESPACE_SESSION }).trim().min(1, NON_WHITESPACE_SESSION).optional(),
36
+ });
37
+
38
+ function sanitizeLogField(value: string): string {
39
+ // Cursor Medium: every interaction-log field — not just summary —
40
+ // must collapse newlines so a malicious or buggy `timestamp` /
41
+ // `kind` / `sessionId` value can't break the one-line-per-entry
42
+ // invariant the append-only log relies on. Replace CR/LF/Tab with
43
+ // a single space; trim leading/trailing whitespace.
44
+ return value.replace(/[\r\n\t]+/g, " ").trim();
45
+ }
46
+
47
+ function isCanonicalIsoTimestamp(value: string): boolean {
48
+ const ms = Date.parse(value);
49
+ return Number.isFinite(ms) && new Date(ms).toISOString() === value;
50
+ }
51
+ function assertCanonicalIsoTimestamp(value: string, field: string): void {
52
+ if (!isCanonicalIsoTimestamp(value)) {
53
+ throw new Error(`${field} must be a canonical ISO-8601 timestamp`);
54
+ }
55
+ }
56
+
57
+ function formatLogEntry(entry: PeerInteractionLogEntry): string {
58
+ // One line per entry. We use a leading bullet so the file remains
59
+ // readable as ordinary markdown. Order: timestamp, kind, optional
60
+ // session id, summary. ALL fields are passed through `sanitizeLogField`
61
+ // so a stray newline anywhere can't shatter the append-only invariant
62
+ // (cursor Medium on PR #723).
63
+ //
64
+ // Cursor Low on PR #736: the previous bare `session=<id>` token was
65
+ // ambiguous with summaries that literally start with `session=`
66
+ // (e.g. summary `"session=foo bar"` round-tripped to
67
+ // `{sessionId: "foo", summary: "bar"}`). New entries wrap the
68
+ // session marker in square brackets — `[session=<id>]` — which a
69
+ // sanitized summary can never start with (sanitizeLogField never
70
+ // emits `[` as the first character of a summary that originally
71
+ // started with `session=`, and bracketed metadata is unambiguously
72
+ // distinct from `session=` text). Old entries written by previous
73
+ // code remain parseable through the legacy fallback in
74
+ // `parseLogLine`.
75
+ const ts = sanitizeLogField(entry.timestamp);
76
+ const kind = sanitizeLogField(entry.kind);
77
+ const summary = sanitizeLogField(entry.summary);
78
+ const session = entry.sessionId
79
+ ? ` [session=${sanitizeLogField(entry.sessionId)}]`
80
+ : "";
81
+ return `- [${ts}] (${kind})${session} ${summary}`;
82
+ }
83
+
84
+ /**
85
+ * Append one entry to a peer's interaction log.
86
+ *
87
+ * Creates `peers/{id}/` and `interactions.log.md` if needed. The file is
88
+ * append-only by contract — this helper never rewrites prior entries.
89
+ * Returns the absolute path of the log file (useful for tests).
90
+ *
91
+ * Concurrency contract: appends to the same file are serialized
92
+ * in-process via a per-file promise chain — entries land in enqueue
93
+ * order and a single entry can never be split by another writer's chunk
94
+ * (#3564). Ordering across separate PROCESSES is still the caller's
95
+ * responsibility (POSIX gives atomicity per write, not ordering).
96
+ */
97
+ // Per-file tail of the append chain. Bounded to files with an in-flight
98
+ // write: the writer deletes its entry when it is still the tail.
99
+ const appendQueues = new Map<string, Promise<void>>();
100
+ export async function appendInteractionLog(
101
+ memoryDir: string,
102
+ peerId: string,
103
+ entry: PeerInteractionLogEntry,
104
+ ): Promise<string> {
105
+ assertValidPeerId(peerId);
106
+ const parsedEntry = interactionEntrySchema.safeParse(entry);
107
+ if (!parsedEntry.success) {
108
+ throw new Error(parsedEntry.error.issues[0]?.message ?? "invalid interaction entry");
109
+ }
110
+ const e = parsedEntry.data;
111
+ assertCanonicalIsoTimestamp(e.timestamp, "interaction entry timestamp");
112
+ await mkdirPeerDirAtomic(memoryDir, peerId);
113
+ await assertPeerDirNotEscaped(memoryDir, peerId);
114
+ const file = interactionsPath(memoryDir, peerId);
115
+ const line = formatLogEntry(e) + "\n";
116
+ // `appendFile` creates the file if it does not exist. Serialize writes
117
+ // per file so concurrent callers' entries land in enqueue order —
118
+ // `fh.writeFile` chunks a large entry across multiple writes, and an
119
+ // unqueued writer could otherwise interleave between them (#3564).
120
+ // The chain tail is kept on a .catch(() => {}) so one failed append
121
+ // does not poison the queue for followers.
122
+ const prev = appendQueues.get(file) ?? Promise.resolve();
123
+ const write = prev.then(() => appendFileNoFollow(file, line));
124
+ const tail = write.catch(() => {});
125
+ appendQueues.set(file, tail);
126
+ try {
127
+ await write;
128
+ } finally {
129
+ if (appendQueues.get(file) === tail) appendQueues.delete(file);
130
+ }
131
+ return file;
132
+ }
@@ -297,6 +297,36 @@ test("appendInteractionLog appends entries in order", async () => {
297
297
  assert.ok(lines[2].includes("third turn"));
298
298
  });
299
299
 
300
+ test("appendInteractionLog serializes concurrent appends to one peer — #3564", async () => {
301
+ // Concurrent callers may append to the same peer's log (the reasoner is
302
+ // serial today, but the helper is a public export — nothing enforces
303
+ // enqueue order). A large entry is chunked across multiple writes
304
+ // internally; without per-file serialization a concurrent small write
305
+ // lands BETWEEN those chunks, corrupting the large entry or reordering
306
+ // the log. Contract: entries appear in enqueue order, each intact.
307
+ const dir = await makeTempDir();
308
+ const peerId = "agent.codex";
309
+ const big = `BIG-${"x".repeat(4 << 20)}-BIG-END`;
310
+ const [fileA, fileB] = await Promise.all([
311
+ appendInteractionLog(dir, peerId, {
312
+ timestamp: "2026-04-25T00:00:01.000Z",
313
+ kind: "message",
314
+ summary: big,
315
+ }),
316
+ appendInteractionLog(dir, peerId, {
317
+ timestamp: "2026-04-25T00:00:02.000Z",
318
+ kind: "message",
319
+ summary: "SMALL-END",
320
+ }),
321
+ ]);
322
+ assert.equal(fileA, fileB);
323
+ const raw = await readInteractionLogRaw(dir, peerId);
324
+ const lines = raw.trim().split("\n");
325
+ assert.equal(lines.length, 2, `expected 2 intact lines, got ${lines.length}`);
326
+ assert.ok(lines[0].includes("BIG-") && lines[0].includes("BIG-END"));
327
+ assert.ok(lines[1].includes("SMALL-END"));
328
+ });
329
+
300
330
  test("appendInteractionLog escapes embedded newlines so each entry stays one line", async () => {
301
331
  const dir = await makeTempDir();
302
332
  const peerId = "human.alex";
@@ -32,12 +32,12 @@
32
32
  */
33
33
 
34
34
  import {
35
- appendInteractionLog,
36
35
  listPeers,
37
36
  readPeerInteractionLog,
38
37
  readPeerProfile,
39
38
  writePeerProfile,
40
39
  } from "./storage.js";
40
+ import { appendInteractionLog } from "./interaction-log-append.js";
41
41
  import type {
42
42
  Peer,
43
43
  PeerInteractionLogEntry,
@@ -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
  // ──────────────────────────────────────────────────────────────────────
@@ -156,3 +156,43 @@ test("input entries are not mutated", () => {
156
156
  buildStateEvidencePackets(entries);
157
157
  assert.deepEqual(entries, snapshot);
158
158
  });
159
+
160
+ test("shared chain suffixes resolve each entry at its own depth — #3565", () => {
161
+ // Diamond: two predecessors share one suffix chain. A memoized walk must
162
+ // give every entry its OWN depth (a1/a2 = 3, b = 2, c = 1), not the depth
163
+ // of whichever entry populated the cache entry it shared.
164
+ const entries: StateViewEntry[] = [
165
+ { memoryId: "head", stateLabel: "current" },
166
+ { memoryId: "a1", stateLabel: "historical", supersededById: "b" },
167
+ { memoryId: "a2", stateLabel: "historical", supersededById: "b" },
168
+ { memoryId: "b", stateLabel: "historical", supersededById: "c" },
169
+ { memoryId: "c", stateLabel: "historical", supersededById: "head" },
170
+ ];
171
+ const out = buildStateEvidencePackets(entries);
172
+ assert.deepEqual(out, {
173
+ packets: [{ headId: "head", historyIds: ["c", "b", "a1", "a2"] }],
174
+ orphanHistoryIds: [],
175
+ });
176
+ });
177
+
178
+ test("a long chain resolves in one pass, preserving per-entry depth order — #3565", () => {
179
+ // 600-entry chain: nearest-to-head ordering must hold end-to-end. Guards
180
+ // the O(n) memoized walk against off-by-one depth corruption at scale.
181
+ const n = 600;
182
+ const entries: StateViewEntry[] = [{ memoryId: "head", stateLabel: "current" }];
183
+ for (let i = n - 1; i >= 0; i--) {
184
+ entries.push({
185
+ memoryId: `h${i}`,
186
+ stateLabel: "historical",
187
+ supersededById: i === n - 1 ? "head" : `h${i + 1}`,
188
+ });
189
+ }
190
+ const out = buildStateEvidencePackets(entries);
191
+ const packet = out.packets.find((p) => p.headId === "head");
192
+ assert.ok(packet);
193
+ assert.equal(packet.historyIds.length, n);
194
+ assert.deepEqual(
195
+ packet.historyIds,
196
+ Array.from({ length: n }, (_, i) => `h${n - 1 - i}`),
197
+ );
198
+ });
@@ -47,25 +47,63 @@ interface Attachment {
47
47
  * stop at the first current/transition successor. Returns undefined when the
48
48
  * walk dead-ends (no or blank successor, successor id absent from the input)
49
49
  * or revisits an id (cycle), so callers treat the entry as an orphan.
50
+ *
51
+ * `resolved` memoizes per-entry outcomes across calls (#3565): every id
52
+ * traversed gets its own cached resolution (its own depth), so one long
53
+ * chain resolves in a single pass instead of O(n^2) re-walks.
50
54
  */
51
55
  function resolveHead(
52
56
  entry: StateViewEntry,
53
57
  byId: ReadonlyMap<string, StateViewEntry>,
58
+ resolved: Map<string, HeadResolution | undefined>,
54
59
  ): HeadResolution | undefined {
55
- const visited = new Set<string>();
60
+ const cached = resolved.get(entry.memoryId);
61
+ if (cached !== undefined || resolved.has(entry.memoryId)) return cached;
62
+ const path: string[] = [entry.memoryId];
63
+ const visited = new Set<string>(path);
56
64
  let current = entry;
57
65
  let depth = 0;
58
66
  for (;;) {
59
67
  const successorId = current.supersededById;
60
- if (successorId === undefined || successorId.trim() === "") return undefined;
61
- const successor = byId.get(successorId);
62
- if (successor === undefined) return undefined;
68
+ const successor =
69
+ successorId === undefined || successorId.trim() === ""
70
+ ? undefined
71
+ : byId.get(successorId);
72
+ if (successor === undefined || successorId === undefined) break;
73
+ const hit = resolved.get(successorId);
74
+ if (hit !== undefined || resolved.has(successorId)) {
75
+ // A node with a known outcome: splice its resolution on with an
76
+ // offset, or propagate the dead-end.
77
+ const result =
78
+ hit === undefined
79
+ ? undefined
80
+ : { headId: hit.headId, depth: depth + 1 + hit.depth };
81
+ for (let i = 0; i < path.length; i++) {
82
+ resolved.set(
83
+ path[i],
84
+ result === undefined
85
+ ? undefined
86
+ : { headId: result.headId, depth: result.depth - i },
87
+ );
88
+ }
89
+ return result;
90
+ }
63
91
  depth += 1;
64
- if (successor.stateLabel !== "historical") return { headId: successorId, depth };
65
- if (visited.has(successorId)) return undefined;
92
+ if (successor.stateLabel !== "historical") {
93
+ // Head found: every path node resolves to it at its own depth.
94
+ for (let i = 0; i < path.length; i++) {
95
+ resolved.set(path[i], { headId: successorId, depth: depth - i });
96
+ }
97
+ return { headId: successorId, depth };
98
+ }
99
+ if (visited.has(successorId)) break;
66
100
  visited.add(successorId);
101
+ path.push(successorId);
67
102
  current = successor;
68
103
  }
104
+ // Dead-end or cycle: every node on the path is an orphan.
105
+ for (const id of path) resolved.set(id, undefined);
106
+ return undefined;
69
107
  }
70
108
 
71
109
  function compareStrings(a: string, b: string): number {
@@ -97,12 +135,11 @@ export function buildStateEvidencePackets(
97
135
  if (!byId.has(entry.memoryId)) byId.set(entry.memoryId, entry);
98
136
  }
99
137
 
100
- // ponytail: per-entry chain walks are O(n^2) on one long chain; recall-sized
101
- // result sets stay tiny, memoize if packet building ever moves offline.
102
138
  const packets: StateEvidencePacket[] = [];
103
139
  const packetByHead = new Map<string, StateEvidencePacket>();
104
140
  const attachments: Attachment[] = [];
105
141
  const orphanHistoryIds: string[] = [];
142
+ const resolved = new Map<string, HeadResolution | undefined>();
106
143
 
107
144
  for (const [id, entry] of byId) {
108
145
  if (entry.stateLabel !== "historical") {
@@ -111,7 +148,7 @@ export function buildStateEvidencePackets(
111
148
  packets.push(packet);
112
149
  continue;
113
150
  }
114
- const head = resolveHead(entry, byId);
151
+ const head = resolveHead(entry, byId, resolved);
115
152
  if (head === undefined) orphanHistoryIds.push(id);
116
153
  else attachments.push({ headId: head.headId, historyId: id, depth: head.depth });
117
154
  }
@@ -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