@remnic/core 9.3.700 → 9.3.702

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 (323) hide show
  1. package/dist/access-boundary.d.ts +7 -7
  2. package/dist/access-boundary.js +17 -14
  3. package/dist/access-cli.js +40 -37
  4. package/dist/access-cli.js.map +1 -1
  5. package/dist/access-http.d.ts +7 -7
  6. package/dist/access-http.js +20 -17
  7. package/dist/access-mcp.d.ts +7 -7
  8. package/dist/access-mcp.js +19 -16
  9. package/dist/access-operations.d.ts +7 -7
  10. package/dist/access-operations.js +18 -15
  11. package/dist/{access-service-Cte3ol0W.d.ts → access-service-COCzhgEL.d.ts} +397 -19
  12. package/dist/access-service.d.ts +6 -6
  13. package/dist/access-service.js +16 -13
  14. package/dist/access-surface-catalog.d.ts +7 -7
  15. package/dist/action-confidence.d.ts +1 -1
  16. package/dist/active-memory-bridge.d.ts +1 -1
  17. package/dist/active-memory-bridge.js +2 -2
  18. package/dist/active-recall.d.ts +1 -1
  19. package/dist/active-recall.js +7 -6
  20. package/dist/active-recall.js.map +1 -1
  21. package/dist/behavior-learner.d.ts +1 -1
  22. package/dist/behavior-signals.d.ts +1 -1
  23. package/dist/bootstrap.d.ts +5 -5
  24. package/dist/briefing.d.ts +1 -1
  25. package/dist/briefing.js +8 -7
  26. package/dist/buffer-surprise-report.d.ts +1 -1
  27. package/dist/buffer.d.ts +1 -1
  28. package/dist/calibration.d.ts +1 -1
  29. package/dist/capabilities.d.ts +1 -1
  30. package/dist/{catalog-DN1PzThs.d.ts → catalog-DxCzhjE6.d.ts} +28 -54
  31. package/dist/causal-behavior.d.ts +1 -1
  32. package/dist/causal-consolidation.d.ts +1 -1
  33. package/dist/causal-consolidation.js +9 -8
  34. package/dist/causal-consolidation.js.map +1 -1
  35. package/dist/{chunk-XJNBEDFE.js → chunk-3FAMU5TX.js} +31 -74
  36. package/dist/chunk-3FAMU5TX.js.map +1 -0
  37. package/dist/{chunk-PCZR32VL.js → chunk-3JJWNZTT.js} +2 -2
  38. package/dist/{chunk-YXLT4EMM.js → chunk-4463LUIE.js} +12 -2
  39. package/dist/chunk-4463LUIE.js.map +1 -0
  40. package/dist/{chunk-R5DB26G6.js → chunk-4SBW47WK.js} +9 -23
  41. package/dist/chunk-4SBW47WK.js.map +1 -0
  42. package/dist/{chunk-CCOXIDRM.js → chunk-5VXVXJH6.js} +149 -6
  43. package/dist/{chunk-CCOXIDRM.js.map → chunk-5VXVXJH6.js.map} +1 -1
  44. package/dist/{chunk-PQG4T5V3.js → chunk-64XXOQRW.js} +49 -45
  45. package/dist/chunk-64XXOQRW.js.map +1 -0
  46. package/dist/{chunk-YXIFA36P.js → chunk-6TAETM63.js} +2 -2
  47. package/dist/{chunk-6JDGADXK.js → chunk-6VVP6NK7.js} +2 -2
  48. package/dist/{chunk-FN2SM5SN.js → chunk-ABCGDW3A.js} +75 -12
  49. package/dist/chunk-ABCGDW3A.js.map +1 -0
  50. package/dist/{chunk-CHM274U6.js → chunk-AMNLZ6SF.js} +2 -2
  51. package/dist/{chunk-JX3YZVII.js → chunk-CZJ6QSKG.js} +3 -3
  52. package/dist/{chunk-GYVVQYA3.js → chunk-EOOVJK2U.js} +3 -3
  53. package/dist/{chunk-JKW5XSWC.js → chunk-EYJD6KIO.js} +2 -2
  54. package/dist/{chunk-XY4WJTEX.js → chunk-EZR35XHX.js} +2 -2
  55. package/dist/{chunk-UU6MVCJ6.js → chunk-FIOYURII.js} +32 -25
  56. package/dist/chunk-FIOYURII.js.map +1 -0
  57. package/dist/{chunk-2NWHLAXX.js → chunk-FVI5B7DE.js} +2 -2
  58. package/dist/{chunk-X74FJSW7.js → chunk-GFIARMA7.js} +16 -8
  59. package/dist/chunk-GFIARMA7.js.map +1 -0
  60. package/dist/{chunk-PONNZ54D.js → chunk-GY3SKOS4.js} +4 -4
  61. package/dist/{chunk-U33LWTQQ.js → chunk-HV57RHMD.js} +4 -4
  62. package/dist/{chunk-RC3CNIPK.js → chunk-IO5NQEGZ.js} +2 -2
  63. package/dist/{chunk-IKNQAGBV.js → chunk-IX3UQT4H.js} +1 -1
  64. package/dist/{chunk-IKNQAGBV.js.map → chunk-IX3UQT4H.js.map} +1 -1
  65. package/dist/{chunk-HDLC75NX.js → chunk-IX72AAMZ.js} +2 -2
  66. package/dist/{chunk-DR2JTSLZ.js → chunk-JMA4RYRN.js} +62 -163
  67. package/dist/chunk-JMA4RYRN.js.map +1 -0
  68. package/dist/{chunk-G5PKTQ5J.js → chunk-JTKFZMZ7.js} +2 -2
  69. package/dist/{chunk-YMTGXDN6.js → chunk-KC6TCAWV.js} +5 -5
  70. package/dist/{chunk-ROZJACKP.js → chunk-KKK7YTYN.js} +4 -1
  71. package/dist/chunk-KKK7YTYN.js.map +1 -0
  72. package/dist/{chunk-EC2AYKRX.js → chunk-L6W77GWW.js} +10 -24
  73. package/dist/chunk-L6W77GWW.js.map +1 -0
  74. package/dist/{chunk-ED35D32I.js → chunk-LQ4J7ELC.js} +2 -2
  75. package/dist/{chunk-YPR7DOPD.js → chunk-LTJAMRGI.js} +4 -4
  76. package/dist/{chunk-YPR7DOPD.js.map → chunk-LTJAMRGI.js.map} +1 -1
  77. package/dist/chunk-LUPVCGYK.js +63 -0
  78. package/dist/chunk-LUPVCGYK.js.map +1 -0
  79. package/dist/{chunk-RJ2THZ4H.js → chunk-MBUM2Y3L.js} +2 -2
  80. package/dist/{chunk-T5QAZIBO.js → chunk-MOXFPLD6.js} +3 -3
  81. package/dist/{chunk-O54DY26V.js → chunk-MXEWQKM7.js} +2 -2
  82. package/dist/{chunk-33L6XHU2.js → chunk-NUIJEGVD.js} +6 -6
  83. package/dist/{chunk-3E5WRQNQ.js → chunk-OXEAMU42.js} +529 -9
  84. package/dist/chunk-OXEAMU42.js.map +1 -0
  85. package/dist/{chunk-EOBJRBLC.js → chunk-QGJAGC2J.js} +2 -2
  86. package/dist/{chunk-SMIVW7XC.js → chunk-QIMFOCSH.js} +2 -2
  87. package/dist/{chunk-IJEZMWKA.js → chunk-SFOAQQDJ.js} +3 -3
  88. package/dist/{chunk-HRUULBBV.js → chunk-SHRRWOVY.js} +81 -4
  89. package/dist/chunk-SHRRWOVY.js.map +1 -0
  90. package/dist/{chunk-NINRTFSV.js → chunk-SINGJCUR.js} +5 -5
  91. package/dist/{chunk-ZPQVJEVQ.js → chunk-SK2CR6MW.js} +146 -2
  92. package/dist/chunk-SK2CR6MW.js.map +1 -0
  93. package/dist/{chunk-SEWF2O74.js → chunk-TGAHHCB6.js} +2 -2
  94. package/dist/{chunk-D75JXBV4.js → chunk-WN4GHSDH.js} +2 -2
  95. package/dist/{chunk-K4DWSPMW.js → chunk-WRGPE6AW.js} +2 -2
  96. package/dist/{chunk-GA5A6MJH.js → chunk-XGMCUY5P.js} +62 -116
  97. package/dist/chunk-XGMCUY5P.js.map +1 -0
  98. package/dist/{chunk-SDPDU2PM.js → chunk-YTMDF6S7.js} +2 -2
  99. package/dist/{chunk-ZDK2IW5F.js → chunk-Z7XEIAV4.js} +2 -2
  100. package/dist/{chunk-NHBEO3F3.js → chunk-ZCEI242W.js} +24 -24
  101. package/dist/{cli--yVN9yEV.d.ts → cli-BM4xQPp4.d.ts} +3 -3
  102. package/dist/cli.d.ts +7 -7
  103. package/dist/cli.js +35 -34
  104. package/dist/compounding/engine.d.ts +1 -1
  105. package/dist/compounding/engine.js +8 -7
  106. package/dist/compounding/preference-consolidator.d.ts +1 -1
  107. package/dist/compression-optimizer.d.ts +1 -1
  108. package/dist/config.d.ts +1 -1
  109. package/dist/config.js +4 -2
  110. package/dist/connectors/codex-materialize-runner.d.ts +1 -1
  111. package/dist/connectors/codex-materialize-runner.js +8 -7
  112. package/dist/connectors/codex-materialize.d.ts +1 -1
  113. package/dist/connectors/index.d.ts +1 -1
  114. package/dist/connectors/index.js +9 -8
  115. package/dist/consolidation-provenance-check.d.ts +1 -1
  116. package/dist/consolidation-undo.d.ts +1 -1
  117. package/dist/contradiction/index.d.ts +2 -2
  118. package/dist/conversation-index/backend.d.ts +1 -1
  119. package/dist/conversation-index/chunker.d.ts +1 -1
  120. package/dist/conversation-index/faiss-adapter.d.ts +1 -1
  121. package/dist/conversation-index/indexer.d.ts +1 -1
  122. package/dist/conversation-index/search.d.ts +1 -1
  123. package/dist/day-summary.d.ts +1 -1
  124. package/dist/delinearize.d.ts +1 -1
  125. package/dist/direct-answer-wiring.d.ts +1 -1
  126. package/dist/direct-answer.d.ts +1 -1
  127. package/dist/embedding-fallback.d.ts +1 -1
  128. package/dist/enrichment/index.d.ts +1 -1
  129. package/dist/entity-retrieval.d.ts +1 -1
  130. package/dist/entity-retrieval.js +8 -7
  131. package/dist/entity-schema.d.ts +1 -1
  132. package/dist/event-order-recall.js +2 -1
  133. package/dist/explicit-capture.d.ts +5 -5
  134. package/dist/explicit-capture.js +2 -2
  135. package/dist/explicit-cue-recall.js +2 -1
  136. package/dist/extraction-faithfulness.d.ts +1 -1
  137. package/dist/extraction-judge-telemetry.d.ts +1 -1
  138. package/dist/extraction-judge-training.d.ts +1 -1
  139. package/dist/extraction-judge.d.ts +1 -1
  140. package/dist/extraction.d.ts +14 -1
  141. package/dist/extraction.js +5 -3
  142. package/dist/fallback-llm.d.ts +1 -1
  143. package/dist/{forget-BEXG5PQC.js → forget-6SOIPUMQ.js} +3 -3
  144. package/dist/identity-continuity.d.ts +1 -1
  145. package/dist/importance.d.ts +1 -1
  146. package/dist/index.d.ts +123 -123
  147. package/dist/index.js +57 -56
  148. package/dist/index.js.map +1 -1
  149. package/dist/intent.d.ts +1 -1
  150. package/dist/lcm/engine.d.ts +1 -1
  151. package/dist/lcm/index.d.ts +1 -1
  152. package/dist/lcm/tools.d.ts +1 -1
  153. package/dist/lifecycle.d.ts +1 -1
  154. package/dist/live-connectors-runner.d.ts +1 -1
  155. package/dist/local-llm.d.ts +1 -1
  156. package/dist/maintenance/memory-governance.d.ts +1 -1
  157. package/dist/maintenance/memory-governance.js +8 -7
  158. package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +8 -7
  159. package/dist/maintenance/rebuild-memory-projection.js +9 -8
  160. package/dist/mcp-memory-inspector-app.d.ts +7 -7
  161. package/dist/memory-action-policy.d.ts +1 -1
  162. package/dist/memory-cache.d.ts +1 -1
  163. package/dist/memory-lifecycle-ledger-utils.d.ts +1 -1
  164. package/dist/memory-projection-store.d.ts +1 -1
  165. package/dist/memory-provenance.d.ts +1 -1
  166. package/dist/memory-worth-outcomes.d.ts +1 -1
  167. package/dist/models-json.d.ts +1 -1
  168. package/dist/namespaces/migrate.d.ts +2 -2
  169. package/dist/namespaces/migrate.js +9 -8
  170. package/dist/namespaces/principal.d.ts +1 -1
  171. package/dist/namespaces/search.d.ts +1 -1
  172. package/dist/namespaces/storage.d.ts +14 -3
  173. package/dist/namespaces/storage.js +8 -7
  174. package/dist/native-knowledge.d.ts +1 -1
  175. package/dist/operator-toolkit.d.ts +1 -1
  176. package/dist/operator-toolkit.js +14 -13
  177. package/dist/orchestration/maintenance.d.ts +2 -2
  178. package/dist/orchestration/maintenance.js +10 -9
  179. package/dist/{orchestrator-CJI4xdqV.d.ts → orchestrator-C9CDWAm6.d.ts} +4 -4
  180. package/dist/orchestrator.d.ts +5 -5
  181. package/dist/orchestrator.js +33 -31
  182. package/dist/patterns-cli.d.ts +1 -1
  183. package/dist/policy-runtime.d.ts +1 -1
  184. package/dist/provenance.d.ts +36 -2
  185. package/dist/provenance.js +5 -1
  186. package/dist/qmd-recall-cache.d.ts +1 -1
  187. package/dist/qmd.d.ts +1 -1
  188. package/dist/recall-disclosure-escalation.d.ts +1 -1
  189. package/dist/recall-explain-renderer.d.ts +1 -1
  190. package/dist/recall-explain-renderer.js +3 -3
  191. package/dist/recall-pipeline-stages.d.ts +15 -0
  192. package/dist/recall-pipeline-stages.js +3 -56
  193. package/dist/recall-pipeline-stages.js.map +1 -1
  194. package/dist/recall-planner-llm.d.ts +1 -1
  195. package/dist/recall-state.d.ts +1 -1
  196. package/dist/recall-tag-filter.d.ts +1 -1
  197. package/dist/recall-xray-cli.d.ts +1 -1
  198. package/dist/recall-xray-cli.js +4 -4
  199. package/dist/recall-xray-renderer.d.ts +1 -1
  200. package/dist/recall-xray-renderer.js +3 -3
  201. package/dist/recall-xray.d.ts +1 -1
  202. package/dist/recall-xray.js +2 -2
  203. package/dist/resolve-auth-token.d.ts +1 -1
  204. package/dist/response-guidance-recall.js +2 -1
  205. package/dist/resume-bundles.js +7 -5
  206. package/dist/retrieval-agents.d.ts +1 -1
  207. package/dist/retrieval-tiers.d.ts +1 -1
  208. package/dist/routing/engine.d.ts +1 -1
  209. package/dist/routing/store.d.ts +1 -1
  210. package/dist/schemas.d.ts +19 -0
  211. package/dist/schemas.js +1 -1
  212. package/dist/search/embed-helper.d.ts +1 -1
  213. package/dist/search/factory.d.ts +1 -1
  214. package/dist/search/index.d.ts +1 -1
  215. package/dist/search/lancedb-backend.d.ts +1 -1
  216. package/dist/search/meilisearch-backend.d.ts +1 -1
  217. package/dist/search/noop-backend.d.ts +1 -1
  218. package/dist/search/orama-backend.d.ts +1 -1
  219. package/dist/search/port.d.ts +1 -1
  220. package/dist/search/remote-backend.d.ts +1 -1
  221. package/dist/{semantic-DJR8_DMQ.d.ts → semantic-SLAa_prH.d.ts} +1 -1
  222. package/dist/{semantic-consolidation-BtUfv-AL.d.ts → semantic-consolidation-DgFXyALl.d.ts} +1 -1
  223. package/dist/semantic-consolidation.d.ts +2 -2
  224. package/dist/semantic-consolidation.js +9 -8
  225. package/dist/semantic-rule-promotion.js +8 -7
  226. package/dist/semantic-rule-verifier.d.ts +1 -1
  227. package/dist/semantic-rule-verifier.js +8 -7
  228. package/dist/session-observer-bands.d.ts +1 -1
  229. package/dist/session-observer-state.d.ts +1 -1
  230. package/dist/shared-context/manager.d.ts +1 -1
  231. package/dist/signal.d.ts +1 -1
  232. package/dist/storage.d.ts +13 -1
  233. package/dist/storage.js +7 -6
  234. package/dist/summarizer.d.ts +1 -1
  235. package/dist/summarizer.js +3 -2
  236. package/dist/summary-snapshot.d.ts +1 -1
  237. package/dist/summary-snapshot.js +2 -1
  238. package/dist/targeted-fact-recall.js +2 -1
  239. package/dist/temporal-supersession.d.ts +1 -1
  240. package/dist/temporal-validity.d.ts +1 -1
  241. package/dist/threading.d.ts +1 -1
  242. package/dist/tier-migration.d.ts +1 -1
  243. package/dist/tier-routing.d.ts +1 -1
  244. package/dist/topics.d.ts +1 -1
  245. package/dist/transcript.d.ts +1 -1
  246. package/dist/transcript.js +2 -2
  247. package/dist/{types-PuiPZ9iE.d.ts → types-MWKPZnM0.d.ts} +25 -1
  248. package/dist/types.d.ts +1 -1
  249. package/dist/types.js +1 -1
  250. package/dist/utility-runtime.d.ts +1 -1
  251. package/dist/utils/serialize-mutations.js +1 -1
  252. package/dist/verified-recall.js +8 -7
  253. package/package.json +2 -2
  254. package/src/access-http.ts +162 -0
  255. package/src/access-service.ts +215 -0
  256. package/src/admin/admin-surfaces.test.ts +458 -0
  257. package/src/admin/admin-surfaces.ts +819 -0
  258. package/src/event-order-recall.test.ts +53 -0
  259. package/src/event-order-recall.ts +61 -37
  260. package/src/explicit-cue-recall.ts +21 -1
  261. package/src/extraction.ts +91 -6
  262. package/src/namespaces/catalog.test.ts +222 -14
  263. package/src/namespaces/catalog.ts +54 -187
  264. package/src/namespaces/storage.ts +87 -80
  265. package/src/orchestrator.ts +46 -5
  266. package/src/provenance-extraction.test.ts +838 -0
  267. package/src/provenance.ts +413 -0
  268. package/src/recall-pipeline-parity.test.ts +288 -0
  269. package/src/recall-pipeline-stages.test.ts +43 -0
  270. package/src/recall-pipeline-stages.ts +22 -0
  271. package/src/response-guidance-recall.ts +32 -36
  272. package/src/schemas.ts +7 -0
  273. package/src/storage.ts +23 -0
  274. package/src/summary-snapshot.test.ts +63 -1
  275. package/src/summary-snapshot.ts +61 -80
  276. package/src/targeted-fact-recall.ts +25 -32
  277. package/src/types.ts +24 -0
  278. package/src/utils/serialize-mutations.ts +10 -6
  279. package/dist/chunk-3E5WRQNQ.js.map +0 -1
  280. package/dist/chunk-DR2JTSLZ.js.map +0 -1
  281. package/dist/chunk-EC2AYKRX.js.map +0 -1
  282. package/dist/chunk-FN2SM5SN.js.map +0 -1
  283. package/dist/chunk-GA5A6MJH.js.map +0 -1
  284. package/dist/chunk-HRUULBBV.js.map +0 -1
  285. package/dist/chunk-PQG4T5V3.js.map +0 -1
  286. package/dist/chunk-R5DB26G6.js.map +0 -1
  287. package/dist/chunk-ROZJACKP.js.map +0 -1
  288. package/dist/chunk-UU6MVCJ6.js.map +0 -1
  289. package/dist/chunk-X74FJSW7.js.map +0 -1
  290. package/dist/chunk-XJNBEDFE.js.map +0 -1
  291. package/dist/chunk-YXLT4EMM.js.map +0 -1
  292. package/dist/chunk-ZPQVJEVQ.js.map +0 -1
  293. /package/dist/{chunk-PCZR32VL.js.map → chunk-3JJWNZTT.js.map} +0 -0
  294. /package/dist/{chunk-YXIFA36P.js.map → chunk-6TAETM63.js.map} +0 -0
  295. /package/dist/{chunk-6JDGADXK.js.map → chunk-6VVP6NK7.js.map} +0 -0
  296. /package/dist/{chunk-CHM274U6.js.map → chunk-AMNLZ6SF.js.map} +0 -0
  297. /package/dist/{chunk-JX3YZVII.js.map → chunk-CZJ6QSKG.js.map} +0 -0
  298. /package/dist/{chunk-GYVVQYA3.js.map → chunk-EOOVJK2U.js.map} +0 -0
  299. /package/dist/{chunk-JKW5XSWC.js.map → chunk-EYJD6KIO.js.map} +0 -0
  300. /package/dist/{chunk-XY4WJTEX.js.map → chunk-EZR35XHX.js.map} +0 -0
  301. /package/dist/{chunk-2NWHLAXX.js.map → chunk-FVI5B7DE.js.map} +0 -0
  302. /package/dist/{chunk-PONNZ54D.js.map → chunk-GY3SKOS4.js.map} +0 -0
  303. /package/dist/{chunk-U33LWTQQ.js.map → chunk-HV57RHMD.js.map} +0 -0
  304. /package/dist/{chunk-RC3CNIPK.js.map → chunk-IO5NQEGZ.js.map} +0 -0
  305. /package/dist/{chunk-HDLC75NX.js.map → chunk-IX72AAMZ.js.map} +0 -0
  306. /package/dist/{chunk-G5PKTQ5J.js.map → chunk-JTKFZMZ7.js.map} +0 -0
  307. /package/dist/{chunk-YMTGXDN6.js.map → chunk-KC6TCAWV.js.map} +0 -0
  308. /package/dist/{chunk-ED35D32I.js.map → chunk-LQ4J7ELC.js.map} +0 -0
  309. /package/dist/{chunk-RJ2THZ4H.js.map → chunk-MBUM2Y3L.js.map} +0 -0
  310. /package/dist/{chunk-T5QAZIBO.js.map → chunk-MOXFPLD6.js.map} +0 -0
  311. /package/dist/{chunk-O54DY26V.js.map → chunk-MXEWQKM7.js.map} +0 -0
  312. /package/dist/{chunk-33L6XHU2.js.map → chunk-NUIJEGVD.js.map} +0 -0
  313. /package/dist/{chunk-EOBJRBLC.js.map → chunk-QGJAGC2J.js.map} +0 -0
  314. /package/dist/{chunk-SMIVW7XC.js.map → chunk-QIMFOCSH.js.map} +0 -0
  315. /package/dist/{chunk-IJEZMWKA.js.map → chunk-SFOAQQDJ.js.map} +0 -0
  316. /package/dist/{chunk-NINRTFSV.js.map → chunk-SINGJCUR.js.map} +0 -0
  317. /package/dist/{chunk-SEWF2O74.js.map → chunk-TGAHHCB6.js.map} +0 -0
  318. /package/dist/{chunk-D75JXBV4.js.map → chunk-WN4GHSDH.js.map} +0 -0
  319. /package/dist/{chunk-K4DWSPMW.js.map → chunk-WRGPE6AW.js.map} +0 -0
  320. /package/dist/{chunk-SDPDU2PM.js.map → chunk-YTMDF6S7.js.map} +0 -0
  321. /package/dist/{chunk-ZDK2IW5F.js.map → chunk-Z7XEIAV4.js.map} +0 -0
  322. /package/dist/{chunk-NHBEO3F3.js.map → chunk-ZCEI242W.js.map} +0 -0
  323. /package/dist/{forget-BEXG5PQC.js.map → forget-6SOIPUMQ.js.map} +0 -0
