@remnic/core 1.1.0 → 1.1.1

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 (287) hide show
  1. package/dist/access-audit.d.ts +56 -0
  2. package/dist/access-audit.js +9 -0
  3. package/dist/access-cli.js +62 -45
  4. package/dist/access-cli.js.map +1 -1
  5. package/dist/access-http.d.ts +16 -9
  6. package/dist/access-http.js +25 -17
  7. package/dist/access-mcp.d.ts +16 -9
  8. package/dist/access-mcp.js +29 -7
  9. package/dist/access-schema.d.ts +124 -33
  10. package/dist/access-schema.js +5 -1
  11. package/dist/{access-service-HmO1Trrx.d.ts → access-service-Br8ZydTK.d.ts} +158 -63
  12. package/dist/access-service.d.ts +13 -6
  13. package/dist/access-service.js +22 -14
  14. package/dist/bootstrap.d.ts +6 -3
  15. package/dist/briefing.d.ts +1 -0
  16. package/dist/briefing.js +7 -6
  17. package/dist/buffer-surprise-report.d.ts +70 -0
  18. package/dist/buffer-surprise-report.js +7 -0
  19. package/dist/buffer-surprise-report.js.map +1 -0
  20. package/dist/buffer-surprise.d.ts +98 -0
  21. package/dist/buffer-surprise.js +11 -0
  22. package/dist/buffer-surprise.js.map +1 -0
  23. package/dist/buffer.d.ts +100 -2
  24. package/dist/buffer.js +1 -1
  25. package/dist/calibration.js +5 -5
  26. package/dist/causal-behavior.js +4 -4
  27. package/dist/causal-chain.js +2 -2
  28. package/dist/causal-consolidation.js +17 -16
  29. package/dist/causal-consolidation.js.map +1 -1
  30. package/dist/causal-retrieval.js +4 -4
  31. package/dist/causal-trajectory.js +1 -1
  32. package/dist/{chunk-QNJMBKFK.js → chunk-2LGMW3DJ.js} +3 -2
  33. package/dist/chunk-2LGMW3DJ.js.map +1 -0
  34. package/dist/{chunk-QDYXG4CS.js → chunk-3FPTCC3Z.js} +4 -3
  35. package/dist/chunk-3FPTCC3Z.js.map +1 -0
  36. package/dist/chunk-3GPTTA4J.js +57 -0
  37. package/dist/chunk-3GPTTA4J.js.map +1 -0
  38. package/dist/{chunk-44ICJRF3.js → chunk-3GXCSUXR.js} +4 -4
  39. package/dist/{chunk-ITRLGI2T.js → chunk-3OGMS3PE.js} +2 -2
  40. package/dist/chunk-54V4BZWP.js +139 -0
  41. package/dist/chunk-54V4BZWP.js.map +1 -0
  42. package/dist/chunk-5JRF2PZA.js +67 -0
  43. package/dist/chunk-5JRF2PZA.js.map +1 -0
  44. package/dist/chunk-64NJRYU2.js +332 -0
  45. package/dist/chunk-64NJRYU2.js.map +1 -0
  46. package/dist/{chunk-OIT5QGG4.js → chunk-6AUUAZEX.js} +72 -2
  47. package/dist/chunk-6AUUAZEX.js.map +1 -0
  48. package/dist/{chunk-ZVBB3T7V.js → chunk-7I7FKFZH.js} +24 -22
  49. package/dist/chunk-7I7FKFZH.js.map +1 -0
  50. package/dist/chunk-AJU4PJGY.js +126 -0
  51. package/dist/chunk-AJU4PJGY.js.map +1 -0
  52. package/dist/chunk-ASAITVLA.js +64 -0
  53. package/dist/chunk-ASAITVLA.js.map +1 -0
  54. package/dist/{chunk-3QHL5ABG.js → chunk-B5WXLVDY.js} +187 -6
  55. package/dist/chunk-B5WXLVDY.js.map +1 -0
  56. package/dist/{chunk-SYUK3VLY.js → chunk-BGJGXLZ7.js} +111 -2
  57. package/dist/{chunk-SYUK3VLY.js.map → chunk-BGJGXLZ7.js.map} +1 -1
  58. package/dist/{chunk-MBJHSA7F.js → chunk-BK2EFTE2.js} +258 -13
  59. package/dist/chunk-BK2EFTE2.js.map +1 -0
  60. package/dist/chunk-C4SQJZAF.js +486 -0
  61. package/dist/chunk-C4SQJZAF.js.map +1 -0
  62. package/dist/{chunk-6UJ47TVX.js → chunk-CUPFXL3J.js} +2 -2
  63. package/dist/chunk-DF3RVK3X.js +119 -0
  64. package/dist/chunk-DF3RVK3X.js.map +1 -0
  65. package/dist/{chunk-37UIFYWO.js → chunk-DFTTJYSO.js} +108 -9
  66. package/dist/chunk-DFTTJYSO.js.map +1 -0
  67. package/dist/chunk-DGVM5SFL.js +69 -0
  68. package/dist/chunk-DGVM5SFL.js.map +1 -0
  69. package/dist/chunk-EIR5VLIH.js +90 -0
  70. package/dist/chunk-EIR5VLIH.js.map +1 -0
  71. package/dist/{chunk-PAORGQRI.js → chunk-EPQJM2GC.js} +37 -23
  72. package/dist/chunk-EPQJM2GC.js.map +1 -0
  73. package/dist/{chunk-GV6NLQ4X.js → chunk-F5VP6YCB.js} +374 -16
  74. package/dist/chunk-F5VP6YCB.js.map +1 -0
  75. package/dist/{chunk-6ZH4TU6I.js → chunk-FAAFWE4G.js} +2 -1
  76. package/dist/chunk-FAAFWE4G.js.map +1 -0
  77. package/dist/{chunk-7WQ6SLIE.js → chunk-FVA6TGI3.js} +2 -2
  78. package/dist/chunk-GDFS42HT.js +206 -0
  79. package/dist/chunk-GDFS42HT.js.map +1 -0
  80. package/dist/{chunk-MVTHXUBX.js → chunk-GKFXUTJ2.js} +479 -20
  81. package/dist/chunk-GKFXUTJ2.js.map +1 -0
  82. package/dist/{chunk-NQEVYWX6.js → chunk-HK3FGIEW.js} +209 -5
  83. package/dist/chunk-HK3FGIEW.js.map +1 -0
  84. package/dist/chunk-IISBCCWR.js +52 -0
  85. package/dist/chunk-IISBCCWR.js.map +1 -0
  86. package/dist/{chunk-WBSAYXVI.js → chunk-INXV5JBT.js} +198 -42
  87. package/dist/chunk-INXV5JBT.js.map +1 -0
  88. package/dist/chunk-JBMSGZEQ.js +441 -0
  89. package/dist/chunk-JBMSGZEQ.js.map +1 -0
  90. package/dist/{chunk-J4IYOZZ5.js → chunk-JXS5PDQ7.js} +3 -1
  91. package/dist/chunk-JXS5PDQ7.js.map +1 -0
  92. package/dist/{chunk-6LX5ORAS.js → chunk-KUB6JU6H.js} +4 -4
  93. package/dist/chunk-KVBLZUKV.js +173 -0
  94. package/dist/chunk-KVBLZUKV.js.map +1 -0
  95. package/dist/chunk-LBLXEFWK.js +51 -0
  96. package/dist/chunk-LBLXEFWK.js.map +1 -0
  97. package/dist/{chunk-3WHVNEN7.js → chunk-LTCGGW2D.js} +1 -1
  98. package/dist/chunk-LTCGGW2D.js.map +1 -0
  99. package/dist/{chunk-UEYA6UC7.js → chunk-NZLQTHS5.js} +25 -2
  100. package/dist/chunk-NZLQTHS5.js.map +1 -0
  101. package/dist/chunk-PVPWZSSI.js +37 -0
  102. package/dist/chunk-PVPWZSSI.js.map +1 -0
  103. package/dist/{chunk-4NRAJUDS.js → chunk-RBBWYEFJ.js} +1 -1
  104. package/dist/chunk-RFYAYKTD.js +146 -0
  105. package/dist/chunk-RFYAYKTD.js.map +1 -0
  106. package/dist/{chunk-DHHP2Z4X.js → chunk-RGLL5SPU.js} +2 -2
  107. package/dist/{chunk-3SV6CQHO.js → chunk-S3EEFKNY.js} +101 -65
  108. package/dist/chunk-S3EEFKNY.js.map +1 -0
  109. package/dist/chunk-SOBJ6NEY.js +18 -0
  110. package/dist/chunk-SOBJ6NEY.js.map +1 -0
  111. package/dist/{chunk-JIU55F3X.js → chunk-SPI27QT6.js} +2 -2
  112. package/dist/chunk-TVVEYCNW.js +65 -0
  113. package/dist/chunk-TVVEYCNW.js.map +1 -0
  114. package/dist/chunk-ULYOGL6R.js +322 -0
  115. package/dist/chunk-ULYOGL6R.js.map +1 -0
  116. package/dist/{chunk-47UU5PU2.js → chunk-VBVG2M5G.js} +18 -3
  117. package/dist/chunk-VBVG2M5G.js.map +1 -0
  118. package/dist/{chunk-7ECD5ATE.js → chunk-VDX363PS.js} +2 -2
  119. package/dist/{chunk-DEPL3635.js → chunk-VYM3VWOF.js} +1432 -188
  120. package/dist/chunk-VYM3VWOF.js.map +1 -0
  121. package/dist/{chunk-MTLYEMJB.js → chunk-WCLICCGB.js} +18 -3
  122. package/dist/chunk-WCLICCGB.js.map +1 -0
  123. package/dist/{chunk-4LACOVZX.js → chunk-WVVA7F5A.js} +2 -2
  124. package/dist/chunk-X6GF3FX2.js +26 -0
  125. package/dist/chunk-X6GF3FX2.js.map +1 -0
  126. package/dist/{chunk-3QFQGRHO.js → chunk-XMHBH5H6.js} +4 -4
  127. package/dist/{chunk-BLKTA7MM.js → chunk-YNQKWQT4.js} +50 -17
  128. package/dist/chunk-YNQKWQT4.js.map +1 -0
  129. package/dist/chunk-ZAIM4TUE.js +488 -0
  130. package/dist/chunk-ZAIM4TUE.js.map +1 -0
  131. package/dist/{chunk-N42IWANG.js → chunk-ZEM3OK2K.js} +2 -2
  132. package/dist/chunk-ZZTOURJI.js +91 -0
  133. package/dist/chunk-ZZTOURJI.js.map +1 -0
  134. package/dist/{cli-BneVIEvh.d.ts → cli-BkeRaYfk.d.ts} +2 -2
  135. package/dist/cli.d.ts +13 -6
  136. package/dist/cli.js +40 -29
  137. package/dist/config.js +1 -1
  138. package/dist/consolidation-operator.d.ts +41 -0
  139. package/dist/consolidation-operator.js +11 -0
  140. package/dist/consolidation-operator.js.map +1 -0
  141. package/dist/consolidation-provenance-check.d.ts +68 -0
  142. package/dist/consolidation-provenance-check.js +9 -0
  143. package/dist/consolidation-provenance-check.js.map +1 -0
  144. package/dist/consolidation-undo.d.ts +123 -0
  145. package/dist/consolidation-undo.js +426 -0
  146. package/dist/consolidation-undo.js.map +1 -0
  147. package/dist/{contradiction-scan-GR33PONM.js → contradiction-scan-E3GJTI4F.js} +43 -7
  148. package/dist/contradiction-scan-E3GJTI4F.js.map +1 -0
  149. package/dist/cross-namespace-budget.d.ts +133 -0
  150. package/dist/cross-namespace-budget.js +9 -0
  151. package/dist/cross-namespace-budget.js.map +1 -0
  152. package/dist/direct-answer-wiring.js +5 -70
  153. package/dist/direct-answer-wiring.js.map +1 -1
  154. package/dist/{engine-5TIQBYZR.js → engine-F3GOXGE5.js} +8 -7
  155. package/dist/engine-F3GOXGE5.js.map +1 -0
  156. package/dist/entity-retrieval.d.ts +1 -0
  157. package/dist/entity-retrieval.js +7 -6
  158. package/dist/explicit-capture.d.ts +6 -3
  159. package/dist/explicit-capture.js +2 -2
  160. package/dist/extraction-judge-telemetry.d.ts +113 -0
  161. package/dist/extraction-judge-telemetry.js +14 -0
  162. package/dist/extraction-judge-telemetry.js.map +1 -0
  163. package/dist/extraction-judge-training.d.ts +85 -0
  164. package/dist/extraction-judge-training.js +16 -0
  165. package/dist/extraction-judge-training.js.map +1 -0
  166. package/dist/extraction-judge.d.ts +124 -2
  167. package/dist/extraction-judge.js +11 -1
  168. package/dist/extraction.js +6 -5
  169. package/dist/fallback-llm.js +2 -2
  170. package/dist/graph-recall.d.ts +100 -0
  171. package/dist/graph-recall.js +8 -0
  172. package/dist/graph-recall.js.map +1 -0
  173. package/dist/graph-retrieval.d.ts +271 -0
  174. package/dist/graph-retrieval.js +21 -0
  175. package/dist/graph-retrieval.js.map +1 -0
  176. package/dist/importance.js +1 -1
  177. package/dist/index.d.ts +585 -20
  178. package/dist/index.js +503 -312
  179. package/dist/index.js.map +1 -1
  180. package/dist/memory-worth-bench.d.ts +51 -0
  181. package/dist/memory-worth-bench.js +131 -0
  182. package/dist/memory-worth-bench.js.map +1 -0
  183. package/dist/memory-worth-filter.d.ts +128 -0
  184. package/dist/memory-worth-filter.js +10 -0
  185. package/dist/memory-worth-filter.js.map +1 -0
  186. package/dist/memory-worth-outcomes.d.ts +118 -0
  187. package/dist/memory-worth-outcomes.js +9 -0
  188. package/dist/memory-worth-outcomes.js.map +1 -0
  189. package/dist/memory-worth.d.ts +102 -0
  190. package/dist/memory-worth.js +7 -0
  191. package/dist/memory-worth.js.map +1 -0
  192. package/dist/operator-toolkit.d.ts +40 -1
  193. package/dist/operator-toolkit.js +23 -14
  194. package/dist/{orchestrator-DRYA6_lW.d.ts → orchestrator-CmJ-NTdJ.d.ts} +233 -8
  195. package/dist/orchestrator.d.ts +6 -3
  196. package/dist/orchestrator.js +49 -39
  197. package/dist/page-versioning.d.ts +12 -1
  198. package/dist/page-versioning.js +5 -3
  199. package/dist/{port-C1GZFv8h.d.ts → port-BADbLZU5.d.ts} +2 -2
  200. package/dist/qmd-recall-cache.d.ts +1 -1
  201. package/dist/qmd.d.ts +5 -3
  202. package/dist/qmd.js +1 -1
  203. package/dist/reasoning-trace-recall.d.ts +90 -0
  204. package/dist/reasoning-trace-recall.js +13 -0
  205. package/dist/reasoning-trace-recall.js.map +1 -0
  206. package/dist/reasoning-trace-types.d.ts +54 -0
  207. package/dist/reasoning-trace-types.js +17 -0
  208. package/dist/reasoning-trace-types.js.map +1 -0
  209. package/dist/recall-audit-anomaly.d.ts +112 -0
  210. package/dist/recall-audit-anomaly.js +11 -0
  211. package/dist/recall-audit-anomaly.js.map +1 -0
  212. package/dist/recall-audit.js +5 -44
  213. package/dist/recall-audit.js.map +1 -1
  214. package/dist/recall-explain-renderer.d.ts +49 -0
  215. package/dist/recall-explain-renderer.js +18 -0
  216. package/dist/recall-explain-renderer.js.map +1 -0
  217. package/dist/recall-state.d.ts +12 -1
  218. package/dist/recall-state.js +1 -1
  219. package/dist/recall-xray-cli.d.ts +40 -0
  220. package/dist/recall-xray-cli.js +11 -0
  221. package/dist/recall-xray-cli.js.map +1 -0
  222. package/dist/recall-xray-renderer.d.ts +44 -0
  223. package/dist/recall-xray-renderer.js +18 -0
  224. package/dist/recall-xray-renderer.js.map +1 -0
  225. package/dist/recall-xray.d.ts +179 -0
  226. package/dist/recall-xray.js +13 -0
  227. package/dist/recall-xray.js.map +1 -0
  228. package/dist/resume-bundles.js +5 -5
  229. package/dist/retrieval-agents.d.ts +1 -1
  230. package/dist/retrieval-tiers.d.ts +17 -0
  231. package/dist/retrieval-tiers.js +9 -0
  232. package/dist/retrieval-tiers.js.map +1 -0
  233. package/dist/schemas.d.ts +287 -31
  234. package/dist/schemas.js +1 -1
  235. package/dist/{semantic-consolidation-DrvSYRdB.d.ts → semantic-consolidation-CxJU6MJk.d.ts} +62 -1
  236. package/dist/semantic-consolidation.d.ts +2 -1
  237. package/dist/semantic-consolidation.js +21 -7
  238. package/dist/semantic-rule-promotion.js +7 -6
  239. package/dist/semantic-rule-verifier.js +7 -6
  240. package/dist/storage.d.ts +82 -1
  241. package/dist/storage.js +6 -5
  242. package/dist/summarizer.js +3 -3
  243. package/dist/temporal-supersession.d.ts +1 -0
  244. package/dist/tier-migration.d.ts +2 -1
  245. package/dist/types.d.ts +276 -2
  246. package/dist/types.js +1 -1
  247. package/dist/verified-recall.js +7 -6
  248. package/package.json +1 -1
  249. package/dist/chunk-37UIFYWO.js.map +0 -1
  250. package/dist/chunk-3QHL5ABG.js.map +0 -1
  251. package/dist/chunk-3SV6CQHO.js.map +0 -1
  252. package/dist/chunk-3WHVNEN7.js.map +0 -1
  253. package/dist/chunk-47UU5PU2.js.map +0 -1
  254. package/dist/chunk-6ZH4TU6I.js.map +0 -1
  255. package/dist/chunk-BLKTA7MM.js.map +0 -1
  256. package/dist/chunk-DEPL3635.js.map +0 -1
  257. package/dist/chunk-GV6NLQ4X.js.map +0 -1
  258. package/dist/chunk-J4IYOZZ5.js.map +0 -1
  259. package/dist/chunk-LAYN4LDC.js +0 -267
  260. package/dist/chunk-LAYN4LDC.js.map +0 -1
  261. package/dist/chunk-MBJHSA7F.js.map +0 -1
  262. package/dist/chunk-MTLYEMJB.js.map +0 -1
  263. package/dist/chunk-MVTHXUBX.js.map +0 -1
  264. package/dist/chunk-NQEVYWX6.js.map +0 -1
  265. package/dist/chunk-OIT5QGG4.js.map +0 -1
  266. package/dist/chunk-PAORGQRI.js.map +0 -1
  267. package/dist/chunk-QDYXG4CS.js.map +0 -1
  268. package/dist/chunk-QNJMBKFK.js.map +0 -1
  269. package/dist/chunk-UEYA6UC7.js.map +0 -1
  270. package/dist/chunk-UVJFDP7P.js +0 -202
  271. package/dist/chunk-UVJFDP7P.js.map +0 -1
  272. package/dist/chunk-WBSAYXVI.js.map +0 -1
  273. package/dist/chunk-ZVBB3T7V.js.map +0 -1
  274. package/dist/contradiction-scan-GR33PONM.js.map +0 -1
  275. /package/dist/{engine-5TIQBYZR.js.map → access-audit.js.map} +0 -0
  276. /package/dist/{chunk-44ICJRF3.js.map → chunk-3GXCSUXR.js.map} +0 -0
  277. /package/dist/{chunk-ITRLGI2T.js.map → chunk-3OGMS3PE.js.map} +0 -0
  278. /package/dist/{chunk-6UJ47TVX.js.map → chunk-CUPFXL3J.js.map} +0 -0
  279. /package/dist/{chunk-7WQ6SLIE.js.map → chunk-FVA6TGI3.js.map} +0 -0
  280. /package/dist/{chunk-6LX5ORAS.js.map → chunk-KUB6JU6H.js.map} +0 -0
  281. /package/dist/{chunk-4NRAJUDS.js.map → chunk-RBBWYEFJ.js.map} +0 -0
  282. /package/dist/{chunk-DHHP2Z4X.js.map → chunk-RGLL5SPU.js.map} +0 -0
  283. /package/dist/{chunk-JIU55F3X.js.map → chunk-SPI27QT6.js.map} +0 -0
  284. /package/dist/{chunk-7ECD5ATE.js.map → chunk-VDX363PS.js.map} +0 -0
  285. /package/dist/{chunk-4LACOVZX.js.map → chunk-WVVA7F5A.js.map} +0 -0
  286. /package/dist/{chunk-3QFQGRHO.js.map → chunk-XMHBH5H6.js.map} +0 -0
  287. /package/dist/{chunk-N42IWANG.js.map → chunk-ZEM3OK2K.js.map} +0 -0
