@remnic/core 9.3.654 → 9.3.656

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 (281) hide show
  1. package/dist/access-cli.js +29 -29
  2. package/dist/access-http.d.ts +4 -4
  3. package/dist/access-http.js +17 -17
  4. package/dist/access-mcp.d.ts +4 -4
  5. package/dist/access-mcp.js +16 -16
  6. package/dist/access-schema.d.ts +10 -10
  7. package/dist/{access-service-C8A5hoXJ.d.ts → access-service-D_nbpexW.d.ts} +33 -2
  8. package/dist/access-service.d.ts +4 -4
  9. package/dist/access-service.js +15 -15
  10. package/dist/action-confidence.d.ts +1 -1
  11. package/dist/active-memory-bridge.d.ts +1 -1
  12. package/dist/active-recall.d.ts +1 -1
  13. package/dist/active-recall.js +1 -1
  14. package/dist/behavior-learner.d.ts +1 -1
  15. package/dist/behavior-signals.d.ts +1 -1
  16. package/dist/bootstrap.d.ts +3 -3
  17. package/dist/briefing.d.ts +1 -1
  18. package/dist/briefing.js +3 -3
  19. package/dist/buffer-surprise-report.d.ts +1 -1
  20. package/dist/buffer.d.ts +1 -1
  21. package/dist/calibration.d.ts +1 -1
  22. package/dist/causal-behavior.d.ts +1 -1
  23. package/dist/causal-consolidation.d.ts +1 -1
  24. package/dist/causal-consolidation.js +4 -4
  25. package/dist/{chunk-JMQSYGXS.js → chunk-2BD7DG37.js} +2 -2
  26. package/dist/{chunk-FVRBLJP6.js → chunk-2MXEVL75.js} +2 -2
  27. package/dist/{chunk-LJCEWTG3.js → chunk-4UL7VPTD.js} +277 -58
  28. package/dist/chunk-4UL7VPTD.js.map +1 -0
  29. package/dist/{chunk-JYN7QNTA.js → chunk-54XF2FY7.js} +17 -17
  30. package/dist/{chunk-7WEB3FLJ.js → chunk-5PLUC5OB.js} +2 -2
  31. package/dist/{chunk-JX2RINDR.js → chunk-6G5JEN55.js} +2 -2
  32. package/dist/{chunk-ZCORQM74.js → chunk-AGJKWOKV.js} +2 -2
  33. package/dist/{chunk-NE2JBMLN.js → chunk-AZBV4RRY.js} +1 -1
  34. package/dist/chunk-AZBV4RRY.js.map +1 -0
  35. package/dist/{chunk-YLZLPVKK.js → chunk-CTAV55JM.js} +344 -1
  36. package/dist/chunk-CTAV55JM.js.map +1 -0
  37. package/dist/{chunk-2DSTAWNZ.js → chunk-DIBWFCLA.js} +3 -3
  38. package/dist/{chunk-NAZWHTYV.js → chunk-DR67OK4E.js} +5 -5
  39. package/dist/{chunk-XBIACVCO.js → chunk-EC2AYKRX.js} +2 -2
  40. package/dist/{chunk-JVRPJ7D4.js → chunk-EKQMQQ3U.js} +48 -12
  41. package/dist/chunk-EKQMQQ3U.js.map +1 -0
  42. package/dist/{chunk-RGPUQ66K.js → chunk-GCYFUTUC.js} +2 -2
  43. package/dist/{chunk-JBHXMCYN.js → chunk-GRYAECRV.js} +2 -2
  44. package/dist/{chunk-BJA6DQOC.js → chunk-GSHW5VVD.js} +5 -5
  45. package/dist/chunk-GYSYLGNE.js +650 -0
  46. package/dist/chunk-GYSYLGNE.js.map +1 -0
  47. package/dist/{chunk-NCGWXCSW.js → chunk-IOZ5WBWD.js} +2 -2
  48. package/dist/{chunk-QKK64Z6M.js → chunk-JSVFEHLL.js} +7 -5
  49. package/dist/chunk-JSVFEHLL.js.map +1 -0
  50. package/dist/{chunk-7LWRCOP7.js → chunk-LZTFCAKE.js} +2 -2
  51. package/dist/{chunk-2DGQLOOM.js → chunk-M3VYPE2H.js} +1 -1
  52. package/dist/{chunk-2DGQLOOM.js.map → chunk-M3VYPE2H.js.map} +1 -1
  53. package/dist/{chunk-6CVI6BP6.js → chunk-NXCK7DO7.js} +2 -2
  54. package/dist/{chunk-Z5MQI7K2.js → chunk-PEPHBH2W.js} +2 -2
  55. package/dist/{chunk-PYWNNF2I.js → chunk-QRSKPI62.js} +99 -66
  56. package/dist/chunk-QRSKPI62.js.map +1 -0
  57. package/dist/{chunk-XWQ6ERUG.js → chunk-QZRKNA5F.js} +2 -2
  58. package/dist/{chunk-PS3SYNHP.js → chunk-R5DB26G6.js} +2 -2
  59. package/dist/{chunk-OL2364SB.js → chunk-RDW5G6DO.js} +1502 -335
  60. package/dist/chunk-RDW5G6DO.js.map +1 -0
  61. package/dist/{chunk-YM3LR4LS.js → chunk-SSSXWIBP.js} +5 -5
  62. package/dist/{chunk-T2C6QJG2.js → chunk-SWDHVH2P.js} +2 -2
  63. package/dist/{chunk-DBM2BD22.js → chunk-SXYCVRLK.js} +3 -3
  64. package/dist/{chunk-K6X553JB.js → chunk-TFFZUFEP.js} +7 -5
  65. package/dist/chunk-TFFZUFEP.js.map +1 -0
  66. package/dist/{chunk-ENV6RDTD.js → chunk-TIJYQXDI.js} +2 -2
  67. package/dist/{chunk-BP2EV6W5.js → chunk-VAEAGTEQ.js} +4 -4
  68. package/dist/{chunk-3RACUBII.js → chunk-WIKMCJUR.js} +2 -2
  69. package/dist/{chunk-QW6JZO5P.js → chunk-WWMHAMAY.js} +2 -2
  70. package/dist/{chunk-GPW2E4LN.js → chunk-YEZHZCUO.js} +4 -4
  71. package/dist/{chunk-5FOCXX5E.js → chunk-YVVQUAOO.js} +3 -3
  72. package/dist/{chunk-5FOCXX5E.js.map → chunk-YVVQUAOO.js.map} +1 -1
  73. package/dist/{chunk-3XGWCZ63.js → chunk-YXLT4EMM.js} +2 -2
  74. package/dist/{chunk-Y2RIIF6H.js → chunk-Z6UDTNY6.js} +2 -2
  75. package/dist/{cli-uQgvDFNE.d.ts → cli-aYxSuPvP.d.ts} +3 -3
  76. package/dist/cli.d.ts +5 -5
  77. package/dist/cli.js +29 -29
  78. package/dist/compounding/engine.d.ts +1 -1
  79. package/dist/compounding/engine.js +3 -3
  80. package/dist/compounding/preference-consolidator.d.ts +1 -1
  81. package/dist/compression-optimizer.d.ts +1 -1
  82. package/dist/config.d.ts +1 -1
  83. package/dist/config.js +1 -1
  84. package/dist/connectors/codex-materialize-runner.d.ts +1 -1
  85. package/dist/connectors/codex-materialize-runner.js +3 -3
  86. package/dist/connectors/codex-materialize.d.ts +1 -1
  87. package/dist/connectors/index.d.ts +1 -1
  88. package/dist/connectors/index.js +3 -3
  89. package/dist/consolidation-provenance-check.d.ts +1 -1
  90. package/dist/consolidation-undo.d.ts +1 -1
  91. package/dist/contradiction/index.d.ts +1 -1
  92. package/dist/conversation-index/backend.d.ts +1 -1
  93. package/dist/conversation-index/chunker.d.ts +1 -1
  94. package/dist/conversation-index/faiss-adapter.d.ts +1 -1
  95. package/dist/conversation-index/indexer.d.ts +1 -1
  96. package/dist/conversation-index/search.d.ts +1 -1
  97. package/dist/day-summary.d.ts +1 -1
  98. package/dist/delinearize.d.ts +1 -1
  99. package/dist/direct-answer-wiring.d.ts +1 -1
  100. package/dist/direct-answer.d.ts +1 -1
  101. package/dist/embedding-fallback.d.ts +1 -1
  102. package/dist/enrichment/index.d.ts +1 -1
  103. package/dist/entity-retrieval.d.ts +1 -1
  104. package/dist/entity-retrieval.js +3 -3
  105. package/dist/entity-schema.d.ts +1 -1
  106. package/dist/explicit-capture.d.ts +3 -3
  107. package/dist/explicit-cue-recall.js +2 -2
  108. package/dist/extraction-judge-telemetry.d.ts +1 -1
  109. package/dist/extraction-judge-training.d.ts +1 -1
  110. package/dist/extraction-judge.d.ts +1 -1
  111. package/dist/extraction.d.ts +1 -1
  112. package/dist/fallback-llm.d.ts +1 -1
  113. package/dist/focused-list-recall.js +2 -2
  114. package/dist/identity-continuity.d.ts +1 -1
  115. package/dist/importance.d.ts +1 -1
  116. package/dist/index.d.ts +121 -121
  117. package/dist/index.js +39 -39
  118. package/dist/intent.d.ts +1 -1
  119. package/dist/lcm/engine.d.ts +1 -1
  120. package/dist/lcm/index.d.ts +1 -1
  121. package/dist/lcm/tools.d.ts +1 -1
  122. package/dist/lcm-fallback-read.js +1 -1
  123. package/dist/lifecycle.d.ts +1 -1
  124. package/dist/live-connectors-runner.d.ts +1 -1
  125. package/dist/local-llm.d.ts +1 -1
  126. package/dist/maintenance/memory-governance.d.ts +1 -1
  127. package/dist/maintenance/memory-governance.js +3 -3
  128. package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +3 -3
  129. package/dist/maintenance/rebuild-memory-projection.js +4 -4
  130. package/dist/mcp-memory-inspector-app.d.ts +4 -4
  131. package/dist/memory-action-policy.d.ts +1 -1
  132. package/dist/memory-cache.d.ts +1 -1
  133. package/dist/memory-lifecycle-ledger-utils.d.ts +1 -1
  134. package/dist/memory-projection-store.d.ts +1 -1
  135. package/dist/memory-provenance.d.ts +1 -1
  136. package/dist/memory-worth-outcomes.d.ts +1 -1
  137. package/dist/models-json.d.ts +1 -1
  138. package/dist/namespaces/migrate.d.ts +1 -1
  139. package/dist/namespaces/migrate.js +11 -11
  140. package/dist/namespaces/principal.d.ts +1 -1
  141. package/dist/namespaces/search.d.ts +15 -4
  142. package/dist/namespaces/search.js +7 -7
  143. package/dist/namespaces/storage.d.ts +1 -1
  144. package/dist/namespaces/storage.js +3 -3
  145. package/dist/native-knowledge.d.ts +1 -1
  146. package/dist/operator-toolkit.d.ts +1 -1
  147. package/dist/operator-toolkit.js +14 -14
  148. package/dist/{orchestrator-B4Y4sWQH.d.ts → orchestrator-D1wcmPNj.d.ts} +17 -14
  149. package/dist/orchestrator.d.ts +3 -3
  150. package/dist/orchestrator.js +25 -25
  151. package/dist/patterns-cli.d.ts +1 -1
  152. package/dist/policy-runtime.d.ts +1 -1
  153. package/dist/qmd-recall-cache.d.ts +1 -1
  154. package/dist/qmd.d.ts +5 -1
  155. package/dist/qmd.js +2 -2
  156. package/dist/recall-disclosure-escalation.d.ts +1 -1
  157. package/dist/recall-explain-renderer.d.ts +1 -1
  158. package/dist/recall-explain-renderer.js +3 -3
  159. package/dist/recall-planner-llm.d.ts +1 -1
  160. package/dist/recall-state.d.ts +1 -1
  161. package/dist/recall-tag-filter.d.ts +1 -1
  162. package/dist/recall-xray-cli.d.ts +1 -1
  163. package/dist/recall-xray-cli.js +4 -4
  164. package/dist/recall-xray-renderer.d.ts +1 -1
  165. package/dist/recall-xray-renderer.js +3 -3
  166. package/dist/recall-xray.d.ts +1 -1
  167. package/dist/recall-xray.js +2 -2
  168. package/dist/resolve-auth-token.d.ts +1 -1
  169. package/dist/response-guidance-recall.js +2 -2
  170. package/dist/resume-bundles.js +2 -2
  171. package/dist/retrieval-agents.d.ts +1 -1
  172. package/dist/retrieval-tiers.d.ts +1 -1
  173. package/dist/routing/engine.d.ts +1 -1
  174. package/dist/routing/store.d.ts +1 -1
  175. package/dist/schemas.d.ts +22 -22
  176. package/dist/search/embed-helper.d.ts +1 -1
  177. package/dist/search/factory.d.ts +1 -1
  178. package/dist/search/factory.js +6 -6
  179. package/dist/search/index.d.ts +1 -1
  180. package/dist/search/index.js +6 -6
  181. package/dist/search/lancedb-backend.d.ts +1 -1
  182. package/dist/search/lancedb-backend.js +2 -2
  183. package/dist/search/meilisearch-backend.d.ts +1 -1
  184. package/dist/search/meilisearch-backend.js +2 -2
  185. package/dist/search/noop-backend.d.ts +1 -1
  186. package/dist/search/orama-backend.d.ts +1 -1
  187. package/dist/search/orama-backend.js +2 -2
  188. package/dist/search/port.d.ts +17 -1
  189. package/dist/search/port.js +1 -1
  190. package/dist/search/remote-backend.d.ts +1 -1
  191. package/dist/{semantic-consolidation-BKd0Pype.d.ts → semantic-consolidation-MWOdNtSE.d.ts} +1 -1
  192. package/dist/semantic-consolidation.d.ts +2 -2
  193. package/dist/semantic-consolidation.js +4 -4
  194. package/dist/semantic-rule-promotion.js +3 -3
  195. package/dist/semantic-rule-verifier.d.ts +3 -2
  196. package/dist/semantic-rule-verifier.js +5 -3
  197. package/dist/session-observer-bands.d.ts +1 -1
  198. package/dist/session-observer-state.d.ts +1 -1
  199. package/dist/shared-context/manager.d.ts +1 -1
  200. package/dist/signal.d.ts +1 -1
  201. package/dist/storage.d.ts +1 -1
  202. package/dist/storage.js +2 -2
  203. package/dist/summarizer.d.ts +1 -1
  204. package/dist/summary-snapshot.d.ts +1 -1
  205. package/dist/targeted-fact-recall.js +2 -2
  206. package/dist/temporal-supersession.d.ts +1 -1
  207. package/dist/temporal-validity.d.ts +1 -1
  208. package/dist/threading.d.ts +1 -1
  209. package/dist/tier-migration.d.ts +1 -1
  210. package/dist/tier-routing.d.ts +1 -1
  211. package/dist/topics.d.ts +1 -1
  212. package/dist/transcript.d.ts +1 -1
  213. package/dist/transfer/types.d.ts +12 -12
  214. package/dist/{types-BgChEr0M.d.ts → types-CgcCpUrf.d.ts} +51 -1
  215. package/dist/types.d.ts +1 -1
  216. package/dist/types.js +1 -1
  217. package/dist/utility-runtime.d.ts +1 -1
  218. package/dist/verified-recall.d.ts +2 -1
  219. package/dist/verified-recall.js +5 -3
  220. package/package.json +1 -1
  221. package/src/access-service-observe-lcm-parity.test.ts +86 -1
  222. package/src/access-service-observe-scope.test.ts +283 -1
  223. package/src/access-service-raw-excerpt-read-gate.test.ts +53 -0
  224. package/src/access-service.ts +391 -93
  225. package/src/coding/coding-namespace.ts +0 -3
  226. package/src/config.test.ts +69 -0
  227. package/src/config.ts +417 -0
  228. package/src/lcm-fallback-read.ts +2 -6
  229. package/src/maintenance/namespace-planner.test.ts +1120 -0
  230. package/src/maintenance/namespace-planner.ts +893 -0
  231. package/src/namespaces/scope-profiles.test.ts +1074 -0
  232. package/src/namespaces/scope-profiles.ts +456 -0
  233. package/src/namespaces/search.test.ts +130 -2
  234. package/src/namespaces/search.ts +71 -10
  235. package/src/orchestrator-flush.test.ts +606 -44
  236. package/src/orchestrator-source-attribution.test.ts +73 -0
  237. package/src/orchestrator.ts +932 -229
  238. package/src/qmd-client.test.ts +59 -0
  239. package/src/qmd.ts +124 -84
  240. package/src/search/port.ts +16 -0
  241. package/src/semantic-rule-verifier.ts +13 -6
  242. package/src/types.ts +64 -0
  243. package/src/verified-recall.ts +10 -6
  244. package/dist/chunk-JVRPJ7D4.js.map +0 -1
  245. package/dist/chunk-K6X553JB.js.map +0 -1
  246. package/dist/chunk-LJCEWTG3.js.map +0 -1
  247. package/dist/chunk-MMJANTJX.js +0 -339
  248. package/dist/chunk-MMJANTJX.js.map +0 -1
  249. package/dist/chunk-NE2JBMLN.js.map +0 -1
  250. package/dist/chunk-OL2364SB.js.map +0 -1
  251. package/dist/chunk-PYWNNF2I.js.map +0 -1
  252. package/dist/chunk-QKK64Z6M.js.map +0 -1
  253. package/dist/chunk-YLZLPVKK.js.map +0 -1
  254. /package/dist/{chunk-JMQSYGXS.js.map → chunk-2BD7DG37.js.map} +0 -0
  255. /package/dist/{chunk-FVRBLJP6.js.map → chunk-2MXEVL75.js.map} +0 -0
  256. /package/dist/{chunk-JYN7QNTA.js.map → chunk-54XF2FY7.js.map} +0 -0
  257. /package/dist/{chunk-7WEB3FLJ.js.map → chunk-5PLUC5OB.js.map} +0 -0
  258. /package/dist/{chunk-JX2RINDR.js.map → chunk-6G5JEN55.js.map} +0 -0
  259. /package/dist/{chunk-ZCORQM74.js.map → chunk-AGJKWOKV.js.map} +0 -0
  260. /package/dist/{chunk-2DSTAWNZ.js.map → chunk-DIBWFCLA.js.map} +0 -0
  261. /package/dist/{chunk-NAZWHTYV.js.map → chunk-DR67OK4E.js.map} +0 -0
  262. /package/dist/{chunk-XBIACVCO.js.map → chunk-EC2AYKRX.js.map} +0 -0
  263. /package/dist/{chunk-RGPUQ66K.js.map → chunk-GCYFUTUC.js.map} +0 -0
  264. /package/dist/{chunk-JBHXMCYN.js.map → chunk-GRYAECRV.js.map} +0 -0
  265. /package/dist/{chunk-BJA6DQOC.js.map → chunk-GSHW5VVD.js.map} +0 -0
  266. /package/dist/{chunk-NCGWXCSW.js.map → chunk-IOZ5WBWD.js.map} +0 -0
  267. /package/dist/{chunk-7LWRCOP7.js.map → chunk-LZTFCAKE.js.map} +0 -0
  268. /package/dist/{chunk-6CVI6BP6.js.map → chunk-NXCK7DO7.js.map} +0 -0
  269. /package/dist/{chunk-Z5MQI7K2.js.map → chunk-PEPHBH2W.js.map} +0 -0
  270. /package/dist/{chunk-XWQ6ERUG.js.map → chunk-QZRKNA5F.js.map} +0 -0
  271. /package/dist/{chunk-PS3SYNHP.js.map → chunk-R5DB26G6.js.map} +0 -0
  272. /package/dist/{chunk-YM3LR4LS.js.map → chunk-SSSXWIBP.js.map} +0 -0
  273. /package/dist/{chunk-T2C6QJG2.js.map → chunk-SWDHVH2P.js.map} +0 -0
  274. /package/dist/{chunk-DBM2BD22.js.map → chunk-SXYCVRLK.js.map} +0 -0
  275. /package/dist/{chunk-ENV6RDTD.js.map → chunk-TIJYQXDI.js.map} +0 -0
  276. /package/dist/{chunk-BP2EV6W5.js.map → chunk-VAEAGTEQ.js.map} +0 -0
  277. /package/dist/{chunk-3RACUBII.js.map → chunk-WIKMCJUR.js.map} +0 -0
  278. /package/dist/{chunk-QW6JZO5P.js.map → chunk-WWMHAMAY.js.map} +0 -0
  279. /package/dist/{chunk-GPW2E4LN.js.map → chunk-YEZHZCUO.js.map} +0 -0
  280. /package/dist/{chunk-3XGWCZ63.js.map → chunk-YXLT4EMM.js.map} +0 -0
  281. /package/dist/{chunk-Y2RIIF6H.js.map → chunk-Z6UDTNY6.js.map} +0 -0
