@remnic/core 9.3.729 → 9.3.731

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 (345) hide show
  1. package/dist/access-boundary.d.ts +6 -5
  2. package/dist/access-boundary.js +13 -13
  3. package/dist/access-cli.js +34 -33
  4. package/dist/access-cli.js.map +1 -1
  5. package/dist/access-http.d.ts +6 -5
  6. package/dist/access-http.js +19 -19
  7. package/dist/access-mcp.d.ts +6 -5
  8. package/dist/access-mcp.js +18 -18
  9. package/dist/access-operations-batch.js +16 -16
  10. package/dist/access-operations.d.ts +11 -10
  11. package/dist/access-operations.js +17 -17
  12. package/dist/access-schema.d.ts +42 -42
  13. package/dist/{access-service-BXMJqkTA.d.ts → access-service-Byoe3HsT.d.ts} +18 -3
  14. package/dist/access-service.d.ts +6 -5
  15. package/dist/access-service.js +12 -12
  16. package/dist/access-surface-catalog.d.ts +6 -5
  17. package/dist/action-confidence.d.ts +1 -1
  18. package/dist/active-memory-bridge.d.ts +1 -1
  19. package/dist/active-recall.d.ts +1 -1
  20. package/dist/active-recall.js +2 -2
  21. package/dist/{auto-sync-F3KCSQFJ.js → auto-sync-G3V5AN4C.js} +2 -2
  22. package/dist/behavior-learner.d.ts +1 -1
  23. package/dist/behavior-signals.d.ts +1 -1
  24. package/dist/bootstrap.d.ts +5 -4
  25. package/dist/briefing.d.ts +1 -1
  26. package/dist/briefing.js +3 -3
  27. package/dist/buffer-surprise-report.d.ts +1 -1
  28. package/dist/buffer.d.ts +1 -1
  29. package/dist/calibration.d.ts +1 -1
  30. package/dist/capabilities.d.ts +55 -2
  31. package/dist/capabilities.js +5 -1
  32. package/dist/{catalog-bMczlO2G.d.ts → catalog-DM1nk7cM.d.ts} +1 -1
  33. package/dist/causal-behavior.d.ts +1 -1
  34. package/dist/causal-consolidation.d.ts +1 -1
  35. package/dist/causal-consolidation.js +4 -4
  36. package/dist/causal-trajectory-graph.d.ts +1 -1
  37. package/dist/{chunk-4NOI577P.js → chunk-24ZLC5QN.js} +2 -2
  38. package/dist/{chunk-DMQWV6SQ.js → chunk-5RZOFIDL.js} +2 -2
  39. package/dist/{chunk-UM5AWJNQ.js → chunk-646B5ERJ.js} +62 -37
  40. package/dist/chunk-646B5ERJ.js.map +1 -0
  41. package/dist/{chunk-H5BWGCRZ.js → chunk-6TUWSUUD.js} +51 -47
  42. package/dist/{chunk-H5BWGCRZ.js.map → chunk-6TUWSUUD.js.map} +1 -1
  43. package/dist/{chunk-36SEDFAU.js → chunk-C5WN74HH.js} +2 -2
  44. package/dist/{chunk-MLKWJOAJ.js → chunk-CGPHMNL4.js} +2 -2
  45. package/dist/{chunk-R6OVFAX6.js → chunk-DJECGBBM.js} +7 -2
  46. package/dist/{chunk-R6OVFAX6.js.map → chunk-DJECGBBM.js.map} +1 -1
  47. package/dist/{chunk-3RCBIOOJ.js → chunk-ESF7TRYJ.js} +18 -2
  48. package/dist/{chunk-3RCBIOOJ.js.map → chunk-ESF7TRYJ.js.map} +1 -1
  49. package/dist/{chunk-EY6MDMHK.js → chunk-F6OEXJQQ.js} +2 -2
  50. package/dist/{chunk-M4V2JVSZ.js → chunk-FFUCCKPN.js} +2 -2
  51. package/dist/{chunk-O6YH5F47.js → chunk-FYWUNVFZ.js} +8 -8
  52. package/dist/{chunk-37436GML.js → chunk-GEXI357K.js} +2 -2
  53. package/dist/{chunk-YGIQORJ3.js → chunk-GGL34GCW.js} +3 -3
  54. package/dist/{chunk-4H4F3BFL.js → chunk-GXTYEG7Q.js} +3 -3
  55. package/dist/{chunk-4H4F3BFL.js.map → chunk-GXTYEG7Q.js.map} +1 -1
  56. package/dist/{chunk-WAS3NV46.js → chunk-H3MB3F62.js} +2 -2
  57. package/dist/{chunk-UTHQPSRC.js → chunk-HHNSLPX7.js} +11 -8
  58. package/dist/chunk-HHNSLPX7.js.map +1 -0
  59. package/dist/{chunk-76NHR6ZL.js → chunk-HJWQJUKQ.js} +4 -4
  60. package/dist/{chunk-Y4YD5TYW.js → chunk-IIBFCZA7.js} +3 -3
  61. package/dist/{chunk-UVPL565C.js → chunk-IQOEW5YV.js} +2 -2
  62. package/dist/{chunk-V4GNSDFH.js → chunk-KQYGNGON.js} +2 -2
  63. package/dist/{chunk-CBWI22JN.js → chunk-KSJCXXOU.js} +2 -2
  64. package/dist/{chunk-M4AYVEWS.js → chunk-LUCARK4W.js} +12 -11
  65. package/dist/chunk-LUCARK4W.js.map +1 -0
  66. package/dist/{chunk-I5REUWLH.js → chunk-NIZQH6AU.js} +3 -3
  67. package/dist/{chunk-4ESAR77N.js → chunk-NOU77OHX.js} +2 -2
  68. package/dist/{chunk-BQCHEV7O.js → chunk-O4ZIBPIW.js} +3 -3
  69. package/dist/{chunk-HOHVIVDR.js → chunk-OBJUKYDO.js} +2 -2
  70. package/dist/{chunk-YKBHOBJK.js → chunk-OEHCMALU.js} +56 -4
  71. package/dist/chunk-OEHCMALU.js.map +1 -0
  72. package/dist/{chunk-YOLZS7NY.js → chunk-OTQE66IX.js} +2 -2
  73. package/dist/{chunk-HEDZUSCS.js → chunk-OUITHS6V.js} +246 -368
  74. package/dist/chunk-OUITHS6V.js.map +1 -0
  75. package/dist/{chunk-4T3BMHKD.js → chunk-OZECYVGI.js} +20 -7
  76. package/dist/chunk-OZECYVGI.js.map +1 -0
  77. package/dist/{chunk-C2PG7IEH.js → chunk-P3VJCTVE.js} +2 -2
  78. package/dist/{chunk-EH5ED3C6.js → chunk-PMAQRUN4.js} +4 -4
  79. package/dist/chunk-PMAQRUN4.js.map +1 -0
  80. package/dist/{chunk-7RLCCNHU.js → chunk-Q6BAA57B.js} +4 -3
  81. package/dist/chunk-Q6BAA57B.js.map +1 -0
  82. package/dist/{chunk-HGNOCPZX.js → chunk-QZHF4BWN.js} +6 -6
  83. package/dist/chunk-SYX73XD7.js +283 -0
  84. package/dist/chunk-SYX73XD7.js.map +1 -0
  85. package/dist/{chunk-ASKXIAHD.js → chunk-WDJCZQB4.js} +2 -2
  86. package/dist/{chunk-AQLOP5F4.js → chunk-WNGXQMRI.js} +95 -6
  87. package/dist/chunk-WNGXQMRI.js.map +1 -0
  88. package/dist/{chunk-JYLFZWUX.js → chunk-XYUFGHUW.js} +2 -2
  89. package/dist/{chunk-3TSTGI6F.js → chunk-ZQUAVZNG.js} +2 -2
  90. package/dist/{chunk-4NR2PDZ5.js → chunk-ZVHRSR2R.js} +14 -4
  91. package/dist/chunk-ZVHRSR2R.js.map +1 -0
  92. package/dist/{cli-DmAiDd8A.d.ts → cli-Dt-tuiYH.d.ts} +3 -3
  93. package/dist/cli.d.ts +7 -6
  94. package/dist/cli.js +35 -35
  95. package/dist/compounding/engine.d.ts +12 -1
  96. package/dist/compounding/engine.js +3 -3
  97. package/dist/compounding/preference-consolidator.d.ts +1 -1
  98. package/dist/compression-optimizer.d.ts +1 -1
  99. package/dist/config.d.ts +1 -1
  100. package/dist/config.js +2 -2
  101. package/dist/connectors/codex-materialize-runner.d.ts +1 -1
  102. package/dist/connectors/codex-materialize-runner.js +3 -3
  103. package/dist/connectors/codex-materialize.d.ts +1 -1
  104. package/dist/connectors/index.d.ts +1 -1
  105. package/dist/connectors/index.js +3 -3
  106. package/dist/consolidation-provenance-check.d.ts +1 -1
  107. package/dist/consolidation-undo.d.ts +1 -1
  108. package/dist/contradiction/index.d.ts +1 -1
  109. package/dist/contradiction/index.js +1 -1
  110. package/dist/conversation-index/backend.d.ts +1 -1
  111. package/dist/conversation-index/chunker.d.ts +1 -1
  112. package/dist/conversation-index/faiss-adapter.d.ts +1 -1
  113. package/dist/conversation-index/indexer.d.ts +1 -1
  114. package/dist/conversation-index/search.d.ts +1 -1
  115. package/dist/day-summary.d.ts +1 -1
  116. package/dist/delinearize.d.ts +1 -1
  117. package/dist/direct-answer-wiring.d.ts +1 -1
  118. package/dist/direct-answer.d.ts +1 -1
  119. package/dist/embedding-fallback.d.ts +1 -1
  120. package/dist/embedding-fallback.js +2 -2
  121. package/dist/enrichment/index.d.ts +1 -1
  122. package/dist/entity-retrieval.d.ts +1 -1
  123. package/dist/entity-retrieval.js +3 -3
  124. package/dist/entity-schema.d.ts +1 -1
  125. package/dist/explicit-capture.d.ts +6 -4
  126. package/dist/explicit-capture.js +1 -1
  127. package/dist/extraction-faithfulness.d.ts +1 -1
  128. package/dist/extraction-judge-telemetry.d.ts +1 -1
  129. package/dist/extraction-judge-training.d.ts +1 -1
  130. package/dist/extraction-judge.d.ts +1 -1
  131. package/dist/extraction.d.ts +1 -1
  132. package/dist/extraction.js +3 -3
  133. package/dist/fallback-llm.d.ts +1 -1
  134. package/dist/{first-start-migration-22LPFHD5.js → first-start-migration-OOR57AYR.js} +2 -2
  135. package/dist/graph-dashboard-diff.d.ts +1 -1
  136. package/dist/graph-dashboard-key.d.ts +1 -1
  137. package/dist/graph-dashboard-parser.d.ts +1 -1
  138. package/dist/graph-edge-reinforcement.d.ts +1 -1
  139. package/dist/graph-snapshot.d.ts +1 -1
  140. package/dist/graph.d.ts +1 -1
  141. package/dist/identity-continuity.d.ts +1 -1
  142. package/dist/importance.d.ts +1 -1
  143. package/dist/index.d.ts +296 -11
  144. package/dist/index.js +359 -47
  145. package/dist/index.js.map +1 -1
  146. package/dist/intent.d.ts +1 -1
  147. package/dist/lcm/engine.d.ts +1 -1
  148. package/dist/lcm/index.d.ts +1 -1
  149. package/dist/lcm/tools.d.ts +1 -1
  150. package/dist/lifecycle.d.ts +1 -1
  151. package/dist/live-connectors-runner.d.ts +1 -1
  152. package/dist/local-llm.d.ts +1 -1
  153. package/dist/local-model-endpoint.d.ts +1 -1
  154. package/dist/maintenance/memory-governance.d.ts +1 -1
  155. package/dist/maintenance/memory-governance.js +3 -3
  156. package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +3 -3
  157. package/dist/maintenance/rebuild-memory-projection.js +4 -4
  158. package/dist/mcp-memory-inspector-app.d.ts +6 -5
  159. package/dist/memory-action-policy.d.ts +1 -1
  160. package/dist/memory-cache.d.ts +1 -1
  161. package/dist/memory-lifecycle-ledger-utils.d.ts +1 -1
  162. package/dist/memory-projection-store.d.ts +1 -1
  163. package/dist/memory-provenance.d.ts +1 -1
  164. package/dist/memory-worth-outcomes.d.ts +1 -1
  165. package/dist/models-json.d.ts +1 -1
  166. package/dist/namespaces/migrate.d.ts +2 -2
  167. package/dist/namespaces/migrate.js +9 -9
  168. package/dist/namespaces/principal.d.ts +1 -1
  169. package/dist/namespaces/search.d.ts +1 -1
  170. package/dist/namespaces/search.js +5 -5
  171. package/dist/namespaces/storage.d.ts +2 -2
  172. package/dist/namespaces/storage.js +3 -3
  173. package/dist/native-knowledge.d.ts +1 -1
  174. package/dist/operator-toolkit.d.ts +1 -1
  175. package/dist/operator-toolkit.js +14 -14
  176. package/dist/orchestration/compression-guideline-coordinator.d.ts +105 -0
  177. package/dist/orchestration/compression-guideline-coordinator.js +12 -0
  178. package/dist/orchestration/maintenance.d.ts +2 -2
  179. package/dist/orchestration/maintenance.js +5 -5
  180. package/dist/{orchestrator-BR0sGsME.d.ts → orchestrator-B4KjaOtY.d.ts} +24 -8
  181. package/dist/orchestrator.d.ts +5 -4
  182. package/dist/orchestrator.js +28 -26
  183. package/dist/patterns-cli.d.ts +1 -1
  184. package/dist/policy-runtime.d.ts +1 -1
  185. package/dist/provenance.d.ts +1 -1
  186. package/dist/provenance.js +1 -1
  187. package/dist/qmd-recall-cache.d.ts +1 -1
  188. package/dist/qmd.d.ts +1 -1
  189. package/dist/recall-disclosure-escalation.d.ts +1 -1
  190. package/dist/recall-explain-renderer.d.ts +1 -1
  191. package/dist/recall-planner-llm.d.ts +1 -1
  192. package/dist/recall-state.d.ts +1 -1
  193. package/dist/recall-tag-filter.d.ts +1 -1
  194. package/dist/recall-xray-cli.d.ts +1 -1
  195. package/dist/recall-xray-renderer.d.ts +1 -1
  196. package/dist/recall-xray.d.ts +1 -1
  197. package/dist/{resolution-MN36NW5P.js → resolution-33PIX3TT.js} +2 -2
  198. package/dist/resolution-33PIX3TT.js.map +1 -0
  199. package/dist/resolve-auth-token.d.ts +1 -1
  200. package/dist/resume-bundles.js +3 -3
  201. package/dist/retrieval-agents.d.ts +1 -1
  202. package/dist/retrieval-tiers.d.ts +1 -1
  203. package/dist/routing/engine.d.ts +1 -1
  204. package/dist/routing/store.d.ts +1 -1
  205. package/dist/schemas.d.ts +84 -84
  206. package/dist/search/embed-helper.d.ts +1 -1
  207. package/dist/search/embed-helper.js +2 -2
  208. package/dist/search/factory.d.ts +1 -1
  209. package/dist/search/factory.js +4 -4
  210. package/dist/search/index.d.ts +1 -1
  211. package/dist/search/index.js +8 -8
  212. package/dist/search/lancedb-backend.d.ts +1 -1
  213. package/dist/search/meilisearch-backend.d.ts +1 -1
  214. package/dist/search/noop-backend.d.ts +1 -1
  215. package/dist/search/orama-backend.d.ts +1 -1
  216. package/dist/search/port.d.ts +1 -1
  217. package/dist/search/remote-backend.d.ts +1 -1
  218. package/dist/{semantic-consolidation-Cl15ksZy.d.ts → semantic-consolidation-CstTvHPo.d.ts} +1 -1
  219. package/dist/semantic-consolidation.d.ts +2 -2
  220. package/dist/semantic-consolidation.js +4 -4
  221. package/dist/semantic-rule-promotion.js +3 -3
  222. package/dist/semantic-rule-verifier.d.ts +1 -1
  223. package/dist/semantic-rule-verifier.js +3 -3
  224. package/dist/session-observer-bands.d.ts +1 -1
  225. package/dist/session-observer-state.d.ts +1 -1
  226. package/dist/shared-context/manager.d.ts +3 -3
  227. package/dist/signal.d.ts +1 -1
  228. package/dist/storage.d.ts +22 -3
  229. package/dist/storage.js +2 -2
  230. package/dist/summarizer.d.ts +1 -1
  231. package/dist/summary-snapshot.d.ts +1 -1
  232. package/dist/temporal-supersession.d.ts +1 -1
  233. package/dist/temporal-validity.d.ts +1 -1
  234. package/dist/threading.d.ts +1 -1
  235. package/dist/tier-migration.d.ts +1 -1
  236. package/dist/tier-routing.d.ts +1 -1
  237. package/dist/topics.d.ts +1 -1
  238. package/dist/transcript.d.ts +1 -1
  239. package/dist/transfer/types.d.ts +46 -46
  240. package/dist/trust-score-stage.d.ts +1 -1
  241. package/dist/trust-score.d.ts +1 -1
  242. package/dist/{types-ChQb9D6s.d.ts → types-VkxElCHR.d.ts} +8 -1
  243. package/dist/types.d.ts +1 -1
  244. package/dist/utility-runtime.d.ts +1 -1
  245. package/dist/verified-recall.js +3 -3
  246. package/package.json +12 -2
  247. package/src/access-service-coding-write.test.ts +2 -2
  248. package/src/access-service.ts +33 -14
  249. package/src/bitemporal-dedup-backfill.test.ts +10 -10
  250. package/src/bitemporal-frontmatter.test.ts +3 -3
  251. package/src/capabilities.test.ts +185 -0
  252. package/src/capabilities.ts +110 -0
  253. package/src/cli/creation-ledger-commands.ts +22 -21
  254. package/src/coding/architecture-surfaces.test.ts +25 -1
  255. package/src/coding/architecture-surfaces.ts +47 -19
  256. package/src/coding/decision-surfaces.ts +12 -3
  257. package/src/coding/review-context-structural.test.ts +303 -0
  258. package/src/coding/review-context.ts +79 -0
  259. package/src/coding/structural-context.test.ts +259 -0
  260. package/src/coding/structural-context.ts +315 -0
  261. package/src/coding/structural-subprocess-provider.test.ts +430 -0
  262. package/src/coding/structural-subprocess-provider.ts +355 -0
  263. package/src/compounding/engine.test.ts +90 -0
  264. package/src/compounding/engine.ts +25 -1
  265. package/src/contradiction/contradiction.test.ts +1 -1
  266. package/src/contradiction/resolution.ts +9 -1
  267. package/src/correction/correction-access-wiring.ts +21 -3
  268. package/src/correction/correction-contract.ts +7 -0
  269. package/src/correction/correction-planner.test.ts +231 -0
  270. package/src/correction/correction-planner.ts +73 -0
  271. package/src/correction/correction-service.ts +29 -0
  272. package/src/correction/correction-storage-integration.test.ts +2 -2
  273. package/src/dedup/semantic.test.ts +1 -1
  274. package/src/explicit-capture.ts +7 -4
  275. package/src/extraction-eventtime-wiring.test.ts +3 -3
  276. package/src/extraction-redaction-rules.test.ts +172 -0
  277. package/src/index.ts +29 -0
  278. package/src/maintenance/forget.test.ts +1 -1
  279. package/src/maintenance/memory-governance.test.ts +1 -1
  280. package/src/maintenance/pattern-reinforcement.test.ts +2 -2
  281. package/src/operator-toolkit.ts +4 -3
  282. package/src/orchestration/compression-guideline-coordinator.ts +449 -0
  283. package/src/orchestrator.ts +345 -464
  284. package/src/procedural/procedure-miner.test.ts +2 -2
  285. package/src/provenance-extraction.test.ts +382 -4
  286. package/src/provenance.ts +158 -22
  287. package/src/recall-handles-wiring.test.ts +1 -1
  288. package/src/search/factory.ts +4 -3
  289. package/src/semantic-rule-promotion.ts +1 -1
  290. package/src/source-attribution-roundtrip.test.ts +2 -2
  291. package/src/storage-contract/atomicity.test.ts +1 -1
  292. package/src/storage-contract/cache-coherence.test.ts +2 -2
  293. package/src/storage-contract/content-hash.test.ts +1 -1
  294. package/src/storage-contract/namespace-routing.test.ts +1 -1
  295. package/src/storage-contract/round-trip.test.ts +3 -3
  296. package/src/storage.ts +23 -2
  297. package/src/temporal-supersession.test.ts +12 -11
  298. package/src/temporal-validity.test.ts +11 -11
  299. package/src/wearables/cli.test.ts +30 -0
  300. package/src/wearables/cli.ts +3 -0
  301. package/src/wearables/memory-gen.test.ts +57 -1
  302. package/src/wearables/memory-gen.ts +31 -7
  303. package/src/wearables/pipeline.test.ts +40 -1
  304. package/src/wearables/pipeline.ts +4 -0
  305. package/src/wearables/service.test.ts +2 -2
  306. package/src/wearables/storage-io.test.ts +3 -3
  307. package/src/wearables/types.ts +7 -0
  308. package/dist/chunk-4NR2PDZ5.js.map +0 -1
  309. package/dist/chunk-4T3BMHKD.js.map +0 -1
  310. package/dist/chunk-7RLCCNHU.js.map +0 -1
  311. package/dist/chunk-AQLOP5F4.js.map +0 -1
  312. package/dist/chunk-EH5ED3C6.js.map +0 -1
  313. package/dist/chunk-HEDZUSCS.js.map +0 -1
  314. package/dist/chunk-M4AYVEWS.js.map +0 -1
  315. package/dist/chunk-UM5AWJNQ.js.map +0 -1
  316. package/dist/chunk-UTHQPSRC.js.map +0 -1
  317. package/dist/chunk-YKBHOBJK.js.map +0 -1
  318. /package/dist/{auto-sync-F3KCSQFJ.js.map → auto-sync-G3V5AN4C.js.map} +0 -0
  319. /package/dist/{chunk-4NOI577P.js.map → chunk-24ZLC5QN.js.map} +0 -0
  320. /package/dist/{chunk-DMQWV6SQ.js.map → chunk-5RZOFIDL.js.map} +0 -0
  321. /package/dist/{chunk-36SEDFAU.js.map → chunk-C5WN74HH.js.map} +0 -0
  322. /package/dist/{chunk-MLKWJOAJ.js.map → chunk-CGPHMNL4.js.map} +0 -0
  323. /package/dist/{chunk-EY6MDMHK.js.map → chunk-F6OEXJQQ.js.map} +0 -0
  324. /package/dist/{chunk-M4V2JVSZ.js.map → chunk-FFUCCKPN.js.map} +0 -0
  325. /package/dist/{chunk-O6YH5F47.js.map → chunk-FYWUNVFZ.js.map} +0 -0
  326. /package/dist/{chunk-37436GML.js.map → chunk-GEXI357K.js.map} +0 -0
  327. /package/dist/{chunk-YGIQORJ3.js.map → chunk-GGL34GCW.js.map} +0 -0
  328. /package/dist/{chunk-WAS3NV46.js.map → chunk-H3MB3F62.js.map} +0 -0
  329. /package/dist/{chunk-76NHR6ZL.js.map → chunk-HJWQJUKQ.js.map} +0 -0
  330. /package/dist/{chunk-Y4YD5TYW.js.map → chunk-IIBFCZA7.js.map} +0 -0
  331. /package/dist/{chunk-UVPL565C.js.map → chunk-IQOEW5YV.js.map} +0 -0
  332. /package/dist/{chunk-V4GNSDFH.js.map → chunk-KQYGNGON.js.map} +0 -0
  333. /package/dist/{chunk-CBWI22JN.js.map → chunk-KSJCXXOU.js.map} +0 -0
  334. /package/dist/{chunk-I5REUWLH.js.map → chunk-NIZQH6AU.js.map} +0 -0
  335. /package/dist/{chunk-4ESAR77N.js.map → chunk-NOU77OHX.js.map} +0 -0
  336. /package/dist/{chunk-BQCHEV7O.js.map → chunk-O4ZIBPIW.js.map} +0 -0
  337. /package/dist/{chunk-HOHVIVDR.js.map → chunk-OBJUKYDO.js.map} +0 -0
  338. /package/dist/{chunk-YOLZS7NY.js.map → chunk-OTQE66IX.js.map} +0 -0
  339. /package/dist/{chunk-C2PG7IEH.js.map → chunk-P3VJCTVE.js.map} +0 -0
  340. /package/dist/{chunk-HGNOCPZX.js.map → chunk-QZHF4BWN.js.map} +0 -0
  341. /package/dist/{chunk-ASKXIAHD.js.map → chunk-WDJCZQB4.js.map} +0 -0
  342. /package/dist/{chunk-JYLFZWUX.js.map → chunk-XYUFGHUW.js.map} +0 -0
  343. /package/dist/{chunk-3TSTGI6F.js.map → chunk-ZQUAVZNG.js.map} +0 -0
  344. /package/dist/{first-start-migration-22LPFHD5.js.map → first-start-migration-OOR57AYR.js.map} +0 -0
  345. /package/dist/{resolution-MN36NW5P.js.map → orchestration/compression-guideline-coordinator.js.map} +0 -0
