@remnic/core 9.52.2 → 9.54.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 (429) hide show
  1. package/dist/access-admin-ops-surface.d.ts +11 -11
  2. package/dist/access-admin-ops-surface.js +22 -22
  3. package/dist/access-authorization-probe.d.ts +11 -11
  4. package/dist/access-authorization-probe.js +23 -23
  5. package/dist/access-boundary.d.ts +11 -11
  6. package/dist/access-boundary.js +22 -22
  7. package/dist/access-cli.js +55 -55
  8. package/dist/access-coding-context-resolution.d.ts +1 -1
  9. package/dist/access-extraction-force-flush.d.ts +11 -11
  10. package/dist/access-extraction-force-flush.js +22 -22
  11. package/dist/access-health-types.d.ts +1 -1
  12. package/dist/access-http-lcm-compaction.d.ts +11 -11
  13. package/dist/access-http-lifecycle-flush.d.ts +11 -11
  14. package/dist/access-http-offline-stream.d.ts +11 -11
  15. package/dist/access-http-query.js +22 -22
  16. package/dist/access-http.d.ts +11 -11
  17. package/dist/access-http.js +29 -29
  18. package/dist/access-identity-continuity-surface.d.ts +9 -9
  19. package/dist/access-identity-continuity-surface.js +22 -22
  20. package/dist/access-lcm-surface.d.ts +11 -11
  21. package/dist/access-lcm-surface.js +22 -22
  22. package/dist/access-mcp.d.ts +11 -11
  23. package/dist/access-mcp.js +27 -27
  24. package/dist/access-memory-search-fanout.d.ts +2 -2
  25. package/dist/{access-namespace-preflight-Ds6CGlCP.d.ts → access-namespace-preflight-C7n4tgWC.d.ts} +1 -1
  26. package/dist/access-namespace-preflight.d.ts +3 -3
  27. package/dist/access-namespace-preflight.js +22 -22
  28. package/dist/access-observe-write-surface.d.ts +11 -11
  29. package/dist/access-observe-write-surface.js +22 -22
  30. package/dist/access-offline-manifest.d.ts +9 -9
  31. package/dist/access-offline-manifest.js +8 -4
  32. package/dist/access-operations-batch.js +24 -24
  33. package/dist/access-operations.d.ts +14 -14
  34. package/dist/access-operations.js +26 -26
  35. package/dist/access-recall-concurrency.d.ts +11 -11
  36. package/dist/access-recall-concurrency.js +22 -22
  37. package/dist/access-recall-response.d.ts +11 -11
  38. package/dist/access-recall-response.js +22 -22
  39. package/dist/access-recall-surface.d.ts +11 -11
  40. package/dist/access-recall-surface.js +22 -22
  41. package/dist/access-schema.d.ts +88 -88
  42. package/dist/{access-service-Cbk3bNbD.d.ts → access-service-CXvbxLK-.d.ts} +7 -7
  43. package/dist/access-service-helpers.d.ts +11 -11
  44. package/dist/access-service.d.ts +11 -11
  45. package/dist/access-service.js +22 -22
  46. package/dist/access-surface-catalog.d.ts +11 -11
  47. package/dist/access-wearables-meetings-surface.d.ts +3 -3
  48. package/dist/action-confidence.d.ts +1 -1
  49. package/dist/active-memory-bridge.d.ts +1 -1
  50. package/dist/active-recall.d.ts +1 -1
  51. package/dist/active-recall.js +5 -5
  52. package/dist/ambient-provenance.d.ts +1 -1
  53. package/dist/artifact-search.d.ts +1 -1
  54. package/dist/{auto-sync-QFQGOEO2.js → auto-sync-TDHLZPVP.js} +7 -7
  55. package/dist/behavior-learner.d.ts +1 -1
  56. package/dist/behavior-signals.d.ts +1 -1
  57. package/dist/bootstrap.d.ts +9 -9
  58. package/dist/briefing.d.ts +2 -2
  59. package/dist/briefing.js +12 -12
  60. package/dist/buffer-surprise-report.d.ts +1 -1
  61. package/dist/buffer-turn-helpers.d.ts +1 -1
  62. package/dist/buffer.d.ts +2 -2
  63. package/dist/bulk-import/index.d.ts +3 -3
  64. package/dist/calibration.d.ts +1 -1
  65. package/dist/capabilities.d.ts +1 -1
  66. package/dist/{catalog-D3B4RDy1.d.ts → catalog-BOOxl-I2.d.ts} +1 -1
  67. package/dist/causal-behavior.d.ts +1 -1
  68. package/dist/causal-consolidation.d.ts +1 -1
  69. package/dist/causal-consolidation.js +13 -13
  70. package/dist/causal-trajectory-graph.d.ts +1 -1
  71. package/dist/{chunk-MLXZD4WM.js → chunk-2GFK22OZ.js} +2 -2
  72. package/dist/{chunk-RANKJI5T.js → chunk-3JLPGJ43.js} +2 -2
  73. package/dist/{chunk-O5FFBO2M.js → chunk-47P3RYZP.js} +70 -8
  74. package/dist/{chunk-O5FFBO2M.js.map → chunk-47P3RYZP.js.map} +1 -1
  75. package/dist/{chunk-X7XEDOSL.js → chunk-4IIFL7GC.js} +8 -8
  76. package/dist/chunk-5FVVY2EB.js +27 -0
  77. package/dist/chunk-5FVVY2EB.js.map +1 -0
  78. package/dist/{chunk-GXSOUIA4.js → chunk-5WQMORU5.js} +4 -4
  79. package/dist/{chunk-J272WKX2.js → chunk-6HPHEFXT.js} +2 -2
  80. package/dist/{chunk-B6LZ4IBH.js → chunk-6LAPLZOS.js} +2 -2
  81. package/dist/{chunk-WD5B5AIE.js → chunk-6R4G7N4S.js} +118 -173
  82. package/dist/chunk-6R4G7N4S.js.map +1 -0
  83. package/dist/{chunk-VXCNQYTC.js → chunk-APPFNGX6.js} +2 -2
  84. package/dist/{chunk-GXFSQ6SD.js → chunk-C4ZNGVK3.js} +2 -2
  85. package/dist/{chunk-JSEJH2YQ.js → chunk-CGVHPCP2.js} +2 -2
  86. package/dist/{chunk-BQIFZ2MP.js → chunk-CX5SW2EW.js} +41 -24
  87. package/dist/chunk-CX5SW2EW.js.map +1 -0
  88. package/dist/{chunk-RMHMUUBW.js → chunk-CYF6WVE7.js} +105 -49
  89. package/dist/{chunk-RMHMUUBW.js.map → chunk-CYF6WVE7.js.map} +1 -1
  90. package/dist/{chunk-TEMSWHQD.js → chunk-DZD576ZU.js} +5 -5
  91. package/dist/{chunk-AMTEYNYK.js → chunk-EVWWT3KE.js} +4 -4
  92. package/dist/{chunk-P2KBDJJ6.js → chunk-G2LUMAUF.js} +4 -3
  93. package/dist/{chunk-P2KBDJJ6.js.map → chunk-G2LUMAUF.js.map} +1 -1
  94. package/dist/{chunk-AXIDQG5A.js → chunk-G4T7L557.js} +5 -5
  95. package/dist/{chunk-7M6NYQWB.js → chunk-G7Z6EENO.js} +4 -4
  96. package/dist/{chunk-IARXXZU4.js → chunk-HOIRB77A.js} +99 -20
  97. package/dist/chunk-HOIRB77A.js.map +1 -0
  98. package/dist/{chunk-NDAH7BJ5.js → chunk-HVP33QVW.js} +103 -6
  99. package/dist/chunk-HVP33QVW.js.map +1 -0
  100. package/dist/{chunk-YXKVLYXU.js → chunk-HWRD23DW.js} +2 -2
  101. package/dist/{chunk-SOEN6KCF.js → chunk-IBKR2TFR.js} +2 -2
  102. package/dist/{chunk-R3DJVOSM.js → chunk-JDSVLVCG.js} +8 -1
  103. package/dist/chunk-JDSVLVCG.js.map +1 -0
  104. package/dist/{chunk-F4EU6VUC.js → chunk-JDZPNCMA.js} +2 -2
  105. package/dist/{chunk-D5YOZ66N.js → chunk-JV5YUBIZ.js} +20 -20
  106. package/dist/{chunk-DLG5V6ND.js → chunk-K4QS7LXU.js} +4 -7
  107. package/dist/chunk-K4QS7LXU.js.map +1 -0
  108. package/dist/{chunk-BAKXNQ3C.js → chunk-KRTY3ENI.js} +2 -2
  109. package/dist/{chunk-NK5RGJ65.js → chunk-L4DLLKPN.js} +2 -2
  110. package/dist/{chunk-VFSAWRMZ.js → chunk-LJS7KUPV.js} +2 -2
  111. package/dist/{chunk-JJRVPWFY.js → chunk-MLPTFODV.js} +166 -37
  112. package/dist/chunk-MLPTFODV.js.map +1 -0
  113. package/dist/{chunk-NOEMGE56.js → chunk-NH5IR2WM.js} +2 -2
  114. package/dist/{chunk-5V6IXHPI.js → chunk-NSVDUN76.js} +2 -2
  115. package/dist/{chunk-W7Y5JDVB.js → chunk-PDDTI7IC.js} +4 -4
  116. package/dist/{chunk-QINJITDS.js → chunk-PX2LSHYM.js} +2 -2
  117. package/dist/{chunk-HDIUYMSB.js → chunk-QWGE2PUH.js} +6 -6
  118. package/dist/{chunk-X57M2Q4I.js → chunk-RDJRFDJY.js} +3 -3
  119. package/dist/{chunk-RYLEDKQ2.js → chunk-RUMNY5DT.js} +3 -3
  120. package/dist/{chunk-BKIFTXHR.js → chunk-RZ4XGKOJ.js} +2 -2
  121. package/dist/{chunk-66SE3BNH.js → chunk-SUPEYLH2.js} +2 -2
  122. package/dist/{chunk-BF6SXNQJ.js → chunk-T2JHZWH6.js} +20 -20
  123. package/dist/{chunk-VHFXP27N.js → chunk-THPPCISA.js} +60 -23
  124. package/dist/chunk-THPPCISA.js.map +1 -0
  125. package/dist/{chunk-QPOHMO6M.js → chunk-UES4BHA2.js} +2 -2
  126. package/dist/{chunk-XAPMEU3K.js → chunk-UU7TRFNE.js} +2 -2
  127. package/dist/{chunk-QBSFOKY6.js → chunk-VOELBUS4.js} +4 -4
  128. package/dist/{chunk-2LY6GIIE.js → chunk-WDBX6VER.js} +2 -2
  129. package/dist/{chunk-BMEYMKWX.js → chunk-WM65LU67.js} +2 -2
  130. package/dist/{chunk-WLRD2TXF.js → chunk-WOPA3SGI.js} +4 -4
  131. package/dist/{chunk-5UZ6UCOZ.js → chunk-XUAMCLY4.js} +3 -3
  132. package/dist/{chunk-7HXZJAID.js → chunk-YGLY6QFV.js} +3 -3
  133. package/dist/{chunk-2OIQDTDC.js → chunk-ZPJ4QSGP.js} +2 -2
  134. package/dist/{chunk-3OY7KXHM.js → chunk-ZYLC7NFO.js} +3 -3
  135. package/dist/{cli-DMAFI0qt.d.ts → cli-DVUFIa5E.d.ts} +5 -5
  136. package/dist/cli.d.ts +13 -13
  137. package/dist/cli.js +42 -42
  138. package/dist/coding/pre-action-gate.d.ts +1 -1
  139. package/dist/compounding/engine.d.ts +2 -2
  140. package/dist/compounding/engine.js +13 -13
  141. package/dist/compounding/preference-consolidator.d.ts +1 -1
  142. package/dist/compression-optimizer.d.ts +1 -1
  143. package/dist/config.d.ts +1 -1
  144. package/dist/config.js +5 -5
  145. package/dist/connectors/codex-materialize-runner.d.ts +1 -1
  146. package/dist/connectors/codex-materialize-runner.js +12 -12
  147. package/dist/connectors/codex-materialize.d.ts +1 -1
  148. package/dist/connectors/index.d.ts +1 -1
  149. package/dist/connectors/index.js +12 -12
  150. package/dist/consolidation-provenance-check.d.ts +2 -2
  151. package/dist/consolidation-undo.d.ts +2 -2
  152. package/dist/content-hash.d.ts +12 -2
  153. package/dist/content-hash.js +9 -3
  154. package/dist/contradiction/index.d.ts +2 -2
  155. package/dist/contradiction/index.js +3 -3
  156. package/dist/converge-config.d.ts +1 -1
  157. package/dist/convergence-refresh.d.ts +2 -2
  158. package/dist/convergence-refresh.js +14 -14
  159. package/dist/conversation-index/backend.d.ts +1 -1
  160. package/dist/conversation-index/chunker.d.ts +1 -1
  161. package/dist/conversation-index/faiss-adapter.d.ts +1 -1
  162. package/dist/conversation-index/indexer.d.ts +1 -1
  163. package/dist/conversation-index/search.d.ts +1 -1
  164. package/dist/corpus-watermark.d.ts +1 -1
  165. package/dist/corpus-watermark.js +14 -14
  166. package/dist/day-summary.d.ts +1 -1
  167. package/dist/delinearize.d.ts +1 -1
  168. package/dist/dependency-propagation-config.d.ts +1 -1
  169. package/dist/{dependency-propagation-delivery-D63r24pH.d.ts → dependency-propagation-delivery-XzF76C9n.d.ts} +1 -1
  170. package/dist/direct-answer-wiring.d.ts +1 -1
  171. package/dist/direct-answer.d.ts +1 -1
  172. package/dist/embedding-fallback.d.ts +1 -1
  173. package/dist/enrichment/index.d.ts +1 -1
  174. package/dist/entity-retrieval.d.ts +2 -2
  175. package/dist/entity-retrieval.js +12 -12
  176. package/dist/entity-schema.d.ts +1 -1
  177. package/dist/explicit-capture.d.ts +9 -9
  178. package/dist/explicit-capture.js +8 -8
  179. package/dist/external-wiki-access.d.ts +11 -11
  180. package/dist/external-wiki-access.js +23 -23
  181. package/dist/external-wiki-collection-registration.d.ts +1 -1
  182. package/dist/external-wiki-collection.d.ts +1 -1
  183. package/dist/external-wiki-mcp-tools.d.ts +11 -11
  184. package/dist/extraction-error-classification.d.ts +1 -1
  185. package/dist/extraction-faithfulness.d.ts +1 -1
  186. package/dist/extraction-judge-telemetry.d.ts +1 -1
  187. package/dist/extraction-judge-training.d.ts +1 -1
  188. package/dist/extraction-judge.d.ts +1 -1
  189. package/dist/extraction-liveness.d.ts +1 -1
  190. package/dist/extraction-normalization.d.ts +1 -1
  191. package/dist/extraction-normalization.js +2 -2
  192. package/dist/extraction-prompt.d.ts +1 -1
  193. package/dist/extraction-source-grounding-rules.d.ts +1 -1
  194. package/dist/extraction-source-grounding.d.ts +1 -1
  195. package/dist/extraction-source-grounding.js +3 -3
  196. package/dist/extraction.d.ts +1 -1
  197. package/dist/extraction.js +16 -16
  198. package/dist/fallback-llm.d.ts +1 -1
  199. package/dist/{forget-HDS4N6CG.js → forget-EHGGJZLX.js} +3 -2
  200. package/dist/{forget-HDS4N6CG.js.map → forget-EHGGJZLX.js.map} +1 -1
  201. package/dist/graph-dashboard-diff.d.ts +1 -1
  202. package/dist/graph-dashboard-key.d.ts +1 -1
  203. package/dist/graph-dashboard-parser.d.ts +1 -1
  204. package/dist/graph-edge-reinforcement.d.ts +1 -1
  205. package/dist/graph-path-reconstruction.d.ts +1 -1
  206. package/dist/graph-path-scoring.d.ts +1 -1
  207. package/dist/graph-snapshot.d.ts +1 -1
  208. package/dist/graph.d.ts +1 -1
  209. package/dist/harmonic-construction.js +2 -2
  210. package/dist/harmonic-retrieval.js +4 -4
  211. package/dist/importance.d.ts +1 -1
  212. package/dist/importers/index.d.ts +1 -1
  213. package/dist/in-flight-reads.d.ts +1 -1
  214. package/dist/index.d.ts +777 -705
  215. package/dist/index.js +77 -67
  216. package/dist/intent.d.ts +1 -1
  217. package/dist/lcm/engine.d.ts +1 -1
  218. package/dist/lcm/index.d.ts +1 -1
  219. package/dist/lcm/tools.d.ts +1 -1
  220. package/dist/lifecycle.d.ts +1 -1
  221. package/dist/live-connectors-runner.d.ts +1 -1
  222. package/dist/local-llm.d.ts +1 -1
  223. package/dist/local-model-endpoint.d.ts +1 -1
  224. package/dist/maintenance/memory-governance.d.ts +1 -1
  225. package/dist/maintenance/memory-governance.js +12 -12
  226. package/dist/maintenance/rebuild-memory-lifecycle-ledger.d.ts +2 -2
  227. package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +12 -12
  228. package/dist/maintenance/rebuild-memory-projection.d.ts +2 -2
  229. package/dist/maintenance/rebuild-memory-projection.js +13 -13
  230. package/dist/{maintenance-kBII2qUI.d.ts → maintenance-BJzNIKBE.d.ts} +3 -3
  231. package/dist/mcp-memory-inspector-app.d.ts +11 -11
  232. package/dist/memory-action-policy.d.ts +1 -1
  233. package/dist/memory-cache.d.ts +1 -1
  234. package/dist/memory-lifecycle-ledger-utils.d.ts +1 -1
  235. package/dist/memory-projection-store.d.ts +1 -1
  236. package/dist/memory-provenance.d.ts +1 -1
  237. package/dist/memory-snapshot.d.ts +1 -1
  238. package/dist/memory-worth-outcomes.d.ts +2 -2
  239. package/dist/models-json.d.ts +1 -1
  240. package/dist/namespaces/migrate.d.ts +3 -3
  241. package/dist/namespaces/migrate.js +13 -13
  242. package/dist/namespaces/principal.d.ts +1 -1
  243. package/dist/namespaces/search.d.ts +1 -1
  244. package/dist/namespaces/storage.d.ts +3 -3
  245. package/dist/namespaces/storage.js +12 -12
  246. package/dist/native-knowledge.d.ts +1 -1
  247. package/dist/offline-sync-impression-drain.d.ts +1 -1
  248. package/dist/operator-doctor-corpus.d.ts +1 -1
  249. package/dist/operator-doctor-corpus.js +15 -15
  250. package/dist/operator-doctor-replica.d.ts +1 -1
  251. package/dist/operator-toolkit.d.ts +3 -3
  252. package/dist/operator-toolkit.js +21 -21
  253. package/dist/orchestration/compression-guideline-coordinator.d.ts +2 -2
  254. package/dist/orchestration/maintenance.d.ts +4 -4
  255. package/dist/orchestration/maintenance.js +17 -17
  256. package/dist/{orchestrator-DHy5LtTy.d.ts → orchestrator-BiXgBJBQ.d.ts} +8 -8
  257. package/dist/orchestrator.d.ts +9 -9
  258. package/dist/orchestrator.js +55 -55
  259. package/dist/patterns-cli.d.ts +1 -1
  260. package/dist/{pipeline-D21Rs6gW.d.ts → pipeline-sz_dcuLg.d.ts} +1 -1
  261. package/dist/policy-runtime.d.ts +1 -1
  262. package/dist/proactive-contention.d.ts +1 -1
  263. package/dist/provenance.d.ts +1 -1
  264. package/dist/provenance.js +2 -2
  265. package/dist/{qmd-Dhle1P4X.d.ts → qmd-eAWObK4M.d.ts} +1 -1
  266. package/dist/qmd-preflight.d.ts +2 -2
  267. package/dist/qmd-recall-cache.d.ts +1 -1
  268. package/dist/qmd.d.ts +2 -2
  269. package/dist/recall-concurrency-config.d.ts +1 -1
  270. package/dist/recall-disclosure-escalation.d.ts +1 -1
  271. package/dist/recall-explain-renderer.d.ts +1 -1
  272. package/dist/recall-memory-map.d.ts +1 -1
  273. package/dist/recall-planner-llm.d.ts +1 -1
  274. package/dist/recall-state.d.ts +1 -1
  275. package/dist/recall-tag-filter.d.ts +1 -1
  276. package/dist/recall-timings.d.ts +1 -1
  277. package/dist/recall-xray-cli.d.ts +1 -1
  278. package/dist/recall-xray-renderer.d.ts +1 -1
  279. package/dist/recall-xray.d.ts +1 -1
  280. package/dist/reconcile/cursor.d.ts +1 -1
  281. package/dist/reconcile/manifest.d.ts +4 -2
  282. package/dist/reconcile/manifest.js +7 -3
  283. package/dist/reconcile/plan.d.ts +1 -1
  284. package/dist/replay/normalizers/chatgpt.d.ts +1 -1
  285. package/dist/replay/normalizers/claude.d.ts +1 -1
  286. package/dist/replay/normalizers/openclaw.d.ts +1 -1
  287. package/dist/replay/normalizers/shared.d.ts +1 -1
  288. package/dist/replay/runner.d.ts +1 -1
  289. package/dist/replay/types.d.ts +1 -1
  290. package/dist/replica-divergence.d.ts +1 -1
  291. package/dist/replica-peers-config.d.ts +1 -1
  292. package/dist/{resolution-MDPNOEG6.js → resolution-MMOD5WC4.js} +4 -4
  293. package/dist/resolve-auth-token.d.ts +1 -1
  294. package/dist/resume-bundles.js +6 -6
  295. package/dist/retrieval-agents.d.ts +2 -2
  296. package/dist/retrieval-tiers.d.ts +1 -1
  297. package/dist/routing/engine.d.ts +1 -1
  298. package/dist/routing/store.d.ts +1 -1
  299. package/dist/salvage-envelope.d.ts +1 -1
  300. package/dist/salvage-envelope.js +3 -3
  301. package/dist/schemas.d.ts +138 -138
  302. package/dist/{scope-profiles-NzGPDXLn.d.ts → scope-profiles-BBQsXuyj.d.ts} +1 -1
  303. package/dist/search/embed-helper.d.ts +1 -1
  304. package/dist/search/factory.d.ts +1 -1
  305. package/dist/search/index.d.ts +1 -1
  306. package/dist/search/lancedb-backend.d.ts +1 -1
  307. package/dist/search/meilisearch-backend.d.ts +1 -1
  308. package/dist/search/noop-backend.d.ts +1 -1
  309. package/dist/search/orama-backend.d.ts +1 -1
  310. package/dist/search/port.d.ts +1 -1
  311. package/dist/search/remote-backend.d.ts +1 -1
  312. package/dist/{semantic-consolidation-DLDKvyy5.d.ts → semantic-consolidation-HD8RkzVA.d.ts} +1 -1
  313. package/dist/semantic-consolidation.d.ts +2 -2
  314. package/dist/semantic-consolidation.js +13 -13
  315. package/dist/semantic-rule-promotion.js +12 -12
  316. package/dist/semantic-rule-verifier.d.ts +1 -1
  317. package/dist/semantic-rule-verifier.js +12 -12
  318. package/dist/{service-PT2_z7xm.d.ts → service-DIrtHHEg.d.ts} +2 -2
  319. package/dist/session-observer-bands.d.ts +1 -1
  320. package/dist/session-observer-state.d.ts +1 -1
  321. package/dist/shared-context/manager.d.ts +9 -9
  322. package/dist/signal.d.ts +1 -1
  323. package/dist/source-agent-qualifier.d.ts +1 -1
  324. package/dist/source-agent-qualifier.js +14 -14
  325. package/dist/{storage-BmVudhk4.d.ts → storage-DqCzXi56.d.ts} +37 -33
  326. package/dist/storage.d.ts +2 -2
  327. package/dist/storage.js +14 -14
  328. package/dist/structured-attributes.d.ts +3 -1
  329. package/dist/structured-attributes.js +3 -1
  330. package/dist/summarizer.d.ts +1 -1
  331. package/dist/summary-snapshot.d.ts +1 -1
  332. package/dist/temporal-supersession.d.ts +2 -2
  333. package/dist/temporal-timeline-recall.d.ts +1 -1
  334. package/dist/temporal-validity.d.ts +1 -1
  335. package/dist/threading.d.ts +1 -1
  336. package/dist/tier-migration.d.ts +2 -2
  337. package/dist/tier-routing.d.ts +1 -1
  338. package/dist/topics.d.ts +1 -1
  339. package/dist/transcript.d.ts +1 -1
  340. package/dist/transfer/types.d.ts +66 -66
  341. package/dist/trust-score-stage.d.ts +1 -1
  342. package/dist/trust-score.d.ts +1 -1
  343. package/dist/{types-CkiDUorT.d.ts → types-d_j4vC6N.d.ts} +26 -1
  344. package/dist/types.d.ts +1 -1
  345. package/dist/utility-runtime.d.ts +1 -1
  346. package/dist/verified-recall.js +12 -12
  347. package/dist/write-envelope.d.ts +1 -1
  348. package/dist/write-envelope.js +2 -2
  349. package/package.json +2 -2
  350. package/src/access-offline-manifest.ts +1 -0
  351. package/src/access-service-offline-file-content.test.ts +1 -0
  352. package/src/content-hash.ts +34 -1
  353. package/src/dedup/index.test.ts +56 -38
  354. package/src/dedup/index.ts +85 -38
  355. package/src/lifecycle/tombstones.test.ts +763 -16
  356. package/src/lifecycle/tombstones.ts +217 -50
  357. package/src/reconcile/manifest.test.ts +158 -1
  358. package/src/reconcile/manifest.ts +76 -22
  359. package/src/storage/content-hash-index.ts +56 -40
  360. package/src/storage/entity-ref-repair.ts +3 -3
  361. package/src/storage/memory-read-store.ts +9 -0
  362. package/src/storage/tombstone-blocked-capture-index.ts +4 -9
  363. package/src/storage-contract/content-hash.test.ts +13 -0
  364. package/src/storage-fact-hash-index-defer.test.ts +1 -1
  365. package/src/storage.ts +107 -93
  366. package/src/structured-attributes.ts +11 -0
  367. package/src/wearables/cleanup.test.ts +71 -0
  368. package/src/wearables/cleanup.ts +163 -16
  369. package/src/wearables/config.test.ts +62 -0
  370. package/src/wearables/config.ts +99 -5
  371. package/src/wearables/index.ts +10 -0
  372. package/src/wearables/pipeline.test.ts +36 -0
  373. package/src/wearables/pipeline.ts +18 -3
  374. package/src/wearables/redaction.test.ts +156 -0
  375. package/src/wearables/redaction.ts +102 -10
  376. package/src/wearables/text-language.ts +146 -0
  377. package/src/wearables/types.ts +26 -0
  378. package/dist/chunk-BQIFZ2MP.js.map +0 -1
  379. package/dist/chunk-DLG5V6ND.js.map +0 -1
  380. package/dist/chunk-IARXXZU4.js.map +0 -1
  381. package/dist/chunk-JJRVPWFY.js.map +0 -1
  382. package/dist/chunk-NDAH7BJ5.js.map +0 -1
  383. package/dist/chunk-R3DJVOSM.js.map +0 -1
  384. package/dist/chunk-VHFXP27N.js.map +0 -1
  385. package/dist/chunk-W5H6ZRPT.js +0 -14
  386. package/dist/chunk-W5H6ZRPT.js.map +0 -1
  387. package/dist/chunk-WD5B5AIE.js.map +0 -1
  388. /package/dist/{auto-sync-QFQGOEO2.js.map → auto-sync-TDHLZPVP.js.map} +0 -0
  389. /package/dist/{chunk-MLXZD4WM.js.map → chunk-2GFK22OZ.js.map} +0 -0
  390. /package/dist/{chunk-RANKJI5T.js.map → chunk-3JLPGJ43.js.map} +0 -0
  391. /package/dist/{chunk-X7XEDOSL.js.map → chunk-4IIFL7GC.js.map} +0 -0
  392. /package/dist/{chunk-GXSOUIA4.js.map → chunk-5WQMORU5.js.map} +0 -0
  393. /package/dist/{chunk-J272WKX2.js.map → chunk-6HPHEFXT.js.map} +0 -0
  394. /package/dist/{chunk-B6LZ4IBH.js.map → chunk-6LAPLZOS.js.map} +0 -0
  395. /package/dist/{chunk-VXCNQYTC.js.map → chunk-APPFNGX6.js.map} +0 -0
  396. /package/dist/{chunk-GXFSQ6SD.js.map → chunk-C4ZNGVK3.js.map} +0 -0
  397. /package/dist/{chunk-JSEJH2YQ.js.map → chunk-CGVHPCP2.js.map} +0 -0
  398. /package/dist/{chunk-TEMSWHQD.js.map → chunk-DZD576ZU.js.map} +0 -0
  399. /package/dist/{chunk-AMTEYNYK.js.map → chunk-EVWWT3KE.js.map} +0 -0
  400. /package/dist/{chunk-AXIDQG5A.js.map → chunk-G4T7L557.js.map} +0 -0
  401. /package/dist/{chunk-7M6NYQWB.js.map → chunk-G7Z6EENO.js.map} +0 -0
  402. /package/dist/{chunk-YXKVLYXU.js.map → chunk-HWRD23DW.js.map} +0 -0
  403. /package/dist/{chunk-SOEN6KCF.js.map → chunk-IBKR2TFR.js.map} +0 -0
  404. /package/dist/{chunk-F4EU6VUC.js.map → chunk-JDZPNCMA.js.map} +0 -0
  405. /package/dist/{chunk-D5YOZ66N.js.map → chunk-JV5YUBIZ.js.map} +0 -0
  406. /package/dist/{chunk-BAKXNQ3C.js.map → chunk-KRTY3ENI.js.map} +0 -0
  407. /package/dist/{chunk-NK5RGJ65.js.map → chunk-L4DLLKPN.js.map} +0 -0
  408. /package/dist/{chunk-VFSAWRMZ.js.map → chunk-LJS7KUPV.js.map} +0 -0
  409. /package/dist/{chunk-NOEMGE56.js.map → chunk-NH5IR2WM.js.map} +0 -0
  410. /package/dist/{chunk-5V6IXHPI.js.map → chunk-NSVDUN76.js.map} +0 -0
  411. /package/dist/{chunk-W7Y5JDVB.js.map → chunk-PDDTI7IC.js.map} +0 -0
  412. /package/dist/{chunk-QINJITDS.js.map → chunk-PX2LSHYM.js.map} +0 -0
  413. /package/dist/{chunk-HDIUYMSB.js.map → chunk-QWGE2PUH.js.map} +0 -0
  414. /package/dist/{chunk-X57M2Q4I.js.map → chunk-RDJRFDJY.js.map} +0 -0
  415. /package/dist/{chunk-RYLEDKQ2.js.map → chunk-RUMNY5DT.js.map} +0 -0
  416. /package/dist/{chunk-BKIFTXHR.js.map → chunk-RZ4XGKOJ.js.map} +0 -0
  417. /package/dist/{chunk-66SE3BNH.js.map → chunk-SUPEYLH2.js.map} +0 -0
  418. /package/dist/{chunk-BF6SXNQJ.js.map → chunk-T2JHZWH6.js.map} +0 -0
  419. /package/dist/{chunk-QPOHMO6M.js.map → chunk-UES4BHA2.js.map} +0 -0
  420. /package/dist/{chunk-XAPMEU3K.js.map → chunk-UU7TRFNE.js.map} +0 -0
  421. /package/dist/{chunk-QBSFOKY6.js.map → chunk-VOELBUS4.js.map} +0 -0
  422. /package/dist/{chunk-2LY6GIIE.js.map → chunk-WDBX6VER.js.map} +0 -0
  423. /package/dist/{chunk-BMEYMKWX.js.map → chunk-WM65LU67.js.map} +0 -0
  424. /package/dist/{chunk-WLRD2TXF.js.map → chunk-WOPA3SGI.js.map} +0 -0
  425. /package/dist/{chunk-5UZ6UCOZ.js.map → chunk-XUAMCLY4.js.map} +0 -0
  426. /package/dist/{chunk-7HXZJAID.js.map → chunk-YGLY6QFV.js.map} +0 -0
  427. /package/dist/{chunk-2OIQDTDC.js.map → chunk-ZPJ4QSGP.js.map} +0 -0
  428. /package/dist/{chunk-3OY7KXHM.js.map → chunk-ZYLC7NFO.js.map} +0 -0
  429. /package/dist/{resolution-MDPNOEG6.js.map → resolution-MMOD5WC4.js.map} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lifecycle/tombstones.ts"],"sourcesContent":["// ---------------------------------------------------------------------------\n// lifecycle/tombstones.ts — Tombstone store + non-resurrection invariant\n// (issue #1579)\n//\n// A \"tombstone\" records that a fact has been retired (corrected, superseded,\n// or retracted) so that the SAME fact cannot silently come back to life through\n// any of the five resurrection paths:\n//\n// 1. Re-extraction (session replay, re-observation)\n// 2. Importers (capsule / import-* payloads)\n// 3. Consolidation merges\n// 4. Dreams (REM re-derivation)\n// 5. Pattern reinforcement (duplicate promotion)\n//\n// The invariant is enforced at the SINGLE storage persist path\n// (`StorageManager.writeMemory` — the same chokepoint that records catalog\n// writes, issue #1522). Every write path funnels through it, so paths (a)–(e)\n// are blocked WITHOUT per-path code.\n//\n// File-first / rebuildable (the repo's storage philosophy): the JSONL at\n// `<stateDir>/tombstones.jsonl` is a cache of truth. The authoritative sources\n// are the memory files themselves (status: superseded/retracted) and the\n// `corrections/` records. `rebuildTombstonesFromStorage` reconstructs the\n// JSONL from those sources.\n//\n// Design rules honored (issue #1579 design section):\n// - Hash `rawContent` exactly as the dedup index does — one helper\n// (`ContentHashIndex.computeHash` / `normalizeContent`), never a second\n// (checklist §13; rule 23).\n// - Append-only log — never rewrite history; a later `kind: \"revocation\"`\n// entry re-allows (rule 25).\n// - Instance-scoped, never module-level (rule 11).\n// - Namespace-scoped — a tombstone in namespace A never blocks namespace B\n// (rule 42).\n// - Serialized appends with rejection recovery (rule 40).\n// - Never silent drop — a blocked write lands as pending_review + blockedBy\n// (rule 34).\n// - Do NOT register a blocked fact as an active dedup/index entry (rule 44).\n// - Off = pre-feature behavior for rollback safety (rule 30).\n// - Semantic tier (4) ships dark, off by default (rule 48).\n// ---------------------------------------------------------------------------\n\nimport { serializeMutations, withHeldFileLock } from \"../utils/serialize-mutations.js\";\nimport { computeLegacyContentHash } from \"../content-hash.js\";\n\n/** Why a tombstone was emitted. */\nexport type TombstoneReason =\n | \"correction\"\n | \"supersession\"\n | \"retraction\"\n | \"contradiction_resolution\";\n\n/** Who emitted the tombstone. */\nexport type TombstoneCreatedBy =\n | \"user_correction\"\n | \"contradiction_resolution\"\n | \"supersession\"\n | \"chat\";\n\n/** Tier that matched on lookup. */\nexport type TombstoneMatchTier = \"exact\" | \"normalized\" | \"keyed\" | \"semantic\";\n\n/**\n * A single append-only tombstone log entry.\n *\n * `kind: \"tombstone\"` blocks; `kind: \"revocation\"` re-allows. The log is\n * never rewritten — the NEWEST matching entry wins at lookup (rule 25).\n */\nexport interface TombstoneEntry {\n /** Stable tombstone id (`tomb-<ts>-<rand>`). */\n id: string;\n kind: \"tombstone\" | \"revocation\";\n reason: TombstoneReason;\n /** The memory that was retired. */\n sourceMemoryId: string;\n /** sha256 of the retired identity; explicit contentHashSource may define it. */\n contentHash: string;\n /** Current body hash retained alongside an ambiguous or explicit primary hash. */\n currentContentHashAlias?: string;\n /** Current normalized body used by the normalized lookup tier. */\n normalizedText: string;\n /** Version of the current body identity fields. */\n normalizerVersion?: number;\n entityRef?: string;\n /** Structured-attribute supersession key when one existed. */\n supersessionKey?: string;\n /** Stable operation identity for crash-recovery replay. */\n operationKey?: string;\n /** Namespace scope (rule 42). */\n namespace: string;\n createdAt: string;\n createdBy: TombstoneCreatedBy;\n /** For `kind: \"revocation\"`: the tombstone id being revoked. */\n revokes?: string;\n}\n\n/** A positive block decision returned by `TombstoneStore.lookup`. */\nexport interface TombstoneMatch {\n tombstoneId: string;\n matchedTier: TombstoneMatchTier;\n reason: TombstoneReason;\n}\n\n/** Inputs to a lookup. At least one discriminator must be present.\n *\n * Issue #1579 thread Ociag/Oci-W: `supersessionKeys` (plural) lets the write\n * chokepoint check EVERY derived key, not just the first. Emitters register\n * one tombstone per matched key (temporal-supersession, rebuild), so a block\n * can live on any later key; querying only `supersessionKeys[0]` missed it\n * and the retired fact resurrected as active. `supersessionKey` (singular)\n * remains for direct/unit callers; `lookup` checks the union of both. */\nexport interface TombstoneLookupQuery {\n contentHash?: string;\n normalizedText?: string;\n entityRef?: string;\n /** Single supersession key (direct/unit callers). */\n supersessionKey?: string;\n /** All derived supersession keys (write chokepoint). The keyed tier is\n * checked for each; the first active match wins. */\n supersessionKeys?: string[];\n namespace: string;\n}\n\n/** Configuration for a tombstone store instance. */\nexport interface TombstoneStoreOptions {\n enabled: boolean;\n semanticMatch: boolean;\n semanticThreshold: number;\n /** sha256 of raw content — wired to `ContentHashIndex.computeHash`. */\n hashContent: (raw: string) => string;\n /** Normalize raw content — wired to `ContentHashIndex.normalizeContent`. */\n normalizeText: (raw: string) => string;\n /**\n * Optional cosine similarity in [0, 1] for the semantic tier. When\n * undefined or when `semanticMatch` is false, the semantic tier is\n * skipped entirely.\n */\n semanticSimilarity?: (a: string, b: string) => number;\n /**\n * Resolve source identity candidates for bounded legacy sourceMemoryIds.\n * StorageManager reads the corpus before the tombstone write lock.\n */\n readonly sourceContentsForMemoryIds?: (\n sourceMemoryIds: readonly string[],\n ) => Promise<ReadonlyMap<string, string | readonly string[]>>;\n /** Maximum number of legacy entries considered during one load. */\n readonly legacyMigrationLimit?: number;\n /**\n * Cross-process write-lock timings for the tombstone JSONL mutation lock\n * (issue #1639). The secure-store append is a read-merge-write (read\n * encrypted → decrypt → concat → re-encrypt → atomic rename), so two\n * Remnic processes appending concurrently can each read the same contents\n * and the last writer drops the other's entry — breaking the\n * non-resurrection invariant. The lock serializes the mutation across\n * processes. When omitted, defaults that fit the short tombstone critical\n * section (mirroring the summary-snapshot lock): staleMs 30s, maxWaitMs 5s,\n * heartbeatMs floor(staleMs/3).\n */\n readonly lockStaleMs?: number;\n readonly lockMaxWaitMs?: number;\n readonly lockHeartbeatMs?: number;\n}\n\n/** Injected file I/O — the StorageManager wires its secure-store-aware\n * implementations so tombstones are encrypted at rest alongside other state.\n * `stat` is optional; when provided the store tracks the file mtime itself and\n * runs a cross-process staleness probe on each access (#1579). */\nexport interface TombstoneFileIo {\n read: (filePath: string) => Promise<string>;\n append: (filePath: string, content: string) => Promise<void>;\n write: (filePath: string, content: string) => Promise<void>;\n stat?: (filePath: string) => { mtimeMs: number };\n}\n\n/** Aggregate stats for `remnic doctor`. */\nexport interface TombstoneStats {\n count: number;\n revoked: number;\n lastAppendAt: string | null;\n corruptedLines: number;\n /** Whether the in-memory index matches the on-disk file (rebuild check). */\n loaded: boolean;\n}\n\nconst TOMBSTONE_NORMALIZER_VERSION = 2;\nconst DEFAULT_LEGACY_MIGRATION_LIMIT = 10_000;\n\nconst TOMBSTONE_PREFIX = \"tomb\";\n\nfunction newTombstoneId(): string {\n return `${TOMBSTONE_PREFIX}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;\n}\n\n/** Deterministic key for the keyed tier (namespace + entityRef + supersessionKey).\n *\n * The namespace is part of the discriminator so two namespace-scoped stores\n * that share the same backing `tombstones.jsonl` (namespaces disabled, or the\n * same directory used with different namespace configs) cannot overwrite each\n * other's index entries — a later tombstone for namespace B with the same\n * entity/key no longer evicts namespace A's entry (issue #1579 thread Ocs-O). */\nfunction keyedTierKey(namespace: string, entityRef: string, supersessionKey: string): string {\n return `${namespace}\\0${entityRef}\\0${supersessionKey}`;\n}\n\n/**\n * Parse one JSONL line into a TombstoneEntry, validating the discriminated\n * union. Returns `null` for malformed lines (rule 34 — skip with a counter,\n * never crash).\n */\nexport function parseTombstoneLine(line: string): TombstoneEntry | null {\n const trimmed = line.trim();\n if (trimmed.length === 0) return null;\n let parsed: unknown;\n try {\n parsed = JSON.parse(trimmed);\n } catch {\n return null;\n }\n if (!parsed || typeof parsed !== \"object\") return null;\n const e = parsed as Record<string, unknown>;\n if (typeof e.id !== \"string\" || e.id.length === 0) return null;\n if (e.kind !== \"tombstone\" && e.kind !== \"revocation\") return null;\n if (\n e.reason !== \"correction\" &&\n e.reason !== \"supersession\" &&\n e.reason !== \"retraction\" &&\n e.reason !== \"contradiction_resolution\"\n ) {\n return null;\n }\n if (typeof e.sourceMemoryId !== \"string\") return null;\n if (typeof e.contentHash !== \"string\") return null;\n if (typeof e.normalizedText !== \"string\") return null;\n if (typeof e.namespace !== \"string\") return null;\n if (typeof e.createdAt !== \"string\") return null;\n if (\n e.createdBy !== \"user_correction\" &&\n e.createdBy !== \"contradiction_resolution\" &&\n e.createdBy !== \"supersession\" &&\n e.createdBy !== \"chat\"\n ) {\n return null;\n }\n const out: TombstoneEntry = {\n id: e.id,\n kind: e.kind,\n reason: e.reason,\n sourceMemoryId: e.sourceMemoryId,\n contentHash: e.contentHash,\n normalizedText: e.normalizedText,\n namespace: e.namespace,\n createdAt: e.createdAt,\n createdBy: e.createdBy,\n };\n if (typeof e.currentContentHashAlias === \"string\") {\n out.currentContentHashAlias = e.currentContentHashAlias;\n }\n if (typeof e.normalizerVersion === \"number\" && Number.isInteger(e.normalizerVersion)) {\n out.normalizerVersion = e.normalizerVersion;\n }\n if (typeof e.operationKey === \"string\") out.operationKey = e.operationKey;\n if (typeof e.entityRef === \"string\") out.entityRef = e.entityRef;\n if (typeof e.supersessionKey === \"string\") out.supersessionKey = e.supersessionKey;\n if (typeof e.revokes === \"string\") out.revokes = e.revokes;\n return out;\n}\n\n/**\n * The instance-scoped tombstone store. One per StorageManager (rule 11),\n * namespace-scoped via `namespace` + the on-disk path (rule 42).\n *\n * The in-memory index is built lazily on first access and invalidated on\n * append + by the StorageManager's cache-invalidation chokepoint (rule 25).\n */\nexport class TombstoneStore {\n private entries: TombstoneEntry[] = [];\n /** contentHash → tombstone id (newest) — exact tier. */\n private readonly byHash = new Map<string, string>();\n /** normalizedText → tombstone id (newest) — normalized tier. */\n private readonly byNormalized = new Map<string, string>();\n /** entityRef\\0supersessionKey → tombstone id (newest) — keyed tier. */\n private readonly byKey = new Map<string, string>();\n /** Tombstone ids that have a later revocation entry. */\n private readonly revokedIds = new Set<string>();\n /** id → entry index (newest only, for revocation lookups). */\n private readonly byId = new Map<string, TombstoneEntry>();\n private loaded = false;\n private loadPromise: Promise<void> | null = null;\n private corruptedLines = 0;\n private lastAppendAt: string | null = null;\n /**\n * Last-seen mtime of the JSONL file (cross-process staleness probe, #1579).\n * Tracked inside the store so the StorageManager wiring stays thin. When the\n * file's mtime advances past this value between accesses, the in-memory index\n * is stale (a peer process appended) and is reloaded before the next lookup.\n */\n private fileMtimeMs = 0;\n\n constructor(\n private readonly filePath: string,\n private readonly namespace: string,\n private readonly options: TombstoneStoreOptions,\n private readonly io: TombstoneFileIo,\n ) {\n const limit = this.options.legacyMigrationLimit;\n if (limit !== undefined && (!Number.isFinite(limit) || !Number.isInteger(limit) || limit < 0)) {\n throw new Error(\"legacyMigrationLimit must be a finite non-negative integer\");\n }\n this.lockStaleMs = this.options.lockStaleMs ?? 30_000;\n this.lockMaxWaitMs = this.options.lockMaxWaitMs ?? 5_000;\n this.lockHeartbeatMs =\n this.options.lockHeartbeatMs ?? Math.max(100, Math.floor(this.lockStaleMs / 3));\n }\n\n /**\n * Resolved cross-process write-lock timings (issue #1639). Defaults mirror\n * the summary-snapshot lock: a tombstone append critical section is\n * sub-second, so a stale lock older than 30s is a crashed holder; bounded\n * acquisition gives up after 5s and strict-fails rather than clobbering a\n * concurrent writer (which would reintroduce the lost-write race this lock\n * closes).\n */\n private readonly lockStaleMs: number;\n private readonly lockMaxWaitMs: number;\n private readonly lockHeartbeatMs: number;\n\n /**\n * Sibling advisory lockfile: `<tombstones>.jsonl` → `<tombstones>.lock`.\n * Shared by append, revoke, and rebuild so every JSONL mutation serializes\n * against the others across processes (issue #1639: \"shared with rebuilds\").\n */\n private get lockPath(): string {\n return this.filePath.replace(/\\.jsonl$/i, \"\") + \".lock\";\n }\n\n /** Lazy load + build the in-memory index. Idempotent. */\n async load(): Promise<void> {\n if (this.loaded) return;\n if (this.loadPromise) return this.loadPromise;\n this.loadPromise = this.loadInternal();\n try {\n await this.loadPromise;\n } finally {\n this.loadPromise = null;\n }\n }\n\n private async loadInternal(migrateLegacy = true): Promise<void> {\n // Record the file mtime before reading so an ENOENT still records 0 and\n // a successful load does not immediately trigger a staleness reload.\n this.recordFileMtime();\n let raw: string;\n try {\n raw = await this.io.read(this.filePath);\n } catch (err) {\n const code = (err as NodeJS.ErrnoException)?.code;\n if (code !== \"ENOENT\") throw err;\n this.loaded = true;\n return;\n }\n const initial = this.parseEntries(raw);\n const migrated = migrateLegacy\n ? await this.migrateLegacyEntries(initial)\n : initial;\n this.resetIndex();\n for (const entry of migrated.entries) this.indexEntry(entry);\n this.corruptedLines = migrated.corruptedLines;\n this.loaded = true;\n }\n\n private parseEntries(raw: string): {\n entries: TombstoneEntry[];\n corruptedLines: number;\n } {\n const entries: TombstoneEntry[] = [];\n let corruptedLines = 0;\n for (const line of raw.split(\"\\n\")) {\n const entry = parseTombstoneLine(line);\n if (!entry) {\n if (line.trim().length > 0) corruptedLines += 1;\n continue;\n }\n entries.push(entry);\n }\n return { entries, corruptedLines };\n }\n\n /**\n * Re-index pre-Unicode records from retired source content.\n * Source reads stay bounded, but every batch finishes before the store\n * publishes its in-memory index. Missing sources remain eligible on restart.\n */\n private async migrateLegacyEntries(initial: {\n entries: TombstoneEntry[];\n corruptedLines: number;\n }): Promise<{ entries: TombstoneEntry[]; corruptedLines: number }> {\n const limit = this.options.legacyMigrationLimit ?? DEFAULT_LEGACY_MIGRATION_LIMIT;\n if (limit === 0 || !this.options.sourceContentsForMemoryIds) return initial;\n const sourceMemoryIds: string[] = [];\n const requested = new Set<string>();\n for (const entry of initial.entries) {\n if (\n entry.kind !== \"tombstone\" ||\n entry.normalizerVersion === TOMBSTONE_NORMALIZER_VERSION\n ) {\n continue;\n }\n if (requested.has(entry.sourceMemoryId)) continue;\n requested.add(entry.sourceMemoryId);\n sourceMemoryIds.push(entry.sourceMemoryId);\n }\n if (sourceMemoryIds.length === 0) return initial;\n const sourceContents = new Map<string, string | readonly string[]>();\n for (let offset = 0; offset < sourceMemoryIds.length; offset += limit) {\n const batch = sourceMemoryIds.slice(offset, offset + limit);\n const fetched = await this.options.sourceContentsForMemoryIds(batch);\n for (const [sourceMemoryId, content] of fetched) sourceContents.set(sourceMemoryId, content);\n }\n return await serializeMutations(`tombstone:${this.filePath}`, () =>\n this.withWriteLock(async () => {\n const latestRaw = await this.io.read(this.filePath);\n const latest = this.parseEntries(latestRaw);\n let changed = false;\n const migrateEntry = (entry: TombstoneEntry): TombstoneEntry => {\n if (\n entry.kind !== \"tombstone\" ||\n entry.normalizerVersion === TOMBSTONE_NORMALIZER_VERSION ||\n !requested.has(entry.sourceMemoryId)\n ) {\n return entry;\n }\n const resolved = sourceContents.get(entry.sourceMemoryId);\n if (resolved === undefined) return entry;\n const candidates = typeof resolved === \"string\" ? [resolved] : resolved;\n const matches = candidates.filter((source) =>\n entry.contentHash === this.options.hashContent(source) ||\n entry.contentHash === computeLegacyContentHash(source)\n );\n const explicitPrimary =\n matches.length === 0 &&\n entry.contentHash !== this.options.hashContent(entry.normalizedText);\n const source = matches[0] ?? (explicitPrimary ? candidates[0] : undefined);\n if (source === undefined) return entry;\n const currentHash = this.options.hashContent(source);\n const alias = explicitPrimary\n ? currentHash\n : matches\n .map((candidate) => this.options.hashContent(candidate))\n .find((hash) => hash !== currentHash);\n changed = true;\n return {\n ...entry,\n contentHash: explicitPrimary ? entry.contentHash : currentHash,\n ...(alias ? { currentContentHashAlias: alias } : {}),\n normalizedText: this.options.normalizeText(source),\n normalizerVersion: TOMBSTONE_NORMALIZER_VERSION,\n };\n };\n const serialized = latestRaw\n .split(\"\\n\")\n .map((line) => {\n const entry = parseTombstoneLine(line);\n if (!entry) return line;\n const migrated = migrateEntry(entry);\n return migrated === entry ? line : JSON.stringify(migrated);\n })\n .join(\"\\n\");\n if (!changed) return latest;\n await this.io.write(this.filePath, serialized);\n this.markWritten();\n return this.parseEntries(serialized);\n }),\n );\n }\n\n private resetIndex(): void {\n this.entries = [];\n this.byHash.clear();\n this.byNormalized.clear();\n this.byKey.clear();\n this.revokedIds.clear();\n this.byId.clear();\n }\n\n /**\n * Index an entry. Later entries (higher array index = newer createdAt)\n * OVERRIDE earlier ones at each tier key — the newest matching entry wins\n * (rule 25). Revocation entries mark their target as revoked.\n */\n private indexEntry(entry: TombstoneEntry): void {\n this.entries.push(entry);\n this.byId.set(entry.id, entry);\n if (entry.createdAt > (this.lastAppendAt ?? \"\")) {\n this.lastAppendAt = entry.createdAt;\n }\n if (entry.kind === \"revocation\") {\n if (entry.revokes) this.revokedIds.add(entry.revokes);\n return;\n }\n // Tombstone entries populate the lookup maps. The namespace is part of\n // every discriminator key (issue #1579 thread Ocs-O): when two\n // namespace-scoped stores share the same backing file, a later tombstone\n // for namespace B with identical content must NOT evict namespace A's map\n // entry — otherwise A's lookup finds B's id, rejects it on namespace\n // mismatch, and misses its own still-active tombstone (resurrection).\n const ns = entry.namespace;\n if (entry.normalizerVersion === TOMBSTONE_NORMALIZER_VERSION) {\n if (entry.contentHash) this.byHash.set(`${ns}\\0${entry.contentHash}`, entry.id);\n if (entry.currentContentHashAlias) {\n this.byHash.set(`${ns}\\0${entry.currentContentHashAlias}`, entry.id);\n }\n if (entry.normalizedText) this.byNormalized.set(`${ns}\\0${entry.normalizedText}`, entry.id);\n }\n if (entry.entityRef && entry.supersessionKey) {\n this.byKey.set(keyedTierKey(ns, entry.entityRef, entry.supersessionKey), entry.id);\n }\n }\n\n /** Invalidate the in-memory cache (rule 25). The next access reloads. */\n invalidate(): void {\n this.loaded = false;\n this.loadPromise = null;\n this.resetIndex();\n }\n\n /**\n * Cross-process staleness probe (#1579). If the file's mtime advanced since\n * the last load/own-write, a peer process appended and our in-memory index\n * is stale — invalidate and reload before the next access. Mutation callers\n * pass `migrate: false` to avoid nested serializer/lock acquisition.\n */\n async ensureFreshAgainstDisk(options: { migrate?: boolean } = {}): Promise<void> {\n if (!this.io.stat) return;\n let mtimeMs: number;\n try {\n mtimeMs = Math.floor(this.io.stat(this.filePath).mtimeMs);\n } catch {\n return; // ENOENT / permission — keep the loaded index (fail-open).\n }\n if (mtimeMs === this.fileMtimeMs && this.loaded) return;\n this.fileMtimeMs = mtimeMs;\n this.invalidate();\n if (options.migrate === false) {\n await this.loadInternal(false);\n } else {\n await this.load();\n }\n }\n\n /**\n * Record the file mtime after THIS process writes (append / revoke / rebuild)\n * so `ensureFreshAgainstDisk` does not treat our own write as a peer append\n * and throw away the just-updated in-memory index (#1579 — avoids a needless\n * invalidate+reload in the hot write path).\n */\n private markWritten(): void {\n this.recordFileMtime();\n }\n\n private recordFileMtime(): void {\n if (!this.io.stat) return;\n try {\n this.fileMtimeMs = Math.floor(this.io.stat(this.filePath).mtimeMs);\n } catch {\n // ENOENT — fresh store with no file yet; mtime stays at its current value.\n }\n }\n\n /**\n * Append a tombstone entry. Serialized via `serializeMutations` keyed by\n * file path so concurrent appends do not interleave, with rejection recovery\n * (rule 40 — a single failed append never poisons the chain). The in-memory\n * index is updated AFTER the durable append succeeds.\n *\n * Returns the new tombstone id.\n */\n async appendTombstone(input: {\n reason: TombstoneReason;\n createdBy: TombstoneCreatedBy;\n sourceMemoryId: string;\n rawContent: string;\n entityRef?: string;\n supersessionKey?: string;\n operationKey?: string;\n createdAt?: string;\n /**\n * Pre-computed canonical contentHash from the retired memory's frontmatter.\n * When provided, used directly so the tombstone's exact tier matches the\n * hash writeMemory computes on re-extraction (issue #1579 review: cited\n * facts must not slip past the chokepoint because the emitter hashed the\n * citation-annotated body instead of the canonical source).\n */\n contentHash?: string;\n }): Promise<string> {\n await this.load();\n const createdAt = input.createdAt ?? new Date().toISOString();\n const id = newTombstoneId();\n const currentHash = this.options.hashContent(input.rawContent);\n const currentNormalizedText = this.options.normalizeText(input.rawContent);\n const entry: TombstoneEntry = {\n id,\n ...(input.contentHash && input.contentHash !== currentHash\n ? { currentContentHashAlias: currentHash }\n : {}),\n kind: \"tombstone\",\n reason: input.reason,\n sourceMemoryId: input.sourceMemoryId,\n contentHash: input.contentHash ?? currentHash,\n normalizedText: currentNormalizedText,\n normalizerVersion: TOMBSTONE_NORMALIZER_VERSION,\n ...(input.entityRef ? { entityRef: input.entityRef } : {}),\n ...(input.supersessionKey ? { supersessionKey: input.supersessionKey } : {}),\n ...(input.operationKey ? { operationKey: input.operationKey } : {}),\n namespace: this.namespace,\n createdAt,\n createdBy: input.createdBy,\n };\n await this.serializeAppend(entry);\n this.indexEntry(entry);\n this.markWritten();\n await this.migrateLoadedLegacyEntries();\n return id;\n }\n\n /**\n * Append a revocation entry referencing `tombstoneId`. The log is\n * append-only; lookup treats a revoked tombstone as re-allowed (rule 25).\n */\n async revoke(tombstoneId: string, createdBy: TombstoneCreatedBy): Promise<string> {\n await this.load();\n const createdAt = new Date().toISOString();\n const id = newTombstoneId();\n const entry: TombstoneEntry = {\n id,\n kind: \"revocation\",\n reason: \"correction\",\n sourceMemoryId: \"\",\n contentHash: \"\",\n normalizedText: \"\",\n namespace: this.namespace,\n createdAt,\n createdBy,\n revokes: tombstoneId,\n };\n await this.serializeAppend(entry);\n this.indexEntry(entry);\n this.markWritten();\n await this.migrateLoadedLegacyEntries();\n return id;\n }\n\n private serializeAppend(entry: TombstoneEntry): Promise<void> {\n const line = JSON.stringify(entry) + \"\\n\";\n // serializeMutations (in-process, rule 40 rejection recovery) wraps the\n // cross-process lock: within one process appends are queued, and across\n // processes the advisory lockfile serializes the read-merge-write so two\n // Remnic processes appending concurrently cannot drop each other's entry\n // (issue #1639). Under the lock we re-sync the in-memory index against\n // disk first, so indexEntry builds on the peer's just-appended entries.\n return serializeMutations(`tombstone:${this.filePath}`, () =>\n this.withWriteLock(async () => {\n await this.ensureFreshAgainstDisk({ migrate: false });\n await this.io.append(this.filePath, line);\n }),\n );\n }\n\n private async migrateLoadedLegacyEntries(): Promise<void> {\n const initial = {\n entries: [...this.entries],\n corruptedLines: this.corruptedLines,\n };\n if (!initial.entries.some(\n (entry) => entry.kind === \"tombstone\" && entry.normalizerVersion !== TOMBSTONE_NORMALIZER_VERSION,\n )) {\n return;\n }\n try {\n const migrated = await this.migrateLegacyEntries(initial);\n this.resetIndex();\n for (const entry of migrated.entries) this.indexEntry(entry);\n this.corruptedLines = migrated.corruptedLines;\n this.loaded = true;\n } catch {\n // The durable mutation already succeeded; defer migration to next load.\n }\n }\n\n /**\n * Acquire the cross-process tombstone write lock and run `task` under it\n * (issue #1639). Strict-fail on acquisition timeout: the secure-store append\n * is a read-merge-write, so a best-effort unlocked run would clobber a\n * concurrent writer — reintroducing the lost-write race this lock closes.\n * The thrown error surfaces to the caller (rule 34: never silently drop);\n * rebuild recovers the tombstone on the next maintenance cycle.\n *\n * In-process callers are already serialized by serializeMutations (one key\n * for append/revoke/rebuild), so this lock only contends across processes —\n * the single-process daemon (default deployment) acquires it immediately.\n */\n private withWriteLock<T>(task: () => Promise<T>): Promise<T> {\n return withHeldFileLock(\n this.lockPath,\n {\n staleMs: this.lockStaleMs,\n maxWaitMs: this.lockMaxWaitMs,\n heartbeatMs: this.lockHeartbeatMs,\n },\n async (acquired) => {\n if (!acquired) {\n throw new Error(\n \"could not acquire tombstone write lock (contention timeout or filesystem error)\",\n );\n }\n return task();\n },\n );\n }\n\n /**\n * Look up whether `query` is blocked by an active (non-revoked) tombstone.\n * Tiers are checked in order: exact (contentHash) → normalized → keyed →\n * semantic (off by default). Returns the first active match, or `null`.\n *\n * Namespace isolation (rule 42): only entries with `namespace === query.namespace`\n * match. The store is per-namespace, so this is belt-and-suspenders.\n */\n lookup(query: TombstoneLookupQuery): TombstoneMatch | null {\n // We intentionally do NOT await load() here — lookup is called from the\n // hot write path. Callers MUST ensure the store is loaded before lookup\n // (StorageManager does this in ensureTombstoneStoreLoaded). If not loaded,\n // lookup returns null (fail-open: a missing tombstone check is preferable\n // to crashing every write — see rule 34 / the \"degrade gracefully\" note).\n if (!this.options.enabled) return null;\n if (!this.loaded) return null;\n\n // Tier 1: exact contentHash. Namespace is part of the map key (thread\n // Ocs-O), so the lookup finds only this namespace's tombstone even when\n // the backing file is shared. The namespace equality check below is kept\n // as defense-in-depth.\n const ns = query.namespace;\n if (query.contentHash) {\n const id = this.byHash.get(`${ns}\\0${query.contentHash}`);\n if (id && !this.revokedIds.has(id)) {\n const entry = this.byId.get(id);\n if (entry && entry.namespace === ns) {\n return { tombstoneId: id, matchedTier: \"exact\", reason: entry.reason };\n }\n }\n }\n // Tier 2: normalized text.\n if (query.normalizedText) {\n const id = this.byNormalized.get(`${ns}\\0${query.normalizedText}`);\n if (id && !this.revokedIds.has(id)) {\n const entry = this.byId.get(id);\n if (entry && entry.namespace === ns) {\n return { tombstoneId: id, matchedTier: \"normalized\", reason: entry.reason };\n }\n }\n }\n // Tier 3: keyed (entityRef + supersessionKey). Issue #1579 thread\n // Ociag/Oci-W: check EVERY supplied key, not just the first — emitters\n // append one tombstone per matched supersession key, so the active block\n // can live on any later key. The union of `supersessionKey` (singular,\n // direct callers) and `supersessionKeys` (array, write chokepoint) is\n // checked; the first active match wins (tiers are equality-based, so\n // ordering across keys does not affect correctness).\n if (query.entityRef) {\n const keysToCheck: string[] = [];\n if (query.supersessionKey) keysToCheck.push(query.supersessionKey);\n if (query.supersessionKeys) {\n for (const k of query.supersessionKeys) {\n if (!keysToCheck.includes(k)) keysToCheck.push(k);\n }\n }\n for (const key of keysToCheck) {\n const id = this.byKey.get(keyedTierKey(ns, query.entityRef, key));\n if (id && !this.revokedIds.has(id)) {\n const entry = this.byId.get(id);\n if (entry && entry.namespace === ns) {\n return { tombstoneId: id, matchedTier: \"keyed\", reason: entry.reason };\n }\n }\n }\n }\n // Tier 4: semantic (off by default, rule 48).\n if (this.options.semanticMatch && this.options.semanticSimilarity && query.normalizedText) {\n const threshold = this.options.semanticThreshold;\n let best: { id: string; reason: TombstoneReason; score: number } | null = null;\n for (const entry of this.entries) {\n if (entry.kind !== \"tombstone\") continue;\n if (entry.normalizerVersion !== TOMBSTONE_NORMALIZER_VERSION) continue;\n if (entry.namespace !== query.namespace) continue;\n if (this.revokedIds.has(entry.id)) continue;\n if (!entry.normalizedText) continue;\n const score = this.options.semanticSimilarity(query.normalizedText, entry.normalizedText);\n if (score >= threshold && (!best || score > best.score)) {\n best = { id: entry.id, reason: entry.reason, score };\n }\n }\n if (best) {\n return { tombstoneId: best.id, matchedTier: \"semantic\", reason: best.reason };\n }\n }\n return null;\n }\n async hasExactEntry(input: {\n sourceMemoryId: string;\n contentHash?: string;\n entityRef?: string;\n supersessionKey?: string;\n createdAt?: string;\n operationKey?: string;\n }): Promise<boolean> {\n if (!this.options.enabled) return false;\n await this.ensureFreshAgainstDisk();\n await this.load();\n return this.entries.some(\n (entry) =>\n entry.kind === \"tombstone\" &&\n !this.revokedIds.has(entry.id) &&\n entry.namespace === this.namespace &&\n entry.sourceMemoryId === input.sourceMemoryId &&\n (input.contentHash === undefined || entry.contentHash === input.contentHash) &&\n (input.entityRef === undefined || entry.entityRef === input.entityRef) &&\n (input.supersessionKey === undefined || entry.supersessionKey === input.supersessionKey) &&\n (input.createdAt === undefined || entry.createdAt === input.createdAt) &&\n (input.operationKey === undefined || entry.operationKey === input.operationKey),\n );\n }\n\n\n /** Aggregate stats for the doctor / x-ray surfaces. */\n stats(): TombstoneStats {\n let active = 0;\n for (const entry of this.entries) {\n if (entry.kind === \"tombstone\" && !this.revokedIds.has(entry.id)) active += 1;\n }\n return {\n count: active,\n revoked: this.revokedIds.size,\n lastAppendAt: this.lastAppendAt,\n corruptedLines: this.corruptedLines,\n loaded: this.loaded,\n };\n }\n\n /** Read-only snapshot of all entries (for rebuild + tests). */\n snapshot(): readonly TombstoneEntry[] {\n return this.entries;\n }\n\n /**\n * Rebuild the in-memory index + JSONL from the supplied retired-memory\n * records + existing entries (preserving revocations). Byte-stable: entries\n * are sorted by (createdAt, id) before write (rule 38).\n *\n * Returns the count of tombstone entries written.\n */\n async rebuild(retiredMemories: ReadonlyArray<RetiredMemoryRecord>): Promise<number> {\n // The full read-merge-write runs UNDER the cross-process lock (issue #1639,\n // cursor/codex review): we ensureFreshAgainstDisk() first so the in-memory\n // index reflects any peer append/revoke that landed while we waited for the\n // lock, THEN compute the payload. Rebuild rewrites the entire JSONL, so a\n // payload built from a stale this.entries would overwrite a peer's just-\n // written entry and resurrect a retired fact — the exact invariant this\n // store exists to enforce. serializeMutations (in-process) wraps the\n // cross-process lock; the key is unified with append/revoke so they cannot\n // interleave in-process either.\n const rebuiltCount = await serializeMutations(`tombstone:${this.filePath}`, () =>\n this.withWriteLock(async () => {\n await this.ensureFreshAgainstDisk({ migrate: false });\n // Preserve existing revocations (all namespaces — ids are globally\n // unique) so a rebuild does not silently un-revoke.\n const existingRevocations = this.entries.filter((e) => e.kind === \"revocation\");\n // Preserve tombstone entries from OTHER namespaces when the backing\n // file is shared (issue #1579 thread Oc2MJ). rebuild rewrites the\n // entire file; without preserving foreign entries, rebuilding\n // namespace A would silently delete namespace B's tombstones, allowing\n // resurrection in B.\n const foreignTombstones = this.entries.filter(\n (e) => e.kind === \"tombstone\" && e.namespace !== this.namespace,\n );\n // Reuse existing tombstone ids for source-equivalent entries so a prior\n // revocation (which references the tombstone id) survives rebuild —\n // minting fresh ids would orphan the revocation and silently un-revoke.\n // Issue #1579 thread Oci-T: key the reuse map by (sourceMemoryId,\n // supersessionKey). See the append path above for the full rationale.\n const existingBySource = new Map<string, string>();\n for (const e of this.entries) {\n if (e.kind === \"tombstone\") {\n existingBySource.set(`${e.sourceMemoryId}\\u{0000}${e.supersessionKey ?? \"\"}`, e.id);\n }\n }\n const rebuilt: TombstoneEntry[] = retiredMemories.map((m) => {\n const currentHash = this.options.hashContent(m.rawContent);\n const currentNormalizedText = this.options.normalizeText(m.rawContent);\n const persistedHash = m.contentHash;\n const preserveOverride =\n persistedHash !== undefined &&\n persistedHash !== currentHash &&\n persistedHash !== computeLegacyContentHash(m.rawContent);\n return {\n id:\n existingBySource.get(`${m.memoryId}\\u{0000}${m.supersessionKey ?? \"\"}`) ??\n newTombstoneId(),\n ...(preserveOverride ? { currentContentHashAlias: currentHash } : {}),\n kind: \"tombstone\" as const,\n reason: m.reason,\n sourceMemoryId: m.memoryId,\n contentHash: preserveOverride ? persistedHash : currentHash,\n normalizedText: currentNormalizedText,\n normalizerVersion: TOMBSTONE_NORMALIZER_VERSION,\n ...(m.entityRef ? { entityRef: m.entityRef } : {}),\n ...(m.supersessionKey ? { supersessionKey: m.supersessionKey } : {}),\n namespace: this.namespace,\n createdAt: m.createdAt,\n createdBy: m.createdBy,\n };\n });\n // Sort deterministically (rule 38): createdAt, then id for stability.\n rebuilt.sort((a, b) =>\n a.createdAt === b.createdAt\n ? a.id < b.id ? -1 : a.id > b.id ? 1 : 0\n : a.createdAt < b.createdAt ? -1 : 1,\n );\n const all = [...rebuilt, ...existingRevocations, ...foreignTombstones].sort((a, b) =>\n a.createdAt === b.createdAt\n ? a.id < b.id ? -1 : a.id > b.id ? 1 : 0\n : a.createdAt < b.createdAt ? -1 : 1,\n );\n const serialized =\n all.map((e) => JSON.stringify(e)).join(\"\\n\") + (all.length > 0 ? \"\\n\" : \"\");\n await this.io.write(this.filePath, serialized);\n // Update the in-memory index under the same lock so it stays consistent\n // with the file we just wrote (no window for a lookup to see a stale\n // index that misses a just-rebuilt entry).\n this.resetIndex();\n for (const entry of all) this.indexEntry(entry);\n this.corruptedLines = 0;\n this.loaded = true;\n this.markWritten();\n return rebuilt.length;\n }),\n );\n await this.migrateLoadedLegacyEntries();\n return rebuiltCount;\n }\n}\n\n/** A retired memory projected into the shape `TombstoneStore.rebuild` consumes. */\nexport interface RetiredMemoryRecord {\n memoryId: string;\n rawContent: string;\n entityRef?: string;\n supersessionKey?: string;\n reason: TombstoneReason;\n createdBy: TombstoneCreatedBy;\n createdAt: string;\n /** Canonical contentHash from the retired memory's frontmatter (#1579). */\n contentHash?: string;\n}\n\n/**\n * Project a corpus of memories into the retired-memory records `rebuild`\n * consumes. Pure (no I/O) so the StorageManager wiring stays thin (#1579,\n * #1520 god-file ratchet). Only superseded / forgotten / rejected FACTS\n * participate — entities, questions, and artifacts have their own lifecycle\n * (issue pitfall). The supersession key is derived from structured attributes\n * via the injected helper so there is one keyed-tier definition (rule 23).\n */\nexport function collectRetiredMemoriesForRebuild(\n memories: ReadonlyArray<{\n frontmatter: {\n id: string;\n status?: string;\n category?: string;\n contentHash?: string;\n entityRef?: string;\n structuredAttributes?: Record<string, string>;\n updated?: string;\n created?: string;\n };\n content: string;\n }>,\n deps: {\n /** Strip citation annotations from the body before hashing/normalizing. */\n stripCitation: (text: string) => string;\n /** Derive the keyed-tier supersession key (one helper, rule 23). */\n supersessionKeysForFact: (spec: {\n entityRef?: string;\n structuredAttributes?: Record<string, string>;\n }) => string[];\n },\n): RetiredMemoryRecord[] {\n const retired: RetiredMemoryRecord[] = [];\n for (const m of memories) {\n const status = m.frontmatter.status;\n if (status !== \"superseded\" && status !== \"rejected\" && status !== \"forgotten\") continue;\n if (m.frontmatter.category !== \"fact\") continue;\n const reason: TombstoneReason =\n status === \"superseded\" ? \"supersession\" : status === \"forgotten\" ? \"retraction\" : \"correction\";\n const createdBy: TombstoneCreatedBy =\n reason === \"supersession\" ? \"supersession\" : \"user_correction\";\n const entityRef = m.frontmatter.entityRef;\n const keys =\n entityRef && m.frontmatter.structuredAttributes\n ? deps.supersessionKeysForFact({\n entityRef,\n structuredAttributes: m.frontmatter.structuredAttributes,\n })\n : [];\n // Issue #1579 thread Ocgjz: emit one record per matched supersession key\n // (not just keys[0]) so rebuild reproduces the same keyed tombstones as\n // live temporal-supersession (which now appends one per key — thread ObteS).\n // Without this, a rebuild would under-rebuild the JSONL and keyed-tier\n // blocks would disappear until rediscovered.\n const keysToEmit = keys.length > 0 ? keys : [undefined];\n for (const key of keysToEmit) {\n retired.push({\n memoryId: m.frontmatter.id,\n rawContent: deps.stripCitation(m.content),\n contentHash: m.frontmatter.contentHash,\n ...(entityRef ? { entityRef } : {}),\n ...(key ? { supersessionKey: key } : {}),\n reason,\n createdBy,\n createdAt: m.frontmatter.updated || m.frontmatter.created || new Date().toISOString(),\n });\n }\n }\n return retired;\n}\n\n/**\n * One-shot write-time resurrection gate (issue #1579 / #2213). Looks up the\n * fact's identity in the tombstone store and, on a match, downgrades the\n * frontmatter to `pending_review` + `blockedBy` IN PLACE. ADD-ONLY: an\n * already-blocked or terminal-status record is left untouched. Pure over its\n * inputs (no I/O beyond the injected store) so both `writeMemory`'s gate and\n * the chunk-repair re-gate share one lookup + apply.\n */\nexport function applyTombstoneResurrectionGate(\n store: Pick<TombstoneStore, \"lookup\">,\n fm: {\n id: string;\n status?: string;\n blockedBy?: string;\n tombstoneBlockTier?: TombstoneMatchTier;\n entityRef?: string;\n contentHash?: string;\n },\n query: {\n normalizedText: string;\n supersessionKeys: string[];\n namespace: string;\n },\n): TombstoneMatch | null {\n if (fm.status === \"pending_review\" && fm.blockedBy) return null;\n if (!(fm.status === undefined || fm.status === \"active\" || fm.status === \"pending_review\")) return null;\n const match = store.lookup({\n contentHash: fm.contentHash,\n normalizedText: query.normalizedText,\n ...(fm.entityRef ? { entityRef: fm.entityRef } : {}),\n ...(query.supersessionKeys.length > 0 ? { supersessionKeys: query.supersessionKeys } : {}),\n namespace: query.namespace,\n });\n if (!match) return null;\n fm.status = \"pending_review\";\n fm.blockedBy = match.tombstoneId;\n fm.tombstoneBlockTier = match.matchedTier;\n return match;\n}\n\n/**\n * Build the live-emission tombstone inputs for a single retired FACT — one\n * input per derived supersession key (or a single keyless record when no\n * structured attributes are present). Pure (no I/O) so the emitters in\n * `StorageManager.supersedeMemory` (contradiction) and `forgetMemory`\n * (retraction) stay thin (#1579, #1520 god-file ratchet). Mirrors the\n * temporal-supersession emitter and `collectRetiredMemoriesForRebuild` so\n * every retire path emits the same keyed-tombstone shape (issue #1579\n * threads Oci-Y / OchiF: without per-key tombstones, a paraphrased\n * re-observation missed the keyed tier and the fact resurrected active).\n */\nexport function buildRetiredFactTombstoneInputs(\n memory: {\n id: string;\n content: string;\n contentHash?: string;\n entityRef?: string;\n structuredAttributes?: Record<string, string>;\n },\n opts: {\n reason: TombstoneReason;\n createdBy: TombstoneCreatedBy;\n createdAt: string;\n supersessionKeysForFact: (spec: {\n entityRef?: string;\n structuredAttributes?: Record<string, string>;\n }) => string[];\n },\n): Array<{\n reason: TombstoneReason;\n createdBy: TombstoneCreatedBy;\n sourceMemoryId: string;\n rawContent: string;\n contentHash?: string;\n entityRef?: string;\n supersessionKey?: string;\n createdAt: string;\n}> {\n const keys =\n memory.entityRef && memory.structuredAttributes\n ? opts.supersessionKeysForFact({\n entityRef: memory.entityRef,\n structuredAttributes: memory.structuredAttributes,\n })\n : [];\n const keysToEmit = keys.length > 0 ? keys : [undefined];\n return keysToEmit.map((key) => ({\n reason: opts.reason,\n createdBy: opts.createdBy,\n sourceMemoryId: memory.id,\n rawContent: memory.content,\n ...(memory.contentHash ? { contentHash: memory.contentHash } : {}),\n ...(memory.entityRef ? { entityRef: memory.entityRef } : {}),\n ...(key ? { supersessionKey: key } : {}),\n createdAt: opts.createdAt,\n }));\n}\n"],"mappings":";;;;;;;;;AAwLA,IAAM,+BAA+B;AACrC,IAAM,iCAAiC;AAEvC,IAAM,mBAAmB;AAEzB,SAAS,iBAAyB;AAChC,SAAO,GAAG,gBAAgB,IAAI,KAAK,IAAI,EAAE,SAAS,EAAE,CAAC,IAAI,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,MAAM,GAAG,CAAC,CAAC;AACjG;AASA,SAAS,aAAa,WAAmB,WAAmB,iBAAiC;AAC3F,SAAO,GAAG,SAAS,KAAK,SAAS,KAAK,eAAe;AACvD;AAOO,SAAS,mBAAmB,MAAqC;AACtE,QAAM,UAAU,KAAK,KAAK;AAC1B,MAAI,QAAQ,WAAW,EAAG,QAAO;AACjC,MAAI;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,OAAO,YAAY,EAAE,WAAW,OAAO,UAAU,IAAI,CAAC;AAAA,IAC1D,GAAI,MAAM,EAAE,iBAAiB,IAAI,IAAI,CAAC;AAAA,IACtC,WAAW,KAAK;AAAA,EAClB,EAAE;AACJ;","names":["source"]}
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-KSXJOC4F.js";
5
5
  import {
6
6
  StorageManager
7
- } from "./chunk-WD5B5AIE.js";
7
+ } from "./chunk-6R4G7N4S.js";
8
8
  import {
9
9
  isSafeRouteNamespace
10
10
  } from "./chunk-U3PN77QT.js";
