@remnic/core 9.51.1 → 9.52.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 (234) hide show
  1. package/dist/access-admin-ops-surface.d.ts +6 -5
  2. package/dist/access-admin-ops-surface.js +16 -16
  3. package/dist/access-authorization-probe.d.ts +6 -5
  4. package/dist/access-authorization-probe.js +17 -17
  5. package/dist/access-boundary.d.ts +6 -5
  6. package/dist/access-boundary.js +16 -16
  7. package/dist/access-cli.js +39 -39
  8. package/dist/access-extraction-force-flush.d.ts +6 -5
  9. package/dist/access-extraction-force-flush.js +16 -16
  10. package/dist/access-http-lcm-compaction.d.ts +6 -5
  11. package/dist/access-http-lifecycle-flush.d.ts +6 -5
  12. package/dist/access-http-offline-stream.d.ts +6 -5
  13. package/dist/access-http-query.js +16 -16
  14. package/dist/access-http.d.ts +6 -5
  15. package/dist/access-http.js +22 -22
  16. package/dist/access-identity-continuity-surface.d.ts +5 -4
  17. package/dist/access-identity-continuity-surface.js +16 -16
  18. package/dist/access-lcm-surface.d.ts +6 -5
  19. package/dist/access-lcm-surface.js +16 -16
  20. package/dist/access-mcp.d.ts +6 -5
  21. package/dist/access-mcp.js +20 -20
  22. package/dist/access-namespace-preflight.js +16 -16
  23. package/dist/access-observe-write-surface.d.ts +6 -5
  24. package/dist/access-observe-write-surface.js +16 -16
  25. package/dist/access-offline-manifest.d.ts +5 -4
  26. package/dist/access-operations-batch.js +17 -17
  27. package/dist/access-operations.d.ts +9 -8
  28. package/dist/access-operations.js +19 -19
  29. package/dist/access-recall-concurrency.d.ts +6 -5
  30. package/dist/access-recall-concurrency.js +16 -16
  31. package/dist/access-recall-response.d.ts +6 -5
  32. package/dist/access-recall-response.js +16 -16
  33. package/dist/access-recall-surface.d.ts +6 -5
  34. package/dist/access-recall-surface.js +16 -16
  35. package/dist/access-schema.d.ts +88 -88
  36. package/dist/{access-service-BY0KJ44c.d.ts → access-service-Cbk3bNbD.d.ts} +3 -3
  37. package/dist/access-service-helpers.d.ts +6 -5
  38. package/dist/access-service.d.ts +6 -5
  39. package/dist/access-service.js +16 -16
  40. package/dist/access-surface-catalog.d.ts +6 -5
  41. package/dist/access-wearables-meetings-surface.d.ts +2 -2
  42. package/dist/bootstrap.d.ts +5 -4
  43. package/dist/briefing.d.ts +1 -1
  44. package/dist/briefing.js +7 -7
  45. package/dist/buffer.d.ts +1 -1
  46. package/dist/{capsule-merge-XMFBXVDP.js → capsule-merge-HCJJMLPS.js} +4 -4
  47. package/dist/causal-consolidation.js +8 -8
  48. package/dist/{chunk-PWN32TAG.js → chunk-2ASAS3CQ.js} +2 -2
  49. package/dist/{chunk-WQM326GS.js → chunk-2LY6GIIE.js} +2 -2
  50. package/dist/{chunk-JL43BVDE.js → chunk-2OIQDTDC.js} +2 -2
  51. package/dist/{chunk-33SV3E43.js → chunk-3OY7KXHM.js} +3 -3
  52. package/dist/{chunk-AIUBBHSF.js → chunk-5UZ6UCOZ.js} +3 -3
  53. package/dist/chunk-5WITETWU.js +591 -0
  54. package/dist/chunk-5WITETWU.js.map +1 -0
  55. package/dist/{chunk-UT5BV5OG.js → chunk-7HXZJAID.js} +2 -2
  56. package/dist/{chunk-M7BXDKPR.js → chunk-7M6NYQWB.js} +3 -3
  57. package/dist/{chunk-TPTECFWR.js → chunk-B6LZ4IBH.js} +3 -3
  58. package/dist/{chunk-J5LLX6IL.js → chunk-BF6SXNQJ.js} +10 -10
  59. package/dist/{chunk-4PC4PRJE.js → chunk-BKIFTXHR.js} +2 -2
  60. package/dist/{chunk-VVG2BOKA.js → chunk-BMEYMKWX.js} +2 -2
  61. package/dist/{chunk-DCZBSE4F.js → chunk-D5YOZ66N.js} +18 -18
  62. package/dist/{chunk-BHXYAVUM.js → chunk-DLG5V6ND.js} +2 -2
  63. package/dist/{chunk-52UKFTUK.js → chunk-F4EU6VUC.js} +2 -2
  64. package/dist/{chunk-M4A44LUA.js → chunk-GSTIBXBW.js} +2 -2
  65. package/dist/{chunk-W5XVQFLM.js → chunk-GXFSQ6SD.js} +2 -2
  66. package/dist/{chunk-XADV5IZ3.js → chunk-HDIUYMSB.js} +5 -5
  67. package/dist/{chunk-FXTYIA46.js → chunk-J272WKX2.js} +2 -2
  68. package/dist/{chunk-ENTCVTQR.js → chunk-JJRVPWFY.js} +11 -1
  69. package/dist/chunk-JJRVPWFY.js.map +1 -0
  70. package/dist/{chunk-JYL3BVVZ.js → chunk-JSEJH2YQ.js} +2 -2
  71. package/dist/{chunk-5UDMFE3Q.js → chunk-MLXZD4WM.js} +2 -2
  72. package/dist/{chunk-PUSLMZBQ.js → chunk-NOEMGE56.js} +2 -2
  73. package/dist/{chunk-C5QLI33R.js → chunk-QINJITDS.js} +2 -2
  74. package/dist/{chunk-45BRYON6.js → chunk-QPOHMO6M.js} +2 -2
  75. package/dist/{chunk-ZQOCRIGA.js → chunk-QYN5PXDZ.js} +3 -3
  76. package/dist/{chunk-PA45XCUD.js → chunk-RANKJI5T.js} +2 -2
  77. package/dist/{chunk-ZHY5TMJG.js → chunk-RMHMUUBW.js} +2392 -628
  78. package/dist/chunk-RMHMUUBW.js.map +1 -0
  79. package/dist/{chunk-37ZO6LLJ.js → chunk-RYLEDKQ2.js} +2 -2
  80. package/dist/{chunk-CV6BBVYV.js → chunk-TEMSWHQD.js} +2 -2
  81. package/dist/{chunk-QGR6OVGT.js → chunk-VFSAWRMZ.js} +2 -2
  82. package/dist/{chunk-NLK2VZYZ.js → chunk-VXCNQYTC.js} +2 -2
  83. package/dist/{chunk-AZ2QBGYB.js → chunk-W7Y5JDVB.js} +1 -1
  84. package/dist/{chunk-VBHPOWBJ.js → chunk-WD5B5AIE.js} +1051 -591
  85. package/dist/chunk-WD5B5AIE.js.map +1 -0
  86. package/dist/{chunk-OYESWJ43.js → chunk-WLRD2TXF.js} +15 -10
  87. package/dist/chunk-WLRD2TXF.js.map +1 -0
  88. package/dist/{chunk-4F6X3RXW.js → chunk-X57M2Q4I.js} +2 -2
  89. package/dist/{chunk-6MTSFX7A.js → chunk-X7XEDOSL.js} +8 -8
  90. package/dist/{chunk-UEVLYVNW.js → chunk-YXKVLYXU.js} +2 -2
  91. package/dist/{chunk-OQAL6SIR.js → chunk-ZMSZVISA.js} +2 -2
  92. package/dist/{cli-CnOkH9hA.d.ts → cli-DMAFI0qt.d.ts} +3 -3
  93. package/dist/cli.d.ts +7 -6
  94. package/dist/cli.js +33 -33
  95. package/dist/compounding/engine.d.ts +1 -1
  96. package/dist/compounding/engine.js +7 -7
  97. package/dist/connectors/codex-materialize-runner.js +7 -7
  98. package/dist/connectors/index.js +7 -7
  99. package/dist/consolidation-provenance-check.d.ts +1 -1
  100. package/dist/consolidation-provenance-check.js +4 -4
  101. package/dist/consolidation-undo.d.ts +1 -1
  102. package/dist/consolidation-undo.js +3 -3
  103. package/dist/contradiction/index.d.ts +1 -1
  104. package/dist/convergence-refresh.d.ts +1 -1
  105. package/dist/convergence-refresh.js +9 -9
  106. package/dist/corpus-watermark.js +9 -9
  107. package/dist/dependency-propagation-delivery-D63r24pH.d.ts +41 -0
  108. package/dist/entity-retrieval.d.ts +1 -1
  109. package/dist/entity-retrieval.js +7 -7
  110. package/dist/explicit-capture.d.ts +5 -4
  111. package/dist/explicit-capture.js +4 -4
  112. package/dist/external-wiki-access.d.ts +6 -5
  113. package/dist/external-wiki-access.js +17 -17
  114. package/dist/external-wiki-mcp-tools.d.ts +6 -5
  115. package/dist/extraction.js +7 -7
  116. package/dist/{forget-UJDJHG6R.js → forget-HDS4N6CG.js} +3 -3
  117. package/dist/harmonic-retrieval.js +1 -1
  118. package/dist/index.d.ts +687 -686
  119. package/dist/index.js +39 -39
  120. package/dist/maintenance/memory-governance.js +7 -7
  121. package/dist/maintenance/rebuild-memory-lifecycle-ledger.d.ts +1 -1
  122. package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +7 -7
  123. package/dist/maintenance/rebuild-memory-projection.d.ts +1 -1
  124. package/dist/maintenance/rebuild-memory-projection.js +8 -8
  125. package/dist/{maintenance-CKwxpdRx.d.ts → maintenance-kBII2qUI.d.ts} +3 -2
  126. package/dist/mcp-memory-inspector-app.d.ts +6 -5
  127. package/dist/memory-worth-outcomes.d.ts +1 -1
  128. package/dist/namespaces/migrate.d.ts +1 -1
  129. package/dist/namespaces/migrate.js +8 -8
  130. package/dist/namespaces/storage.d.ts +1 -1
  131. package/dist/namespaces/storage.js +7 -7
  132. package/dist/operator-doctor-corpus.js +10 -10
  133. package/dist/operator-toolkit.d.ts +1 -1
  134. package/dist/operator-toolkit.js +15 -15
  135. package/dist/orchestration/compression-guideline-coordinator.d.ts +1 -1
  136. package/dist/orchestration/maintenance.d.ts +2 -2
  137. package/dist/orchestration/maintenance.js +12 -12
  138. package/dist/{orchestrator-BshGam-o.d.ts → orchestrator-DHy5LtTy.d.ts} +20 -35
  139. package/dist/orchestrator.d.ts +5 -4
  140. package/dist/orchestrator.js +39 -39
  141. package/dist/page-versioning.js +3 -3
  142. package/dist/schemas.d.ts +138 -138
  143. package/dist/semantic-consolidation.js +8 -8
  144. package/dist/semantic-rule-promotion.js +7 -7
  145. package/dist/semantic-rule-verifier.js +7 -7
  146. package/dist/{service-BIgVM7fL.d.ts → service-PT2_z7xm.d.ts} +1 -1
  147. package/dist/shared-context/manager.d.ts +8 -8
  148. package/dist/source-agent-qualifier.js +7 -7
  149. package/dist/{storage-CVfGWqCI.d.ts → storage-BmVudhk4.d.ts} +46 -27
  150. package/dist/storage.d.ts +1 -1
  151. package/dist/storage.js +6 -6
  152. package/dist/temporal-supersession.d.ts +51 -26
  153. package/dist/temporal-supersession.js +3 -1
  154. package/dist/tier-migration.d.ts +1 -1
  155. package/dist/transfer/capsule-import.js +4 -4
  156. package/dist/transfer/types.d.ts +66 -66
  157. package/dist/verified-recall.js +7 -7
  158. package/package.json +2 -2
  159. package/src/lifecycle/tombstones.ts +30 -0
  160. package/src/orchestration/consolidation-run.ts +324 -106
  161. package/src/orchestration/contradiction-linking-coordinator.ts +237 -64
  162. package/src/orchestration/dependency-propagation-delivery.test.ts +2353 -0
  163. package/src/orchestration/dependency-propagation-delivery.ts +1143 -0
  164. package/src/orchestration/dependency-propagation-queue-state.ts +220 -0
  165. package/src/orchestration/dependency-propagation-recovery-replay.ts +237 -0
  166. package/src/orchestration/dependency-propagation-replay-reconciliation.ts +73 -0
  167. package/src/orchestration/dependency-propagation-triggers.test.ts +1069 -11
  168. package/src/orchestration/dependency-propagation.test.ts +82 -31
  169. package/src/orchestration/dependency-propagation.ts +55 -17
  170. package/src/orchestration/extraction-persist-deps.ts +2 -2
  171. package/src/orchestration/extraction-persist.ts +14 -15
  172. package/src/orchestration/extraction-queue-coordinator.ts +23 -1
  173. package/src/orchestration/extraction-shutdown.ts +29 -0
  174. package/src/orchestration/maintenance.ts +13 -7
  175. package/src/orchestration/turn-ingestion.ts +5 -1
  176. package/src/orchestrator-background-writes.test.ts +265 -1
  177. package/src/orchestrator-extraction-queue.test.ts +39 -0
  178. package/src/orchestrator.ts +59 -58
  179. package/src/storage/committed-invalidation.ts +34 -0
  180. package/src/storage/deletion-revision-store.ts +529 -0
  181. package/src/storage/supersession-audit.ts +41 -0
  182. package/src/storage/supersession-side-effects.ts +52 -25
  183. package/src/storage-contract/failure-semantics.test.ts +12 -0
  184. package/src/storage-contract/round-trip.test.ts +184 -2
  185. package/src/storage-deletion-revisions.test.ts +213 -1
  186. package/src/storage-frontmatter-cas.test.ts +141 -0
  187. package/src/storage-memory-lifecycle-ledger.test.ts +372 -0
  188. package/src/storage-replay.test.ts +149 -0
  189. package/src/storage.ts +345 -358
  190. package/src/temporal-supersession.test.ts +431 -2
  191. package/src/temporal-supersession.ts +567 -107
  192. package/src/testing/subjects/dependency-propagation.test.ts +179 -38
  193. package/dist/chunk-ENTCVTQR.js.map +0 -1
  194. package/dist/chunk-EWMTOVMY.js +0 -484
  195. package/dist/chunk-EWMTOVMY.js.map +0 -1
  196. package/dist/chunk-OYESWJ43.js.map +0 -1
  197. package/dist/chunk-VBHPOWBJ.js.map +0 -1
  198. package/dist/chunk-ZHY5TMJG.js.map +0 -1
  199. /package/dist/{capsule-merge-XMFBXVDP.js.map → capsule-merge-HCJJMLPS.js.map} +0 -0
  200. /package/dist/{chunk-PWN32TAG.js.map → chunk-2ASAS3CQ.js.map} +0 -0
  201. /package/dist/{chunk-WQM326GS.js.map → chunk-2LY6GIIE.js.map} +0 -0
  202. /package/dist/{chunk-JL43BVDE.js.map → chunk-2OIQDTDC.js.map} +0 -0
  203. /package/dist/{chunk-33SV3E43.js.map → chunk-3OY7KXHM.js.map} +0 -0
  204. /package/dist/{chunk-AIUBBHSF.js.map → chunk-5UZ6UCOZ.js.map} +0 -0
  205. /package/dist/{chunk-UT5BV5OG.js.map → chunk-7HXZJAID.js.map} +0 -0
  206. /package/dist/{chunk-M7BXDKPR.js.map → chunk-7M6NYQWB.js.map} +0 -0
  207. /package/dist/{chunk-TPTECFWR.js.map → chunk-B6LZ4IBH.js.map} +0 -0
  208. /package/dist/{chunk-J5LLX6IL.js.map → chunk-BF6SXNQJ.js.map} +0 -0
  209. /package/dist/{chunk-4PC4PRJE.js.map → chunk-BKIFTXHR.js.map} +0 -0
  210. /package/dist/{chunk-VVG2BOKA.js.map → chunk-BMEYMKWX.js.map} +0 -0
  211. /package/dist/{chunk-DCZBSE4F.js.map → chunk-D5YOZ66N.js.map} +0 -0
  212. /package/dist/{chunk-BHXYAVUM.js.map → chunk-DLG5V6ND.js.map} +0 -0
  213. /package/dist/{chunk-52UKFTUK.js.map → chunk-F4EU6VUC.js.map} +0 -0
  214. /package/dist/{chunk-M4A44LUA.js.map → chunk-GSTIBXBW.js.map} +0 -0
  215. /package/dist/{chunk-W5XVQFLM.js.map → chunk-GXFSQ6SD.js.map} +0 -0
  216. /package/dist/{chunk-XADV5IZ3.js.map → chunk-HDIUYMSB.js.map} +0 -0
  217. /package/dist/{chunk-FXTYIA46.js.map → chunk-J272WKX2.js.map} +0 -0
  218. /package/dist/{chunk-JYL3BVVZ.js.map → chunk-JSEJH2YQ.js.map} +0 -0
  219. /package/dist/{chunk-5UDMFE3Q.js.map → chunk-MLXZD4WM.js.map} +0 -0
  220. /package/dist/{chunk-PUSLMZBQ.js.map → chunk-NOEMGE56.js.map} +0 -0
  221. /package/dist/{chunk-C5QLI33R.js.map → chunk-QINJITDS.js.map} +0 -0
  222. /package/dist/{chunk-45BRYON6.js.map → chunk-QPOHMO6M.js.map} +0 -0
  223. /package/dist/{chunk-ZQOCRIGA.js.map → chunk-QYN5PXDZ.js.map} +0 -0
  224. /package/dist/{chunk-PA45XCUD.js.map → chunk-RANKJI5T.js.map} +0 -0
  225. /package/dist/{chunk-37ZO6LLJ.js.map → chunk-RYLEDKQ2.js.map} +0 -0
  226. /package/dist/{chunk-CV6BBVYV.js.map → chunk-TEMSWHQD.js.map} +0 -0
  227. /package/dist/{chunk-QGR6OVGT.js.map → chunk-VFSAWRMZ.js.map} +0 -0
  228. /package/dist/{chunk-NLK2VZYZ.js.map → chunk-VXCNQYTC.js.map} +0 -0
  229. /package/dist/{chunk-AZ2QBGYB.js.map → chunk-W7Y5JDVB.js.map} +0 -0
  230. /package/dist/{chunk-4F6X3RXW.js.map → chunk-X57M2Q4I.js.map} +0 -0
  231. /package/dist/{chunk-6MTSFX7A.js.map → chunk-X7XEDOSL.js.map} +0 -0
  232. /package/dist/{chunk-UEVLYVNW.js.map → chunk-YXKVLYXU.js.map} +0 -0
  233. /package/dist/{chunk-OQAL6SIR.js.map → chunk-ZMSZVISA.js.map} +0 -0
  234. /package/dist/{forget-UJDJHG6R.js.map → forget-HDS4N6CG.js.map} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/temporal-supersession.ts"],"sourcesContent":["/**\n * Temporal Supersession (issue #375)\n *\n * When a new fact lands with `structuredAttributes` keyed on a known\n * `entityRef`, any prior fact whose supersession key collides with the new\n * fact's key is marked `status: \"superseded\"` and linked via\n * `supersededBy` / `supersededAt`. Recall filters those superseded memories\n * by default so agents see only the \"current\" value per entity attribute.\n *\n * The algorithm is intentionally O(N) over the memory corpus per write, but\n * skips cheaply when the new fact has no structuredAttributes. It reuses the\n * cached `readAllMemories()` path so cost is amortized with the rest of the\n * write pipeline.\n */\nimport type { MemoryFile, MemoryFrontmatter, MemoryLifecycleEvent } from \"./types.js\";\n\nimport { createHash } from \"node:crypto\";\nimport { log } from \"./logger.js\";\nimport { effectiveValidAt } from \"./temporal-validity.js\";\nimport type {\n DependencyPropagationDeliveryPort,\n DependencyPropagationPreparationToken,\n} from \"./orchestration/dependency-propagation-delivery.js\";\nimport type { PropagationEvent } from \"./orchestration/dependency-propagation.js\";\nexport interface TemporalSupersessionStorage {\n readAllMemories(): Promise<MemoryFile[]>;\n readAllColdMemories(): Promise<MemoryFile[]>;\n readMemoryByPath(memoryPath: string): Promise<MemoryFile | null>;\n writeMemoryFrontmatterIfUnchanged?: (\n memory: MemoryFile,\n patch: Partial<MemoryFrontmatter>,\n lifecycle?: {\n actor?: string;\n reasonCode?: string;\n relatedMemoryIds?: string[];\n correlationId?: string;\n },\n ) => Promise<boolean>;\n appendTombstone(input: {\n reason: \"supersession\";\n createdBy: \"supersession\";\n sourceMemoryId: string;\n rawContent: string;\n entityRef?: string;\n supersessionKey?: string;\n createdAt?: string;\n contentHash?: string;\n operationKey?: string;\n }): Promise<string | null>;\n hasExactTombstone?: (input: {\n sourceMemoryId: string;\n contentHash?: string;\n entityRef?: string;\n supersessionKey?: string;\n createdAt?: string;\n operationKey?: string;\n }) => Promise<boolean>;\n getMemoryTimeline: (memoryId: string, limit?: number) => Promise<MemoryLifecycleEvent[]>;\n isTombstonesEnabled?: () => boolean;\n}\n\n/**\n * Shared normalization for supersession key components.\n *\n * Trims surrounding whitespace, lowercases, then collapses any run of\n * whitespace OR hyphens to a single hyphen, and strips any leading/trailing\n * hyphens that result. Both `computeSupersessionKey` and\n * `lookupAttributeByNormalizedKey` must use this so that keys produced at\n * write time and keys used at lookup time are identical regardless of how\n * the LLM encoded whitespace, hyphens, or casing (Finding B fix).\n *\n * Symmetry guarantee: `\"foo bar\"`, `\"foo-bar\"`, `\"foo - bar\"`, and\n * `\"foo bar\"` all canonicalize to `\"foo-bar\"`.\n *\n * Exported so external tests can verify the canonical form.\n */\nexport function normalizeSupersessionKey(raw: string): string {\n return raw\n .trim()\n .toLowerCase()\n .replace(/[\\s\\-]+/g, \"-\")\n // The previous line already collapsed runs to single hyphens, so ^-|-$ is\n // equivalent to ^-+|-+$ here and drops the anchored quantifier flagged by\n // CodeQL js/polynomial-redos.\n .replace(/^-|-$/g, \"\");\n}\n\n/**\n * Stable supersession key for an (entityRef, attributeName) pair.\n *\n * The algorithm is:\n * - normalize the entityRef (trim, lower-case, collapse whitespace)\n * - normalize the attributeName the same way\n * - join with `::`\n *\n * Exported so tests and tools can recompute it without depending on storage.\n */\nexport function computeSupersessionKey(\n entityRef: string | undefined,\n attributeName: string,\n): string | null {\n if (!entityRef || typeof entityRef !== \"string\") return null;\n if (!attributeName || typeof attributeName !== \"string\") return null;\n const entity = normalizeSupersessionKey(entityRef);\n const attr = normalizeSupersessionKey(attributeName);\n if (entity.length === 0 || attr.length === 0) return null;\n return `${entity}::${attr}`;\n}\n\n/**\n * Compute the full set of supersession keys for a fact with structured\n * attributes. Returns an empty array if no keys can be derived.\n */\nexport function supersessionKeysForFact(spec: {\n entityRef?: string;\n structuredAttributes?: Record<string, string>;\n}): string[] {\n if (!spec.entityRef) return [];\n if (!spec.structuredAttributes) return [];\n const keys: string[] = [];\n for (const attrName of Object.keys(spec.structuredAttributes)) {\n const key = computeSupersessionKey(spec.entityRef, attrName);\n if (key) keys.push(key);\n }\n return keys;\n}\n\n/**\n * Look up a structured-attribute value by a raw key, normalizing both sides\n * with `normalizeSupersessionKey` before comparing. This ensures that keys\n * written by the LLM with mixed case, surrounding whitespace, or internal\n * whitespace (e.g. `\"City\"`, `\" city \"`, `\"job title\"`, `\"job-title\"`)\n * are all matched against normalized keys produced by `computeSupersessionKey`\n * (Finding B fix — uses the same helper so both sides are identical).\n *\n * The storage format is NOT changed — we only normalize at lookup time.\n */\nexport function lookupAttributeByNormalizedKey(\n attributes: Record<string, unknown>,\n rawKey: string,\n): unknown {\n const normalizedTarget = normalizeSupersessionKey(rawKey);\n for (const [k, v] of Object.entries(attributes)) {\n if (normalizeSupersessionKey(k) === normalizedTarget) return v;\n }\n return undefined;\n}\n\n/**\n * Decide whether an existing memory should be superseded by a newly-written\n * memory that carries the supplied supersession key set.\n *\n * Only memories that:\n * - are currently `active`\n * - share an `entityRef` with the new fact\n * - share at least one supersession key with the new fact\n * - are older than the new fact\n * - have a conflicting value (different string) for the overlapping key\n * are eligible. This keeps supersession local to the attribute that actually\n * changed — if fact A sets `{city: Austin, tool: vim}` and fact B sets\n * `{city: NYC}`, only the city attribute is superseded, not the tool.\n */\nexport function shouldSupersedeExisting(args: {\n candidate: MemoryFrontmatter;\n newEntityRef: string;\n newAttributes: Record<string, string>;\n newCreatedAt: string;\n newMemoryId: string;\n}): { matchedKeys: string[] } | null {\n const { candidate, newEntityRef, newAttributes, newCreatedAt, newMemoryId } = args;\n\n if (candidate.id === newMemoryId) return null;\n if (candidate.status && candidate.status !== \"active\") return null;\n if (!candidate.entityRef) return null;\n if (!candidate.structuredAttributes) return null;\n\n // Reuse the shared `normalizeSupersessionKey` helper so this comparison\n // cannot drift from the canonical form used to build supersession keys\n // elsewhere in this file.\n const candidateEntityNorm = normalizeSupersessionKey(candidate.entityRef);\n const newEntityNorm = normalizeSupersessionKey(newEntityRef);\n if (candidateEntityNorm !== newEntityNorm) return null;\n\n // Must be older than the new fact's effective validity start — equal\n // timestamps are ignored to avoid races within the same millisecond. When\n // replay/import supplies source time, valid_at must drive ordering instead\n // of wall-clock persistence time.\n const candidateCreated = Date.parse(effectiveValidAt(candidate));\n const newCreated = Date.parse(newCreatedAt);\n if (!Number.isFinite(candidateCreated) || !Number.isFinite(newCreated)) return null;\n if (candidateCreated >= newCreated) return null;\n\n const matchedKeys: string[] = [];\n for (const [attrName, newValue] of Object.entries(newAttributes)) {\n // Use normalized key lookup so mixed-case or whitespace-padded keys\n // stored by the LLM are matched correctly (Finding 2 fix).\n const candidateValue = lookupAttributeByNormalizedKey(\n candidate.structuredAttributes,\n attrName,\n );\n if (candidateValue === undefined) continue;\n // Only supersede on conflicting values — identical values are a no-op.\n if (normalizeValue(String(candidateValue)) === normalizeValue(newValue)) continue;\n const key = computeSupersessionKey(newEntityRef, attrName);\n if (key) matchedKeys.push(key);\n }\n\n return matchedKeys.length > 0 ? { matchedKeys } : null;\n}\n\nfunction normalizeValue(v: string): string {\n return v.trim().toLowerCase();\n}\nfunction temporalSupersessionOperationKey(\n sourceMemoryId: string,\n replacementId: string,\n mutation: TemporalSupersessionMutation,\n): string {\n return createHash(\"sha256\")\n .update(\n JSON.stringify({\n sourceMemoryId,\n replacementId,\n cause: \"temporal_supersession\",\n supersededAt: mutation.supersededAt,\n invalidAt: mutation.invalidAt ?? null,\n matchedKeys: [...mutation.matchedKeys].sort(compareByteStable),\n }),\n )\n .digest(\"hex\");\n}\ntype TemporalMemorySnapshot = Pick<MemoryFile, \"content\" | \"frontmatter\">;\nfunction compareByteStable(left: string, right: string): number {\n return Buffer.from(left, \"utf8\").compare(Buffer.from(right, \"utf8\"));\n}\n\nfunction canonicalTemporalValue(value: unknown): unknown {\n if (Array.isArray(value)) return value.map((entry) => canonicalTemporalValue(entry));\n if (value && typeof value === \"object\") {\n return Object.fromEntries(\n Object.entries(value as Record<string, unknown>)\n .sort(([left], [right]) => compareByteStable(left, right))\n .map(([key, entry]) => [key, canonicalTemporalValue(entry)]),\n );\n }\n return value;\n}\n\nfunction temporalSnapshotKey(memory: TemporalMemorySnapshot): string {\n return JSON.stringify(\n canonicalTemporalValue({\n content: memory.content,\n frontmatter: memory.frontmatter,\n }),\n );\n}\n\nfunction temporalMutationPatch(\n replacementId: string,\n mutation: TemporalSupersessionMutation,\n): Partial<MemoryFrontmatter> {\n return {\n status: \"superseded\",\n supersededBy: replacementId,\n supersededAt: mutation.supersededAt,\n updated: mutation.supersededAt,\n ...(mutation.invalidAt ? { invalid_at: mutation.invalidAt } : {}),\n };\n}\n\ntype TemporalPrimaryCommitState = \"committed\" | \"not-committed\" | \"unknown\";\n\nasync function classifyTemporalPrimaryMutation(args: {\n storage: TemporalSupersessionStorage;\n path: string;\n before: TemporalMemorySnapshot;\n patch: Partial<MemoryFrontmatter>;\n}): Promise<TemporalPrimaryCommitState> {\n let current: MemoryFile | null;\n try {\n current = await args.storage.readMemoryByPath(args.path);\n } catch {\n return \"unknown\";\n }\n if (!current) return \"unknown\";\n const beforeKey = temporalSnapshotKey(args.before);\n const committedKey = temporalSnapshotKey({\n content: args.before.content,\n frontmatter: { ...args.before.frontmatter, ...args.patch },\n });\n const currentKey = temporalSnapshotKey(current);\n if (currentKey === committedKey) return \"committed\";\n if (currentKey === beforeKey) return \"not-committed\";\n return \"unknown\";\n}\ntype PreparedTemporalPropagation = {\n delivery: DependencyPropagationDeliveryPort;\n event: PropagationEvent;\n token: DependencyPropagationPreparationToken | null;\n};\n\nasync function settleTemporalPropagationAfterPrimaryFailure(\n pending: PreparedTemporalPropagation,\n commitState: TemporalPrimaryCommitState,\n memoryId: string,\n): Promise<void> {\n let token = pending.token;\n if (commitState === \"not-committed\") {\n if (token !== null) {\n try {\n await pending.delivery.cancel(token);\n } catch (error) {\n log.warn(\n `temporal-supersession: dependency propagation cancellation failed for ${memoryId}: ${error}`,\n );\n }\n }\n return;\n }\n if (token === null && (commitState === \"committed\" || commitState === \"unknown\")) {\n try {\n token = await pending.delivery.prepare(pending.event);\n } catch (error) {\n log.warn(\n `temporal-supersession: dependency propagation recovery preparation failed for ${memoryId}: ${error}`,\n );\n }\n }\n if (token !== null) {\n try {\n await pending.delivery.deferPrepared(token);\n } catch (error) {\n log.warn(`temporal-supersession: dependency propagation defer failed for ${memoryId}: ${error}`);\n }\n return;\n }\n if (commitState === \"committed\") {\n try {\n await pending.delivery.afterMutation(null, pending.event);\n } catch (error) {\n log.warn(`temporal-supersession: dependency propagation fallback failed for ${memoryId}: ${error}`);\n }\n }\n}\n\n\nasync function hasTemporalLifecycleEffect(args: {\n storage: TemporalSupersessionStorage;\n memoryId: string;\n timestamp: string;\n operationKey: string;\n reasonCode: string;\n relatedMemoryIds: string[];\n}): Promise<boolean> {\n const events = await args.storage.getMemoryTimeline(args.memoryId, 200);\n return events.some((event) => {\n if (\n event.memoryId !== args.memoryId ||\n (event.eventType !== \"superseded\" && event.eventType !== \"updated\") ||\n event.timestamp !== args.timestamp ||\n event.after?.status !== \"superseded\"\n ) {\n return false;\n }\n if (event.correlationId !== undefined) return event.correlationId === args.operationKey;\n // Rows written before correlation IDs existed can be replayed only with\n // their complete legacy identity. New rows always take the exact branch.\n return (\n event.reasonCode === args.reasonCode &&\n Array.isArray(event.relatedMemoryIds) &&\n event.relatedMemoryIds.length === args.relatedMemoryIds.length &&\n event.relatedMemoryIds.every((memoryId, index) => memoryId === args.relatedMemoryIds[index])\n );\n });\n}\n\nasync function hasTemporalTombstoneEffect(args: {\n storage: TemporalSupersessionStorage;\n oldMemory: MemoryFile;\n supersessionKey?: string;\n operationKey: string;\n createdAt: string;\n}): Promise<boolean> {\n if (!args.storage.hasExactTombstone) return false;\n return args.storage.hasExactTombstone({\n sourceMemoryId: args.oldMemory.frontmatter.id,\n ...(args.oldMemory.frontmatter.contentHash\n ? { contentHash: args.oldMemory.frontmatter.contentHash }\n : {}),\n ...(args.oldMemory.frontmatter.entityRef\n ? { entityRef: args.oldMemory.frontmatter.entityRef }\n : {}),\n ...(args.supersessionKey ? { supersessionKey: args.supersessionKey } : {}),\n createdAt: args.createdAt,\n operationKey: args.operationKey,\n });\n}\n\n\nasync function ensureTemporalLifecycleEffect(args: {\n storage: TemporalSupersessionStorage;\n memory: MemoryFile;\n replacementId: string;\n mutation: TemporalSupersessionMutation;\n operationKey: string;\n child?: boolean;\n}): Promise<boolean> {\n const reasonCode = args.child\n ? \"structured-attribute-update-child-chunk\"\n : \"structured-attribute-update\";\n const relatedMemoryIds = args.child\n ? [args.replacementId, args.memory.frontmatter.parentId ?? \"\"].filter(Boolean)\n : [args.replacementId];\n const lifecycleEffect = await hasTemporalLifecycleEffect({\n storage: args.storage,\n memoryId: args.memory.frontmatter.id,\n timestamp: args.mutation.supersededAt,\n operationKey: args.operationKey,\n reasonCode,\n relatedMemoryIds,\n });\n if (lifecycleEffect === undefined) return false;\n if (lifecycleEffect === true) return true;\n if (lifecycleEffect === false || args.memory.frontmatter.status !== \"superseded\") {\n if (!args.storage.writeMemoryFrontmatterIfUnchanged) return false;\n const wrote = await args.storage.writeMemoryFrontmatterIfUnchanged(\n args.memory,\n {\n status: \"superseded\",\n supersededBy: args.replacementId,\n supersededAt: args.mutation.supersededAt,\n updated: args.mutation.supersededAt,\n ...(args.mutation.invalidAt && !args.memory.frontmatter.invalid_at\n ? { invalid_at: args.mutation.invalidAt }\n : {}),\n },\n {\n actor: \"temporal-supersession\",\n reasonCode: args.child\n ? \"structured-attribute-update-child-chunk\"\n : \"structured-attribute-update\",\n relatedMemoryIds: args.child\n ? [args.replacementId, args.memory.frontmatter.parentId ?? \"\"].filter(Boolean)\n : [args.replacementId],\n correlationId: args.operationKey,\n },\n );\n return wrote;\n }\n return true;\n}\n\nasync function expireChildChunksForSupersededParent(args: {\n storage: TemporalSupersessionStorage;\n allCandidates: MemoryFile[];\n parentId: string;\n newMemoryId: string;\n supersededAt: string;\n invalidAt?: string;\n operationKey: string;\n}): Promise<boolean> {\n const processedChunkIds = new Set<string>();\n const chunks = args.allCandidates.filter(\n (candidate) => candidate.frontmatter.parentId === args.parentId,\n );\n\n for (const chunk of chunks) {\n const chunkKey = chunk.frontmatter.id ?? chunk.path;\n if (processedChunkIds.has(chunkKey)) continue;\n\n try {\n const freshChunk = await args.storage.readMemoryByPath(chunk.path);\n if (!freshChunk) continue;\n processedChunkIds.add(chunkKey);\n const freshStatus = freshChunk.frontmatter.status ?? \"active\";\n if (\n freshStatus !== \"active\" &&\n !(\n freshStatus === \"superseded\" &&\n freshChunk.frontmatter.supersededBy === args.newMemoryId\n )\n ) {\n continue;\n }\n const completed = await ensureTemporalLifecycleEffect({\n storage: args.storage,\n memory: freshChunk,\n replacementId: args.newMemoryId,\n mutation: {\n supersededAt: args.supersededAt,\n ...(args.invalidAt ? { invalidAt: args.invalidAt } : {}),\n matchedKeys: [],\n },\n operationKey: `${args.operationKey}:child:${freshChunk.frontmatter.id}`,\n child: true,\n });\n if (!completed) return false;\n } catch (err) {\n log.warn(\n `temporal-supersession: failed to expire child chunk ${chunk.frontmatter.id} for parent ${args.parentId}: ${err}`,\n );\n return false;\n }\n }\n return true;\n}\n\nexport interface TemporalSupersessionMutation {\n supersededAt: string;\n invalidAt?: string;\n matchedKeys: string[];\n}\n\nexport async function applyTemporalSupersessionPrimaryMutation(args: {\n storage: TemporalSupersessionStorage;\n oldMemory: MemoryFile;\n replacementId: string;\n mutation: TemporalSupersessionMutation;\n allCandidates?: MemoryFile[];\n}): Promise<boolean> {\n const { storage, oldMemory, replacementId, mutation } = args;\n if (typeof storage.getMemoryTimeline !== \"function\") {\n log.warn(\"temporal-supersession: required memory timeline adapter is missing\");\n return false;\n }\n const operationKey = temporalSupersessionOperationKey(\n oldMemory.frontmatter.id,\n replacementId,\n mutation,\n );\n const alreadyApplied =\n oldMemory.frontmatter.status === \"superseded\" &&\n oldMemory.frontmatter.supersededBy === replacementId &&\n oldMemory.frontmatter.supersededAt === mutation.supersededAt &&\n (mutation.invalidAt === undefined || oldMemory.frontmatter.invalid_at === mutation.invalidAt);\n const lifecycleEffect = alreadyApplied\n ? await hasTemporalLifecycleEffect({\n storage,\n memoryId: oldMemory.frontmatter.id,\n timestamp: mutation.supersededAt,\n operationKey,\n reasonCode: \"structured-attribute-update\",\n relatedMemoryIds: [replacementId],\n })\n : undefined;\n if (alreadyApplied && lifecycleEffect === undefined) return false;\n if (!alreadyApplied || lifecycleEffect === false) {\n if (!storage.writeMemoryFrontmatterIfUnchanged) return false;\n const wrote = await storage.writeMemoryFrontmatterIfUnchanged(\n oldMemory,\n temporalMutationPatch(replacementId, mutation),\n {\n actor: \"temporal-supersession\",\n reasonCode: \"structured-attribute-update\",\n relatedMemoryIds: [replacementId],\n correlationId: operationKey,\n },\n );\n if (!wrote) return false;\n }\n\n let allCandidates = args.allCandidates;\n if (!allCandidates) {\n let hotMemories: MemoryFile[];\n let coldMemories: MemoryFile[];\n try {\n hotMemories = await storage.readAllMemories();\n } catch (error) {\n log.warn(`temporal-supersession: recovery hot-memory scan failed: ${error}`);\n return false;\n }\n try {\n coldMemories = await storage.readAllColdMemories();\n } catch (error) {\n log.warn(`temporal-supersession: recovery cold-memory scan failed: ${error}`);\n return false;\n }\n allCandidates = [...hotMemories, ...coldMemories];\n }\n const childrenCompleted = await expireChildChunksForSupersededParent({\n storage,\n allCandidates,\n parentId: oldMemory.frontmatter.id,\n newMemoryId: replacementId,\n supersededAt: mutation.supersededAt,\n invalidAt: mutation.invalidAt ?? oldMemory.frontmatter.invalid_at,\n operationKey,\n });\n if (!childrenCompleted) return false;\n\n const keysToTombstone =\n mutation.matchedKeys.length > 0 ? mutation.matchedKeys : [undefined];\n for (const key of keysToTombstone) {\n const tombstoneOperationKey = `${operationKey}:tombstone:${key ?? \"content\"}`;\n if (\n await hasTemporalTombstoneEffect({\n storage,\n oldMemory,\n supersessionKey: key,\n operationKey: tombstoneOperationKey,\n createdAt: mutation.supersededAt,\n })\n ) {\n continue;\n }\n try {\n const tombstoneId = await storage.appendTombstone({\n reason: \"supersession\",\n createdBy: \"supersession\",\n sourceMemoryId: oldMemory.frontmatter.id,\n ...(oldMemory.frontmatter.contentHash\n ? { contentHash: oldMemory.frontmatter.contentHash }\n : {}),\n rawContent: oldMemory.content,\n ...(oldMemory.frontmatter.entityRef ? { entityRef: oldMemory.frontmatter.entityRef } : {}),\n ...(key ? { supersessionKey: key } : {}),\n createdAt: mutation.supersededAt,\n operationKey: tombstoneOperationKey,\n });\n if (tombstoneId === null && storage.isTombstonesEnabled?.() !== false) {\n return false;\n }\n } catch (error) {\n log.warn(\n `temporal-supersession: tombstone emit failed for ${oldMemory.frontmatter.id}${key ? ` (key=${key})` : \"\"} : ${error}`,\n );\n return false;\n }\n }\n return true;\n}\n\nexport interface TemporalSupersessionResult {\n supersededIds: string[];\n matchedKeys: string[];\n}\n\n/**\n * Scan existing memories and mark any that are superseded by the\n * just-written memory. Fails open on I/O errors — the new memory is already\n * on disk, and supersession is a best-effort hygiene step.\n */\nexport async function applyTemporalSupersession(args: {\n storage: TemporalSupersessionStorage;\n newMemoryId: string;\n entityRef?: string;\n structuredAttributes?: Record<string, string>;\n createdAt: string;\n enabled: boolean;\n /**\n * When true, skip the persisted `frontmatter.created` lookup and use\n * `args.createdAt` directly as the ordering anchor. Set this on the\n * hash-dedup short-circuit path where `newMemoryId` points to an existing\n * OLD fact (no new file is written) and its persisted timestamp would be\n * stale relative to the incoming promotion event (PR #402 Finding Uyui).\n */\n useCallerTimestamp?: boolean;\n /** Namespace used by the dependency propagation worker. */\n namespaceScope?: string;\n /** Optional durable delivery for one-hop propagation. */\n dependencyPropagationDelivery?: DependencyPropagationDeliveryPort;\n}): Promise<TemporalSupersessionResult> {\n const empty: TemporalSupersessionResult = { supersededIds: [], matchedKeys: [] };\n const createdAtMs = typeof args.createdAt === \"string\" ? Date.parse(args.createdAt) : Number.NaN;\n if (!Number.isFinite(createdAtMs)) {\n log.warn(`temporal-supersession: refusing mutation with invalid createdAt: ${String(args.createdAt)}`);\n return empty;\n }\n // Validate the caller's ordering anchor before any corpus scan or durable\n // side-effect preparation. A malformed timestamp must be a true no-op:\n // otherwise a later monotonic clamp could manufacture a 1970 mutation and\n // leave a prepared propagation job without a replayable temporal identity.\n if (!args.enabled) return empty;\n if (!args.entityRef) return empty;\n if (!args.structuredAttributes) return empty;\n if (Object.keys(args.structuredAttributes).length === 0) return empty;\n if (typeof args.storage.getMemoryTimeline !== \"function\") {\n log.warn(\"temporal-supersession: required memory timeline adapter is missing\");\n return empty;\n }\n\n const newKeys = supersessionKeysForFact({\n entityRef: args.entityRef,\n structuredAttributes: args.structuredAttributes,\n });\n if (newKeys.length === 0) return empty;\n\n let hotMemories: MemoryFile[];\n try {\n hotMemories = await args.storage.readAllMemories();\n } catch (err) {\n log.warn(`temporal-supersession: readAllMemories failed: ${err}`);\n return empty;\n }\n\n // Finding 1 fix: use the on-disk effective validity start of the\n // newly-written memory rather than a wall-clock timestamp sampled after\n // `writeMemory` returns. In concurrent writers the two can differ by enough\n // to cause wrong-direction supersession. If source replay/import provided\n // valid_at, it must drive ordering; otherwise created remains the legacy\n // fallback. If the memory is not yet visible in the cache (edge case during\n // fast concurrent writes) fall back to args.createdAt.\n //\n // PR #402 round-12 (Finding Uyui): on the hash-dedup early-return path the\n // caller supplies the OLD matching fact's id as `newMemoryId` (no new file is\n // written). That makes `newMemoryFile.frontmatter.created` an arbitrarily\n // old timestamp. When `args.useCallerTimestamp` is set the caller explicitly\n // opts out of the persisted-timestamp lookup so `args.createdAt` (the\n // incoming event time: source valid_at when present, otherwise wall-clock) is\n // used directly, keeping ordering correct regardless of how old the matching\n // fact is.\n const newMemoryFile = hotMemories.find((m) => m.frontmatter.id === args.newMemoryId);\n const persistedCreatedAt = args.useCallerTimestamp\n ? args.createdAt\n : (newMemoryFile ? effectiveValidAt(newMemoryFile.frontmatter) : args.createdAt);\n\n const supersededIds: string[] = [];\n const matchedKeys = new Set<string>();\n\n // Process hot then cold. Hot-then-cold ordering is safer because hot\n // writes are more frequent and the CAS re-read guards against double-writes.\n // A Set<string> of already-processed ids ensures that a memory visible in\n // both tiers (same logical memory with different filesystem paths during a\n // migration race) is processed at most once. Keying on `frontmatter.id`\n // is correct because the same logical memory has the same id regardless of\n // which tier's directory it currently lives in (PR #402 Finding 1 fix).\n // Fall back to path-based keying when id is absent (defensive).\n const processedIds = new Set<string>();\n\n // Finding UOGi fix (round-6): readAllColdMemories() performs a full uncached\n // recursive directory scan of cold/. After Finding UTsP broadened the scan\n // to cover the entire cold root (not just facts/+corrections/), the per-call\n // cost grows with the cold tree size.\n //\n // The fix is a TTL-based in-memory cache inside StorageManager\n // (readAllColdMemories caches its result for COLD_SCAN_CACHE_TTL_MS) that is\n // shared across consecutive supersession calls within the same write burst.\n // The cache is invalidated automatically on any hot→cold demotion (which\n // calls invalidateAllMemoriesCache, which also clears the cold cache) and\n // expires after the TTL as a safety net.\n //\n // This means back-to-back structured-attribute writes in the same burst\n // (e.g. batch extraction) pay the cold I/O cost at most once, not N times.\n // Correctness is preserved because the cache TTL ensures eventual consistency\n // and the invalidation hook covers the hot→cold path.\n\n let coldMemories: MemoryFile[];\n try {\n coldMemories = await args.storage.readAllColdMemories();\n } catch (err) {\n log.warn(`temporal-supersession: readAllColdMemories failed: ${err}`);\n coldMemories = [];\n }\n\n // Combine hot and cold memories into a single scan. New memory itself is\n // excluded inline. We do NOT skip cold scan when hot produced zero\n // supersessions — the P1 finding is precisely that stale cold facts leak\n // when hot has no hits.\n const allCandidates: MemoryFile[] = [...hotMemories, ...coldMemories];\n // Resolve the replacement from the combined hot and cold snapshot. A\n // hash-dedup promotion can point at a cold-only memory, and replay needs its\n // captured content rather than a null replacement payload.\n const replacementMemory =\n allCandidates.find((memory) => memory.frontmatter.id === args.newMemoryId) ?? newMemoryFile;\n\n for (const memory of allCandidates) {\n if (memory.frontmatter.id === args.newMemoryId) continue;\n const dedupeKey = memory.frontmatter.id ?? memory.path;\n if (processedIds.has(dedupeKey)) continue;\n const snapshotStatus = memory.frontmatter.status ?? \"active\";\n if (snapshotStatus !== \"active\") {\n // A stale non-active snapshot entry must not suppress an active copy of\n // the same logical memory that appears later in another tier. This can\n // happen during hot/cold migration races where the hot snapshot is already\n // superseded but the cold copy is still active and should be evaluated.\n continue;\n }\n // NOTE: do NOT call processedIds.add(dedupeKey) here. We defer marking\n // the id as processed until AFTER the CAS re-read succeeds. If we mark\n // it here and the re-read fails (e.g. the hot entry has already been\n // migrated to cold storage), the same logical id that appears later in\n // the cold tier scan would be silently skipped, leaving a stale cold\n // fact unsuperseded. Deferring ensures that a failed primary-tier read\n // grants the alternate tier a chance to process the same id (PR #402\n // round-6 Finding 1 fix).\n\n const decision = shouldSupersedeExisting({\n candidate: memory.frontmatter,\n newEntityRef: args.entityRef,\n newAttributes: args.structuredAttributes,\n newCreatedAt: persistedCreatedAt,\n newMemoryId: args.newMemoryId,\n });\n if (!decision) {\n // No supersession decision — safe to mark as processed now so the\n // alternate tier doesn't re-evaluate an identical non-matching entry.\n processedIds.add(dedupeKey);\n continue;\n }\n\n let preparedPropagation: {\n delivery: DependencyPropagationDeliveryPort;\n event: PropagationEvent;\n token: DependencyPropagationPreparationToken | null;\n } | null = null;\n let primaryPath: string | null = null;\n let primaryBefore: TemporalMemorySnapshot | null = null;\n let primaryPatch: Partial<MemoryFrontmatter> | null = null;\n try {\n // CAS-style re-read immediately before the write. `readAllMemories()`\n // is a snapshot — with concurrent writers, another run may have already\n // superseded this candidate since we loaded it. If we blindly trust the\n // snapshot we can clobber a newer `supersededBy` link with a stale one.\n //\n // File storage offers no true locking, so the best we can do is:\n // 1. re-read the exact file we're about to mutate\n // 2. verify status is still \"active\" and no `supersededBy` is set\n // 3. only then issue the write\n // If the re-read shows a newer concurrent writer beat us to it, skip.\n // This CAS pattern applies equally to hot and cold tier candidates.\n // Mark as processed AFTER confirming the candidate is readable so that\n // a migration-race read failure on the hot entry does not silently\n // prevent the cold entry from being evaluated (Finding 1, round 6).\n const fresh = await args.storage.readMemoryByPath(memory.path);\n if (!fresh) {\n log.debug(\n `[engram] temporal supersession skipped candidate ${memory.frontmatter.id}: no longer readable at ${memory.path} — leaving id available for alternate tier`,\n );\n // Do NOT add to processedIds — allow the cold-tier copy to be\n // evaluated in the next iteration of the same scan.\n continue;\n }\n // Candidate is readable — mark the id as processed now to prevent the\n // alternate tier from double-writing.\n processedIds.add(dedupeKey);\n const freshStatus = fresh.frontmatter.status ?? \"active\";\n if (freshStatus !== \"active\" || fresh.frontmatter.supersededBy) {\n log.debug(\n `[engram] temporal supersession skipped candidate ${memory.frontmatter.id}: already superseded by concurrent writer`,\n );\n continue;\n }\n primaryPath = fresh.path;\n primaryBefore = {\n content: fresh.content,\n frontmatter: { ...fresh.frontmatter },\n };\n\n // Finding 2 fix: the `supersededAt` / `updated` timestamps written to the\n // old fact must never run backwards relative to its own persisted\n // `created` timestamp. If the caller-supplied `args.createdAt` (which\n // represents \"when the new replacing fact was authored\") is earlier than\n // either the new fact's persisted `created` (T_new) or the old fact's\n // persisted `created` (T_old), we'd be writing a nonsensical\n // `supersededAt` that precedes the old memory's own creation. Clamp to\n // the monotonic maximum so time only moves forward.\n // This monotonic clamp is applied for both hot and cold tier writes.\n const oldCreatedMs = new Date(fresh.frontmatter.created).getTime();\n const newCreatedMs = new Date(persistedCreatedAt).getTime();\n const argCreatedMs = new Date(args.createdAt).getTime();\n const maxMs = Math.max(\n Number.isFinite(oldCreatedMs) ? oldCreatedMs : 0,\n Number.isFinite(newCreatedMs) ? newCreatedMs : 0,\n Number.isFinite(argCreatedMs) ? argCreatedMs : 0,\n );\n const supersededAt = new Date(maxMs).toISOString();\n\n // Issue #680 — explicit fact lifecycle. When the new fact\n // supersedes this one, set the predecessor's `invalid_at` to the\n // successor's effective valid_at. Skip when the predecessor\n // already carries an `invalid_at` so manual / earlier values\n // are preserved (idempotent).\n //\n // Codex P1 on PR #713: in the hash-dedup early-return path\n // (`useCallerTimestamp: true`), `newMemoryFile` is actually the\n // OLD matching fact — no new file was written — so its\n // `valid_at` is the predecessor's own old timestamp, not the\n // successor's effective time. Use `persistedCreatedAt`\n // directly in that path so the predecessor's invalid_at lines\n // up with the caller's wall-clock, not the matching fact's old\n // valid_at. The non-dedup path keeps the previous behavior\n // (prefer the new file's explicit valid_at, fall back to its\n // persisted created).\n let invalidAtPatch: string | undefined;\n if (!fresh.frontmatter.invalid_at) {\n if (args.useCallerTimestamp) {\n invalidAtPatch = persistedCreatedAt;\n } else {\n const newValidAt = replacementMemory?.frontmatter.valid_at?.trim();\n invalidAtPatch =\n newValidAt && newValidAt.length > 0 ? newValidAt : persistedCreatedAt;\n }\n }\n const mutation: TemporalSupersessionMutation = {\n supersededAt,\n ...(invalidAtPatch ? { invalidAt: invalidAtPatch } : {}),\n matchedKeys: decision.matchedKeys,\n };\n primaryPatch = temporalMutationPatch(args.newMemoryId, mutation);\n const propagationEvent: PropagationEvent | null =\n args.dependencyPropagationDelivery && args.namespaceScope\n ? {\n oldMemory: {\n content: fresh.content,\n frontmatter: {\n ...fresh.frontmatter,\n ...(fresh.frontmatter.links\n ? { links: fresh.frontmatter.links.map((link) => ({ ...link })) }\n : {}),\n },\n },\n replacementId: args.newMemoryId,\n replacementContent: replacementMemory?.content ?? null,\n cause: \"temporal_supersession\",\n namespaceScope: args.namespaceScope,\n temporalMutation: mutation,\n }\n : null;\n if (propagationEvent && args.dependencyPropagationDelivery) {\n preparedPropagation = {\n delivery: args.dependencyPropagationDelivery,\n event: propagationEvent,\n token: null,\n };\n try {\n preparedPropagation.token =\n await args.dependencyPropagationDelivery.prepare(propagationEvent);\n } catch (prepareErr) {\n log.warn(\n `temporal-supersession: dependency propagation preparation failed for ${fresh.frontmatter.id}: ${prepareErr}`,\n );\n }\n }\n const wrote = await applyTemporalSupersessionPrimaryMutation({\n storage: args.storage,\n oldMemory: fresh,\n replacementId: args.newMemoryId,\n mutation,\n allCandidates,\n });\n if (!wrote) {\n const commitState = await classifyTemporalPrimaryMutation({\n storage: args.storage,\n path: fresh.path,\n before: primaryBefore,\n patch: primaryPatch,\n });\n if (preparedPropagation) {\n await settleTemporalPropagationAfterPrimaryFailure(\n preparedPropagation,\n commitState,\n fresh.frontmatter.id,\n );\n if (commitState !== \"not-committed\") {\n log.warn(\n `temporal-supersession: retaining dependency propagation recovery for ${fresh.frontmatter.id} after ${commitState} primary mutation`,\n );\n }\n }\n preparedPropagation = null;\n continue;\n }\n if (preparedPropagation) {\n const completedPropagation = preparedPropagation;\n preparedPropagation = null;\n try {\n await completedPropagation.delivery.afterMutation(\n completedPropagation.token,\n completedPropagation.event,\n );\n } catch (afterMutationErr) {\n log.warn(\n `temporal-supersession: dependency propagation delivery failed for ${memory.frontmatter.id}: ${afterMutationErr}`,\n );\n }\n }\n supersededIds.push(memory.frontmatter.id);\n for (const key of decision.matchedKeys) matchedKeys.add(key);\n } catch (err) {\n let commitState: TemporalPrimaryCommitState = \"unknown\";\n if (primaryPath && primaryBefore && primaryPatch) {\n commitState = await classifyTemporalPrimaryMutation({\n storage: args.storage,\n path: primaryPath,\n before: primaryBefore,\n patch: primaryPatch,\n });\n }\n if (preparedPropagation) {\n await settleTemporalPropagationAfterPrimaryFailure(\n preparedPropagation,\n commitState,\n memory.frontmatter.id,\n );\n if (commitState !== \"not-committed\") {\n log.warn(\n `temporal-supersession: retaining dependency propagation recovery for ${memory.frontmatter.id} after ${commitState} primary mutation`,\n );\n }\n }\n preparedPropagation = null;\n log.warn(\n `temporal-supersession: failed to mark ${memory.frontmatter.id} superseded: ${err}`,\n );\n }\n }\n\n if (supersededIds.length > 0) {\n log.debug(\n `temporal-supersession: marked ${supersededIds.length} memories superseded by ${args.newMemoryId} (keys=${Array.from(matchedKeys).join(\",\")})`,\n );\n }\n\n return { supersededIds, matchedKeys: Array.from(matchedKeys) };\n}\n\n/**\n * Recall-side filter: returns true when the candidate should be excluded\n * from recall because it has been temporally superseded. When\n * `includeInRecall` is true, this always returns false (the fact is kept),\n * matching the audit/history opt-in described in the config.\n */\nexport function shouldFilterSupersededFromRecall(\n frontmatter: MemoryFrontmatter,\n options: { enabled: boolean; includeInRecall: boolean },\n): boolean {\n if (!options.enabled) return false;\n if (options.includeInRecall) return false;\n return frontmatter.status === \"superseded\";\n}\n"],"mappings":";;;;;;;;AAgBA,SAAS,kBAAkB;AA4DpB,SAAS,yBAAyB,KAAqB;AAC5D,SAAO,IACJ,KAAK,EACL,YAAY,EACZ,QAAQ,YAAY,GAAG,EAIvB,QAAQ,UAAU,EAAE;AACzB;AAYO,SAAS,uBACd,WACA,eACe;AACf,MAAI,CAAC,aAAa,OAAO,cAA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AiB,cAAc;AAChD,sBAAc,MAAM,gCAAgC;AAAA,UAClD,SAAS,KAAK;AAAA,UACd,MAAM;AAAA,UACN,QAAQ;AAAA,UACR,OAAO;AAAA,QACT,CAAC;AAAA,MACH;AACA,UAAI,qBAAqB;AACvB,cAAM;AAAA,UACJ;AAAA,UACA;AAAA,UACA,OAAO,YAAY;AAAA,QACrB;AACA,YAAI,gBAAgB,iBAAiB;AACnC,cAAI;AAAA,YACF,wEAAwE,OAAO,YAAY,EAAE,UAAU,WAAW;AAAA,UACpH;AAAA,QACF;AAAA,MACF;AACA,4BAAsB;AACtB,UAAI;AAAA,QACF,yCAAyC,OAAO,YAAY,EAAE,gBAAgB,GAAG;AAAA,MACnF;AAAA,IACF;AAAA,EACF;AAEA,MAAI,cAAc,SAAS,GAAG;AAC5B,QAAI;AAAA,MACF,iCAAiC,cAAc,MAAM,2BAA2B,KAAK,WAAW,UAAU,MAAM,KAAK,WAAW,EAAE,KAAK,GAAG,CAAC;AAAA,IAC7I;AAAA,EACF;AAEA,SAAO,EAAE,eAAe,aAAa,MAAM,KAAK,WAAW,EAAE;AAC/D;AAQO,SAAS,iCACd,aACA,SACS;AACT,MAAI,CAAC,QAAQ,QAAS,QAAO;AAC7B,MAAI,QAAQ,gBAAiB,QAAO;AACpC,SAAO,YAAY,WAAW;AAChC;","names":[]}