@@ -4,10 +4,13 @@ import {
4
4
  loadSyncState,
5
5
  syncWearableSource,
6
6
  wearableSourceLabel
7
- } from "./chunk-4T3BMHKD.js";
7
+ } from "./chunk-OZECYVGI.js";
8
+ import {
9
+ CompressionGuidelineCoordinator
10
+ } from "./chunk-SYX73XD7.js";
8
11
  import {
9
12
  MaintenanceScheduler
10
- } from "./chunk-MLKWJOAJ.js";
13
+ } from "./chunk-CGPHMNL4.js";
11
14
  import {
12
15
  migrateFromEngram
13
16
  } from "./chunk-7HYPN2GC.js";
@@ -23,7 +26,7 @@ import {
23
26
  import {
24
27
  CompoundingEngine,
25
28
  defaultTierMigrationCycleBudget
26
- } from "./chunk-4NR2PDZ5.js";
29
+ } from "./chunk-ZVHRSR2R.js";
27
30
  import {
28
31
  SharedContextManager
29
32
  } from "./chunk-UFS7OXGL.js";
@@ -154,7 +157,7 @@ import {
154
157
  } from "./chunk-LTHVM4XN.js";
155
158
  import {
156
159
  ExtractionEngine
157
- } from "./chunk-I5REUWLH.js";
160
+ } from "./chunk-NIZQH6AU.js";
158
161
  import {
159
162
  parseMemoryActionEligibilityContext
160
163
  } from "./chunk-5GSUBCZM.js";