@@ -14,7 +14,7 @@ import {
14
14
  } from "./chunk-H7XKCNR6.js";
15
15
  import {
16
16
  toRecallExplainJson
17
- } from "./chunk-ENV6RDTD.js";
17
+ } from "./chunk-TIJYQXDI.js";
18
18
  import {
19
19
  applyTagFilter,
20
20
  normalizeTags,
@@ -27,15 +27,17 @@ import {
27
27
  listMemoryGovernanceRuns,
28
28
  readMemoryGovernanceRunArtifact,
29
29
  runMemoryGovernance
30
- } from "./chunk-XWQ6ERUG.js";
30
+ } from "./chunk-QZRKNA5F.js";
31
31
  import {
32
32
  clusterByKey,
33
33
  combineNamespaces,
34
+ expandScopeProfileReadNamespaces,
34
35
  lcmSessionKeyForNamespace,
35
36
  projectTagProjectId,
36
37
  resolveCodingNamespaceOverlay,
37
- resolveGitContext
38
- } from "./chunk-MMJANTJX.js";
38
+ resolveGitContext,
39
+ resolveScopeProfilePlan
40
+ } from "./chunk-GYSYLGNE.js";
39
41
  import {
40
42
  getTrustZoneStoreStatus,
41
43
  isTrustZoneName,
@@ -50,10 +52,10 @@ import {
50
52
  } from "./chunk-FF4KLI5W.js";
51
53
  import {
52
54
  estimateRecallTokens
53
- } from "./chunk-FVRBLJP6.js";
55
+ } from "./chunk-2MXEVL75.js";
54
56
  import {
55
57
  namespaceCollectionName
56
- } from "./chunk-JVRPJ7D4.js";
58
+ } from "./chunk-EKQMQQ3U.js";
57
59
  import {
58
60
  namespaceIdentityFromToken
59
61
  } from "./chunk-ZFXCQPNO.js";