@@ -134,4 +134,4 @@ export {
134
134
  runCodexMaterialize,
135
135
  runPostConsolidationMaterialize
136
136
  };
137
- //# sourceMappingURL=chunk-NOEMGE56.js.map
137
+ //# sourceMappingURL=chunk-NH5IR2WM.js.map
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-BT7NVCML.js";
4
4
  import {
5
5
  assemblePersistedBody
6
- } from "./chunk-R3DJVOSM.js";
6
+ } from "./chunk-JDSVLVCG.js";
7
7
  import {
8
8
  parseFlexibleIsoTimestamp
9
9
  } from "./chunk-P7FMDTKL.js";
@@ -418,4 +418,4 @@ export {
418
418
  buildAccessWriteRequestFingerprint,
419
419
  buildObserveRequestFingerprint
420
420
  };
421
- //# sourceMappingURL=chunk-5V6IXHPI.js.map
421
+ //# sourceMappingURL=chunk-NSVDUN76.js.map
@@ -10,9 +10,6 @@ import {
10
10
  import {
11
11
  compareDeterministicStrings
12
12
  } from "./chunk-G73MCJKL.js";
13
- import {
14
- stripAttributesSuffix
15
- } from "./chunk-R3DJVOSM.js";
16
13
  import {
17
14
  isValidityExpiredNow
18
15
  } from "./chunk-6CIAGZ6X.js";
@@ -24,6 +21,9 @@ import {
24
21
  inferMemoryStatus,
25
22
  toMemoryPathRel
26
23
  } from "./chunk-7RJUVTVF.js";
24
+ import {
25
+ stripAttributesSuffix
26
+ } from "./chunk-JDSVLVCG.js";
27
27
  import {
28
28
  throwIfAborted
29
29
  } from "./chunk-BTTPKDIL.js";
@@ -279,4 +279,4 @@ async function searchHarmonicRetrieval(options) {
279
279
  export {
280
280
  searchHarmonicRetrieval
281
281
  };
282
- //# sourceMappingURL=chunk-W7Y5JDVB.js.map
282
+ //# sourceMappingURL=chunk-PDDTI7IC.js.map
@@ -25,7 +25,7 @@ import {
25
25
  } from "./chunk-YYQAKIDJ.js";
26
26
  import {
27
27
  getOperation
28
- } from "./chunk-BF6SXNQJ.js";
28
+ } from "./chunk-T2JHZWH6.js";
29
29
  import {
30
30
  assertOperationAllowed,
31
31
  capabilityAllowsOp,
@@ -3761,4 +3761,4 @@ export {
3761
3761
  MCP_SUPPORTED_PROTOCOL_VERSIONS,
3762
3762
  EngramMcpServer
3763
3763
  };
3764
- //# sourceMappingURL=chunk-QINJITDS.js.map
3764
+ //# sourceMappingURL=chunk-PX2LSHYM.js.map
@@ -21,17 +21,17 @@ import {
21
21
  processChatMessage,
22
22
  sessionBelongsToPrincipal,
23
23
  subscribeChatTranscript
24
- } from "./chunk-QINJITDS.js";
24
+ } from "./chunk-PX2LSHYM.js";
25
25
  import {
26
26
  RelayMissionStoreError
27
- } from "./chunk-3OY7KXHM.js";
27
+ } from "./chunk-ZYLC7NFO.js";
28
28
  import {
29
29
  validateRequest
30
30
  } from "./chunk-NIS256NW.js";