@@ -7,7 +7,7 @@ import {
7
7
  } from "./chunk-66SE3BNH.js";
8
8
  import {
9
9
  StorageManager
10
- } from "./chunk-VBHPOWBJ.js";
10
+ } from "./chunk-WD5B5AIE.js";
11
11
  import {
12
12
  parseContinuityImprovementLoops
13
13
  } from "./chunk-LDXUBPMO.js";
@@ -1283,4 +1283,4 @@ export {
1283
1283
  defaultTierMigrationCycleBudget,
1284
1284
  CompoundingEngine
1285
1285
  };
1286
- //# sourceMappingURL=chunk-UT5BV5OG.js.map
1286
+ //# sourceMappingURL=chunk-7HXZJAID.js.map
@@ -28,10 +28,10 @@ import {
28
28
  defineOperation,
29
29
  parseNamespacePreflightWriteOp,
30
30
  resolveAuthorizedNamespaceWritablePreflight
31
- } from "./chunk-J5LLX6IL.js";
31
+ } from "./chunk-BF6SXNQJ.js";
32
32
  import {
33
33
  validateBriefingFormat
34
- } from "./chunk-52UKFTUK.js";
34
+ } from "./chunk-F4EU6VUC.js";
35
35
  import {
36
36
  enforceNamespaceAllowList,
37
37
  tokenCapabilityStore
@@ -494,4 +494,4 @@ defineOperation({ name: "graph_events", description: "SSE graph events.", schema
494
494
  defineOperation({ name: "chat_message", description: "Chat message.", schema: strictSchema({ message: S.str, chatSessionId: S.str }), handler: async (_i, _ctx) => ({ result: { ok: true } }) });
495
495
  defineOperation({ name: "chat_events", description: "SSE chat events.", schema: strictSchema({}), handler: async (_i, _ctx) => ({ result: { stream: "sse" } }) });
496
496
  defineOperation({ name: "adapters_status", description: "Adapter registry metadata (issue #1850 round 5). Marker op: the HTTP transport builds the response from its own adapterRegistry, but the op still must be registered so it appears in listRegisteredOperations and enforceTokenOp can gate it for scoped tokens.", schema: strictSchema({}), handler: async (_i, _ctx) => ({ result: { ok: true } }) });
497
- //# sourceMappingURL=chunk-M7BXDKPR.js.map
497
+ //# sourceMappingURL=chunk-7M6NYQWB.js.map
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  StorageManager
3
- } from "./chunk-VBHPOWBJ.js";
3
+ } from "./chunk-WD5B5AIE.js";
4
4
  import {
5
5
  bumpMemoryCorpusVersionForDir
6
6
  } from "./chunk-KMAP7SNQ.js";
7
7
  import {
8
8
  requestEntityCanonicalIdReconcile
9
- } from "./chunk-M4A44LUA.js";
9
+ } from "./chunk-GSTIBXBW.js";
10
10
  import {
11
11
  decideLifecycleTransition
12
12
  } from "./chunk-TBBDFYXW.js";