@@ -92,14 +94,14 @@ import {
92
94
  buildBriefing,
93
95
  parseBriefingFocus,
94
96
  parseBriefingWindow
95
- } from "./chunk-Y2RIIF6H.js";
97
+ } from "./chunk-Z6UDTNY6.js";
96
98
  import {
97
99
  parseEntityFile
98
- } from "./chunk-6CVI6BP6.js";
100
+ } from "./chunk-NXCK7DO7.js";
99
101
  import {
100
102
  DEFAULT_RECALL_DISCLOSURE,
101
103
  isRecallDisclosure
102
- } from "./chunk-NE2JBMLN.js";
104
+ } from "./chunk-AZBV4RRY.js";
103
105
  import {
104
106
  inferMemoryStatus,
105
107
  toMemoryPathRel
@@ -789,11 +791,32 @@ var EngramAccessService = class {
789
791
  );
790
792
  }
791
793
  const hasSession = typeof request.sessionKey === "string" && request.sessionKey.length > 0;
794
+ const codingContext = hasSession && this.orchestrator.config.namespacesEnabled && this.orchestrator.config.codingMode?.projectScope ? this.orchestrator.getCodingContextForSession(request.sessionKey) ?? await this.resolveCodingContextFromOptions(request) : null;
792
795
  const overlay = hasSession && this.orchestrator.config.namespacesEnabled && this.orchestrator.config.codingMode?.projectScope ? resolveCodingNamespaceOverlay(
793
- this.orchestrator.getCodingContextForSession(request.sessionKey) ?? await this.resolveCodingContextFromOptions(request),
796
+ codingContext,
794
797
  this.orchestrator.config.codingMode,
795
798
  this.orchestrator.config.defaultNamespace
796
799
  ) : null;
