@remnic/core 9.3.752 → 9.3.753

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 (303) hide show
  1. package/dist/access-admin-ops-surface.d.ts +194 -0
  2. package/dist/access-admin-ops-surface.js +128 -0
  3. package/dist/access-boundary.d.ts +5 -5
  4. package/dist/access-boundary.js +22 -22
  5. package/dist/access-cli.js +72 -72
  6. package/dist/access-http.d.ts +5 -5
  7. package/dist/access-http.js +30 -30
  8. package/dist/access-mcp.d.ts +5 -5
  9. package/dist/access-mcp.js +27 -27
  10. package/dist/access-operations-batch.js +24 -24
  11. package/dist/access-operations.d.ts +11 -11
  12. package/dist/access-operations.js +26 -26
  13. package/dist/access-recall-surface.d.ts +5 -5
  14. package/dist/access-recall-surface.js +21 -21
  15. package/dist/access-schema.d.ts +116 -116
  16. package/dist/access-schema.js +3 -3
  17. package/dist/{access-service-C2cOHQvg.d.ts → access-service-MitduesD.d.ts} +72 -96
  18. package/dist/access-service.d.ts +5 -5
  19. package/dist/access-service.js +25 -21
  20. package/dist/access-surface-catalog.d.ts +5 -5
  21. package/dist/action-confidence.d.ts +1 -1
  22. package/dist/active-memory-bridge.d.ts +1 -1
  23. package/dist/active-recall.d.ts +1 -1
  24. package/dist/active-recall.js +5 -5
  25. package/dist/adapters/index.js +4 -4
  26. package/dist/adapters/registry.js +2 -2
  27. package/dist/behavior-learner.d.ts +1 -1
  28. package/dist/behavior-signals.d.ts +1 -1
  29. package/dist/bootstrap.d.ts +4 -4
  30. package/dist/briefing.d.ts +3 -3
  31. package/dist/briefing.js +8 -8
  32. package/dist/buffer-surprise-report.d.ts +1 -1
  33. package/dist/buffer.d.ts +3 -3
  34. package/dist/buffer.js +2 -2
  35. package/dist/calibration.d.ts +1 -1
  36. package/dist/capabilities.d.ts +1 -1
  37. package/dist/{catalog-D_FvzTM0.d.ts → catalog-BEmNVRN0.d.ts} +1 -1
  38. package/dist/causal-behavior.d.ts +1 -1
  39. package/dist/causal-consolidation.d.ts +1 -1
  40. package/dist/causal-consolidation.js +11 -11
  41. package/dist/causal-trajectory-graph.d.ts +1 -1
  42. package/dist/{chunk-J2JB6BHT.js → chunk-243P7YYV.js} +8 -8
  43. package/dist/{chunk-YGNQG4Q6.js → chunk-34THARMH.js} +10 -10
  44. package/dist/{chunk-UFNQKZV7.js → chunk-3HGZX26P.js} +20 -20
  45. package/dist/{chunk-2U4E34Y3.js → chunk-3ZIKDH6C.js} +4 -4
  46. package/dist/{chunk-5JAT4ZJD.js → chunk-4DLFJJOQ.js} +4 -4
  47. package/dist/{chunk-BIAMJUUJ.js → chunk-5QANTTY2.js} +4 -4
  48. package/dist/{chunk-JBPKEARU.js → chunk-AU7Q3LSC.js} +4 -4
  49. package/dist/{chunk-L3VSTJ2V.js → chunk-AXBRVBT6.js} +2 -2
  50. package/dist/{chunk-V4ZPLQLC.js → chunk-BWOEYBRB.js} +2 -2
  51. package/dist/{chunk-2DPCAW2T.js → chunk-C3IHRWIC.js} +8 -8
  52. package/dist/{chunk-MW7UUXTA.js → chunk-DBSMLRTO.js} +5 -5
  53. package/dist/{chunk-OVMLS7TN.js → chunk-DKIZ4BUQ.js} +14 -14
  54. package/dist/{chunk-RBYV3WSB.js → chunk-DS4QM6I7.js} +4 -4
  55. package/dist/{chunk-IBPEVGP5.js → chunk-E3MRYDUQ.js} +2 -2
  56. package/dist/{chunk-MTN2G4DT.js → chunk-E6LENGYV.js} +2 -2
  57. package/dist/{chunk-K5CWCJKJ.js → chunk-EEO4YWQ7.js} +10 -10
  58. package/dist/{chunk-KFNG72W7.js → chunk-GWGWBK5Y.js} +2 -2
  59. package/dist/{chunk-5DXUE7GB.js → chunk-HAZVVOYT.js} +2 -2
  60. package/dist/{chunk-R7TGDLV3.js → chunk-HM6UJPPO.js} +4 -4
  61. package/dist/{chunk-C4LNKQ3M.js → chunk-ITLJATQI.js} +5 -5
  62. package/dist/{chunk-MEPWWSTD.js → chunk-JES2O5Q6.js} +4 -4
  63. package/dist/{chunk-SC5AEZLU.js → chunk-JGPURIEH.js} +9 -9
  64. package/dist/{chunk-33NX5BLR.js → chunk-JRZV3767.js} +4 -4
  65. package/dist/{chunk-IQWFWSCP.js → chunk-JZ7P26GF.js} +4 -4
  66. package/dist/{chunk-XKAOT4ZB.js → chunk-K5LLP4CY.js} +4 -4
  67. package/dist/{chunk-JNKSFIAY.js → chunk-KY4WOZ3P.js} +53 -53
  68. package/dist/{chunk-6ROCH5JV.js → chunk-KYHGLDFU.js} +8 -8
  69. package/dist/{chunk-RRRZ3CLN.js → chunk-LOPZ2DWR.js} +4 -4
  70. package/dist/{chunk-MLDAD27I.js → chunk-LZ73Y56P.js} +5 -5
  71. package/dist/{chunk-FEELYTRT.js → chunk-N3VE7OCY.js} +5 -5
  72. package/dist/{chunk-OKOF7ITI.js → chunk-OSMBC3JU.js} +6 -6
  73. package/dist/{chunk-FLVL4L3L.js → chunk-OUXPVWTZ.js} +5 -5
  74. package/dist/{chunk-QMMCMV2L.js → chunk-OZMBT7N3.js} +6 -6
  75. package/dist/{chunk-VQL22SHO.js → chunk-PN5AMCK2.js} +96 -96
  76. package/dist/{chunk-GFGYHLON.js → chunk-QIRZI3C3.js} +2 -2
  77. package/dist/{chunk-QRM3K3XT.js → chunk-RNWWAS5V.js} +5 -5
  78. package/dist/{chunk-DC5OBZS3.js → chunk-TVISHYL5.js} +2 -2
  79. package/dist/{chunk-S5UYWK3O.js → chunk-VVSV2QVY.js} +6 -6
  80. package/dist/{chunk-GECEETQ3.js → chunk-W3M34XT4.js} +4 -4
  81. package/dist/{chunk-FXRFFYWD.js → chunk-WIWPSQYU.js} +4 -4
  82. package/dist/{chunk-KT2VQLP7.js → chunk-XOPLMSVV.js} +8 -8
  83. package/dist/{chunk-JHZ3LEM7.js → chunk-YNBEHUZH.js} +2 -2
  84. package/dist/{chunk-VX2RYM2K.js → chunk-ZECLLIMX.js} +811 -744
  85. package/dist/chunk-ZECLLIMX.js.map +1 -0
  86. package/dist/{chunk-67JRXV6Z.js → chunk-ZIFPFKB2.js} +5 -5
  87. package/dist/{chunk-ZGGI3COG.js → chunk-ZMHDSIEX.js} +9 -9
  88. package/dist/{cli-DFUU9WYu.d.ts → cli-DqonYBZ0.d.ts} +3 -3
  89. package/dist/cli.d.ts +6 -6
  90. package/dist/cli.js +47 -47
  91. package/dist/compounding/engine.d.ts +3 -3
  92. package/dist/compounding/engine.js +10 -10
  93. package/dist/compounding/preference-consolidator.d.ts +1 -1
  94. package/dist/compression-optimizer.d.ts +1 -1
  95. package/dist/config.d.ts +1 -1
  96. package/dist/config.js +2 -2
  97. package/dist/connectors/codex-materialize-runner.d.ts +1 -1
  98. package/dist/connectors/codex-materialize-runner.js +9 -9
  99. package/dist/connectors/codex-materialize.d.ts +1 -1
  100. package/dist/connectors/index.d.ts +1 -1
  101. package/dist/connectors/index.js +11 -11
  102. package/dist/consolidation-provenance-check.d.ts +1 -1
  103. package/dist/consolidation-undo.d.ts +1 -1
  104. package/dist/contradiction/index.d.ts +1 -1
  105. package/dist/contradiction/index.js +2 -2
  106. package/dist/{contradiction-scan-KO4WWCS4.js → contradiction-scan-2SODRNUF.js} +3 -3
  107. package/dist/contradiction-scan-2SODRNUF.js.map +1 -0
  108. package/dist/conversation-index/backend.d.ts +1 -1
  109. package/dist/conversation-index/chunker.d.ts +1 -1
  110. package/dist/conversation-index/faiss-adapter.d.ts +1 -1
  111. package/dist/conversation-index/indexer.d.ts +1 -1
  112. package/dist/conversation-index/search.d.ts +1 -1
  113. package/dist/day-summary.d.ts +1 -1
  114. package/dist/day-summary.js +2 -2
  115. package/dist/delinearize.d.ts +1 -1
  116. package/dist/direct-answer-wiring.d.ts +1 -1
  117. package/dist/direct-answer.d.ts +1 -1
  118. package/dist/embedding-fallback.d.ts +1 -1
  119. package/dist/embedding-fallback.js +2 -2
  120. package/dist/enrichment/index.d.ts +1 -1
  121. package/dist/entity-retrieval.d.ts +1 -1
  122. package/dist/entity-retrieval.js +9 -9
  123. package/dist/entity-schema.d.ts +1 -1
  124. package/dist/explicit-capture.d.ts +6 -6
  125. package/dist/explicit-capture.js +2 -2
  126. package/dist/extraction-faithfulness.d.ts +1 -1
  127. package/dist/extraction-judge-telemetry.d.ts +1 -1
  128. package/dist/extraction-judge-training.d.ts +1 -1
  129. package/dist/extraction-judge.d.ts +1 -1
  130. package/dist/extraction.d.ts +1 -1
  131. package/dist/extraction.js +5 -5
  132. package/dist/fallback-llm.d.ts +1 -1
  133. package/dist/{first-start-migration-4I3VDSYS.js → first-start-migration-DY6YCRC2.js} +2 -2
  134. package/dist/{forget-WYLR4ZFV.js → forget-OEE5OELK.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 +1284 -1284
  144. package/dist/index.js +102 -102
  145. package/dist/intent.d.ts +1 -1
  146. package/dist/lcm/engine.d.ts +1 -1
  147. package/dist/lcm/engine.js +2 -2
  148. package/dist/lcm/index.d.ts +1 -1
  149. package/dist/lcm/index.js +5 -5
  150. package/dist/lcm/tools.d.ts +1 -1
  151. package/dist/lifecycle.d.ts +1 -1
  152. package/dist/live-connectors-runner.d.ts +1 -1
  153. package/dist/local-llm.d.ts +1 -1
  154. package/dist/local-llm.js +2 -2
  155. package/dist/local-model-endpoint.d.ts +1 -1
  156. package/dist/maintenance/memory-governance.d.ts +1 -1
  157. package/dist/maintenance/memory-governance.js +8 -8
  158. package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +8 -8
  159. package/dist/maintenance/rebuild-memory-projection.js +9 -9
  160. package/dist/mcp-memory-inspector-app.d.ts +5 -5
  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 +14 -14
  170. package/dist/namespaces/principal.d.ts +1 -1
  171. package/dist/namespaces/search.d.ts +1 -1
  172. package/dist/namespaces/search.js +4 -4
  173. package/dist/namespaces/storage.d.ts +2 -2
  174. package/dist/namespaces/storage.js +10 -10
  175. package/dist/native-knowledge.d.ts +1 -1
  176. package/dist/operator-toolkit.d.ts +1 -1
  177. package/dist/operator-toolkit.js +20 -20
  178. package/dist/orchestration/compression-guideline-coordinator.d.ts +1 -1
  179. package/dist/orchestration/compression-guideline-coordinator.js +2 -2
  180. package/dist/orchestration/maintenance.d.ts +2 -2
  181. package/dist/orchestration/maintenance.js +14 -14
  182. package/dist/{orchestrator-BhxMxtQJ.d.ts → orchestrator-D7ZGOQLX.d.ts} +77 -77
  183. package/dist/orchestrator.d.ts +4 -4
  184. package/dist/orchestrator.js +72 -72
  185. package/dist/patterns-cli.d.ts +1 -1
  186. package/dist/policy-runtime.d.ts +1 -1
  187. package/dist/provenance.d.ts +1 -1
  188. package/dist/qmd-recall-cache.d.ts +1 -1
  189. package/dist/qmd.d.ts +1 -1
  190. package/dist/recall-disclosure-escalation.d.ts +1 -1
  191. package/dist/recall-explain-renderer.d.ts +1 -1
  192. package/dist/recall-planner-llm.d.ts +1 -1
  193. package/dist/recall-state.d.ts +1 -1
  194. package/dist/recall-tag-filter.d.ts +1 -1
  195. package/dist/recall-xray-cli.d.ts +1 -1
  196. package/dist/recall-xray-renderer.d.ts +1 -1
  197. package/dist/recall-xray.d.ts +1 -1
  198. package/dist/resolve-auth-token.d.ts +1 -1
  199. package/dist/resume-bundles.js +2 -2
  200. package/dist/retrieval-agents.d.ts +1 -1
  201. package/dist/retrieval-tiers.d.ts +1 -1
  202. package/dist/routing/engine.d.ts +1 -1
  203. package/dist/routing/store.d.ts +1 -1
  204. package/dist/routing/store.js +2 -2
  205. package/dist/schemas.d.ts +122 -122
  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 +3 -3
  210. package/dist/search/index.d.ts +1 -1
  211. package/dist/search/index.js +3 -3
  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-BrsoFeMP.d.ts → semantic-consolidation-7Sndms2M.d.ts} +1 -1
  219. package/dist/semantic-consolidation.d.ts +2 -2
  220. package/dist/semantic-consolidation.js +11 -11
  221. package/dist/semantic-rule-promotion.js +8 -8
  222. package/dist/semantic-rule-verifier.d.ts +1 -1
  223. package/dist/semantic-rule-verifier.js +8 -8
  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 +9 -9
  227. package/dist/shared-context/manager.js +2 -2
  228. package/dist/signal.d.ts +1 -1
  229. package/dist/storage.d.ts +1 -1
  230. package/dist/storage.js +7 -7
  231. package/dist/summarizer.d.ts +1 -1
  232. package/dist/summarizer.js +3 -3
  233. package/dist/summary-snapshot.d.ts +1 -1
  234. package/dist/temporal-supersession.d.ts +1 -1
  235. package/dist/temporal-validity.d.ts +1 -1
  236. package/dist/threading.d.ts +1 -1
  237. package/dist/tier-migration.d.ts +1 -1
  238. package/dist/tier-routing.d.ts +1 -1
  239. package/dist/{tier-stats-5XF4UBRQ.js → tier-stats-TG6GUZ6N.js} +4 -4
  240. package/dist/topics.d.ts +1 -1
  241. package/dist/transcript.d.ts +1 -1
  242. package/dist/transfer/autodetect.js +1 -1
  243. package/dist/transfer/backup.js +1 -1
  244. package/dist/transfer/capsule-export.js +2 -2
  245. package/dist/transfer/types.d.ts +110 -110
  246. package/dist/trust-score-stage.d.ts +1 -1
  247. package/dist/trust-score.d.ts +1 -1
  248. package/dist/{types-BfI4uJeb.d.ts → types-DTEFxFuL.d.ts} +1 -1
  249. package/dist/types.d.ts +1 -1
  250. package/dist/utility-runtime.d.ts +1 -1
  251. package/dist/verified-recall.js +8 -8
  252. package/package.json +2 -2
  253. package/src/access-admin-ops-surface.ts +828 -0
  254. package/src/access-service.ts +41 -698
  255. package/dist/chunk-VX2RYM2K.js.map +0 -1
  256. /package/dist/{contradiction-scan-KO4WWCS4.js.map → access-admin-ops-surface.js.map} +0 -0
  257. /package/dist/{chunk-J2JB6BHT.js.map → chunk-243P7YYV.js.map} +0 -0
  258. /package/dist/{chunk-YGNQG4Q6.js.map → chunk-34THARMH.js.map} +0 -0
  259. /package/dist/{chunk-UFNQKZV7.js.map → chunk-3HGZX26P.js.map} +0 -0
  260. /package/dist/{chunk-2U4E34Y3.js.map → chunk-3ZIKDH6C.js.map} +0 -0
  261. /package/dist/{chunk-5JAT4ZJD.js.map → chunk-4DLFJJOQ.js.map} +0 -0
  262. /package/dist/{chunk-BIAMJUUJ.js.map → chunk-5QANTTY2.js.map} +0 -0
  263. /package/dist/{chunk-JBPKEARU.js.map → chunk-AU7Q3LSC.js.map} +0 -0
  264. /package/dist/{chunk-L3VSTJ2V.js.map → chunk-AXBRVBT6.js.map} +0 -0
  265. /package/dist/{chunk-V4ZPLQLC.js.map → chunk-BWOEYBRB.js.map} +0 -0
  266. /package/dist/{chunk-2DPCAW2T.js.map → chunk-C3IHRWIC.js.map} +0 -0
  267. /package/dist/{chunk-MW7UUXTA.js.map → chunk-DBSMLRTO.js.map} +0 -0
  268. /package/dist/{chunk-OVMLS7TN.js.map → chunk-DKIZ4BUQ.js.map} +0 -0
  269. /package/dist/{chunk-RBYV3WSB.js.map → chunk-DS4QM6I7.js.map} +0 -0
  270. /package/dist/{chunk-IBPEVGP5.js.map → chunk-E3MRYDUQ.js.map} +0 -0
  271. /package/dist/{chunk-MTN2G4DT.js.map → chunk-E6LENGYV.js.map} +0 -0
  272. /package/dist/{chunk-K5CWCJKJ.js.map → chunk-EEO4YWQ7.js.map} +0 -0
  273. /package/dist/{chunk-KFNG72W7.js.map → chunk-GWGWBK5Y.js.map} +0 -0
  274. /package/dist/{chunk-5DXUE7GB.js.map → chunk-HAZVVOYT.js.map} +0 -0
  275. /package/dist/{chunk-R7TGDLV3.js.map → chunk-HM6UJPPO.js.map} +0 -0
  276. /package/dist/{chunk-C4LNKQ3M.js.map → chunk-ITLJATQI.js.map} +0 -0
  277. /package/dist/{chunk-MEPWWSTD.js.map → chunk-JES2O5Q6.js.map} +0 -0
  278. /package/dist/{chunk-SC5AEZLU.js.map → chunk-JGPURIEH.js.map} +0 -0
  279. /package/dist/{chunk-33NX5BLR.js.map → chunk-JRZV3767.js.map} +0 -0
  280. /package/dist/{chunk-IQWFWSCP.js.map → chunk-JZ7P26GF.js.map} +0 -0
  281. /package/dist/{chunk-XKAOT4ZB.js.map → chunk-K5LLP4CY.js.map} +0 -0
  282. /package/dist/{chunk-JNKSFIAY.js.map → chunk-KY4WOZ3P.js.map} +0 -0
  283. /package/dist/{chunk-6ROCH5JV.js.map → chunk-KYHGLDFU.js.map} +0 -0
  284. /package/dist/{chunk-RRRZ3CLN.js.map → chunk-LOPZ2DWR.js.map} +0 -0
  285. /package/dist/{chunk-MLDAD27I.js.map → chunk-LZ73Y56P.js.map} +0 -0
  286. /package/dist/{chunk-FEELYTRT.js.map → chunk-N3VE7OCY.js.map} +0 -0
  287. /package/dist/{chunk-OKOF7ITI.js.map → chunk-OSMBC3JU.js.map} +0 -0
  288. /package/dist/{chunk-FLVL4L3L.js.map → chunk-OUXPVWTZ.js.map} +0 -0
  289. /package/dist/{chunk-QMMCMV2L.js.map → chunk-OZMBT7N3.js.map} +0 -0
  290. /package/dist/{chunk-VQL22SHO.js.map → chunk-PN5AMCK2.js.map} +0 -0
  291. /package/dist/{chunk-GFGYHLON.js.map → chunk-QIRZI3C3.js.map} +0 -0
  292. /package/dist/{chunk-QRM3K3XT.js.map → chunk-RNWWAS5V.js.map} +0 -0
  293. /package/dist/{chunk-DC5OBZS3.js.map → chunk-TVISHYL5.js.map} +0 -0
  294. /package/dist/{chunk-S5UYWK3O.js.map → chunk-VVSV2QVY.js.map} +0 -0
  295. /package/dist/{chunk-GECEETQ3.js.map → chunk-W3M34XT4.js.map} +0 -0
  296. /package/dist/{chunk-FXRFFYWD.js.map → chunk-WIWPSQYU.js.map} +0 -0
  297. /package/dist/{chunk-KT2VQLP7.js.map → chunk-XOPLMSVV.js.map} +0 -0
  298. /package/dist/{chunk-JHZ3LEM7.js.map → chunk-YNBEHUZH.js.map} +0 -0
  299. /package/dist/{chunk-67JRXV6Z.js.map → chunk-ZIFPFKB2.js.map} +0 -0
  300. /package/dist/{chunk-ZGGI3COG.js.map → chunk-ZMHDSIEX.js.map} +0 -0
  301. /package/dist/{first-start-migration-4I3VDSYS.js.map → first-start-migration-DY6YCRC2.js.map} +0 -0
  302. /package/dist/{forget-WYLR4ZFV.js.map → forget-OEE5OELK.js.map} +0 -0
  303. /package/dist/{tier-stats-5XF4UBRQ.js.map → tier-stats-TG6GUZ6N.js.map} +0 -0