@@ -759,4 +759,4 @@ export {
759
759
  listMemoryGovernanceRuns,
760
760
  readMemoryGovernanceRunArtifact
761
761
  };
762
- //# sourceMappingURL=chunk-TPTECFWR.js.map
762
+ //# sourceMappingURL=chunk-B6LZ4IBH.js.map
@@ -8,7 +8,7 @@ import {
8
8
  } from "./chunk-GDB4J2H3.js";
9
9
  import {
10
10
  importCapsule
11
- } from "./chunk-ZQOCRIGA.js";
11
+ } from "./chunk-QYN5PXDZ.js";
12
12
  import {
13
13
  WriteQuarantineStore
14
14
  } from "./chunk-PJSK6OJM.js";
@@ -45,7 +45,7 @@ import {
45
45
  } from "./chunk-QHFV6VNU.js";
46
46
  import {
47
47
  readAggregateExtractionWatermark
48
- } from "./chunk-JYL3BVVZ.js";
48
+ } from "./chunk-JSEJH2YQ.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-37ZO6LLJ.js";
87
+ } from "./chunk-RYLEDKQ2.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-TPTECFWR.js";
98
+ } from "./chunk-B6LZ4IBH.js";
99
99
  import {
100
100
  CorpusWatermarkCache,
101
101
  computeServiceCorpusCensus
102
- } from "./chunk-NLK2VZYZ.js";
102
+ } from "./chunk-VXCNQYTC.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-52UKFTUK.js";
123
+ } from "./chunk-F4EU6VUC.js";
124
124
  import {
125
125
  parseEntityFile,
126
126
  parseFrontmatter,
127
127
  qmdCollectionPathParts,
128
128
  qmdResultPathCandidates,
129
129
  selfDeps
130
- } from "./chunk-VBHPOWBJ.js";
130
+ } from "./chunk-WD5B5AIE.js";
131
131
  import {
132
132
  DEFAULT_RECALL_DISCLOSURE,
133
133
  isRecallDisclosure
@@ -153,10 +153,10 @@ import {
153
153
  } from "./chunk-R3DJVOSM.js";
154
154
  import {
155
155
  createVersion
156
- } from "./chunk-OQAL6SIR.js";
156
+ } from "./chunk-ZMSZVISA.js";
157
157
  import {
158
158
  supersessionKeysForFact
159
- } from "./chunk-EWMTOVMY.js";
159
+ } from "./chunk-5WITETWU.js";
160
160
  import {
161
161
  ExtractionDeadlineError,
162
162
  isActivityDigestPath,
@@ -13523,4 +13523,4 @@ export {
13523
13523
  EngramAccessService,
13524
13524
  AccessAdminOpsSurface
13525
13525
  };
13526
- //# sourceMappingURL=chunk-J5LLX6IL.js.map
13526
+ //# sourceMappingURL=chunk-BF6SXNQJ.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  resolveDefaultNamespaceRoot,
3
3
  resolveNamespaceStorageRoot
4
- } from "./chunk-WQM326GS.js";
4
+ } from "./chunk-2LY6GIIE.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-4PC4PRJE.js.map
2207
+ //# sourceMappingURL=chunk-BKIFTXHR.js.map
@@ -5,7 +5,7 @@ import {
5
5
  } from "./chunk-JLNBQWZ2.js";