31
31
  import {
32
32
  executeResolution,
33
33
  isValidResolutionVerb
34
- } from "./chunk-BAKXNQ3C.js";
34
+ } from "./chunk-KRTY3ENI.js";
35
35
  import {
36
36
  isDefaultReviewNamespace,
37
37
  listPairs,
@@ -50,12 +50,12 @@ import {
50
50
  import {
51
51
  authorizationProbeNamespaces,
52
52
  probeOperationAuthorization
53
- } from "./chunk-QPOHMO6M.js";
53
+ } from "./chunk-UES4BHA2.js";
54
54
  import {
55
55
  CorrectionContractError,
56
56
  getOperation,
57
57
  resolveQueryNamespaceWritablePreflight
58
- } from "./chunk-BF6SXNQJ.js";
58
+ } from "./chunk-T2JHZWH6.js";
59
59
  import {
60
60
  isTrustZoneName
61
61
  } from "./chunk-KQS72GCR.js";
@@ -3263,4 +3263,4 @@ export {
3263
3263
  MeetingsInputError,
3264
3264
  EngramAccessHttpServer
3265
3265
  };
3266
- //# sourceMappingURL=chunk-HDIUYMSB.js.map
3266
+ //# sourceMappingURL=chunk-QWGE2PUH.js.map
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  StorageManager
3
- } from "./chunk-WD5B5AIE.js";
3
+ } from "./chunk-6R4G7N4S.js";
4
4
  import {
5
5
  composeMemoryEnvelope
6
- } from "./chunk-5V6IXHPI.js";
6
+ } from "./chunk-NSVDUN76.js";
7
7
  import {
8
8
  log
9
9
  } from "./chunk-3WCASNQZ.js";