@@ -187,29 +190,29 @@ import {
187
190
  } from "./chunk-Q6IP2ARR.js";
188
191
  import {
189
192
  EmbeddingFallback
190
- } from "./chunk-C2PG7IEH.js";
193
+ } from "./chunk-P3VJCTVE.js";
191
194
  import {
192
195
  buildEntityRecallSection,
193
196
  entityRecentTranscriptLookbackHours,
194
197
  readRecentEntityTranscriptEntries
195
- } from "./chunk-YOLZS7NY.js";
196
- import {
197
- normalizeReplaySessionKey
198
- } from "./chunk-2PRQG7PV.js";
198
+ } from "./chunk-OTQE66IX.js";
199
199
  import {
200
200
  RoutingRulesStore
201
201
  } from "./chunk-WIWPSQYU.js";
202
+ import {
203
+ normalizeReplaySessionKey
204
+ } from "./chunk-2PRQG7PV.js";
202
205
  import {
203
206
  compareVerifiedEpisodeResults,
204
207
  searchVerifiedEpisodes
205
- } from "./chunk-ASKXIAHD.js";
208
+ } from "./chunk-WDJCZQB4.js";
206
209
  import {
207
210
  ThreadingManager
208
211
  } from "./chunk-QRDOSYOR.js";
209
212
  import {
210
213
  compareVerifiedSemanticRuleResults,
211
214
  searchVerifiedSemanticRules
212
- } from "./chunk-UVPL565C.js";
215
+ } from "./chunk-IQOEW5YV.js";
213
216
  import {
214
217
  searchWorkProductLedgerEntries
215
218
  } from "./chunk-ZRWB5D4H.js";
@@ -222,14 +225,14 @@ import {
222
225
  import {
223
226
  runNamespaceMaintenanceFanout,
224
227
  summarizeNamespaceMaintenanceHealth
225
- } from "./chunk-CBWI22JN.js";
228
+ } from "./chunk-KSJCXXOU.js";
226
229
  import {
227
230
  NamespaceCatalog,
228
231
  planNamespaceMaintenance
229
- } from "./chunk-M4V2JVSZ.js";
232
+ } from "./chunk-FFUCCKPN.js";
230
233
  import {
231
234
  NamespaceStorageRouter
232
- } from "./chunk-3TSTGI6F.js";
235
+ } from "./chunk-ZQUAVZNG.js";
233
236
  import {
234
237
  searchHarmonicRetrieval
235
238
  } from "./chunk-AV5ZEH4M.js";
@@ -253,10 +256,7 @@ import {
253
256
  applyCommitmentLedgerLifecycle
254
257
  } from "./chunk-LMDRGRJ2.js";
255
258
  import {
256
- buildCompressionGuidelinesMarkdown,
257
- computeCompressionGuidelineCandidate,
258
- refineCompressionGuidelineCandidateSemantically,
259
- renderCompressionGuidelinesMarkdown
259
+ buildCompressionGuidelinesMarkdown
260
260
  } from "./chunk-OD4FM2U7.js";
261
261
  import {
262
262
  buildConsolidationPrompt,
@@ -267,7 +267,7 @@ import {
267
267
  materializeAfterSemanticConsolidation,
268
268
  parseConsolidationResponse,
269
269
  parseOperatorAwareConsolidationResponse
270
- } from "./chunk-DMQWV6SQ.js";
270
+ } from "./chunk-5RZOFIDL.js";
271
271
  import {
272
272
  buildRecallQueryPolicy
273
273
  } from "./chunk-LBJBNWS2.js";
@@ -308,7 +308,7 @@ import {
308
308
  clusterByKey,
309
309
  createCorrectionService,
310
310
  detectPassiveCorrections
311
- } from "./chunk-AQLOP5F4.js";
311
+ } from "./chunk-WNGXQMRI.js";
312
312
  import {
313
313
  listTrustZoneRecords,
314
314
  searchTrustZoneRecords
@@ -333,11 +333,11 @@ import {
333
333
  } from "./chunk-J6BH2OBA.js";
334
334
  import {
335
335
  NamespaceSearchRouter
336
- } from "./chunk-V4GNSDFH.js";
336
+ } from "./chunk-KQYGNGON.js";
337
337
  import {
338
338
  createConversationIndexRuntime,
339
339
  createSearchBackend
340
- } from "./chunk-UTHQPSRC.js";
340
+ } from "./chunk-HHNSLPX7.js";
341
341
  import {
342
342
  NoopSearchBackend
343
343
  } from "./chunk-CYEPCZN5.js";
@@ -360,12 +360,14 @@ import {
360
360
  } from "./chunk-QDW3E4RD.js";
361
361
  import {
362
362
  shouldSkipImplicitExtraction
363
- } from "./chunk-EH5ED3C6.js";
363
+ } from "./chunk-PMAQRUN4.js";
364
364
  import {
365
365
  resolveCapabilities,
366
+ resolveCreationMemoryCapabilities,
366
367
  resolveGraphConstructionCapabilities,
368
+ resolveIndexingCapabilities,
367
369
  resolveMemoryLifecycleCapabilities
368
- } from "./chunk-3RCBIOOJ.js";
370
+ } from "./chunk-ESF7TRYJ.js";
369
371
  import {
370
372
  searchCausalTrajectories
371
373
  } from "./chunk-SQNED75R.js";
@@ -378,7 +380,7 @@ import {
378
380
  } from "./chunk-TBBDFYXW.js";
379
381
  import {
380
382
  buildChainFollowupGenerator
381
- } from "./chunk-EY6MDMHK.js";
383
+ } from "./chunk-F6OEXJQQ.js";
382
384
  import {
383
385
  ContentHashIndex,
384
386
  StorageManager,
@@ -386,7 +388,7 @@ import {
386
388
  fingerprintEntityStructuredFacts,
387
389
  normalizeAttributePairs,
388
390
  parseEntityFile
389
- } from "./chunk-7RLCCNHU.js";
391
+ } from "./chunk-Q6BAA57B.js";
390
392
  import {
391
393
  buildRetiredFactTombstoneInputs
392
394
  } from "./chunk-L2B3EE7B.js";