6
6
  import {
7
7
  runPostConsolidationMaterialize
8
- } from "./chunk-PUSLMZBQ.js";
8
+ } from "./chunk-NOEMGE56.js";
9
9
  import {
10
10
  isSemanticConsolidationLlmOperator
11
11
  } from "./chunk-G7D6GZ5J.js";
@@ -220,4 +220,4 @@ export {
220
220
  buildExtensionsBlockForConsolidation,
221
221
  materializeAfterSemanticConsolidation
222
222
  };
223
- //# sourceMappingURL=chunk-VVG2BOKA.js.map
223
+ //# sourceMappingURL=chunk-BMEYMKWX.js.map
@@ -54,7 +54,7 @@ import {
54
54
  } from "./chunk-IIFFC3RL.js";
55
55
  import {
56
56
  rebuildMemoryLifecycleLedger
57
- } from "./chunk-UEVLYVNW.js";
57
+ } from "./chunk-YXKVLYXU.js";
58
58
  import {
59
59
  rebuildObservations
60
60
  } from "./chunk-DQTCGVFK.js";
@@ -80,16 +80,16 @@ import {
80
80
  } from "./chunk-6FC3IZ26.js";
81
81
  import {
82
82
  searchVerifiedEpisodes
83
- } from "./chunk-FXTYIA46.js";
83
+ } from "./chunk-J272WKX2.js";
84
84
  import {
85
85
  ThreadingManager
86
86
  } from "./chunk-OJP3N7UK.js";
