@remnic/core 9.29.0 → 9.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (359) hide show
  1. package/dist/access-admin-ops-surface.d.ts +11 -11
  2. package/dist/access-admin-ops-surface.js +19 -18
  3. package/dist/access-authorization-probe.d.ts +11 -11
  4. package/dist/access-authorization-probe.js +20 -19
  5. package/dist/access-boundary.d.ts +11 -11
  6. package/dist/access-boundary.js +19 -18
  7. package/dist/access-citation-namespace.js +2 -2
  8. package/dist/access-cli.js +45 -44
  9. package/dist/access-cli.js.map +1 -1
  10. package/dist/access-health-types.d.ts +1 -1
  11. package/dist/access-http-lcm-compaction.d.ts +11 -11
  12. package/dist/access-http.d.ts +11 -11
  13. package/dist/access-http.js +25 -24
  14. package/dist/access-identity-continuity-surface.d.ts +8 -8
  15. package/dist/access-identity-continuity-surface.js +19 -18
  16. package/dist/access-lcm-surface.d.ts +10 -10
  17. package/dist/access-lcm-surface.js +19 -18
  18. package/dist/access-mcp.d.ts +11 -11
  19. package/dist/access-mcp.js +23 -22
  20. package/dist/access-memory-search-fanout.d.ts +2 -2
  21. package/dist/{access-namespace-preflight-DCXBkDp0.d.ts → access-namespace-preflight-VfXssvoI.d.ts} +1 -1
  22. package/dist/access-namespace-preflight.d.ts +3 -3
  23. package/dist/access-namespace-preflight.js +19 -18
  24. package/dist/access-observe-write-surface.d.ts +10 -10
  25. package/dist/access-observe-write-surface.js +19 -18
  26. package/dist/access-operations-batch.js +20 -19
  27. package/dist/access-operations.d.ts +11 -11
  28. package/dist/access-operations.js +22 -21
  29. package/dist/access-recall-concurrency.d.ts +11 -11
  30. package/dist/access-recall-concurrency.js +19 -18
  31. package/dist/access-recall-response.d.ts +10 -10
  32. package/dist/access-recall-response.js +19 -18
  33. package/dist/access-recall-surface.d.ts +10 -10
  34. package/dist/access-recall-surface.js +19 -18
  35. package/dist/access-schema.d.ts +7 -7
  36. package/dist/access-schema.js +3 -3
  37. package/dist/{access-service-DvPW_M5j.d.ts → access-service-B5RwVsTV.d.ts} +7 -7
  38. package/dist/access-service.d.ts +11 -11
  39. package/dist/access-service.js +19 -18
  40. package/dist/access-surface-catalog.d.ts +11 -11
  41. package/dist/access-wearables-meetings-surface.d.ts +4 -3
  42. package/dist/action-confidence.d.ts +1 -1
  43. package/dist/active-memory-bridge.d.ts +1 -1
  44. package/dist/active-recall.d.ts +1 -1
  45. package/dist/active-recall.js +3 -3
  46. package/dist/behavior-learner.d.ts +1 -1
  47. package/dist/behavior-signals.d.ts +1 -1
  48. package/dist/bootstrap.d.ts +8 -8
  49. package/dist/briefing.d.ts +3 -2
  50. package/dist/briefing.js +10 -9
  51. package/dist/buffer-surprise-report.d.ts +1 -1
  52. package/dist/buffer.d.ts +3 -2
  53. package/dist/bulk-import/index.d.ts +3 -3
  54. package/dist/calibration.d.ts +1 -1
  55. package/dist/capabilities.d.ts +1 -1
  56. package/dist/{catalog-BIVgftWu.d.ts → catalog-V7inUQdp.d.ts} +1 -1
  57. package/dist/causal-behavior.d.ts +1 -1
  58. package/dist/causal-consolidation.d.ts +1 -1
  59. package/dist/causal-consolidation.js +11 -10
  60. package/dist/causal-consolidation.js.map +1 -1
  61. package/dist/causal-trajectory-graph.d.ts +1 -1
  62. package/dist/{chunk-KUJQHXPH.js → chunk-2EUVEDF5.js} +2 -2
  63. package/dist/{chunk-2XC73SHY.js → chunk-4WKA6I65.js} +20 -20
  64. package/dist/{chunk-2XC73SHY.js.map → chunk-4WKA6I65.js.map} +1 -1
  65. package/dist/{chunk-AIK5W3IW.js → chunk-5TFP4CUL.js} +68 -2
  66. package/dist/chunk-5TFP4CUL.js.map +1 -0
  67. package/dist/{chunk-EVX44I7C.js → chunk-5W4ZLBEZ.js} +9 -9
  68. package/dist/{chunk-P3MH72CI.js → chunk-62U4J2GN.js} +2 -2
  69. package/dist/{chunk-YGHMSDLK.js → chunk-66772WBP.js} +2 -2
  70. package/dist/{chunk-EP5BVCRI.js → chunk-6BNE62PM.js} +2 -2
  71. package/dist/{chunk-AAP5T6QG.js → chunk-6DNMUYEE.js} +2 -2
  72. package/dist/{chunk-SG265CVF.js → chunk-6FUPCJUL.js} +7 -7
  73. package/dist/{chunk-WZ7UB7XQ.js → chunk-6U7F52DE.js} +19 -19
  74. package/dist/{chunk-E4OCKU67.js → chunk-7XC2HX75.js} +2 -2
  75. package/dist/{chunk-OVRQLAYR.js → chunk-AZ5BTEKX.js} +2 -2
  76. package/dist/{chunk-2HNUMF5V.js → chunk-CZRYLSSW.js} +3 -3
  77. package/dist/chunk-FBUE6PD3.js +1769 -0
  78. package/dist/chunk-FBUE6PD3.js.map +1 -0
  79. package/dist/{chunk-WONS4RZ2.js → chunk-FDAMS4PK.js} +2 -2
  80. package/dist/{chunk-WL5EBRDH.js → chunk-FFAZ2XFU.js} +9 -8
  81. package/dist/chunk-FFAZ2XFU.js.map +1 -0
  82. package/dist/{chunk-Q6VFVAKZ.js → chunk-GIBMDSJ2.js} +2 -2
  83. package/dist/{chunk-ZXAGJFHJ.js → chunk-H5CPS5JP.js} +3 -3
  84. package/dist/{chunk-NBDCZWP4.js → chunk-I5NLEENJ.js} +2 -2
  85. package/dist/{chunk-DRBXHRXE.js → chunk-IB26HVAJ.js} +2 -2
  86. package/dist/{chunk-XEQ7OT7U.js → chunk-IC6CBHCA.js} +3 -3
  87. package/dist/{chunk-CMRQ34J5.js → chunk-JCBWCYEJ.js} +2 -2
  88. package/dist/{chunk-3PDOVUHC.js → chunk-KXB4VXHY.js} +2 -2
  89. package/dist/{chunk-G6LBWZRF.js → chunk-LBOD4U5B.js} +7 -7
  90. package/dist/{chunk-ZGOQTOYA.js → chunk-LGHKJABJ.js} +3 -3
  91. package/dist/{chunk-T3GCXULH.js → chunk-M3C2V3PV.js} +10 -10
  92. package/dist/{chunk-OFHFH655.js → chunk-MJCGLM25.js} +8 -8
  93. package/dist/{chunk-JDZRYH2N.js → chunk-NHWB6HG2.js} +2 -2
  94. package/dist/{chunk-TC3VNKGX.js → chunk-NM2WP3B7.js} +4 -4
  95. package/dist/{chunk-IMA2EWLV.js → chunk-P5PXWTW7.js} +2 -2
  96. package/dist/chunk-PH3ZWL3W.js +786 -0
  97. package/dist/chunk-PH3ZWL3W.js.map +1 -0
  98. package/dist/{chunk-QMBNMPQM.js → chunk-PUS63Q3G.js} +24 -22
  99. package/dist/{chunk-QMBNMPQM.js.map → chunk-PUS63Q3G.js.map} +1 -1
  100. package/dist/{chunk-2QMKMVHH.js → chunk-QNWXCJ76.js} +2 -2
  101. package/dist/{chunk-FCDWWCLX.js → chunk-RGIWINDN.js} +427 -795
  102. package/dist/chunk-RGIWINDN.js.map +1 -0
  103. package/dist/{chunk-CSMCNOPH.js → chunk-SPJXKAVF.js} +3 -3
  104. package/dist/{chunk-4PBVXX7L.js → chunk-TH2LSRMG.js} +2 -2
  105. package/dist/{chunk-ESBQWC3U.js → chunk-VI2JQPNQ.js} +2 -2
  106. package/dist/{chunk-GGUBDXRR.js → chunk-W5EG6LE3.js} +2 -2
  107. package/dist/{chunk-DEBHXHJR.js → chunk-WIPEXG6R.js} +2 -2
  108. package/dist/{chunk-SH6YO3LT.js → chunk-WVO4G37W.js} +2 -2
  109. package/dist/{chunk-VVIW3PTA.js → chunk-YTQNQ4KB.js} +14 -14
  110. package/dist/{chunk-PKRIQL3V.js → chunk-YTSNAUXN.js} +2 -2
  111. package/dist/{chunk-QAOGGNE3.js → chunk-ZPSVBSOF.js} +4 -4
  112. package/dist/{cli-CxoSOiG0.d.ts → cli-C4GbETPC.d.ts} +5 -5
  113. package/dist/cli.d.ts +13 -13
  114. package/dist/cli.js +36 -35
  115. package/dist/compounding/engine.d.ts +3 -2
  116. package/dist/compounding/engine.js +10 -9
  117. package/dist/compounding/preference-consolidator.d.ts +1 -1
  118. package/dist/compression-optimizer.d.ts +1 -1
  119. package/dist/config.d.ts +1 -1
  120. package/dist/config.js +3 -3
  121. package/dist/connectors/codex-materialize-runner.d.ts +1 -1
  122. package/dist/connectors/codex-materialize-runner.js +10 -9
  123. package/dist/connectors/codex-materialize.d.ts +1 -1
  124. package/dist/connectors/index.d.ts +1 -1
  125. package/dist/connectors/index.js +10 -9
  126. package/dist/consolidation-provenance-check.d.ts +3 -2
  127. package/dist/consolidation-undo.d.ts +3 -2
  128. package/dist/contradiction/index.d.ts +3 -2
  129. package/dist/conversation-index/backend.d.ts +1 -1
  130. package/dist/conversation-index/chunker.d.ts +1 -1
  131. package/dist/conversation-index/faiss-adapter.d.ts +1 -1
  132. package/dist/conversation-index/indexer.d.ts +1 -1
  133. package/dist/conversation-index/search.d.ts +1 -1
  134. package/dist/corpus-watermark.d.ts +1 -1
  135. package/dist/corpus-watermark.js +12 -11
  136. package/dist/day-summary.d.ts +1 -1
  137. package/dist/delinearize.d.ts +1 -1
  138. package/dist/direct-answer-wiring.d.ts +1 -1
  139. package/dist/direct-answer.d.ts +1 -1
  140. package/dist/embedding-fallback.d.ts +1 -1
  141. package/dist/enrichment/index.d.ts +1 -1
  142. package/dist/entity-retrieval.d.ts +3 -2
  143. package/dist/entity-retrieval.js +10 -9
  144. package/dist/entity-schema.d.ts +1 -1
  145. package/dist/explicit-capture.d.ts +52 -10
  146. package/dist/explicit-capture.js +13 -1
  147. package/dist/extraction-error-classification.d.ts +1 -1
  148. package/dist/extraction-faithfulness.d.ts +1 -1
  149. package/dist/extraction-judge-telemetry.d.ts +1 -1
  150. package/dist/extraction-judge-training.d.ts +1 -1
  151. package/dist/extraction-judge.d.ts +1 -1
  152. package/dist/extraction-liveness.d.ts +1 -1
  153. package/dist/extraction-source-grounding-rules.d.ts +1 -1
  154. package/dist/extraction-source-grounding.d.ts +1 -1
  155. package/dist/extraction.d.ts +1 -1
  156. package/dist/fallback-llm.d.ts +1 -1
  157. package/dist/{forget-HRPLVB3W.js → forget-4UY2EOKH.js} +3 -3
  158. package/dist/graph-dashboard-diff.d.ts +1 -1
  159. package/dist/graph-dashboard-key.d.ts +1 -1
  160. package/dist/graph-dashboard-parser.d.ts +1 -1
  161. package/dist/graph-edge-reinforcement.d.ts +1 -1
  162. package/dist/graph-snapshot.d.ts +1 -1
  163. package/dist/graph.d.ts +1 -1
  164. package/dist/importance.d.ts +1 -1
  165. package/dist/importers/index.d.ts +1 -1
  166. package/dist/in-flight-reads.d.ts +1 -1
  167. package/dist/index.d.ts +21 -21
  168. package/dist/index.js +47 -45
  169. package/dist/intent.d.ts +1 -1
  170. package/dist/lcm/engine.d.ts +1 -1
  171. package/dist/lcm/index.d.ts +1 -1
  172. package/dist/lcm/tools.d.ts +1 -1
  173. package/dist/lifecycle.d.ts +1 -1
  174. package/dist/live-connectors-runner.d.ts +1 -1
  175. package/dist/local-llm.d.ts +1 -1
  176. package/dist/local-model-endpoint.d.ts +1 -1
  177. package/dist/maintenance/memory-governance.d.ts +1 -1
  178. package/dist/maintenance/memory-governance.js +10 -9
  179. package/dist/maintenance/rebuild-memory-lifecycle-ledger.d.ts +2 -2
  180. package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +10 -9
  181. package/dist/maintenance/rebuild-memory-projection.d.ts +3 -2
  182. package/dist/maintenance/rebuild-memory-projection.js +11 -10
  183. package/dist/{maintenance-Cb-PjxQd.d.ts → maintenance-CL30NWtc.d.ts} +3 -3
  184. package/dist/mcp-memory-inspector-app.d.ts +11 -11
  185. package/dist/memory-action-policy.d.ts +1 -1
  186. package/dist/memory-cache.d.ts +1 -1
  187. package/dist/memory-lifecycle-ledger-utils.d.ts +1 -1
  188. package/dist/memory-projection-store.d.ts +1 -1
  189. package/dist/memory-provenance.d.ts +1 -1
  190. package/dist/memory-worth-outcomes.d.ts +3 -2
  191. package/dist/models-json.d.ts +1 -1
  192. package/dist/namespaces/migrate.d.ts +4 -3
  193. package/dist/namespaces/migrate.js +11 -10
  194. package/dist/namespaces/principal.d.ts +1 -1
  195. package/dist/namespaces/search.d.ts +1 -1
  196. package/dist/namespaces/storage.d.ts +4 -3
  197. package/dist/namespaces/storage.js +10 -9
  198. package/dist/native-knowledge.d.ts +1 -1
  199. package/dist/offline-sync-impression-drain.d.ts +1 -1
  200. package/dist/offline-sync-impression-drain.js +5 -5
  201. package/dist/offline-sync.js +2 -2
  202. package/dist/operator-doctor-corpus.d.ts +1 -1
  203. package/dist/operator-doctor-corpus.js +13 -12
  204. package/dist/operator-doctor-replica.d.ts +1 -1
  205. package/dist/operator-toolkit.d.ts +4 -3
  206. package/dist/operator-toolkit.js +18 -17
  207. package/dist/orchestration/compression-guideline-coordinator.d.ts +3 -2
  208. package/dist/orchestration/maintenance.d.ts +5 -4
  209. package/dist/orchestration/maintenance.js +15 -14
  210. package/dist/{orchestrator-5GKqb_HL.d.ts → orchestrator-CKTCRwWV.d.ts} +7 -7
  211. package/dist/orchestrator.d.ts +8 -8
  212. package/dist/orchestrator.js +45 -44
  213. package/dist/patterns-cli.d.ts +1 -1
  214. package/dist/{pipeline-3Qi1TpRo.d.ts → pipeline-B7wj4rRZ.d.ts} +1 -1
  215. package/dist/policy-runtime.d.ts +1 -1
  216. package/dist/proactive-contention.d.ts +1 -1
  217. package/dist/provenance.d.ts +1 -1
  218. package/dist/{purge-YSGX5BOG.js → purge-533FZLS4.js} +16 -9
  219. package/dist/purge-533FZLS4.js.map +1 -0
  220. package/dist/qmd-preflight.d.ts +2 -2
  221. package/dist/{qmd-D9JqzzRX.d.ts → qmd-q9tg4dHp.d.ts} +1 -1
  222. package/dist/qmd-recall-cache.d.ts +1 -1
  223. package/dist/qmd.d.ts +2 -2
  224. package/dist/recall-concurrency-config.d.ts +1 -1
  225. package/dist/recall-disclosure-escalation.d.ts +1 -1
  226. package/dist/recall-explain-renderer.d.ts +1 -1
  227. package/dist/recall-memory-map.d.ts +1 -1
  228. package/dist/recall-planner-llm.d.ts +1 -1
  229. package/dist/recall-state.d.ts +1 -1
  230. package/dist/recall-state.js +2 -2
  231. package/dist/recall-tag-filter.d.ts +1 -1
  232. package/dist/recall-timings.d.ts +1 -1
  233. package/dist/recall-xray-cli.d.ts +1 -1
  234. package/dist/recall-xray-renderer.d.ts +1 -1
  235. package/dist/recall-xray.d.ts +1 -1
  236. package/dist/replay/normalizers/chatgpt.d.ts +1 -1
  237. package/dist/replay/normalizers/claude.d.ts +1 -1
  238. package/dist/replay/normalizers/openclaw.d.ts +1 -1
  239. package/dist/replay/normalizers/shared.d.ts +1 -1
  240. package/dist/replay/runner.d.ts +1 -1
  241. package/dist/replay/types.d.ts +1 -1
  242. package/dist/replica-divergence.d.ts +1 -1
  243. package/dist/replica-peers-config.d.ts +1 -1
  244. package/dist/resolve-auth-token.d.ts +1 -1
  245. package/dist/resume-bundles.js +4 -4
  246. package/dist/retrieval-agents.d.ts +2 -2
  247. package/dist/retrieval-tiers.d.ts +1 -1
  248. package/dist/routing/engine.d.ts +1 -1
  249. package/dist/routing/store.d.ts +1 -1
  250. package/dist/salvage-envelope.d.ts +1 -1
  251. package/dist/schemas.d.ts +22 -22
  252. package/dist/{scope-profiles-C4g6_UdP.d.ts → scope-profiles-CWDyglPM.d.ts} +1 -1
  253. package/dist/search/embed-helper.d.ts +1 -1
  254. package/dist/search/factory.d.ts +1 -1
  255. package/dist/search/index.d.ts +1 -1
  256. package/dist/search/lancedb-backend.d.ts +1 -1
  257. package/dist/search/meilisearch-backend.d.ts +1 -1
  258. package/dist/search/noop-backend.d.ts +1 -1
  259. package/dist/search/orama-backend.d.ts +1 -1
  260. package/dist/search/port.d.ts +1 -1
  261. package/dist/search/remote-backend.d.ts +1 -1
  262. package/dist/secure-store/index.js +2 -2
  263. package/dist/{semantic-consolidation-BrxqnzTW.d.ts → semantic-consolidation-BUE3deLn.d.ts} +1 -1
  264. package/dist/semantic-consolidation.d.ts +2 -2
  265. package/dist/semantic-consolidation.js +11 -10
  266. package/dist/semantic-rule-promotion.js +10 -9
  267. package/dist/semantic-rule-verifier.d.ts +1 -1
  268. package/dist/semantic-rule-verifier.js +10 -9
  269. package/dist/{service-Bi1JgxdP.d.ts → service-CXgM0bQG.d.ts} +2 -2
  270. package/dist/session-observer-bands.d.ts +1 -1
  271. package/dist/session-observer-state.d.ts +1 -1
  272. package/dist/shared-context/manager.d.ts +1 -1
  273. package/dist/signal.d.ts +1 -1
  274. package/dist/{storage-CcH6yPk2.d.ts → storage-DysJq-XH.d.ts} +163 -27
  275. package/dist/storage.d.ts +3 -2
  276. package/dist/storage.js +12 -10
  277. package/dist/summarizer.d.ts +1 -1
  278. package/dist/summarizer.js +3 -3
  279. package/dist/summary-snapshot.d.ts +1 -1
  280. package/dist/summary-snapshot.js +2 -2
  281. package/dist/temporal-supersession.d.ts +3 -2
  282. package/dist/temporal-timeline-recall.d.ts +1 -1
  283. package/dist/temporal-validity.d.ts +1 -1
  284. package/dist/threading.d.ts +1 -1
  285. package/dist/tier-migration.d.ts +3 -2
  286. package/dist/tier-routing.d.ts +1 -1
  287. package/dist/topics.d.ts +1 -1
  288. package/dist/transcript.d.ts +1 -1
  289. package/dist/transfer/types.d.ts +12 -12
  290. package/dist/trust-score-stage.d.ts +1 -1
  291. package/dist/trust-score.d.ts +1 -1
  292. package/dist/{types-Dg0w9ADr.d.ts → types-aPPzhnjT.d.ts} +1 -1
  293. package/dist/types.d.ts +1 -1
  294. package/dist/utility-runtime.d.ts +1 -1
  295. package/dist/utils/serialize-mutations.d.ts +11 -7
  296. package/dist/utils/serialize-mutations.js +1 -1
  297. package/dist/verified-recall.js +10 -9
  298. package/dist/write-envelope.d.ts +1 -1
  299. package/package.json +2 -2
  300. package/src/access-observe-write-surface.ts +1 -1
  301. package/src/access-service-coding-write.test.ts +40 -0
  302. package/src/explicit-capture.test.ts +1110 -1
  303. package/src/explicit-capture.ts +534 -135
  304. package/src/maintenance/purge.test.ts +157 -1
  305. package/src/maintenance/purge.ts +15 -9
  306. package/src/secure-store/secure-fs.ts +78 -1
  307. package/src/storage/content-hash-index.ts +43 -17
  308. package/src/storage/entity-canonical-id-migration.ts +151 -23
  309. package/src/storage/tombstone-blocked-capture-index.ts +562 -0
  310. package/src/storage/tombstone-blocked-capture-mutation.ts +284 -0
  311. package/src/storage/tombstone-blocked-capture-sync.ts +872 -0
  312. package/src/storage-fact-hash-index-defer.test.ts +2900 -57
  313. package/src/storage.ts +266 -265
  314. package/src/testing/subjects/tombstone-blocked-capture.test.ts +181 -0
  315. package/src/utils/serialize-mutations.test.ts +4 -1
  316. package/src/utils/serialize-mutations.ts +26 -27
  317. package/dist/chunk-55MDBZLC.js +0 -490
  318. package/dist/chunk-55MDBZLC.js.map +0 -1
  319. package/dist/chunk-AIK5W3IW.js.map +0 -1
  320. package/dist/chunk-FCDWWCLX.js.map +0 -1
  321. package/dist/chunk-WL5EBRDH.js.map +0 -1
  322. package/dist/purge-YSGX5BOG.js.map +0 -1
  323. /package/dist/{chunk-KUJQHXPH.js.map → chunk-2EUVEDF5.js.map} +0 -0
  324. /package/dist/{chunk-EVX44I7C.js.map → chunk-5W4ZLBEZ.js.map} +0 -0
  325. /package/dist/{chunk-P3MH72CI.js.map → chunk-62U4J2GN.js.map} +0 -0
  326. /package/dist/{chunk-YGHMSDLK.js.map → chunk-66772WBP.js.map} +0 -0
  327. /package/dist/{chunk-EP5BVCRI.js.map → chunk-6BNE62PM.js.map} +0 -0
  328. /package/dist/{chunk-AAP5T6QG.js.map → chunk-6DNMUYEE.js.map} +0 -0
  329. /package/dist/{chunk-SG265CVF.js.map → chunk-6FUPCJUL.js.map} +0 -0
  330. /package/dist/{chunk-WZ7UB7XQ.js.map → chunk-6U7F52DE.js.map} +0 -0
  331. /package/dist/{chunk-E4OCKU67.js.map → chunk-7XC2HX75.js.map} +0 -0
  332. /package/dist/{chunk-OVRQLAYR.js.map → chunk-AZ5BTEKX.js.map} +0 -0
  333. /package/dist/{chunk-2HNUMF5V.js.map → chunk-CZRYLSSW.js.map} +0 -0
  334. /package/dist/{chunk-WONS4RZ2.js.map → chunk-FDAMS4PK.js.map} +0 -0
  335. /package/dist/{chunk-Q6VFVAKZ.js.map → chunk-GIBMDSJ2.js.map} +0 -0
  336. /package/dist/{chunk-ZXAGJFHJ.js.map → chunk-H5CPS5JP.js.map} +0 -0
  337. /package/dist/{chunk-NBDCZWP4.js.map → chunk-I5NLEENJ.js.map} +0 -0
  338. /package/dist/{chunk-DRBXHRXE.js.map → chunk-IB26HVAJ.js.map} +0 -0
  339. /package/dist/{chunk-XEQ7OT7U.js.map → chunk-IC6CBHCA.js.map} +0 -0
  340. /package/dist/{chunk-CMRQ34J5.js.map → chunk-JCBWCYEJ.js.map} +0 -0
  341. /package/dist/{chunk-3PDOVUHC.js.map → chunk-KXB4VXHY.js.map} +0 -0
  342. /package/dist/{chunk-G6LBWZRF.js.map → chunk-LBOD4U5B.js.map} +0 -0
  343. /package/dist/{chunk-ZGOQTOYA.js.map → chunk-LGHKJABJ.js.map} +0 -0
  344. /package/dist/{chunk-T3GCXULH.js.map → chunk-M3C2V3PV.js.map} +0 -0
  345. /package/dist/{chunk-OFHFH655.js.map → chunk-MJCGLM25.js.map} +0 -0
  346. /package/dist/{chunk-JDZRYH2N.js.map → chunk-NHWB6HG2.js.map} +0 -0
  347. /package/dist/{chunk-TC3VNKGX.js.map → chunk-NM2WP3B7.js.map} +0 -0
  348. /package/dist/{chunk-IMA2EWLV.js.map → chunk-P5PXWTW7.js.map} +0 -0
  349. /package/dist/{chunk-2QMKMVHH.js.map → chunk-QNWXCJ76.js.map} +0 -0
  350. /package/dist/{chunk-CSMCNOPH.js.map → chunk-SPJXKAVF.js.map} +0 -0
  351. /package/dist/{chunk-4PBVXX7L.js.map → chunk-TH2LSRMG.js.map} +0 -0
  352. /package/dist/{chunk-ESBQWC3U.js.map → chunk-VI2JQPNQ.js.map} +0 -0
  353. /package/dist/{chunk-GGUBDXRR.js.map → chunk-W5EG6LE3.js.map} +0 -0
  354. /package/dist/{chunk-DEBHXHJR.js.map → chunk-WIPEXG6R.js.map} +0 -0
  355. /package/dist/{chunk-SH6YO3LT.js.map → chunk-WVO4G37W.js.map} +0 -0
  356. /package/dist/{chunk-VVIW3PTA.js.map → chunk-YTQNQ4KB.js.map} +0 -0
  357. /package/dist/{chunk-PKRIQL3V.js.map → chunk-YTSNAUXN.js.map} +0 -0
  358. /package/dist/{chunk-QAOGGNE3.js.map → chunk-ZPSVBSOF.js.map} +0 -0
  359. /package/dist/{forget-HRPLVB3W.js.map → forget-4UY2EOKH.js.map} +0 -0