@@ -2592,20 +2594,6 @@ function deriveTopicsFromExtraction(result) {
2592
2594
  function buildCompressionGuidelinesMarkdown2(events, generatedAtIso = (/* @__PURE__ */ new Date()).toISOString()) {
2593
2595
  return buildCompressionGuidelinesMarkdown(events, generatedAtIso);
2594
2596
  }
2595
- function formatCompressionGuidelinesForRecall(raw, maxLines = 5) {
2596
- if (typeof raw !== "string" || raw.trim().length === 0) return null;
2597
- const sectionMatch = raw.match(
2598
- // End the section at `\n## ` or end-of-string. Plain $ (not \s*$): the
2599
- // \s* branch overlapped the lazy body and backtracked polynomially
2600
- // (CodeQL js/polynomial-redos). Captured lines are trimmed/filtered below,
2601
- // so trailing whitespace handling is unchanged.
2602
- /## Suggested Guidelines\s*\n([\s\S]*?)(?:\n##\s+|$)/i
2603
- );
2604
- if (!sectionMatch) return null;
2605
- const lines = sectionMatch[1].split("\n").map((line) => line.trim()).filter((line) => line.startsWith("- ")).slice(0, Math.max(1, Math.floor(maxLines)));
2606
- if (lines.length === 0) return null;
2607
- return lines.join("\n");
2608
- }
2609
2597
  function filterRecallCandidates(candidates, options) {
2610
2598
  const scopedByNamespace = options.namespacesEnabled ? candidates.filter(
2611
2599
  (r) => options.recallNamespaces.includes(options.resolveNamespace(r.path))
@@ -3042,6 +3030,7 @@ var Orchestrator = class _Orchestrator {
3042
3030
  handleHistory;
3043
3031
  tierMigrationStatus;
3044
3032
  tierMigrationCoordinator;
3033
+ compressionGuidelineCoordinator;
3045
3034
  /**
3046
3035
  * In-memory X-ray snapshot from the most recent `recall()` call that
3047
3036
  * was invoked with `xrayCapture: true` (issue #570 PR 1). Scope is
@@ -3867,6 +3856,11 @@ var Orchestrator = class _Orchestrator {
3867
3856
  getCompounding: () => this.compounding,
3868
3857
  createColdStorage: (parentDir) => new StorageManager(parentDir)
3869
3858
  });
3859
+ this.compressionGuidelineCoordinator = new CompressionGuidelineCoordinator({
3860
+ config,
3861
+ getStorage: () => this.storage,
3862
+ fastChatCompletion: (messages, options) => this.fastChatCompletion(messages, options)
3863
+ });
3870
3864
  this.sessionObserver = new SessionObserverState({
3871
3865
  memoryDir: config.memoryDir,
3872
3866
  debounceMs: config.sessionObserverDebounceMs ?? 12e4,
@@ -4177,6 +4171,25 @@ var Orchestrator = class _Orchestrator {
4177
4171
  }
4178
4172
  await this.namespaceCatalog.registerConfiguredNamespaces().catch(() => void 0);
4179
4173
  }
4174
+ try {
4175
+ const correctionNamespaces = new Set(this.configuredNamespaceList());
4176
+ if (this.namespaceCatalog.enabled) {
4177
+ try {
4178
+ for (const rec of await this.namespaceCatalog.listNamespaces()) {
4179
+ correctionNamespaces.add(rec.namespace);
4180
+ }
4181
+ } catch {
4182
+ }
4183
+ }
4184
+ const recovered = await this.passiveCorrectionService().recoverStaleApplyingPlans(
4185
+ [...correctionNamespaces]
4186
+ );
4187
+ if (recovered > 0) {
4188
+ log.info(`correction: recovered ${recovered} stale applying plan(s) on startup`);
4189
+ }
4190
+ } catch (staleErr) {
4191
+ log.debug(`correction: stale-plan recovery skipped: ${staleErr instanceof Error ? staleErr.message : String(staleErr)}`);
4192
+ }
4180
4193
  await this.relevance.load();
4181
4194
  await this.negatives.load();
4182
4195
  await this.lastRecall.load();
@@ -4382,7 +4395,7 @@ var Orchestrator = class _Orchestrator {
4382
4395
  }));
4383
4396
  await Promise.all(cacheWarmups);
4384
4397
  if (signal.aborted) return;
4385
- if (this.config.conversationIndexEnabled && this.conversationIndexBackend) {
4398
+ if (resolveIndexingCapabilities(this.config).conversationIndex && this.conversationIndexBackend) {
4386
4399
  try {
4387
4400
  const init = await this.conversationIndexBackend.initialize();
4388
4401
  if (!init.enabled) {
@@ -4413,7 +4426,7 @@ var Orchestrator = class _Orchestrator {
4413
4426
  if (signal.aborted) return;
4414
4427
  if (lifecycleCaps.lifecyclePolicy && this.config.qmdTierMigrationEnabled) {
4415
4428
  try {
4416
- const { runFirstStartMigration } = await import("./first-start-migration-22LPFHD5.js");
4429
+ const { runFirstStartMigration } = await import("./first-start-migration-OOR57AYR.js");
4417
4430
  const result = await runFirstStartMigration({
4418
4431
  storage: this.storage,
4419
4432
  config: this.config,
@@ -4436,7 +4449,7 @@ var Orchestrator = class _Orchestrator {
4436
4449
  if (signal.aborted) return;
4437
4450
  if (!this.wearablesAutoSyncHandle && this.config.wearables.enabled && this.config.wearables.autoSyncEnabled && Object.values(this.config.wearables.sources).some((source) => source.enabled)) {
4438
4451
  try {
4439
- const { startWearablesAutoSync } = await import("./auto-sync-F3KCSQFJ.js");
4452
+ const { startWearablesAutoSync } = await import("./auto-sync-G3V5AN4C.js");
4440
4453
  if (signal.aborted) return;
4441
4454
  this.wearablesAutoSyncHandle = startWearablesAutoSync(
4442
4455
  {
@@ -4943,7 +4956,7 @@ ${doc.content}` : doc.content,
4943
4956
  const entry = await targetStorage.snapshotForProvenance(m.path);
4944
4957
  if (entry) derivedFromEntries.push(entry);
4945
4958
  }
4946
- const canonicalId = await targetStorage.writeMemory(
4959
+ const { id: canonicalId, tombstoneBlocked: canonicalBlocked } = await targetStorage.writeMemory(
4947
4960
  newest.frontmatter.category,
4948
4961
  canonicalContent,
4949
4962
  {
@@ -4960,6 +4973,10 @@ ${doc.content}` : doc.content,
4960
4973
  derivedVia: operator
4961
4974
  }
4962
4975
  );
4976
+ if (canonicalBlocked) {
4977
+ log.info(`[semantic-consolidation] cluster in "${cluster.category}" tombstone-blocked \u2014 keeping ${cluster.memories.length} source(s) active (pending_review ${canonicalId})`);
4978
+ continue;
4979
+ }
4963
4980
  canonicalWriteCompleted = true;
4964
4981
  result.memoriesConsolidated++;
4965
4982
  for (const m of cluster.memories) {
@@ -4976,7 +4993,7 @@ ${doc.content}` : doc.content,
4976
4993
  );
4977
4994
  try {
4978
4995
  await this.embeddingFallback.removeFromIndex(m.frontmatter.id);
4979
- if (this.config.queryAwareIndexingEnabled && m.path && m.frontmatter?.created) {
4996
+ if (resolveIndexingCapabilities(this.config).queryAwareIndexing && m.path && m.frontmatter?.created) {
4980
4997
  deindexMemory(
4981
4998
  targetStorage.dir,
4982
4999
  m.path,
@@ -5658,7 +5675,7 @@ ${r.snippet.trim()}
5658
5675
  ...this.conversationIndexLastUpdateAtMs.values()
5659
5676
  );
5660
5677
  const lastUpdateAt = lastUpdateAtMs > 0 ? new Date(lastUpdateAtMs).toISOString() : null;
5661
- if (!this.config.conversationIndexEnabled) {
5678
+ if (!resolveIndexingCapabilities(this.config).conversationIndex) {
5662
5679
  return {
5663
5680
  enabled: false,
5664
5681
  backend: this.config.conversationIndexBackend,
@@ -5687,7 +5704,7 @@ ${r.snippet.trim()}
5687
5704
  ...this.conversationIndexLastUpdateAtMs.values()
5688
5705
  );
5689
5706
  const lastUpdateAt = lastUpdateAtMs > 0 ? new Date(lastUpdateAtMs).toISOString() : null;
5690
- if (!this.config.conversationIndexEnabled) {
5707
+ if (!resolveIndexingCapabilities(this.config).conversationIndex) {
5691
5708
  return {
5692
5709
  enabled: false,
5693
5710
  backend: this.config.conversationIndexBackend,
@@ -5725,7 +5742,7 @@ ${r.snippet.trim()}
5725
5742
  return this.transcript.getRecoverySummary(sessionKey);
5726
5743
  }
5727
5744
  async updateConversationIndex(sessionKey, hours = 24, opts) {
5728
- if (!this.config.conversationIndexEnabled) {
5745
+ if (!resolveIndexingCapabilities(this.config).conversationIndex) {
5729
5746
  return { chunks: 0, skipped: true, reason: "disabled", embedded: false };
5730
5747
  }
5731
5748
  const enforceMinInterval = opts?.enforceMinInterval !== false;
@@ -5767,7 +5784,7 @@ ${r.snippet.trim()}
5767
5784
  return { chunks: chunks.length, skipped: false, embedded };
5768
5785
  }
5769
5786
  async rebuildConversationIndex(sessionKey, hours = 24, opts) {
5770
- if (!this.config.conversationIndexEnabled) {
5787
+ if (!resolveIndexingCapabilities(this.config).conversationIndex) {
5771
5788
  return {
5772
5789
  chunks: 0,
5773
5790
  skipped: true,
@@ -6204,7 +6221,7 @@ ${r.snippet.trim()}
6204
6221
  return scoped;
6205
6222
  }
6206
6223
  async buildQueryAwarePrefilter(prompt, recallNamespaces) {
6207
- if (!this.config.queryAwareIndexingEnabled || !prompt.trim()) {
6224
+ if (!resolveIndexingCapabilities(this.config).queryAwareIndexing || !prompt.trim()) {
6208
6225
  return {
6209
6226
  candidatePaths: null,
6210
6227
  temporalFromDate: null,
@@ -8300,7 +8317,7 @@ ${rows.join("\n")}
8300
8317
  })();
8301
8318
  const workProductsPromise = (async () => {
8302
8319
  const t0 = Date.now();
8303
- if (!this.config.creationMemoryEnabled || !this.config.workProductRecallEnabled || !this.isRecallSectionEnabled(
8320
+ if (!resolveCreationMemoryCapabilities(this.config).creationMemory || !this.config.workProductRecallEnabled || !this.isRecallSectionEnabled(
8304
8321
  "work-products",
8305
8322
  this.config.workProductRecallEnabled === true
8306
8323
  )) {
@@ -8362,7 +8379,7 @@ ${rows.join("\n")}
8362
8379
  })();
8363
8380
  const queryAwarePrefilterPromise = (async () => {
8364
8381
  const t0 = Date.now();
8365
- if (!this.config.queryAwareIndexingEnabled || !prompt.trim()) {
8382
+ if (!resolveIndexingCapabilities(this.config).queryAwareIndexing || !prompt.trim()) {
8366
8383
  recordRecallSectionMetric({
8367
8384
  section: "queryAware",
8368
8385
  priority: "enrichment",
@@ -8955,7 +8972,7 @@ ${formatted}`;
8955
8972
  );
8956
8973
  const conversationRecallPromise = (async () => {
8957
8974
  const t0 = Date.now();
8958
- if (!this.config.conversationIndexEnabled || queryPolicy.skipConversationRecall || !this.isRecallSectionEnabled("conversation-recall", true)) {
8975
+ if (!resolveIndexingCapabilities(this.config).conversationIndex || queryPolicy.skipConversationRecall || !this.isRecallSectionEnabled("conversation-recall", true)) {
8959
8976
  recordRecallSectionMetric({
8960
8977
  section: "convRecall",
8961
8978
  priority: "core",
@@ -11965,6 +11982,7 @@ ${normalized}`).digest("hex");
11965
11982
  const profileAllowsSharedWrites = !scopeProfileWritePlan || Boolean(
11966
11983
  scopeProfileWritePlan.profile.readOrder.includes("serverShared") && scopeProfileWritePlan.readNamespaces.includes(this.config.sharedNamespace) && sharedProfileLayer?.readable && sharedProfileLayer.writable && sharedPromotionTarget?.authorized
11967
11984
  );
11985
+ const namespacesEnabled = this.config.namespacesEnabled;
11968
11986
  const profileAutoPromotionAllows = (category, confidence) => {
11969
11987
  if (!scopeProfileWritePlan) return false;
11970
11988
  const actualTier = confidenceTier(confidence);
@@ -12033,7 +12051,7 @@ ${normalized}`).digest("hex");
12033
12051
  }
12034
12052
  continue;
12035
12053
  }
12036
- const promotedId = await targetStorage.writeMemory(
12054
+ const targetPromotion = await targetStorage.writeMemory(
12037
12055
  options.category,
12038
12056
  citedContent,
12039
12057
  {
@@ -12059,7 +12077,8 @@ ${normalized}`).digest("hex");
12059
12077
  ...options.provenance ? { provenance: options.provenance } : {}
12060
12078
  }
12061
12079
  );
12062
- if (lifecycleCaps.temporalSupersession && options.category === "fact" && options.entityRef && options.structuredAttributes && Object.keys(options.structuredAttributes).length > 0) {
12080
+ const promotedId = targetPromotion.id;
12081
+ if (!targetPromotion.tombstoneBlocked && lifecycleCaps.temporalSupersession && options.category === "fact" && options.entityRef && options.structuredAttributes && Object.keys(options.structuredAttributes).length > 0) {
12063
12082
  try {
12064
12083
  await applyTemporalSupersession({
12065
12084
  storage: targetStorage,
@@ -12075,19 +12094,21 @@ ${normalized}`).digest("hex");
12075
12094
  );
12076
12095
  }
12077
12096
  }
12078
- trackPersistedId(targetStorage, promotedId, { includeReturnedIds: false });
12079
- await this.indexPersistedMemory(targetStorage, promotedId);
12080
- trackBehaviorSignals(
12081
- targetStorage,
12082
- buildBehaviorSignalsForMemory({
12083
- memoryId: promotedId,
12084
- category: options.category,
12085
- content: options.content,
12086
- namespace: target.namespace,
12087
- confidence: options.confidence,
12088
- source: "extraction"
12089
- })
12090
- );
12097
+ if (!targetPromotion.tombstoneBlocked) {
12098
+ trackPersistedId(targetStorage, promotedId, { includeReturnedIds: false });
12099
+ await this.indexPersistedMemory(targetStorage, promotedId);
12100
+ trackBehaviorSignals(
12101
+ targetStorage,
12102
+ buildBehaviorSignalsForMemory({
12103
+ memoryId: promotedId,
12104
+ category: options.category,
12105
+ content: options.content,
12106
+ namespace: target.namespace,
12107
+ confidence: options.confidence,
12108
+ source: "extraction"
12109
+ })
12110
+ );
12111
+ }
12091
12112
  } catch (err) {
12092
12113
  log.warn(
12093
12114
  `persistExtraction: ${target.target} promotion failed open for ${options.sourceMemoryId}: ${err}`
@@ -12179,7 +12200,7 @@ ${normalized}`).digest("hex");
12179
12200
  return;
12180
12201
  }
12181
12202
  }
12182
- const promotedId = await sharedStorage.writeMemory(
12203
+ const sharedPromotion = await sharedStorage.writeMemory(
12183
12204
  options.category,
12184
12205
  citedContent,
12185
12206
  {
@@ -12206,7 +12227,8 @@ ${normalized}`).digest("hex");
12206
12227
  ...options.provenance ? { provenance: options.provenance } : {}
12207
12228
  }
12208
12229
  );
12209
- if (lifecycleCaps.temporalSupersession && options.entityRef && options.structuredAttributes && Object.keys(options.structuredAttributes).length > 0) {
12230
+ const promotedId = sharedPromotion.id;
12231
+ if (!sharedPromotion.tombstoneBlocked && lifecycleCaps.temporalSupersession && options.entityRef && options.structuredAttributes && Object.keys(options.structuredAttributes).length > 0) {
12210
12232
  try {
12211
12233
  await applyTemporalSupersession({
12212
12234
  storage: sharedStorage,
@@ -12222,21 +12244,23 @@ ${normalized}`).digest("hex");
12222
12244
  );
12223
12245
  }
12224
12246
  }
12225
- trackPersistedId(sharedStorage, promotedId, {
12226
- includeReturnedIds: false
12227
- });
12228
- await this.indexPersistedMemory(sharedStorage, promotedId);
12229
- trackBehaviorSignals(
12230
- sharedStorage,
12231
- buildBehaviorSignalsForMemory({
12232
- memoryId: promotedId,
12233
- category: options.category,
12234
- content: options.content,
12235
- namespace: this.config.sharedNamespace,
12236
- confidence: options.confidence,
12237
- source: "extraction"
12238
- })
12239
- );
12247
+ if (!sharedPromotion.tombstoneBlocked) {
12248
+ trackPersistedId(sharedStorage, promotedId, {
12249
+ includeReturnedIds: false
12250
+ });
12251
+ await this.indexPersistedMemory(sharedStorage, promotedId);
12252
+ trackBehaviorSignals(
12253
+ sharedStorage,
12254
+ buildBehaviorSignalsForMemory({
12255
+ memoryId: promotedId,
12256
+ category: options.category,
12257
+ content: options.content,
12258
+ namespace: this.config.sharedNamespace,
12259
+ confidence: options.confidence,
12260
+ source: "extraction"
12261
+ })
12262
+ );
12263
+ }
12240
12264
  } catch (err) {
12241
12265
  log.warn(
12242
12266
  `persistExtraction: shared promotion failed open for ${options.sourceMemoryId}: ${err}`
@@ -12364,6 +12388,7 @@ ${normalized}`).digest("hex");
12364
12388
  const routeRules = await this.loadRoutingRules();
12365
12389
  const routeOptions = this.routeEngineOptions();
12366
12390
  const preRoutedCategories = new Array(facts.length);
12391
+ const preRoutedNamespaceByFact = new Array(facts.length);
12367
12392
  if (routeRules.length > 0) {
12368
12393
  for (let fi = 0; fi < facts.length; fi++) {
12369
12394
  const f = facts[fi];
@@ -12377,6 +12402,9 @@ ${normalized}`).digest("hex");
12377
12402
  if (selected?.target.category) {
12378
12403
  preRoutedCategories[fi] = selected.target.category;
12379
12404
  }
12405
+ if (selected?.target.namespace) {
12406
+ preRoutedNamespaceByFact[fi] = selected.target.namespace;
12407
+ }
12380
12408
  } catch {
12381
12409
  }
12382
12410
  }
@@ -12414,9 +12442,24 @@ ${normalized}`).digest("hex");
12414
12442
  )) {
12415
12443
  continue;
12416
12444
  }
12417
- if (preJudgeRedactionRules.length > 0) {
12445
+ let factRedactionRules = preJudgeRedactionRules;
12446
+ let factNs = preRoutedNamespaceByFact[fi];
12447
+ if (!factNs && lifecycleCaps.extractionScopeClassification && namespacesEnabled && f.scope === "global" && profileAllowsSharedWrites && this.storageDirNamespace(storage.dir) !== this.config.sharedNamespace) {
12448
+ factNs = this.config.sharedNamespace;
12449
+ }
12450
+ if (factNs) {
12451
+ try {
12452
+ const factDir = (await this.storageRouter.storageFor(factNs)).dir;
12453
+ if (factDir !== storage.dir) {
12454
+ const targetRules = await redactionRulesFor(factDir);
12455
+ if (targetRules.length) factRedactionRules = [...preJudgeRedactionRules, ...targetRules];
12456
+ }
12457
+ } catch {
12458
+ }
12459
+ }
12460
+ if (factRedactionRules.length > 0) {
12418
12461
  const rc = f.content + (f.structuredAttributes ? " " + JSON.stringify(f.structuredAttributes) : "") + (f.procedureSteps ? " " + f.procedureSteps.map((s) => `${s.intent} ${s.expectedOutcome ?? ""} ${s.toolCall ? `${s.toolCall.kind} ${s.toolCall.signature}` : ""}`.trim()).join(" ") : "");
12419
- if (contentMatchesRedactionRules(rc, preJudgeRedactionRules)) continue;
12462
+ if (contentMatchesRedactionRules(rc, factRedactionRules)) continue;
12420
12463
  }
12421
12464
  judgeCandidates.push({
12422
12465
  text: f.content,
@@ -12553,7 +12596,7 @@ ${normalized}`).digest("hex");
12553
12596
  );
12554
12597
  }
12555
12598
  }
12556
- if (lifecycleCaps.extractionScopeClassification && this.config.namespacesEnabled && fact.scope === "global" && !routedNamespaceExplicit) {
12599
+ if (lifecycleCaps.extractionScopeClassification && namespacesEnabled && fact.scope === "global" && !routedNamespaceExplicit) {
12557
12600
  const currentNs = this.storageDirNamespace(targetStorage.dir);
12558
12601
  if (currentNs !== this.config.sharedNamespace && profileAllowsSharedWrites) {
12559
12602
  try {
@@ -12747,9 +12790,10 @@ ${normalized}`).digest("hex");
12747
12790
  let supersedes;
12748
12791
  let links = [];
12749
12792
  let contradictionDetected = false;
12793
+ let contradiction;
12750
12794
  if (this.config.contradictionDetectionEnabled && this.qmd.isAvailable() && faithfulnessEnforceStatus !== "pending_review") {
12751
12795
  const targetNamespace = this.storageDirNamespace(targetStorage.dir);
12752
- const contradiction = await this.checkForContradiction(
12796
+ contradiction = await this.checkForContradiction(
12753
12797
  fact.content,
12754
12798
  writeCategory,
12755
12799
  targetNamespace
@@ -12765,14 +12809,6 @@ ${normalized}`).digest("hex");
12765
12809
  strength: contradiction.confidence,
12766
12810
  reason: contradiction.reason
12767
12811
  });
12768
- if (this.config.contradictionAutoResolve && this.config.queryAwareIndexingEnabled && contradiction.supersededPath) {
12769
- deindexMemory(
12770
- this.config.memoryDir,
12771
- contradiction.supersededPath,
12772
- contradiction.supersededCreated,
12773
- contradiction.supersededTags
12774
- );
12775
- }
12776
12812
  }
12777
12813
  }
12778
12814
  const isCorrection = writeCategory === "correction";
@@ -12812,7 +12848,7 @@ ${normalized}`).digest("hex");
12812
12848
  const memoryKind2 = this.config.episodeNoteModeEnabled ? classifyMemoryKind(fact.content, fact.tags ?? [], writeCategory) : void 0;
12813
12849
  const rawChunkedContent = citationEnabled && hasCitationForTemplate(fact.content, citationTemplate) ? stripCitationForTemplate(fact.content, citationTemplate) : fact.content;
12814
12850
  const citedChunkedContent = applyInlineCitation(rawChunkedContent);
12815
- const parentId = await targetStorage.writeMemory(
12851
+ const parentWrite = await targetStorage.writeMemory(
12816
12852
  writeCategory,
12817
12853
  citedChunkedContent,
12818
12854
  {
@@ -12839,6 +12875,15 @@ ${normalized}`).digest("hex");
12839
12875
  ...fact.provenance ? { provenance: fact.provenance } : {}
12840
12876
  }
12841
12877
  );
12878
+ const parentId = parentWrite.id;
12879
+ const tombstoneBlocked2 = parentWrite.tombstoneBlocked;
12880
+ const postWriteGuard2 = faithfulnessEnforceStatus === "pending_review" || tombstoneBlocked2;
12881
+ await this.applyDeferredContradictionResolve(
12882
+ contradiction,
12883
+ targetStorage,
12884
+ parentId,
12885
+ postWriteGuard2
12886
+ );
12842
12887
  try {
12843
12888
  for (const chunk of chunkResult.chunks) {
12844
12889
  const chunkImportance = scoreImportance(
@@ -12876,7 +12921,9 @@ ${normalized}`).digest("hex");
12876
12921
  // fact's verdict + enforce status so a pending_review fact
12877
12922
  // is not indexed as active through its chunks (chatgpt P2).
12878
12923
  ...faithfulnessFm ? { faithfulness: faithfulnessFm } : {},
12879
- ...faithfulnessEnforceStatus ? { status: faithfulnessEnforceStatus } : {},
12924
+ // #1645 (OchiE): inherit pending_review + blockedBy so no chunk lands active.
12925
+ ...postWriteGuard2 ? { status: "pending_review" } : faithfulnessEnforceStatus ? { status: faithfulnessEnforceStatus } : {},
12926
+ ...tombstoneBlocked2 && parentWrite.blockedBy ? { blockedBy: parentWrite.blockedBy } : {},
12880
12927
  // Claim-level provenance (issue #1575 PR 2): mirror the
12881
12928
  // parent's spans onto each chunk so a chunk surfaced
12882
12929
  // independently (memory_get/x-ray on a chunk ID) preserves
@@ -12897,13 +12944,15 @@ ${normalized}`).digest("hex");
12897
12944
  `chunked memory ${parentId} into ${chunkResult.chunks.length} chunks`
12898
12945
  );
12899
12946
  trackPersistedId(targetStorage, parentId, {
12900
- pendingReview: faithfulnessEnforceStatus === "pending_review"
12947
+ pendingReview: postWriteGuard2
12901
12948
  });
12902
- if (faithfulnessEnforceStatus !== "pending_review" && threadEpisodeIdsForGraph && !threadEpisodeIdsForGraph.includes(parentId)) {
12949
+ if (!postWriteGuard2 && threadEpisodeIdsForGraph && !threadEpisodeIdsForGraph.includes(parentId)) {
12903
12950
  threadEpisodeIdsForGraph.push(parentId);
12904
12951
  }
12905
- await this.indexPersistedMemory(targetStorage, parentId);
12906
- if (faithfulnessEnforceStatus !== "pending_review") {
12952
+ if (!postWriteGuard2) {
12953
+ await this.indexPersistedMemory(targetStorage, parentId);
12954
+ }
12955
+ if (!postWriteGuard2) {
12907
12956
  try {
12908
12957
  const supersessionEntityRef = typeof fact.entityRef === "string" ? fact.entityRef : void 0;
12909
12958
  await applyTemporalSupersession({
@@ -12921,7 +12970,7 @@ ${normalized}`).digest("hex");
12921
12970
  log.warn(`temporal-supersession (chunked): unexpected error: ${err}`);
12922
12971
  }
12923
12972
  }
12924
- if (faithfulnessEnforceStatus !== "pending_review") await promoteMemoryToShared({
12973
+ if (!postWriteGuard2) await promoteMemoryToShared({
12925
12974
  sourceStorage: targetStorage,
12926
12975
  category: writeCategory,
12927
12976
  content: fact.content,
@@ -12947,7 +12996,9 @@ ${normalized}`).digest("hex");
12947
12996
  });
12948
12997
  try {
12949
12998
  const canonicalChunkedContent = citationEnabled && hasCitationForTemplate(fact.content, citationTemplate) ? stripCitationForTemplate(fact.content, citationTemplate) : fact.content;
12950
- await this.addContentHashDedup(targetStorage, canonicalChunkedContent);
12999
+ if (!tombstoneBlocked2) {
13000
+ await this.addContentHashDedup(targetStorage, canonicalChunkedContent);
13001
+ }
12951
13002
  } catch (err) {
12952
13003
  log.warn(
12953
13004
  `content-hash dedup registration failed for chunked memory ${parentId}: ${err}`
@@ -12955,10 +13006,12 @@ ${normalized}`).digest("hex");
12955
13006
  }
12956
13007
  for (const chunk of chunkResult.chunks) {
12957
13008
  const chunkId = `${parentId}-chunk-${chunk.index}`;
12958
- await this.indexPersistedMemory(targetStorage, chunkId);
13009
+ if (!postWriteGuard2) {
13010
+ await this.indexPersistedMemory(targetStorage, chunkId);
13011
+ }
12959
13012
  }
12960
13013
  try {
12961
- if (this.config.verbatimArtifactsEnabled && this.config.verbatimArtifactCategories.includes(writeCategory) && fact.confidence >= this.config.verbatimArtifactsMinConfidence && faithfulnessEnforceStatus !== "pending_review") {
13014
+ if (this.config.verbatimArtifactsEnabled && this.config.verbatimArtifactCategories.includes(writeCategory) && fact.confidence >= this.config.verbatimArtifactsMinConfidence && !postWriteGuard2) {
12962
13015
  await targetStorage.writeArtifact(citedChunkedContent, {
12963
13016
  confidence: fact.confidence,
12964
13017
  tags: [...fact.tags, "artifact", "chunked-parent"],
@@ -12969,7 +13022,7 @@ ${normalized}`).digest("hex");
12969
13022
  intentEntityTypes: inferredIntent?.entityTypes
12970
13023
  });
12971
13024
  }
12972
- if (graphCaps.multiGraphMemory && faithfulnessEnforceStatus !== "pending_review") {
13025
+ if (graphCaps.multiGraphMemory && !postWriteGuard2) {
12973
13026
  try {
12974
13027
  const graphContext = await ensureGraphContext(targetStorage);
12975
13028
  const entityRef = typeof fact.entityRef === "string" ? fact.entityRef : void 0;
@@ -13035,7 +13088,7 @@ ${normalized}`).digest("hex");
13035
13088
  const memoryKind = writeCategory === "procedure" ? void 0 : this.config.episodeNoteModeEnabled ? classifyMemoryKind(fact.content, fact.tags ?? [], writeCategory) : void 0;
13036
13089
  const rawPersistBody = writeCategory === "procedure" ? buildProcedurePersistBody(fact.content, fact.procedureSteps) : fact.content;
13037
13090
  const citedFactContent = applyInlineCitation(rawPersistBody);
13038
- const memoryId = await targetStorage.writeMemory(
13091
+ const factWrite = await targetStorage.writeMemory(
13039
13092
  writeCategory,
13040
13093
  citedFactContent,
13041
13094
  {
@@ -13064,12 +13117,21 @@ ${normalized}`).digest("hex");
13064
13117
  ...fact.provenance ? { provenance: fact.provenance } : {}
13065
13118
  }
13066
13119
  );
13120
+ const memoryId = factWrite.id;
13121
+ const tombstoneBlocked = factWrite.tombstoneBlocked;
13122
+ const postWriteGuard = faithfulnessEnforceStatus === "pending_review" || tombstoneBlocked;
13123
+ await this.applyDeferredContradictionResolve(
13124
+ contradiction,
13125
+ targetStorage,
13126
+ memoryId,
13127
+ postWriteGuard
13128
+ );
13067
13129
  if (routedRuleId) {
13068
13130
  log.debug(
13069
13131
  `routing applied for memory ${memoryId}: rule=${routedRuleId} category=${writeCategory} storage=${targetStorage.dir}`
13070
13132
  );
13071
13133
  }
13072
- if (faithfulnessEnforceStatus !== "pending_review") {
13134
+ if (!postWriteGuard) {
13073
13135
  try {
13074
13136
  const supersessionEntityRef = typeof fact.entityRef === "string" ? fact.entityRef : void 0;
13075
13137
  await applyTemporalSupersession({
@@ -13097,13 +13159,15 @@ ${normalized}`).digest("hex");
13097
13159
  })
13098
13160
  );
13099
13161
  trackPersistedId(targetStorage, memoryId, {
13100
- pendingReview: faithfulnessEnforceStatus === "pending_review"
13162
+ pendingReview: postWriteGuard
13101
13163
  });
13102
- if (faithfulnessEnforceStatus !== "pending_review" && threadEpisodeIdsForGraph && !threadEpisodeIdsForGraph.includes(memoryId)) {
13164
+ if (!postWriteGuard && threadEpisodeIdsForGraph && !threadEpisodeIdsForGraph.includes(memoryId)) {
13103
13165
  threadEpisodeIdsForGraph.push(memoryId);
13104
13166
  }
13105
- await this.indexPersistedMemory(targetStorage, memoryId);
13106
- if (faithfulnessEnforceStatus !== "pending_review") await promoteMemoryToShared({
13167
+ if (!postWriteGuard) {
13168
+ await this.indexPersistedMemory(targetStorage, memoryId);
13169
+ }
13170
+ if (!postWriteGuard) await promoteMemoryToShared({
13107
13171
  sourceStorage: targetStorage,
13108
13172
  category: writeCategory,
13109
13173
  content: fact.content,
@@ -13127,7 +13191,7 @@ ${normalized}`).digest("hex");
13127
13191
  ...fact.sources && fact.sources.length > 0 ? { sources: fact.sources } : {},
13128
13192
  ...fact.provenance ? { provenance: fact.provenance } : {}
13129
13193
  });
13130
- if (graphCaps.multiGraphMemory && faithfulnessEnforceStatus !== "pending_review") {
13194
+ if (graphCaps.multiGraphMemory && !postWriteGuard) {
13131
13195
  try {
13132
13196
  const graphContext = await ensureGraphContext(targetStorage);
13133
13197
  const entityRef = typeof fact.entityRef === "string" ? fact.entityRef : void 0;
@@ -13163,7 +13227,7 @@ ${normalized}`).digest("hex");
13163
13227
  } catch {
13164
13228
  }
13165
13229
  }
13166
- if (this.config.verbatimArtifactsEnabled && this.config.verbatimArtifactCategories.includes(writeCategory) && fact.confidence >= this.config.verbatimArtifactsMinConfidence && faithfulnessEnforceStatus !== "pending_review") {
13230
+ if (this.config.verbatimArtifactsEnabled && this.config.verbatimArtifactCategories.includes(writeCategory) && fact.confidence >= this.config.verbatimArtifactsMinConfidence && !postWriteGuard) {
13167
13231
  await targetStorage.writeArtifact(citedFactContent, {
13168
13232
  confidence: fact.confidence,
13169
13233
  tags: [...fact.tags, "artifact"],
@@ -13177,7 +13241,9 @@ ${normalized}`).digest("hex");
13177
13241
  try {
13178
13242
  const canonicalFactContent = citationEnabled && hasCitationForTemplate(fact.content, citationTemplate) ? stripCitationForTemplate(fact.content, citationTemplate) : fact.content;
13179
13243
  const hashRegisterKey = writeCategory === "procedure" ? buildProcedurePersistBody(fact.content, fact.procedureSteps) : canonicalFactContent;
13180
- await this.addContentHashDedup(targetStorage, hashRegisterKey);
13244
+ if (!tombstoneBlocked) {
13245
+ await this.addContentHashDedup(targetStorage, hashRegisterKey);
13246
+ }
13181
13247
  } catch (err) {
13182
13248
  log.warn(
13183
13249
  `content-hash dedup registration failed for memory ${memoryId}: ${err}`
@@ -13414,7 +13480,7 @@ ${normalized}`).digest("hex");
13414
13480
  */
13415
13481
  async updateTemporalTagIndexes(storage, persistedIds) {
13416
13482
  const caps = resolveCapabilities(this.config);
13417
- if (!this.config.queryAwareIndexingEnabled && !caps.parallelRetrieval)
13483
+ if (!resolveIndexingCapabilities(this.config).queryAwareIndexing && !caps.parallelRetrieval)
13418
13484
  return;
13419
13485
  const needsFullRebuild = !indexesExist(this.config.memoryDir);
13420
13486
  if (!needsFullRebuild && persistedIds.length === 0) return;
@@ -13480,11 +13546,11 @@ ${normalized}`).digest("hex");
13480
13546
  );
13481
13547
  const profile = await this.storage.readProfile();
13482
13548
  const result = await this.extraction.consolidate(recent, older, profile);
13483
- const memoryLookup = this.config.queryAwareIndexingEnabled ? new Map(allMemories.map((m) => [m.frontmatter.id, m])) : null;
13549
+ const memoryLookup = resolveIndexingCapabilities(this.config).queryAwareIndexing ? new Map(allMemories.map((m) => [m.frontmatter.id, m])) : null;
13484
13550
  for (const item of result.items) {
13485
13551
  switch (item.action) {
13486
13552
  case "INVALIDATE": {
13487
- const toInvalidate = this.config.queryAwareIndexingEnabled ? memoryLookup?.get(item.existingId) ?? null : null;
13553
+ const toInvalidate = resolveIndexingCapabilities(this.config).queryAwareIndexing ? memoryLookup?.get(item.existingId) ?? null : null;
13488
13554
  if (await this.storage.invalidateMemory(item.existingId)) {
13489
13555
  invalidated += 1;
13490
13556
  memoryItemMutated = true;
@@ -13525,7 +13591,7 @@ ${normalized}`).digest("hex");
13525
13591
  );
13526
13592
  memoryItemMutated = true;
13527
13593
  await this.indexPersistedMemory(this.storage, item.existingId);
13528
- const toMergeInvalidate = this.config.queryAwareIndexingEnabled ? memoryLookup?.get(item.mergeWith) ?? null : null;
13594
+ const toMergeInvalidate = resolveIndexingCapabilities(this.config).queryAwareIndexing ? memoryLookup?.get(item.mergeWith) ?? null : null;
13529
13595
  if (await this.storage.invalidateMemory(item.mergeWith)) {
13530
13596
  invalidated += 1;
13531
13597
  merged += 1;
@@ -13581,7 +13647,7 @@ ${normalized}`).digest("hex");
13581
13647
  if (deletedCommitments.length > 0) {
13582
13648
  memoryItemMutated = true;
13583
13649
  log.info(`cleaned ${deletedCommitments.length} expired commitments`);
13584
- if (this.config.queryAwareIndexingEnabled) {
13650
+ if (resolveIndexingCapabilities(this.config).queryAwareIndexing) {
13585
13651
  for (const m of deletedCommitments) {
13586
13652
  deindexMemory(
13587
13653
  this.config.memoryDir,
@@ -13592,7 +13658,7 @@ ${normalized}`).digest("hex");
13592
13658
  }
13593
13659
  }
13594
13660
  }