87
87
  import {
88
88
  promoteSemanticRuleFromMemory
89
- } from "./chunk-4F6X3RXW.js";
89
+ } from "./chunk-X57M2Q4I.js";
90
90
  import {
91
91
  searchVerifiedSemanticRules
92
- } from "./chunk-QGR6OVGT.js";
92
+ } from "./chunk-VFSAWRMZ.js";
93
93
  import {
94
94
  buildResumeBundleFromState,
95
95
  getResumeBundleStatus,
@@ -127,7 +127,7 @@ import {
127
127
  runOperatorInventory,
128
128
  runOperatorRepair,
129
129
  runOperatorSetup
130
- } from "./chunk-6MTSFX7A.js";
130
+ } from "./chunk-X7XEDOSL.js";
131
131
  import {
132
132
  analyzeSessionIntegrity,
133
133
  applySessionRepair,
@@ -152,7 +152,7 @@ import {
152
152
  } from "./chunk-6GUG4YNM.js";
153
153
  import {
154
154
  searchHarmonicRetrieval
155
- } from "./chunk-AZ2QBGYB.js";
155
+ } from "./chunk-W7Y5JDVB.js";
156
156
  import {
157
157
  rescoreMemoryImportance
158
158
  } from "./chunk-JXS5PDQ7.js";