@@ -546,4 +546,4 @@ export {
546
546
  setSemanticRulePromotionTestHooks,
547
547
  promoteSemanticRuleFromMemory
548
548
  };
549
- //# sourceMappingURL=chunk-X57M2Q4I.js.map
549
+ //# sourceMappingURL=chunk-RDJRFDJY.js.map
@@ -2,11 +2,11 @@ import {
2
2
  buildExplicitCaptureDedupKey,
3
3
  isTombstoneBlockedCaptureWriteLockBusy,
4
4
  normalizeExplicitCaptureContent
5
- } from "./chunk-DLG5V6ND.js";
5
+ } from "./chunk-K4QS7LXU.js";
6
6
  import {
7
7
  TAG_LIMITS,
8
8
  composeMemoryEnvelope
9
- } from "./chunk-5V6IXHPI.js";
9
+ } from "./chunk-NSVDUN76.js";
10
10
  import {
11
11
  sanitizeMemoryContent
12
12
  } from "./chunk-5GKPFL3S.js";
@@ -783,4 +783,4 @@ export {
783
783
  shouldProcessInlineExplicitCapture,
784
784
  InlineExplicitCaptureProcessor
785
785
  };
786
- //# sourceMappingURL=chunk-RYLEDKQ2.js.map
786
+ //# sourceMappingURL=chunk-RUMNY5DT.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  resolveDefaultNamespaceRoot,
3
3
  resolveNamespaceStorageRoot