800
+ const principal = this.resolveRequestPrincipal(
801
+ request.sessionKey,
802
+ request.authenticatedPrincipal
803
+ );
804
+ const profilePlan = resolveScopeProfilePlan({
805
+ config: this.orchestrator.config,
806
+ principal,
807
+ codingContext,
808
+ codingOverlay: overlay
809
+ });
810
+ if (profilePlan) {
811
+ const selectedLayer = profilePlan.layers.find((layer) => layer.id === profilePlan.writeLayer);
812
+ const writeNamespaceReadable = profilePlan.writeNamespace.length > 0 && profilePlan.readNamespaces.includes(profilePlan.writeNamespace);
813
+ if (!selectedLayer?.writable || !writeNamespaceReadable) {
814
+ throw new EngramAccessInputError(
815
+ `scope profile ${profilePlan.profileId} has no writable layer inside the profile read stack for principal ${principal ?? "anonymous"}`
816
+ );
817
+ }
818
+ return profilePlan.writeNamespace;
819
+ }
797
820
  if (!overlay) {
798
821
  return this.resolveWritableNamespace(
799
822
  void 0,
@@ -801,10 +824,6 @@ var EngramAccessService = class {
801
824
  request.authenticatedPrincipal
802
825
  );
803
826
  }
804
- const principal = this.resolveRequestPrincipal(
805
- request.sessionKey,
806
- request.authenticatedPrincipal
807
- );
808
827
  const base = defaultNamespaceForPrincipal(principal, this.orchestrator.config);
809
828
  if (!canWriteNamespace(principal, base, this.orchestrator.config)) {
810
829
  throw new EngramAccessInputError(`namespace is not writable: ${base}`);
@@ -887,6 +906,55 @@ var EngramAccessService = class {
887
906
  baseNamespace
888
907
  );
889
908
  const codingOverlayApplied = overlaidBase !== baseNamespace;
909
+ const codingOverlay = overlayEligible ? resolveCodingNamespaceOverlay(
910
+ attachedContext,
911
+ this.orchestrator.config.codingMode,
912
+ this.orchestrator.config.defaultNamespace
913
+ ) : null;
914
+ const profilePlan = resolveScopeProfilePlan({
915
+ config: this.orchestrator.config,
916
+ principal,
917
+ codingContext: attachedContext,
918
+ codingOverlay
919
+ });
920
+ if (profilePlan) {
921
+ const selectedLayer = profilePlan.layers.find((layer) => layer.id === profilePlan.writeLayer);
922
+ const writeNamespaceReadable = profilePlan.writeNamespace.length > 0 && profilePlan.readNamespaces.includes(profilePlan.writeNamespace);
923
+ if (!selectedLayer?.writable || !writeNamespaceReadable) {
924
+ clearSeededContext();
925
+ throw new EngramAccessInputError(
926
+ `scope profile ${profilePlan.profileId} has no writable layer inside the profile read stack for principal ${principal ?? "anonymous"}`
927
+ );
928
+ }
929
+ const legacyRecallNamespaces = Array.isArray(this.orchestrator.config.defaultRecallNamespaces) ? recallNamespacesForPrincipal(principal, this.orchestrator.config) : [];
930
+ const expandedReadNamespaces = expandScopeProfileReadNamespaces({
931
+ profilePlan,
932
+ principalSelfNamespace: profilePlan.baseNamespace,
933
+ config: this.orchestrator.config,
934
+ principal,
935
+ codingOverlay,
936
+ legacyRecallNamespaces
937
+ });
938
+ const readNamespaces2 = expandedReadNamespaces;
939
+ const profileCodingOverlayApplied = Boolean(
940
+ codingOverlay && profilePlan.layers.some(
941
+ (layer) => (layer.id === "userProject" || layer.id === "teamProject") && layer.readable && layer.namespace && readNamespaces2.includes(layer.namespace)
942
+ )
943
+ );
944
+ return {
945
+ principal,
946
+ baseNamespace: profilePlan.baseNamespace,
947
+ writeNamespace: profilePlan.writeNamespace,
948
+ objectiveStateNamespace: profilePlan.writeNamespace,
949
+ readNamespaces: readNamespaces2,
950
+ scopeProfile: profilePlan.profileId,
951
+ writeLayer: profilePlan.writeLayer,
952
+ layers: profilePlan.layers,
953
+ promotionTargets: profilePlan.promotionTargets,
954
+ codingOverlayApplied: profileCodingOverlayApplied,
955
+ warnings: [...warnings, ...profilePlan.warnings]
956
+ };
957
+ }
890
958
  if (!codingOverlayApplied) {
891
959
  const writeNamespace2 = this.resolveWritableNamespace(
892
960
  void 0,
@@ -926,12 +994,7 @@ var EngramAccessService = class {
926
994
  }
927
995
  const writeNamespace = overlaidBase;
928
996
  const readNamespaces = [writeNamespace];
929
- const overlay = resolveCodingNamespaceOverlay(
930
- attachedContext,
931
- this.orchestrator.config.codingMode,
932
- this.orchestrator.config.defaultNamespace
933
- );
934
- for (const fallback of overlay?.readFallbacks ?? []) {
997
+ for (const fallback of codingOverlay?.readFallbacks ?? []) {
935
998
  const ns = combineNamespaces(baseNamespace, fallback);
936
999
  if (!readNamespaces.includes(ns)) readNamespaces.push(ns);
937
1000
  }
@@ -945,6 +1008,13 @@ var EngramAccessService = class {
945
1008
  warnings
946
1009
  };
947
1010
  }
1011
+ legacyResponseNamespaceForScope(scope) {
1012
+ if (scope.explicitNamespace) return scope.writeNamespace;
1013
+ if (scope.scopeProfile && scope.writeLayer !== "userProject") {
1014
+ return scope.writeNamespace;
1015
+ }
1016
+ return scope.codingOverlayApplied ? this.orchestrator.config.defaultNamespace : scope.writeNamespace;
1017
+ }
948
1018
  async objectiveStateStoreLocationForNamespace(namespace) {
949
1019
  if (!this.orchestrator.config.namespacesEnabled) {
950
1020
  return {
@@ -992,7 +1062,28 @@ var EngramAccessService = class {
992
1062
  "authentication required: namespaces are enabled and no principal was supplied"
993
1063
  );
994
1064
  }
995
- return recallNamespacesForPrincipal(principal, this.orchestrator.config).filter((ns) => canReadNamespace(principal, ns, this.orchestrator.config));
1065
+ const legacyRecallNamespaces = recallNamespacesForPrincipal(
1066
+ principal,
1067
+ this.orchestrator.config
1068
+ );
1069
+ const profilePlan = resolveScopeProfilePlan({
1070
+ config: this.orchestrator.config,
1071
+ principal,
1072
+ codingContext: null,
1073
+ codingOverlay: null
1074
+ });
1075
+ const namespaces = profilePlan ? expandScopeProfileReadNamespaces({
1076
+ profilePlan,
1077
+ principalSelfNamespace: profilePlan.baseNamespace,
1078
+ config: this.orchestrator.config,
1079
+ principal,
1080
+ codingOverlay: null,
1081
+ legacyRecallNamespaces
1082
+ }) : legacyRecallNamespaces;
1083
+ if (profilePlan) return namespaces;
1084
+ return namespaces.filter(
1085
+ (ns) => canReadNamespace(principal, ns, this.orchestrator.config)
1086
+ );
996
1087
  }
997
1088
  resolveAllReadableConfiguredNamespaces(principal) {
998
1089
  const config = this.orchestrator.config;
@@ -1011,7 +1102,13 @@ var EngramAccessService = class {
1011
1102
  if (!collection || collection === "global" || collection === baseCollection) {
1012
1103
  return namespaces;
1013
1104
  }
1014
- const candidates = collectionPrincipal ? this.resolveAllReadableConfiguredNamespaces(collectionPrincipal) : namespaces;
1105
+ const activeScopeProfilePlan = collectionPrincipal ? resolveScopeProfilePlan({
1106
+ config: this.orchestrator.config,
1107
+ principal: collectionPrincipal,
1108
+ codingContext: null,
1109
+ codingOverlay: null
1110
+ }) : null;
1111
+ const candidates = collectionPrincipal ? activeScopeProfilePlan ? namespaces : this.resolveAllReadableConfiguredNamespaces(collectionPrincipal) : namespaces;
1015
1112
  const matchedNamespaces = candidates.filter((namespace) => {
1016
1113
  const canonical = namespaceCollectionName(baseCollection, namespace, {
1017
1114
  defaultNamespace: this.orchestrator.config.defaultNamespace,
@@ -1078,7 +1175,7 @@ var EngramAccessService = class {
1078
1175
  query: options.query,
1079
1176
  ...options.sessionKey ? { sessionKey: options.sessionKey } : {},
1080
1177
  ...options.rawExcerptNamespace ? { rawExcerptNamespace: options.rawExcerptNamespace } : {},
1081
- ...options.rawExcerptSessionIds ? { rawExcerptSessionIds: options.rawExcerptSessionIds } : {},
1178
+ ...options.rawExcerptSessionIds !== void 0 ? { rawExcerptSessionIds: options.rawExcerptSessionIds } : {},
1082
1179
  ...options.rawExcerptsSuppressed ? { rawExcerptsSuppressed: options.rawExcerptsSuppressed } : {}
1083
1180
  }
1084
1181
  );
@@ -1222,7 +1319,7 @@ var EngramAccessService = class {
1222
1319
  query: rawContext.query,
1223
1320
  ...rawContext.sessionKey ? { sessionKey: rawContext.sessionKey } : {},
1224
1321
  namespace: rawContext.rawExcerptNamespace ?? namespace,
1225
- ...rawContext.rawExcerptSessionIds ? { lcmSessionIds: rawContext.rawExcerptSessionIds } : {}
1322
+ ...rawContext.rawExcerptSessionIds !== void 0 ? { lcmSessionIds: rawContext.rawExcerptSessionIds } : {}
1226
1323
  } : null
1227
1324
  );
1228
1325
  const rawExcerpts = rawExcerptsResult ?? void 0;
@@ -1322,18 +1419,19 @@ var EngramAccessService = class {
1322
1419
  if (!lcm || !lcm.enabled) return [];
1323
1420
  try {
1324
1421
  const legacyKey = context.namespace && context.namespace !== this.orchestrator.config.defaultNamespace ? `${context.namespace}:${context.sessionKey}` : context.sessionKey;
1325
- const lcmSessionIds = context.lcmSessionIds && context.lcmSessionIds.length > 0 ? context.lcmSessionIds : [legacyKey];
1422
+ const lcmSessionIds = context.lcmSessionIds !== void 0 ? context.lcmSessionIds : [legacyKey];
1326
1423
  const limit = 5;
1327
1424
  const seenRows = /* @__PURE__ */ new Set();
1328
1425
  const excerpts = [];
1329
- for (const lcmSessionKey of lcmSessionIds) {
1426
+ const settledRows = await Promise.allSettled(
1427
+ lcmSessionIds.map(
1428
+ async (lcmSessionKey) => lcm.searchContextFull(context.query, limit, lcmSessionKey)
1429
+ )
1430
+ );
1431
+ for (const result of settledRows) {
1330
1432
  if (excerpts.length >= limit) break;
1331
- const rows = await lcm.searchContextFull(
1332
- context.query,
1333
- limit,
1334
- lcmSessionKey
1335
- );
1336
- for (const r of rows) {
1433
+ if (result.status !== "fulfilled") continue;
1434
+ for (const r of result.value) {
1337
1435
  const dedupeKey = `${r.session_id} ${r.turn_index}`;
1338
1436
  if (seenRows.has(dedupeKey)) continue;
1339
1437
  seenRows.add(dedupeKey);
@@ -1923,8 +2021,29 @@ var EngramAccessService = class {
1923
2021
  }
1924
2022
  const principal = maybePrincipal ?? "default";
1925
2023
  const principalNamespace = defaultNamespaceForPrincipal(principal, this.orchestrator.config);
2024
+ const profileCodingContext = request.sessionKey && typeof this.orchestrator.getCodingContextForSession === "function" ? this.orchestrator.getCodingContextForSession(request.sessionKey) : null;
2025
+ const profileCodingOverlay = !namespaceOverride && profileCodingContext && this.orchestrator.config.namespacesEnabled && this.orchestrator.config.codingMode?.projectScope ? resolveCodingNamespaceOverlay(
2026
+ profileCodingContext,
2027
+ this.orchestrator.config.codingMode,
2028
+ this.orchestrator.config.defaultNamespace
2029
+ ) : null;
2030
+ const profilePlan = namespaceOverride ? null : resolveScopeProfilePlan({
2031
+ config: this.orchestrator.config,
2032
+ principal,
2033
+ codingContext: profileCodingContext,
2034
+ codingOverlay: profileCodingOverlay
2035
+ });
1926
2036
  const modeSkipsBudget = mode === "no_recall";
1927
- const effectiveNamespaces = namespaceOverride ? [namespaceOverride] : recallNamespacesForPrincipal(principal, this.orchestrator.config);
2037
+ const legacyRecallNamespaces = Array.isArray(this.orchestrator.config.defaultRecallNamespaces) ? recallNamespacesForPrincipal(principal, this.orchestrator.config) : [];
2038
+ const effectiveNamespaces = namespaceOverride ? [namespaceOverride] : profilePlan ? expandScopeProfileReadNamespaces({
2039
+ profilePlan,
2040
+ principalSelfNamespace: profilePlan.baseNamespace,
2041
+ config: this.orchestrator.config,
2042
+ principal,
2043
+ codingOverlay: profileCodingOverlay,
2044
+ legacyRecallNamespaces
2045
+ }) : legacyRecallNamespaces;
2046
+ const budgetPrincipalNamespace = profilePlan?.baseNamespace ?? principalNamespace;
1928
2047
  let budgetDecision;
1929
2048
  let recordBudgetAfterSuccess = false;
1930
2049
  if (modeSkipsBudget) {
@@ -1945,7 +2064,7 @@ var EngramAccessService = class {
1945
2064
  for (const ns of effectiveNamespaces) {
1946
2065
  const peek = this.budget.peek({
1947
2066
  principal,
1948
- principalNamespace,
2067
+ principalNamespace: budgetPrincipalNamespace,
1949
2068
  queryNamespace: ns
1950
2069
  });
1951
2070
  if (peek.reason !== "allowed-same-namespace") {
@@ -2049,7 +2168,7 @@ var EngramAccessService = class {
2049
2168
  query,
2050
2169
  sessionKey: trimmedSessionKey,
2051
2170
  ...rawExcerptNamespace ? { rawExcerptNamespace } : {},
2052
- ...rawExcerptSessionIds ? { rawExcerptSessionIds } : {},
2171
+ ...rawExcerptSessionIds !== void 0 ? { rawExcerptSessionIds } : {},
2053
2172
  ...rawExcerptsSuppressed ? { rawExcerptsSuppressed } : {}
2054
2173
  });
2055
2174
  const filterTags = normalizeTags(request.tags);
@@ -2347,7 +2466,7 @@ var EngramAccessService = class {
2347
2466
  query,
2348
2467
  ...trimmedSessionKey ? { sessionKey: trimmedSessionKey } : {},
2349
2468
  ...rawExcerptNamespace ? { namespace: rawExcerptNamespace } : {},
2350
- ...rawExcerptSessionIds ? { lcmSessionIds: rawExcerptSessionIds } : {}
2469
+ ...rawExcerptSessionIds !== void 0 ? { lcmSessionIds: rawExcerptSessionIds } : {}
2351
2470
  }) : disclosure2 === "raw" ? [] : null;
2352
2471
  const rawExcerptText = rawExcerpts && rawExcerpts.length > 0 ? rawExcerpts.map((e) => e.content).join("\n") : "";
2353
2472
  const memoryByIndex = await Promise.all(
@@ -2426,7 +2545,7 @@ var EngramAccessService = class {
2426
2545
  requestedMode: request.mode,
2427
2546
  normalizedMode: mode,
2428
2547
  ...xrayRawExcerptNamespace ? { rawExcerptNamespace: xrayRawExcerptNamespace } : {},
2429
- ...xrayRawExcerptSessionIds ? { rawExcerptSessionIds: xrayRawExcerptSessionIds } : {},
2548
+ ...xrayRawExcerptSessionIds !== void 0 ? { rawExcerptSessionIds: xrayRawExcerptSessionIds } : {},
2430
2549
  ...xrayRawExcerptsSuppressed ? { rawExcerptsSuppressed: xrayRawExcerptsSuppressed } : {}
2431
2550
  })
2432
2551
  };
@@ -3366,7 +3485,7 @@ var EngramAccessService = class {
3366
3485
  }
3367
3486
  const scope = await this.resolveMemoryScopePlan(request);
3368
3487
  const writeNamespace = scope.writeNamespace;
3369
- const namespace = scope.explicitNamespace ? scope.writeNamespace : scope.codingOverlayApplied ? this.orchestrator.config.defaultNamespace : scope.writeNamespace;
3488
+ const namespace = this.legacyResponseNamespaceForScope(scope);
3370
3489
  const shouldWriteObjectiveState = this.orchestrator.config.objectiveStateMemoryEnabled === true && this.orchestrator.config.objectiveStateSnapshotWritesEnabled === true;
3371
3490
  await this.maybeAttachCodingContext(request.sessionKey, {
3372
3491
  cwd: request.cwd,
@@ -3455,7 +3574,11 @@ var EngramAccessService = class {
3455
3574
  baseNamespace: scope.baseNamespace,
3456
3575
  writeNamespace: scope.writeNamespace,
3457
3576
  codingOverlayApplied: scope.codingOverlayApplied,
3458
- readNamespaces: scope.readNamespaces
3577
+ readNamespaces: scope.readNamespaces,
3578
+ scopeProfile: scope.scopeProfile,
3579
+ writeLayer: scope.writeLayer,
3580
+ layers: scope.layers,
3581
+ promotionTargets: scope.promotionTargets
3459
3582
  },
3460
3583
  lcmArchived,
3461
3584
  extractionQueued
@@ -3467,7 +3590,11 @@ var EngramAccessService = class {
3467
3590
  }
3468
3591
  const principal = this.resolveRequestPrincipal(request.sessionKey, request.authenticatedPrincipal);
3469
3592
  const hasExplicitNamespace = typeof request.namespace === "string" && request.namespace.trim().length > 0;
3470
- const namespace = hasExplicitNamespace ? this.resolveReadableNamespace(request.namespace, principal) : this.resolveImplicitLcmReadFallbackNamespace(principal);
3593
+ const profileLcmReadNamespaces = hasExplicitNamespace ? null : this.resolveScopeProfileLcmReadNamespaces(
3594
+ request.sessionKey,
3595
+ request.authenticatedPrincipal
3596
+ );
3597
+ const namespace = hasExplicitNamespace ? this.resolveReadableNamespace(request.namespace, principal) : profileLcmReadNamespaces !== null ? profileLcmReadNamespaces[0] : this.resolveImplicitLcmReadFallbackNamespace(principal);
3471
3598
  if (!this.orchestrator.lcmEngine || !this.orchestrator.lcmEngine.enabled) {
3472
3599
  return {
3473
3600
  query: request.query,
@@ -3477,6 +3604,15 @@ var EngramAccessService = class {
3477
3604
  lcmEnabled: false
3478
3605
  };
3479
3606
  }
3607
+ if (profileLcmReadNamespaces !== null && profileLcmReadNamespaces.length === 0) {
3608
+ return {
3609
+ query: request.query,
3610
+ namespace: this.orchestrator.config.defaultNamespace,
3611
+ results: [],
3612
+ count: 0,
3613
+ lcmEnabled: true
3614
+ };
3615
+ }
3480
3616
  if (namespace === void 0) {
3481
3617
  return {
3482
3618
  query: request.query,
@@ -3487,24 +3623,32 @@ var EngramAccessService = class {
3487
3623
  };
3488
3624
  }
3489
3625
  const limit = Math.max(1, Math.min(request.limit ?? 10, 100));
3490
- const lcmReadNamespace = this.resolveLcmReadNamespace(
3626
+ const lcmReadNamespace = profileLcmReadNamespaces !== null ? profileLcmReadNamespaces[0] ?? this.orchestrator.config.defaultNamespace : this.resolveLcmReadNamespace(
3491
3627
  request.namespace,
3492
3628
  namespace,
3493
3629
  request.sessionKey,
3494
3630
  request.authenticatedPrincipal
3495
3631
  );
3496
- const lcmSessionKeyIds = request.sessionKey ? this.resolveLcmReadSessionIds(
3632
+ const lcmSessionKeyIds = request.sessionKey ? profileLcmReadNamespaces !== null ? this.lcmSessionIdsForNamespaces(
3633
+ profileLcmReadNamespaces,
3634
+ request.sessionKey
3635
+ ) : this.resolveLcmReadSessionIds(
3497
3636
  request.namespace,
3498
3637
  namespace,
3499
3638
  request.sessionKey,
3500
3639
  request.authenticatedPrincipal
3501
3640
  ) : [void 0];
3502
- const lcmSessionPrefix = request.sessionPrefix ? lcmSessionKeyForNamespace(
3503
- lcmReadNamespace,
3504
- request.sessionPrefix,
3505
- this.orchestrator.config.defaultNamespace
3506
- ) ?? request.sessionPrefix : request.sessionPrefix;
3507
- const hasScopedSession = typeof request.sessionKey === "string" && request.sessionKey.length > 0 || typeof lcmSessionPrefix === "string" && lcmSessionPrefix.length > 0;
3641
+ const lcmSessionPrefixes = request.sessionPrefix ? profileLcmReadNamespaces !== null && !request.sessionKey ? this.lcmSessionIdsForNamespaces(
3642
+ profileLcmReadNamespaces,
3643
+ request.sessionPrefix
3644
+ ) : [
3645
+ lcmSessionKeyForNamespace(
3646
+ lcmReadNamespace,
3647
+ request.sessionPrefix,
3648
+ this.orchestrator.config.defaultNamespace
3649
+ ) ?? request.sessionPrefix
3650
+ ] : [void 0];
3651
+ const hasScopedSession = typeof request.sessionKey === "string" && request.sessionKey.length > 0 || lcmSessionPrefixes.some((prefix) => typeof prefix === "string" && prefix.length > 0);
3508
3652
  if (!hasScopedSession && this.orchestrator.config.namespacesEnabled === true) {
3509
3653
  return {
3510
3654
  query: request.query,
@@ -3516,15 +3660,35 @@ var EngramAccessService = class {
3516
3660
  }
3517
3661
  const seenRows = /* @__PURE__ */ new Set();
3518
3662
  const results = [];
3663
+ const lcmSearches = [];
3519
3664
  for (const lcmSessionKey of lcmSessionKeyIds) {
3665
+ for (const lcmSessionPrefix of lcmSessionPrefixes) {
3666
+ lcmSearches.push({
3667
+ key: lcmSessionKey,
3668
+ prefix: lcmSessionPrefix,
3669
+ promise: this.orchestrator.lcmEngine.searchContextFull(
3670
+ request.query,
3671
+ limit,
3672
+ lcmSessionKey,
3673
+ lcmSessionPrefix
3674
+ )
3675
+ });
3676
+ }
3677
+ }
3678
+ const settledSearches = await Promise.allSettled(
3679
+ lcmSearches.map((search) => search.promise)
3680
+ );
3681
+ for (let i = 0; i < settledSearches.length; i += 1) {
3520
3682
  if (results.length >= limit) break;
3521
- const rawResults = await this.orchestrator.lcmEngine.searchContextFull(
3522
- request.query,
3523
- limit,
3524
- lcmSessionKey,
3525
- lcmSessionPrefix
3526
- );
3527
- for (const r of rawResults) {
3683
+ const settled = settledSearches[i];
3684
+ if (!settled || settled.status === "rejected") {
3685
+ const failed = lcmSearches[i];
3686
+ log.warn(
3687
+ `lcmSearch: failed for key=${failed?.key ?? "<none>"} prefix=${failed?.prefix ?? "<none>"}: ${settled?.status === "rejected" ? settled.reason : "missing result"}`
3688
+ );
3689
+ continue;
3690
+ }
3691
+ for (const r of settled.value) {
3528
3692
  const dedupeKey = `${r.session_id}\0${r.turn_index}`;
3529
3693
  if (seenRows.has(dedupeKey)) continue;
3530
3694
  seenRows.add(dedupeKey);
@@ -3669,6 +3833,11 @@ var EngramAccessService = class {
3669
3833
  "read"
3670
3834
  );
3671
3835
  }
3836
+ const profileReadNamespaces = this.resolveScopeProfileLcmReadNamespaces(
3837
+ sessionKey,
3838
+ authenticatedPrincipal
3839
+ );
3840
+ if (profileReadNamespaces !== null) return profileReadNamespaces[0];
3672
3841
  const fallbackNamespace = this.resolveImplicitLcmReadFallbackNamespace(principal);
3673
3842
  if (fallbackNamespace === void 0) return void 0;
3674
3843
  return this.resolveLcmReadNamespace(
@@ -3763,6 +3932,49 @@ var EngramAccessService = class {
3763
3932
  * `<principal>-project-*` key is ever searched for an unauthorized reader (no
3764
3933
  * cross-tenant read leak).
3765
3934
  */
3935
+ resolveScopeProfileLcmReadNamespaces(sessionKey, authenticatedPrincipal) {
3936
+ const config = this.orchestrator.config;
3937
+ const principal = this.resolveRequestPrincipal(sessionKey, authenticatedPrincipal);
3938
+ const codingContext = sessionKey ? this.orchestrator.getCodingContextForSession(sessionKey) : null;
3939
+ const codingOverlay = resolveCodingNamespaceOverlay(
3940
+ codingContext,
3941
+ config.codingMode,
3942
+ config.defaultNamespace
3943
+ );
3944
+ const profilePlan = resolveScopeProfilePlan({
3945
+ config,
3946
+ principal,
3947
+ codingContext,
3948
+ codingOverlay
3949
+ });
3950
+ if (!profilePlan) return null;
3951
+ const principalSelfNamespace = defaultNamespaceForPrincipal(principal, config);
3952
+ const legacyRecallNamespaces = Array.isArray(config.defaultRecallNamespaces) ? recallNamespacesForPrincipal(principal, config) : [];
3953
+ return expandScopeProfileReadNamespaces({
3954
+ profilePlan,
3955
+ principalSelfNamespace: profilePlan.baseNamespace,
3956
+ config,
3957
+ principal,
3958
+ codingOverlay,
3959
+ legacyRecallNamespaces
3960
+ });
3961
+ }
3962
+ lcmSessionIdsForNamespaces(namespaces, sessionKey) {
3963
+ const out = [];
3964
+ const seen = /* @__PURE__ */ new Set();
3965
+ for (const namespace of namespaces) {
3966
+ const key = lcmSessionKeyForNamespace(
3967
+ namespace,
3968
+ sessionKey,
3969
+ this.orchestrator.config.defaultNamespace
3970
+ ) ?? sessionKey;
3971
+ if (!seen.has(key)) {
3972
+ seen.add(key);
3973
+ out.push(key);
3974
+ }
3975
+ }
3976
+ return out;
3977
+ }
3766
3978
  resolveLcmReadSessionIds(explicitNamespace, resolvedNamespace, sessionKey, authenticatedPrincipal) {
3767
3979
  const primary = this.resolveLcmReadSessionKey(
3768
3980
  explicitNamespace,
@@ -3773,6 +3985,13 @@ var EngramAccessService = class {
3773
3985
  );
3774
3986
  const hasExplicitNamespace = typeof explicitNamespace === "string" && explicitNamespace.trim().length > 0;
3775
3987
  if (hasExplicitNamespace) return [primary];
3988
+ const profileReadNamespaces = this.resolveScopeProfileLcmReadNamespaces(
3989
+ sessionKey,
3990
+ authenticatedPrincipal
3991
+ );
3992
+ if (profileReadNamespaces !== null) {
3993
+ return this.lcmSessionIdsForNamespaces(profileReadNamespaces, sessionKey);
3994
+ }
3776
3995
  const principal = this.resolveRequestPrincipal(
3777
3996
  sessionKey,
3778
3997
  authenticatedPrincipal
@@ -3819,7 +4038,7 @@ var EngramAccessService = class {
3819
4038
  throw new EngramAccessInputError("sessionKey is required and must be a non-empty string");
3820
4039
  }
3821
4040
  const scope = await this.resolveMemoryScopePlan(request);
3822
- const namespace = scope.explicitNamespace ? scope.writeNamespace : scope.codingOverlayApplied ? this.orchestrator.config.defaultNamespace : scope.writeNamespace;
4041
+ const namespace = this.legacyResponseNamespaceForScope(scope);
3823
4042
  if (!this.orchestrator.lcmEngine || !this.orchestrator.lcmEngine.enabled) {
3824
4043
  return {
3825
4044
  enabled: false,
@@ -3854,7 +4073,7 @@ var EngramAccessService = class {
3854
4073
  throw new EngramAccessInputError("tokensAfter must be a non-negative integer");
3855
4074
  }
3856
4075
  const scope = await this.resolveMemoryScopePlan(request);
3857
- const namespace = scope.explicitNamespace ? scope.writeNamespace : scope.codingOverlayApplied ? this.orchestrator.config.defaultNamespace : scope.writeNamespace;
4076
+ const namespace = this.legacyResponseNamespaceForScope(scope);
3858
4077
  if (!this.orchestrator.lcmEngine || !this.orchestrator.lcmEngine.enabled) {
3859
4078
  return {
3860
4079
  enabled: false,
@@ -5360,4 +5579,4 @@ export {
5360
5579
  shapeMemorySummary,
5361
5580
  EngramAccessService
5362
5581
  };
5363
- //# sourceMappingURL=chunk-LJCEWTG3.js.map
5582
+ //# sourceMappingURL=chunk-4UL7VPTD.js.map