@@ -56,10 +56,10 @@ import {
56
56
  resolveScopeProfilePlan,
57
57
  resolveWritableNamespaceValue,
58
58
  sanitizeFragment
59
- } from "./chunk-GECEETQ3.js";
59
+ } from "./chunk-W3M34XT4.js";
60
60
  import {
61
61
  namespaceCollectionName
62
- } from "./chunk-5DXUE7GB.js";
62
+ } from "./chunk-HAZVVOYT.js";
63
63
  import {
64
64
  namespaceIdentityFromToken
65
65
  } from "./chunk-ZFXCQPNO.js";
@@ -70,7 +70,7 @@ import {
70
70
  listMemoryGovernanceRuns,
71
71
  readMemoryGovernanceRunArtifact,
72
72
  runMemoryGovernance
73
- } from "./chunk-JHZ3LEM7.js";
73
+ } from "./chunk-YNBEHUZH.js";
74
74
  import {
75
75
  recordMemoryOutcome
76
76
  } from "./chunk-EIR5VLIH.js";
@@ -91,7 +91,7 @@ import {
91
91
  persistExplicitCapture,
92
92
  queueExplicitCaptureForReview,
93
93
  validateExplicitCaptureInput
94
- } from "./chunk-XKAOT4ZB.js";
94
+ } from "./chunk-K5LLP4CY.js";
95
95
  import {
96
96
  CrossNamespaceBudget
97
97
  } from "./chunk-ODPLEWB6.js";
@@ -102,29 +102,57 @@ import {
102
102
  filterTrajectoriesByLookbackDays,
103
103
  readCausalTrajectoryRecords
104
104
  } from "./chunk-V5UV7BOA.js";
105
+ import {
106
+ canReadNamespace,
107
+ canWriteNamespace,
108
+ defaultNamespaceForPrincipal,
109
+ recallNamespacesForPrincipal,
110
+ resolvePrincipal
111
+ } from "./chunk-PE6XR4GG.js";
112
+ import {
113
+ resolveAccessSetupCapabilities,
114
+ resolveCompressionCapabilities,
115
+ resolveConsolidationCapabilities,
116
+ resolveGraphConstructionCapabilities,
117
+ resolveIdentityContinuityCapabilities,
118
+ resolveIndexingCapabilities,
119
+ resolveMemoryLifecycleCapabilities,
120
+ resolveNamespaceCapabilities,
121
+ resolveObjectiveStateCapabilities,
122
+ resolveQmdCapabilities,
123
+ resolveRecallAuxiliaryCapabilities,
124
+ resolveRecallEnhancementCapabilities,
125
+ resolveSecurityCapabilities
126
+ } from "./chunk-VSF7AAGE.js";
105
127
  import {
106
128
  FileCalendarSource,
107
129
  buildBriefing,
108
130
  enqueuePassiveCorrectionNotification,
109
131
  parseBriefingFocus,
110
132
  parseBriefingWindow
111
- } from "./chunk-MTN2G4DT.js";
133
+ } from "./chunk-E6LENGYV.js";
112
134
  import {
113
135
  parseEntityFile
114
- } from "./chunk-YGNQG4Q6.js";
136
+ } from "./chunk-34THARMH.js";
137
+ import {
138
+ supersessionKeysForFact
139
+ } from "./chunk-TKZ3AL5V.js";
115
140
  import {
116
141
  stripAttributesSuffix
117
142
  } from "./chunk-SVOZFLIQ.js";
118
143
  import {
119
144
  serializeMutations
120
145
  } from "./chunk-LTJAMRGI.js";
121
- import {
122
- supersessionKeysForFact
123
- } from "./chunk-TKZ3AL5V.js";
124
146
  import {
125
147
  DEFAULT_RECALL_DISCLOSURE,
126
148
  isRecallDisclosure
127
149
  } from "./chunk-JS2HKKOK.js";