4
- } from "./chunk-2LY6GIIE.js";
4
+ } from "./chunk-WDBX6VER.js";
5
5
  import {
6
6
  getConfiguredNamespaces
7
7
  } from "./chunk-YN6ASZUG.js";
@@ -2204,4 +2204,4 @@ export {
2204
2204
  runNamespaceMaintenancePlan,
2205
2205
  runNamespaceMaintenanceBatchPlan
2206
2206
  };
2207
- //# sourceMappingURL=chunk-BKIFTXHR.js.map
2207
+ //# sourceMappingURL=chunk-RZ4XGKOJ.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  composeMemoryEnvelope
3
- } from "./chunk-5V6IXHPI.js";
3
+ } from "./chunk-NSVDUN76.js";
4
4
  import {
5
5
  log
6
6
  } from "./chunk-3WCASNQZ.js";
@@ -17,4 +17,4 @@ function composeSalvagedEnvelope(label, input, ctx) {
17
17
  export {
18
18
  composeSalvagedEnvelope
19
19
  };
20
- //# sourceMappingURL=chunk-66SE3BNH.js.map
20
+ //# sourceMappingURL=chunk-SUPEYLH2.js.map
@@ -45,7 +45,7 @@ import {
45
45
  } from "./chunk-QHFV6VNU.js";
46
46
  import {
47
47
  readAggregateExtractionWatermark
48
- } from "./chunk-JSEJH2YQ.js";
48
+ } from "./chunk-CGVHPCP2.js";
49
49
  import {
50
50
  ReplicaDivergenceMonitor
51
51
  } from "./chunk-CVILPI77.js";