@@ -1,3 +1,6 @@
1
+ import {
2
+ toRecallExplainJson
3
+ } from "./chunk-ZAIM4TUE.js";
1
4
  import {
2
5
  buildProposedActions,
3
6
  buildQualityScore,
@@ -5,7 +8,7 @@ import {
5
8
  listMemoryGovernanceRuns,
6
9
  readMemoryGovernanceRunArtifact,
7
10
  runMemoryGovernance
8
- } from "./chunk-ITRLGI2T.js";
11
+ } from "./chunk-3OGMS3PE.js";
9
12
  import {
10
13
  getTrustZoneStoreStatus,
11
14
  isTrustZoneName,
@@ -16,10 +19,8 @@ import {
16
19
  summarizeTrustZonePromotionReadiness
17
20
  } from "./chunk-EQINRHYR.js";
18
21
  import {
19
- persistExplicitCapture,
20
- queueExplicitCaptureForReview,
21
- validateExplicitCaptureInput
22
- } from "./chunk-QDYXG4CS.js";
22
+ recordMemoryOutcome
23
+ } from "./chunk-EIR5VLIH.js";
23
24
  import {
24
25
  wrapWorkLayerContext
25
26
  } from "./chunk-EEQLFRUM.js";
@@ -27,28 +28,38 @@ import {
27
28
  buildProcedurePersistBody,
28
29
  normalizeProcedureSteps
29
30
  } from "./chunk-QDW3E4RD.js";