13595
- if (this.config.creationMemoryEnabled && this.config.commitmentLedgerEnabled && this.config.commitmentLifecycleEnabled) {
13661
+ if (resolveCreationMemoryCapabilities(this.config).creationMemory && resolveCreationMemoryCapabilities(this.config).commitmentLedger && resolveCreationMemoryCapabilities(this.config).commitmentLifecycle) {
13596
13662
  try {
13597
13663
  const lifecycle = await applyCommitmentLedgerLifecycle({
13598
13664
  memoryDir: this.config.memoryDir,
@@ -13614,7 +13680,7 @@ ${normalized}`).digest("hex");
13614
13680
  if (deletedTTL.length > 0) {
13615
13681
  memoryItemMutated = true;
13616
13682
  log.info(`cleaned ${deletedTTL.length} TTL-expired memories`);
13617
- if (this.config.queryAwareIndexingEnabled) {
13683
+ if (resolveIndexingCapabilities(this.config).queryAwareIndexing) {
13618
13684
  for (const m of deletedTTL) {
13619
13685
  deindexMemory(
13620
13686
  this.config.memoryDir,
@@ -13839,242 +13905,19 @@ ${texts.map((t, i) => `[${i + 1}] ${t}`).join("\n\n")}`;
13839
13905
  return { memoriesProcessed: allMemories.length, merged, invalidated };
13840
13906
  }
13841
13907
  async optimizeCompressionGuidelines(options) {
13842
- const dryRun = options?.dryRun === true;
13843
- const eventLimit = typeof options?.eventLimit === "number" ? Math.max(0, Math.floor(options.eventLimit)) : 500;
13844
- const [activeState, draftState] = await Promise.all([
13845
- this.storage.readCompressionGuidelineOptimizerState(),
13846
- this.storage.readCompressionGuidelineDraftState().catch(() => null)
13847
- ]);
13848
- const previousState = draftState && ((activeState?.guidelineVersion ?? 0) < draftState.guidelineVersion || (activeState?.guidelineVersion ?? 0) === draftState.guidelineVersion) ? draftState : activeState;
13849
- if (!this.config.compressionGuidelineLearningEnabled) {
13850
- return {
13851
- enabled: false,
13852
- dryRun,
13853
- eventCount: 0,
13854
- previousGuidelineVersion: previousState?.guidelineVersion ?? null,
13855
- nextGuidelineVersion: previousState?.guidelineVersion ?? 0,
13856
- changedRules: 0,
13857
- semanticRefinementApplied: false,
13858
- persisted: false,
13859
- draftContentHash: null
13860
- };
13861
- }
13862
- let events = await this.storage.readMemoryActionEvents(eventLimit);
13863
- if (eventLimit > 0) {
13864
- let effectiveEvents = events.filter((event) => event.dryRun !== true);
13865
- let fetchLimit = eventLimit;
13866
- while (effectiveEvents.length < eventLimit && events.length === fetchLimit) {
13867
- fetchLimit = Math.min(fetchLimit * 2, fetchLimit + 1e3);
13868
- if (fetchLimit <= events.length) break;
13869
- events = await this.storage.readMemoryActionEvents(fetchLimit);
13870
- effectiveEvents = events.filter((event) => event.dryRun !== true);
13871
- }
13872
- events = effectiveEvents.slice(-eventLimit);
13873
- }
13874
- const generatedAt = (/* @__PURE__ */ new Date()).toISOString();
13875
- const candidate = computeCompressionGuidelineCandidate(events, {
13876
- generatedAtIso: generatedAt,
13877
- previousState
13878
- });
13879
- if (candidate.eventCounts.total === 0) {
13880
- return {
13881
- enabled: true,
13882
- dryRun,
13883
- eventCount: 0,
13884
- previousGuidelineVersion: previousState?.guidelineVersion ?? null,
13885
- nextGuidelineVersion: previousState?.guidelineVersion ?? 0,
13886
- changedRules: 0,
13887
- semanticRefinementApplied: false,
13888
- persisted: false,
13889
- draftContentHash: null
13890
- };
13891
- }
13892
- const refinedCandidate = await refineCompressionGuidelineCandidateSemantically(candidate, {
13893
- enabled: this.config.compressionGuidelineSemanticRefinementEnabled,
13894
- timeoutMs: this.config.compressionGuidelineSemanticTimeoutMs,
13895
- runRefinement: async (baseline) => {
13896
- const prompt = [
13897
- "You refine compression policy suggestions conservatively.",
13898
- "Return JSON only in this shape:",
13899
- '{"updates":[{"action":"summarize_node","delta":0.02,"confidence":"medium","note":"..."}]}',
13900
- "Constraints:",
13901
- "- Keep updates sparse and conservative.",
13902
- "- delta must stay between -0.15 and 0.15.",
13903
- "- Only include actions present in the input.",
13904
- "Input candidate:",
13905
- JSON.stringify(baseline)
13906
- ].join("\n");
13907
- const response = await this.fastChatCompletion(
13908
- [
13909
- {
13910
- role: "system",
13911
- content: "Respond with strict JSON only. No markdown."
13912
- },
13913
- { role: "user", content: prompt }
13914
- ],
13915
- {
13916
- temperature: 0.1,
13917
- maxTokens: 400,
13918
- operation: "compression_guideline_semantic_refinement",
13919
- priority: "background"
13920
- }
13921
- );
13922
- return this.parseCompressionSemanticRefinement(
13923
- response?.content ?? ""
13924
- );
13925
- }
13926
- });
13927
- const content = renderCompressionGuidelinesMarkdown(refinedCandidate);
13928
- const contentHash = createHash("sha256").update(content).digest("hex");
13929
- const semanticRefinementApplied = JSON.stringify(refinedCandidate.ruleUpdates) !== JSON.stringify(candidate.ruleUpdates);
13930
- const changedRules = refinedCandidate.ruleUpdates.filter(
13931
- (rule) => rule.delta !== 0
13932
- ).length;
13933
- if (!dryRun) {
13934
- await this.storage.writeCompressionGuidelineDraft(content);
13935
- await this.storage.writeCompressionGuidelineDraftState({
13936
- version: refinedCandidate.optimizerVersion,
13937
- updatedAt: refinedCandidate.generatedAt,
13938
- sourceWindow: refinedCandidate.sourceWindow,
13939
- eventCounts: refinedCandidate.eventCounts,
13940
- guidelineVersion: refinedCandidate.guidelineVersion,
13941
- contentHash,
13942
- activationState: "draft",
13943
- actionSummaries: refinedCandidate.actionSummaries,
13944
- ruleUpdates: refinedCandidate.ruleUpdates
13945
- });
13946
- }
13947
- return {
13948
- enabled: true,
13949
- dryRun,
13950
- eventCount: candidate.eventCounts.total,
13951
- previousGuidelineVersion: previousState?.guidelineVersion ?? null,
13952
- nextGuidelineVersion: refinedCandidate.guidelineVersion,
13953
- changedRules,
13954
- semanticRefinementApplied,
13955
- persisted: !dryRun,
13956
- draftContentHash: dryRun ? null : contentHash
13957
- };
13908
+ return this.compressionGuidelineCoordinator.optimizeCompressionGuidelines(options);
13958
13909
  }
13959
13910
  async activateCompressionGuidelineDraft(options) {
13960
- if (!this.config.compressionGuidelineLearningEnabled) {
13961
- return {
13962
- enabled: false,
13963
- activated: false,
13964
- guidelineVersion: null,
13965
- reason: "disabled"
13966
- };
13967
- }
13968
- const draftState = await this.storage.readCompressionGuidelineDraftState();
13969
- if (!draftState) {
13970
- return {
13971
- enabled: true,
13972
- activated: false,
13973
- guidelineVersion: null,
13974
- reason: "missing_draft"
13975
- };
13976
- }
13977
- const expectedContentHash = options?.expectedContentHash?.trim();
13978
- const expectedGuidelineVersion = options?.expectedGuidelineVersion;
13979
- if ((!expectedContentHash || expectedContentHash.length === 0) && typeof expectedGuidelineVersion !== "number") {
13980
- return {
13981
- enabled: true,
13982
- activated: false,
13983
- guidelineVersion: null,
13984
- reason: "expected_revision_required"
13985
- };
13986
- }
13987
- if (expectedContentHash && draftState.contentHash !== expectedContentHash) {
13988
- return {
13989
- enabled: true,
13990
- activated: false,
13991
- guidelineVersion: null,
13992
- reason: "content_hash_mismatch"
13993
- };
13994
- }
13995
- if (typeof expectedGuidelineVersion === "number" && draftState.guidelineVersion !== expectedGuidelineVersion) {
13996
- return {
13997
- enabled: true,
13998
- activated: false,
13999
- guidelineVersion: null,
14000
- reason: "guideline_version_mismatch"
14001
- };
14002
- }
14003
- const activated = await this.storage.activateCompressionGuidelineDraft({
14004
- ...expectedContentHash ? { expectedContentHash } : {},
14005
- ...typeof expectedGuidelineVersion === "number" ? { expectedGuidelineVersion } : {}
14006
- });
14007
- return {
14008
- enabled: true,
14009
- activated,
14010
- guidelineVersion: activated ? draftState.guidelineVersion : null,
14011
- ...activated ? {} : { reason: "draft_changed" }
14012
- };
13911
+ return this.compressionGuidelineCoordinator.activateCompressionGuidelineDraft(options);
14013
13912
  }
13913
+ // Issue #1526 (seam 4): compression-guideline learning moved to
13914
+ // CompressionGuidelineCoordinator. Thin delegation keeps the
13915
+ // consolidation-loop hook + recall-section hook call sites stable.
14014
13916
  async runCompressionGuidelineLearningPass() {
14015
- if (!this.config.compressionGuidelineLearningEnabled) return;
14016
- try {
14017
- const result = await this.optimizeCompressionGuidelines({
14018
- dryRun: false,
14019
- eventLimit: 500
14020
- });
14021
- log.info(
14022
- `compression guideline learning updated (${result.eventCount} events)`
14023
- );
14024
- } catch (err) {
14025
- log.warn(`compression guideline learning failed (ignored): ${err}`);
14026
- }
13917
+ return this.compressionGuidelineCoordinator.runCompressionGuidelineLearningPass();
14027
13918
  }
14028
13919
  async buildCompressionGuidelineRecallSection() {
14029
- if (!this.config.contextCompressionActionsEnabled) return null;
14030
- if (!this.config.compressionGuidelineLearningEnabled) return null;
14031
- const state = await this.storage.readCompressionGuidelineOptimizerState().catch(() => null);
14032
- if (!state || state.guidelineVersion <= 0) return null;
14033
- const raw = await this.storage.readCompressionGuidelines().catch(() => null);
14034
- const summary = raw ? formatCompressionGuidelinesForRecall(raw, 5) : null;
14035
- if (!summary) return null;
14036
- return [
14037
- "## Active Compression Guidelines",
14038
- "",
14039
- `Guideline version: ${state.guidelineVersion}`,
14040
- `Updated: ${state.updatedAt}`,
14041
- "",
14042
- summary
14043
- ].join("\n");
14044
- }
14045
- parseCompressionSemanticRefinement(raw) {
14046
- if (typeof raw !== "string" || raw.trim().length === 0) return null;
14047
- const trimmed = raw.trim();
14048
- const start = trimmed.indexOf("{");
14049
- const end = trimmed.lastIndexOf("}");
14050
- if (start === -1 || end === -1 || end <= start) return null;
14051
- try {
14052
- const parsed = JSON.parse(trimmed.slice(start, end + 1));
14053
- if (!Array.isArray(parsed?.updates)) return null;
14054
- const validActions = /* @__PURE__ */ new Set([
14055
- "store_episode",
14056
- "store_note",
14057
- "update_note",
14058
- "create_artifact",
14059
- "summarize_node",
14060
- "discard",
14061
- "link_graph"
14062
- ]);
14063
- const updates = parsed.updates.filter(
14064
- (item) => item && typeof item.action === "string" && validActions.has(item.action)
14065
- ).map((item) => {
14066
- const confidence = item.confidence === "low" || item.confidence === "medium" || item.confidence === "high" ? item.confidence : void 0;
14067
- return {
14068
- action: item.action,
14069
- delta: typeof item.delta === "number" && Number.isFinite(item.delta) ? item.delta : void 0,
14070
- confidence,
14071
- note: typeof item.note === "string" ? item.note : void 0
14072
- };
14073
- });
14074
- return { updates };
14075
- } catch {
14076
- return null;
14077
- }
13920
+ return this.compressionGuidelineCoordinator.buildCompressionGuidelineRecallSection();
14078
13921
  }
14079
13922
  actionOutcomePriorDelta(event) {
14080
13923
  if (event.outcome === "failed") return -0.3;
@@ -14268,7 +14111,7 @@ ${texts.map((t, i) => `[${i + 1}] ${t}`).join("\n\n")}`;
14268
14111
  "fact-archival"
14269
14112
  );
14270
14113
  await this.embeddingFallback.removeFromIndex(memory.frontmatter.id);
14271
- if (this.config.queryAwareIndexingEnabled && memory.path && memory.frontmatter?.created) {
14114
+ if (resolveIndexingCapabilities(this.config).queryAwareIndexing && memory.path && memory.frontmatter?.created) {
14272
14115
  deindexMemory(
14273
14116
  this.config.memoryDir,
14274
14117
  memory.path,
@@ -15938,7 +15781,7 @@ ${lines.join("\n\n")}`;
15938
15781
  );
15939
15782
  let temporalFromDate = null;
15940
15783
  let promptTags = [];
15941
- if (this.config.queryAwareIndexingEnabled && prompt) {
15784
+ if (resolveIndexingCapabilities(this.config).queryAwareIndexing && prompt) {
15942
15785
  if (isTemporalQuery(prompt)) {
15943
15786
  temporalFromDate = recencyWindowFromPrompt(prompt, now);
15944
15787
  }
@@ -15951,7 +15794,7 @@ ${lines.join("\n\n")}`;
15951
15794
  const queryIntent = this.config.intentRoutingEnabled && prompt ? inferIntentFromText(prompt) : null;
15952
15795
  let temporalCandidates = null;
15953
15796
  let tagCandidates = null;
15954
- if (this.config.queryAwareIndexingEnabled && prompt) {
15797
+ if (resolveIndexingCapabilities(this.config).queryAwareIndexing && prompt) {
15955
15798
  const maxCandidates = this.config.queryAwareIndexingMaxCandidates;
15956
15799
  const capSet = (s) => {
15957
15800
  if (!s) return null;
@@ -16037,7 +15880,7 @@ ${lines.join("\n\n")}`;
16037
15880
  "boost"
16038
15881
  );
16039
15882
  }
16040
- if (this.config.queryAwareIndexingEnabled && r.path) {
15883
+ if (resolveIndexingCapabilities(this.config).queryAwareIndexing && r.path) {
16041
15884
  if (temporalCandidates?.has(r.path)) {
16042
15885
  score += applyUtilityRankingRuntimeDelta(
16043
15886
  0.08,
@@ -16196,14 +16039,6 @@ ${lines.join("\n\n")}`;
16196
16039
  );
16197
16040
  continue;
16198
16041
  }
16199
- if (this.config.contradictionAutoResolve) {
16200
- await resultStorage.supersedeMemory(
16201
- existingMemory.frontmatter.id,
16202
- "pending-new",
16203
- // Will be updated after the new memory is written
16204
- verification.reasoning
16205
- );
16206
- }
16207
16042
  log.info(
16208
16043
  `detected contradiction (confidence: ${verification.confidence}): ${existingMemory.frontmatter.id} vs new memory${this.config.contradictionAutoResolve ? " (auto-resolved)" : " (queued for manual review)"}`
16209
16044
  );
@@ -16219,6 +16054,50 @@ ${lines.join("\n\n")}`;
16219
16054
  }
16220
16055
  return null;
16221
16056
  }
16057
+ /**
16058
+ * #1645: Complete the deferred contradiction auto-resolve after writeMemory
16059
+ * returns and the new write's tombstone status is known. Retires the old
16060
+ * memory + deindexes it ONLY when the new write is genuinely active (not
16061
+ * tombstone-blocked / pending_review). A blocked write must not retire the
16062
+ * only active copy — deferring here closes the "contradictionAutoResolve
16063
+ * supersedes before tombstone status is known" defect class.
16064
+ */
16065
+ async applyDeferredContradictionResolve(contradiction, storage, newMemoryId, postWriteGuard) {
16066
+ if (postWriteGuard && contradiction && this.config.contradictionAutoResolve) {
16067
+ try {
16068
+ const blockedRow = await storage.getMemoryById(newMemoryId);
16069
+ if (blockedRow?.frontmatter?.supersedes) {
16070
+ await storage.writeMemoryFrontmatter(blockedRow, { supersedes: void 0 });
16071
+ }
16072
+ } catch (err) {
16073
+ log.warn(
16074
+ `contradiction auto-resolve supersedes clear failed for blocked ${newMemoryId}: ${err}`
16075
+ );
16076
+ }
16077
+ }
16078
+ if (!contradiction || !this.config.contradictionAutoResolve || postWriteGuard) {
16079
+ return;
16080
+ }
16081
+ try {
16082
+ await storage.supersedeMemory(
16083
+ contradiction.supersededId,
16084
+ newMemoryId,
16085
+ contradiction.reason
16086
+ );
16087
+ if (resolveIndexingCapabilities(this.config).queryAwareIndexing && contradiction.supersededPath) {
16088
+ deindexMemory(
16089
+ this.config.memoryDir,
16090
+ contradiction.supersededPath,
16091
+ contradiction.supersededCreated,
16092
+ contradiction.supersededTags
16093
+ );
16094
+ }
16095
+ } catch (err) {
16096
+ log.warn(
16097
+ `contradiction auto-resolve supersede failed for ${contradiction.supersededId}: ${err}`
16098
+ );
16099
+ }
16100
+ }
16222
16101
  // ---------------------------------------------------------------------------
16223
16102
  // Memory Linking (Phase 3A)
16224
16103
  // ---------------------------------------------------------------------------
@@ -16369,7 +16248,6 @@ export {
16369
16248
  isArtifactMemoryPath,
16370
16249
  deriveTopicsFromExtraction,
16371
16250
  buildCompressionGuidelinesMarkdown2 as buildCompressionGuidelinesMarkdown,
16372
- formatCompressionGuidelinesForRecall,
16373
16251
  filterRecallCandidates,
16374
16252
  shouldFilterLifecycleRecallCandidate,
16375
16253
  lifecycleRecallScoreAdjustment,
@@ -16392,4 +16270,4 @@ export {
16392
16270
  resolvePersistedMemoryRelativePath,
16393
16271
  Orchestrator
16394
16272
  };
16395
- //# sourceMappingURL=chunk-HEDZUSCS.js.map
16273
+ //# sourceMappingURL=chunk-OUITHS6V.js.map