@@ -84,7 +84,7 @@ import {
84
84
  persistExplicitCapture,
85
85
  queueExplicitCaptureForReview,
86
86
  validateExplicitCaptureInput
87
- } from "./chunk-RYLEDKQ2.js";
87
+ } from "./chunk-RUMNY5DT.js";
88
88
  import {
89
89
  lcmEvidenceIdentity
90
90
  } from "./chunk-C37ZRXX7.js";
@@ -95,11 +95,11 @@ import {
95
95
  listMemoryGovernanceRuns,
96
96
  readMemoryGovernanceRunArtifact,
97
97
  runMemoryGovernance
98
- } from "./chunk-B6LZ4IBH.js";
98
+ } from "./chunk-6LAPLZOS.js";
99
99
  import {
100
100
  CorpusWatermarkCache,
101
101
  computeServiceCorpusCensus
102
- } from "./chunk-VXCNQYTC.js";
102
+ } from "./chunk-APPFNGX6.js";
103
103
  import {
104
104
  namespaceCollectionName
105
105
  } from "./chunk-VMMQDEN5.js";
@@ -120,14 +120,14 @@ import {
120
120
  enqueuePassiveCorrectionNotification,
121
121
  parseBriefingFocus,
122
122
  parseBriefingWindow
123
- } from "./chunk-F4EU6VUC.js";
123
+ } from "./chunk-JDZPNCMA.js";
124
124
  import {
125
125
  parseEntityFile,
126
126
  parseFrontmatter,
127
127
  qmdCollectionPathParts,
128
128
  qmdResultPathCandidates,
129
129
  selfDeps
130
- } from "./chunk-WD5B5AIE.js";
130
+ } from "./chunk-6R4G7N4S.js";
131
131
  import {
132
132
  DEFAULT_RECALL_DISCLOSURE,
133
133
  isRecallDisclosure
@@ -142,15 +142,12 @@ import {
142
142
  buildObserveRequestFingerprint,
143
143
  composeMemoryEnvelope,
144
144
  isMemoryCategory
145
- } from "./chunk-5V6IXHPI.js";
145
+ } from "./chunk-NSVDUN76.js";
146
146
  import {
147
147
  applyTagFilter,
148
148
  normalizeTags,
149
149
  parseTagMatch
150
150
  } from "./chunk-BT7NVCML.js";