150
+ import {
151
+ getMemoryProjectionPath
152
+ } from "./chunk-MB5RSUW6.js";
153
+ import {
154
+ displayErrorDetail
155
+ } from "./chunk-6KYMPV2O.js";
128
156
  import {
129
157
  inferMemoryStatus,
130
158
  toMemoryPathRel
@@ -133,12 +161,6 @@ import {
133
161
  normalizeProjectionPreview,
134
162
  normalizeProjectionTags
135
163
  } from "./chunk-SCU65EZI.js";
136
- import {
137
- getMemoryProjectionPath
138
- } from "./chunk-MB5RSUW6.js";
139
- import {
140
- displayErrorDetail
141
- } from "./chunk-6KYMPV2O.js";
142
164
  import {
143
165
  createVersion
144
166
  } from "./chunk-VF4XKTX3.js";
@@ -151,12 +173,15 @@ import {
151
173
  import {
152
174
  expandTildePath
153
175
  } from "./chunk-EYIEWJNI.js";
176
+ import {
177
+ isHandleToken
178
+ } from "./chunk-JAKIDQB2.js";
154
179
  import {
155
180
  log
156
181
  } from "./chunk-NU3CSQ4H.js";
157
182
  import {
158
183
  exportCapsule
159
- } from "./chunk-FLVL4L3L.js";
184
+ } from "./chunk-OUXPVWTZ.js";
160
185
  import {
161
186
  OFFLINE_SYNC_SNAPSHOT_FORMAT,
162
187
  applyOfflineSyncChangeset,
@@ -174,31 +199,6 @@ import {
174
199
  import {
175
200
  evaluateActionConfidence
176
201
  } from "./chunk-Z2YFLXHU.js";
177
- import {
178
- canReadNamespace,
179
- canWriteNamespace,
180
- defaultNamespaceForPrincipal,
181
- recallNamespacesForPrincipal,
182
- resolvePrincipal
183
- } from "./chunk-PE6XR4GG.js";
184
- import {
185
- resolveAccessSetupCapabilities,
186
- resolveCompressionCapabilities,
187
- resolveConsolidationCapabilities,
188
- resolveGraphConstructionCapabilities,
189
- resolveIdentityContinuityCapabilities,
190
- resolveIndexingCapabilities,
191
- resolveMemoryLifecycleCapabilities,
192
- resolveNamespaceCapabilities,
193
- resolveObjectiveStateCapabilities,
194
- resolveQmdCapabilities,
195
- resolveRecallAuxiliaryCapabilities,
196
- resolveRecallEnhancementCapabilities,
197
- resolveSecurityCapabilities
198
- } from "./chunk-VSF7AAGE.js";
199
- import {
200
- isHandleToken
201
- } from "./chunk-JAKIDQB2.js";
202
202
  import {
203
203
  AccessAuditAdapter
204
204
  } from "./chunk-TVVEYCNW.js";
@@ -209,11 +209,11 @@ import {
209
209
 
210
210
  // src/access-recall-surface.ts
211
211
  import { createHash as createHash5 } from "crypto";
212
- import * as nodePath2 from "path";
212
+ import * as nodePath3 from "path";
213
213
 
214
214
  // src/access-service.ts
215
215
  import { stat as stat2 } from "fs/promises";
216
- import * as nodeFs from "fs/promises";
216
+ import * as nodeFs2 from "fs/promises";
217
217
  import { constants as fsConstants } from "fs";
218
218
  import { readdirSync, unlinkSync } from "fs";
219
219
  import { createHash as createHash4 } from "crypto";
@@ -1193,12 +1193,12 @@ async function findArchitectureCardMemory(storage) {
1193
1193
  });
1194
1194
  return cards[0] ?? null;
1195
1195
  }
1196
- function createArchitectureVersioningHook(enabled, maxVersionsPerPage, sidecarDir, memoryDir, readFile5, writeVersion) {
1196
+ function createArchitectureVersioningHook(enabled, maxVersionsPerPage, sidecarDir, memoryDir, readFile6, writeVersion) {
1197
1197
  return {
1198
1198
  async snapshotIfExists(memory) {
1199
1199
  if (!enabled) return;
1200
1200
  try {
1201
- const fullContent = await readFile5(memory.path);
1201
+ const fullContent = await readFile6(memory.path);
1202
1202
  await writeVersion(
1203
1203
  memory.path,
1204
1204
  fullContent,
@@ -4055,7 +4055,7 @@ function isErrnoCode(error, code) {
4055
4055
  return typeof error === "object" && error !== null && "code" in error && error.code === code;
4056
4056
  }
4057
4057
  function sleep(ms) {
4058
- return new Promise((resolve3) => setTimeout(resolve3, ms));
4058
+ return new Promise((resolve4) => setTimeout(resolve4, ms));
4059
4059
  }
4060
4060
  async function acquireClusterWriteLock(memoryDir, clusterHash) {
4061
4061
  const lockRoot = path6.join(path6.resolve(memoryDir), "state", "procedure-miner-locks");
@@ -4094,8 +4094,8 @@ async function withClusterWriteLock(memoryDir, clusterHash, fn) {
4094
4094
  const previous = inProcessClusterWriteLocks.get(inProcessKey) ?? Promise.resolve();
4095
4095
  let releaseInProcess;
4096
4096
  const current = previous.catch(() => void 0).then(
4097
- () => new Promise((resolve3) => {
4098
- releaseInProcess = resolve3;
4097
+ () => new Promise((resolve4) => {
4098
+ releaseInProcess = resolve4;
4099
4099
  })
4100
4100
  );
4101
4101
  inProcessClusterWriteLocks.set(inProcessKey, current);
@@ -4750,78 +4750,662 @@ async function promoteMemory(options) {
4750
4750
  }
4751
4751
 
4752
4752
  // src/access-service.ts
4753
- import * as nodePath from "path";
4754
-
4755
- // src/orchestration/self-deps.ts
4756
- function selfDeps(self) {
4757
- const source = self;
4758
- return new Proxy(/* @__PURE__ */ Object.create(null), {
4759
- get(_target, prop) {
4760
- const value = source[prop];
4761
- return typeof value === "function" ? value.bind(self) : value;
4762
- },
4763
- set(_target, prop, value) {
4764
- if (!(prop in source)) return false;
4765
- source[prop] = value;
4766
- return true;
4767
- },
4768
- has(_target, prop) {
4769
- return prop in source;
4770
- }
4771
- });
4772
- }
4753
+ import * as nodePath2 from "path";
4773
4754
 
4774
- // src/access-service.ts
4775
- var EngramAccessInputError = class extends Error {
4776
- };
4777
- var cachedPackageVersion = null;
4778
- async function getPackageVersion() {
4779
- if (cachedPackageVersion !== null) return cachedPackageVersion;
4780
- try {
4781
- const raw = await nodeFs.readFile(new URL("../package.json", import.meta.url), "utf-8");
4782
- const parsed = JSON.parse(raw);
4783
- cachedPackageVersion = typeof parsed.version === "string" && parsed.version.length > 0 ? parsed.version : "unknown";
4784
- } catch {
4785
- cachedPackageVersion = "unknown";
4755
+ // src/access-admin-ops-surface.ts
4756
+ import * as nodeFs from "fs/promises";
4757
+ import * as nodePath from "path";
4758
+ var AccessAdminOpsSurface = class {
4759
+ constructor(deps) {
4760
+ this.deps = deps;
4786
4761
  }
4787
- return cachedPackageVersion;
4788
- }
4789
- function normalizeTrustZoneInputError(error) {
4790
- const message = error instanceof Error ? error.message : null;
4791
- if (!message) {
4792
- return null;
4762
+ deps;
4763
+ async reviewQueue(runId, namespace, principal) {
4764
+ const resolvedNamespace = this.deps.resolveReadableNamespace(namespace, principal);
4765
+ const storage = await this.deps.orchestrator.getStorage(resolvedNamespace);
4766
+ const projected = await storage.getProjectedGovernanceRecord();
4767
+ if (projected && (!runId || projected.runId === runId.trim())) {
4768
+ const projectedAppliedActions = projected.appliedActionRows.map((row) => ({
4769
+ action: row.action,
4770
+ memoryId: row.memoryId,
4771
+ reasonCode: row.reasonCode,
4772
+ beforeStatus: row.beforeStatus,
4773
+ afterStatus: row.afterStatus,
4774
+ originalPath: row.originalPath,
4775
+ currentPath: row.currentPath
4776
+ }));
4777
+ const projectedProposedActions = await buildProjectedGovernanceProposedActions(storage, projected);
4778
+ const projectedArtifact = await (async () => {
4779
+ try {
4780
+ return await readMemoryGovernanceRunArtifact(storage.dir, projected.runId);
4781
+ } catch {
4782
+ return null;
4783
+ }
4784
+ })();
4785
+ const metrics = projected.metrics;
4786
+ const fallbackTransitionReport = {
4787
+ proposed: groupActionsByStatus(projectedProposedActions),
4788
+ applied: groupActionsByStatus(projectedAppliedActions)
4789
+ };
4790
+ const transitionReport = projectedArtifact?.transitionReport ? {
4791
+ proposed: hasGroupedGovernanceActions(projectedArtifact.transitionReport.proposed) || projectedProposedActions.length === 0 ? projectedArtifact.transitionReport.proposed : fallbackTransitionReport.proposed,
4792
+ applied: hasGroupedGovernanceActions(projectedArtifact.transitionReport.applied) || projectedAppliedActions.length === 0 ? projectedArtifact.transitionReport.applied : fallbackTransitionReport.applied
4793
+ } : fallbackTransitionReport;
4794
+ const qualityScore = projectedArtifact?.qualityScore ?? metrics?.qualityScore ?? buildQualityScore(metrics?.reviewReasons ?? {
4795
+ exact_duplicate: 0,
4796
+ semantic_duplicate_candidate: 0,
4797
+ disputed_memory: 0,
4798
+ speculative_low_confidence: 0,
4799
+ archive_candidate: 0,
4800
+ explicit_capture_review: 0,
4801
+ malformed_import: 0
4802
+ });
4803
+ const effectiveMetrics = metrics ? { ...metrics, qualityScore: metrics.qualityScore ?? qualityScore } : metrics;
4804
+ return {
4805
+ found: true,
4806
+ namespace: resolvedNamespace,
4807
+ runId: projected.runId,
4808
+ summary: projected.summary,
4809
+ metrics: effectiveMetrics,
4810
+ qualityScore,
4811
+ reviewQueue: projected.reviewQueueRows.map((row) => ({
4812
+ entryId: row.entryId,
4813
+ memoryId: row.memoryId,
4814
+ path: row.path,
4815
+ reasonCode: row.reasonCode,
4816
+ severity: row.severity,
4817
+ suggestedAction: row.suggestedAction,
4818
+ suggestedStatus: row.suggestedStatus,
4819
+ relatedMemoryIds: row.relatedMemoryIds
4820
+ })),
4821
+ appliedActions: projectedAppliedActions,
4822
+ transitionReport,
4823
+ report: projected.report
4824
+ };
4825
+ }
4826
+ const resolvedRunId = runId?.trim() || (await listMemoryGovernanceRuns(storage.dir))[0];
4827
+ if (!resolvedRunId) return { found: false, namespace: resolvedNamespace };
4828
+ const artifact = await readMemoryGovernanceRunArtifact(storage.dir, resolvedRunId);
4829
+ return {
4830
+ found: true,
4831
+ namespace: resolvedNamespace,
4832
+ runId: resolvedRunId,
4833
+ summary: artifact.summary,
4834
+ metrics: artifact.metrics,
4835
+ qualityScore: artifact.qualityScore,
4836
+ reviewQueue: artifact.reviewQueue,
4837
+ appliedActions: artifact.appliedActions,
4838
+ transitionReport: artifact.transitionReport,
4839
+ report: artifact.report
4840
+ };
4793
4841
  }
4794
- if (/^sourceRecordId must /.test(message) || /^promotionReason must /.test(message) || /^recordedAt must /.test(message) || /^trust zone promotion requires /.test(message) || /^source trust-zone record not found: /.test(message) || /^trust-zone promotion denied: /.test(message) || /^trust zone demo seed requires /.test(message) || /^unsupported trust-zone demo scenario: /.test(message)) {
4795
- return new EngramAccessInputError(message);
4842
+ async governanceRun(request, principal) {
4843
+ const deepSleep = this.deps.orchestrator.config.dreamsPhases.deepSleep;
4844
+ if (deepSleep.enabled === false && deepSleep.enabledExplicitlySet === true) {
4845
+ throw new Error("memory governance is disabled by dreams.phases.deepSleep.enabled=false");
4846
+ }
4847
+ const resolvedNamespace = this.deps.writableNamespaceFor(
4848
+ request.namespace,
4849
+ void 0,
4850
+ request.authenticatedPrincipal ?? principal
4851
+ );
4852
+ const storage = await this.deps.orchestrator.getStorage(resolvedNamespace);
4853
+ const mode = request.mode === "apply" ? "apply" : "shadow";
4854
+ const boundedBatchSize = typeof request.batchSize === "number" && Number.isFinite(request.batchSize) ? Math.max(1, Math.floor(request.batchSize)) : void 0;
4855
+ const result = await runMemoryGovernance({
4856
+ memoryDir: storage.dir,
4857
+ mode,
4858
+ recentDays: typeof request.recentDays === "number" && Number.isFinite(request.recentDays) ? Math.max(1, Math.floor(request.recentDays)) : void 0,
4859
+ maxMemories: typeof request.maxMemories === "number" && Number.isFinite(request.maxMemories) ? Math.max(1, Math.floor(request.maxMemories)) : void 0,
4860
+ batchSize: boundedBatchSize
4861
+ });
4862
+ if (mode === "apply") {
4863
+ try {
4864
+ await this.deps.orchestrator.processEntitySynthesisQueue(
4865
+ resolvedNamespace,
4866
+ Math.min(boundedBatchSize ?? 5, 5)
4867
+ );
4868
+ } catch (error) {
4869
+ log.debug(`governanceRun: entity synthesis refresh failed after governance apply: ${error}`);
4870
+ }
4871
+ }
4872
+ return {
4873
+ namespace: resolvedNamespace,
4874
+ runId: result.runId,
4875
+ traceId: result.traceId,
4876
+ mode: result.mode,
4877
+ reviewQueueCount: result.reviewQueue.length,
4878
+ proposedActionCount: result.proposedActions.length,
4879
+ appliedActionCount: result.appliedActions.length,
4880
+ summaryPath: result.summaryPath,
4881
+ reportPath: result.reportPath
4882
+ };
4796
4883
  }
4797
- return null;
4798
- }
4799
- var ENGRAM_ACCESS_WRITE_SCHEMA_VERSION = 1;
4800
- async function buildProjectedGovernanceProposedActions(storage, projected) {
4801
- const reviewQueue = projected.reviewQueueRows.map((row) => ({
4802
- entryId: row.entryId,
4803
- memoryId: row.memoryId,
4804
- path: row.path,
4805
- reasonCode: row.reasonCode,
4806
- severity: row.severity,
4807
- suggestedAction: row.suggestedAction,
4808
- suggestedStatus: row.suggestedStatus,
4809
- relatedMemoryIds: row.relatedMemoryIds
4810
- }));
4811
- const memories = (await Promise.all(projected.reviewQueueRows.map((row) => storage.getMemoryById(row.memoryId)))).filter((memory) => Boolean(memory));
4812
- return buildProposedActions(reviewQueue, memories);
4813
- }
4814
- function hasGroupedGovernanceActions(grouped) {
4815
- if (!grouped) return false;
4816
- return Object.values(grouped).some((actions) => Array.isArray(actions) && actions.length > 0);
4817
- }
4818
- function normalizePagination(limit, offset) {
4819
- const normalizedLimit = Number.isFinite(limit) ? Math.max(1, Math.min(200, Math.floor(limit ?? 50))) : 50;
4820
- const normalizedOffset = Number.isFinite(offset) ? Math.max(0, Math.floor(offset ?? 0)) : 0;
4821
- return { limit: normalizedLimit, offset: normalizedOffset };
4822
- }
4823
- function normalizeBrowseSort(sort) {
4824
- switch (sort) {
4884
+ async conversationIndexUpdate(request = {}) {
4885
+ if (!resolveIndexingCapabilities(this.deps.orchestrator.config).conversationIndex) {
4886
+ return {
4887
+ enabled: false,
4888
+ sessions: 0,
4889
+ chunks: 0,
4890
+ skipped: 0,
4891
+ skippedSessionKeys: [],
4892
+ embeddedRuns: 0,
4893
+ reason: "disabled"
4894
+ };
4895
+ }
4896
+ const hours = typeof request.hours === "number" && Number.isFinite(request.hours) ? Math.max(1, Math.floor(request.hours)) : 24;
4897
+ let sessionKey;
4898
+ if (request.sessionKey !== void 0) {
4899
+ if (typeof request.sessionKey !== "string" || request.sessionKey.trim().length === 0) {
4900
+ throw new EngramAccessInputError("sessionKey must be a non-empty string when provided");
4901
+ }
4902
+ sessionKey = request.sessionKey.trim();
4903
+ }
4904
+ if (sessionKey) {
4905
+ const result = await this.deps.orchestrator.updateConversationIndex(
4906
+ sessionKey,
4907
+ hours,
4908
+ { embed: request.embed }
4909
+ );
4910
+ return {
4911
+ enabled: true,
4912
+ sessionKey,
4913
+ sessions: 1,
4914
+ chunks: result.chunks,
4915
+ skipped: result.skipped ? 1 : 0,
4916
+ skippedSessionKeys: result.skipped ? [sessionKey] : [],
4917
+ embeddedRuns: result.embedded ? 1 : 0,
4918
+ reason: result.reason,
4919
+ retryAfterMs: result.retryAfterMs
4920
+ };
4921
+ }
4922
+ const sessionKeys = await this.deps.orchestrator.transcript.listSessionKeys();
4923
+ let chunks = 0;
4924
+ let skipped = 0;
4925
+ const skippedSessionKeys = [];
4926
+ let embeddedRuns = 0;
4927
+ for (const sessionKey2 of sessionKeys) {
4928
+ const result = await this.deps.orchestrator.updateConversationIndex(
4929
+ sessionKey2,
4930
+ hours,
4931
+ { embed: request.embed }
4932
+ );
4933
+ chunks += result.chunks;
4934
+ if (result.skipped) {
4935
+ skipped += 1;
4936
+ skippedSessionKeys.push(sessionKey2);
4937
+ }
4938
+ if (result.embedded) {
4939
+ embeddedRuns += 1;
4940
+ }
4941
+ }
4942
+ return {
4943
+ enabled: true,
4944
+ sessions: sessionKeys.length,
4945
+ chunks,
4946
+ skipped,
4947
+ skippedSessionKeys,
4948
+ embeddedRuns
4949
+ };
4950
+ }
4951
+ async profilingReport(request = {}) {
4952
+ const profiler = this.deps.orchestrator.profiler;
4953
+ if (!profiler.isEnabled) {
4954
+ return {
4955
+ enabled: false,
4956
+ reason: "disabled",
4957
+ message: "Profiling is disabled. Set profilingEnabled: true in your plugin config to enable."
4958
+ };
4959
+ }
4960
+ const format = request.format ?? "ascii";
4961
+ if (format !== "ascii" && format !== "json") {
4962
+ throw new EngramAccessInputError("format must be one of: ascii, json");
4963
+ }
4964
+ const limit = request.limit ?? 5;
4965
+ if (!Number.isInteger(limit) || limit < 1 || limit > 20) {
4966
+ throw new EngramAccessInputError("limit must be an integer between 1 and 20");
4967
+ }
4968
+ const traces = profiler.getRecentTraces(limit);
4969
+ const stats = profiler.getStats();
4970
+ const bottleneck = profiler.identifyBottleneck();
4971
+ if (format === "json") {
4972
+ return {
4973
+ enabled: true,
4974
+ format,
4975
+ traces,
4976
+ stats,
4977
+ bottleneck
4978
+ };
4979
+ }
4980
+ const lines = [];
4981
+ lines.push("Engram Profiling Report");
4982
+ lines.push("=".repeat(60));
4983
+ lines.push("");
4984
+ const allBuckets = [
4985
+ ["byKind", stats.byKind],
4986
+ ["bySpan", stats.bySpan]
4987
+ ];
4988
+ const hasStats = allBuckets.some(([, entries]) => Object.keys(entries).length > 0);
4989
+ if (hasStats) {
4990
+ lines.push("Aggregate Stats (all retained traces):");
4991
+ for (const [bucket, entries] of allBuckets) {
4992
+ for (const [key, summary] of Object.entries(entries)) {
4993
+ lines.push(
4994
+ ` ${bucket}/${key}: avg=${summary.avgMs}ms p50=${summary.p50Ms}ms p95=${summary.p95Ms}ms max=${summary.maxMs}ms (n=${summary.count})`
4995
+ );
4996
+ }
4997
+ }
4998
+ lines.push("");
4999
+ }
5000
+ if (bottleneck) {
5001
+ lines.push(`Bottleneck: ${bottleneck}`);
5002
+ lines.push("");
5003
+ }
5004
+ if (traces.length === 0) {
5005
+ lines.push("No traces recorded yet. Trigger a recall or extraction to see timing data.");
5006
+ } else {
5007
+ for (const trace of traces) {
5008
+ lines.push(formatProfileTraceAscii(trace));
5009
+ lines.push("");
5010
+ }
5011
+ }
5012
+ return {
5013
+ enabled: true,
5014
+ format,
5015
+ report: lines.join("\n")
5016
+ };
5017
+ }
5018
+ /**
5019
+ * Read-only graph snapshot for the admin pane (issue #691 PR 2/5).
5020
+ *
5021
+ * Reads adjacency from the JSONL edge store written by `GraphIndex` and
5022
+ * resolves node metadata via the namespaced storage manager. Namespace
5023
+ * resolution mirrors the read-side path used by `recall` /
5024
+ * `procedureStats`, so multi-principal deployments can't leak edges from
5025
+ * a peer namespace (CLAUDE.md rule 42).
5026
+ */
5027
+ async graphSnapshot(request, authenticatedPrincipal) {
5028
+ const namespace = this.deps.resolveReadableNamespace(
5029
+ request.namespace,
5030
+ authenticatedPrincipal
5031
+ );
5032
+ const storage = await this.deps.orchestrator.getStorage(namespace);
5033
+ const cfg = this.deps.orchestrator.config;
5034
+ const graphCaps = resolveGraphConstructionCapabilities(cfg);
5035
+ let namespaceRootReal;
5036
+ try {
5037
+ namespaceRootReal = await nodeFs.realpath(storage.dir);
5038
+ } catch {
5039
+ namespaceRootReal = nodePath.resolve(storage.dir);
5040
+ }
5041
+ const namespaceRootWithSep = namespaceRootReal.endsWith(nodePath.sep) ? namespaceRootReal : namespaceRootReal + nodePath.sep;
5042
+ const loadNode = async (relPath) => {
5043
+ if (nodePath.isAbsolute(relPath)) {
5044
+ log.warn(
5045
+ `graphSnapshot: rejected absolute edge endpoint (len=${relPath.length}) outside namespace root`
5046
+ );
5047
+ return null;
5048
+ }
5049
+ const candidate = nodePath.resolve(namespaceRootReal, relPath);
5050
+ if (candidate !== namespaceRootReal && !candidate.startsWith(namespaceRootWithSep)) {
5051
+ log.warn(
5052
+ `graphSnapshot: rejected traversing edge endpoint (len=${relPath.length}) outside namespace root`
5053
+ );
5054
+ return null;
5055
+ }
5056
+ let canonical;
5057
+ try {
5058
+ canonical = await nodeFs.realpath(candidate);
5059
+ } catch {
5060
+ canonical = candidate;
5061
+ }
5062
+ if (canonical !== namespaceRootReal && !canonical.startsWith(namespaceRootWithSep)) {
5063
+ log.warn(
5064
+ `graphSnapshot: rejected symlinked edge endpoint (len=${relPath.length}) that resolved outside namespace root`
5065
+ );
5066
+ return null;
5067
+ }
5068
+ const memory = await storage.readMemoryByPath(canonical);
5069
+ if (!memory) return null;
5070
+ const fm = memory.frontmatter;
5071
+ return {
5072
+ category: fm.category ?? "unknown",
5073
+ label: fm.id ?? nodePath.basename(canonical, nodePath.extname(canonical)),
5074
+ updated: fm.updated
5075
+ };
5076
+ };
5077
+ return buildGraphSnapshot({
5078
+ memoryDir: namespaceRootReal,
5079
+ graphConfig: {
5080
+ entityGraph: graphCaps.entityGraph,
5081
+ timeGraph: graphCaps.timeGraph,
5082
+ causalGraph: graphCaps.causalGraph
5083
+ },
5084
+ request: {
5085
+ limit: request.limit,
5086
+ since: request.since,
5087
+ focusNodeId: request.focusNodeId,
5088
+ categories: request.categories
5089
+ },
5090
+ loadNode
5091
+ });
5092
+ }
5093
+ /**
5094
+ * List capsule archives in the namespace-scoped capsule store.
5095
+ *
5096
+ * MCP uses this access-layer method instead of reading arbitrary paths so
5097
+ * capsule discovery remains bound to the same namespace ACLs as export and
5098
+ * import.
5099
+ */
5100
+ async capsuleList(options) {
5101
+ const resolvedNamespace = this.deps.resolveReadableNamespace(options?.namespace, options?.principal);
5102
+ const storage = await this.deps.orchestrator.getStorage(resolvedNamespace);
5103
+ const capsulesDir = defaultCapsulesDir(storage.dir);
5104
+ let dirEntries;
5105
+ try {
5106
+ const capsulesDirStat = await nodeFs.lstat(capsulesDir);
5107
+ if (capsulesDirStat.isSymbolicLink()) {
5108
+ throw new EngramAccessInputError("capsule list failed: capsule store directory must not be a symlink");
5109
+ }
5110
+ if (!capsulesDirStat.isDirectory()) {
5111
+ throw new EngramAccessInputError("capsule list failed: capsule store path must be a directory");
5112
+ }
5113
+ dirEntries = await nodeFs.readdir(capsulesDir, { withFileTypes: true });
5114
+ } catch (err) {
5115
+ const code = typeof err === "object" && err !== null && "code" in err ? err.code : void 0;
5116
+ if (code === "ENOENT") {
5117
+ return { namespace: resolvedNamespace, capsulesDir, capsules: [] };
5118
+ }
5119
+ throw err;
5120
+ }
5121
+ const archiveNames = dirEntries.filter(
5122
+ (entry) => entry.isFile() && (entry.name.endsWith(".capsule.json.gz") || entry.name.endsWith(".capsule.json.gz.enc"))
5123
+ ).map((entry) => entry.name).sort();
5124
+ const capsules = [];
5125
+ for (const archiveName of archiveNames) {
5126
+ const archivePath = nodePath.join(capsulesDir, archiveName);
5127
+ const id = archiveName.replace(/\.capsule\.json\.gz\.enc$/, "").replace(/\.capsule\.json\.gz$/, "");
5128
+ const manifestPath = nodePath.join(capsulesDir, `${id}.manifest.json`);
5129
+ let createdAt = null;
5130
+ let pluginVersion = null;
5131
+ let fileCount = null;
5132
+ let description = null;
5133
+ let manifestPathOrNull = manifestPath;
5134
+ try {
5135
+ const manifestStat = await nodeFs.lstat(manifestPath);
5136
+ if (manifestStat.isSymbolicLink() || !manifestStat.isFile()) {
5137
+ capsules.push({
5138
+ id,
5139
+ archivePath,
5140
+ manifestPath: manifestPathOrNull,
5141
+ createdAt,
5142
+ pluginVersion,
5143
+ fileCount,
5144
+ description
5145
+ });
5146
+ continue;
5147
+ }
5148
+ const raw = await nodeFs.readFile(manifestPath, "utf-8");
5149
+ const sidecar = JSON.parse(raw);
5150
+ createdAt = typeof sidecar.createdAt === "string" ? sidecar.createdAt : null;
5151
+ pluginVersion = typeof sidecar.pluginVersion === "string" ? sidecar.pluginVersion : null;
5152
+ fileCount = Array.isArray(sidecar.files) ? sidecar.files.length : null;
5153
+ const capsule = sidecar.capsule;
5154
+ description = capsule && typeof capsule.description === "string" ? capsule.description : null;
5155
+ } catch (err) {
5156
+ const code = typeof err === "object" && err !== null && "code" in err ? err.code : void 0;
5157
+ if (code === "ENOENT") {
5158
+ manifestPathOrNull = null;
5159
+ }
5160
+ }
5161
+ capsules.push({
5162
+ id,
5163
+ archivePath,
5164
+ manifestPath: manifestPathOrNull,
5165
+ createdAt,
5166
+ pluginVersion,
5167
+ fileCount,
5168
+ description
5169
+ });
5170
+ }
5171
+ return { namespace: resolvedNamespace, capsulesDir, capsules };
5172
+ }
5173
+ /**
5174
+ * Manually invoke a single Dreams phase pass (PR 4/4).
5175
+ *
5176
+ * Deep-sleep delegates to memory governance (shadow → dry-run, apply → live).
5177
+ * Light-sleep and REM scan the observation ledger and memory corpus
5178
+ * respectively, returning the same telemetry shape as a scheduled run.
5179
+ */
5180
+ async dreamsRun(options) {
5181
+ const { runDreamsPhase } = await import("./dreams-ledger-6UODQOX6.js");
5182
+ const validPhases = ["lightSleep", "rem", "deepSleep"];
5183
+ if (!validPhases.includes(options.phase)) {
5184
+ throw new EngramAccessInputError(
5185
+ `Invalid phase: ${String(options.phase)}. Must be one of: ${validPhases.join(", ")}`
5186
+ );
5187
+ }
5188
+ const deepSleep = this.deps.orchestrator.config.dreamsPhases.deepSleep;
5189
+ if (options.phase === "deepSleep" && deepSleep.enabled === false && deepSleep.enabledExplicitlySet === true) {
5190
+ throw new EngramAccessInputError(
5191
+ "memory governance is disabled by dreams.phases.deepSleep.enabled=false"
5192
+ );
5193
+ }
5194
+ const dryRun = options.dryRun === true;
5195
+ const resolvedNamespace = this.deps.writableNamespaceFor(
5196
+ options.namespace,
5197
+ void 0,
5198
+ options.authenticatedPrincipal
5199
+ );
5200
+ const storage = await this.deps.orchestrator.getStorage(resolvedNamespace);
5201
+ const memoryDir = storage.dir;
5202
+ const phaseRunner = dryRun || options.phase === "deepSleep" ? void 0 : async (_opts) => {
5203
+ if (_opts.phase === "lightSleep") {
5204
+ const result3 = await this.deps.orchestrator.runLifecyclePolicyNow(storage);
5205
+ return {
5206
+ itemsProcessed: result3.memoriesAssessed,
5207
+ notes: `scored ${result3.memoriesAssessed} memories`
5208
+ };
5209
+ }
5210
+ const result2 = await this.deps.orchestrator.runSemanticConsolidationNow({
5211
+ dryRun: false,
5212
+ storage
5213
+ });
5214
+ const itemsProcessed = result2.clusters.reduce(
5215
+ (sum, cluster) => sum + cluster.memories.length,
5216
+ 0
5217
+ );
5218
+ return {
5219
+ itemsProcessed,
5220
+ notes: `REM consolidation found ${result2.clustersFound} clusters`
5221
+ };
5222
+ };
5223
+ const governanceRunner = options.phase === "deepSleep" ? async (_opts) => {
5224
+ return this.deps.orchestrator.runDeepSleepGovernanceNow({
5225
+ storage,
5226
+ dryRun: _opts.dryRun
5227
+ });
5228
+ } : void 0;
5229
+ const result = await runDreamsPhase(
5230
+ { memoryDir, phase: options.phase, dryRun },
5231
+ governanceRunner,
5232
+ phaseRunner
5233
+ );
5234
+ return {
5235
+ phase: result.phase,
5236
+ dryRun: result.dryRun,
5237
+ durationMs: result.durationMs,
5238
+ itemsProcessed: result.itemsProcessed,
5239
+ notes: result.notes
5240
+ };
5241
+ }
5242
+ /**
5243
+ * Manually promote a memory into one or more authorized targets. Requires
5244
+ * a non-empty reason (audit-logged). Reuses the scope-profile promotion
5245
+ * resolution and `canWriteNamespace` gate — there is no dashboard-only
5246
+ * write path.
5247
+ */
5248
+ async adminPromoteMemory(request) {
5249
+ const config = this.deps.orchestrator.config;
5250
+ const namespacesEnabled = resolveNamespaceCapabilities(config).namespaces === true;
5251
+ let sourceNamespace;
5252
+ if (request.namespace) {
5253
+ sourceNamespace = this.deps.resolveReadableNamespace(
5254
+ request.namespace,
5255
+ request.principal
5256
+ );
5257
+ } else {
5258
+ const codingContext2 = request.sessionKey ? this.deps.orchestrator.getCodingContextForSession(request.sessionKey) ?? null : null;
5259
+ const plan = resolveScopePlan({
5260
+ config,
5261
+ sessionKey: request.sessionKey,
5262
+ principalOverride: request.principal,
5263
+ codingContext: codingContext2,
5264
+ namespacesEnabled
5265
+ });
5266
+ sourceNamespace = this.deps.resolveReadableNamespace(
5267
+ plan.baseNamespace,
5268
+ request.principal
5269
+ );
5270
+ }
5271
+ const codingContext = request.sessionKey ? this.deps.orchestrator.getCodingContextForSession(request.sessionKey) ?? null : null;
5272
+ const codingOverlay = codingContext ? resolveCodingNamespaceOverlay(
5273
+ codingContext,
5274
+ config.codingMode,
5275
+ config.defaultNamespace
5276
+ ) : null;
5277
+ const scopeProfilePlan = resolveScopeProfilePlan({
5278
+ config,
5279
+ principal: request.principal,
5280
+ codingContext,
5281
+ codingOverlay
5282
+ });
5283
+ const storage = {
5284
+ readMemory: async (namespace, memoryId) => {
5285
+ const resolved = await this.deps.orchestrator.getStorage(namespace);
5286
+ const memory = await resolved.getMemoryById(memoryId);
5287
+ if (!memory) return null;
5288
+ return {
5289
+ category: memory.frontmatter.category,
5290
+ content: memory.content,
5291
+ frontmatter: memory.frontmatter
5292
+ };
5293
+ },
5294
+ writePromotedMemory: async (namespace, memory) => {
5295
+ const resolved = await this.deps.orchestrator.getStorage(namespace);
5296
+ const { id, tombstoneBlocked } = await resolved.writeMemory(
5297
+ memory.category,
5298
+ memory.content,
5299
+ {
5300
+ confidence: memory.confidence,
5301
+ tags: memory.tags,
5302
+ entityRef: memory.entityRef,
5303
+ source: `admin-promotion:${memory.sourceNamespace}:${memory.reason.slice(0, 120)}`,
5304
+ lineage: memory.lineage,
5305
+ sourceMemoryId: memory.sourceMemoryId,
5306
+ actor: memory.actor,
5307
+ validAt: memory.validAt
5308
+ }
5309
+ );
5310
+ if (tombstoneBlocked) {
5311
+ throw new Error(
5312
+ "target namespace tombstone-blocked the promoted content (pending_review)"
5313
+ );
5314
+ }
5315
+ return id;
5316
+ }
5317
+ };
5318
+ try {
5319
+ return await promoteMemory({
5320
+ config,
5321
+ sourceMemoryId: request.sourceMemoryId,
5322
+ sourceNamespace,
5323
+ principal: request.principal,
5324
+ targets: request.targets,
5325
+ reason: request.reason,
5326
+ actor: request.principal ?? "admin-console",
5327
+ storage,
5328
+ scopeProfilePlan
5329
+ });
5330
+ } catch (err) {
5331
+ if (err instanceof AdminPromotionError) {
5332
+ throw new EngramAccessInputError(err.message);
5333
+ }
5334
+ throw err;
5335
+ }
5336
+ }
5337
+ };
5338
+
5339
+ // src/orchestration/self-deps.ts
5340
+ function selfDeps(self) {
5341
+ const source = self;
5342
+ return new Proxy(/* @__PURE__ */ Object.create(null), {
5343
+ get(_target, prop) {
5344
+ const value = source[prop];
5345
+ return typeof value === "function" ? value.bind(self) : value;
5346
+ },
5347
+ set(_target, prop, value) {
5348
+ if (!(prop in source)) return false;
5349
+ source[prop] = value;
5350
+ return true;
5351
+ },
5352
+ has(_target, prop) {
5353
+ return prop in source;
5354
+ }
5355
+ });
5356
+ }
5357
+
5358
+ // src/access-service.ts
5359
+ var EngramAccessInputError = class extends Error {
5360
+ };
5361
+ var cachedPackageVersion = null;
5362
+ async function getPackageVersion() {
5363
+ if (cachedPackageVersion !== null) return cachedPackageVersion;
5364
+ try {
5365
+ const raw = await nodeFs2.readFile(new URL("../package.json", import.meta.url), "utf-8");
5366
+ const parsed = JSON.parse(raw);
5367
+ cachedPackageVersion = typeof parsed.version === "string" && parsed.version.length > 0 ? parsed.version : "unknown";
5368
+ } catch {
5369
+ cachedPackageVersion = "unknown";
5370
+ }
5371
+ return cachedPackageVersion;
5372
+ }
5373
+ function normalizeTrustZoneInputError(error) {
5374
+ const message = error instanceof Error ? error.message : null;
5375
+ if (!message) {
5376
+ return null;
5377
+ }
5378
+ if (/^sourceRecordId must /.test(message) || /^promotionReason must /.test(message) || /^recordedAt must /.test(message) || /^trust zone promotion requires /.test(message) || /^source trust-zone record not found: /.test(message) || /^trust-zone promotion denied: /.test(message) || /^trust zone demo seed requires /.test(message) || /^unsupported trust-zone demo scenario: /.test(message)) {
5379
+ return new EngramAccessInputError(message);
5380
+ }
5381
+ return null;
5382
+ }
5383
+ var ENGRAM_ACCESS_WRITE_SCHEMA_VERSION = 1;
5384
+ async function buildProjectedGovernanceProposedActions(storage, projected) {
5385
+ const reviewQueue = projected.reviewQueueRows.map((row) => ({
5386
+ entryId: row.entryId,
5387
+ memoryId: row.memoryId,
5388
+ path: row.path,
5389
+ reasonCode: row.reasonCode,
5390
+ severity: row.severity,
5391
+ suggestedAction: row.suggestedAction,
5392
+ suggestedStatus: row.suggestedStatus,
5393
+ relatedMemoryIds: row.relatedMemoryIds
5394
+ }));
5395
+ const memories = (await Promise.all(projected.reviewQueueRows.map((row) => storage.getMemoryById(row.memoryId)))).filter((memory) => Boolean(memory));
5396
+ return buildProposedActions(reviewQueue, memories);
5397
+ }
5398
+ function hasGroupedGovernanceActions(grouped) {
5399
+ if (!grouped) return false;
5400
+ return Object.values(grouped).some((actions) => Array.isArray(actions) && actions.length > 0);
5401
+ }
5402
+ function normalizePagination(limit, offset) {
5403
+ const normalizedLimit = Number.isFinite(limit) ? Math.max(1, Math.min(200, Math.floor(limit ?? 50))) : 50;
5404
+ const normalizedOffset = Number.isFinite(offset) ? Math.max(0, Math.floor(offset ?? 0)) : 0;
5405
+ return { limit: normalizedLimit, offset: normalizedOffset };
5406
+ }
5407
+ function normalizeBrowseSort(sort) {
5408
+ switch (sort) {
4825
5409
  case "updated_asc":
4826
5410
  case "created_desc":
4827
5411
  case "created_asc":
@@ -4954,6 +5538,16 @@ var EngramAccessService = class {
4954
5538
  budgetLocks = /* @__PURE__ */ new Map();
4955
5539
  budget;
4956
5540
  auditAdapter;
5541
+ /** AccessAdminOpsSurface (access-service decomposition). Lazy; selfDeps live wiring. */
5542
+ _accessAdminOpsSurface;
5543
+ get accessAdminOpsSurface() {
5544
+ if (!this._accessAdminOpsSurface) {
5545
+ this._accessAdminOpsSurface = new AccessAdminOpsSurface(
5546
+ selfDeps(this)
5547
+ );
5548
+ }
5549
+ return this._accessAdminOpsSurface;
5550
+ }
4957
5551
  /** AccessRecallSurface (access-service decomposition). Lazy; selfDeps live wiring. */
4958
5552
  _accessRecallSurface;
4959
5553
  get accessRecallSurface() {
@@ -5464,9 +6058,9 @@ var EngramAccessService = class {
5464
6058
  );
5465
6059
  }
5466
6060
  async storageForAbsoluteRecallPath(memoryPath, primaryNamespace, recallNamespaces = []) {
5467
- const resolvedPath = nodePath.resolve(memoryPath);
5468
- const memoryRoot = nodePath.resolve(this.orchestrator.config.memoryDir);
5469
- const namespacesRoot = nodePath.join(memoryRoot, "namespaces");
6061
+ const resolvedPath = nodePath2.resolve(memoryPath);
6062
+ const memoryRoot = nodePath2.resolve(this.orchestrator.config.memoryDir);
6063
+ const namespacesRoot = nodePath2.join(memoryRoot, "namespaces");
5470
6064
  const configuredNamespaces = /* @__PURE__ */ new Set();
5471
6065
  configuredNamespaces.add(primaryNamespace);
5472
6066
  for (const namespace of recallNamespaces) {
@@ -5475,7 +6069,7 @@ var EngramAccessService = class {
5475
6069
  configuredNamespaces.add(this.orchestrator.config.defaultNamespace);
5476
6070
  configuredNamespaces.add(this.orchestrator.config.sharedNamespace);
5477
6071
  if (isPathInsideStorageRoot(namespacesRoot, resolvedPath)) {
5478
- const relativeToNamespaces = nodePath.relative(namespacesRoot, resolvedPath);
6072
+ const relativeToNamespaces = nodePath2.relative(namespacesRoot, resolvedPath);
5479
6073
  const [namespaceSegment] = relativeToNamespaces.split(/[\\/]/);
5480
6074
  if (namespaceSegment) {
5481
6075
  configuredNamespaces.add(
@@ -5495,7 +6089,7 @@ var EngramAccessService = class {
5495
6089
  } catch {
5496
6090
  continue;
5497
6091
  }
5498
- const candidateRoot = nodePath.resolve(candidateStorage.dir);
6092
+ const candidateRoot = nodePath2.resolve(candidateStorage.dir);
5499
6093
  if (!isPathInsideStorageRoot(candidateRoot, resolvedPath)) continue;
5500
6094
  if (candidateRoot === memoryRoot && isPathInsideStorageRoot(namespacesRoot, resolvedPath)) {
5501
6095
  continue;
@@ -5595,8 +6189,8 @@ var EngramAccessService = class {
5595
6189
  async withIdempotencyLock(key, fn) {
5596
6190
  const previous = this.idempotencyLocks.get(key) ?? Promise.resolve();
5597
6191
  let release;
5598
- const current = new Promise((resolve3) => {
5599
- release = resolve3;
6192
+ const current = new Promise((resolve4) => {
6193
+ release = resolve4;
5600
6194
  });
5601
6195
  const queued = previous.then(() => current, () => current);
5602
6196
  this.idempotencyLocks.set(key, queued);
@@ -5615,8 +6209,8 @@ var EngramAccessService = class {
5615
6209
  const key = principal || "__anonymous__";
5616
6210
  const previous = this.budgetLocks.get(key) ?? Promise.resolve();
5617
6211
  let release;
5618
- const current = new Promise((resolve3) => {
5619
- release = resolve3;
6212
+ const current = new Promise((resolve4) => {
6213
+ release = resolve4;
5620
6214
  });
5621
6215
  const queued = previous.then(() => current, () => current);
5622
6216
  this.budgetLocks.set(key, queued);
@@ -5806,14 +6400,14 @@ var EngramAccessService = class {
5806
6400
  const timer = setTimeout(() => controller.abort(), 2e3);
5807
6401
  timer.unref?.();
5808
6402
  try {
5809
- return await new Promise((resolve3) => {
6403
+ return await new Promise((resolve4) => {
5810
6404
  const onAbort = () => {
5811
6405
  controller.signal.removeEventListener("abort", onAbort);
5812
- resolve3(false);
6406
+ resolve4(false);
5813
6407
  };
5814
6408
  controller.signal.addEventListener("abort", onAbort, { once: true });
5815
6409
  const probe = typeof qmd.checkAvailability === "function" ? qmd.checkAvailability({ signal: controller.signal }) : qmd.probe();
5816
- probe.then(resolve3, () => resolve3(false)).finally(() => {
6410
+ probe.then(resolve4, () => resolve4(false)).finally(() => {
5817
6411
  controller.signal.removeEventListener("abort", onAbort);
5818
6412
  });
5819
6413
  });
@@ -6460,7 +7054,7 @@ var EngramAccessService = class {
6460
7054
  resolvedConfig.versioningMaxPerPage,
6461
7055
  resolvedConfig.versioningSidecarDir,
6462
7056
  resolvedConfig.memoryDir,
6463
- (p) => nodeFs.readFile(p, "utf-8"),
7057
+ (p) => nodeFs2.readFile(p, "utf-8"),
6464
7058
  createVersion
6465
7059
  ),
6466
7060
  throwInputError: (msg) => {
@@ -6723,83 +7317,11 @@ var EngramAccessService = class {
6723
7317
  };
6724
7318
  }
6725
7319
  async reviewQueue(runId, namespace, principal) {
6726
- const resolvedNamespace = this.resolveReadableNamespace(namespace, principal);
6727
- const storage = await this.orchestrator.getStorage(resolvedNamespace);
6728
- const projected = await storage.getProjectedGovernanceRecord();
6729
- if (projected && (!runId || projected.runId === runId.trim())) {
6730
- const projectedAppliedActions = projected.appliedActionRows.map((row) => ({
6731
- action: row.action,
6732
- memoryId: row.memoryId,
6733
- reasonCode: row.reasonCode,
6734
- beforeStatus: row.beforeStatus,
6735
- afterStatus: row.afterStatus,
6736
- originalPath: row.originalPath,
6737
- currentPath: row.currentPath
6738
- }));
6739
- const projectedProposedActions = await buildProjectedGovernanceProposedActions(storage, projected);
6740
- const projectedArtifact = await (async () => {
6741
- try {
6742
- return await readMemoryGovernanceRunArtifact(storage.dir, projected.runId);
6743
- } catch {
6744
- return null;
6745
- }
6746
- })();
6747
- const metrics = projected.metrics;
6748
- const fallbackTransitionReport = {
6749
- proposed: groupActionsByStatus(projectedProposedActions),
6750
- applied: groupActionsByStatus(projectedAppliedActions)
6751
- };
6752
- const transitionReport = projectedArtifact?.transitionReport ? {
6753
- proposed: hasGroupedGovernanceActions(projectedArtifact.transitionReport.proposed) || projectedProposedActions.length === 0 ? projectedArtifact.transitionReport.proposed : fallbackTransitionReport.proposed,
6754
- applied: hasGroupedGovernanceActions(projectedArtifact.transitionReport.applied) || projectedAppliedActions.length === 0 ? projectedArtifact.transitionReport.applied : fallbackTransitionReport.applied
6755
- } : fallbackTransitionReport;
6756
- const qualityScore = projectedArtifact?.qualityScore ?? metrics?.qualityScore ?? buildQualityScore(metrics?.reviewReasons ?? {
6757
- exact_duplicate: 0,
6758
- semantic_duplicate_candidate: 0,
6759
- disputed_memory: 0,
6760
- speculative_low_confidence: 0,
6761
- archive_candidate: 0,
6762
- explicit_capture_review: 0,
6763
- malformed_import: 0
6764
- });
6765
- const effectiveMetrics = metrics ? { ...metrics, qualityScore: metrics.qualityScore ?? qualityScore } : metrics;
6766
- return {
6767
- found: true,
6768
- namespace: resolvedNamespace,
6769
- runId: projected.runId,
6770
- summary: projected.summary,
6771
- metrics: effectiveMetrics,
6772
- qualityScore,
6773
- reviewQueue: projected.reviewQueueRows.map((row) => ({
6774
- entryId: row.entryId,
6775
- memoryId: row.memoryId,
6776
- path: row.path,
6777
- reasonCode: row.reasonCode,
6778
- severity: row.severity,
6779
- suggestedAction: row.suggestedAction,
6780
- suggestedStatus: row.suggestedStatus,
6781
- relatedMemoryIds: row.relatedMemoryIds
6782
- })),
6783
- appliedActions: projectedAppliedActions,
6784
- transitionReport,
6785
- report: projected.report
6786
- };
6787
- }
6788
- const resolvedRunId = runId?.trim() || (await listMemoryGovernanceRuns(storage.dir))[0];
6789
- if (!resolvedRunId) return { found: false, namespace: resolvedNamespace };
6790
- const artifact = await readMemoryGovernanceRunArtifact(storage.dir, resolvedRunId);
6791
- return {
6792
- found: true,
6793
- namespace: resolvedNamespace,
6794
- runId: resolvedRunId,
6795
- summary: artifact.summary,
6796
- metrics: artifact.metrics,
6797
- qualityScore: artifact.qualityScore,
6798
- reviewQueue: artifact.reviewQueue,
6799
- appliedActions: artifact.appliedActions,
6800
- transitionReport: artifact.transitionReport,
6801
- report: artifact.report
6802
- };
7320
+ return this.accessAdminOpsSurface.reviewQueue(
7321
+ runId,
7322
+ namespace,
7323
+ principal
7324
+ );
6803
7325
  }
6804
7326
  async maintenance(namespace, principal) {
6805
7327
  const resolvedNamespace = this.resolveReadableNamespace(namespace, principal);
@@ -6828,76 +7350,40 @@ var EngramAccessService = class {
6828
7350
  incrementCount(statusCounts, status);
6829
7351
  incrementCount(categoryCounts, memory.frontmatter.category);
6830
7352
  incrementCount(confidenceTierCounts, confidenceTier);
6831
- incrementCount(ageBucketCounts, ageBucket);
6832
- if (status === "active") {
6833
- if (ageBucket === "91_plus_days") staleActive += 1;
6834
- if ((memory.frontmatter.confidence ?? 0) < 0.6) lowConfidenceActive += 1;
6835
- }
6836
- }
6837
- return {
6838
- namespace: resolvedNamespace,
6839
- totalMemories: memories.length,
6840
- statusCounts,
6841
- categoryCounts,
6842
- confidenceTierCounts,
6843
- ageBucketCounts,
6844
- archivePressure: {
6845
- pendingReview: statusCounts.pending_review ?? 0,
6846
- quarantined: statusCounts.quarantined ?? 0,
6847
- archived: statusCounts.archived ?? 0,
6848
- staleActive,
6849
- lowConfidenceActive
6850
- },
6851
- latestGovernanceRun: {
6852
- found: governance.found,
6853
- runId: governance.runId,
6854
- qualityScore: governance.qualityScore ?? governance.metrics?.qualityScore,
6855
- reviewQueueCount: governance.reviewQueue?.length ?? 0
6856
- }
6857
- };
6858
- }
6859
- async governanceRun(request, principal) {
6860
- const deepSleep = this.orchestrator.config.dreamsPhases.deepSleep;
6861
- if (deepSleep.enabled === false && deepSleep.enabledExplicitlySet === true) {
6862
- throw new Error("memory governance is disabled by dreams.phases.deepSleep.enabled=false");
6863
- }
6864
- const resolvedNamespace = this.writableNamespaceFor(
6865
- request.namespace,
6866
- void 0,
6867
- request.authenticatedPrincipal ?? principal
6868
- );
6869
- const storage = await this.orchestrator.getStorage(resolvedNamespace);
6870
- const mode = request.mode === "apply" ? "apply" : "shadow";
6871
- const boundedBatchSize = typeof request.batchSize === "number" && Number.isFinite(request.batchSize) ? Math.max(1, Math.floor(request.batchSize)) : void 0;
6872
- const result = await runMemoryGovernance({
6873
- memoryDir: storage.dir,
6874
- mode,
6875
- recentDays: typeof request.recentDays === "number" && Number.isFinite(request.recentDays) ? Math.max(1, Math.floor(request.recentDays)) : void 0,
6876
- maxMemories: typeof request.maxMemories === "number" && Number.isFinite(request.maxMemories) ? Math.max(1, Math.floor(request.maxMemories)) : void 0,
6877
- batchSize: boundedBatchSize
6878
- });
6879
- if (mode === "apply") {
6880
- try {
6881
- await this.orchestrator.processEntitySynthesisQueue(
6882
- resolvedNamespace,
6883
- Math.min(boundedBatchSize ?? 5, 5)
6884
- );
6885
- } catch (error) {
6886
- log.debug(`governanceRun: entity synthesis refresh failed after governance apply: ${error}`);
7353
+ incrementCount(ageBucketCounts, ageBucket);
7354
+ if (status === "active") {
7355
+ if (ageBucket === "91_plus_days") staleActive += 1;
7356
+ if ((memory.frontmatter.confidence ?? 0) < 0.6) lowConfidenceActive += 1;
6887
7357
  }
6888
7358
  }
6889
7359
  return {
6890
7360
  namespace: resolvedNamespace,
6891
- runId: result.runId,
6892
- traceId: result.traceId,
6893
- mode: result.mode,
6894
- reviewQueueCount: result.reviewQueue.length,
6895
- proposedActionCount: result.proposedActions.length,
6896
- appliedActionCount: result.appliedActions.length,
6897
- summaryPath: result.summaryPath,
6898
- reportPath: result.reportPath
7361
+ totalMemories: memories.length,
7362
+ statusCounts,
7363
+ categoryCounts,
7364
+ confidenceTierCounts,
7365
+ ageBucketCounts,
7366
+ archivePressure: {
7367
+ pendingReview: statusCounts.pending_review ?? 0,
7368
+ quarantined: statusCounts.quarantined ?? 0,
7369
+ archived: statusCounts.archived ?? 0,
7370
+ staleActive,
7371
+ lowConfidenceActive
7372
+ },
7373
+ latestGovernanceRun: {
7374
+ found: governance.found,
7375
+ runId: governance.runId,
7376
+ qualityScore: governance.qualityScore ?? governance.metrics?.qualityScore,
7377
+ reviewQueueCount: governance.reviewQueue?.length ?? 0
7378
+ }
6899
7379
  };
6900
7380
  }
7381
+ async governanceRun(request, principal) {
7382
+ return this.accessAdminOpsSurface.governanceRun(
7383
+ request,
7384
+ principal
7385
+ );
7386
+ }
6901
7387
  async procedureMiningRun(request, principal) {
6902
7388
  const resolvedNamespace = this.writableNamespaceFor(
6903
7389
  request.namespace,
@@ -7002,138 +7488,14 @@ var EngramAccessService = class {
7002
7488
  };
7003
7489
  }
7004
7490
  async conversationIndexUpdate(request = {}) {
7005
- if (!resolveIndexingCapabilities(this.orchestrator.config).conversationIndex) {
7006
- return {
7007
- enabled: false,
7008
- sessions: 0,
7009
- chunks: 0,
7010
- skipped: 0,
7011
- skippedSessionKeys: [],
7012
- embeddedRuns: 0,
7013
- reason: "disabled"
7014
- };
7015
- }
7016
- const hours = typeof request.hours === "number" && Number.isFinite(request.hours) ? Math.max(1, Math.floor(request.hours)) : 24;
7017
- let sessionKey;
7018
- if (request.sessionKey !== void 0) {
7019
- if (typeof request.sessionKey !== "string" || request.sessionKey.trim().length === 0) {
7020
- throw new EngramAccessInputError("sessionKey must be a non-empty string when provided");
7021
- }
7022
- sessionKey = request.sessionKey.trim();
7023
- }
7024
- if (sessionKey) {
7025
- const result = await this.orchestrator.updateConversationIndex(
7026
- sessionKey,
7027
- hours,
7028
- { embed: request.embed }
7029
- );
7030
- return {
7031
- enabled: true,
7032
- sessionKey,
7033
- sessions: 1,
7034
- chunks: result.chunks,
7035
- skipped: result.skipped ? 1 : 0,
7036
- skippedSessionKeys: result.skipped ? [sessionKey] : [],
7037
- embeddedRuns: result.embedded ? 1 : 0,
7038
- reason: result.reason,
7039
- retryAfterMs: result.retryAfterMs
7040
- };
7041
- }
7042
- const sessionKeys = await this.orchestrator.transcript.listSessionKeys();
7043
- let chunks = 0;
7044
- let skipped = 0;
7045
- const skippedSessionKeys = [];
7046
- let embeddedRuns = 0;
7047
- for (const sessionKey2 of sessionKeys) {
7048
- const result = await this.orchestrator.updateConversationIndex(
7049
- sessionKey2,
7050
- hours,
7051
- { embed: request.embed }
7052
- );
7053
- chunks += result.chunks;
7054
- if (result.skipped) {
7055
- skipped += 1;
7056
- skippedSessionKeys.push(sessionKey2);
7057
- }
7058
- if (result.embedded) {
7059
- embeddedRuns += 1;
7060
- }
7061
- }
7062
- return {
7063
- enabled: true,
7064
- sessions: sessionKeys.length,
7065
- chunks,
7066
- skipped,
7067
- skippedSessionKeys,
7068
- embeddedRuns
7069
- };
7491
+ return this.accessAdminOpsSurface.conversationIndexUpdate(
7492
+ request
7493
+ );
7070
7494
  }
7071
7495
  async profilingReport(request = {}) {
7072
- const profiler = this.orchestrator.profiler;
7073
- if (!profiler.isEnabled) {
7074
- return {
7075
- enabled: false,
7076
- reason: "disabled",
7077
- message: "Profiling is disabled. Set profilingEnabled: true in your plugin config to enable."
7078
- };
7079
- }
7080
- const format = request.format ?? "ascii";
7081
- if (format !== "ascii" && format !== "json") {
7082
- throw new EngramAccessInputError("format must be one of: ascii, json");
7083
- }
7084
- const limit = request.limit ?? 5;
7085
- if (!Number.isInteger(limit) || limit < 1 || limit > 20) {
7086
- throw new EngramAccessInputError("limit must be an integer between 1 and 20");
7087
- }
7088
- const traces = profiler.getRecentTraces(limit);
7089
- const stats = profiler.getStats();
7090
- const bottleneck = profiler.identifyBottleneck();
7091
- if (format === "json") {
7092
- return {
7093
- enabled: true,
7094
- format,
7095
- traces,
7096
- stats,
7097
- bottleneck
7098
- };
7099
- }
7100
- const lines = [];
7101
- lines.push("Engram Profiling Report");
7102
- lines.push("=".repeat(60));
7103
- lines.push("");
7104
- const allBuckets = [
7105
- ["byKind", stats.byKind],
7106
- ["bySpan", stats.bySpan]
7107
- ];
7108
- const hasStats = allBuckets.some(([, entries]) => Object.keys(entries).length > 0);
7109
- if (hasStats) {
7110
- lines.push("Aggregate Stats (all retained traces):");
7111
- for (const [bucket, entries] of allBuckets) {
7112
- for (const [key, summary] of Object.entries(entries)) {
7113
- lines.push(
7114
- ` ${bucket}/${key}: avg=${summary.avgMs}ms p50=${summary.p50Ms}ms p95=${summary.p95Ms}ms max=${summary.maxMs}ms (n=${summary.count})`
7115
- );
7116
- }
7117
- }
7118
- lines.push("");
7119
- }
7120
- if (bottleneck) {
7121
- lines.push(`Bottleneck: ${bottleneck}`);
7122
- lines.push("");
7123
- }
7124
- if (traces.length === 0) {
7125
- lines.push("No traces recorded yet. Trigger a recall or extraction to see timing data.");
7126
- } else {
7127
- for (const trace of traces) {
7128
- lines.push(formatProfileTraceAscii(trace));
7129
- lines.push("");
7130
- }
7131
- }
7132
- return {
7133
- enabled: true,
7134
- format,
7135
- report: lines.join("\n")
7136
- };
7496
+ return this.accessAdminOpsSurface.profilingReport(
7497
+ request
7498
+ );
7137
7499
  }
7138
7500
  async trustZoneStatus(namespace, principal) {
7139
7501
  const resolvedNamespace = this.resolveReadableNamespace(namespace, principal);
@@ -8473,100 +8835,31 @@ ${next}`);
8473
8835
  const storage = await this.orchestrator.getStorage(resolvedNs);
8474
8836
  const questions = await storage.readQuestions();
8475
8837
  return {
8476
- questions: questions.map((q) => ({ id: q.id, question: q.question, resolved: q.resolved })),
8477
- count: questions.length
8478
- };
8479
- }
8480
- async lastRecallSnapshot(sessionKey) {
8481
- const snapshot = sessionKey ? this.orchestrator.lastRecall.get(sessionKey) : this.orchestrator.lastRecall.getMostRecent();
8482
- return snapshot ?? { message: "No recall snapshot available" };
8483
- }
8484
- async intentDebug(namespace) {
8485
- const snapshot = await this.orchestrator.getLastIntentSnapshot(namespace);
8486
- return snapshot ?? { message: "No intent debug snapshot available" };
8487
- }
8488
- async qmdDebug(namespace) {
8489
- const snapshot = await this.orchestrator.getLastQmdRecallSnapshot(namespace);
8490
- return snapshot ?? { message: "No QMD debug snapshot available" };
8491
- }
8492
- async graphExplainLastRecall(namespace) {
8493
- const explanation = await this.orchestrator.explainLastGraphRecall({ namespace });
8494
- return { explanation };
8495
- }
8496
- /**
8497
- * Read-only graph snapshot for the admin pane (issue #691 PR 2/5).
8498
- *
8499
- * Reads adjacency from the JSONL edge store written by `GraphIndex` and
8500
- * resolves node metadata via the namespaced storage manager. Namespace
8501
- * resolution mirrors the read-side path used by `recall` /
8502
- * `procedureStats`, so multi-principal deployments can't leak edges from
8503
- * a peer namespace (CLAUDE.md rule 42).
8504
- */
8505
- async graphSnapshot(request, authenticatedPrincipal) {
8506
- const namespace = this.resolveReadableNamespace(
8507
- request.namespace,
8508
- authenticatedPrincipal
8509
- );
8510
- const storage = await this.orchestrator.getStorage(namespace);
8511
- const cfg = this.orchestrator.config;
8512
- const graphCaps = resolveGraphConstructionCapabilities(cfg);
8513
- let namespaceRootReal;
8514
- try {
8515
- namespaceRootReal = await nodeFs.realpath(storage.dir);
8516
- } catch {
8517
- namespaceRootReal = nodePath.resolve(storage.dir);
8518
- }
8519
- const namespaceRootWithSep = namespaceRootReal.endsWith(nodePath.sep) ? namespaceRootReal : namespaceRootReal + nodePath.sep;
8520
- const loadNode = async (relPath) => {
8521
- if (nodePath.isAbsolute(relPath)) {
8522
- log.warn(
8523
- `graphSnapshot: rejected absolute edge endpoint (len=${relPath.length}) outside namespace root`
8524
- );
8525
- return null;
8526
- }
8527
- const candidate = nodePath.resolve(namespaceRootReal, relPath);
8528
- if (candidate !== namespaceRootReal && !candidate.startsWith(namespaceRootWithSep)) {
8529
- log.warn(
8530
- `graphSnapshot: rejected traversing edge endpoint (len=${relPath.length}) outside namespace root`
8531
- );
8532
- return null;
8533
- }
8534
- let canonical;
8535
- try {
8536
- canonical = await nodeFs.realpath(candidate);
8537
- } catch {
8538
- canonical = candidate;
8539
- }
8540
- if (canonical !== namespaceRootReal && !canonical.startsWith(namespaceRootWithSep)) {
8541
- log.warn(
8542
- `graphSnapshot: rejected symlinked edge endpoint (len=${relPath.length}) that resolved outside namespace root`
8543
- );
8544
- return null;
8545
- }
8546
- const memory = await storage.readMemoryByPath(canonical);
8547
- if (!memory) return null;
8548
- const fm = memory.frontmatter;
8549
- return {
8550
- category: fm.category ?? "unknown",
8551
- label: fm.id ?? nodePath.basename(canonical, nodePath.extname(canonical)),
8552
- updated: fm.updated
8553
- };
8554
- };
8555
- return buildGraphSnapshot({
8556
- memoryDir: namespaceRootReal,
8557
- graphConfig: {
8558
- entityGraph: graphCaps.entityGraph,
8559
- timeGraph: graphCaps.timeGraph,
8560
- causalGraph: graphCaps.causalGraph
8561
- },
8562
- request: {
8563
- limit: request.limit,
8564
- since: request.since,
8565
- focusNodeId: request.focusNodeId,
8566
- categories: request.categories
8567
- },
8568
- loadNode
8569
- });
8838
+ questions: questions.map((q) => ({ id: q.id, question: q.question, resolved: q.resolved })),
8839
+ count: questions.length
8840
+ };
8841
+ }
8842
+ async lastRecallSnapshot(sessionKey) {
8843
+ const snapshot = sessionKey ? this.orchestrator.lastRecall.get(sessionKey) : this.orchestrator.lastRecall.getMostRecent();
8844
+ return snapshot ?? { message: "No recall snapshot available" };
8845
+ }
8846
+ async intentDebug(namespace) {
8847
+ const snapshot = await this.orchestrator.getLastIntentSnapshot(namespace);
8848
+ return snapshot ?? { message: "No intent debug snapshot available" };
8849
+ }
8850
+ async qmdDebug(namespace) {
8851
+ const snapshot = await this.orchestrator.getLastQmdRecallSnapshot(namespace);
8852
+ return snapshot ?? { message: "No QMD debug snapshot available" };
8853
+ }
8854
+ async graphExplainLastRecall(namespace) {
8855
+ const explanation = await this.orchestrator.explainLastGraphRecall({ namespace });
8856
+ return { explanation };
8857
+ }
8858
+ async graphSnapshot(request, authenticatedPrincipal) {
8859
+ return this.accessAdminOpsSurface.graphSnapshot(
8860
+ request,
8861
+ authenticatedPrincipal
8862
+ );
8570
8863
  }
8571
8864
  async memoryFeedback(request) {
8572
8865
  if (!resolveRecallEnhancementCapabilities(this.orchestrator.config).feedback) {
@@ -8689,17 +8982,17 @@ ${next}`);
8689
8982
  const storage = await this.orchestrator.getStorage(resolvedNs);
8690
8983
  const storageDir = storage.dir;
8691
8984
  const { writeFile: writeFile4, mkdir: mkdir5 } = await import("fs/promises");
8692
- const { join: join3, resolve: resolve3 } = await import("path");
8985
+ const { join: join4, resolve: resolve4 } = await import("path");
8693
8986
  const safeKey = request.sessionKey.replace(/[^a-zA-Z0-9_-]/g, "_");
8694
8987
  if (!safeKey) throw new EngramAccessInputError("sessionKey is required");
8695
- const checkpointDir = join3(storageDir, "checkpoints", safeKey);
8696
- const resolved = resolve3(checkpointDir);
8697
- if (!resolved.startsWith(resolve3(storageDir))) {
8988
+ const checkpointDir = join4(storageDir, "checkpoints", safeKey);
8989
+ const resolved = resolve4(checkpointDir);
8990
+ if (!resolved.startsWith(resolve4(storageDir))) {
8698
8991
  throw new EngramAccessInputError("Invalid sessionKey");
8699
8992
  }
8700
8993
  await mkdir5(checkpointDir, { recursive: true });
8701
8994
  const ts = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
8702
- const filePath = join3(checkpointDir, `checkpoint-${ts}.md`);
8995
+ const filePath = join4(checkpointDir, `checkpoint-${ts}.md`);
8703
8996
  await writeFile4(filePath, request.context, "utf-8");
8704
8997
  return { saved: true };
8705
8998
  }
@@ -9030,7 +9323,7 @@ ${next}`);
9030
9323
  throw new EngramAccessInputError("capsule import failed: archivePath must point to a file");
9031
9324
  }
9032
9325
  try {
9033
- await nodeFs.access(archivePath, fsConstants.R_OK);
9326
+ await nodeFs2.access(archivePath, fsConstants.R_OK);
9034
9327
  } catch (err) {
9035
9328
  if (!this.isCapsuleImportPathInputFsError(err)) throw err;
9036
9329
  const message = err instanceof Error ? err.message : String(err);
@@ -9069,85 +9362,10 @@ ${next}`);
9069
9362
  memoryDir: exportOptions.encrypt === true ? memoryDir : void 0
9070
9363
  });
9071
9364
  }
9072
- /**
9073
- * List capsule archives in the namespace-scoped capsule store.
9074
- *
9075
- * MCP uses this access-layer method instead of reading arbitrary paths so
9076
- * capsule discovery remains bound to the same namespace ACLs as export and
9077
- * import.
9078
- */
9079
9365
  async capsuleList(options) {
9080
- const resolvedNamespace = this.resolveReadableNamespace(options?.namespace, options?.principal);
9081
- const storage = await this.orchestrator.getStorage(resolvedNamespace);
9082
- const capsulesDir = defaultCapsulesDir(storage.dir);
9083
- let dirEntries;
9084
- try {
9085
- const capsulesDirStat = await nodeFs.lstat(capsulesDir);
9086
- if (capsulesDirStat.isSymbolicLink()) {
9087
- throw new EngramAccessInputError("capsule list failed: capsule store directory must not be a symlink");
9088
- }
9089
- if (!capsulesDirStat.isDirectory()) {
9090
- throw new EngramAccessInputError("capsule list failed: capsule store path must be a directory");
9091
- }
9092
- dirEntries = await nodeFs.readdir(capsulesDir, { withFileTypes: true });
9093
- } catch (err) {
9094
- const code = typeof err === "object" && err !== null && "code" in err ? err.code : void 0;
9095
- if (code === "ENOENT") {
9096
- return { namespace: resolvedNamespace, capsulesDir, capsules: [] };
9097
- }
9098
- throw err;
9099
- }
9100
- const archiveNames = dirEntries.filter(
9101
- (entry) => entry.isFile() && (entry.name.endsWith(".capsule.json.gz") || entry.name.endsWith(".capsule.json.gz.enc"))
9102
- ).map((entry) => entry.name).sort();
9103
- const capsules = [];
9104
- for (const archiveName of archiveNames) {
9105
- const archivePath = nodePath.join(capsulesDir, archiveName);
9106
- const id = archiveName.replace(/\.capsule\.json\.gz\.enc$/, "").replace(/\.capsule\.json\.gz$/, "");
9107
- const manifestPath = nodePath.join(capsulesDir, `${id}.manifest.json`);
9108
- let createdAt = null;
9109
- let pluginVersion = null;
9110
- let fileCount = null;
9111
- let description = null;
9112
- let manifestPathOrNull = manifestPath;
9113
- try {
9114
- const manifestStat = await nodeFs.lstat(manifestPath);
9115
- if (manifestStat.isSymbolicLink() || !manifestStat.isFile()) {
9116
- capsules.push({
9117
- id,
9118
- archivePath,
9119
- manifestPath: manifestPathOrNull,
9120
- createdAt,
9121
- pluginVersion,
9122
- fileCount,
9123
- description
9124
- });
9125
- continue;
9126
- }
9127
- const raw = await nodeFs.readFile(manifestPath, "utf-8");
9128
- const sidecar = JSON.parse(raw);
9129
- createdAt = typeof sidecar.createdAt === "string" ? sidecar.createdAt : null;
9130
- pluginVersion = typeof sidecar.pluginVersion === "string" ? sidecar.pluginVersion : null;
9131
- fileCount = Array.isArray(sidecar.files) ? sidecar.files.length : null;
9132
- const capsule = sidecar.capsule;
9133
- description = capsule && typeof capsule.description === "string" ? capsule.description : null;
9134
- } catch (err) {
9135
- const code = typeof err === "object" && err !== null && "code" in err ? err.code : void 0;
9136
- if (code === "ENOENT") {
9137
- manifestPathOrNull = null;
9138
- }
9139
- }
9140
- capsules.push({
9141
- id,
9142
- archivePath,
9143
- manifestPath: manifestPathOrNull,
9144
- createdAt,
9145
- pluginVersion,
9146
- fileCount,
9147
- description
9148
- });
9149
- }
9150
- return { namespace: resolvedNamespace, capsulesDir, capsules };
9366
+ return this.accessAdminOpsSurface.capsuleList(
9367
+ options
9368
+ );
9151
9369
  }
9152
9370
  /**
9153
9371
  * Operator-configured offline-sync excludes (#1786), compiled once per
@@ -9340,74 +9558,10 @@ ${next}`);
9340
9558
  const storage = await this.orchestrator.getStorage(resolvedNamespace);
9341
9559
  return getDreamsStatus(storage.dir, windowHours);
9342
9560
  }
9343
- /**
9344
- * Manually invoke a single Dreams phase pass (PR 4/4).
9345
- *
9346
- * Deep-sleep delegates to memory governance (shadow → dry-run, apply → live).
9347
- * Light-sleep and REM scan the observation ledger and memory corpus
9348
- * respectively, returning the same telemetry shape as a scheduled run.
9349
- */
9350
9561
  async dreamsRun(options) {
9351
- const { runDreamsPhase } = await import("./dreams-ledger-6UODQOX6.js");
9352
- const validPhases = ["lightSleep", "rem", "deepSleep"];
9353
- if (!validPhases.includes(options.phase)) {
9354
- throw new EngramAccessInputError(
9355
- `Invalid phase: ${String(options.phase)}. Must be one of: ${validPhases.join(", ")}`
9356
- );
9357
- }
9358
- const deepSleep = this.orchestrator.config.dreamsPhases.deepSleep;
9359
- if (options.phase === "deepSleep" && deepSleep.enabled === false && deepSleep.enabledExplicitlySet === true) {
9360
- throw new EngramAccessInputError(
9361
- "memory governance is disabled by dreams.phases.deepSleep.enabled=false"
9362
- );
9363
- }
9364
- const dryRun = options.dryRun === true;
9365
- const resolvedNamespace = this.writableNamespaceFor(
9366
- options.namespace,
9367
- void 0,
9368
- options.authenticatedPrincipal
9369
- );
9370
- const storage = await this.orchestrator.getStorage(resolvedNamespace);
9371
- const memoryDir = storage.dir;
9372
- const phaseRunner = dryRun || options.phase === "deepSleep" ? void 0 : async (_opts) => {
9373
- if (_opts.phase === "lightSleep") {
9374
- const result3 = await this.orchestrator.runLifecyclePolicyNow(storage);
9375
- return {
9376
- itemsProcessed: result3.memoriesAssessed,
9377
- notes: `scored ${result3.memoriesAssessed} memories`
9378
- };
9379
- }
9380
- const result2 = await this.orchestrator.runSemanticConsolidationNow({
9381
- dryRun: false,
9382
- storage
9383
- });
9384
- const itemsProcessed = result2.clusters.reduce(
9385
- (sum, cluster) => sum + cluster.memories.length,
9386
- 0
9387
- );
9388
- return {
9389
- itemsProcessed,
9390
- notes: `REM consolidation found ${result2.clustersFound} clusters`
9391
- };
9392
- };
9393
- const governanceRunner = options.phase === "deepSleep" ? async (_opts) => {
9394
- return this.orchestrator.runDeepSleepGovernanceNow({
9395
- storage,
9396
- dryRun: _opts.dryRun
9397
- });
9398
- } : void 0;
9399
- const result = await runDreamsPhase(
9400
- { memoryDir, phase: options.phase, dryRun },
9401
- governanceRunner,
9402
- phaseRunner
9562
+ return this.accessAdminOpsSurface.dreamsRun(
9563
+ options
9403
9564
  );
9404
- return {
9405
- phase: result.phase,
9406
- dryRun: result.dryRun,
9407
- durationMs: result.durationMs,
9408
- itemsProcessed: result.itemsProcessed,
9409
- notes: result.notes
9410
- };
9411
9565
  }
9412
9566
  // ---------------------------------------------------------------------------
9413
9567
  // Wearables (Limitless / Bee / Omi transcript ingestion)
@@ -9517,100 +9671,10 @@ ${next}`);
9517
9671
  const result = await auditTranscripts(this.orchestrator.config.memoryDir);
9518
9672
  return redactSensitive(result);
9519
9673
  }
9520
- /**
9521
- * Manually promote a memory into one or more authorized targets. Requires
9522
- * a non-empty reason (audit-logged). Reuses the scope-profile promotion
9523
- * resolution and `canWriteNamespace` gate — there is no dashboard-only
9524
- * write path.
9525
- */
9526
9674
  async adminPromoteMemory(request) {
9527
- const config = this.orchestrator.config;
9528
- const namespacesEnabled = resolveNamespaceCapabilities(config).namespaces === true;
9529
- let sourceNamespace;
9530
- if (request.namespace) {
9531
- sourceNamespace = this.resolveReadableNamespace(
9532
- request.namespace,
9533
- request.principal
9534
- );
9535
- } else {
9536
- const codingContext2 = request.sessionKey ? this.orchestrator.getCodingContextForSession(request.sessionKey) ?? null : null;
9537
- const plan = resolveScopePlan({
9538
- config,
9539
- sessionKey: request.sessionKey,
9540
- principalOverride: request.principal,
9541
- codingContext: codingContext2,
9542
- namespacesEnabled
9543
- });
9544
- sourceNamespace = this.resolveReadableNamespace(
9545
- plan.baseNamespace,
9546
- request.principal
9547
- );
9548
- }
9549
- const codingContext = request.sessionKey ? this.orchestrator.getCodingContextForSession(request.sessionKey) ?? null : null;
9550
- const codingOverlay = codingContext ? resolveCodingNamespaceOverlay(
9551
- codingContext,
9552
- config.codingMode,
9553
- config.defaultNamespace
9554
- ) : null;
9555
- const scopeProfilePlan = resolveScopeProfilePlan({
9556
- config,
9557
- principal: request.principal,
9558
- codingContext,
9559
- codingOverlay
9560
- });
9561
- const storage = {
9562
- readMemory: async (namespace, memoryId) => {
9563
- const resolved = await this.orchestrator.getStorage(namespace);
9564
- const memory = await resolved.getMemoryById(memoryId);
9565
- if (!memory) return null;
9566
- return {
9567
- category: memory.frontmatter.category,
9568
- content: memory.content,
9569
- frontmatter: memory.frontmatter
9570
- };
9571
- },
9572
- writePromotedMemory: async (namespace, memory) => {
9573
- const resolved = await this.orchestrator.getStorage(namespace);
9574
- const { id, tombstoneBlocked } = await resolved.writeMemory(
9575
- memory.category,
9576
- memory.content,
9577
- {
9578
- confidence: memory.confidence,
9579
- tags: memory.tags,
9580
- entityRef: memory.entityRef,
9581
- source: `admin-promotion:${memory.sourceNamespace}:${memory.reason.slice(0, 120)}`,
9582
- lineage: memory.lineage,
9583
- sourceMemoryId: memory.sourceMemoryId,
9584
- actor: memory.actor,
9585
- validAt: memory.validAt
9586
- }
9587
- );
9588
- if (tombstoneBlocked) {
9589
- throw new Error(
9590
- "target namespace tombstone-blocked the promoted content (pending_review)"
9591
- );
9592
- }
9593
- return id;
9594
- }
9595
- };
9596
- try {
9597
- return await promoteMemory({
9598
- config,
9599
- sourceMemoryId: request.sourceMemoryId,
9600
- sourceNamespace,
9601
- principal: request.principal,
9602
- targets: request.targets,
9603
- reason: request.reason,
9604
- actor: request.principal ?? "admin-console",
9605
- storage,
9606
- scopeProfilePlan
9607
- });
9608
- } catch (err) {
9609
- if (err instanceof AdminPromotionError) {
9610
- throw new EngramAccessInputError(err.message);
9611
- }
9612
- throw err;
9613
- }
9675
+ return this.accessAdminOpsSurface.adminPromoteMemory(
9676
+ request
9677
+ );
9614
9678
  }
9615
9679
  };
9616
9680
 
@@ -9970,7 +10034,7 @@ var AccessRecallSurface = class {
9970
10034
  const storages = [];
9971
10035
  const seenStorageDirs = /* @__PURE__ */ new Set();
9972
10036
  const addStorage = (candidateStorage) => {
9973
- const candidateDir = nodePath2.resolve(candidateStorage.dir);
10037
+ const candidateDir = nodePath3.resolve(candidateStorage.dir);
9974
10038
  if (seenStorageDirs.has(candidateDir)) return;
9975
10039
  seenStorageDirs.add(candidateDir);
9976
10040
  storages.push({ storage: candidateStorage, dir: candidateDir });
@@ -9985,7 +10049,7 @@ var AccessRecallSurface = class {
9985
10049
  }
9986
10050
  for (const candidateStorage of storages) {
9987
10051
  try {
9988
- const coldRoot = nodePath2.join(candidateStorage.dir, "cold");
10052
+ const coldRoot = nodePath3.join(candidateStorage.dir, "cold");
9989
10053
  for (const candidatePath of qmdResultPathCandidates(
9990
10054
  coldRoot,
9991
10055
  parts.relativePath
@@ -10017,7 +10081,7 @@ var AccessRecallSurface = class {
10017
10081
  return null;
10018
10082
  }
10019
10083
  }
10020
- if (nodePath2.isAbsolute(memoryPath)) {
10084
+ if (nodePath3.isAbsolute(memoryPath)) {
10021
10085
  const ownerStorage = await this.deps.storageForAbsoluteRecallPath(
10022
10086
  memoryPath,
10023
10087
  namespace,
@@ -10469,8 +10533,8 @@ var AccessRecallSurface = class {
10469
10533
  const previousQueue = this.deps.xrayQueue;
10470
10534
  let release = () => {
10471
10535
  };
10472
- this.deps.xrayQueue = new Promise((resolve3) => {
10473
- release = resolve3;
10536
+ this.deps.xrayQueue = new Promise((resolve4) => {
10537
+ release = resolve4;
10474
10538
  });
10475
10539
  await previousQueue;
10476
10540
  const recallStartedAt = Date.now();
@@ -10665,7 +10729,10 @@ export {
10665
10729
  selfDeps,
10666
10730
  EngramAccessInputError,
10667
10731
  ENGRAM_ACCESS_WRITE_SCHEMA_VERSION,
10732
+ buildProjectedGovernanceProposedActions,
10733
+ hasGroupedGovernanceActions,
10668
10734
  shapeMemorySummary,
10669
- EngramAccessService
10735
+ EngramAccessService,
10736
+ AccessAdminOpsSurface
10670
10737
  };
10671
- //# sourceMappingURL=chunk-VX2RYM2K.js.map
10738
+ //# sourceMappingURL=chunk-ZECLLIMX.js.map