@@ -15,6 +15,7 @@ import { readFileSync } from "node:fs";
15
15
  import { z } from "zod";
16
16
  import { computeSupersessionKey, normalizeSupersessionKey } from "../temporal-supersession.js";
17
17
  import type { EntityFile, MemoryFile } from "../types.js";
18
+ import { log } from "../logger.js";
18
19
  import { isErrnoCode } from "../utils/errno.js";
19
20
  import { withHeldFileLock } from "../utils/serialize-mutations.js";
20
21
  import { RECALL_FALLBACK_DIRS } from "../utils/category-dir.js";
@@ -69,6 +70,14 @@ const EntityCanonicalIdMigrationStateSchema = z.object({
69
70
  version: z.literal(ENTITY_CANONICAL_ID_MIGRATION_VERSION),
70
71
  complete: z.boolean(),
71
72
  mappings: z.record(z.string().min(1)),
73
+ /**
74
+ * Pairs the migration refused to resolve, PARKED rather than dropped.
75
+ * Deleting the record would strand the collision: once an operator removes
76
+ * the legacy file, no later scan can rediscover the mapping, so references
77
+ * still naming the legacy id would never be rewritten. Optional so a journal
78
+ * written by an older build still parses.
79
+ */
80
+ blocked: z.record(z.string().min(1)).optional(),
72
81
  });