151
- import {
152
- stripAttributesSuffix
153
- } from "./chunk-R3DJVOSM.js";
154
151
  import {
155
152
  createVersion
156
153
  } from "./chunk-ZMSZVISA.js";
@@ -170,13 +167,6 @@ import {
170
167
  import {
171
168
  isExternalWikiCollectionName
172
169
  } from "./chunk-JV3C2MNQ.js";
173
- import {
174
- sanitizeMemoryContent
175
- } from "./chunk-5GKPFL3S.js";
176
- import {
177
- buildHandleIndexForResults,
178
- isHandleToken
179
- } from "./chunk-JAKIDQB2.js";
180
170
  import {
181
171
  exportCapsule
182
172
  } from "./chunk-KQAFEZQX.js";
@@ -208,7 +198,7 @@ import {
208
198
  } from "./chunk-LNEWDF2A.js";
209
199
  import {
210
200
  createOfflineSyncManifestStream
211
- } from "./chunk-P2KBDJJ6.js";
201
+ } from "./chunk-G2LUMAUF.js";
212
202
  import {
213
203
  offlineSyncStorageForSnapshot
214
204
  } from "./chunk-GUKBW4HL.js";
@@ -233,16 +223,26 @@ import {
233
223
  import {
234
224
  displayErrorDetail
235
225
  } from "./chunk-RL6NEVXT.js";
226
+ import {
227
+ stripAttributesSuffix
228
+ } from "./chunk-JDSVLVCG.js";
236
229
  import {
237
230
  serializeMutations
238
231
  } from "./chunk-FFAZ2XFU.js";
239
232
  import {
240
233
  computeContentHash
241
- } from "./chunk-W5H6ZRPT.js";
234
+ } from "./chunk-5FVVY2EB.js";
242
235
  import {
243
236
  expandScopeProfileReadNamespaces,
244
237
  resolveScopeProfilePlan
245
238
  } from "./chunk-BGLY7EEM.js";