@@ -169,7 +169,7 @@ import {
169
169
  rebuildMemoryProjection,
170
170
  repairMemoryProjection,
171
171
  verifyMemoryProjection
172
- } from "./chunk-AIUBBHSF.js";
172
+ } from "./chunk-5UZ6UCOZ.js";
173
173
  import {
174
174
  getCueAnchorStoreStatus
175
175
  } from "./chunk-ACPCA4NO.js";
@@ -200,7 +200,7 @@ import {
200
200
  import {
201
201
  EngramAccessHttpServer,
202
202
  MeetingsInputError
203
- } from "./chunk-XADV5IZ3.js";
203
+ } from "./chunk-HDIUYMSB.js";
204
204
  import {
205
205
  WearablesInputError
206
206
  } from "./chunk-V7IZKJI3.js";
@@ -213,13 +213,13 @@ import {
213
213
  createProductionChatLlmAdapter,
214
214
  loadChatSession,
215
215
  sessionBelongsToPrincipal
216
- } from "./chunk-C5QLI33R.js";
216
+ } from "./chunk-QINJITDS.js";
217
217
  import {
218
218
  getAbstractionNodeStoreStatus
219
219
  } from "./chunk-DJUKBGAD.js";
220
220
  import {
221
221
  EngramAccessService
222
- } from "./chunk-J5LLX6IL.js";
222
+ } from "./chunk-BF6SXNQJ.js";
223
223
  import {
224
224
  WorkStorage
225
225
  } from "./chunk-GDB4J2H3.js";