31
+ import {
32
+ persistExplicitCapture,
33
+ queueExplicitCaptureForReview,
34
+ validateExplicitCaptureInput
35
+ } from "./chunk-3FPTCC3Z.js";
36
+ import {
37
+ CrossNamespaceBudget
38
+ } from "./chunk-GDFS42HT.js";
30
39
  import {
31
40
  filterTrajectoriesByLookbackDays,
32
41
  readCausalTrajectoryRecords
33
- } from "./chunk-4NRAJUDS.js";
42
+ } from "./chunk-RBBWYEFJ.js";
34
43
  import {
35
44
  canReadNamespace,
36
45
  canWriteNamespace,
46
+ defaultNamespaceForPrincipal,
47
+ recallNamespacesForPrincipal,
37
48
  resolvePrincipal
38
49
  } from "./chunk-N5AKDXAI.js";
39
- import {
40
- AccessIdempotencyStore,
41
- hashAccessIdempotencyPayload
42
- } from "./chunk-XKECPATV.js";
43
50
  import {
44
51
  FileCalendarSource,
45
52
  buildBriefing,
46
53
  parseBriefingFocus,
47
54
  parseBriefingWindow
48
- } from "./chunk-4LACOVZX.js";
55
+ } from "./chunk-WVVA7F5A.js";
49
56
  import {
50
57
  parseEntityFile
51
- } from "./chunk-GV6NLQ4X.js";
58
+ } from "./chunk-F5VP6YCB.js";
59
+ import {
60
+ inferMemoryStatus,
61
+ toMemoryPathRel
62
+ } from "./chunk-TP4FZJIZ.js";
52
63
  import {
53
64
  normalizeProjectionPreview,
54
65
  normalizeProjectionTags
@@ -56,13 +67,16 @@ import {
56
67
  import {
57
68
  getMemoryProjectionPath
58
69
  } from "./chunk-BOUYNNYD.js";
59
- import {
60
- inferMemoryStatus,
61
- toMemoryPathRel
62
- } from "./chunk-TP4FZJIZ.js";
63
70
  import {
64
71
  log
65
72
  } from "./chunk-2ODBA7MQ.js";
73
+ import {
74
+ AccessAuditAdapter
75
+ } from "./chunk-TVVEYCNW.js";
76
+ import {
77
+ AccessIdempotencyStore,
78
+ hashAccessIdempotencyPayload
79
+ } from "./chunk-XKECPATV.js";
66
80
 
67
81
  // src/access-service.ts
68
82
  import { stat } from "fs/promises";
@@ -772,6 +786,125 @@ async function runProcedureMining(options) {
772
786
  return { clustersProcessed, proceduresWritten };
773
787
  }
774
788
 
789
+ // src/procedural/procedure-stats.ts
790
+ function snapshotConfig(config) {
791
+ const p = config.procedural;
792
+ return {
793
+ enabled: p?.enabled === true,
794
+ minOccurrences: typeof p?.minOccurrences === "number" ? p.minOccurrences : 0,
795
+ successFloor: typeof p?.successFloor === "number" ? p.successFloor : 0,
796
+ autoPromoteOccurrences: typeof p?.autoPromoteOccurrences === "number" ? p.autoPromoteOccurrences : 0,
797
+ autoPromoteEnabled: p?.autoPromoteEnabled === true,
798
+ lookbackDays: typeof p?.lookbackDays === "number" ? p.lookbackDays : 0,
799
+ recallMaxProcedures: typeof p?.recallMaxProcedures === "number" ? p.recallMaxProcedures : 0
800
+ };
801
+ }
802
+ function tsMs(value) {
803
+ if (typeof value !== "string") return null;
804
+ const ms = Date.parse(value);
805
+ return Number.isFinite(ms) ? ms : null;
806
+ }
807
+ async function computeProcedureStats(options) {
808
+ const { storage, config } = options;
809
+ const nowMs = options.nowMs ?? Date.now();
810
+ const sevenDaysMs = 7 * 24 * 60 * 60 * 1e3;
811
+ const counts = {
812
+ total: 0,
813
+ active: 0,
814
+ pending_review: 0,
815
+ rejected: 0,
816
+ quarantined: 0,
817
+ superseded: 0,
818
+ archived: 0,
819
+ other: 0
820
+ };
821
+ let lastWriteMs = null;
822
+ let writesLast7Days = 0;
823
+ let minerSourced = 0;
824
+ const known = [
825
+ "active",
826
+ "pending_review",
827
+ "rejected",
828
+ "quarantined",
829
+ "superseded",
830
+ "archived"
831
+ ];
832
+ const seen = /* @__PURE__ */ new Set();
833
+ const live = await storage.readAllMemories();
834
+ const archived = await storage.readArchivedMemories();
835
+ const pool = [...live, ...archived];
836
+ for (const m of pool) {
837
+ if (m.frontmatter.category !== "procedure") continue;
838
+ if (seen.has(m.frontmatter.id)) continue;
839
+ seen.add(m.frontmatter.id);
840
+ counts.total += 1;
841
+ const status = m.frontmatter.status ?? "active";
842
+ if (known.includes(status)) {
843
+ counts[status] += 1;
844
+ } else {
845
+ counts.other += 1;
846
+ }
847
+ const createdMs = tsMs(m.frontmatter.created);
848
+ const updatedMs = tsMs(m.frontmatter.updated);
849
+ const latestMs = createdMs !== null && updatedMs !== null ? Math.max(createdMs, updatedMs) : updatedMs ?? createdMs;
850
+ if (latestMs !== null) {
851
+ if (lastWriteMs === null || latestMs > lastWriteMs) {
852
+ lastWriteMs = latestMs;
853
+ }
854
+ if (latestMs >= nowMs - sevenDaysMs && latestMs < nowMs) {
855
+ writesLast7Days += 1;
856
+ }
857
+ }
858
+ if (m.frontmatter.source === "procedure-miner") {
859
+ minerSourced += 1;
860
+ }
861
+ }
862
+ return {
863
+ schemaVersion: 1,
864
+ generatedAt: new Date(nowMs).toISOString(),
865
+ counts,
866
+ recent: {
867
+ lastWriteAt: lastWriteMs !== null ? new Date(lastWriteMs).toISOString() : null,
868
+ writesLast7Days,
869
+ minerSourced
870
+ },
871
+ config: snapshotConfig(config)
872
+ };
873
+ }
874
+ function formatProcedureStatsText(report) {
875
+ const { counts, recent, config } = report;
876
+ const lines = [];
877
+ lines.push(`Procedural memory stats (schema v${report.schemaVersion})`);
878
+ lines.push(` generated: ${report.generatedAt}`);
879
+ lines.push("");
880
+ lines.push(` config:`);
881
+ lines.push(` enabled: ${config.enabled}`);
882
+ lines.push(` minOccurrences: ${config.minOccurrences}`);
883
+ lines.push(` successFloor: ${config.successFloor}`);
884
+ lines.push(` autoPromoteOccurrences: ${config.autoPromoteOccurrences}`);
885
+ lines.push(` autoPromoteEnabled: ${config.autoPromoteEnabled}`);
886
+ lines.push(` lookbackDays: ${config.lookbackDays}`);
887
+ lines.push(` recallMaxProcedures: ${config.recallMaxProcedures}`);
888
+ lines.push("");
889
+ lines.push(` counts:`);
890
+ lines.push(` total: ${counts.total}`);
891
+ lines.push(` active: ${counts.active}`);
892
+ lines.push(` pending_review: ${counts.pending_review}`);
893
+ lines.push(` rejected: ${counts.rejected}`);
894
+ lines.push(` quarantined: ${counts.quarantined}`);
895
+ lines.push(` superseded: ${counts.superseded}`);
896
+ lines.push(` archived: ${counts.archived}`);
897
+ if (counts.other > 0) {
898
+ lines.push(` other: ${counts.other}`);
899
+ }
900
+ lines.push("");
901
+ lines.push(` recent:`);
902
+ lines.push(` lastWriteAt: ${recent.lastWriteAt ?? "(none)"}`);
903
+ lines.push(` writesLast7Days: ${recent.writesLast7Days}`);
904
+ lines.push(` minerSourced: ${recent.minerSourced}`);
905
+ return lines.join("\n") + "\n";
906
+ }
907
+
775
908
  // src/access-service.ts
776
909
  var EngramAccessInputError = class extends Error {
777
910
  };
@@ -891,10 +1024,39 @@ var EngramAccessService = class {
891
1024
  constructor(orchestrator) {
892
1025
  this.orchestrator = orchestrator;
893
1026
  this.idempotency = new AccessIdempotencyStore(orchestrator.config.memoryDir);
1027
+ this.budget = new CrossNamespaceBudget({
1028
+ enabled: orchestrator.config.recallCrossNamespaceBudgetEnabled,
1029
+ windowMs: orchestrator.config.recallCrossNamespaceBudgetWindowMs,
1030
+ softLimit: orchestrator.config.recallCrossNamespaceBudgetSoftLimit,
1031
+ hardLimit: orchestrator.config.recallCrossNamespaceBudgetHardLimit
1032
+ });
1033
+ const auditEnabled = orchestrator.config.recallAuditAnomalyDetectionEnabled === true;
1034
+ const auditLogEnabled = false;
1035
+ if (auditEnabled || auditLogEnabled) {
1036
+ const auditConfig = {
1037
+ audit: {
1038
+ enabled: auditLogEnabled,
1039
+ rootDir: orchestrator.config.memoryDir
1040
+ },
1041
+ detection: {
1042
+ enabled: auditEnabled,
1043
+ windowMs: orchestrator.config.recallAuditAnomalyWindowMs,
1044
+ repeatQueryLimit: orchestrator.config.recallAuditAnomalyRepeatQueryLimit,
1045
+ namespaceWalkLimit: orchestrator.config.recallAuditAnomalyNamespaceWalkLimit,
1046
+ highCardinalityReturnLimit: orchestrator.config.recallAuditAnomalyHighCardinalityLimit,
1047
+ rapidFireLimit: orchestrator.config.recallAuditAnomalyRapidFireLimit
1048
+ }
1049
+ };
1050
+ this.auditAdapter = new AccessAuditAdapter(auditConfig);
1051
+ } else {
1052
+ this.auditAdapter = null;
1053
+ }
894
1054
  }
895
1055
  orchestrator;
896
1056
  idempotency;
897
1057
  idempotencyLocks = /* @__PURE__ */ new Map();
1058
+ budget;
1059
+ auditAdapter;
898
1060
  get briefingEnabled() {
899
1061
  return this.orchestrator.config.briefing?.enabled === true;
900
1062
  }
@@ -1147,14 +1309,117 @@ var EngramAccessService = class {
1147
1309
  followupsUnavailableReason: result.followupsUnavailableReason
1148
1310
  };
1149
1311
  }
1312
+ /**
1313
+ * Attach a coding context to a session (issue #569). Used by the Claude
1314
+ * Code / Codex / generic-MCP connectors at session start so that recall +
1315
+ * write paths can route to a project- / branch-scoped namespace.
1316
+ *
1317
+ * Validates the input shape and rejects malformed payloads rather than
1318
+ * silently accepting them (CLAUDE.md #51). Pass `codingContext: null` to
1319
+ * clear.
1320
+ */
1321
+ setCodingContext(request) {
1322
+ const sessionKey = typeof request.sessionKey === "string" ? request.sessionKey.trim() : "";
1323
+ if (!sessionKey) {
1324
+ throw new EngramAccessInputError("sessionKey is required for setCodingContext");
1325
+ }
1326
+ if (request.codingContext === null) {
1327
+ this.orchestrator.setCodingContextForSession(sessionKey, null);
1328
+ return;
1329
+ }
1330
+ const ctx = request.codingContext;
1331
+ if (!ctx || typeof ctx !== "object") {
1332
+ throw new EngramAccessInputError("codingContext must be an object or null");
1333
+ }
1334
+ if (typeof ctx.projectId !== "string" || ctx.projectId.trim().length === 0) {
1335
+ throw new EngramAccessInputError("codingContext.projectId must be a non-empty string");
1336
+ }
1337
+ if (typeof ctx.rootPath !== "string" || ctx.rootPath.trim().length === 0) {
1338
+ throw new EngramAccessInputError("codingContext.rootPath must be a non-empty string");
1339
+ }
1340
+ if (ctx.branch !== null && typeof ctx.branch !== "string") {
1341
+ throw new EngramAccessInputError("codingContext.branch must be a string or null");
1342
+ }
1343
+ if (ctx.defaultBranch !== null && typeof ctx.defaultBranch !== "string") {
1344
+ throw new EngramAccessInputError("codingContext.defaultBranch must be a string or null");
1345
+ }
1346
+ this.orchestrator.setCodingContextForSession(sessionKey, {
1347
+ projectId: ctx.projectId,
1348
+ branch: ctx.branch,
1349
+ rootPath: ctx.rootPath,
1350
+ defaultBranch: ctx.defaultBranch
1351
+ });
1352
+ }
1150
1353
  async recall(request) {
1151
1354
  const query = request.query.trim();
1152
1355
  if (query.length === 0) {
1153
1356
  throw new EngramAccessInputError("query is required");
1154
1357
  }
1358
+ if (request.codingContext !== void 0 && request.sessionKey) {
1359
+ this.setCodingContext({
1360
+ sessionKey: request.sessionKey,
1361
+ codingContext: request.codingContext
1362
+ });
1363
+ }
1155
1364
  const namespaceOverride = this.resolveRecallNamespace(request.namespace, request.sessionKey);
1156
1365
  const namespace = namespaceOverride ?? this.orchestrator.config.defaultNamespace;
1157
1366
  const mode = this.normalizeRecallMode(request.mode);
1367
+ const principal = resolvePrincipal(request.sessionKey, this.orchestrator.config);
1368
+ const principalNamespace = defaultNamespaceForPrincipal(principal, this.orchestrator.config);
1369
+ const modeSkipsBudget = mode === "no_recall";
1370
+ const effectiveNamespaces = namespaceOverride ? [namespaceOverride] : recallNamespacesForPrincipal(principal, this.orchestrator.config);
1371
+ let budgetDecision;
1372
+ if (modeSkipsBudget) {
1373
+ budgetDecision = {
1374
+ allowed: true,
1375
+ reason: "allowed-same-namespace",
1376
+ count: 0,
1377
+ limit: {
1378
+ softLimit: this.orchestrator.config.recallCrossNamespaceBudgetSoftLimit ?? 10,
1379
+ hardLimit: this.orchestrator.config.recallCrossNamespaceBudgetHardLimit ?? 30,
1380
+ windowMs: this.orchestrator.config.recallCrossNamespaceBudgetWindowMs ?? 6e4
1381
+ }
1382
+ };
1383
+ } else {
1384
+ let anyCrossNamespace = false;
1385
+ let denied = null;
1386
+ for (const ns of effectiveNamespaces) {
1387
+ const peek = this.budget.peek({
1388
+ principal,
1389
+ principalNamespace,
1390
+ queryNamespace: ns
1391
+ });
1392
+ if (peek.reason !== "allowed-same-namespace") {
1393
+ anyCrossNamespace = true;
1394
+ }
1395
+ if (!peek.allowed) {
1396
+ denied = peek;
1397
+ break;
1398
+ }
1399
+ }
1400
+ if (denied) {
1401
+ budgetDecision = denied;
1402
+ } else if (anyCrossNamespace) {
1403
+ budgetDecision = this.budget.record(principal);
1404
+ } else {
1405
+ budgetDecision = {
1406
+ allowed: true,
1407
+ reason: "allowed-same-namespace",
1408
+ count: 0,
1409
+ limit: {
1410
+ softLimit: this.orchestrator.config.recallCrossNamespaceBudgetSoftLimit ?? 10,
1411
+ hardLimit: this.orchestrator.config.recallCrossNamespaceBudgetHardLimit ?? 30,
1412
+ windowMs: this.orchestrator.config.recallCrossNamespaceBudgetWindowMs ?? 6e4
1413
+ }
1414
+ };
1415
+ }
1416
+ if (!budgetDecision.allowed) {
1417
+ throw new EngramAccessInputError(
1418
+ `recall denied: cross-namespace budget exceeded (${budgetDecision.count}/${budgetDecision.limit.hardLimit} in ${budgetDecision.limit.windowMs}ms window)`
1419
+ );
1420
+ }
1421
+ this.budget.gc();
1422
+ }
1158
1423
  const topK = Number.isFinite(request.topK) ? Math.max(0, Math.floor(request.topK ?? 0)) : void 0;
1159
1424
  const recallOptions = {
1160
1425
  namespace: namespaceOverride,
@@ -1172,6 +1437,36 @@ var EngramAccessService = class {
1172
1437
  request.includeDebug === true,
1173
1438
  request.sessionKey
1174
1439
  );
1440
+ let auditAnomalies;
1441
+ if (this.auditAdapter) {
1442
+ try {
1443
+ const resolvedAgentId = resolvePrincipal(
1444
+ request.sessionKey,
1445
+ this.orchestrator.config
1446
+ );
1447
+ const auditEntry = {
1448
+ ts: (/* @__PURE__ */ new Date()).toISOString(),
1449
+ sessionKey: request.sessionKey ?? "",
1450
+ agentId: resolvedAgentId,
1451
+ trigger: "access-surface",
1452
+ queryText: query,
1453
+ candidateMemoryIds: snapshot?.memoryIds ?? [],
1454
+ summary: context.slice(0, 200) || null,
1455
+ injectedChars: context.length,
1456
+ toggleState: "enabled",
1457
+ latencyMs: Date.now() - startedAt,
1458
+ plannerMode: snapshot?.plannerMode ?? mode,
1459
+ requestedMode: mode,
1460
+ fallbackUsed: snapshot?.fallbackUsed ?? false
1461
+ };
1462
+ const auditResult = await this.auditAdapter.record(
1463
+ resolvedAgentId || "__anonymous__",
1464
+ auditEntry
1465
+ );
1466
+ auditAnomalies = auditResult.anomalies;
1467
+ } catch {
1468
+ }
1469
+ }
1175
1470
  return {
1176
1471
  query,
1177
1472
  sessionKey: request.sessionKey,
@@ -1186,6 +1481,8 @@ var EngramAccessService = class {
1186
1481
  fallbackUsed: snapshot?.fallbackUsed ?? false,
1187
1482
  sourcesUsed: snapshot?.sourcesUsed ?? [],
1188
1483
  budgetsApplied: snapshot?.budgetsApplied,
1484
+ auditAnomalies,
1485
+ budgetWarning: budgetDecision.reason === "warn-over-soft" ? budgetDecision : void 0,
1189
1486
  latencyMs: snapshot?.latencyMs ?? Date.now() - startedAt,
1190
1487
  debug
1191
1488
  };
@@ -1217,6 +1514,108 @@ var EngramAccessService = class {
1217
1514
  if (!snapshot && !intent && !graph) return { found: false };
1218
1515
  return { found: true, snapshot: snapshot ?? void 0, intent, graph };
1219
1516
  }
1517
+ async recallTierExplain(sessionKey, namespace, authenticatedPrincipal) {
1518
+ const namespacesEnabled = this.orchestrator.config.namespacesEnabled;
1519
+ const requestedNamespace = namespace?.trim() ? this.resolveNamespace(namespace) : void 0;
1520
+ const principal = authenticatedPrincipal?.trim() || resolvePrincipal(sessionKey, this.orchestrator.config);
1521
+ if (requestedNamespace) {
1522
+ if (!canReadNamespace(principal, requestedNamespace, this.orchestrator.config)) {
1523
+ return toRecallExplainJson(null);
1524
+ }
1525
+ } else if (namespacesEnabled && !authenticatedPrincipal?.trim() && !sessionKey?.trim()) {
1526
+ return toRecallExplainJson(null);
1527
+ }
1528
+ const candidate = sessionKey ? this.orchestrator.lastRecall.get(sessionKey) : this.orchestrator.lastRecall.getMostRecent();
1529
+ const snapshot = (() => {
1530
+ if (!candidate) return null;
1531
+ if (requestedNamespace) {
1532
+ return candidate.namespace === requestedNamespace ? candidate : null;
1533
+ }
1534
+ if (!namespacesEnabled) return candidate;
1535
+ const snapshotNs = candidate.namespace ?? this.orchestrator.config.defaultNamespace;
1536
+ return canReadNamespace(principal, snapshotNs, this.orchestrator.config) ? candidate : null;
1537
+ })();
1538
+ return toRecallExplainJson(snapshot);
1539
+ }
1540
+ /**
1541
+ * Recall X-ray (issue #570). Runs a recall with `xrayCapture: true`
1542
+ * and returns the resulting snapshot as structured JSON so every
1543
+ * surface (CLI / HTTP / MCP) gets the same payload. Namespace scope
1544
+ * is enforced before the recall fires (CLAUDE.md rule 42 — read and
1545
+ * write paths must resolve through the same namespace layer) so an
1546
+ * unauthorized principal cannot capture an x-ray for a namespace it
1547
+ * cannot read.
1548
+ */
1549
+ async recallXray(request) {
1550
+ const query = typeof request.query === "string" ? request.query : "";
1551
+ if (query.trim().length === 0) {
1552
+ throw new Error("recallXray: query is required and must be non-empty");
1553
+ }
1554
+ const namespacesEnabled = this.orchestrator.config.namespacesEnabled;
1555
+ const requestedNamespace = request.namespace?.trim() ? this.resolveNamespace(request.namespace) : void 0;
1556
+ const authenticatedPrincipal = request.authenticatedPrincipal?.trim();
1557
+ const principal = authenticatedPrincipal || resolvePrincipal(request.sessionKey, this.orchestrator.config);
1558
+ if (requestedNamespace) {
1559
+ if (!canReadNamespace(
1560
+ principal,
1561
+ requestedNamespace,
1562
+ this.orchestrator.config
1563
+ )) {
1564
+ return { snapshotFound: false };
1565
+ }
1566
+ } else if (namespacesEnabled && !authenticatedPrincipal && !request.sessionKey?.trim()) {
1567
+ return { snapshotFound: false };
1568
+ }
1569
+ let budgetOverride;
1570
+ if (request.budget !== void 0 && request.budget !== null) {
1571
+ const parsed = typeof request.budget === "number" ? request.budget : Number(request.budget);
1572
+ if (!Number.isFinite(parsed) || parsed <= 0 || !Number.isInteger(parsed)) {
1573
+ throw new Error(
1574
+ `recallXray: budget expects a positive integer; got ${JSON.stringify(request.budget)}`
1575
+ );
1576
+ }
1577
+ budgetOverride = parsed;
1578
+ }
1579
+ const previousQueue = this.xrayQueue;
1580
+ let release = () => {
1581
+ };
1582
+ this.xrayQueue = new Promise((resolve) => {
1583
+ release = resolve;
1584
+ });
1585
+ await previousQueue;
1586
+ try {
1587
+ this.orchestrator.clearLastXraySnapshot();
1588
+ await this.orchestrator.recall(query, request.sessionKey?.trim() || void 0, {
1589
+ xrayCapture: true,
1590
+ ...requestedNamespace ? { namespace: requestedNamespace } : {},
1591
+ ...budgetOverride !== void 0 ? { budgetCharsOverride: budgetOverride } : {},
1592
+ // When the caller supplies an authenticated principal, forward
1593
+ // it via the dedicated override channel so orchestrator-side
1594
+ // ACL decisions use the SAME principal the access-surface
1595
+ // pre-check above authorized. Threading an
1596
+ // `authenticatedPrincipal` through `sessionKey` would be wrong:
1597
+ // `resolvePrincipal(sessionKey)` only maps configured raw
1598
+ // session keys and otherwise collapses to `"default"`, which
1599
+ // in namespace-enabled deployments produces false denials /
1600
+ // wrong-scope serving despite the pre-check passing
1601
+ // (CLAUDE.md rule 42).
1602
+ ...authenticatedPrincipal ? { principalOverride: authenticatedPrincipal } : {}
1603
+ });
1604
+ const snapshot = this.orchestrator.getLastXraySnapshot();
1605
+ if (!snapshot) return { snapshotFound: false };
1606
+ if (requestedNamespace && snapshot.namespace !== requestedNamespace) {
1607
+ return { snapshotFound: false };
1608
+ }
1609
+ return { snapshotFound: true, snapshot };
1610
+ } finally {
1611
+ release();
1612
+ }
1613
+ }
1614
+ // Sequence lock for `recallXray` — see comment inside the method.
1615
+ // Lives on the instance so every x-ray call on the same service
1616
+ // shares it, and so separate services in the same process (e.g.
1617
+ // per-tenant) do not block each other.
1618
+ xrayQueue = Promise.resolve();
1220
1619
  async memoryStore(request) {
1221
1620
  const namespace = this.resolveWritableNamespace(
1222
1621
  request.namespace,
@@ -1731,6 +2130,23 @@ var EngramAccessService = class {
1731
2130
  skippedReason: result.skippedReason
1732
2131
  };
1733
2132
  }
2133
+ /**
2134
+ * Procedural memory stats (issue #567 PR 5/5). Read-only — resolves the
2135
+ * namespace via the same path used by `recallExplain` / `trustZoneStatus`
2136
+ * so cross-tenant reads are impossible (CLAUDE.md rule 42).
2137
+ */
2138
+ async procedureStats(request = {}, principal) {
2139
+ const resolvedNamespace = this.resolveReadableNamespace(
2140
+ request.namespace,
2141
+ principal
2142
+ );
2143
+ const storage = await this.orchestrator.getStorage(resolvedNamespace);
2144
+ const report = await computeProcedureStats({
2145
+ storage,
2146
+ config: this.orchestrator.config
2147
+ });
2148
+ return { namespace: resolvedNamespace, ...report };
2149
+ }
1734
2150
  async trustZoneStatus(namespace, principal) {
1735
2151
  const resolvedNamespace = this.resolveReadableNamespace(namespace, principal);
1736
2152
  const storage = await this.orchestrator.getStorage(resolvedNamespace);
@@ -2533,6 +2949,38 @@ ${next}`);
2533
2949
  );
2534
2950
  return { recorded: true };
2535
2951
  }
2952
+ /**
2953
+ * Record a Memory Worth outcome observation (issue #560 PR 3).
2954
+ *
2955
+ * This is distinct from `memoryFeedback` — feedback is a human thumbs
2956
+ * up/down on whether a recalled memory was relevant; outcome is an
2957
+ * automated signal about whether the session that consumed the memory
2958
+ * ultimately succeeded or failed. Outcomes feed the Laplace-smoothed
2959
+ * worth score (`computeMemoryWorth`, PR 2) that PR 4 will use to
2960
+ * downweight memories correlated with bad sessions.
2961
+ *
2962
+ * The underlying writer only touches fact-category memories. Corrections,
2963
+ * procedures, and other kinds return `{ ok: false, reason:
2964
+ * "ineligible_category" }` so a ledger drainer doesn't need to pre-filter.
2965
+ */
2966
+ async memoryOutcome(request) {
2967
+ if (request.memoryId.includes("/") || request.memoryId.includes("\\")) {
2968
+ throw new EngramAccessInputError(
2969
+ "memoryId must not contain path separators"
2970
+ );
2971
+ }
2972
+ const resolvedNs = this.resolveWritableNamespace(
2973
+ request.namespace,
2974
+ request.sessionKey,
2975
+ request.principal
2976
+ );
2977
+ const storage = await this.orchestrator.getStorage(resolvedNs);
2978
+ return recordMemoryOutcome(storage, {
2979
+ memoryPath: `${request.memoryId}.md`,
2980
+ outcome: request.outcome,
2981
+ timestamp: request.timestamp
2982
+ });
2983
+ }
2536
2984
  async memoryPromote(request) {
2537
2985
  const resolvedNs = this.resolveWritableNamespace(request.namespace, request.sessionKey, request.principal);
2538
2986
  const storage = await this.orchestrator.getStorage(resolvedNs);
@@ -2625,17 +3073,28 @@ ${next}`);
2625
3073
  return this.orchestrator.localLlm ?? null;
2626
3074
  }
2627
3075
  get fallbackLlmRef() {
2628
- return null;
3076
+ return this.orchestrator.fastGatewayLlm ?? null;
2629
3077
  }
2630
- get embeddingLookupRef() {
2631
- return void 0;
3078
+ get embeddingLookupFactoryRef() {
3079
+ return (storage) => {
3080
+ if (!this.orchestrator.config.embeddingFallbackEnabled) return void 0;
3081
+ return async (content, limit) => {
3082
+ try {
3083
+ return await this.orchestrator.semanticDedupLookup(content, limit, storage);
3084
+ } catch {
3085
+ return [];
3086
+ }
3087
+ };
3088
+ };
2632
3089
  }
2633
3090
  };
2634
3091
 
2635
3092
  export {
2636
3093
  WorkStorage,
3094
+ computeProcedureStats,
3095
+ formatProcedureStatsText,
2637
3096
  EngramAccessInputError,
2638
3097
  ENGRAM_ACCESS_WRITE_SCHEMA_VERSION,
2639
3098
  EngramAccessService
2640
3099
  };
2641
- //# sourceMappingURL=chunk-MVTHXUBX.js.map
3100
+ //# sourceMappingURL=chunk-GKFXUTJ2.js.map