239
+ import {
240
+ sanitizeMemoryContent
241
+ } from "./chunk-5GKPFL3S.js";
242
+ import {
243
+ buildHandleIndexForResults,
244
+ isHandleToken
245
+ } from "./chunk-JAKIDQB2.js";
246
246
  import {
247
247
  OFFLINE_SYNC_SNAPSHOT_FORMAT,
248
248
  applyOfflineSyncChangeset,
@@ -13523,4 +13523,4 @@ export {
13523
13523
  EngramAccessService,
13524
13524
  AccessAdminOpsSurface
13525
13525
  };
13526
- //# sourceMappingURL=chunk-BF6SXNQJ.js.map
13526
+ //# sourceMappingURL=chunk-T2JHZWH6.js.map
@@ -1,12 +1,22 @@
1
1
  import {
2
2
  summarizeReconcilePlan
3
3
  } from "./chunk-G7A5HLUS.js";
4
+ import {
5
+ DEFAULT_CITATION_FORMAT,
6
+ stripCitationForTemplate
7
+ } from "./chunk-J6A3CX5N.js";
4
8
  import {
5
9
  inferMemoryStatus
6
10
  } from "./chunk-7RJUVTVF.js";
7
11
  import {
8
12
  ContentHashIndex
9
- } from "./chunk-BQIFZ2MP.js";
13
+ } from "./chunk-CX5SW2EW.js";
14
+ import {
15
+ storedContentIdentityCandidates
16
+ } from "./chunk-JDSVLVCG.js";
17
+ import {
18
+ computeLegacyContentHash
19
+ } from "./chunk-5FVVY2EB.js";
10
20
  import {
11
21
  RECALL_FALLBACK_DIRS
12
22
  } from "./chunk-VS2IYZRU.js";
@@ -15,6 +25,7 @@ import {
15
25
  import { createHash } from "crypto";
16
26
  var RECONCILE_MANIFEST_FORMAT = "remnic-reconcile-manifest";
17
27
  var RECONCILE_MANIFEST_SCHEMA_VERSION = 1;
28
+ var CONTENT_HASH_NORMALIZER_VERSION = 4;
18
29
  var SHA256_PATTERN = /^[a-f0-9]{64}$/i;
19
30
  var MEMORY_DIRS = new Set(RECALL_FALLBACK_DIRS);
20
31
  function isMemoryPath(filePath) {
@@ -24,20 +35,32 @@ function isMemoryPath(filePath) {
24
35
  if (segments[index] === "cold" || segments[index] === "archive") index += 1;
25
36
  return MEMORY_DIRS.has(segments[index] ?? "");
26
37
  }
27
- function parsedMemoryIdentity(filePath, raw, parseMemory) {
38
+ function parsedMemoryIdentity(filePath, raw, parseMemory, citationTemplate) {
28
39
  if (!isMemoryPath(filePath)) return void 0;
29
40
  const parsed = parseMemory(Buffer.isBuffer(raw) ? raw.toString("utf8") : raw);
30
41
  if (!parsed?.frontmatter.id) return void 0;
31
- const storedHash = parsed.frontmatter.contentHash;
32
- const contentHash = storedHash && SHA256_PATTERN.test(storedHash) ? storedHash.toLowerCase() : ContentHashIndex.computeHash(parsed.content);
42
+ const storedHash = parsed.frontmatter.contentHash && SHA256_PATTERN.test(parsed.frontmatter.contentHash) ? parsed.frontmatter.contentHash.toLowerCase() : void 0;
43
+ const candidates = storedContentIdentityCandidates(
44
+ parsed.content,
45
+ (content) => stripCitationForTemplate(content, citationTemplate)
46
+ );
47
+ const bodyHash = ContentHashIndex.computeHash(candidates[0] ?? "");
48
+ const currentMatch = candidates.find(
49
+ (content) => ContentHashIndex.computeHash(content) === storedHash
50
+ );
51
+ const legacyMatch = [...candidates].reverse().find(
52
+ (content) => computeLegacyContentHash(content) === storedHash
53
+ );
54
+ const contentHash = currentMatch ? ContentHashIndex.computeHash(currentMatch) : legacyMatch ? ContentHashIndex.computeHash(legacyMatch) : storedHash ?? bodyHash;
33
55
  return {
34
56
  id: parsed.frontmatter.id,
35
57
  category: parsed.frontmatter.category,
36
58
  contentHash,
59
+ normalizerVersion: CONTENT_HASH_NORMALIZER_VERSION,
37
60
  status: inferMemoryStatus(parsed.frontmatter, filePath)
38
61
  };
39
62
  }
40
- async function buildReconcileManifestFile(file, readFile, parseMemory) {
63
+ async function buildReconcileManifestFile(file, readFile, parseMemory, citationTemplate = DEFAULT_CITATION_FORMAT) {
41
64
  let raw = null;
42
65
  if (isMemoryPath(file.path)) {
43
66
  try {
@@ -49,7 +72,7 @@ async function buildReconcileManifestFile(file, readFile, parseMemory) {
49
72
  if (raw !== null && createHash("sha256").update(raw).digest("hex") !== file.sha256.toLowerCase()) {
50
73
  raw = null;
51
74
  }
52
- const memory = raw === null ? void 0 : parsedMemoryIdentity(file.path, raw, parseMemory);
75
+ const memory = raw === null ? void 0 : parsedMemoryIdentity(file.path, raw, parseMemory, citationTemplate);
53
76
  return { ...file, ...memory ? { memory } : {} };
54
77
  }
55
78
  async function buildReconcileManifest(options) {
@@ -60,11 +83,16 @@ async function buildReconcileManifest(options) {
60
83
  const files = [];
61
84
  for (const file of options.files) {
62
85
  const cached = cachedByPath.get(file.path);
63
- if (cached?.sha256.toLowerCase() === file.sha256.toLowerCase()) {
86
+ if (cached?.sha256.toLowerCase() === file.sha256.toLowerCase() && (cached.memory === void 0 || cached.memory.normalizerVersion === CONTENT_HASH_NORMALIZER_VERSION)) {
64
87
  files.push({ ...file, ...cached.memory ? { memory: cached.memory } : {} });
65
88
  continue;
66
89
  }
67
- files.push(await buildReconcileManifestFile(file, options.readFile, options.parseMemory));
90
+ files.push(await buildReconcileManifestFile(
91
+ file,
92
+ options.readFile,
93
+ options.parseMemory,
94
+ options.citationTemplate
95
+ ));
68
96
  }
69
97
  files.sort((left, right) => left.path < right.path ? -1 : left.path > right.path ? 1 : 0);
70
98
  return {
@@ -82,10 +110,13 @@ function activeFactByPath(manifest) {
82
110
  }
83
111
  return result;
84
112
  }
85
- function contentHashRows(files) {
113
+ function memoryIdentityHashes(memory) {
114
+ return [memory.contentHash];
115
+ }
116
+ function contentHashRows(files, contentHash) {
86
117
  const rows = [];
87
118
  for (const file of files) {
88
- rows.push({ path: file.path, contentHash: file.memory.contentHash });
119
+ rows.push({ path: file.path, contentHash });
89
120
  }
90
121
  return rows;
91
122
  }
@@ -130,33 +161,39 @@ function collapseActiveFactDuplicates(plan, localManifests, peerManifests, prior
130
161
  const localByHash = /* @__PURE__ */ new Map();
131
162
  const peerByHash = /* @__PURE__ */ new Map();
132
163
  for (const file of localByPath.values()) {
133
- const hash = file.memory.contentHash;
134
- const bucket = localByHash.get(hash) ?? [];
135
- bucket.push(file);
136
- localByHash.set(hash, bucket);
164
+ for (const hash of memoryIdentityHashes(file.memory)) {
165
+ const bucket = localByHash.get(hash) ?? [];
166
+ bucket.push(file);
167
+ localByHash.set(hash, bucket);
168
+ }
137
169
  }
138
170
  for (const file of peerByPath.values()) {
139
- const hash = file.memory.contentHash;
140
- const bucket = peerByHash.get(hash) ?? [];
141
- bucket.push(file);
142
- peerByHash.set(hash, bucket);
171
+ for (const hash of memoryIdentityHashes(file.memory)) {
172
+ const bucket = peerByHash.get(hash) ?? [];
173
+ bucket.push(file);
174
+ peerByHash.set(hash, bucket);
175
+ }
143
176
  }
144
177
  const removed = /* @__PURE__ */ new Set();
145
178
  const replacements = [];
179
+ const processedPathPairs = /* @__PURE__ */ new Set();
146
180
  for (const hash of /* @__PURE__ */ new Set([...localByHash.keys(), ...peerByHash.keys()])) {
147
181
  const localCandidates = (localByHash.get(hash) ?? []).filter((file) => {
148
182
  const opposite = peerFilesByPath.get(file.path);
149
183
  const activeOpposite = peerByPath.get(file.path);
150
- return opposite === void 0 || activeOpposite?.memory.contentHash === hash;
184
+ return opposite === void 0 || activeOpposite !== void 0 && memoryIdentityHashes(activeOpposite.memory).includes(hash);
151
185
  });
152
186
  const peerCandidates = (peerByHash.get(hash) ?? []).filter((file) => {
153
187
  const opposite = localFilesByPath.get(file.path);
154
188
  const activeOpposite = localByPath.get(file.path);
155
- return opposite === void 0 || activeOpposite?.memory.contentHash === hash;
189
+ return opposite === void 0 || activeOpposite !== void 0 && memoryIdentityHashes(activeOpposite.memory).includes(hash);
156
190
  });
157
- const localPath = ContentHashIndex.resolvePathByHash(hash, contentHashRows(localCandidates));
158
- const peerPath = ContentHashIndex.resolvePathByHash(hash, contentHashRows(peerCandidates));
191
+ const localPath = ContentHashIndex.resolvePathByHash(hash, contentHashRows(localCandidates, hash));
192
+ const peerPath = ContentHashIndex.resolvePathByHash(hash, contentHashRows(peerCandidates, hash));
159
193
  if (localPath && peerPath && localPath !== peerPath) {
194
+ const pathPair = `${localPath}\0${peerPath}`;
195
+ if (processedPathPairs.has(pathPair)) continue;
196
+ processedPathPairs.add(pathPair);
160
197
  const localFile = localByPath.get(localPath);
161
198
  const peerFile = peerByPath.get(peerPath);
162
199
  if (!localFile || !peerFile) continue;
@@ -247,4 +284,4 @@ export {
247
284
  buildReconcileManifest,
248
285
  collapseActiveFactDuplicates
249
286
  };
250
- //# sourceMappingURL=chunk-VHFXP27N.js.map
287
+ //# sourceMappingURL=chunk-THPPCISA.js.map