@@ -6,6 +6,7 @@ import type { PluginConfig } from "../types.js";
6
6
  import { ALL_CATEGORY_DIRS } from "../utils/category-dir.js";
7
7
  import { namespaceIdentityToken, normalizeNamespaceIdentity } from "./identity.js";
8
8
  import type { NamespaceCatalog } from "./catalog.js";
9
+ import { MutationSerializer } from "../utils/serialize-mutations.js";
9
10
 
10
11
  async function exists(p: string): Promise<boolean> {
11
12
  try {
@@ -209,21 +210,22 @@ export class NamespaceStorageRouter {
209
210
  // rebuilds. We fire the hook only when the (namespace, storageDir) pair is new
210
211
  // or its dir changed, so a steady-state cache hit is a no-op for the catalog.
211
212
  private readonly notifiedResolved = new Map<string, string>();
212
- // In-flight resolve-hook dedup (NFJV-, codex P2). The catalog's `onResolve`
213
- // hook is ASYNC (it returns `registerResolved(...)`), so `notifiedResolved` is
214
- // only set after the hook's promise SETTLES. Without tracking the in-flight
215
- // window, a burst of `storageFor()` cache hits for the SAME namespace before
216
- // the first registration finishes would each pass the `notifiedResolved` guard
217
- // and fire their OWN `onResolve` queueing N duplicate catalog touches + lock
218
- // acquisitions despite the once-per-namespace intent. We therefore record the
219
- // (namespace storageDir) being registered BEFORE awaiting the hook so a
220
- // concurrent call for the same pair skips firing. On SUCCESS the pair is
221
- // promoted to `notifiedResolved` (future calls skip permanently); on `false`
222
- // (dropped touch e.g. rebuild-lock timeout) OR rejection the in-flight marker
223
- // is CLEARED so a later `storageFor()` can RETRY the dropped registration. The
224
- // entry is always removed when the promise settles, so the map cannot grow
225
- // unbounded (one transient entry per concurrently-resolving namespace).
226
- private readonly inFlightResolved = new Map<string, string>();
213
+ // Instance-scoped serializer for the resolve hook (issue #1524 adoption).
214
+ // Replaces the bespoke `inFlightResolved` marker-then-clear pattern: the
215
+ // serializer's per-key chain strictly orders concurrent notifications for the
216
+ // SAME namespace, and the task re-checks `notifiedResolved` once it runs, so a
217
+ // burst of cache hits before the first hook settles collapses to a single
218
+ // hook invocation (the once-per-namespace intent). Recovery is preserved
219
+ // one rejected hook never poisons subsequent notifications for that key.
220
+ private readonly resolveSerializer = new MutationSerializer();
221
+ // (namespace, storageDir) pairs whose resolve hook is currently pending. Set SYNCHRONOUSLY in
222
+ // notifyResolved (before queueing) so a burst of concurrent storageFor()
223
+ // cache hits collapses onto the one in-flight hook instead of each enqueuing
224
+ // its own task. Cleared when the queued hook settles. Without this, a dropped
225
+ // hook (returns false on a rebuild-lock timeout) leaves notifiedResolved
226
+ // unset, so every queued sibling task would re-run the hook — N serial lock
227
+ // waits (cursor Medium 06f58a7c, codex P2).
228
+ private readonly inFlightResolveHooks = new Set<string>();
227
229
  // Tracks every in-flight resolve-hook promise so callers can deterministically
228
230
  // await the fire-and-forget registrations that `storageFor()` kicks off (see
229
231
  // `whenResolveHooksSettled`). Entries are removed as each hook settles, so the
@@ -308,77 +310,82 @@ export class NamespaceStorageRouter {
308
310
  /**
309
311
  * Fire the resolve hook defensively. A hook failure (e.g. a catalog write
310
312
  * error) MUST NOT crash storage resolution — see CLAUDE.md gotcha #13.
313
+ *
314
+ * Issue #1524 adoption: hook invocations for the SAME namespace are now
315
+ * strictly ordered through the shared `MutationSerializer` rather than the
316
+ * bespoke `inFlightResolved` marker-then-clear pattern. The serializer
317
+ * guarantees one in-flight hook per namespace; a concurrent burst of
318
+ * `storageFor()` cache hits collapses to a single hook invocation because
319
+ * each queued task re-checks `notifiedResolved` before invoking the hook. A
320
+ * dropped (`false`) or rejected hook leaves `notifiedResolved` unset so the
321
+ * next `storageFor()` retries — the serializer recovers from the rejection,
322
+ * so a failed hook never poisons later notifications.
311
323
  */
312
324
  private notifyResolved(namespace: string, storageDir: string): void {
313
325
  const hook = this.hooks.onResolve;
314
326
  if (!hook) return;
315
- // Skip when we've already SUCCESSFULLY notified this exact (namespace,
316
- // storageDir) a steady-state cache hit must not re-append to the catalog
317
- // log (NCNL2). A changed dir (rare: migration/realignment) still re-fires
318
- // once. We mark the pair as notified ONLY AFTER the hook succeeds, and CLEAR
319
- // it on failure, so a dropped registration (e.g. rebuild-lock timeout) is
320
- // RETRIED on the next cache hit instead of being suppressed forever (round 6,
321
- // cursor Medium — ND3EJ).
327
+ // Permanent dedup: skip once we've SUCCESSFULLY notified this exact
328
+ // (namespace, storageDir). A changed dir (rare: migration/realignment)
329
+ // still re-fires once. The mark is set ONLY AFTER the hook succeeds, so a
330
+ // dropped registration (e.g. rebuild-lock timeout) is RETRIED on the next
331
+ // cache hit instead of being suppressed forever (round 6, cursor Medium —
332
+ // ND3EJ).
322
333
  if (this.notifiedResolved.get(namespace) === storageDir) return;
323
- // In-flight dedup (NFJV-, codex P2): if a registration for this exact
324
- // (namespace, storageDir) is already AWAITING its async hook, do not fire a
325
- // second one. Without this, concurrent cache-hit bursts before the first
326
- // append settles each pass the `notifiedResolved` guard above and queue
327
- // duplicate catalog touches/lock acquisitions. A pair with a DIFFERENT
328
- // in-flight dir (rare mid-migration realignment) still fires once.
329
- if (this.inFlightResolved.get(namespace) === storageDir) return;
330
- try {
331
- // Handle BOTH synchronous throws and asynchronous rejections (round 6,
332
- // codex P2 NDo8C). The hook may be `async`; its rejected promise would
333
- // bypass this try/catch and, where unhandled rejections are fatal, crash
334
- // storage resolution. Mark the dedup pair as notified ONLY when the hook
335
- // resolves to a PERSISTED result (round 6, codex P2 — NEFoX): a result of
336
- // `false` means the registration was dropped/no-op (e.g. rebuild-lock
337
- // timeout), so we must NOT suppress its retry. `void`/`undefined` is treated
338
- // as success for legacy hooks. On rejection we leave it un-notified to retry.
339
- //
340
- // Record the in-flight marker BEFORE awaiting so concurrent calls for the
341
- // same pair skip (NFJV-). It is always cleared once the promise settles, so
342
- // the map holds at most one transient entry per concurrently-resolving
343
- // namespace and cannot grow unbounded.
344
- this.inFlightResolved.set(namespace, storageDir);
345
- const hookResult = Promise.resolve(hook(namespace, storageDir));
346
- // Track the in-flight promise so `whenResolveHooksSettled()` can await it.
347
- this.pendingResolveHooks.add(hookResult);
348
- hookResult.then(
349
- (persisted) => {
350
- // Clear the in-flight marker ONLY if it is still ours (a newer resolve
351
- // for a different dir may have replaced it).
352
- if (this.inFlightResolved.get(namespace) === storageDir) {
353
- this.inFlightResolved.delete(namespace);
354
- }
355
- if (persisted !== false) {
356
- this.notifiedResolved.set(namespace, storageDir);
357
- }
358
- // On `false` (dropped touch) we intentionally do NOT mark notified, so
359
- // a later `storageFor()` retries the registration. Clearing the
360
- // in-flight marker above is what re-enables that retry.
361
- this.pendingResolveHooks.delete(hookResult);
362
- },
363
- () => {
364
- // Registration failed clear in-flight AND do NOT mark as notified, so
365
- // it is retried on the next cache hit.
366
- if (this.inFlightResolved.get(namespace) === storageDir) {
367
- this.inFlightResolved.delete(namespace);
368
- }
369
- if (this.notifiedResolved.get(namespace) === storageDir) {
370
- this.notifiedResolved.delete(namespace);
371
- }
372
- this.pendingResolveHooks.delete(hookResult);
373
- },
374
- );
375
- } catch {
376
- // Synchronous throw: clear any in-flight marker we just set and leave the
377
- // pair un-notified so a later resolve retries.
378
- if (this.inFlightResolved.get(namespace) === storageDir) {
379
- this.inFlightResolved.delete(namespace);
334
+ // In-flight dedup (cursor Medium 06f58a7c, codex P2): if a hook for THIS
335
+ // namespace is already pending, collapse this call onto it instead of
336
+ // enqueueing another task. The serializer strictly orders queued tasks, but
337
+ // ordering alone is not enough — when the first hook returns `false`
338
+ // (dropped touch, e.g. rebuild-lock timeout), `notifiedResolved` stays
339
+ // unset, so each queued sibling task would pass its re-check and re-run the
340
+ // hook. With the real catalog hook each retry can spend the full lock wait,
341
+ // so N cache hits during a rebuild leave N serial background lock attempts.
342
+ // Collapsing here means at most ONE hook runs per in-flight registration;
343
+ // its result (set `notifiedResolved` on success, leave unset on drop)
344
+ // decides whether a LATER `storageFor()` retries collapsing loses
345
+ // nothing because the drop is already retried on the next cache hit.
346
+ // Keyed by the composite (namespace, storageDir) so a CHANGED dir
347
+ // (migration/realignment) for the same namespace still gets its own hook —
348
+ // it is NOT collapsed onto the old dir's pending registration (cursor
349
+ // Medium, codex P2).
350
+ const inFlightKey = namespace + "\u0000" + storageDir;
351
+ if (this.inFlightResolveHooks.has(inFlightKey)) return;
352
+ this.inFlightResolveHooks.add(inFlightKey);
353
+ // Queue through the serializer. Concurrent calls for the same namespace
354
+ // strictly order here; the 2nd call's task runs only after the 1st's hook
355
+ // settles, by which point `notifiedResolved` is either set (no-op) or still
356
+ // unset (retry). The returned promise is tracked for
357
+ // `whenResolveHooksSettled()`. Rejections from the task body are caught so
358
+ // they never reach the caller (best-effort hook contract); the serializer's
359
+ // recovered tail still lets subsequent notifications run.
360
+ const task = async (): Promise<void> => {
361
+ // Re-check after queueing: a prior task in this same chain may have just
362
+ // marked the pair as notified.
363
+ if (this.notifiedResolved.get(namespace) === storageDir) return;
364
+ try {
365
+ // Hook may be sync or async; Promise.resolve normalizes both. A result
366
+ // of `false` means the registration was dropped/no-op (e.g. rebuild-lock
367
+ // timeout) — leave notifiedResolved UNSET so the next storageFor retries
368
+ // (round 6, codex P2 — NEFoX). `void`/`undefined` is success for legacy
369
+ // hooks. A rejection leaves notifiedResolved unset for the same reason.
370
+ const persisted = await Promise.resolve(hook(namespace, storageDir));
371
+ if (persisted !== false) {
372
+ this.notifiedResolved.set(namespace, storageDir);
373
+ }
374
+ } catch {
375
+ // Best-effort: a hook failure MUST NOT crash storage resolution. Leave
376
+ // notifiedResolved unset so a later storageFor retries the registration.
380
377
  }
381
- }
378
+ };
379
+ const queued = this.resolveSerializer.serialize(namespace, task);
380
+ this.pendingResolveHooks.add(queued);
381
+ // Clear the in-flight marker when the hook settles so a subsequent
382
+ // storageFor() can retry after a drop, or short-circuit via notifiedResolved
383
+ // after a success.
384
+ const cleanup = (): void => {
385
+ this.inFlightResolveHooks.delete(inFlightKey);
386
+ this.pendingResolveHooks.delete(queued);
387
+ };
388
+ void queued.then(cleanup, cleanup);
382
389
  }
383
390
 
384
391
  /**
@@ -343,7 +343,7 @@ import {
343
343
  lcmReadSessionIdsForNamespaces,
344
344
  resolveCodingNamespaceOverlay,
345
345
  } from "./coding/coding-namespace.js";
346
- import type { CodingContext } from "./types.js";
346
+ import type { CodingContext, ProvenanceSource } from "./types.js";
347
347
  import {
348
348
  NamespaceSearchRouter,
349
349
  type NamespaceSearchHealth,
@@ -13923,6 +13923,8 @@ export class Orchestrator {
13923
13923
  memoryKind?: MemoryFrontmatter["memoryKind"];
13924
13924
  validAt?: string;
13925
13925
  source: string;
13926
+ sources?: ProvenanceSource[];
13927
+ provenance?: "verified" | "unverified" | "none";
13926
13928
  }): Promise<void> => {
13927
13929
  if (
13928
13930
  !scopeProfileWritePlan ||
@@ -13979,6 +13981,8 @@ export class Orchestrator {
13979
13981
  memoryKind: options.memoryKind,
13980
13982
  validAt: options.validAt,
13981
13983
  contentHashSource: options.category === "fact" ? dedupContent : rawContent,
13984
+ ...(options.sources && options.sources.length > 0 ? { sources: options.sources } : {}),
13985
+ ...(options.provenance ? { provenance: options.provenance } : {}),
13982
13986
  },
13983
13987
  );
13984
13988
  if (
@@ -14039,6 +14043,9 @@ export class Orchestrator {
14039
14043
  memoryKind?: MemoryFrontmatter["memoryKind"];
14040
14044
  validAt?: string;
14041
14045
  source: string;
14046
+ /** Claim-level provenance spans (issue #1575 PR 2). */
14047
+ sources?: ProvenanceSource[];
14048
+ provenance?: "verified" | "unverified" | "none";
14042
14049
  }): Promise<void> => {
14043
14050
  await promoteMemoryToProfileTargets(options);
14044
14051
  if (
@@ -14264,10 +14271,10 @@ export class Orchestrator {
14264
14271
  intentEntityTypes: options.intentEntityTypes,
14265
14272
  memoryKind: options.memoryKind,
14266
14273
  validAt: options.validAt,
14267
- // Index the same canonical body used by hasFactContentHash above.
14268
- // For structured facts this includes the normalized Attributes
14269
- // suffix, matching StorageManager.writeMemory enrichment.
14270
14274
  contentHashSource: options.category === "fact" ? dedupContent : rawContent,
14275
+ // Claim-level provenance spans (issue #1575 PR 2).
14276
+ ...(options.sources && options.sources.length > 0 ? { sources: options.sources } : {}),
14277
+ ...(options.provenance ? { provenance: options.provenance } : {}),
14271
14278
  },
14272
14279
  );
14273
14280
  // PR #402 Finding 3 fix: run temporal supersession against the shared
@@ -14887,7 +14894,7 @@ export class Orchestrator {
14887
14894
  // pre-computed verdict for this fact and translate it to frontmatter +
14888
14895
  // an optional enforce-mode pending_review status. Logic lives in the
14889
14896
  // pure module; this is thin read-through (ground rule 4).
14890
- const { faithfulness: faithfulnessFm, enforceStatus: faithfulnessEnforceStatus } =
14897
+ const { faithfulness: faithfulnessFm, enforceStatus: faithfulnessGateStatus } =
14891
14898
  applyFaithfulnessVerdict(
14892
14899
  faithfulnessResultsByFactIndex,
14893
14900
  factLoopIndex,
@@ -14896,6 +14903,22 @@ export class Orchestrator {
14896
14903
  this.faithfulnessCounters,
14897
14904
  );
14898
14905
 
14906
+ // requireSpans enforcement (issue #1575 PR 2): when an operator opts
14907
+ // into provenance.requireSpans, a fact whose quote could not be located
14908
+ // in any source turn (carried as the transient requireSpansPending
14909
+ // signal from the extraction validator) routes to pending_review — the
14910
+ // same review queue an unsupported faithfulness verdict uses. This is
14911
+ // the persist-path wiring ProvenanceConfig.requireSpans documents.
14912
+ // Faithfulness takes precedence when it already routed the fact; both
14913
+ // gates agree on pending_review so the merge is a simple coalesce
14914
+ // (chatgpt-codex-connector thread 4xB).
14915
+ const requireSpansPendingStatus =
14916
+ this.config.provenance?.requireSpans === true &&
14917
+ fact.requireSpansPending === true
14918
+ ? ("pending_review" as const)
14919
+ : undefined;
14920
+ const faithfulnessEnforceStatus = faithfulnessGateStatus ?? requireSpansPendingStatus;
14921
+
14899
14922
  // Issue #373 — write-time semantic similarity guard. Hook runs after
14900
14923
  // the exact content-hash miss and the importance gate so that:
14901
14924
  // (a) paraphrased near-duplicates never reach writeMemory(), and
@@ -15169,6 +15192,9 @@ export class Orchestrator {
15169
15192
  // Faithfulness gate (issue #1576).
15170
15193
  ...(faithfulnessFm ? { faithfulness: faithfulnessFm } : {}),
15171
15194
  ...(faithfulnessEnforceStatus ? { status: faithfulnessEnforceStatus } : {}),
15195
+ // Claim-level provenance spans (issue #1575 PR 2).
15196
+ ...(fact.sources && fact.sources.length > 0 ? { sources: fact.sources } : {}),
15197
+ ...(fact.provenance ? { provenance: fact.provenance } : {}),
15172
15198
  },
15173
15199
  );
15174
15200
  try {
@@ -15209,6 +15235,12 @@ export class Orchestrator {
15209
15235
  // is not indexed as active through its chunks (chatgpt P2).
15210
15236
  ...(faithfulnessFm ? { faithfulness: faithfulnessFm } : {}),
15211
15237
  ...(faithfulnessEnforceStatus ? { status: faithfulnessEnforceStatus } : {}),
15238
+ // Claim-level provenance (issue #1575 PR 2): mirror the
15239
+ // parent's spans onto each chunk so a chunk surfaced
15240
+ // independently (memory_get/x-ray on a chunk ID) preserves
15241
+ // the verified span (chatgpt-codex-connector thread Ocvmo).
15242
+ ...(fact.sources && fact.sources.length > 0 ? { sources: fact.sources } : {}),
15243
+ ...(fact.provenance ? { provenance: fact.provenance } : {}),
15212
15244
  },
15213
15245
  );
15214
15246
  }
@@ -15281,6 +15313,8 @@ export class Orchestrator {
15281
15313
  memoryKind,
15282
15314
  validAt: sourceContext?.validAt,
15283
15315
  source: extractionWriteSource,
15316
+ ...(fact.sources && fact.sources.length > 0 ? { sources: fact.sources } : {}),
15317
+ ...(fact.provenance ? { provenance: fact.provenance } : {}),
15284
15318
  });
15285
15319
  // Register chunked content in the target storage hash index too.
15286
15320
  // Thread 3 fix: canonicalize by stripping any pre-existing citation
@@ -15454,6 +15488,11 @@ export class Orchestrator {
15454
15488
  // Faithfulness gate (issue #1576).
15455
15489
  ...(faithfulnessFm ? { faithfulness: faithfulnessFm } : {}),
15456
15490
  ...(faithfulnessEnforceStatus ? { status: faithfulnessEnforceStatus } : {}),
15491
+ // Claim-level provenance spans (issue #1575 PR 2). Carry verified
15492
+ // sources + the coarse strength tag from the extraction validator
15493
+ // through to frontmatter so they survive end-to-end.
15494
+ ...(fact.sources && fact.sources.length > 0 ? { sources: fact.sources } : {}),
15495
+ ...(fact.provenance ? { provenance: fact.provenance } : {}),
15457
15496
  },
15458
15497
  );
15459
15498
  if (routedRuleId) {
@@ -15527,6 +15566,8 @@ export class Orchestrator {
15527
15566
  memoryKind,
15528
15567
  validAt: sourceContext?.validAt,
15529
15568
  source: extractionWriteSource,
15569
+ ...(fact.sources && fact.sources.length > 0 ? { sources: fact.sources } : {}),
15570
+ ...(fact.provenance ? { provenance: fact.provenance } : {}),
15530
15571
  });
15531
15572
  // v8.2: graph edge building (fail-open). #1576: skip pending_review facts.
15532
15573
  if (graphCaps.multiGraphMemory && faithfulnessEnforceStatus !== "pending_review") {