@@ -239,7 +239,7 @@ import {
239
239
  } from "./chunk-QT2FRYI4.js";
240
240
  import {
241
241
  readAggregateExtractionWatermark
242
- } from "./chunk-JYL3BVVZ.js";
242
+ } from "./chunk-JSEJH2YQ.js";
243
243
  import {
244
244
  getObjectiveStateStoreStatus
245
245
  } from "./chunk-HTP6XRUI.js";
@@ -248,15 +248,15 @@ import {
248
248
  readMemoryGovernanceRunArtifact,
249
249
  restoreMemoryGovernanceRun,
250
250
  runMemoryGovernance
251
- } from "./chunk-TPTECFWR.js";
251
+ } from "./chunk-B6LZ4IBH.js";
252
252
  import {
253
253
  listNamespaces,
254
254
  runNamespaceMigration,
255
255
  verifyNamespaces
256
- } from "./chunk-PA45XCUD.js";
256
+ } from "./chunk-RANKJI5T.js";
257
257
  import {
258
258
  resolveNamespaceChildRoot
259
- } from "./chunk-PUSLMZBQ.js";
259
+ } from "./chunk-NOEMGE56.js";
260
260
  import {
261
261
  getCausalTrajectoryStoreStatus
262
262
  } from "./chunk-AHZOMHWN.js";