73
82
 
74
83
  type EntityCanonicalIdMigrationState = z.infer<typeof EntityCanonicalIdMigrationStateSchema>;
@@ -348,12 +357,28 @@ async function readSafeEntityEntries(entitiesDir: string): Promise<string[]> {
348
357
  return entries;
349
358
  }
350
359
 
360
+ /**
361
+ * Legacy ids the migration cannot resolve on its own, mapped to the canonical
362
+ * id they collide with. Two entity files describing one entity is an ORDINARY
363
+ * operator state, and picking a winner would silently drop whichever side lost.
364
+ * So the pair is skipped and reported: reads of the legacy id keep working
365
+ * exactly as they did before the migration ran.
366
+ */
367
+ export type BlockedEntityPairs = Map<string, string>;
368
+
351
369
  async function discoverMappings(
352
370
  deps: EntityCanonicalIdMigrationDependencies,
353
371
  knownMappings: Readonly<Record<string, string>> = {},
372
+ blocked: BlockedEntityPairs = new Map(),
354
373
  ): Promise<Record<string, string>> {
355
374
  const mappings: Record<string, string> = {};
356
- const canonicalOwners = new Map<string, string>();
375
+ const canonicalOwners = new Map<string, string[]>();
376
+ // Blocks describe THIS scan of the directory, so they are rebuilt per pass.
377
+ // Accumulating them across a run would let a collision another writer has
378
+ // since resolved keep pruning its now-valid mapping: the entity file gets
379
+ // renamed while the pruned mapping skips the reference rewrite, stranding
380
+ // memories on a filename that no longer exists.
381
+ blocked.clear();
357
382
  const entityEntries = await readSafeEntityEntries(deps.entitiesDir);
358
383
  for (const entry of entityEntries) {
359
384
  if (!entry.endsWith(".md")) continue;
@@ -386,18 +411,23 @@ async function discoverMappings(
386
411
  if (canonicalExists) {
387
412
  const canonicalContent = await deps.readStorageSecureFile(canonicalPath);
388
413
  if (entityContent !== canonicalContent) {
389
- throw new Error(`Cannot migrate legacy entity id ${legacyId}: ${canonicalId} already exists.`);
414
+ blocked.set(legacyId, canonicalId);
415
+ continue;
390
416
  }
391
417
  }
392
- const previousOwner = canonicalOwners.get(canonicalId);
393
- if (previousOwner !== undefined && previousOwner !== legacyId) {
394
- throw new Error(
395
- `Cannot migrate legacy entity ids ${previousOwner} and ${legacyId}: both normalize to ${canonicalId}.`,
396
- );
397
- }
398
- canonicalOwners.set(canonicalId, legacyId);
418
+ canonicalOwners.set(canonicalId, [...(canonicalOwners.get(canonicalId) ?? []), legacyId]);
399
419
  mappings[legacyId] = canonicalId;
400
420
  }
421
+ // A canonical id claimed by more than one legacy file has no non-arbitrary
422
+ // winner, and readdir order is not stable (§6) - so the "winner" would differ
423
+ // between hosts reading identical data. Block every claimant instead.
424
+ for (const [canonicalId, claimants] of canonicalOwners) {
425
+ if (claimants.length < 2) continue;
426
+ for (const legacyId of claimants) {
427
+ blocked.set(legacyId, canonicalId);
428
+ delete mappings[legacyId];
429
+ }
430
+ }
401
431
  return mappings;
402
432
  }
403
433
 
@@ -645,7 +675,19 @@ function mergeDiscoveredMappings(
645
675
  for (const [legacyId, canonicalId] of Object.entries(discovered)) {
646
676
  const previousMapping = merged[legacyId];
647
677
  if (previousMapping !== undefined && previousMapping !== canonicalId) {
648
- throw new Error(`Legacy entity id ${legacyId} changed canonical target during migration.`);
678
+ // A -> B collapses to A -> C once B -> C exists, so a rescan that still
679
+ // reads A -> B off disk is reporting the same chain, not a new target.
680
+ // Only a target the chain cannot reach is a real conflict.
681
+ let hop: string | undefined = canonicalId;
682
+ const seen = new Set<string>();
683
+ while (hop !== undefined && hop !== previousMapping && !seen.has(hop)) {
684
+ seen.add(hop);
685
+ hop = merged[hop];
686
+ }
687
+ if (hop !== previousMapping) {
688
+ throw new Error(`Legacy entity id ${legacyId} changed canonical target during migration.`);
689
+ }
690
+ continue;
649
691
  }
650
692
  if (previousMapping === undefined && wouldCreateMappingCycle(merged, legacyId, canonicalId)) continue;
651
693
  const previousOwner = canonicalOwners.get(canonicalId);
@@ -681,6 +723,8 @@ function collapseMappings(mappings: Readonly<Record<string, string>>): Record<st
681
723
  type EntityFileMigrationResult = {
682
724
  deferred: boolean;
683
725
  progressed: boolean;
726
+ /** The pair collided on content; skipped and reported, never migrated. */
727
+ blocked?: boolean;
684
728
  };
685
729
 
686
730
  async function migrateEntityFilePair(
@@ -711,7 +755,9 @@ async function migrateEntityFilePair(
711
755
  deps.isEncryptedStorageFile(canonicalPath),
712
756
  ]);
713
757
  if (legacyContent !== canonicalContent) {
714
- throw new Error(`Cannot migrate legacy entity id ${legacyId}: ${canonicalId} already exists.`);
758
+ // A mapping persisted by an older build, or a file changed since
759
+ // discovery. Same verdict as discovery: skip the pair, keep both files.
760
+ return { deferred: false, progressed: false, blocked: true };
715
761
  }
716
762
  if (legacyEncrypted && !canonicalEncrypted) {
717
763
  if (!(await refreshMigrationLock()) || !(await refreshEntityLock())) {
@@ -792,6 +838,77 @@ export async function migrateLegacyEntityCanonicalIds(
792
838
  mappings: {},
793
839
  };
794
840
  }
841
+ const blocked: BlockedEntityPairs = new Map();
842
+ // ONE aggregated line per run, not one per pair per restart: this used to
843
+ // abort the daemon, so the operator needs the whole list and the remedy.
844
+ const finish = (): Promise<string | undefined> | string | undefined => {
845
+ if (blocked.size > 0) {
846
+ const pairs = [...blocked].map(([legacyId, canonicalId]) => `${legacyId} -> ${canonicalId}`).join(", ");
847
+ log.warn(
848
+ `entity canonical-id migration skipped ${blocked.size} unresolvable pair(s): ${pairs}. `
849
+ + "Both files were kept and the legacy id still resolves; merge or delete one side to migrate it.",
850
+ );
851
+ }
852
+ return deps.readMigrationFingerprint?.();
853
+ };
854
+ /**
855
+ * Drop blocked pairs from the working set. Discovery only refuses to
856
+ * ADD them; a mapping persisted by an earlier run would otherwise still
857
+ * be applied - migrating one claimant and rewriting every reference onto
858
+ * the canonical file, i.e. picking the winner this fix exists to avoid,
859
+ * off stale state rather than what is on disk.
860
+ */
861
+ /** @returns true when a park was promoted back into the mapping set. */
862
+ const pruneBlocked = async (): Promise<boolean> => {
863
+ const current = state;
864
+ if (!current) return false;
865
+ // THIS scan's verdict wins over the journal: normalization can change
866
+ // between runs, so a stale parked target would otherwise be promoted
867
+ // later and rewrite references onto an id that does not exist.
868
+ let revived = false;
869
+ const parked: Record<string, string> = { ...(current.blocked ?? {}) };
870
+ const active: Record<string, string> = {};
871
+ for (const [legacyId, canonicalId] of Object.entries(current.mappings)) {
872
+ if (!blocked.has(legacyId)) active[legacyId] = canonicalId;
873
+ }
874
+ for (const [legacyId, canonicalId] of blocked) parked[legacyId] = canonicalId;
875
+ // A parked pair whose legacy file is gone was resolved by keeping the
876
+ // canonical side. The rename is moot; the reference rewrite is not, and
877
+ // this record is the only thing that can still perform it.
878
+ // A park survives ONLY while this scan re-establishes the collision.
879
+ // Anything else - the scan found a real migration, or found the source
880
+ // needs none (already canonical under a newer normalization) - makes
881
+ // the record obsolete, and keeping it lets a later deletion promote a
882
+ // target the entity never occupied.
883
+ for (const [legacyId, canonicalId] of Object.entries(parked)) {
884
+ if (blocked.has(legacyId)) continue;
885
+ delete parked[legacyId];
886
+ if (active[legacyId] !== undefined) continue;
887
+ const legacyPath = deps.resolveEntityFilePath(legacyId);
888
+ if (legacyPath !== null && (await fileExists(legacyPath))) continue;
889
+ // Source gone: the rename is moot, but references still name it and
890
+ // this record is the only thing that can still rewrite them.
891
+ active[legacyId] = canonicalId;
892
+ revived = true;
893
+ }
894
+ // Reviving a whole chain at once yields A -> B -> C, and each rewrite
895
+ // surface makes a different number of passes over it - so collapse
896
+ // transitively before anything consumes the set.
897
+ const collapsed = collapseMappings(active);
898
+ // Parked targets follow ACTIVE moves only: hopping over a still-blocked
899
+ // link would jump to an id the migration has not been allowed to reach.
900
+ for (const [legacyId, canonicalId] of Object.entries(parked)) {
901
+ const moved = collapsed[canonicalId];
902
+ if (moved !== undefined && moved !== legacyId) parked[legacyId] = moved;
903
+ }
904
+ const same = (a: Record<string, string>, b: Record<string, string>): boolean =>
905
+ Object.keys(a).length === Object.keys(b).length
906
+ && Object.entries(a).every(([key, value]) => b[key] === value);
907
+ if (same(collapsed, current.mappings) && same(parked, current.blocked ?? {})) return revived;
908
+ state = { ...current, mappings: collapsed, blocked: parked };
909
+ await writeState(deps, state);
910
+ return revived;
911
+ };
795
912
  const previousMappings = state.mappings;
796
913
  const collapsedMappings = collapseMappings(previousMappings);
797
914
  const mappingsChanged =
@@ -804,11 +921,12 @@ export async function migrateLegacyEntityCanonicalIds(
804
921
  if (!(await lock.refresh())) throw new Error("Lost entity canonical-id migration lock.");
805
922
  const discoveredBefore = rejectMappingCycles(
806
923
  state.mappings,
807
- await discoverMappings(deps, state.mappings),
924
+ await discoverMappings(deps, state.mappings, blocked),
808
925
  );
926
+ await pruneBlocked();
809
927
  const mergedBefore = collapseMappings(mergeDiscoveredMappings(state.mappings, discoveredBefore));
810
928
  if (state.complete && Object.keys(discoveredBefore).length === 0 && !mappingsChanged) {
811
- if (Object.keys(state.mappings).length === 0) return deps.readMigrationFingerprint?.();
929
+ if (Object.keys(state.mappings).length === 0) return finish();
812
930
  const rewroteColdMemory = await rewriteKnownReferences(
813
931
  deps,
814
932
  state.mappings,
@@ -818,7 +936,7 @@ export async function migrateLegacyEntityCanonicalIds(
818
936
  deps.invalidateAllMemoriesCache();
819
937
  if (rewroteColdMemory) deps.invalidateColdMemoriesCache();
820
938
  deps.bumpMemoryStatusVersion();
821
- return deps.readMigrationFingerprint?.();
939
+ return finish();
822
940
  }
823
941
  if (
824
942
  state.complete
@@ -832,11 +950,16 @@ export async function migrateLegacyEntityCanonicalIds(
832
950
  if (!(await lock.refresh())) throw new Error("Lost entity canonical-id migration lock.");
833
951
  const discoveredAfter = rejectMappingCycles(
834
952
  state.mappings,
835
- await discoverMappings(deps, state.mappings),
953
+ await discoverMappings(deps, state.mappings, blocked),
836
954
  );
837
- if (Object.keys(discoveredAfter).length === 0) {
955
+ // Reconcile before declaring completion: this rescan can resolve a
956
+ // park (another writer removed the legacy file), and completing
957
+ // without promoting it strands its references behind a fingerprint
958
+ // that already reflects the deletion - so no later run revisits it.
959
+ const revivedInRescan = await pruneBlocked();
960
+ if (Object.keys(discoveredAfter).length === 0 && !revivedInRescan) {
838
961
  await writeState(deps, { ...state, complete: true });
839
- return deps.readMigrationFingerprint?.();
962
+ return finish();
840
963
  }
841
964
  state = {
842
965
  ...state,
@@ -857,9 +980,8 @@ export async function migrateLegacyEntityCanonicalIds(
857
980
  canonicalId,
858
981
  () => lock.refresh(),
859
982
  );
860
- if (result.deferred) {
861
- deferredMappings.push([legacyId, canonicalId]);
862
- }
983
+ if (result.blocked) blocked.set(legacyId, canonicalId);
984
+ else if (result.deferred) deferredMappings.push([legacyId, canonicalId]);
863
985
  progressed ||= result.progressed;
864
986
  }
865
987
  if (deferredMappings.length === 0) break;
@@ -871,6 +993,7 @@ export async function migrateLegacyEntityCanonicalIds(
871
993
  }
872
994
  pendingMappings = deferredMappings;
873
995
  }
996
+ await pruneBlocked();
874
997
 
875
998
  const rewroteColdMemory = await rewriteKnownReferences(
876
999
  deps,
@@ -885,11 +1008,16 @@ export async function migrateLegacyEntityCanonicalIds(
885
1008
  if (!(await lock.refresh())) throw new Error("Lost entity canonical-id migration lock.");
886
1009
  const discoveredAfter = rejectMappingCycles(
887
1010
  state.mappings,
888
- await discoverMappings(deps, state.mappings),
1011
+ await discoverMappings(deps, state.mappings, blocked),
889
1012
  );
890
- if (Object.keys(discoveredAfter).length === 0) {
1013
+ // A park resolved after the rewrite pass is promoted here, and a
1014
+ // promotion still has to be APPLIED. Completing on `discoveredAfter`
1015
+ // alone fingerprints the post-deletion corpus, so the runner never
1016
+ // retries and those references stay stranded.
1017
+ const revivedAfterRewrite = await pruneBlocked();
1018
+ if (Object.keys(discoveredAfter).length === 0 && !revivedAfterRewrite) {
891
1019
  await writeState(deps, { ...state, complete: true });
892
- return deps.readMigrationFingerprint?.();
1020
+ return finish();
893
1021
  }
894
1022
  state = {
895
1023
  ...state,