@@ -265,7 +265,7 @@ import {
265
265
  } from "./chunk-BIJAWZYW.js";
266
266
  import {
267
267
  meetingIdDate
268
- } from "./chunk-VBHPOWBJ.js";
268
+ } from "./chunk-WD5B5AIE.js";
269
269
  import {
270
270
  isValidTranscriptDate
271
271
  } from "./chunk-UHVXE24Y.js";
@@ -4025,7 +4025,7 @@ function registerCli(api, orchestrator, registerOptions = {}) {
4025
4025
  const idArg = typeof args[0] === "string" ? args[0] : "";
4026
4026
  const options = args[1] ?? {};
4027
4027
  const reason = typeof options.reason === "string" && options.reason.trim().length > 0 ? options.reason.trim() : void 0;
4028
- const { forgetMemory } = await import("./forget-UJDJHG6R.js");
4028
+ const { forgetMemory } = await import("./forget-HDS4N6CG.js");
4029
4029
  try {
4030
4030
  const result = await forgetMemory(orchestrator.storage, {
4031
4031
  id: idArg,
@@ -4591,7 +4591,7 @@ function registerCli(api, orchestrator, registerOptions = {}) {
4591
4591
  );
4592
4592
  }
4593
4593
  }
4594
- const { mergeCapsule } = await import("./capsule-merge-XMFBXVDP.js");
4594
+ const { mergeCapsule } = await import("./capsule-merge-HCJJMLPS.js");
4595
4595
  const result = await mergeCapsule({
4596
4596
  sourceArchive,
4597
4597
  targetRoot: memoryDir,
@@ -7989,4 +7989,4 @@ export {
7989
7989
  listMemoryMarkdownFilePaths,
7990
7990
  registerCli
7991
7991
  };
7992
- //# sourceMappingURL=chunk-DCZBSE4F.js.map
7992
+ //# sourceMappingURL=chunk-D5YOZ66N.js.map
@@ -2,7 +2,7 @@ import {
2
2
  pathMayCarryEntityRefs,
3
3
  requestEntityCanonicalIdReconcile,
4
4
  withRawEntityPageMutation
5
- } from "./chunk-M4A44LUA.js";
5
+ } from "./chunk-GSTIBXBW.js";
6
6
  import {
7
7
  bumpArchiveMutationForPath
8
8
  } from "./chunk-W5BIQOAJ.js";
@@ -1377,4 +1377,4 @@ export {
1377
1377
  parseTombstoneBlockedOfflineSyncMemory,
1378
1378
  TombstoneBlockedCaptureIndexHost
1379
1379
  };
1380
- //# sourceMappingURL=chunk-BHXYAVUM.js.map
1380
+ //# sourceMappingURL=chunk-DLG5V6ND.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  StorageManager
3
- } from "./chunk-VBHPOWBJ.js";
3
+ } from "./chunk-WD5B5AIE.js";
4
4
  import {
5
5
  normalizeEntityName
6
6
  } from "./chunk-YXZG5TVN.js";
@@ -958,4 +958,4 @@ export {
958
958
  resolveBriefingSaveDir,
959
959
  briefingFilename
960
960
  };
961
- //# sourceMappingURL=chunk-52UKFTUK.js.map
961
+ //# sourceMappingURL=chunk-F4EU6VUC.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  normalizeSupersessionKey
3
- } from "./chunk-EWMTOVMY.js";
3
+ } from "./chunk-5WITETWU.js";
4
4
  import {
5
5
  invalidateForScope
6
6
  } from "./chunk-XMMESCPD.js";
@@ -383,4 +383,4 @@ export {
383
383
  repairContentAfterJournalMove,
384
384
  repairContentAfterJournalMoveSync
385
385
  };
386
- //# sourceMappingURL=chunk-M4A44LUA.js.map
386
+ //# sourceMappingURL=chunk-GSTIBXBW.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  rebuildMemoryProjection
3
- } from "./chunk-AIUBBHSF.js";
3
+ } from "./chunk-5UZ6UCOZ.js";
4
4
 
5
5
  // src/convergence-refresh.ts
6
6
  async function refreshConvergedNamespaces(namespaces, namespaceSearchRouter, getStorage, searchEnabled) {
@@ -32,4 +32,4 @@ async function refreshConvergedNamespaces(namespaces, namespaceSearchRouter, get
32
32
  export {
33
33
  refreshConvergedNamespaces
34
34
  };
35
- //# sourceMappingURL=chunk-W5XVQFLM.js.map
35
+ //# sourceMappingURL=chunk-GXFSQ6SD.js.map
@@ -21,10 +21,10 @@ import {
21
21
  processChatMessage,
22
22
  sessionBelongsToPrincipal,
23
23
  subscribeChatTranscript
24
- } from "./chunk-C5QLI33R.js";
24
+ } from "./chunk-QINJITDS.js";
25
25
  import {
26
26
  RelayMissionStoreError
27
- } from "./chunk-33SV3E43.js";
27
+ } from "./chunk-3OY7KXHM.js";
28
28
  import {
29
29
  validateRequest
30
30
  } from "./chunk-NIS256NW.js";
@@ -50,12 +50,12 @@ import {
50
50
  import {
51
51
  authorizationProbeNamespaces,
52
52
  probeOperationAuthorization
53
- } from "./chunk-45BRYON6.js";
53
+ } from "./chunk-QPOHMO6M.js";
54
54
  import {
55
55
  CorrectionContractError,
56
56
  getOperation,
57
57
  resolveQueryNamespaceWritablePreflight
58
- } from "./chunk-J5LLX6IL.js";
58
+ } from "./chunk-BF6SXNQJ.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-XADV5IZ3.js.map
3266
+ //# sourceMappingURL=chunk-HDIUYMSB.js.map
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-B7RWBZXW.js";
4
4
  import {
5
5
  StorageManager
6
- } from "./chunk-VBHPOWBJ.js";
6
+ } from "./chunk-WD5B5AIE.js";
7
7
  import {
8
8
  getCachedEpisodeMap,
9
9
  setCachedEpisodeMap
@@ -109,4 +109,4 @@ export {
109
109
  compareVerifiedEpisodeResults,
110
110
  searchVerifiedEpisodes
111
111
  };
112
- //# sourceMappingURL=chunk-FXTYIA46.js.map
112
+ //# sourceMappingURL=chunk-J272WKX2.js.map
@@ -46,6 +46,7 @@ function parseTombstoneLine(line) {
46
46
  createdAt: e.createdAt,
47
47
  createdBy: e.createdBy
48
48
  };
49
+ if (typeof e.operationKey === "string") out.operationKey = e.operationKey;
49
50
  if (typeof e.entityRef === "string") out.entityRef = e.entityRef;
50
51
  if (typeof e.supersessionKey === "string") out.supersessionKey = e.supersessionKey;
51
52
  if (typeof e.revokes === "string") out.revokes = e.revokes;
@@ -238,6 +239,7 @@ var TombstoneStore = class {
238
239
  normalizedText: this.options.normalizeText(input.rawContent),
239
240
  ...input.entityRef ? { entityRef: input.entityRef } : {},
240
241
  ...input.supersessionKey ? { supersessionKey: input.supersessionKey } : {},
242
+ ...input.operationKey ? { operationKey: input.operationKey } : {},
241
243
  namespace: this.namespace,
242
244
  createdAt,
243
245
  createdBy: input.createdBy
@@ -379,6 +381,14 @@ var TombstoneStore = class {
379
381
  }
380
382
  return null;
381
383
  }
384
+ async hasExactEntry(input) {
385
+ if (!this.options.enabled) return false;
386
+ await this.ensureFreshAgainstDisk();
387
+ await this.load();
388
+ return this.entries.some(
389
+ (entry) => entry.kind === "tombstone" && !this.revokedIds.has(entry.id) && entry.namespace === this.namespace && entry.sourceMemoryId === input.sourceMemoryId && (input.contentHash === void 0 || entry.contentHash === input.contentHash) && (input.entityRef === void 0 || entry.entityRef === input.entityRef) && (input.supersessionKey === void 0 || entry.supersessionKey === input.supersessionKey) && (input.createdAt === void 0 || entry.createdAt === input.createdAt) && (input.operationKey === void 0 || entry.operationKey === input.operationKey)
390
+ );
391
+ }
382
392
  /** Aggregate stats for the doctor / x-ray surfaces. */
383
393
  stats() {
384
394
  let active = 0;
@@ -520,4 +530,4 @@ export {
520
530
  applyTombstoneResurrectionGate,
521
531
  buildRetiredFactTombstoneInputs
522
532
  };
523
- //# sourceMappingURL=chunk-ENTCVTQR.js.map
533
+ //# sourceMappingURL=chunk-JJRVPWFY.js.map